@wise/dynamic-flow-client 1.12.0 → 2.0.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 +4 -0
- package/build/main.js +939 -539
- package/build/main.min.js +1 -1
- package/build/types/jsonSchemaForm/arrayTypeSchema/arrayListSchema/ArrayListSchema.d.ts +6 -6
- package/build/types/jsonSchemaForm/arrayTypeSchema/arrayListSchema/repeatableSchema/ItemSummary.d.ts +12 -0
- package/build/types/jsonSchemaForm/arrayTypeSchema/arrayListSchema/repeatableSchema/RepeatableSchema.d.ts +8 -0
- package/build/types/jsonSchemaForm/arrayTypeSchema/arrayListSchema/repeatableSchema/RepeatableSchema.messages.d.ts +23 -0
- package/build/types/jsonSchemaForm/arrayTypeSchema/arrayListSchema/repeatableSchema/RepeatableSchemaStep.d.ts +14 -0
- package/build/types/jsonSchemaForm/arrayTypeSchema/arrayListSchema/repeatableSchema/utils/summary-utils.d.ts +3 -0
- package/build/types/layout/utils/index.d.ts +2 -2
- package/package.json +2 -2
- /package/build/types/common/validators/models/{models.utils.d.ts → model-utils.d.ts} +0 -0
package/build/main.js
CHANGED
|
@@ -850,8 +850,8 @@ function isReference(block) {
|
|
|
850
850
|
}
|
|
851
851
|
|
|
852
852
|
// src/dynamicFlow/DynamicFlow.tsx
|
|
853
|
-
var
|
|
854
|
-
var
|
|
853
|
+
var import_react41 = require("react");
|
|
854
|
+
var import_react_intl32 = require("react-intl");
|
|
855
855
|
|
|
856
856
|
// src/common/contexts/dynamicFlowContexts/DynamicFlowContexts.tsx
|
|
857
857
|
var import_react2 = require("react");
|
|
@@ -914,7 +914,12 @@ function useEventDispatcher() {
|
|
|
914
914
|
const { triggerEvent } = (0, import_react3.useContext)(EventsContext);
|
|
915
915
|
return triggerEvent;
|
|
916
916
|
}
|
|
917
|
-
var getEventDispatcher = (onEvent, metadata) => (eventName, properties = {}) =>
|
|
917
|
+
var getEventDispatcher = (onEvent, metadata) => (eventName, properties = {}) => {
|
|
918
|
+
try {
|
|
919
|
+
onEvent(eventName, __spreadValues(__spreadValues({}, metadata), properties));
|
|
920
|
+
} catch (e) {
|
|
921
|
+
}
|
|
922
|
+
};
|
|
918
923
|
|
|
919
924
|
// src/common/contexts/httpClientContext/HttpClientContext.tsx
|
|
920
925
|
var import_react4 = require("react");
|
|
@@ -974,7 +979,15 @@ var useHasHttpClientProvider = () => {
|
|
|
974
979
|
// src/common/contexts/logContext/LogContext.tsx
|
|
975
980
|
var import_react5 = require("react");
|
|
976
981
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
977
|
-
var getLogger = (level, onLog, flowId = "UNKNOWN-FLOW-ID", stepId = "UNKNOWN-FLOW-ID") => (title, description, extra) =>
|
|
982
|
+
var getLogger = (level, onLog, flowId = "UNKNOWN-FLOW-ID", stepId = "UNKNOWN-FLOW-ID") => (title, description, extra) => {
|
|
983
|
+
try {
|
|
984
|
+
onLog(level, `Dynamic Flow ${level} - ${title} - ${description}`, __spreadValues({
|
|
985
|
+
flowId,
|
|
986
|
+
stepId
|
|
987
|
+
}, extra));
|
|
988
|
+
} catch (e) {
|
|
989
|
+
}
|
|
990
|
+
};
|
|
978
991
|
var LogContext = (0, import_react5.createContext)(null);
|
|
979
992
|
var LogProvider = ({ flowId, stepId, children, onLog }) => {
|
|
980
993
|
const value = (0, import_react5.useMemo)(
|
|
@@ -1014,7 +1027,7 @@ var isUndefined = (value) => typeof value === "undefined";
|
|
|
1014
1027
|
// src/common/validators/values/value-validators.ts
|
|
1015
1028
|
var isEmpty = (value) => isString(value) && value.length === 0 || (isObject(value) || isArray(value)) && Object.keys(value).length === 0;
|
|
1016
1029
|
|
|
1017
|
-
// src/common/validators/models/
|
|
1030
|
+
// src/common/validators/models/model-utils.ts
|
|
1018
1031
|
function cleanBasicModelWithOneOfSchema(model, schema) {
|
|
1019
1032
|
return schema.oneOf.some(
|
|
1020
1033
|
(nestedSchema) => getValidBasicModelOrNull(model, nestedSchema) === model
|
|
@@ -1059,7 +1072,7 @@ function cleanModelWithArraySchema(model, schema) {
|
|
|
1059
1072
|
return new Array(model.length).fill(null);
|
|
1060
1073
|
}
|
|
1061
1074
|
}
|
|
1062
|
-
return model.map((childModel) =>
|
|
1075
|
+
return model.map((childModel) => getValidModelParts(childModel, schema.items));
|
|
1063
1076
|
}
|
|
1064
1077
|
function cleanObjectModelWithObjectSchema(model, schema) {
|
|
1065
1078
|
return Object.keys(schema.properties).reduce((cleanedModel, property) => {
|
|
@@ -1368,6 +1381,9 @@ function isValidObjectSchema(value, schema) {
|
|
|
1368
1381
|
).every((property) => property);
|
|
1369
1382
|
}
|
|
1370
1383
|
function isObjectPropertyValid(propertyValue, propertySchema, isRequired) {
|
|
1384
|
+
if (propertySchema.hidden) {
|
|
1385
|
+
return true;
|
|
1386
|
+
}
|
|
1371
1387
|
if (typeof propertyValue === "undefined") {
|
|
1372
1388
|
return !isRequired;
|
|
1373
1389
|
}
|
|
@@ -1399,6 +1415,9 @@ function isValidBlobSchema(value, schema) {
|
|
|
1399
1415
|
return !getBlobValidationFailures(value, schema).length;
|
|
1400
1416
|
}
|
|
1401
1417
|
function isValidSchema(value, schema) {
|
|
1418
|
+
if (schema.hidden) {
|
|
1419
|
+
return true;
|
|
1420
|
+
}
|
|
1402
1421
|
if (schema.oneOf) {
|
|
1403
1422
|
return isValidOneOfSchema(value, schema);
|
|
1404
1423
|
}
|
|
@@ -1678,7 +1697,7 @@ var isArrayModel = (model) => {
|
|
|
1678
1697
|
return true;
|
|
1679
1698
|
}
|
|
1680
1699
|
return model.every(
|
|
1681
|
-
(item) => typeof item === "string" || typeof item === "number" || typeof item === "boolean"
|
|
1700
|
+
(item) => typeof item === "string" || typeof item === "number" || typeof item === "boolean" || typeof item === "object"
|
|
1682
1701
|
);
|
|
1683
1702
|
}
|
|
1684
1703
|
return false;
|
|
@@ -1774,8 +1793,8 @@ function useExternalStepPolling(polling, onAction) {
|
|
|
1774
1793
|
}
|
|
1775
1794
|
|
|
1776
1795
|
// src/common/hooks/usePersistAsync/usePersistAsync.ts
|
|
1777
|
-
var
|
|
1778
|
-
var
|
|
1796
|
+
var import_react29 = require("react");
|
|
1797
|
+
var import_react_intl21 = require("react-intl");
|
|
1779
1798
|
|
|
1780
1799
|
// src/jsonSchemaForm/persistAsyncSchema/PersistAsyncSchema.messages.js
|
|
1781
1800
|
var import_react_intl = require("react-intl");
|
|
@@ -1788,8 +1807,8 @@ var PersistAsyncSchema_messages_default = (0, import_react_intl.defineMessages)(
|
|
|
1788
1807
|
});
|
|
1789
1808
|
|
|
1790
1809
|
// src/jsonSchemaForm/persistAsyncSchema/persistAsyncBasicSchema/PersistAsyncBasicSchema.tsx
|
|
1791
|
-
var
|
|
1792
|
-
var
|
|
1810
|
+
var import_react28 = require("react");
|
|
1811
|
+
var import_react_intl20 = require("react-intl");
|
|
1793
1812
|
|
|
1794
1813
|
// src/common/constants/DateMode.ts
|
|
1795
1814
|
var DateMode = {
|
|
@@ -1833,7 +1852,7 @@ var Size = {
|
|
|
1833
1852
|
|
|
1834
1853
|
// src/jsonSchemaForm/basicTypeSchema/BasicTypeSchema.tsx
|
|
1835
1854
|
var import_classnames6 = __toESM(require_classnames());
|
|
1836
|
-
var
|
|
1855
|
+
var import_react27 = require("react");
|
|
1837
1856
|
|
|
1838
1857
|
// src/layout/alert/DynamicAlert.tsx
|
|
1839
1858
|
var import_components2 = require("@transferwise/components");
|
|
@@ -2097,18 +2116,18 @@ var getNavigationOptionMedia = ({ icon, image }) => {
|
|
|
2097
2116
|
};
|
|
2098
2117
|
|
|
2099
2118
|
// src/layout/utils/index.ts
|
|
2100
|
-
var
|
|
2119
|
+
var getMargin = (size) => {
|
|
2101
2120
|
switch (size) {
|
|
2102
2121
|
case "xs":
|
|
2103
|
-
return "m-
|
|
2122
|
+
return "m-t-0";
|
|
2104
2123
|
case "sm":
|
|
2105
|
-
return "m-
|
|
2124
|
+
return "m-t-1";
|
|
2106
2125
|
case "md":
|
|
2107
|
-
return "m-
|
|
2126
|
+
return "m-t-2";
|
|
2108
2127
|
case "lg":
|
|
2109
|
-
return "m-
|
|
2128
|
+
return "m-t-3";
|
|
2110
2129
|
case "xl":
|
|
2111
|
-
return "m-
|
|
2130
|
+
return "m-t-5";
|
|
2112
2131
|
default:
|
|
2113
2132
|
return "";
|
|
2114
2133
|
}
|
|
@@ -2124,7 +2143,7 @@ var getTextAlignment = (align) => {
|
|
|
2124
2143
|
return "";
|
|
2125
2144
|
}
|
|
2126
2145
|
};
|
|
2127
|
-
var getTextAlignmentAndMargin = (component) => `${getTextAlignment(component.align)} ${
|
|
2146
|
+
var getTextAlignmentAndMargin = (component) => `${getTextAlignment(component.align)} ${getMargin(component.margin)}`;
|
|
2128
2147
|
|
|
2129
2148
|
// src/layout/alert/DynamicAlert.tsx
|
|
2130
2149
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
@@ -2134,7 +2153,7 @@ var DynamicAlert = (props) => {
|
|
|
2134
2153
|
import_components2.Alert,
|
|
2135
2154
|
{
|
|
2136
2155
|
type: mapContextToAlertType(legacy_mapContext(alert.context)),
|
|
2137
|
-
className:
|
|
2156
|
+
className: getMargin(alert.margin),
|
|
2138
2157
|
message: alert.markdown
|
|
2139
2158
|
}
|
|
2140
2159
|
);
|
|
@@ -2166,7 +2185,7 @@ var DynamicAlert_default = DynamicAlert;
|
|
|
2166
2185
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
2167
2186
|
var DynamicBox = (props) => {
|
|
2168
2187
|
const box = props.component;
|
|
2169
|
-
const margin =
|
|
2188
|
+
const margin = getMargin(box.margin || box.border ? "lg" : "xs");
|
|
2170
2189
|
if (!box.width || box.width === "xl") {
|
|
2171
2190
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: margin + getBorderClass(box.border), children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
2172
2191
|
DynamicLayout_default,
|
|
@@ -2266,7 +2285,7 @@ var DynamicButton = (props) => {
|
|
|
2266
2285
|
const type = getButtonType(component);
|
|
2267
2286
|
const priority = getButtonPriority(component);
|
|
2268
2287
|
const { loading } = useDynamicFlow();
|
|
2269
|
-
const className =
|
|
2288
|
+
const className = getMargin(component.margin || "md");
|
|
2270
2289
|
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2271
2290
|
import_components3.Button,
|
|
2272
2291
|
{
|
|
@@ -2288,7 +2307,7 @@ var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
|
2288
2307
|
var DynamicColumns = (props) => {
|
|
2289
2308
|
const columns = props.component;
|
|
2290
2309
|
const { leftWidth, rightWidth } = getWidth(columns.bias);
|
|
2291
|
-
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: `${
|
|
2310
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: `${getMargin(columns.margin || "xs")} row`, children: [
|
|
2292
2311
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: `${leftWidth} m-b-0`, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2293
2312
|
DynamicLayout_default,
|
|
2294
2313
|
{
|
|
@@ -2338,7 +2357,7 @@ var DynamicColumns_default = DynamicColumns;
|
|
|
2338
2357
|
// src/layout/decision/DynamicDecision.tsx
|
|
2339
2358
|
var import_components4 = require("@transferwise/components");
|
|
2340
2359
|
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
2341
|
-
var DynamicDecision = ({ component, onAction }) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className:
|
|
2360
|
+
var DynamicDecision = ({ component, onAction }) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getMargin(component.margin), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_components4.NavigationOptionsList, { children: component.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2342
2361
|
import_components4.NavigationOption,
|
|
2343
2362
|
{
|
|
2344
2363
|
title: option.title,
|
|
@@ -2356,7 +2375,7 @@ var DynamicDecision_default = DynamicDecision;
|
|
|
2356
2375
|
// src/layout/divider/DynamicDivider.tsx
|
|
2357
2376
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
2358
2377
|
var DynamicDivider = ({ component }) => {
|
|
2359
|
-
const margin =
|
|
2378
|
+
const margin = getMargin(component.margin);
|
|
2360
2379
|
const className = `m-t-0 ${margin}`;
|
|
2361
2380
|
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("hr", { className });
|
|
2362
2381
|
};
|
|
@@ -2402,7 +2421,7 @@ var DynamicExternal = ({ component, onAction }) => {
|
|
|
2402
2421
|
var DynamicExternal_default = DynamicExternal;
|
|
2403
2422
|
|
|
2404
2423
|
// src/jsonSchemaForm/genericSchema/GenericSchema.tsx
|
|
2405
|
-
var
|
|
2424
|
+
var import_react21 = require("react");
|
|
2406
2425
|
|
|
2407
2426
|
// src/jsonSchemaForm/allOfSchema/AllOfSchema.tsx
|
|
2408
2427
|
var import_classnames = __toESM(require_classnames());
|
|
@@ -2784,14 +2803,418 @@ function getValidationMessages(schema, required, defaultErrorMessages) {
|
|
|
2784
2803
|
return __spreadValues(__spreadValues(__spreadValues({}, required && { required: defaultErrorMessages.requiredMessage }), minItems && { minItems: defaultErrorMessages.minItemsErrorMessage }), maxItems && { maxItems: defaultErrorMessages.maxItemsErrorMessage });
|
|
2785
2804
|
}
|
|
2786
2805
|
|
|
2787
|
-
// src/jsonSchemaForm/arrayTypeSchema/arrayListSchema/
|
|
2806
|
+
// src/jsonSchemaForm/arrayTypeSchema/arrayListSchema/repeatableSchema/RepeatableSchema.tsx
|
|
2807
|
+
var import_components9 = require("@transferwise/components");
|
|
2808
|
+
var import_icons = require("@transferwise/icons");
|
|
2809
|
+
var import_react12 = require("react");
|
|
2810
|
+
var import_react_intl11 = require("react-intl");
|
|
2811
|
+
|
|
2812
|
+
// src/jsonSchemaForm/arrayTypeSchema/arrayListSchema/repeatableSchema/ItemSummary.tsx
|
|
2813
|
+
var import_components8 = require("@transferwise/components");
|
|
2788
2814
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
2815
|
+
var ItemSummaryOption = ({
|
|
2816
|
+
item,
|
|
2817
|
+
onClick
|
|
2818
|
+
}) => {
|
|
2819
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
2820
|
+
import_components8.NavigationOption,
|
|
2821
|
+
{
|
|
2822
|
+
onClick,
|
|
2823
|
+
media: getNavigationOptionMedia(item),
|
|
2824
|
+
title: item.title,
|
|
2825
|
+
content: item.description
|
|
2826
|
+
}
|
|
2827
|
+
);
|
|
2828
|
+
};
|
|
2829
|
+
|
|
2830
|
+
// src/jsonSchemaForm/arrayTypeSchema/arrayListSchema/repeatableSchema/RepeatableSchema.messages.ts
|
|
2831
|
+
var import_react_intl9 = require("react-intl");
|
|
2832
|
+
var RepeatableSchema_messages_default = (0, import_react_intl9.defineMessages)({
|
|
2833
|
+
addItemTitle: {
|
|
2834
|
+
id: "dynamicFlows.ArraySchema.addItemTitle",
|
|
2835
|
+
defaultMessage: "Add Item",
|
|
2836
|
+
description: "Label on the button used to open a form to add an item"
|
|
2837
|
+
},
|
|
2838
|
+
addItem: {
|
|
2839
|
+
id: "dynamicFlows.ArraySchema.addItem",
|
|
2840
|
+
defaultMessage: "Save",
|
|
2841
|
+
description: "Label on the add button used to submit a form that adds an item"
|
|
2842
|
+
},
|
|
2843
|
+
editItem: {
|
|
2844
|
+
id: "dynamicFlows.ArraySchema.editItem",
|
|
2845
|
+
defaultMessage: "Save",
|
|
2846
|
+
description: "Label on the edit button used to submit a form that edits an item"
|
|
2847
|
+
},
|
|
2848
|
+
removeItem: {
|
|
2849
|
+
id: "dynamicFlows.ArraySchema.removeItem",
|
|
2850
|
+
defaultMessage: "Remove",
|
|
2851
|
+
description: "Label on the remove button used to confirm deletion of an item"
|
|
2852
|
+
}
|
|
2853
|
+
});
|
|
2854
|
+
|
|
2855
|
+
// src/jsonSchemaForm/arrayTypeSchema/arrayListSchema/repeatableSchema/RepeatableSchemaStep.tsx
|
|
2856
|
+
var import_react_intl10 = require("react-intl");
|
|
2857
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
2858
|
+
var RepeatableSchemaStep = ({
|
|
2859
|
+
type,
|
|
2860
|
+
schema,
|
|
2861
|
+
model,
|
|
2862
|
+
errors,
|
|
2863
|
+
submitted,
|
|
2864
|
+
onModelChange,
|
|
2865
|
+
onAction
|
|
2866
|
+
}) => {
|
|
2867
|
+
const { formatMessage } = (0, import_react_intl10.useIntl)();
|
|
2868
|
+
const step = {
|
|
2869
|
+
layout: [
|
|
2870
|
+
{
|
|
2871
|
+
type: "form",
|
|
2872
|
+
schema: schema.items
|
|
2873
|
+
},
|
|
2874
|
+
{
|
|
2875
|
+
type: "button",
|
|
2876
|
+
control: "primary",
|
|
2877
|
+
action: {
|
|
2878
|
+
url: type,
|
|
2879
|
+
title: formatMessage(type === "add" ? RepeatableSchema_messages_default.addItem : RepeatableSchema_messages_default.editItem)
|
|
2880
|
+
}
|
|
2881
|
+
},
|
|
2882
|
+
{
|
|
2883
|
+
type: "button",
|
|
2884
|
+
context: "negative",
|
|
2885
|
+
action: {
|
|
2886
|
+
url: "remove",
|
|
2887
|
+
title: formatMessage(RepeatableSchema_messages_default.removeItem)
|
|
2888
|
+
}
|
|
2889
|
+
}
|
|
2890
|
+
],
|
|
2891
|
+
title: "",
|
|
2892
|
+
actions: [],
|
|
2893
|
+
schemas: []
|
|
2894
|
+
};
|
|
2895
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2896
|
+
DynamicFlowStep,
|
|
2897
|
+
{
|
|
2898
|
+
step,
|
|
2899
|
+
model,
|
|
2900
|
+
stepLayoutOptions: { displayStepTitle: false },
|
|
2901
|
+
submitted,
|
|
2902
|
+
formErrors: errors,
|
|
2903
|
+
globalError: null,
|
|
2904
|
+
onAction: (action) => {
|
|
2905
|
+
onAction(action.url);
|
|
2906
|
+
},
|
|
2907
|
+
onModelChange
|
|
2908
|
+
}
|
|
2909
|
+
);
|
|
2910
|
+
};
|
|
2911
|
+
var RepeatableSchemaStep_default = RepeatableSchemaStep;
|
|
2912
|
+
|
|
2913
|
+
// src/jsonSchemaForm/oneOfSchema/utils.ts
|
|
2914
|
+
var getActiveSchemaIndex = (schema, model) => {
|
|
2915
|
+
const indexFromModel = getValidIndexFromValue(schema, model);
|
|
2916
|
+
if (indexFromModel >= 0) {
|
|
2917
|
+
return indexFromModel;
|
|
2918
|
+
}
|
|
2919
|
+
if (schema.oneOf.length === 1 && isNoNConstSchema(schema.oneOf[0])) {
|
|
2920
|
+
return 0;
|
|
2921
|
+
}
|
|
2922
|
+
if (isConstSchema(schema.oneOf[0])) {
|
|
2923
|
+
const indexFromDefault = getValidIndexFromValue(schema, schema.default);
|
|
2924
|
+
if (indexFromDefault >= 0) {
|
|
2925
|
+
return indexFromDefault;
|
|
2926
|
+
}
|
|
2927
|
+
}
|
|
2928
|
+
if (isOneOfObjectSchema(schema) && isObjectModel(model) && Object.keys(model).length >= 1) {
|
|
2929
|
+
return getBestMatchingSchemaIndexForValue(schema, model);
|
|
2930
|
+
}
|
|
2931
|
+
if (isOneOfObjectSchema(schema) && !isUndefined(schema.default) && isObjectModel(schema.default) && Object.keys(schema.default).length >= 1) {
|
|
2932
|
+
return getBestMatchingSchemaIndexForValue(schema, schema.default);
|
|
2933
|
+
}
|
|
2934
|
+
return null;
|
|
2935
|
+
};
|
|
2936
|
+
var getValidIndexFromValue = (schema, value) => {
|
|
2937
|
+
return schema.oneOf.findIndex(
|
|
2938
|
+
(childSchema) => !isUndefined(value) && isValidSchema(value, childSchema)
|
|
2939
|
+
);
|
|
2940
|
+
};
|
|
2941
|
+
function getBestMatchingSchemaIndexForValue(schema, value) {
|
|
2942
|
+
if (value === null || value === void 0) {
|
|
2943
|
+
return null;
|
|
2944
|
+
}
|
|
2945
|
+
const schemaPoints = schema.oneOf.map((childSchema) => {
|
|
2946
|
+
return getSchemaProperties(childSchema).reduce((total, [key, propertySchema]) => {
|
|
2947
|
+
if (isConstSchema(propertySchema) && propertySchema.const === value[key]) {
|
|
2948
|
+
return total + 2;
|
|
2949
|
+
} else if (isNoNConstSchema(propertySchema) && typeof value[key] !== "undefined") {
|
|
2950
|
+
return total + 1;
|
|
2951
|
+
}
|
|
2952
|
+
return total;
|
|
2953
|
+
}, 0);
|
|
2954
|
+
});
|
|
2955
|
+
if (schemaPoints.every((p) => p === schemaPoints[0])) {
|
|
2956
|
+
return null;
|
|
2957
|
+
}
|
|
2958
|
+
return schemaPoints.indexOf(Math.max(...schemaPoints));
|
|
2959
|
+
}
|
|
2960
|
+
function getSchemaProperties(childSchema) {
|
|
2961
|
+
return childSchema.properties !== null && typeof childSchema.properties === "object" ? Object.entries(childSchema.properties) : [];
|
|
2962
|
+
}
|
|
2963
|
+
|
|
2964
|
+
// src/jsonSchemaForm/arrayTypeSchema/arrayListSchema/repeatableSchema/utils/summary-utils.ts
|
|
2965
|
+
var getItemSummaryFromSchema = (schema, model, defaults = {}) => {
|
|
2966
|
+
const { defaultTitle = "", defaultDescription = "", defaultIcon, defaultImage } = defaults;
|
|
2967
|
+
const title = getSummaryPropFromSchema({
|
|
2968
|
+
schema,
|
|
2969
|
+
model,
|
|
2970
|
+
providesProp: "providesTitle",
|
|
2971
|
+
getValueFromSchema: getStringValueFromSchema
|
|
2972
|
+
});
|
|
2973
|
+
const description = getSummaryPropFromSchema({
|
|
2974
|
+
schema,
|
|
2975
|
+
model,
|
|
2976
|
+
providesProp: "providesDescription",
|
|
2977
|
+
getValueFromSchema: getStringValueFromSchema
|
|
2978
|
+
});
|
|
2979
|
+
const icon = getSummaryPropFromSchema({
|
|
2980
|
+
schema,
|
|
2981
|
+
model,
|
|
2982
|
+
providesProp: "providesIcon",
|
|
2983
|
+
getValueFromSchema: (schema2) => {
|
|
2984
|
+
var _a;
|
|
2985
|
+
return (_a = schema2.icon) != null ? _a : null;
|
|
2986
|
+
}
|
|
2987
|
+
});
|
|
2988
|
+
const image = getSummaryPropFromSchema({
|
|
2989
|
+
schema,
|
|
2990
|
+
model,
|
|
2991
|
+
providesProp: "providesImage",
|
|
2992
|
+
getValueFromSchema: (schema2) => {
|
|
2993
|
+
var _a;
|
|
2994
|
+
return (_a = schema2.image) != null ? _a : null;
|
|
2995
|
+
}
|
|
2996
|
+
});
|
|
2997
|
+
return {
|
|
2998
|
+
value: model,
|
|
2999
|
+
title: title || defaultTitle,
|
|
3000
|
+
description: description || defaultDescription,
|
|
3001
|
+
icon: icon || defaultIcon,
|
|
3002
|
+
image: image || defaultImage
|
|
3003
|
+
};
|
|
3004
|
+
};
|
|
3005
|
+
var getSummaryPropFromSchema = (props) => {
|
|
3006
|
+
const { schema, model, providesProp, getValueFromSchema } = props;
|
|
3007
|
+
if (schemaSummaryProvides(schema.summary, providesProp)) {
|
|
3008
|
+
return getValueFromSchema(schema, model);
|
|
3009
|
+
}
|
|
3010
|
+
const type = getSchemaType(schema);
|
|
3011
|
+
switch (type) {
|
|
3012
|
+
case "object": {
|
|
3013
|
+
return getObjectValueFromSchema(props);
|
|
3014
|
+
}
|
|
3015
|
+
case "oneOf": {
|
|
3016
|
+
return getOneOfValueFromSchema(props);
|
|
3017
|
+
}
|
|
3018
|
+
case "allOf": {
|
|
3019
|
+
return getAllOfValueFromSchema(props);
|
|
3020
|
+
}
|
|
3021
|
+
default:
|
|
3022
|
+
return null;
|
|
3023
|
+
}
|
|
3024
|
+
};
|
|
3025
|
+
var getObjectValueFromSchema = (props) => {
|
|
3026
|
+
const { schema, model } = props;
|
|
3027
|
+
const objectSchema = schema;
|
|
3028
|
+
for (const propertyKey in objectSchema.properties) {
|
|
3029
|
+
const propertySchema = objectSchema.properties[propertyKey];
|
|
3030
|
+
const propertyModel = isObjectModel(model) && propertyKey in model ? model[propertyKey] : null;
|
|
3031
|
+
const result = getSummaryPropFromSchema(__spreadProps(__spreadValues({}, props), {
|
|
3032
|
+
schema: propertySchema,
|
|
3033
|
+
model: propertyModel
|
|
3034
|
+
}));
|
|
3035
|
+
if (result) {
|
|
3036
|
+
return result;
|
|
3037
|
+
}
|
|
3038
|
+
}
|
|
3039
|
+
return null;
|
|
3040
|
+
};
|
|
3041
|
+
var getOneOfValueFromSchema = (props) => {
|
|
3042
|
+
const { schema, model } = props;
|
|
3043
|
+
if (isOneOfObjectSchema(schema)) {
|
|
3044
|
+
if (!isObjectModel(model)) {
|
|
3045
|
+
return null;
|
|
3046
|
+
}
|
|
3047
|
+
const activeSchemaIndex2 = getBestMatchingSchemaIndexForValue(schema, model);
|
|
3048
|
+
if (activeSchemaIndex2 === null || activeSchemaIndex2 < 0) {
|
|
3049
|
+
return null;
|
|
3050
|
+
}
|
|
3051
|
+
const activeSchema = schema.oneOf[activeSchemaIndex2];
|
|
3052
|
+
return getSummaryPropFromSchema(__spreadProps(__spreadValues({}, props), {
|
|
3053
|
+
schema: activeSchema
|
|
3054
|
+
}));
|
|
3055
|
+
}
|
|
3056
|
+
const oneOfSchema = schema;
|
|
3057
|
+
const activeSchemaIndex = getActiveSchemaIndex(oneOfSchema, model);
|
|
3058
|
+
if (activeSchemaIndex === null || activeSchemaIndex < 0) {
|
|
3059
|
+
return null;
|
|
3060
|
+
}
|
|
3061
|
+
return getSummaryPropFromSchema(__spreadProps(__spreadValues({}, props), {
|
|
3062
|
+
schema: oneOfSchema.oneOf[activeSchemaIndex]
|
|
3063
|
+
}));
|
|
3064
|
+
};
|
|
3065
|
+
var getAllOfValueFromSchema = (props) => {
|
|
3066
|
+
const { schema } = props;
|
|
3067
|
+
const allOfSchema = schema;
|
|
3068
|
+
for (const childSchema of allOfSchema.allOf) {
|
|
3069
|
+
const result = getSummaryPropFromSchema(__spreadProps(__spreadValues({}, props), {
|
|
3070
|
+
schema: childSchema
|
|
3071
|
+
}));
|
|
3072
|
+
if (result) {
|
|
3073
|
+
return result;
|
|
3074
|
+
}
|
|
3075
|
+
}
|
|
3076
|
+
return null;
|
|
3077
|
+
};
|
|
3078
|
+
var getStringValueFromSchema = (schema, model) => {
|
|
3079
|
+
if (isConstSchema(schema)) {
|
|
3080
|
+
if (schema.title) {
|
|
3081
|
+
return schema.title;
|
|
3082
|
+
}
|
|
3083
|
+
if (isString(schema.const)) {
|
|
3084
|
+
return schema.const;
|
|
3085
|
+
}
|
|
3086
|
+
return null;
|
|
3087
|
+
}
|
|
3088
|
+
return isNullableStringModel(model) ? model : null;
|
|
3089
|
+
};
|
|
3090
|
+
var schemaSummaryProvides = (summary, providesProp) => !!summary && Object.hasOwnProperty.call(summary, providesProp) && Boolean(summary[providesProp]);
|
|
3091
|
+
|
|
3092
|
+
// src/jsonSchemaForm/arrayTypeSchema/arrayListSchema/repeatableSchema/RepeatableSchema.tsx
|
|
3093
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
3094
|
+
var RepeatableSchema = ({
|
|
3095
|
+
schema,
|
|
3096
|
+
model,
|
|
3097
|
+
errors,
|
|
3098
|
+
submitted,
|
|
3099
|
+
onChange
|
|
3100
|
+
}) => {
|
|
3101
|
+
const [openModalType, setOpenModalType] = (0, import_react12.useState)(null);
|
|
3102
|
+
const [itemSummaries, setItemSummaries] = (0, import_react12.useState)(() => {
|
|
3103
|
+
if (isObject(model) && !isArray(model)) {
|
|
3104
|
+
throw new Error(
|
|
3105
|
+
"RepeatableSchema does not support object models. Ensure your array schema is wrapped inside an object schema."
|
|
3106
|
+
);
|
|
3107
|
+
}
|
|
3108
|
+
return model ? model.map((item) => getItemSummaryFromSchema(schema.items, item, schema == null ? void 0 : schema.summary)) : null;
|
|
3109
|
+
});
|
|
3110
|
+
const [editableItem, setEditableItem] = (0, import_react12.useState)({ item: null, model: null });
|
|
3111
|
+
const broadcastModelChange = (updatedItems) => {
|
|
3112
|
+
const updatedModel = updatedItems ? updatedItems.map(({ value }) => value) : null;
|
|
3113
|
+
onChange({
|
|
3114
|
+
model: updatedModel,
|
|
3115
|
+
triggerSchema: schema.items,
|
|
3116
|
+
triggerModel: updatedModel
|
|
3117
|
+
});
|
|
3118
|
+
};
|
|
3119
|
+
const onAddItem = () => {
|
|
3120
|
+
setOpenModalType("add");
|
|
3121
|
+
};
|
|
3122
|
+
const onEditItem = (item) => {
|
|
3123
|
+
setEditableItem({ item, model: item.value });
|
|
3124
|
+
setOpenModalType("edit");
|
|
3125
|
+
};
|
|
3126
|
+
const onSaveItem = (action) => {
|
|
3127
|
+
const updatedItem = action === "remove" ? null : getItemSummaryFromSchema(schema.items, editableItem.model, schema == null ? void 0 : schema.summary);
|
|
3128
|
+
const updatedItemSummaries = getUpdatedItemSummaries(action, {
|
|
3129
|
+
originalItem: editableItem.item,
|
|
3130
|
+
updatedItem,
|
|
3131
|
+
itemSummaries
|
|
3132
|
+
});
|
|
3133
|
+
setItemSummaries(updatedItemSummaries);
|
|
3134
|
+
broadcastModelChange(updatedItemSummaries);
|
|
3135
|
+
setEditableItem({ item: null, model: null });
|
|
3136
|
+
setOpenModalType(null);
|
|
3137
|
+
};
|
|
3138
|
+
const onCancelEdit = () => {
|
|
3139
|
+
setEditableItem({ item: null, model: null });
|
|
3140
|
+
setOpenModalType(null);
|
|
3141
|
+
};
|
|
3142
|
+
const { formatMessage } = (0, import_react_intl11.useIntl)();
|
|
3143
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(import_jsx_runtime21.Fragment, { children: [
|
|
3144
|
+
schema.title && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_components9.Header, { title: schema.title }),
|
|
3145
|
+
itemSummaries && itemSummaries.map((itemSummary) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
3146
|
+
ItemSummaryOption,
|
|
3147
|
+
{
|
|
3148
|
+
item: itemSummary,
|
|
3149
|
+
onClick: () => onEditItem(itemSummary)
|
|
3150
|
+
},
|
|
3151
|
+
JSON.stringify(itemSummary)
|
|
3152
|
+
)),
|
|
3153
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
3154
|
+
import_components9.NavigationOption,
|
|
3155
|
+
{
|
|
3156
|
+
onClick: onAddItem,
|
|
3157
|
+
media: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_icons.Plus, {}),
|
|
3158
|
+
title: schema.addItemTitle || formatMessage(RepeatableSchema_messages_default.addItemTitle)
|
|
3159
|
+
}
|
|
3160
|
+
),
|
|
3161
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
3162
|
+
import_components9.Modal,
|
|
3163
|
+
{
|
|
3164
|
+
open: openModalType !== null,
|
|
3165
|
+
onClose: onCancelEdit,
|
|
3166
|
+
title: (openModalType === "add" ? schema.addItemTitle : schema.editItemTitle) || formatMessage(RepeatableSchema_messages_default.addItemTitle),
|
|
3167
|
+
body: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
3168
|
+
RepeatableSchemaStep_default,
|
|
3169
|
+
{
|
|
3170
|
+
type: openModalType != null ? openModalType : "add",
|
|
3171
|
+
schema,
|
|
3172
|
+
model: editableItem.model,
|
|
3173
|
+
errors,
|
|
3174
|
+
submitted,
|
|
3175
|
+
onAction: onSaveItem,
|
|
3176
|
+
onModelChange: ({ model: model2 }) => setEditableItem(__spreadProps(__spreadValues({}, editableItem), { model: model2 }))
|
|
3177
|
+
}
|
|
3178
|
+
)
|
|
3179
|
+
}
|
|
3180
|
+
)
|
|
3181
|
+
] });
|
|
3182
|
+
};
|
|
3183
|
+
var getUpdatedItemSummaries = (action, {
|
|
3184
|
+
originalItem,
|
|
3185
|
+
updatedItem,
|
|
3186
|
+
itemSummaries
|
|
3187
|
+
}) => {
|
|
3188
|
+
if (action === "remove") {
|
|
3189
|
+
return (itemSummaries || []).filter((itemSummary) => itemSummary !== originalItem);
|
|
3190
|
+
}
|
|
3191
|
+
if (!updatedItem) {
|
|
3192
|
+
return itemSummaries;
|
|
3193
|
+
}
|
|
3194
|
+
switch (action) {
|
|
3195
|
+
case "add":
|
|
3196
|
+
return [...itemSummaries || [], updatedItem];
|
|
3197
|
+
case "edit":
|
|
3198
|
+
return (itemSummaries || []).map(
|
|
3199
|
+
(itemSummary) => itemSummary === originalItem ? updatedItem : itemSummary
|
|
3200
|
+
);
|
|
3201
|
+
default:
|
|
3202
|
+
return null;
|
|
3203
|
+
}
|
|
3204
|
+
};
|
|
3205
|
+
var RepeatableSchema_default = RepeatableSchema;
|
|
3206
|
+
|
|
3207
|
+
// src/jsonSchemaForm/arrayTypeSchema/arrayListSchema/ArrayListSchema.tsx
|
|
3208
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
2789
3209
|
var ArrayListSchema = (props) => {
|
|
2790
3210
|
const { schema } = props;
|
|
2791
3211
|
if (isMultipleFileUploadSchema(schema)) {
|
|
2792
|
-
return /* @__PURE__ */ (0,
|
|
3212
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(MultipleFileUploadSchema_default, __spreadProps(__spreadValues({}, props), { schema }));
|
|
2793
3213
|
}
|
|
2794
|
-
|
|
3214
|
+
if (isListArraySchema(schema)) {
|
|
3215
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(RepeatableSchema_default, __spreadProps(__spreadValues({}, props), { schema }));
|
|
3216
|
+
}
|
|
3217
|
+
throw new Error("Invalid array list schema");
|
|
2795
3218
|
};
|
|
2796
3219
|
ArrayListSchema.defaultProps = {
|
|
2797
3220
|
errors: null,
|
|
@@ -2800,11 +3223,11 @@ ArrayListSchema.defaultProps = {
|
|
|
2800
3223
|
var ArrayListSchema_default = ArrayListSchema;
|
|
2801
3224
|
|
|
2802
3225
|
// src/jsonSchemaForm/arrayTypeSchema/ArraySchema.tsx
|
|
2803
|
-
var
|
|
3226
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
2804
3227
|
var ArraySchema = (props) => {
|
|
2805
3228
|
const { schema } = props;
|
|
2806
3229
|
if (isListArraySchema(schema)) {
|
|
2807
|
-
return /* @__PURE__ */ (0,
|
|
3230
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ArrayListSchema_default, __spreadValues({}, props));
|
|
2808
3231
|
}
|
|
2809
3232
|
throw new Error("Not implemented");
|
|
2810
3233
|
};
|
|
@@ -2815,8 +3238,8 @@ var ArraySchema_default = ArraySchema;
|
|
|
2815
3238
|
|
|
2816
3239
|
// src/jsonSchemaForm/objectSchema/ObjectSchema.tsx
|
|
2817
3240
|
var import_classnames3 = __toESM(require_classnames());
|
|
2818
|
-
var
|
|
2819
|
-
var
|
|
3241
|
+
var import_react13 = require("react");
|
|
3242
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
2820
3243
|
var getSchemaColumnClasses2 = (width) => {
|
|
2821
3244
|
return {
|
|
2822
3245
|
"col-xs-12": true,
|
|
@@ -2825,7 +3248,7 @@ var getSchemaColumnClasses2 = (width) => {
|
|
|
2825
3248
|
};
|
|
2826
3249
|
};
|
|
2827
3250
|
var ObjectSchema = (props) => {
|
|
2828
|
-
const [model, setModel] = (0,
|
|
3251
|
+
const [model, setModel] = (0, import_react13.useState)(() => __spreadValues({}, getValidObjectModelParts(props.model, props.schema)));
|
|
2829
3252
|
const onChangeProperty = (propertyName, onChangeProps) => {
|
|
2830
3253
|
if (onChangeProps.model !== null) {
|
|
2831
3254
|
model[propertyName] = onChangeProps.model;
|
|
@@ -2836,7 +3259,7 @@ var ObjectSchema = (props) => {
|
|
|
2836
3259
|
props.onChange(__spreadProps(__spreadValues({}, onChangeProps), { model }));
|
|
2837
3260
|
};
|
|
2838
3261
|
const isRequired = (propertyName) => props.schema.required && props.schema.required.includes(propertyName);
|
|
2839
|
-
(0,
|
|
3262
|
+
(0, import_react13.useEffect)(() => {
|
|
2840
3263
|
const newModel = getValidObjectModelParts(model, props.schema) || {};
|
|
2841
3264
|
setModel(newModel);
|
|
2842
3265
|
if (!isEqual(newModel, model)) {
|
|
@@ -2854,25 +3277,25 @@ var ObjectSchema = (props) => {
|
|
|
2854
3277
|
const isPropertyDefined = (propertyName) => typeof props.schema.properties[propertyName] !== "undefined";
|
|
2855
3278
|
const orderedPropertyNames = Array.from(allorderedPropertiesSet).filter(isPropertyDefined);
|
|
2856
3279
|
const propsErrors = props.errors;
|
|
2857
|
-
return /* @__PURE__ */ (0,
|
|
2858
|
-
props.schema.title && !props.hideTitle && /* @__PURE__ */ (0,
|
|
3280
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("fieldset", { children: [
|
|
3281
|
+
props.schema.title && !props.hideTitle && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("legend", { children: [
|
|
2859
3282
|
" ",
|
|
2860
3283
|
props.schema.title,
|
|
2861
3284
|
" "
|
|
2862
3285
|
] }),
|
|
2863
|
-
props.schema.description && !props.hideTitle && /* @__PURE__ */ (0,
|
|
3286
|
+
props.schema.description && !props.hideTitle && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("p", { children: [
|
|
2864
3287
|
" ",
|
|
2865
3288
|
props.schema.description,
|
|
2866
3289
|
" "
|
|
2867
3290
|
] }),
|
|
2868
|
-
props.schema.alert && /* @__PURE__ */ (0,
|
|
2869
|
-
/* @__PURE__ */ (0,
|
|
3291
|
+
props.schema.alert && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DynamicAlert_default, { component: props.schema.alert }),
|
|
3292
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "row", children: orderedPropertyNames.map((propertyName) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2870
3293
|
"div",
|
|
2871
3294
|
{
|
|
2872
3295
|
className: (0, import_classnames3.default)(
|
|
2873
3296
|
getSchemaColumnClasses2(props.schema.properties[propertyName].width)
|
|
2874
3297
|
),
|
|
2875
|
-
children: /* @__PURE__ */ (0,
|
|
3298
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2876
3299
|
GenericSchema_default,
|
|
2877
3300
|
{
|
|
2878
3301
|
schema: props.schema.properties[propertyName],
|
|
@@ -2898,15 +3321,15 @@ var ObjectSchema_default = ObjectSchema;
|
|
|
2898
3321
|
|
|
2899
3322
|
// src/jsonSchemaForm/oneOfSchema/OneOfSchema.tsx
|
|
2900
3323
|
var import_classnames4 = __toESM(require_classnames());
|
|
2901
|
-
var
|
|
3324
|
+
var import_react16 = require("react");
|
|
2902
3325
|
|
|
2903
3326
|
// src/jsonSchemaForm/help/Help.tsx
|
|
2904
|
-
var
|
|
2905
|
-
var
|
|
3327
|
+
var import_components10 = require("@transferwise/components");
|
|
3328
|
+
var import_react_intl13 = require("react-intl");
|
|
2906
3329
|
|
|
2907
3330
|
// src/jsonSchemaForm/help/Help.messages.js
|
|
2908
|
-
var
|
|
2909
|
-
var Help_messages_default = (0,
|
|
3331
|
+
var import_react_intl12 = require("react-intl");
|
|
3332
|
+
var Help_messages_default = (0, import_react_intl12.defineMessages)({
|
|
2910
3333
|
helpAria: {
|
|
2911
3334
|
id: "dynamicFlows.Help.ariaLabel",
|
|
2912
3335
|
defaultMessage: "Click here for more info.",
|
|
@@ -2915,14 +3338,14 @@ var Help_messages_default = (0, import_react_intl9.defineMessages)({
|
|
|
2915
3338
|
});
|
|
2916
3339
|
|
|
2917
3340
|
// src/jsonSchemaForm/help/Help.tsx
|
|
2918
|
-
var
|
|
3341
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
2919
3342
|
var Help = (props) => {
|
|
2920
|
-
const intl = (0,
|
|
2921
|
-
return /* @__PURE__ */ (0,
|
|
2922
|
-
|
|
3343
|
+
const intl = (0, import_react_intl13.useIntl)();
|
|
3344
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3345
|
+
import_components10.Info,
|
|
2923
3346
|
{
|
|
2924
3347
|
className: "m-l-1",
|
|
2925
|
-
content: /* @__PURE__ */ (0,
|
|
3348
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_components10.Markdown, { children: props.help.markdown }),
|
|
2926
3349
|
presentation: "POPOVER",
|
|
2927
3350
|
size: "sm",
|
|
2928
3351
|
"aria-label": intl.formatMessage(Help_messages_default.helpAria)
|
|
@@ -2932,11 +3355,11 @@ var Help = (props) => {
|
|
|
2932
3355
|
var Help_default = Help;
|
|
2933
3356
|
|
|
2934
3357
|
// src/jsonSchemaForm/schemaFormControl/SchemaFormControl.tsx
|
|
2935
|
-
var
|
|
3358
|
+
var import_react15 = require("react");
|
|
2936
3359
|
|
|
2937
3360
|
// src/formControl/FormControl.tsx
|
|
2938
|
-
var
|
|
2939
|
-
var
|
|
3361
|
+
var import_components11 = require("@transferwise/components");
|
|
3362
|
+
var import_react14 = require("react");
|
|
2940
3363
|
|
|
2941
3364
|
// src/formControl/utils/value-utils.ts
|
|
2942
3365
|
var getSafeStringValue = (value, options = {}) => {
|
|
@@ -3046,8 +3469,8 @@ var logInvalidTypeFallbackWarning = ({
|
|
|
3046
3469
|
};
|
|
3047
3470
|
|
|
3048
3471
|
// src/formControl/FormControl.tsx
|
|
3049
|
-
var
|
|
3050
|
-
var _FormControl = class extends
|
|
3472
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
3473
|
+
var _FormControl = class extends import_react14.PureComponent {
|
|
3051
3474
|
constructor(props) {
|
|
3052
3475
|
super(props);
|
|
3053
3476
|
/**
|
|
@@ -3085,6 +3508,7 @@ var _FormControl = class extends import_react13.PureComponent {
|
|
|
3085
3508
|
this.mapOption = (option) => {
|
|
3086
3509
|
return __spreadProps(__spreadValues({}, option), {
|
|
3087
3510
|
value: isNumber(option.value) || isString(option.value) ? option.value : void 0,
|
|
3511
|
+
secondary: option.note,
|
|
3088
3512
|
disabled: option.disabled || this.props.disabled,
|
|
3089
3513
|
readOnly: this.props.readOnly
|
|
3090
3514
|
});
|
|
@@ -3133,8 +3557,8 @@ var _FormControl = class extends import_react13.PureComponent {
|
|
|
3133
3557
|
} = this.props;
|
|
3134
3558
|
switch (type) {
|
|
3135
3559
|
case FormControlType.RADIO:
|
|
3136
|
-
return /* @__PURE__ */ (0,
|
|
3137
|
-
|
|
3560
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3561
|
+
import_components11.RadioGroup,
|
|
3138
3562
|
{
|
|
3139
3563
|
radios: options.map(this.mapOption),
|
|
3140
3564
|
name,
|
|
@@ -3143,8 +3567,8 @@ var _FormControl = class extends import_react13.PureComponent {
|
|
|
3143
3567
|
}
|
|
3144
3568
|
);
|
|
3145
3569
|
case FormControlType.CHECKBOX:
|
|
3146
|
-
return /* @__PURE__ */ (0,
|
|
3147
|
-
|
|
3570
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3571
|
+
import_components11.Checkbox,
|
|
3148
3572
|
{
|
|
3149
3573
|
checked: getSafeBooleanValue(value, { coerceValue: true }),
|
|
3150
3574
|
disabled,
|
|
@@ -3158,8 +3582,8 @@ var _FormControl = class extends import_react13.PureComponent {
|
|
|
3158
3582
|
);
|
|
3159
3583
|
case FormControlType.SELECT: {
|
|
3160
3584
|
const search = options.length >= 20;
|
|
3161
|
-
return /* @__PURE__ */ (0,
|
|
3162
|
-
|
|
3585
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3586
|
+
import_components11.Select,
|
|
3163
3587
|
{
|
|
3164
3588
|
id,
|
|
3165
3589
|
selected: this.getSelectedOption(options),
|
|
@@ -3182,13 +3606,13 @@ var _FormControl = class extends import_react13.PureComponent {
|
|
|
3182
3606
|
);
|
|
3183
3607
|
}
|
|
3184
3608
|
case FormControlType.TAB:
|
|
3185
|
-
return /* @__PURE__ */ (0,
|
|
3186
|
-
|
|
3609
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3610
|
+
import_components11.Tabs,
|
|
3187
3611
|
{
|
|
3188
3612
|
selected: ((_a = this.getSelectedOption(options)) == null ? void 0 : _a.value) || 0,
|
|
3189
3613
|
tabs: options.map((option) => ({
|
|
3190
3614
|
title: option.label,
|
|
3191
|
-
content: /* @__PURE__ */ (0,
|
|
3615
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_jsx_runtime26.Fragment, {}),
|
|
3192
3616
|
disabled: option.disabled || false
|
|
3193
3617
|
})),
|
|
3194
3618
|
name: id,
|
|
@@ -3202,7 +3626,7 @@ var _FormControl = class extends import_react13.PureComponent {
|
|
|
3202
3626
|
}
|
|
3203
3627
|
);
|
|
3204
3628
|
case FormControlType.NUMBER:
|
|
3205
|
-
return /* @__PURE__ */ (0,
|
|
3629
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3206
3630
|
"input",
|
|
3207
3631
|
{
|
|
3208
3632
|
autoComplete: this.getAutocompleteStatus(),
|
|
@@ -3230,7 +3654,7 @@ var _FormControl = class extends import_react13.PureComponent {
|
|
|
3230
3654
|
}
|
|
3231
3655
|
);
|
|
3232
3656
|
case FormControlType.HIDDEN:
|
|
3233
|
-
return /* @__PURE__ */ (0,
|
|
3657
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3234
3658
|
"input",
|
|
3235
3659
|
{
|
|
3236
3660
|
type: "hidden",
|
|
@@ -3240,7 +3664,7 @@ var _FormControl = class extends import_react13.PureComponent {
|
|
|
3240
3664
|
}
|
|
3241
3665
|
);
|
|
3242
3666
|
case FormControlType.PASSWORD:
|
|
3243
|
-
return /* @__PURE__ */ (0,
|
|
3667
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3244
3668
|
"input",
|
|
3245
3669
|
{
|
|
3246
3670
|
autoComplete: this.getAutocompleteStatus(),
|
|
@@ -3259,8 +3683,8 @@ var _FormControl = class extends import_react13.PureComponent {
|
|
|
3259
3683
|
);
|
|
3260
3684
|
case FormControlType.DATE:
|
|
3261
3685
|
case FormControlType.DATETIME:
|
|
3262
|
-
return /* @__PURE__ */ (0,
|
|
3263
|
-
|
|
3686
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3687
|
+
import_components11.DateInput,
|
|
3264
3688
|
{
|
|
3265
3689
|
disabled,
|
|
3266
3690
|
size,
|
|
@@ -3273,8 +3697,8 @@ var _FormControl = class extends import_react13.PureComponent {
|
|
|
3273
3697
|
}
|
|
3274
3698
|
);
|
|
3275
3699
|
case FormControlType.DATELOOKUP: {
|
|
3276
|
-
return /* @__PURE__ */ (0,
|
|
3277
|
-
|
|
3700
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3701
|
+
import_components11.DateLookup,
|
|
3278
3702
|
{
|
|
3279
3703
|
value: getSafeDateStringValue(value),
|
|
3280
3704
|
min: minDate,
|
|
@@ -3291,8 +3715,8 @@ var _FormControl = class extends import_react13.PureComponent {
|
|
|
3291
3715
|
);
|
|
3292
3716
|
}
|
|
3293
3717
|
case FormControlType.TEL:
|
|
3294
|
-
return /* @__PURE__ */ (0,
|
|
3295
|
-
|
|
3718
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3719
|
+
import_components11.PhoneNumberInput,
|
|
3296
3720
|
{
|
|
3297
3721
|
disabled,
|
|
3298
3722
|
countryCode,
|
|
@@ -3323,8 +3747,8 @@ var _FormControl = class extends import_react13.PureComponent {
|
|
|
3323
3747
|
autoComplete: this.getAutocompleteStatus()
|
|
3324
3748
|
};
|
|
3325
3749
|
if (this.props.displayPattern) {
|
|
3326
|
-
return /* @__PURE__ */ (0,
|
|
3327
|
-
|
|
3750
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3751
|
+
import_components11.TextareaWithDisplayFormat,
|
|
3328
3752
|
__spreadProps(__spreadValues({
|
|
3329
3753
|
displayPattern: this.props.displayPattern
|
|
3330
3754
|
}, textareaProps), {
|
|
@@ -3332,15 +3756,15 @@ var _FormControl = class extends import_react13.PureComponent {
|
|
|
3332
3756
|
})
|
|
3333
3757
|
);
|
|
3334
3758
|
}
|
|
3335
|
-
return /* @__PURE__ */ (0,
|
|
3759
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("textarea", __spreadProps(__spreadValues({}, textareaProps), { onChange: this.handleInputOnChange }));
|
|
3336
3760
|
}
|
|
3337
3761
|
case FormControlType.FILE:
|
|
3338
3762
|
case FormControlType.UPLOAD: {
|
|
3339
3763
|
return (
|
|
3340
3764
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3341
3765
|
// @ts-expect-error - TODO: Remove this once Upload is migrated to TypeScript
|
|
3342
|
-
/* @__PURE__ */ (0,
|
|
3343
|
-
|
|
3766
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3767
|
+
import_components11.Upload,
|
|
3344
3768
|
__spreadProps(__spreadValues({}, uploadProps), {
|
|
3345
3769
|
usAccept: uploadProps.usAccept || "*",
|
|
3346
3770
|
usDisabled: uploadProps.usDisabled || disabled,
|
|
@@ -3376,8 +3800,8 @@ var _FormControl = class extends import_react13.PureComponent {
|
|
|
3376
3800
|
autoComplete: this.getAutocompleteStatus()
|
|
3377
3801
|
};
|
|
3378
3802
|
if (this.props.displayPattern) {
|
|
3379
|
-
return /* @__PURE__ */ (0,
|
|
3380
|
-
|
|
3803
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3804
|
+
import_components11.InputWithDisplayFormat,
|
|
3381
3805
|
__spreadProps(__spreadValues({
|
|
3382
3806
|
displayPattern: this.props.displayPattern
|
|
3383
3807
|
}, inputProps), {
|
|
@@ -3385,7 +3809,7 @@ var _FormControl = class extends import_react13.PureComponent {
|
|
|
3385
3809
|
})
|
|
3386
3810
|
);
|
|
3387
3811
|
}
|
|
3388
|
-
return /* @__PURE__ */ (0,
|
|
3812
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("input", __spreadProps(__spreadValues({}, inputProps), { onChange: this.handleInputOnChange }));
|
|
3389
3813
|
}
|
|
3390
3814
|
}
|
|
3391
3815
|
}
|
|
@@ -3428,8 +3852,8 @@ FormControl.defaultProps = {
|
|
|
3428
3852
|
};
|
|
3429
3853
|
|
|
3430
3854
|
// src/jsonSchemaForm/schemaFormControl/utils/mapping-utils.tsx
|
|
3431
|
-
var
|
|
3432
|
-
var
|
|
3855
|
+
var import_components12 = require("@transferwise/components");
|
|
3856
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
3433
3857
|
var mapConstSchemaToOption = (schema, controlType) => {
|
|
3434
3858
|
switch (controlType) {
|
|
3435
3859
|
case "select":
|
|
@@ -3457,7 +3881,7 @@ var mapKeywordsToSearchStrings = (searchStrings) => isArray(searchStrings) ? { s
|
|
|
3457
3881
|
var mapImage = (image) => {
|
|
3458
3882
|
if (image == null ? void 0 : image.url) {
|
|
3459
3883
|
return {
|
|
3460
|
-
icon: /* @__PURE__ */ (0,
|
|
3884
|
+
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 || "" }) }) })
|
|
3461
3885
|
};
|
|
3462
3886
|
}
|
|
3463
3887
|
return null;
|
|
@@ -3467,27 +3891,27 @@ var getIconPropertyForSelectOption = (icon) => {
|
|
|
3467
3891
|
return { currency: icon.name.substring(5) };
|
|
3468
3892
|
}
|
|
3469
3893
|
if ((icon == null ? void 0 : icon.name) && isValidIconName(icon.name)) {
|
|
3470
|
-
return { icon: /* @__PURE__ */ (0,
|
|
3894
|
+
return { icon: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(DynamicIcon_default, { type: icon.name }) };
|
|
3471
3895
|
}
|
|
3472
3896
|
if (icon == null ? void 0 : icon.text) {
|
|
3473
|
-
return { icon: /* @__PURE__ */ (0,
|
|
3897
|
+
return { icon: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { children: icon.text }) };
|
|
3474
3898
|
}
|
|
3475
3899
|
return null;
|
|
3476
3900
|
};
|
|
3477
3901
|
var getAvatarPropertyForRadioOption = ({ image, icon }) => {
|
|
3478
3902
|
if (image == null ? void 0 : image.url) {
|
|
3479
3903
|
return {
|
|
3480
|
-
avatar: /* @__PURE__ */ (0,
|
|
3904
|
+
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: "" }) })
|
|
3481
3905
|
};
|
|
3482
3906
|
}
|
|
3483
3907
|
if ((icon == null ? void 0 : icon.name) && isValidIconName(icon.name)) {
|
|
3484
3908
|
return {
|
|
3485
|
-
avatar: /* @__PURE__ */ (0,
|
|
3909
|
+
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 }) })
|
|
3486
3910
|
};
|
|
3487
3911
|
}
|
|
3488
3912
|
if (icon == null ? void 0 : icon.text) {
|
|
3489
3913
|
return {
|
|
3490
|
-
avatar: /* @__PURE__ */ (0,
|
|
3914
|
+
avatar: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_components12.Avatar, { type: import_components12.AvatarType.INITIALS, children: icon.text })
|
|
3491
3915
|
};
|
|
3492
3916
|
}
|
|
3493
3917
|
return null;
|
|
@@ -3508,7 +3932,7 @@ var getDisabled = (disabled) => {
|
|
|
3508
3932
|
};
|
|
3509
3933
|
|
|
3510
3934
|
// src/jsonSchemaForm/schemaFormControl/SchemaFormControl.tsx
|
|
3511
|
-
var
|
|
3935
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
3512
3936
|
var isNativeInput = (propsSchemaType) => {
|
|
3513
3937
|
return propsSchemaType === "string" || propsSchemaType === "number";
|
|
3514
3938
|
};
|
|
@@ -3561,7 +3985,7 @@ var SchemaFormControl = (props) => {
|
|
|
3561
3985
|
onChange(getValidBasicModelOrNull(value2, schema), type);
|
|
3562
3986
|
};
|
|
3563
3987
|
const controlType = getControlType(schema);
|
|
3564
|
-
(0,
|
|
3988
|
+
(0, import_react15.useEffect)(() => {
|
|
3565
3989
|
warnIfInvalidSchema(schema, log, controlType);
|
|
3566
3990
|
}, [JSON.stringify(schema), log, controlType]);
|
|
3567
3991
|
const options = schema.values || getOptions(schema, controlType);
|
|
@@ -3584,7 +4008,7 @@ var SchemaFormControl = (props) => {
|
|
|
3584
4008
|
// TODO: LOW avoid type assertion below
|
|
3585
4009
|
uploadProps: mapSchemaToUploadOptions(schema)
|
|
3586
4010
|
};
|
|
3587
|
-
return /* @__PURE__ */ (0,
|
|
4011
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(FormControl, __spreadValues(__spreadValues({ type: controlType, value: safeValue }, events), controlProps));
|
|
3588
4012
|
};
|
|
3589
4013
|
SchemaFormControl.defaultProps = {
|
|
3590
4014
|
value: null,
|
|
@@ -3612,69 +4036,18 @@ var warnIfInvalidSchema = (schema, log, controlType) => {
|
|
|
3612
4036
|
};
|
|
3613
4037
|
var SchemaFormControl_default = SchemaFormControl;
|
|
3614
4038
|
|
|
3615
|
-
// src/jsonSchemaForm/oneOfSchema/utils.ts
|
|
3616
|
-
var getActiveSchemaIndex = (schema, model) => {
|
|
3617
|
-
const indexFromModel = getValidIndexFromValue(schema, model);
|
|
3618
|
-
if (indexFromModel >= 0) {
|
|
3619
|
-
return indexFromModel;
|
|
3620
|
-
}
|
|
3621
|
-
if (schema.oneOf.length === 1 && isNoNConstSchema(schema.oneOf[0])) {
|
|
3622
|
-
return 0;
|
|
3623
|
-
}
|
|
3624
|
-
if (isConstSchema(schema.oneOf[0])) {
|
|
3625
|
-
const indexFromDefault = getValidIndexFromValue(schema, schema.default);
|
|
3626
|
-
if (indexFromDefault >= 0) {
|
|
3627
|
-
return indexFromDefault;
|
|
3628
|
-
}
|
|
3629
|
-
}
|
|
3630
|
-
if (isOneOfObjectSchema(schema) && isObjectModel(model) && Object.keys(model).length >= 1) {
|
|
3631
|
-
return getBestMatchingSchemaIndexForValue(schema, model);
|
|
3632
|
-
}
|
|
3633
|
-
if (isOneOfObjectSchema(schema) && !isUndefined(schema.default) && isObjectModel(schema.default) && Object.keys(schema.default).length >= 1) {
|
|
3634
|
-
return getBestMatchingSchemaIndexForValue(schema, schema.default);
|
|
3635
|
-
}
|
|
3636
|
-
return null;
|
|
3637
|
-
};
|
|
3638
|
-
var getValidIndexFromValue = (schema, value) => {
|
|
3639
|
-
return schema.oneOf.findIndex(
|
|
3640
|
-
(childSchema) => !isUndefined(value) && isValidSchema(value, childSchema)
|
|
3641
|
-
);
|
|
3642
|
-
};
|
|
3643
|
-
function getBestMatchingSchemaIndexForValue(schema, value) {
|
|
3644
|
-
if (value === null || value === void 0) {
|
|
3645
|
-
return null;
|
|
3646
|
-
}
|
|
3647
|
-
const schemaPoints = schema.oneOf.map((childSchema) => {
|
|
3648
|
-
return getSchemaProperties(childSchema).reduce((total, [key, propertySchema]) => {
|
|
3649
|
-
if (isConstSchema(propertySchema) && propertySchema.const === value[key]) {
|
|
3650
|
-
return total + 2;
|
|
3651
|
-
} else if (isNoNConstSchema(propertySchema) && typeof value[key] !== "undefined") {
|
|
3652
|
-
return total + 1;
|
|
3653
|
-
}
|
|
3654
|
-
return total;
|
|
3655
|
-
}, 0);
|
|
3656
|
-
});
|
|
3657
|
-
if (schemaPoints.every((p) => p === schemaPoints[0])) {
|
|
3658
|
-
return null;
|
|
3659
|
-
}
|
|
3660
|
-
return schemaPoints.indexOf(Math.max(...schemaPoints));
|
|
3661
|
-
}
|
|
3662
|
-
function getSchemaProperties(childSchema) {
|
|
3663
|
-
return childSchema.properties !== null && typeof childSchema.properties === "object" ? Object.entries(childSchema.properties) : [];
|
|
3664
|
-
}
|
|
3665
|
-
|
|
3666
4039
|
// src/jsonSchemaForm/oneOfSchema/OneOfSchema.tsx
|
|
3667
|
-
var
|
|
4040
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
3668
4041
|
var OneOfSchema = (props) => {
|
|
3669
4042
|
const onEvent = useEventDispatcher();
|
|
3670
|
-
const [changed, setChanged] = (0,
|
|
3671
|
-
const [focused, setFocused] = (0,
|
|
3672
|
-
const [blurred, setBlurred] = (0,
|
|
3673
|
-
const id = (0,
|
|
3674
|
-
const [schemaIndex, setSchemaIndex] = (0,
|
|
4043
|
+
const [changed, setChanged] = (0, import_react16.useState)(false);
|
|
4044
|
+
const [focused, setFocused] = (0, import_react16.useState)(false);
|
|
4045
|
+
const [blurred, setBlurred] = (0, import_react16.useState)(false);
|
|
4046
|
+
const id = (0, import_react16.useMemo)(() => props.schema.$id || generateRandomId(), [props.schema.$id]);
|
|
4047
|
+
const [schemaIndex, setSchemaIndex] = (0, import_react16.useState)(
|
|
3675
4048
|
getActiveSchemaIndex(props.schema, props.model)
|
|
3676
4049
|
);
|
|
3677
|
-
const [models, setModels] = (0,
|
|
4050
|
+
const [models, setModels] = (0, import_react16.useState)(getModelPartsForSchemas(props.model, props.schema.oneOf));
|
|
3678
4051
|
const debouncedTrackEvent = useDebouncedFunction(onEvent, 200);
|
|
3679
4052
|
const onSearchChange = (searchValue) => {
|
|
3680
4053
|
debouncedTrackEvent("Dynamic Flow - OneOf Searched", {
|
|
@@ -3682,7 +4055,7 @@ var OneOfSchema = (props) => {
|
|
|
3682
4055
|
searchValueLength: searchValue.length
|
|
3683
4056
|
});
|
|
3684
4057
|
};
|
|
3685
|
-
(0,
|
|
4058
|
+
(0, import_react16.useEffect)(() => {
|
|
3686
4059
|
const modelIndex = getValidIndexFromValue(props.schema, props.model);
|
|
3687
4060
|
const defaultIndex = getValidIndexFromValue(props.schema, props.schema.default);
|
|
3688
4061
|
if (modelIndex === -1 && defaultIndex >= 0) {
|
|
@@ -3737,11 +4110,11 @@ var OneOfSchema = (props) => {
|
|
|
3737
4110
|
"form-group": true,
|
|
3738
4111
|
"has-error": !changed && props.errors && !isEmpty(props.errors) || (props.submitted || changed && blurred) && validations.length
|
|
3739
4112
|
};
|
|
3740
|
-
return /* @__PURE__ */ (0,
|
|
3741
|
-
(props.schema.oneOf.length > 1 || isConstSchema(props.schema.oneOf[0])) && /* @__PURE__ */ (0,
|
|
3742
|
-
/* @__PURE__ */ (0,
|
|
4113
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(import_jsx_runtime29.Fragment, { children: [
|
|
4114
|
+
(props.schema.oneOf.length > 1 || isConstSchema(props.schema.oneOf[0])) && /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(import_jsx_runtime29.Fragment, { children: [
|
|
4115
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: (0, import_classnames4.default)(formGroupClasses), children: [
|
|
3743
4116
|
getTitleAndHelp(props.schema, id),
|
|
3744
|
-
/* @__PURE__ */ (0,
|
|
4117
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3745
4118
|
SchemaFormControl_default,
|
|
3746
4119
|
{
|
|
3747
4120
|
id,
|
|
@@ -3754,7 +4127,7 @@ var OneOfSchema = (props) => {
|
|
|
3754
4127
|
onSearchChange
|
|
3755
4128
|
}
|
|
3756
4129
|
),
|
|
3757
|
-
/* @__PURE__ */ (0,
|
|
4130
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3758
4131
|
ControlFeedback_default,
|
|
3759
4132
|
{
|
|
3760
4133
|
changed,
|
|
@@ -3768,9 +4141,9 @@ var OneOfSchema = (props) => {
|
|
|
3768
4141
|
}
|
|
3769
4142
|
)
|
|
3770
4143
|
] }),
|
|
3771
|
-
props.schema.alert && /* @__PURE__ */ (0,
|
|
4144
|
+
props.schema.alert && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(DynamicAlert_default, { component: props.schema.alert })
|
|
3772
4145
|
] }),
|
|
3773
|
-
isNoNConstSchema(props.schema.oneOf[schemaIndex]) && /* @__PURE__ */ (0,
|
|
4146
|
+
isNoNConstSchema(props.schema.oneOf[schemaIndex]) && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3774
4147
|
GenericSchema_default,
|
|
3775
4148
|
{
|
|
3776
4149
|
schema: props.schema.oneOf[schemaIndex],
|
|
@@ -3786,12 +4159,12 @@ var OneOfSchema = (props) => {
|
|
|
3786
4159
|
] });
|
|
3787
4160
|
};
|
|
3788
4161
|
function getTitleAndHelp(schema, id) {
|
|
3789
|
-
const helpElement = schema.help ? /* @__PURE__ */ (0,
|
|
3790
|
-
const titleElement = isConstSchema(schema.oneOf[0]) ? /* @__PURE__ */ (0,
|
|
4162
|
+
const helpElement = schema.help ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Help_default, { help: schema.help }) : null;
|
|
4163
|
+
const titleElement = isConstSchema(schema.oneOf[0]) ? /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("label", { className: "control-label d-inline", htmlFor: id, children: [
|
|
3791
4164
|
schema.title,
|
|
3792
4165
|
" ",
|
|
3793
4166
|
helpElement
|
|
3794
|
-
] }) : /* @__PURE__ */ (0,
|
|
4167
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("h4", { className: "m-b-2", children: [
|
|
3795
4168
|
schema.title,
|
|
3796
4169
|
" ",
|
|
3797
4170
|
helpElement
|
|
@@ -3832,12 +4205,12 @@ var OneOfSchema_default = OneOfSchema;
|
|
|
3832
4205
|
|
|
3833
4206
|
// src/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/PersistAsyncBlobSchema.tsx
|
|
3834
4207
|
var import_classnames5 = __toESM(require_classnames());
|
|
3835
|
-
var
|
|
4208
|
+
var import_react18 = require("react");
|
|
3836
4209
|
|
|
3837
4210
|
// src/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/UploadInputAdapter.tsx
|
|
3838
|
-
var
|
|
3839
|
-
var
|
|
3840
|
-
var
|
|
4211
|
+
var import_components13 = require("@transferwise/components");
|
|
4212
|
+
var import_react17 = require("react");
|
|
4213
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
3841
4214
|
var UploadInputAdapter = (props) => {
|
|
3842
4215
|
const {
|
|
3843
4216
|
id,
|
|
@@ -3853,7 +4226,7 @@ var UploadInputAdapter = (props) => {
|
|
|
3853
4226
|
onCancel
|
|
3854
4227
|
} = props;
|
|
3855
4228
|
const onEvent = useEventDispatcher();
|
|
3856
|
-
const files = (0,
|
|
4229
|
+
const files = (0, import_react17.useMemo)(() => fileId ? [{ id: fileId, status: import_components13.Status.SUCCEEDED }] : [], [fileId]);
|
|
3857
4230
|
const uploadFile = (formData) => {
|
|
3858
4231
|
onEvent("Dynamic Flow - PersistAsync", { status: "pending", schemaId: id });
|
|
3859
4232
|
return httpClient(`${httpOptions.url}`, {
|
|
@@ -3871,8 +4244,8 @@ var UploadInputAdapter = (props) => {
|
|
|
3871
4244
|
}
|
|
3872
4245
|
});
|
|
3873
4246
|
};
|
|
3874
|
-
return /* @__PURE__ */ (0,
|
|
3875
|
-
|
|
4247
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
4248
|
+
import_components13.UploadInput,
|
|
3876
4249
|
{
|
|
3877
4250
|
id,
|
|
3878
4251
|
fileInputName: httpOptions.fileInputName,
|
|
@@ -3891,12 +4264,12 @@ var UploadInputAdapter = (props) => {
|
|
|
3891
4264
|
};
|
|
3892
4265
|
|
|
3893
4266
|
// src/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/PersistAsyncBlobSchema.tsx
|
|
3894
|
-
var
|
|
4267
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
3895
4268
|
var PersistAsyncBlobSchema = (props) => {
|
|
3896
|
-
const [persistAsyncValidationMessages, setPersistAsyncValidationMessages] = (0,
|
|
3897
|
-
const [persistAsyncValidations, setPersistAsyncValidations] = (0,
|
|
3898
|
-
const [validations, setValidations] = (0,
|
|
3899
|
-
const [changed, setChanged] = (0,
|
|
4269
|
+
const [persistAsyncValidationMessages, setPersistAsyncValidationMessages] = (0, import_react18.useState)({});
|
|
4270
|
+
const [persistAsyncValidations, setPersistAsyncValidations] = (0, import_react18.useState)(null);
|
|
4271
|
+
const [validations, setValidations] = (0, import_react18.useState)([]);
|
|
4272
|
+
const [changed, setChanged] = (0, import_react18.useState)(false);
|
|
3900
4273
|
const httpClient = useHttpClient();
|
|
3901
4274
|
const onEvent = useEventDispatcher();
|
|
3902
4275
|
const refreshValidations = () => {
|
|
@@ -3904,7 +4277,7 @@ var PersistAsyncBlobSchema = (props) => {
|
|
|
3904
4277
|
setValidations(getValidationFailures(props.model, props.schema, !!props.required));
|
|
3905
4278
|
}
|
|
3906
4279
|
};
|
|
3907
|
-
(0,
|
|
4280
|
+
(0, import_react18.useEffect)(refreshValidations, [props.model, props.submitted]);
|
|
3908
4281
|
const onSuccess = async (httpResponse, _fileName) => {
|
|
3909
4282
|
const jsonResponse = await httpResponse.json();
|
|
3910
4283
|
const id = getIdFromResponse(props.schema.persistAsync.idProperty, jsonResponse);
|
|
@@ -3933,8 +4306,8 @@ var PersistAsyncBlobSchema = (props) => {
|
|
|
3933
4306
|
"form-group": true,
|
|
3934
4307
|
"has-error": (props.submitted || changed) && !!combinedValidations.length
|
|
3935
4308
|
};
|
|
3936
|
-
return /* @__PURE__ */ (0,
|
|
3937
|
-
/* @__PURE__ */ (0,
|
|
4309
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: (0, import_classnames5.default)(formGroupClasses), children: [
|
|
4310
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
3938
4311
|
UploadInputAdapter,
|
|
3939
4312
|
__spreadValues({
|
|
3940
4313
|
id: props.schema.$id || props.schema.persistAsync.schema.$id || props.schema.persistAsync.idProperty,
|
|
@@ -3951,7 +4324,7 @@ var PersistAsyncBlobSchema = (props) => {
|
|
|
3951
4324
|
onCancel
|
|
3952
4325
|
}, mapSchemaToUploadOptions(props.schema.persistAsync.schema))
|
|
3953
4326
|
),
|
|
3954
|
-
/* @__PURE__ */ (0,
|
|
4327
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
3955
4328
|
ControlFeedback_default,
|
|
3956
4329
|
{
|
|
3957
4330
|
blurred: true,
|
|
@@ -3975,17 +4348,17 @@ PersistAsyncBlobSchema.defaultProps = {
|
|
|
3975
4348
|
var PersistAsyncBlobSchema_default = PersistAsyncBlobSchema;
|
|
3976
4349
|
|
|
3977
4350
|
// src/jsonSchemaForm/persistAsyncSchema/PersistAsyncSchema.tsx
|
|
3978
|
-
var
|
|
4351
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
3979
4352
|
var PersistAsyncSchema = (props) => {
|
|
3980
4353
|
const { schema } = props;
|
|
3981
4354
|
const persistAsyncSchemaType = schema.persistAsync.schema.type;
|
|
3982
4355
|
if (persistAsyncSchemaType === "blob") {
|
|
3983
|
-
return /* @__PURE__ */ (0,
|
|
4356
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
3984
4357
|
PersistAsyncBlobSchema_default,
|
|
3985
4358
|
__spreadValues({}, props)
|
|
3986
4359
|
);
|
|
3987
4360
|
}
|
|
3988
|
-
return /* @__PURE__ */ (0,
|
|
4361
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(PersistAsyncBasicSchema_default, __spreadValues({}, props));
|
|
3989
4362
|
};
|
|
3990
4363
|
PersistAsyncSchema.defaultProps = {
|
|
3991
4364
|
required: false
|
|
@@ -3993,7 +4366,7 @@ PersistAsyncSchema.defaultProps = {
|
|
|
3993
4366
|
var PersistAsyncSchema_default = PersistAsyncSchema;
|
|
3994
4367
|
|
|
3995
4368
|
// src/jsonSchemaForm/promotedOneOfSchema/PromotedOneOfSchema.tsx
|
|
3996
|
-
var
|
|
4369
|
+
var import_react19 = require("react");
|
|
3997
4370
|
|
|
3998
4371
|
// src/jsonSchemaForm/promotedOneOfSchema/promoted-one-of-utils.ts
|
|
3999
4372
|
var getSelectionFromModel = (schema, model) => {
|
|
@@ -4005,8 +4378,8 @@ var getSelectionFromModel = (schema, model) => {
|
|
|
4005
4378
|
};
|
|
4006
4379
|
|
|
4007
4380
|
// src/jsonSchemaForm/promotedOneOfSchema/promotedOneOfControl/PromotedOneOfCheckboxControl.tsx
|
|
4008
|
-
var
|
|
4009
|
-
var
|
|
4381
|
+
var import_components14 = require("@transferwise/components");
|
|
4382
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
4010
4383
|
var PromotedOneOfCheckboxControl = (props) => {
|
|
4011
4384
|
const { id, selection, setSelection } = props;
|
|
4012
4385
|
const { promoted, other, checkedMeans } = props.promotion;
|
|
@@ -4017,14 +4390,14 @@ var PromotedOneOfCheckboxControl = (props) => {
|
|
|
4017
4390
|
const toggleSelection = () => {
|
|
4018
4391
|
setSelection(checked ? selectionWhenUnchecked : selectionWhenChecked);
|
|
4019
4392
|
};
|
|
4020
|
-
return /* @__PURE__ */ (0,
|
|
4393
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: "form-group", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_components14.Checkbox, { id, label: title, checked, onChange: toggleSelection }) });
|
|
4021
4394
|
};
|
|
4022
4395
|
PromotedOneOfCheckboxControl.defaultProps = {};
|
|
4023
4396
|
var PromotedOneOfCheckboxControl_default = PromotedOneOfCheckboxControl;
|
|
4024
4397
|
|
|
4025
4398
|
// src/jsonSchemaForm/promotedOneOfSchema/promotedOneOfControl/PromotedOneOfRadioControl.tsx
|
|
4026
|
-
var
|
|
4027
|
-
var
|
|
4399
|
+
var import_components15 = require("@transferwise/components");
|
|
4400
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
4028
4401
|
var PromotedOneOfRadioControl = (props) => {
|
|
4029
4402
|
var _a, _b;
|
|
4030
4403
|
const { id, selection, setSelection, promotion, promotedOneOf, title } = props;
|
|
@@ -4041,10 +4414,10 @@ var PromotedOneOfRadioControl = (props) => {
|
|
|
4041
4414
|
secondary: promotion.other.description
|
|
4042
4415
|
}, getAvatarPropertyForRadioOption(promotion.other))
|
|
4043
4416
|
];
|
|
4044
|
-
return /* @__PURE__ */ (0,
|
|
4045
|
-
title && /* @__PURE__ */ (0,
|
|
4046
|
-
/* @__PURE__ */ (0,
|
|
4047
|
-
|
|
4417
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: "form-group", children: [
|
|
4418
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("label", { className: "control-label", htmlFor: id, children: title }),
|
|
4419
|
+
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
4420
|
+
import_components15.RadioGroup,
|
|
4048
4421
|
{
|
|
4049
4422
|
name: "promoted-selection",
|
|
4050
4423
|
selectedValue: selection,
|
|
@@ -4061,16 +4434,16 @@ PromotedOneOfRadioControl.defaultProps = {
|
|
|
4061
4434
|
var PromotedOneOfRadioControl_default = PromotedOneOfRadioControl;
|
|
4062
4435
|
|
|
4063
4436
|
// src/jsonSchemaForm/promotedOneOfSchema/promotedOneOfControl/PromotedOneOfControl.tsx
|
|
4064
|
-
var
|
|
4437
|
+
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
4065
4438
|
var PromotedOneOfControl = (props) => {
|
|
4066
4439
|
const controlType = props.promotion.control || "radio";
|
|
4067
4440
|
switch (controlType) {
|
|
4068
4441
|
case "radio":
|
|
4069
|
-
return /* @__PURE__ */ (0,
|
|
4442
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(PromotedOneOfRadioControl_default, __spreadValues({}, props));
|
|
4070
4443
|
case "checkbox":
|
|
4071
|
-
return /* @__PURE__ */ (0,
|
|
4444
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(PromotedOneOfCheckboxControl_default, __spreadValues({}, props));
|
|
4072
4445
|
default:
|
|
4073
|
-
return /* @__PURE__ */ (0,
|
|
4446
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_jsx_runtime35.Fragment, {});
|
|
4074
4447
|
}
|
|
4075
4448
|
};
|
|
4076
4449
|
PromotedOneOfControl.defaultProps = {
|
|
@@ -4080,20 +4453,20 @@ PromotedOneOfControl.defaultProps = {
|
|
|
4080
4453
|
var PromotedOneOfControl_default = PromotedOneOfControl;
|
|
4081
4454
|
|
|
4082
4455
|
// src/jsonSchemaForm/promotedOneOfSchema/PromotedOneOfSchema.tsx
|
|
4083
|
-
var
|
|
4456
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
4084
4457
|
var isPromoted = (schema) => schema.promoted === true;
|
|
4085
4458
|
var PromotedOneOfSchema = (props) => {
|
|
4086
4459
|
var _a;
|
|
4087
|
-
const [selection, setSelection] = (0,
|
|
4460
|
+
const [selection, setSelection] = (0, import_react19.useState)(
|
|
4088
4461
|
getSelectionFromModel(props.schema, props.model) || ((_a = props.schema.promotion) == null ? void 0 : _a.default) || "promoted"
|
|
4089
4462
|
);
|
|
4090
4463
|
const promotedAlert = props.schema.alert;
|
|
4091
4464
|
const promotedOneOf = props.schema.oneOf.find(isPromoted);
|
|
4092
4465
|
const promotedObjectSchema = getPromotedObjectSchema(promotedOneOf);
|
|
4093
4466
|
const otherOneOf = getOtherOneOf(props.schema);
|
|
4094
|
-
return /* @__PURE__ */ (0,
|
|
4095
|
-
promotedAlert && /* @__PURE__ */ (0,
|
|
4096
|
-
/* @__PURE__ */ (0,
|
|
4467
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_jsx_runtime36.Fragment, { children: [
|
|
4468
|
+
promotedAlert && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(DynamicAlert_default, { component: promotedAlert }),
|
|
4469
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
4097
4470
|
PromotedOneOfControl_default,
|
|
4098
4471
|
{
|
|
4099
4472
|
id: props.schema.$id,
|
|
@@ -4104,8 +4477,8 @@ var PromotedOneOfSchema = (props) => {
|
|
|
4104
4477
|
setSelection
|
|
4105
4478
|
}
|
|
4106
4479
|
),
|
|
4107
|
-
selection === "promoted" && /* @__PURE__ */ (0,
|
|
4108
|
-
selection === "other" && /* @__PURE__ */ (0,
|
|
4480
|
+
selection === "promoted" && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ObjectSchema_default, __spreadProps(__spreadValues({}, props), { schema: promotedObjectSchema })),
|
|
4481
|
+
selection === "other" && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(GenericSchema_default, __spreadProps(__spreadValues({}, props), { schema: otherOneOf }))
|
|
4109
4482
|
] });
|
|
4110
4483
|
};
|
|
4111
4484
|
function getPromotedObjectSchema(promotedSchema) {
|
|
@@ -4135,12 +4508,12 @@ function getOtherOneOf(schema) {
|
|
|
4135
4508
|
var PromotedOneOfSchema_default = PromotedOneOfSchema;
|
|
4136
4509
|
|
|
4137
4510
|
// src/jsonSchemaForm/readOnlySchema/ReadOnlySchema.tsx
|
|
4138
|
-
var
|
|
4139
|
-
var
|
|
4511
|
+
var import_components16 = require("@transferwise/components");
|
|
4512
|
+
var import_react_intl15 = require("react-intl");
|
|
4140
4513
|
|
|
4141
4514
|
// src/jsonSchemaForm/readOnlySchema/ReadOnlySchema.messages.js
|
|
4142
|
-
var
|
|
4143
|
-
var ReadOnlySchema_messages_default = (0,
|
|
4515
|
+
var import_react_intl14 = require("react-intl");
|
|
4516
|
+
var ReadOnlySchema_messages_default = (0, import_react_intl14.defineMessages)({
|
|
4144
4517
|
yes: {
|
|
4145
4518
|
id: "dynamicFlows.ReadOnlySchema.yes",
|
|
4146
4519
|
defaultMessage: "Yes",
|
|
@@ -4154,12 +4527,12 @@ var ReadOnlySchema_messages_default = (0, import_react_intl11.defineMessages)({
|
|
|
4154
4527
|
});
|
|
4155
4528
|
|
|
4156
4529
|
// src/jsonSchemaForm/readOnlySchema/ReadOnlySchema.tsx
|
|
4157
|
-
var
|
|
4530
|
+
var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
4158
4531
|
var ReadOnlySchema = ({ schema, model }) => {
|
|
4159
4532
|
const { title = "" } = schema;
|
|
4160
|
-
const { formatMessage } = (0,
|
|
4533
|
+
const { formatMessage } = (0, import_react_intl15.useIntl)();
|
|
4161
4534
|
const value = getValueForSchema({ schema, model, formatMessage });
|
|
4162
|
-
return /* @__PURE__ */ (0,
|
|
4535
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_components16.DefinitionList, { layout: import_components16.Layout.VERTICAL_ONE_COLUMN, definitions: [{ title, value, key: "" }] });
|
|
4163
4536
|
};
|
|
4164
4537
|
var ReadOnlySchema_default = ReadOnlySchema;
|
|
4165
4538
|
function getValueForSchema({
|
|
@@ -4192,7 +4565,7 @@ function getSelectedOneOf(schema, model) {
|
|
|
4192
4565
|
function getValueFromOption(option) {
|
|
4193
4566
|
const text = option.title && option.description ? `${option.title} - ${option.description}` : option.title || "";
|
|
4194
4567
|
const icon = getAvatarPropertyForRadioOption({ icon: option.icon });
|
|
4195
|
-
return (icon == null ? void 0 : icon.avatar) ? /* @__PURE__ */ (0,
|
|
4568
|
+
return (icon == null ? void 0 : icon.avatar) ? /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(import_jsx_runtime37.Fragment, { children: [
|
|
4196
4569
|
icon.avatar,
|
|
4197
4570
|
" ",
|
|
4198
4571
|
text
|
|
@@ -4200,22 +4573,22 @@ function getValueFromOption(option) {
|
|
|
4200
4573
|
}
|
|
4201
4574
|
|
|
4202
4575
|
// src/jsonSchemaForm/validationAsyncSchema/ValidationAsyncSchema.tsx
|
|
4203
|
-
var
|
|
4204
|
-
var
|
|
4576
|
+
var import_react20 = require("react");
|
|
4577
|
+
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
4205
4578
|
var ValidationAsyncSchema = (props) => {
|
|
4206
4579
|
const { schema, model, required, submitted, errors, onChange } = props;
|
|
4207
|
-
const [validationAsyncModel, setValidationAsyncModel] = (0,
|
|
4208
|
-
const previousRequestedModelReference = (0,
|
|
4209
|
-
const [validationAsyncSuccessMessage, setValidationAsyncSuccessMessage] = (0,
|
|
4580
|
+
const [validationAsyncModel, setValidationAsyncModel] = (0, import_react20.useState)(model);
|
|
4581
|
+
const previousRequestedModelReference = (0, import_react20.useRef)(null);
|
|
4582
|
+
const [validationAsyncSuccessMessage, setValidationAsyncSuccessMessage] = (0, import_react20.useState)(
|
|
4210
4583
|
null
|
|
4211
4584
|
);
|
|
4212
|
-
const [validationAsyncErrors, setValidationAsyncErrors] = (0,
|
|
4213
|
-
const [fieldSubmitted, setFieldSubmitted] = (0,
|
|
4214
|
-
const [abortController, setAbortController] = (0,
|
|
4585
|
+
const [validationAsyncErrors, setValidationAsyncErrors] = (0, import_react20.useState)(null);
|
|
4586
|
+
const [fieldSubmitted, setFieldSubmitted] = (0, import_react20.useState)(false);
|
|
4587
|
+
const [abortController, setAbortController] = (0, import_react20.useState)(null);
|
|
4215
4588
|
const httpClient = useHttpClient();
|
|
4216
4589
|
const onEvent = useEventDispatcher();
|
|
4217
4590
|
const log = useLogger();
|
|
4218
|
-
(0,
|
|
4591
|
+
(0, import_react20.useEffect)(() => {
|
|
4219
4592
|
if (!schema.validationAsync.method) {
|
|
4220
4593
|
log.warning(
|
|
4221
4594
|
"Invalid schema or model",
|
|
@@ -4262,7 +4635,7 @@ var ValidationAsyncSchema = (props) => {
|
|
|
4262
4635
|
return newAbortController.signal;
|
|
4263
4636
|
};
|
|
4264
4637
|
const onBlur = () => {
|
|
4265
|
-
if (!isNull(validationAsyncModel) && !isEqual(validationAsyncModel, previousRequestedModelReference.current)) {
|
|
4638
|
+
if (!isNull(validationAsyncModel) && !isEqual(validationAsyncModel, previousRequestedModelReference.current) && isValidSchema(validationAsyncModel, schema)) {
|
|
4266
4639
|
void getValidationAsyncResponse(validationAsyncModel, schema.validationAsync);
|
|
4267
4640
|
}
|
|
4268
4641
|
};
|
|
@@ -4273,9 +4646,7 @@ var ValidationAsyncSchema = (props) => {
|
|
|
4273
4646
|
}));
|
|
4274
4647
|
setValidationAsyncErrors(null);
|
|
4275
4648
|
setValidationAsyncSuccessMessage(null);
|
|
4276
|
-
|
|
4277
|
-
setValidationAsyncModel(parameters.model);
|
|
4278
|
-
}
|
|
4649
|
+
setValidationAsyncModel(parameters.model);
|
|
4279
4650
|
};
|
|
4280
4651
|
const basicTypeSchemaProps = {
|
|
4281
4652
|
submitted: submitted || fieldSubmitted,
|
|
@@ -4287,20 +4658,20 @@ var ValidationAsyncSchema = (props) => {
|
|
|
4287
4658
|
required,
|
|
4288
4659
|
schema
|
|
4289
4660
|
};
|
|
4290
|
-
return /* @__PURE__ */ (0,
|
|
4661
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(BasicTypeSchema_default, __spreadValues({}, basicTypeSchemaProps));
|
|
4291
4662
|
};
|
|
4292
4663
|
ValidationAsyncSchema.defaultProps = { required: false };
|
|
4293
4664
|
var ValidationAsyncSchema_default = ValidationAsyncSchema;
|
|
4294
4665
|
|
|
4295
4666
|
// src/jsonSchemaForm/genericSchema/GenericSchema.tsx
|
|
4296
|
-
var
|
|
4297
|
-
var
|
|
4667
|
+
var import_jsx_runtime39 = require("react/jsx-runtime");
|
|
4668
|
+
var import_react22 = require("react");
|
|
4298
4669
|
var GenericSchemaForm = (props) => {
|
|
4299
4670
|
const { schema, model = null, errors = null, hideTitle = false, disabled = false } = props;
|
|
4300
4671
|
const schemaProps = __spreadProps(__spreadValues({}, props), { model, errors, hideTitle, disabled });
|
|
4301
4672
|
const type = getSchemaType(schema);
|
|
4302
4673
|
const log = useLogger();
|
|
4303
|
-
(0,
|
|
4674
|
+
(0, import_react21.useEffect)(() => {
|
|
4304
4675
|
if (!isValidGenericSchema(schema, model, errors)) {
|
|
4305
4676
|
log.error(
|
|
4306
4677
|
"Invalid schema or model",
|
|
@@ -4310,27 +4681,27 @@ var GenericSchemaForm = (props) => {
|
|
|
4310
4681
|
}, [JSON.stringify(schema), JSON.stringify(model), JSON.stringify(errors), type, log]);
|
|
4311
4682
|
switch (type) {
|
|
4312
4683
|
case "readOnly":
|
|
4313
|
-
return /* @__PURE__ */ (0,
|
|
4684
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ReadOnlySchema_default, __spreadValues({}, schemaProps));
|
|
4314
4685
|
case "persistAsync":
|
|
4315
|
-
return /* @__PURE__ */ (0,
|
|
4686
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(PersistAsyncSchema_default, __spreadValues({}, schemaProps));
|
|
4316
4687
|
case "validationAsync":
|
|
4317
|
-
return /* @__PURE__ */ (0,
|
|
4688
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ValidationAsyncSchema_default, __spreadValues({}, schemaProps));
|
|
4318
4689
|
case "basic": {
|
|
4319
4690
|
const basicTypeProps = __spreadValues({ infoMessage: null }, schemaProps);
|
|
4320
|
-
return /* @__PURE__ */ (0,
|
|
4691
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(BasicTypeSchema_default, __spreadValues({}, basicTypeProps));
|
|
4321
4692
|
}
|
|
4322
4693
|
case "object":
|
|
4323
|
-
return /* @__PURE__ */ (0,
|
|
4694
|
+
return /* @__PURE__ */ (0, import_react22.createElement)(ObjectSchema_default, __spreadProps(__spreadValues({}, schemaProps), { key: JSON.stringify(schema) }));
|
|
4324
4695
|
case "array":
|
|
4325
|
-
return /* @__PURE__ */ (0,
|
|
4696
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ArraySchema_default, __spreadValues({}, schemaProps));
|
|
4326
4697
|
case "promotedOneOf":
|
|
4327
|
-
return /* @__PURE__ */ (0,
|
|
4698
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(PromotedOneOfSchema_default, __spreadValues({}, schemaProps));
|
|
4328
4699
|
case "oneOf":
|
|
4329
|
-
return /* @__PURE__ */ (0,
|
|
4700
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(OneOfSchema_default, __spreadValues({}, schemaProps));
|
|
4330
4701
|
case "allOf":
|
|
4331
|
-
return /* @__PURE__ */ (0,
|
|
4702
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(AllOfSchema_default, __spreadValues({}, schemaProps));
|
|
4332
4703
|
}
|
|
4333
|
-
return /* @__PURE__ */ (0,
|
|
4704
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_jsx_runtime39.Fragment, {});
|
|
4334
4705
|
};
|
|
4335
4706
|
var GenericSchema_default = GenericSchemaForm;
|
|
4336
4707
|
var isValidGenericSchema = (schema, model, errors) => {
|
|
@@ -4357,7 +4728,7 @@ var isValidGenericSchema = (schema, model, errors) => {
|
|
|
4357
4728
|
};
|
|
4358
4729
|
|
|
4359
4730
|
// src/jsonSchemaForm/JsonSchemaForm.tsx
|
|
4360
|
-
var
|
|
4731
|
+
var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
4361
4732
|
var JsonSchemaForm = (props) => {
|
|
4362
4733
|
const schemaProps = __spreadValues({
|
|
4363
4734
|
model: null,
|
|
@@ -4366,26 +4737,26 @@ var JsonSchemaForm = (props) => {
|
|
|
4366
4737
|
baseUrl: ""
|
|
4367
4738
|
}, props);
|
|
4368
4739
|
if (useHasHttpClientProvider() || schemaProps.baseUrl == null) {
|
|
4369
|
-
return /* @__PURE__ */ (0,
|
|
4740
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(GenericSchema_default, __spreadValues({}, schemaProps));
|
|
4370
4741
|
}
|
|
4371
|
-
return /* @__PURE__ */ (0,
|
|
4742
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
4372
4743
|
Providers,
|
|
4373
4744
|
{
|
|
4374
4745
|
baseUrl: schemaProps.baseUrl,
|
|
4375
4746
|
onEvent: schemaProps.onEvent,
|
|
4376
4747
|
onLog: schemaProps.onLog,
|
|
4377
|
-
children: /* @__PURE__ */ (0,
|
|
4748
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(GenericSchema_default, __spreadValues({}, schemaProps))
|
|
4378
4749
|
}
|
|
4379
4750
|
);
|
|
4380
4751
|
};
|
|
4381
4752
|
var JsonSchemaForm_default = JsonSchemaForm;
|
|
4382
4753
|
var Providers = ({ baseUrl, onEvent, onLog, children }) => {
|
|
4383
|
-
return /* @__PURE__ */ (0,
|
|
4754
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(LogProvider, { flowId: "JsonSchemaForm", stepId: "JsonSchemaForm", onLog: onLog != null ? onLog : noop2, children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
4384
4755
|
EventsContextProvider,
|
|
4385
4756
|
{
|
|
4386
4757
|
metadata: { flowId: "JsonSchemaForm", stepId: "JsonSchemaForm" },
|
|
4387
4758
|
onEvent: onEvent != null ? onEvent : noop2,
|
|
4388
|
-
children: /* @__PURE__ */ (0,
|
|
4759
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(HttpClientProviderFromBaseUrl, { baseUrl, children })
|
|
4389
4760
|
}
|
|
4390
4761
|
) });
|
|
4391
4762
|
};
|
|
@@ -4393,11 +4764,11 @@ var noop2 = () => {
|
|
|
4393
4764
|
};
|
|
4394
4765
|
|
|
4395
4766
|
// src/layout/form/DynamicForm.tsx
|
|
4396
|
-
var
|
|
4767
|
+
var import_jsx_runtime41 = require("react/jsx-runtime");
|
|
4397
4768
|
var DynamicForm = (props) => {
|
|
4398
4769
|
const form = props.component;
|
|
4399
4770
|
const formSchema = form.schema;
|
|
4400
|
-
return /* @__PURE__ */ (0,
|
|
4771
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getMargin(form.margin || "md"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
4401
4772
|
JsonSchemaForm_default,
|
|
4402
4773
|
{
|
|
4403
4774
|
schema: formSchema,
|
|
@@ -4414,46 +4785,46 @@ var DynamicForm = (props) => {
|
|
|
4414
4785
|
var DynamicForm_default = DynamicForm;
|
|
4415
4786
|
|
|
4416
4787
|
// src/layout/heading/DynamicHeading.tsx
|
|
4417
|
-
var
|
|
4788
|
+
var import_jsx_runtime42 = require("react/jsx-runtime");
|
|
4418
4789
|
var DynamicHeading = (props) => {
|
|
4419
4790
|
const { text, size = "md", align = "left", margin = "md" } = props.component;
|
|
4420
4791
|
const classes = getTextAlignmentAndMargin({ align, margin });
|
|
4421
4792
|
switch (size) {
|
|
4422
4793
|
case "xs":
|
|
4423
|
-
return /* @__PURE__ */ (0,
|
|
4794
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("h5", { className: classes, children: text });
|
|
4424
4795
|
case "sm":
|
|
4425
|
-
return /* @__PURE__ */ (0,
|
|
4796
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("h4", { className: classes, children: text });
|
|
4426
4797
|
case "lg":
|
|
4427
|
-
return /* @__PURE__ */ (0,
|
|
4798
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("h2", { className: classes, children: text });
|
|
4428
4799
|
case "xl":
|
|
4429
|
-
return /* @__PURE__ */ (0,
|
|
4800
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("h1", { className: classes, children: text });
|
|
4430
4801
|
case "md":
|
|
4431
4802
|
default:
|
|
4432
|
-
return /* @__PURE__ */ (0,
|
|
4803
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("h3", { className: classes, children: text });
|
|
4433
4804
|
}
|
|
4434
4805
|
};
|
|
4435
4806
|
var DynamicHeading_default = DynamicHeading;
|
|
4436
4807
|
|
|
4437
4808
|
// src/layout/markdown/DynamicMarkdown.tsx
|
|
4438
|
-
var
|
|
4439
|
-
var
|
|
4809
|
+
var import_components17 = require("@transferwise/components");
|
|
4810
|
+
var import_jsx_runtime43 = require("react/jsx-runtime");
|
|
4440
4811
|
var DynamicMarkdown = ({ component }) => {
|
|
4441
4812
|
const { content, align, margin } = component;
|
|
4442
|
-
return /* @__PURE__ */ (0,
|
|
4813
|
+
return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: getTextAlignmentAndMargin({ align, margin }), children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_components17.Markdown, { config: { link: { target: "_blank" } }, children: content }) });
|
|
4443
4814
|
};
|
|
4444
4815
|
var DynamicInfo = ({ component }) => {
|
|
4445
|
-
return /* @__PURE__ */ (0,
|
|
4816
|
+
return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: getTextAlignmentAndMargin(component), children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_components17.Markdown, { config: { link: { target: "_blank" } }, children: component.markdown }) });
|
|
4446
4817
|
};
|
|
4447
4818
|
|
|
4448
4819
|
// src/layout/image/DynamicImage.tsx
|
|
4449
|
-
var
|
|
4450
|
-
var
|
|
4451
|
-
var
|
|
4820
|
+
var import_components18 = require("@transferwise/components");
|
|
4821
|
+
var import_react23 = require("react");
|
|
4822
|
+
var import_jsx_runtime44 = require("react/jsx-runtime");
|
|
4452
4823
|
var DynamicImage = ({ component: image }) => {
|
|
4453
4824
|
const { url, size, text, margin, accessibilityDescription } = image;
|
|
4454
4825
|
const httpClient = useHttpClient();
|
|
4455
|
-
const [imageSource, setImageSource] = (0,
|
|
4456
|
-
(0,
|
|
4826
|
+
const [imageSource, setImageSource] = (0, import_react23.useState)("");
|
|
4827
|
+
(0, import_react23.useEffect)(() => {
|
|
4457
4828
|
void getImageSource(httpClient, url).then(setImageSource);
|
|
4458
4829
|
}, [url, httpClient]);
|
|
4459
4830
|
const imageProps = {
|
|
@@ -4465,7 +4836,7 @@ var DynamicImage = ({ component: image }) => {
|
|
|
4465
4836
|
if (!imageSource) {
|
|
4466
4837
|
return null;
|
|
4467
4838
|
}
|
|
4468
|
-
return /* @__PURE__ */ (0,
|
|
4839
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: `df-image ${size || "md"}`, children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_components18.Image, __spreadValues({ className: `img-responsive ${getMargin(margin || "md")}` }, imageProps)) });
|
|
4469
4840
|
};
|
|
4470
4841
|
var readImageBlobAsDataURL = (imageBlob) => {
|
|
4471
4842
|
return new Promise((resolve, reject) => {
|
|
@@ -4498,48 +4869,48 @@ var getImageSource = async (httpClient, imageUrl) => {
|
|
|
4498
4869
|
var DynamicImage_default = DynamicImage;
|
|
4499
4870
|
|
|
4500
4871
|
// src/layout/instructions/DynamicInstructions.tsx
|
|
4501
|
-
var
|
|
4502
|
-
var
|
|
4872
|
+
var import_components19 = require("@transferwise/components");
|
|
4873
|
+
var import_jsx_runtime45 = require("react/jsx-runtime");
|
|
4503
4874
|
var doContext = ["positive", "neutral"];
|
|
4504
4875
|
var dontContext = ["warning", "negative"];
|
|
4505
4876
|
var DynamicInstructions = ({ component }) => {
|
|
4506
4877
|
const { items } = component;
|
|
4507
4878
|
const dos = items.filter((item) => doContext.includes(item.context)).map(({ text }) => text);
|
|
4508
4879
|
const donts = items.filter((item) => dontContext.includes(item.context)).map(({ text }) => text);
|
|
4509
|
-
return /* @__PURE__ */ (0,
|
|
4510
|
-
component.title ? /* @__PURE__ */ (0,
|
|
4511
|
-
/* @__PURE__ */ (0,
|
|
4880
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: getMargin(component.margin || "md"), children: [
|
|
4881
|
+
component.title ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_components19.Header, { title: component.title }) : null,
|
|
4882
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_components19.InstructionsList, { dos, donts })
|
|
4512
4883
|
] });
|
|
4513
4884
|
};
|
|
4514
4885
|
var DynamicInstructions_default = DynamicInstructions;
|
|
4515
4886
|
|
|
4516
4887
|
// src/layout/DynamicLayout.tsx
|
|
4517
|
-
var
|
|
4888
|
+
var import_jsx_runtime46 = require("react/jsx-runtime");
|
|
4518
4889
|
var getKey = (component) => JSON.stringify(component);
|
|
4519
4890
|
var DynamicLayout = (props) => {
|
|
4520
4891
|
const { components, model, submitted, errors, onModelChange, onAction, onPersistAsync, baseUrl } = props;
|
|
4521
4892
|
const renderComponent = (component) => {
|
|
4522
4893
|
switch (component.type) {
|
|
4523
4894
|
case "heading":
|
|
4524
|
-
return /* @__PURE__ */ (0,
|
|
4895
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(DynamicHeading_default, { component }, getKey(component));
|
|
4525
4896
|
case "paragraph":
|
|
4526
|
-
return /* @__PURE__ */ (0,
|
|
4897
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(DynamicParagraph_default, { component }, getKey(component));
|
|
4527
4898
|
case "image":
|
|
4528
|
-
return /* @__PURE__ */ (0,
|
|
4899
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(DynamicImage_default, { component }, getKey(component));
|
|
4529
4900
|
case "alert":
|
|
4530
|
-
return /* @__PURE__ */ (0,
|
|
4901
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(DynamicAlert_default, { component }, getKey(component));
|
|
4531
4902
|
case "review":
|
|
4532
|
-
return /* @__PURE__ */ (0,
|
|
4903
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(DynamicReview_default, { component, onAction }, getKey(component));
|
|
4533
4904
|
case "divider":
|
|
4534
|
-
return /* @__PURE__ */ (0,
|
|
4905
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(DynamicDivider_default, { component }, getKey(component));
|
|
4535
4906
|
case "info":
|
|
4536
|
-
return /* @__PURE__ */ (0,
|
|
4907
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(DynamicInfo, { component }, getKey(component));
|
|
4537
4908
|
case "instructions":
|
|
4538
|
-
return /* @__PURE__ */ (0,
|
|
4909
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(DynamicInstructions_default, { component }, getKey(component));
|
|
4539
4910
|
case "markdown":
|
|
4540
|
-
return /* @__PURE__ */ (0,
|
|
4911
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(DynamicMarkdown, { component }, getKey(component));
|
|
4541
4912
|
case "columns":
|
|
4542
|
-
return /* @__PURE__ */ (0,
|
|
4913
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
4543
4914
|
DynamicColumns_default,
|
|
4544
4915
|
{
|
|
4545
4916
|
component,
|
|
@@ -4553,7 +4924,7 @@ var DynamicLayout = (props) => {
|
|
|
4553
4924
|
getKey(component)
|
|
4554
4925
|
);
|
|
4555
4926
|
case "form":
|
|
4556
|
-
return /* @__PURE__ */ (0,
|
|
4927
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
4557
4928
|
DynamicForm_default,
|
|
4558
4929
|
{
|
|
4559
4930
|
component,
|
|
@@ -4566,9 +4937,9 @@ var DynamicLayout = (props) => {
|
|
|
4566
4937
|
getKey(__spreadProps(__spreadValues({}, component), { errors: errors != null ? errors : null }))
|
|
4567
4938
|
);
|
|
4568
4939
|
case "button":
|
|
4569
|
-
return /* @__PURE__ */ (0,
|
|
4940
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(DynamicButton_default, { component, onAction }, getKey(component));
|
|
4570
4941
|
case "box":
|
|
4571
|
-
return /* @__PURE__ */ (0,
|
|
4942
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
4572
4943
|
DynamicBox_default,
|
|
4573
4944
|
{
|
|
4574
4945
|
component,
|
|
@@ -4582,34 +4953,34 @@ var DynamicLayout = (props) => {
|
|
|
4582
4953
|
getKey(component)
|
|
4583
4954
|
);
|
|
4584
4955
|
case "decision":
|
|
4585
|
-
return /* @__PURE__ */ (0,
|
|
4956
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(DynamicDecision_default, { component, onAction }, getKey(component));
|
|
4586
4957
|
case "external":
|
|
4587
|
-
return /* @__PURE__ */ (0,
|
|
4958
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(DynamicExternal_default, { component, onAction }, getKey(component));
|
|
4588
4959
|
case "list":
|
|
4589
4960
|
case "status-list":
|
|
4590
|
-
return /* @__PURE__ */ (0,
|
|
4961
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(DynamicStatusList_default, { component, onAction }, getKey(component));
|
|
4591
4962
|
case "loading-indicator":
|
|
4592
|
-
return /* @__PURE__ */ (0,
|
|
4963
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(DynamicLoadingIndicator_default, { component }, getKey(component));
|
|
4593
4964
|
case "search":
|
|
4594
|
-
return /* @__PURE__ */ (0,
|
|
4965
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(DynamicSearch_default, { component, onAction }, getKey(component));
|
|
4595
4966
|
default:
|
|
4596
|
-
return /* @__PURE__ */ (0,
|
|
4967
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", {}, getKey(component));
|
|
4597
4968
|
}
|
|
4598
4969
|
};
|
|
4599
4970
|
if (useHasHttpClientProvider() || baseUrl == null) {
|
|
4600
|
-
return /* @__PURE__ */ (0,
|
|
4971
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_jsx_runtime46.Fragment, { children: components.map(renderComponent) });
|
|
4601
4972
|
} else {
|
|
4602
|
-
return /* @__PURE__ */ (0,
|
|
4973
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(HttpClientProviderFromBaseUrl, { baseUrl, children: components.map(renderComponent) });
|
|
4603
4974
|
}
|
|
4604
4975
|
};
|
|
4605
4976
|
var DynamicLayout_default = DynamicLayout;
|
|
4606
4977
|
|
|
4607
4978
|
// src/layout/list/DynamicStatusList.tsx
|
|
4608
|
-
var
|
|
4609
|
-
var
|
|
4979
|
+
var import_components20 = require("@transferwise/components");
|
|
4980
|
+
var import_jsx_runtime47 = require("react/jsx-runtime");
|
|
4610
4981
|
var DynamicStatusList = ({ component }) => {
|
|
4611
|
-
return /* @__PURE__ */ (0,
|
|
4612
|
-
component.title ? /* @__PURE__ */ (0,
|
|
4982
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: getMargin(component.margin || "md"), children: [
|
|
4983
|
+
component.title ? /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("h4", { className: "m-b-2", children: [
|
|
4613
4984
|
" ",
|
|
4614
4985
|
component.title,
|
|
4615
4986
|
" "
|
|
@@ -4622,8 +4993,8 @@ var mapListItemToSummary = ({ title, description, icon, status }) => {
|
|
|
4622
4993
|
key: `${title}/${description || ""}`,
|
|
4623
4994
|
title,
|
|
4624
4995
|
description
|
|
4625
|
-
}, (icon == null ? void 0 : icon.name) ? { icon: /* @__PURE__ */ (0,
|
|
4626
|
-
return /* @__PURE__ */ (0,
|
|
4996
|
+
}, (icon == null ? void 0 : icon.name) ? { icon: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(DynamicIcon_default, { type: icon.name }) } : {}), status ? { status: statusMap[status] } : {});
|
|
4997
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_components20.Summary, __spreadValues({}, props));
|
|
4627
4998
|
};
|
|
4628
4999
|
var statusListMap = {
|
|
4629
5000
|
done: "done",
|
|
@@ -4639,16 +5010,16 @@ var statusMap = __spreadValues(__spreadValues({}, statusListMap), legacyStatusMa
|
|
|
4639
5010
|
var DynamicStatusList_default = DynamicStatusList;
|
|
4640
5011
|
|
|
4641
5012
|
// src/layout/loadingIndicator/DynamicLoadingIndicator.tsx
|
|
4642
|
-
var
|
|
4643
|
-
var
|
|
5013
|
+
var import_components21 = require("@transferwise/components");
|
|
5014
|
+
var import_jsx_runtime48 = require("react/jsx-runtime");
|
|
4644
5015
|
var DynamicLoadingIndicator = ({ component }) => {
|
|
4645
5016
|
const { margin, size = "md" } = component;
|
|
4646
|
-
return /* @__PURE__ */ (0,
|
|
4647
|
-
|
|
5017
|
+
return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
5018
|
+
import_components21.Loader,
|
|
4648
5019
|
{
|
|
4649
5020
|
size,
|
|
4650
5021
|
classNames: {
|
|
4651
|
-
"tw-loader": `tw-loader m-x-auto ${
|
|
5022
|
+
"tw-loader": `tw-loader m-x-auto ${getMargin(margin)}`
|
|
4652
5023
|
},
|
|
4653
5024
|
"data-testid": "loading-indicator"
|
|
4654
5025
|
}
|
|
@@ -4657,12 +5028,12 @@ var DynamicLoadingIndicator = ({ component }) => {
|
|
|
4657
5028
|
var DynamicLoadingIndicator_default = DynamicLoadingIndicator;
|
|
4658
5029
|
|
|
4659
5030
|
// src/layout/paragraph/DynamicParagraph.tsx
|
|
4660
|
-
var
|
|
4661
|
-
var
|
|
5031
|
+
var import_components23 = require("@transferwise/components");
|
|
5032
|
+
var import_react_intl17 = require("react-intl");
|
|
4662
5033
|
|
|
4663
5034
|
// src/layout/paragraph/DynamicParagraph.messages.ts
|
|
4664
|
-
var
|
|
4665
|
-
var DynamicParagraph_messages_default = (0,
|
|
5035
|
+
var import_react_intl16 = require("react-intl");
|
|
5036
|
+
var DynamicParagraph_messages_default = (0, import_react_intl16.defineMessages)({
|
|
4666
5037
|
copy: {
|
|
4667
5038
|
id: "dynamicFlows.DynamicParagraph.copy",
|
|
4668
5039
|
defaultMessage: "Copy",
|
|
@@ -4676,25 +5047,25 @@ var DynamicParagraph_messages_default = (0, import_react_intl13.defineMessages)(
|
|
|
4676
5047
|
});
|
|
4677
5048
|
|
|
4678
5049
|
// src/layout/paragraph/useSnackBarIfAvailable.ts
|
|
4679
|
-
var
|
|
4680
|
-
var
|
|
5050
|
+
var import_components22 = require("@transferwise/components");
|
|
5051
|
+
var import_react24 = require("react");
|
|
4681
5052
|
function useSnackBarIfAvailable() {
|
|
4682
|
-
const context = (0,
|
|
5053
|
+
const context = (0, import_react24.useContext)(import_components22.SnackbarContext);
|
|
4683
5054
|
return context ? context.createSnackbar : noop3;
|
|
4684
5055
|
}
|
|
4685
5056
|
function noop3() {
|
|
4686
5057
|
}
|
|
4687
5058
|
|
|
4688
5059
|
// src/layout/paragraph/DynamicParagraph.tsx
|
|
4689
|
-
var
|
|
4690
|
-
var DynamicParagraph = ({ component }) => component.control === "copyable" ? /* @__PURE__ */ (0,
|
|
4691
|
-
var BasicDynamicParagraph = ({ component }) => /* @__PURE__ */ (0,
|
|
5060
|
+
var import_jsx_runtime49 = require("react/jsx-runtime");
|
|
5061
|
+
var DynamicParagraph = ({ component }) => component.control === "copyable" ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(CopyableDynamicParagraph, { component }) : /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(BasicDynamicParagraph, { component });
|
|
5062
|
+
var BasicDynamicParagraph = ({ component }) => /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("p", { className: getTextAlignmentAndMargin(component), children: [
|
|
4692
5063
|
" ",
|
|
4693
5064
|
component.text,
|
|
4694
5065
|
" "
|
|
4695
5066
|
] });
|
|
4696
5067
|
var CopyableDynamicParagraph = ({ component }) => {
|
|
4697
|
-
const { formatMessage } = (0,
|
|
5068
|
+
const { formatMessage } = (0, import_react_intl17.useIntl)();
|
|
4698
5069
|
const createSnackbar = useSnackBarIfAvailable();
|
|
4699
5070
|
const { text } = component;
|
|
4700
5071
|
const copy = () => {
|
|
@@ -4702,8 +5073,8 @@ var CopyableDynamicParagraph = ({ component }) => {
|
|
|
4702
5073
|
(_a = navigator.clipboard) == null ? void 0 : _a.writeText(text).then(() => createSnackbar({ text: formatMessage(DynamicParagraph_messages_default.copied) })).catch(noop4);
|
|
4703
5074
|
};
|
|
4704
5075
|
const classNames7 = getTextAlignmentAndMargin({ align: component.align, margin: "sm" }) + " form-control";
|
|
4705
|
-
return /* @__PURE__ */ (0,
|
|
4706
|
-
/* @__PURE__ */ (0,
|
|
5076
|
+
return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className: getTextAlignmentAndMargin(component), children: [
|
|
5077
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
4707
5078
|
"input",
|
|
4708
5079
|
{
|
|
4709
5080
|
type: "text",
|
|
@@ -4713,7 +5084,7 @@ var CopyableDynamicParagraph = ({ component }) => {
|
|
|
4713
5084
|
style: { textOverflow: "ellipsis" }
|
|
4714
5085
|
}
|
|
4715
5086
|
),
|
|
4716
|
-
/* @__PURE__ */ (0,
|
|
5087
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_components23.Button, { block: true, onClick: copy, children: formatMessage(DynamicParagraph_messages_default.copy) })
|
|
4717
5088
|
] });
|
|
4718
5089
|
};
|
|
4719
5090
|
function noop4() {
|
|
@@ -4721,8 +5092,8 @@ function noop4() {
|
|
|
4721
5092
|
var DynamicParagraph_default = DynamicParagraph;
|
|
4722
5093
|
|
|
4723
5094
|
// src/layout/review/DynamicReview.tsx
|
|
4724
|
-
var
|
|
4725
|
-
var
|
|
5095
|
+
var import_components24 = require("@transferwise/components");
|
|
5096
|
+
var import_jsx_runtime50 = require("react/jsx-runtime");
|
|
4726
5097
|
var getDefinitions = (orientation, review) => {
|
|
4727
5098
|
return review.fields.map(
|
|
4728
5099
|
({ label, value, help }, index) => {
|
|
@@ -4736,14 +5107,14 @@ var getDefinitions = (orientation, review) => {
|
|
|
4736
5107
|
};
|
|
4737
5108
|
var getFieldValue = (value, help, orientation) => {
|
|
4738
5109
|
if (help) {
|
|
4739
|
-
return orientation === "HORIZONTAL_RIGHT_ALIGNED" ? /* @__PURE__ */ (0,
|
|
4740
|
-
/* @__PURE__ */ (0,
|
|
5110
|
+
return orientation === "HORIZONTAL_RIGHT_ALIGNED" ? /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_jsx_runtime50.Fragment, { children: [
|
|
5111
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Help_default, { help }),
|
|
4741
5112
|
" ",
|
|
4742
5113
|
value
|
|
4743
|
-
] }) : /* @__PURE__ */ (0,
|
|
5114
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_jsx_runtime50.Fragment, { children: [
|
|
4744
5115
|
value,
|
|
4745
5116
|
" ",
|
|
4746
|
-
/* @__PURE__ */ (0,
|
|
5117
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Help_default, { help })
|
|
4747
5118
|
] });
|
|
4748
5119
|
}
|
|
4749
5120
|
return value;
|
|
@@ -4754,9 +5125,9 @@ var getReviewLayout = (review) => {
|
|
|
4754
5125
|
};
|
|
4755
5126
|
var DynamicReview = (props) => {
|
|
4756
5127
|
const review = props.component;
|
|
4757
|
-
const margin =
|
|
5128
|
+
const margin = getMargin(review.margin || "xs");
|
|
4758
5129
|
const getReviewAction = (action) => {
|
|
4759
|
-
return /* @__PURE__ */ (0,
|
|
5130
|
+
return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
4760
5131
|
"a",
|
|
4761
5132
|
{
|
|
4762
5133
|
href: action.url,
|
|
@@ -4771,36 +5142,36 @@ var DynamicReview = (props) => {
|
|
|
4771
5142
|
);
|
|
4772
5143
|
};
|
|
4773
5144
|
const orientation = getReviewLayout(review);
|
|
4774
|
-
return /* @__PURE__ */ (0,
|
|
4775
|
-
review.title && /* @__PURE__ */ (0,
|
|
5145
|
+
return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_jsx_runtime50.Fragment, { children: [
|
|
5146
|
+
review.title && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("h6", { className: "m-b-2", children: [
|
|
4776
5147
|
review.title,
|
|
4777
5148
|
review.action && getReviewAction(review.action)
|
|
4778
5149
|
] }),
|
|
4779
|
-
/* @__PURE__ */ (0,
|
|
5150
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: margin, children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_components24.DefinitionList, { layout: orientation, definitions: getDefinitions(orientation, review) }) })
|
|
4780
5151
|
] });
|
|
4781
5152
|
};
|
|
4782
5153
|
var DynamicReview_default = DynamicReview;
|
|
4783
5154
|
|
|
4784
5155
|
// src/layout/search/DynamicSearch.tsx
|
|
4785
|
-
var
|
|
5156
|
+
var import_react26 = require("react");
|
|
4786
5157
|
|
|
4787
5158
|
// src/layout/search/SearchInput.tsx
|
|
4788
|
-
var
|
|
4789
|
-
var
|
|
5159
|
+
var import_components25 = require("@transferwise/components");
|
|
5160
|
+
var import_jsx_runtime51 = require("react/jsx-runtime");
|
|
4790
5161
|
var SearchInput = ({ title, value, onChange }) => {
|
|
4791
|
-
return /* @__PURE__ */ (0,
|
|
5162
|
+
return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("label", { className: "control-label d-inline", children: [
|
|
4792
5163
|
title,
|
|
4793
|
-
/* @__PURE__ */ (0,
|
|
5164
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_components25.Input, { type: "text", value, onChange: (event) => onChange(event.currentTarget.value) })
|
|
4794
5165
|
] });
|
|
4795
5166
|
};
|
|
4796
5167
|
|
|
4797
5168
|
// src/layout/search/SearchResults.tsx
|
|
4798
|
-
var
|
|
4799
|
-
var
|
|
5169
|
+
var import_components26 = require("@transferwise/components");
|
|
5170
|
+
var import_react_intl19 = require("react-intl");
|
|
4800
5171
|
|
|
4801
5172
|
// src/dynamicFlow/utils/errorBoundary/ErrorBoundary.messages.ts
|
|
4802
|
-
var
|
|
4803
|
-
var ErrorBoundary_messages_default = (0,
|
|
5173
|
+
var import_react_intl18 = require("react-intl");
|
|
5174
|
+
var ErrorBoundary_messages_default = (0, import_react_intl18.defineMessages)({
|
|
4804
5175
|
errorAlert: {
|
|
4805
5176
|
id: "dynamicFlows.ErrorBoundary.errorAlert",
|
|
4806
5177
|
defaultMessage: "Oops. Something went wrong...",
|
|
@@ -4814,14 +5185,14 @@ var ErrorBoundary_messages_default = (0, import_react_intl15.defineMessages)({
|
|
|
4814
5185
|
});
|
|
4815
5186
|
|
|
4816
5187
|
// src/layout/search/SearchResults.tsx
|
|
4817
|
-
var
|
|
5188
|
+
var import_jsx_runtime52 = require("react/jsx-runtime");
|
|
4818
5189
|
var SearchResults = ({ results, emptyMessage, onSelect }) => {
|
|
4819
5190
|
if (results.length === 0) {
|
|
4820
|
-
return /* @__PURE__ */ (0,
|
|
5191
|
+
return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("p", { className: "m-t-2", children: emptyMessage });
|
|
4821
5192
|
}
|
|
4822
|
-
return /* @__PURE__ */ (0,
|
|
4823
|
-
return /* @__PURE__ */ (0,
|
|
4824
|
-
|
|
5193
|
+
return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_components26.NavigationOptionsList, { children: results.map((result) => {
|
|
5194
|
+
return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
|
|
5195
|
+
import_components26.NavigationOption,
|
|
4825
5196
|
{
|
|
4826
5197
|
title: result.title,
|
|
4827
5198
|
content: result.description,
|
|
@@ -4835,11 +5206,11 @@ var SearchResults = ({ results, emptyMessage, onSelect }) => {
|
|
|
4835
5206
|
}) });
|
|
4836
5207
|
};
|
|
4837
5208
|
var ErrorResult = ({ onRetrySearch }) => {
|
|
4838
|
-
const intl = (0,
|
|
4839
|
-
return /* @__PURE__ */ (0,
|
|
5209
|
+
const intl = (0, import_react_intl19.useIntl)();
|
|
5210
|
+
return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("p", { className: "m-t-2", children: [
|
|
4840
5211
|
intl.formatMessage(ErrorBoundary_messages_default.errorAlert),
|
|
4841
5212
|
"\xA0",
|
|
4842
|
-
/* @__PURE__ */ (0,
|
|
5213
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
|
|
4843
5214
|
"a",
|
|
4844
5215
|
{
|
|
4845
5216
|
href: "/",
|
|
@@ -4854,15 +5225,15 @@ var ErrorResult = ({ onRetrySearch }) => {
|
|
|
4854
5225
|
};
|
|
4855
5226
|
|
|
4856
5227
|
// src/layout/search/useSearch.tsx
|
|
4857
|
-
var
|
|
5228
|
+
var import_react25 = require("react");
|
|
4858
5229
|
var headers = { "Content-Type": "application/json" };
|
|
4859
5230
|
var useSearch = (defaultSearchConfig) => {
|
|
4860
|
-
const [state, setState] = (0,
|
|
5231
|
+
const [state, setState] = (0, import_react25.useState)({
|
|
4861
5232
|
status: "idle"
|
|
4862
5233
|
});
|
|
4863
|
-
const abortControllerRef = (0,
|
|
5234
|
+
const abortControllerRef = (0, import_react25.useRef)(null);
|
|
4864
5235
|
const httpClient = useHttpClient();
|
|
4865
|
-
const search = (0,
|
|
5236
|
+
const search = (0, import_react25.useCallback)(
|
|
4866
5237
|
async (query, { url, method, param } = defaultSearchConfig) => {
|
|
4867
5238
|
var _a;
|
|
4868
5239
|
(_a = abortControllerRef.current) == null ? void 0 : _a.abort();
|
|
@@ -4915,13 +5286,13 @@ var isValidResponseBody = (body) => {
|
|
|
4915
5286
|
var isAbortError = (error) => error instanceof DOMException && error.name === "AbortError";
|
|
4916
5287
|
|
|
4917
5288
|
// src/layout/search/DynamicSearch.tsx
|
|
4918
|
-
var
|
|
5289
|
+
var import_jsx_runtime53 = require("react/jsx-runtime");
|
|
4919
5290
|
var DEBOUNCE_TIME = 400;
|
|
4920
5291
|
var DynamicSearch = ({ component, onAction }) => {
|
|
4921
|
-
const [query, setQuery] = (0,
|
|
5292
|
+
const [query, setQuery] = (0, import_react26.useState)("");
|
|
4922
5293
|
const { title, margin, url, method, param, emptyMessage } = component;
|
|
4923
5294
|
const { status, results, search } = useSearch({ url, method, param });
|
|
4924
|
-
const debouncedSearch = (0,
|
|
5295
|
+
const debouncedSearch = (0, import_react26.useMemo)(() => debounce(search, DEBOUNCE_TIME), [search]);
|
|
4925
5296
|
const onChange = (value) => {
|
|
4926
5297
|
setQuery(value);
|
|
4927
5298
|
debouncedSearch(value);
|
|
@@ -4940,17 +5311,17 @@ var DynamicSearch = ({ component, onAction }) => {
|
|
|
4940
5311
|
setQuery(query);
|
|
4941
5312
|
void search(query);
|
|
4942
5313
|
};
|
|
4943
|
-
return /* @__PURE__ */ (0,
|
|
4944
|
-
/* @__PURE__ */ (0,
|
|
4945
|
-
status === "loading" && /* @__PURE__ */ (0,
|
|
4946
|
-
status === "error" && /* @__PURE__ */ (0,
|
|
4947
|
-
status === "success" && /* @__PURE__ */ (0,
|
|
5314
|
+
return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: getMargin(margin), children: [
|
|
5315
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(SearchInput, { title, value: query, onChange }),
|
|
5316
|
+
status === "loading" && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(DynamicLoadingIndicator_default, { component: { type: "loading-indicator", size: "sm" } }),
|
|
5317
|
+
status === "error" && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(ErrorResult, { onRetrySearch }),
|
|
5318
|
+
status === "success" && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(SearchResults, { results, emptyMessage, onSelect: onResultSelected })
|
|
4948
5319
|
] });
|
|
4949
5320
|
};
|
|
4950
5321
|
var DynamicSearch_default = DynamicSearch;
|
|
4951
5322
|
|
|
4952
5323
|
// src/jsonSchemaForm/basicTypeSchema/BasicTypeSchema.tsx
|
|
4953
|
-
var
|
|
5324
|
+
var import_jsx_runtime54 = require("react/jsx-runtime");
|
|
4954
5325
|
var isNullish = (value) => isNull(value) || isUndefined(value);
|
|
4955
5326
|
var getDefaultValue = (schema) => {
|
|
4956
5327
|
return schema.type === "boolean" && isNullish(schema.default) ? false : schema.default;
|
|
@@ -4987,13 +5358,13 @@ var BasicTypeSchema = (props) => {
|
|
|
4987
5358
|
props.onBlur();
|
|
4988
5359
|
}
|
|
4989
5360
|
};
|
|
4990
|
-
const [model, setModel] = (0,
|
|
4991
|
-
const [lastModel, setLastModel] = (0,
|
|
4992
|
-
const [changed, setChanged] = (0,
|
|
4993
|
-
const [focused, setFocused] = (0,
|
|
4994
|
-
const [blurred, setBlurred] = (0,
|
|
4995
|
-
const [validations, setValidations] = (0,
|
|
4996
|
-
const id = (0,
|
|
5361
|
+
const [model, setModel] = (0, import_react27.useState)((_a = props.model) != null ? _a : null);
|
|
5362
|
+
const [lastModel, setLastModel] = (0, import_react27.useState)((_b = props.model) != null ? _b : null);
|
|
5363
|
+
const [changed, setChanged] = (0, import_react27.useState)(false);
|
|
5364
|
+
const [focused, setFocused] = (0, import_react27.useState)(false);
|
|
5365
|
+
const [blurred, setBlurred] = (0, import_react27.useState)(false);
|
|
5366
|
+
const [validations, setValidations] = (0, import_react27.useState)([]);
|
|
5367
|
+
const id = (0, import_react27.useMemo)(() => props.schema.$id || generateRandomId(), [props.schema.$id]);
|
|
4997
5368
|
const onSchemaChange = () => {
|
|
4998
5369
|
const defaultValue = getDefaultValue(props.schema);
|
|
4999
5370
|
if (isNullish(model) && !isNullish(defaultValue)) {
|
|
@@ -5008,9 +5379,9 @@ var BasicTypeSchema = (props) => {
|
|
|
5008
5379
|
};
|
|
5009
5380
|
const isConst = props.schema.const;
|
|
5010
5381
|
const isHidden = props.schema.hidden || isConst;
|
|
5011
|
-
(0,
|
|
5012
|
-
(0,
|
|
5013
|
-
(0,
|
|
5382
|
+
(0, import_react27.useEffect)(refreshValidations, [props.model, props.submitted]);
|
|
5383
|
+
(0, import_react27.useEffect)(onSchemaChange, [props.schema]);
|
|
5384
|
+
(0, import_react27.useEffect)(() => {
|
|
5014
5385
|
var _a2;
|
|
5015
5386
|
const newModel = (_a2 = props.model) != null ? _a2 : null;
|
|
5016
5387
|
if (newModel !== model) {
|
|
@@ -5024,15 +5395,15 @@ var BasicTypeSchema = (props) => {
|
|
|
5024
5395
|
};
|
|
5025
5396
|
const showLabel = props.schema.format !== "file" && props.schema.type !== "boolean";
|
|
5026
5397
|
const schemaHelp = props.schema.help;
|
|
5027
|
-
return !isHidden ? /* @__PURE__ */ (0,
|
|
5028
|
-
props.schema.alert && /* @__PURE__ */ (0,
|
|
5029
|
-
/* @__PURE__ */ (0,
|
|
5030
|
-
showLabel && /* @__PURE__ */ (0,
|
|
5031
|
-
/* @__PURE__ */ (0,
|
|
5032
|
-
!!schemaHelp && /* @__PURE__ */ (0,
|
|
5398
|
+
return !isHidden ? /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(import_jsx_runtime54.Fragment, { children: [
|
|
5399
|
+
props.schema.alert && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(DynamicAlert_default, { component: props.schema.alert }),
|
|
5400
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("div", { className: (0, import_classnames6.default)(formGroupClasses), children: [
|
|
5401
|
+
showLabel && /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("div", { className: "d-inline-block", children: [
|
|
5402
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("label", { className: "control-label d-inline", htmlFor: id, children: props.schema.title }),
|
|
5403
|
+
!!schemaHelp && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(Help_default, { help: schemaHelp })
|
|
5033
5404
|
] }),
|
|
5034
|
-
!showLabel && !!schemaHelp && /* @__PURE__ */ (0,
|
|
5035
|
-
/* @__PURE__ */ (0,
|
|
5405
|
+
!showLabel && !!schemaHelp && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(Help_default, { help: schemaHelp }),
|
|
5406
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
5036
5407
|
SchemaFormControl_default,
|
|
5037
5408
|
{
|
|
5038
5409
|
id,
|
|
@@ -5044,7 +5415,7 @@ var BasicTypeSchema = (props) => {
|
|
|
5044
5415
|
onBlur
|
|
5045
5416
|
}
|
|
5046
5417
|
),
|
|
5047
|
-
/* @__PURE__ */ (0,
|
|
5418
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
5048
5419
|
ControlFeedback_default,
|
|
5049
5420
|
{
|
|
5050
5421
|
changed,
|
|
@@ -5068,7 +5439,7 @@ BasicTypeSchema.defaultProps = {
|
|
|
5068
5439
|
var BasicTypeSchema_default = BasicTypeSchema;
|
|
5069
5440
|
|
|
5070
5441
|
// src/jsonSchemaForm/persistAsyncSchema/persistAsyncBasicSchema/PersistAsyncBasicSchema.tsx
|
|
5071
|
-
var
|
|
5442
|
+
var import_jsx_runtime55 = require("react/jsx-runtime");
|
|
5072
5443
|
var getIdFromResponse = (idProperty, response) => {
|
|
5073
5444
|
return response[idProperty];
|
|
5074
5445
|
};
|
|
@@ -5085,15 +5456,15 @@ var controlTypesWithPersistOnChange = /* @__PURE__ */ new Set([
|
|
|
5085
5456
|
]);
|
|
5086
5457
|
var PersistAsyncBasicSchema = (props) => {
|
|
5087
5458
|
const { schema, required, submitted, errors, onChange, onPersistAsync } = props;
|
|
5088
|
-
const intl = (0,
|
|
5459
|
+
const intl = (0, import_react_intl20.useIntl)();
|
|
5089
5460
|
const httpClient = useHttpClient();
|
|
5090
5461
|
const onEvent = useEventDispatcher();
|
|
5091
|
-
const [persistAsyncModel, setPersistAsyncModel] = (0,
|
|
5462
|
+
const [persistAsyncModel, setPersistAsyncModel] = (0, import_react28.useState)(null);
|
|
5092
5463
|
const previousPersistAsyncModel = usePrevious(persistAsyncModel);
|
|
5093
|
-
const [persistAsyncError, setPersistAsyncError] = (0,
|
|
5094
|
-
const [fieldSubmitted, setFieldSubmitted] = (0,
|
|
5095
|
-
const [abortController, setAbortController] = (0,
|
|
5096
|
-
(0,
|
|
5464
|
+
const [persistAsyncError, setPersistAsyncError] = (0, import_react28.useState)(null);
|
|
5465
|
+
const [fieldSubmitted, setFieldSubmitted] = (0, import_react28.useState)(false);
|
|
5466
|
+
const [abortController, setAbortController] = (0, import_react28.useState)(null);
|
|
5467
|
+
(0, import_react28.useEffect)(() => {
|
|
5097
5468
|
if (controlTypesWithPersistOnChange.has(
|
|
5098
5469
|
// TODO: LOW avoid type assertion below -- control type may be nullish. consider ?? ''
|
|
5099
5470
|
getControlType(schema.persistAsync.schema)
|
|
@@ -5160,7 +5531,7 @@ var PersistAsyncBasicSchema = (props) => {
|
|
|
5160
5531
|
setPersistAsyncModel(newPersistAsyncModel);
|
|
5161
5532
|
}
|
|
5162
5533
|
};
|
|
5163
|
-
return /* @__PURE__ */ (0,
|
|
5534
|
+
return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
5164
5535
|
BasicTypeSchema_default,
|
|
5165
5536
|
{
|
|
5166
5537
|
required,
|
|
@@ -5181,9 +5552,9 @@ var PersistAsyncBasicSchema_default = PersistAsyncBasicSchema;
|
|
|
5181
5552
|
|
|
5182
5553
|
// src/common/hooks/usePersistAsync/usePersistAsync.ts
|
|
5183
5554
|
var usePersistAsync = (persistAsync) => {
|
|
5184
|
-
const [abortController, setAbortController] = (0,
|
|
5555
|
+
const [abortController, setAbortController] = (0, import_react29.useState)(null);
|
|
5185
5556
|
const httpClient = useHttpClient();
|
|
5186
|
-
const intl = (0,
|
|
5557
|
+
const intl = (0, import_react_intl21.useIntl)();
|
|
5187
5558
|
const { schema } = persistAsync;
|
|
5188
5559
|
async function handlePersistAsync(model) {
|
|
5189
5560
|
const isInvalidSchema = model instanceof Blob ? !isBlobSchema(schema) : !isValidSchema(model, schema);
|
|
@@ -5260,7 +5631,7 @@ function hasStringMessage(value) {
|
|
|
5260
5631
|
}
|
|
5261
5632
|
|
|
5262
5633
|
// src/common/hooks/usePolling/usePolling.tsx
|
|
5263
|
-
var
|
|
5634
|
+
var import_react30 = require("react");
|
|
5264
5635
|
function usePolling({
|
|
5265
5636
|
asyncFn,
|
|
5266
5637
|
interval,
|
|
@@ -5269,9 +5640,9 @@ function usePolling({
|
|
|
5269
5640
|
onPollingResponse,
|
|
5270
5641
|
onFailure
|
|
5271
5642
|
}) {
|
|
5272
|
-
const onPollingResponseReference = (0,
|
|
5273
|
-
const onFailureReference = (0,
|
|
5274
|
-
const poll = (0,
|
|
5643
|
+
const onPollingResponseReference = (0, import_react30.useRef)(onPollingResponse);
|
|
5644
|
+
const onFailureReference = (0, import_react30.useRef)(onFailure);
|
|
5645
|
+
const poll = (0, import_react30.useMemo)(
|
|
5275
5646
|
() => createPollingClosure(
|
|
5276
5647
|
asyncFn,
|
|
5277
5648
|
maxAttempts,
|
|
@@ -5281,7 +5652,7 @@ function usePolling({
|
|
|
5281
5652
|
),
|
|
5282
5653
|
[asyncFn, maxAttempts, maxConsecutiveFails]
|
|
5283
5654
|
);
|
|
5284
|
-
(0,
|
|
5655
|
+
(0, import_react30.useEffect)(() => {
|
|
5285
5656
|
if (interval > 0) {
|
|
5286
5657
|
const intervalReference = setInterval(() => {
|
|
5287
5658
|
poll();
|
|
@@ -5289,7 +5660,7 @@ function usePolling({
|
|
|
5289
5660
|
return () => clearInterval(intervalReference);
|
|
5290
5661
|
}
|
|
5291
5662
|
}, [poll, interval]);
|
|
5292
|
-
(0,
|
|
5663
|
+
(0, import_react30.useEffect)(() => {
|
|
5293
5664
|
onPollingResponseReference.current = onPollingResponse;
|
|
5294
5665
|
onFailureReference.current = onFailure;
|
|
5295
5666
|
}, [onPollingResponse, onFailure]);
|
|
@@ -5318,20 +5689,20 @@ function createPollingClosure(asyncFn, maxAttempts, maxConsecutiveFails, onPolli
|
|
|
5318
5689
|
}
|
|
5319
5690
|
|
|
5320
5691
|
// src/common/hooks/usePrevious/usePrevious.js
|
|
5321
|
-
var
|
|
5692
|
+
var import_react31 = require("react");
|
|
5322
5693
|
var usePrevious = (value) => {
|
|
5323
|
-
const reference = (0,
|
|
5324
|
-
(0,
|
|
5694
|
+
const reference = (0, import_react31.useRef)();
|
|
5695
|
+
(0, import_react31.useEffect)(() => {
|
|
5325
5696
|
reference.current = value;
|
|
5326
5697
|
}, [value]);
|
|
5327
5698
|
return reference.current;
|
|
5328
5699
|
};
|
|
5329
5700
|
|
|
5330
5701
|
// src/common/hooks/useStepPolling/useStepPolling.tsx
|
|
5331
|
-
var
|
|
5702
|
+
var import_react32 = require("react");
|
|
5332
5703
|
function useStepPolling(polling, onAction) {
|
|
5333
5704
|
const httpClient = useHttpClient();
|
|
5334
|
-
const asyncFn = (0,
|
|
5705
|
+
const asyncFn = (0, import_react32.useMemo)(() => {
|
|
5335
5706
|
if (polling) {
|
|
5336
5707
|
return () => {
|
|
5337
5708
|
return httpClient(polling.url).then((response) => {
|
|
@@ -5346,7 +5717,7 @@ function useStepPolling(polling, onAction) {
|
|
|
5346
5717
|
return void 0;
|
|
5347
5718
|
}
|
|
5348
5719
|
}, [polling, httpClient]);
|
|
5349
|
-
const onPollingResponse = (0,
|
|
5720
|
+
const onPollingResponse = (0, import_react32.useCallback)(
|
|
5350
5721
|
(pollingResponse) => {
|
|
5351
5722
|
if (pollingResponse == null ? void 0 : pollingResponse.action) {
|
|
5352
5723
|
onAction(pollingResponse.action);
|
|
@@ -5362,7 +5733,7 @@ function useStepPolling(polling, onAction) {
|
|
|
5362
5733
|
maxAttempts: (polling == null ? void 0 : polling.maxAttempts) || 0,
|
|
5363
5734
|
maxConsecutiveFails: 1,
|
|
5364
5735
|
onPollingResponse,
|
|
5365
|
-
onFailure: (0,
|
|
5736
|
+
onFailure: (0, import_react32.useCallback)(() => {
|
|
5366
5737
|
if (polling) {
|
|
5367
5738
|
onAction(polling.onError.action);
|
|
5368
5739
|
}
|
|
@@ -5371,7 +5742,7 @@ function useStepPolling(polling, onAction) {
|
|
|
5371
5742
|
}
|
|
5372
5743
|
|
|
5373
5744
|
// src/step/layoutStep/LayoutStep.tsx
|
|
5374
|
-
var
|
|
5745
|
+
var import_jsx_runtime56 = require("react/jsx-runtime");
|
|
5375
5746
|
var getComponents = (step, options) => {
|
|
5376
5747
|
var _a;
|
|
5377
5748
|
if (isEmpty(step)) {
|
|
@@ -5394,7 +5765,7 @@ var LayoutStep = (props) => {
|
|
|
5394
5765
|
onEvent("Dynamic Flow - onAction supressed", { reason: "LayoutStep - loading state" });
|
|
5395
5766
|
};
|
|
5396
5767
|
useStepPolling(stepSpecification.polling, onAction);
|
|
5397
|
-
return /* @__PURE__ */ (0,
|
|
5768
|
+
return /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
5398
5769
|
DynamicLayout_default,
|
|
5399
5770
|
{
|
|
5400
5771
|
components,
|
|
@@ -5410,16 +5781,16 @@ var LayoutStep = (props) => {
|
|
|
5410
5781
|
var LayoutStep_default = LayoutStep;
|
|
5411
5782
|
|
|
5412
5783
|
// src/step/cameraStep/CameraStep.tsx
|
|
5413
|
-
var
|
|
5784
|
+
var import_react36 = require("react");
|
|
5414
5785
|
|
|
5415
5786
|
// src/step/cameraStep/cameraCapture/CameraCapture.tsx
|
|
5416
|
-
var
|
|
5417
|
-
var
|
|
5787
|
+
var import_react35 = require("react");
|
|
5788
|
+
var import_react_intl28 = require("react-intl");
|
|
5418
5789
|
var import_react_webcam = __toESM(require_react_webcam());
|
|
5419
5790
|
|
|
5420
5791
|
// src/step/cameraStep/cameraCapture/CameraCapture.messages.ts
|
|
5421
|
-
var
|
|
5422
|
-
var CameraCapture_messages_default = (0,
|
|
5792
|
+
var import_react_intl22 = require("react-intl");
|
|
5793
|
+
var CameraCapture_messages_default = (0, import_react_intl22.defineMessages)({
|
|
5423
5794
|
reviewSubmit: {
|
|
5424
5795
|
id: "dynamicFlows.CameraCapture.reviewSubmit",
|
|
5425
5796
|
defaultMessage: "Yes, submit",
|
|
@@ -5438,54 +5809,54 @@ var CameraCapture_messages_default = (0, import_react_intl19.defineMessages)({
|
|
|
5438
5809
|
});
|
|
5439
5810
|
|
|
5440
5811
|
// src/step/cameraStep/cameraCapture/components/index.tsx
|
|
5441
|
-
var
|
|
5442
|
-
var
|
|
5443
|
-
var
|
|
5444
|
-
var CaptureBottomBar = ({ onCapture }) => /* @__PURE__ */ (0,
|
|
5812
|
+
var import_components27 = require("@transferwise/components");
|
|
5813
|
+
var import_react_intl23 = require("react-intl");
|
|
5814
|
+
var import_jsx_runtime57 = require("react/jsx-runtime");
|
|
5815
|
+
var CaptureBottomBar = ({ onCapture }) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "bottom-bar", children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(CaptureButton, { onClick: onCapture }) });
|
|
5445
5816
|
var ReviewBottomBar = ({
|
|
5446
5817
|
onSubmit,
|
|
5447
5818
|
onRetry
|
|
5448
5819
|
}) => {
|
|
5449
|
-
const intl = (0,
|
|
5450
|
-
return /* @__PURE__ */ (0,
|
|
5451
|
-
/* @__PURE__ */ (0,
|
|
5452
|
-
|
|
5820
|
+
const intl = (0, import_react_intl23.useIntl)();
|
|
5821
|
+
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: [
|
|
5822
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
|
|
5823
|
+
import_components27.Button,
|
|
5453
5824
|
{
|
|
5454
5825
|
className: "m-b-1",
|
|
5455
5826
|
block: true,
|
|
5456
|
-
size:
|
|
5457
|
-
type:
|
|
5827
|
+
size: import_components27.Size.MEDIUM,
|
|
5828
|
+
type: import_components27.ControlType.ACCENT,
|
|
5458
5829
|
onClick: onSubmit,
|
|
5459
5830
|
children: intl.formatMessage(CameraCapture_messages_default.reviewSubmit)
|
|
5460
5831
|
}
|
|
5461
5832
|
),
|
|
5462
|
-
/* @__PURE__ */ (0,
|
|
5463
|
-
|
|
5833
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
|
|
5834
|
+
import_components27.Button,
|
|
5464
5835
|
{
|
|
5465
5836
|
className: "m-b-2",
|
|
5466
5837
|
block: true,
|
|
5467
|
-
size:
|
|
5468
|
-
type:
|
|
5469
|
-
priority:
|
|
5838
|
+
size: import_components27.Size.MEDIUM,
|
|
5839
|
+
type: import_components27.ControlType.ACCENT,
|
|
5840
|
+
priority: import_components27.Priority.SECONDARY,
|
|
5470
5841
|
onClick: onRetry,
|
|
5471
5842
|
children: intl.formatMessage(CameraCapture_messages_default.reviewRetry)
|
|
5472
5843
|
}
|
|
5473
5844
|
)
|
|
5474
5845
|
] }) }) });
|
|
5475
5846
|
};
|
|
5476
|
-
var CaptureButton = ({ onClick }) => /* @__PURE__ */ (0,
|
|
5847
|
+
var CaptureButton = ({ onClick }) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
|
|
5477
5848
|
"button",
|
|
5478
5849
|
{
|
|
5479
5850
|
type: "button",
|
|
5480
5851
|
className: "camera-capture-btn m-b-2",
|
|
5481
5852
|
"data-testid": "camera-capture-button",
|
|
5482
5853
|
onClick,
|
|
5483
|
-
children: /* @__PURE__ */ (0,
|
|
5854
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("span", { className: "camera-capture-btn-inner" })
|
|
5484
5855
|
}
|
|
5485
5856
|
);
|
|
5486
5857
|
|
|
5487
5858
|
// src/step/cameraStep/cameraCapture/hooks/index.ts
|
|
5488
|
-
var
|
|
5859
|
+
var import_react33 = require("react");
|
|
5489
5860
|
|
|
5490
5861
|
// src/step/cameraStep/cameraCapture/utils/index.ts
|
|
5491
5862
|
var isSelfieCamera = (stream) => {
|
|
@@ -5533,7 +5904,7 @@ var getVideoCapabilities = (videoStream) => {
|
|
|
5533
5904
|
|
|
5534
5905
|
// src/step/cameraStep/cameraCapture/hooks/index.ts
|
|
5535
5906
|
var useVideoConstraints = (direction) => {
|
|
5536
|
-
const [videoConstraints, setVideoConstraints] = (0,
|
|
5907
|
+
const [videoConstraints, setVideoConstraints] = (0, import_react33.useState)();
|
|
5537
5908
|
const defaultVideoConstraints = {
|
|
5538
5909
|
facingMode: direction === "front" ? "user" : "environment",
|
|
5539
5910
|
height: { min: 480, max: 1080, ideal: 720 },
|
|
@@ -5541,7 +5912,7 @@ var useVideoConstraints = (direction) => {
|
|
|
5541
5912
|
frameRate: 30,
|
|
5542
5913
|
aspectRatio: 16 / 9
|
|
5543
5914
|
};
|
|
5544
|
-
(0,
|
|
5915
|
+
(0, import_react33.useEffect)(() => {
|
|
5545
5916
|
void getVideoConstraints(direction).then(setVideoConstraints);
|
|
5546
5917
|
}, [direction]);
|
|
5547
5918
|
const getVideoConstraints = async (direction2) => {
|
|
@@ -5559,8 +5930,8 @@ var useVideoConstraints = (direction) => {
|
|
|
5559
5930
|
};
|
|
5560
5931
|
|
|
5561
5932
|
// src/step/cameraStep/cameraCapture/overlay/Overlay.tsx
|
|
5562
|
-
var
|
|
5563
|
-
var
|
|
5933
|
+
var import_react34 = require("react");
|
|
5934
|
+
var import_jsx_runtime58 = require("react/jsx-runtime");
|
|
5564
5935
|
var captureButtonHeight = 92;
|
|
5565
5936
|
var reviewButtonsHeight = 120;
|
|
5566
5937
|
var imageHeight = 40;
|
|
@@ -5576,8 +5947,8 @@ var Overlay = ({
|
|
|
5576
5947
|
instructions,
|
|
5577
5948
|
reviewInstructions
|
|
5578
5949
|
}) => {
|
|
5579
|
-
const svgReference = (0,
|
|
5580
|
-
(0,
|
|
5950
|
+
const svgReference = (0, import_react34.useRef)(null);
|
|
5951
|
+
(0, import_react34.useEffect)(() => {
|
|
5581
5952
|
const listener = debounce(() => {
|
|
5582
5953
|
var _a;
|
|
5583
5954
|
if ((_a = svgReference.current) == null ? void 0 : _a.innerHTML) {
|
|
@@ -5589,18 +5960,18 @@ var Overlay = ({
|
|
|
5589
5960
|
return () => window.removeEventListener("resize", listener);
|
|
5590
5961
|
});
|
|
5591
5962
|
let helperBoxHeight = (imageUrl ? imageHeight : 0) + (title ? titleHeight : 0) + (instructions ? instructionsHeight : 0);
|
|
5592
|
-
let helperBox = /* @__PURE__ */ (0,
|
|
5593
|
-
imageUrl && /* @__PURE__ */ (0,
|
|
5594
|
-
title && /* @__PURE__ */ (0,
|
|
5595
|
-
instructions && /* @__PURE__ */ (0,
|
|
5963
|
+
let helperBox = /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_jsx_runtime58.Fragment, { children: [
|
|
5964
|
+
imageUrl && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("img", { className: "camera-capture-img", src: imageUrl, alt: "" }),
|
|
5965
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("h4", { className: "camera-capture-title", children: title }),
|
|
5966
|
+
instructions && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("small", { className: "camera-capture-instructions", children: instructions })
|
|
5596
5967
|
] });
|
|
5597
5968
|
const frameBottomMargin = captureButtonHeight + helperBoxHeight;
|
|
5598
5969
|
if (reviewInstructions) {
|
|
5599
5970
|
helperBoxHeight = frameBottomMargin - reviewButtonsHeight;
|
|
5600
|
-
helperBox = /* @__PURE__ */ (0,
|
|
5971
|
+
helperBox = /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("small", { className: "camera-capture-instructions", children: reviewInstructions });
|
|
5601
5972
|
const frameWithReviewInstructionsMinBottomMargin = reviewButtonsHeight + reviewInstructionsHeight;
|
|
5602
5973
|
if (frameBottomMargin < frameWithReviewInstructionsMinBottomMargin) {
|
|
5603
|
-
helperBox = /* @__PURE__ */ (0,
|
|
5974
|
+
helperBox = /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_jsx_runtime58.Fragment, {});
|
|
5604
5975
|
}
|
|
5605
5976
|
}
|
|
5606
5977
|
const framePosition = {
|
|
@@ -5618,25 +5989,25 @@ var Overlay = ({
|
|
|
5618
5989
|
width: "90%"
|
|
5619
5990
|
}
|
|
5620
5991
|
};
|
|
5621
|
-
return /* @__PURE__ */ (0,
|
|
5622
|
-
/* @__PURE__ */ (0,
|
|
5623
|
-
/* @__PURE__ */ (0,
|
|
5624
|
-
/* @__PURE__ */ (0,
|
|
5992
|
+
return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("svg", { ref: svgReference, xmlns: "http://www.w3.org/2000/svg", children: [
|
|
5993
|
+
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("mask", { id: "mask", children: [
|
|
5994
|
+
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)("rect", { width: "100%", height: "100%", fill: "#fff" }),
|
|
5995
|
+
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)("image", __spreadValues({ href: overlay }, framePosition))
|
|
5625
5996
|
] }) }),
|
|
5626
|
-
overlay && /* @__PURE__ */ (0,
|
|
5627
|
-
outline && /* @__PURE__ */ (0,
|
|
5628
|
-
/* @__PURE__ */ (0,
|
|
5997
|
+
overlay && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("rect", { width: "100%", height: "100%", mask: "url(#mask)", fillOpacity: "0.72" }),
|
|
5998
|
+
outline && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("image", __spreadValues({ href: outline }, framePosition)),
|
|
5999
|
+
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)("foreignObject", { width: "100%", height: "100%", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", __spreadProps(__spreadValues({ className: "camera-capture-text-and-image-container" }, helperBoxPosition), { children: helperBox })) })
|
|
5629
6000
|
] });
|
|
5630
6001
|
};
|
|
5631
6002
|
var Overlay_default = Overlay;
|
|
5632
6003
|
|
|
5633
6004
|
// src/step/cameraStep/cameraCapture/screens/NoCameraAccess/NoCameraAccess.tsx
|
|
5634
|
-
var
|
|
5635
|
-
var
|
|
6005
|
+
var import_components28 = require("@transferwise/components");
|
|
6006
|
+
var import_react_intl25 = require("react-intl");
|
|
5636
6007
|
|
|
5637
6008
|
// src/step/cameraStep/cameraCapture/screens/NoCameraAccess/NoCameraAccess.messages.ts
|
|
5638
|
-
var
|
|
5639
|
-
var NoCameraAccess_messages_default = (0,
|
|
6009
|
+
var import_react_intl24 = require("react-intl");
|
|
6010
|
+
var NoCameraAccess_messages_default = (0, import_react_intl24.defineMessages)({
|
|
5640
6011
|
title: {
|
|
5641
6012
|
id: "dynamicFlows.CameraCapture.NoCameraAccess.title",
|
|
5642
6013
|
defaultMessage: "We can't access your camera",
|
|
@@ -5655,23 +6026,23 @@ var NoCameraAccess_messages_default = (0, import_react_intl21.defineMessages)({
|
|
|
5655
6026
|
});
|
|
5656
6027
|
|
|
5657
6028
|
// src/step/cameraStep/cameraCapture/screens/NoCameraAccess/NoCameraAccess.tsx
|
|
5658
|
-
var
|
|
6029
|
+
var import_jsx_runtime59 = require("react/jsx-runtime");
|
|
5659
6030
|
var NoCameraAccess = ({ onAction }) => {
|
|
5660
|
-
const intl = (0,
|
|
5661
|
-
return /* @__PURE__ */ (0,
|
|
5662
|
-
/* @__PURE__ */ (0,
|
|
5663
|
-
/* @__PURE__ */ (0,
|
|
5664
|
-
/* @__PURE__ */ (0,
|
|
6031
|
+
const intl = (0, import_react_intl25.useIntl)();
|
|
6032
|
+
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: [
|
|
6033
|
+
/* @__PURE__ */ (0, import_jsx_runtime59.jsx)("h2", { className: "text-xs-center m-b-3", children: intl.formatMessage(NoCameraAccess_messages_default.title) }),
|
|
6034
|
+
/* @__PURE__ */ (0, import_jsx_runtime59.jsx)("p", { className: "text-xs-center m-b-5", children: intl.formatMessage(NoCameraAccess_messages_default.paragraph) }),
|
|
6035
|
+
/* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_components28.Button, { block: true, onClick: onAction, children: intl.formatMessage(NoCameraAccess_messages_default.action) })
|
|
5665
6036
|
] }) }) }) });
|
|
5666
6037
|
};
|
|
5667
6038
|
var NoCameraAccess_default = NoCameraAccess;
|
|
5668
6039
|
|
|
5669
6040
|
// src/step/cameraStep/cameraCapture/screens/CameraNotSupported/CameraNotSupported.tsx
|
|
5670
|
-
var
|
|
6041
|
+
var import_react_intl27 = require("react-intl");
|
|
5671
6042
|
|
|
5672
6043
|
// src/step/cameraStep/cameraCapture/screens/CameraNotSupported/CameraNotSupported.messages.ts
|
|
5673
|
-
var
|
|
5674
|
-
var CameraNotSupported_messages_default = (0,
|
|
6044
|
+
var import_react_intl26 = require("react-intl");
|
|
6045
|
+
var CameraNotSupported_messages_default = (0, import_react_intl26.defineMessages)({
|
|
5675
6046
|
title: {
|
|
5676
6047
|
id: "dynamicFlows.CameraCapture.CameraNotSupported.title",
|
|
5677
6048
|
defaultMessage: "Camera not supported",
|
|
@@ -5685,12 +6056,12 @@ var CameraNotSupported_messages_default = (0, import_react_intl23.defineMessages
|
|
|
5685
6056
|
});
|
|
5686
6057
|
|
|
5687
6058
|
// src/step/cameraStep/cameraCapture/screens/CameraNotSupported/CameraNotSupported.tsx
|
|
5688
|
-
var
|
|
6059
|
+
var import_jsx_runtime60 = require("react/jsx-runtime");
|
|
5689
6060
|
var CameraNotSupported = () => {
|
|
5690
|
-
const intl = (0,
|
|
5691
|
-
return /* @__PURE__ */ (0,
|
|
5692
|
-
/* @__PURE__ */ (0,
|
|
5693
|
-
/* @__PURE__ */ (0,
|
|
6061
|
+
const intl = (0, import_react_intl27.useIntl)();
|
|
6062
|
+
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: [
|
|
6063
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)("h2", { className: "text-xs-center m-b-3", children: intl.formatMessage(CameraNotSupported_messages_default.title) }),
|
|
6064
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)("p", { className: "text-xs-center m-b-5", children: intl.formatMessage(CameraNotSupported_messages_default.paragraph) })
|
|
5694
6065
|
] }) }) }) });
|
|
5695
6066
|
};
|
|
5696
6067
|
var CameraNotSupported_default = CameraNotSupported;
|
|
@@ -5715,7 +6086,7 @@ var getCameraStartedProperties = async (props, videoStream) => {
|
|
|
5715
6086
|
};
|
|
5716
6087
|
|
|
5717
6088
|
// src/step/cameraStep/cameraCapture/CameraCapture.tsx
|
|
5718
|
-
var
|
|
6089
|
+
var import_jsx_runtime61 = require("react/jsx-runtime");
|
|
5719
6090
|
var CameraCapture = ({
|
|
5720
6091
|
direction = "back",
|
|
5721
6092
|
overlay = "",
|
|
@@ -5727,14 +6098,14 @@ var CameraCapture = ({
|
|
|
5727
6098
|
onCapture,
|
|
5728
6099
|
onEvent
|
|
5729
6100
|
}) => {
|
|
5730
|
-
const [mode, setMode] = (0,
|
|
5731
|
-
const [isVideoMirrored, setIsVideoMirrored] = (0,
|
|
5732
|
-
const [ready, setReady] = (0,
|
|
5733
|
-
const [reviewImage, setReviewImage] = (0,
|
|
5734
|
-
const webcamReference = (0,
|
|
6101
|
+
const [mode, setMode] = (0, import_react35.useState)("CAPTURE");
|
|
6102
|
+
const [isVideoMirrored, setIsVideoMirrored] = (0, import_react35.useState)(false);
|
|
6103
|
+
const [ready, setReady] = (0, import_react35.useState)(false);
|
|
6104
|
+
const [reviewImage, setReviewImage] = (0, import_react35.useState)();
|
|
6105
|
+
const webcamReference = (0, import_react35.useRef)(null);
|
|
5735
6106
|
const { videoConstraints } = useVideoConstraints(direction);
|
|
5736
|
-
const intl = (0,
|
|
5737
|
-
const handleCapture = (0,
|
|
6107
|
+
const intl = (0, import_react_intl28.useIntl)();
|
|
6108
|
+
const handleCapture = (0, import_react35.useCallback)(async () => {
|
|
5738
6109
|
var _a, _b, _c, _d, _e, _f;
|
|
5739
6110
|
if (((_a = webcamReference == null ? void 0 : webcamReference.current) == null ? void 0 : _a.video) && ((_c = (_b = webcamReference == null ? void 0 : webcamReference.current) == null ? void 0 : _b.video) == null ? void 0 : _c.readyState) >= 3) {
|
|
5740
6111
|
(_e = (_d = webcamReference == null ? void 0 : webcamReference.current) == null ? void 0 : _d.video) == null ? void 0 : _e.pause();
|
|
@@ -5756,7 +6127,7 @@ var CameraCapture = ({
|
|
|
5756
6127
|
);
|
|
5757
6128
|
}
|
|
5758
6129
|
}, [webcamReference, showReview, setReviewImage, setMode, onCapture, isVideoMirrored]);
|
|
5759
|
-
const handleUserMediaError = (0,
|
|
6130
|
+
const handleUserMediaError = (0, import_react35.useCallback)(
|
|
5760
6131
|
(error) => {
|
|
5761
6132
|
if (error instanceof DOMException && (error == null ? void 0 : error.name) === "NotAllowedError") {
|
|
5762
6133
|
setMode("NO_CAMERA_ACCESS");
|
|
@@ -5768,7 +6139,7 @@ var CameraCapture = ({
|
|
|
5768
6139
|
},
|
|
5769
6140
|
[setMode, onEvent]
|
|
5770
6141
|
);
|
|
5771
|
-
const handleUserMedia = (0,
|
|
6142
|
+
const handleUserMedia = (0, import_react35.useCallback)(
|
|
5772
6143
|
(stream) => {
|
|
5773
6144
|
setReady(true);
|
|
5774
6145
|
setIsVideoMirrored(isSelfieCamera(stream));
|
|
@@ -5784,8 +6155,8 @@ var CameraCapture = ({
|
|
|
5784
6155
|
setReviewImage(void 0);
|
|
5785
6156
|
};
|
|
5786
6157
|
const handleRetryCameraAccess = () => setMode("CAPTURE");
|
|
5787
|
-
const captureScreen = /* @__PURE__ */ (0,
|
|
5788
|
-
videoConstraints && /* @__PURE__ */ (0,
|
|
6158
|
+
const captureScreen = /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(import_jsx_runtime61.Fragment, { children: [
|
|
6159
|
+
videoConstraints && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
|
|
5789
6160
|
import_react_webcam.default,
|
|
5790
6161
|
{
|
|
5791
6162
|
ref: webcamReference,
|
|
@@ -5796,7 +6167,7 @@ var CameraCapture = ({
|
|
|
5796
6167
|
onUserMedia: handleUserMedia
|
|
5797
6168
|
}
|
|
5798
6169
|
),
|
|
5799
|
-
/* @__PURE__ */ (0,
|
|
6170
|
+
/* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
|
|
5800
6171
|
Overlay_default,
|
|
5801
6172
|
{
|
|
5802
6173
|
overlay,
|
|
@@ -5806,11 +6177,11 @@ var CameraCapture = ({
|
|
|
5806
6177
|
instructions
|
|
5807
6178
|
}
|
|
5808
6179
|
),
|
|
5809
|
-
ready && /* @__PURE__ */ (0,
|
|
6180
|
+
ready && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(CaptureBottomBar, { onCapture: () => void handleCapture() })
|
|
5810
6181
|
] });
|
|
5811
|
-
const reviewScreen = /* @__PURE__ */ (0,
|
|
5812
|
-
/* @__PURE__ */ (0,
|
|
5813
|
-
/* @__PURE__ */ (0,
|
|
6182
|
+
const reviewScreen = /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(import_jsx_runtime61.Fragment, { children: [
|
|
6183
|
+
/* @__PURE__ */ (0, import_jsx_runtime61.jsx)("img", { className: "review-image", src: reviewImage == null ? void 0 : reviewImage.source, alt: "" }),
|
|
6184
|
+
/* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
|
|
5814
6185
|
Overlay_default,
|
|
5815
6186
|
{
|
|
5816
6187
|
overlay,
|
|
@@ -5820,19 +6191,19 @@ var CameraCapture = ({
|
|
|
5820
6191
|
reviewInstructions: intl.formatMessage(CameraCapture_messages_default.reviewInstructions)
|
|
5821
6192
|
}
|
|
5822
6193
|
),
|
|
5823
|
-
/* @__PURE__ */ (0,
|
|
6194
|
+
/* @__PURE__ */ (0, import_jsx_runtime61.jsx)(ReviewBottomBar, { onSubmit: handleReviewSubmit, onRetry: handleReviewRetry })
|
|
5824
6195
|
] });
|
|
5825
|
-
return /* @__PURE__ */ (0,
|
|
6196
|
+
return /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)("section", { className: "camera-capture", children: [
|
|
5826
6197
|
mode === "CAPTURE" && captureScreen,
|
|
5827
6198
|
mode === "REVIEW" && reviewScreen,
|
|
5828
|
-
mode === "NO_CAMERA_ACCESS" && /* @__PURE__ */ (0,
|
|
5829
|
-
mode === "CAMERA_NOT_SUPPORTED" && /* @__PURE__ */ (0,
|
|
6199
|
+
mode === "NO_CAMERA_ACCESS" && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(NoCameraAccess_default, { onAction: handleRetryCameraAccess }),
|
|
6200
|
+
mode === "CAMERA_NOT_SUPPORTED" && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(CameraNotSupported_default, {})
|
|
5830
6201
|
] });
|
|
5831
6202
|
};
|
|
5832
6203
|
var CameraCapture_default = CameraCapture;
|
|
5833
6204
|
|
|
5834
6205
|
// src/step/cameraStep/CameraStep.tsx
|
|
5835
|
-
var
|
|
6206
|
+
var import_jsx_runtime62 = require("react/jsx-runtime");
|
|
5836
6207
|
function blobToBase64(blob) {
|
|
5837
6208
|
return new Promise((resolve, _) => {
|
|
5838
6209
|
const reader = new FileReader();
|
|
@@ -5850,8 +6221,8 @@ var CameraStep = (props) => {
|
|
|
5850
6221
|
const { assets, direction, instructions } = cameraConfig || {};
|
|
5851
6222
|
const { overlay, outline } = assets || {};
|
|
5852
6223
|
const { url: imageUrl } = image || {};
|
|
5853
|
-
const [captureClicked, setCaptureClicked] = (0,
|
|
5854
|
-
(0,
|
|
6224
|
+
const [captureClicked, setCaptureClicked] = (0, import_react36.useState)(false);
|
|
6225
|
+
(0, import_react36.useEffect)(() => {
|
|
5855
6226
|
if (captureClicked) {
|
|
5856
6227
|
onAction(action);
|
|
5857
6228
|
}
|
|
@@ -5870,7 +6241,7 @@ var CameraStep = (props) => {
|
|
|
5870
6241
|
});
|
|
5871
6242
|
}
|
|
5872
6243
|
};
|
|
5873
|
-
return /* @__PURE__ */ (0,
|
|
6244
|
+
return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
|
|
5874
6245
|
CameraCapture_default,
|
|
5875
6246
|
{
|
|
5876
6247
|
overlay,
|
|
@@ -5919,11 +6290,11 @@ function getFirstAction(step) {
|
|
|
5919
6290
|
}
|
|
5920
6291
|
|
|
5921
6292
|
// src/step/externalConfirmationStep/ExternalConfirmationStep.tsx
|
|
5922
|
-
var
|
|
6293
|
+
var import_react_intl30 = require("react-intl");
|
|
5923
6294
|
|
|
5924
6295
|
// src/step/externalConfirmationStep/ExternalConfirmationStep.messages.ts
|
|
5925
|
-
var
|
|
5926
|
-
var ExternalConfirmationStep_messages_default = (0,
|
|
6296
|
+
var import_react_intl29 = require("react-intl");
|
|
6297
|
+
var ExternalConfirmationStep_messages_default = (0, import_react_intl29.defineMessages)({
|
|
5927
6298
|
title: {
|
|
5928
6299
|
id: "dynamicFlows.ExternalConfirmation.title",
|
|
5929
6300
|
defaultMessage: "Please confirm",
|
|
@@ -5947,12 +6318,12 @@ var ExternalConfirmationStep_messages_default = (0, import_react_intl26.defineMe
|
|
|
5947
6318
|
});
|
|
5948
6319
|
|
|
5949
6320
|
// src/step/externalConfirmationStep/ExternalConfirmationStep.tsx
|
|
5950
|
-
var
|
|
6321
|
+
var import_jsx_runtime63 = require("react/jsx-runtime");
|
|
5951
6322
|
var noop5 = () => {
|
|
5952
6323
|
};
|
|
5953
6324
|
var ExternalConfirmationStep = ({ url, onClose }) => {
|
|
5954
|
-
const { formatMessage } = (0,
|
|
5955
|
-
return /* @__PURE__ */ (0,
|
|
6325
|
+
const { formatMessage } = (0, import_react_intl30.useIntl)();
|
|
6326
|
+
return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
|
|
5956
6327
|
DynamicLayout_default,
|
|
5957
6328
|
{
|
|
5958
6329
|
components: [
|
|
@@ -6017,11 +6388,11 @@ function getOrigin(url) {
|
|
|
6017
6388
|
}
|
|
6018
6389
|
|
|
6019
6390
|
// src/dynamicFlow/BackButton.tsx
|
|
6020
|
-
var
|
|
6021
|
-
var
|
|
6022
|
-
var
|
|
6391
|
+
var import_components30 = require("@transferwise/components");
|
|
6392
|
+
var import_icons2 = require("@transferwise/icons");
|
|
6393
|
+
var import_jsx_runtime64 = require("react/jsx-runtime");
|
|
6023
6394
|
var BackButton = ({ title, action, onAction }) => {
|
|
6024
|
-
return /* @__PURE__ */ (0,
|
|
6395
|
+
return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(
|
|
6025
6396
|
"a",
|
|
6026
6397
|
{
|
|
6027
6398
|
onClick: (event) => {
|
|
@@ -6032,8 +6403,8 @@ var BackButton = ({ title, action, onAction }) => {
|
|
|
6032
6403
|
className: "df-back-btn",
|
|
6033
6404
|
"aria-label": title,
|
|
6034
6405
|
children: [
|
|
6035
|
-
/* @__PURE__ */ (0,
|
|
6036
|
-
/* @__PURE__ */ (0,
|
|
6406
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("span", { className: "sr-only", children: title }),
|
|
6407
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_components30.Avatar, { type: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_icons2.ArrowLeft, { size: "24" }) })
|
|
6037
6408
|
]
|
|
6038
6409
|
}
|
|
6039
6410
|
);
|
|
@@ -6041,7 +6412,7 @@ var BackButton = ({ title, action, onAction }) => {
|
|
|
6041
6412
|
var BackButton_default = BackButton;
|
|
6042
6413
|
|
|
6043
6414
|
// src/dynamicFlow/DynamicFlowStep.tsx
|
|
6044
|
-
var
|
|
6415
|
+
var import_jsx_runtime65 = require("react/jsx-runtime");
|
|
6045
6416
|
var DynamicFlowStep = (props) => {
|
|
6046
6417
|
var _a, _b;
|
|
6047
6418
|
const { step, globalError, onAction } = props;
|
|
@@ -6052,23 +6423,23 @@ var DynamicFlowStep = (props) => {
|
|
|
6052
6423
|
return null;
|
|
6053
6424
|
}
|
|
6054
6425
|
if (externalUrl && requiresManualTrigger) {
|
|
6055
|
-
return /* @__PURE__ */ (0,
|
|
6426
|
+
return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(ExternalConfirmationStep_default, { url: externalUrl, onClose: dismissConfirmation });
|
|
6056
6427
|
}
|
|
6057
6428
|
if (isCameraStep(step)) {
|
|
6058
|
-
return /* @__PURE__ */ (0,
|
|
6429
|
+
return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(CameraStep_default, __spreadProps(__spreadValues({}, props), { step }));
|
|
6059
6430
|
}
|
|
6060
|
-
return /* @__PURE__ */ (0,
|
|
6061
|
-
backButton && /* @__PURE__ */ (0,
|
|
6062
|
-
globalError ? /* @__PURE__ */ (0,
|
|
6063
|
-
/* @__PURE__ */ (0,
|
|
6431
|
+
return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(import_jsx_runtime65.Fragment, { children: [
|
|
6432
|
+
backButton && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(BackButton_default, __spreadProps(__spreadValues({}, backButton), { onAction })),
|
|
6433
|
+
globalError ? /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(DynamicAlert_default, { component: { context: "negative", markdown: globalError, margin: "lg" } }) : null,
|
|
6434
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)(LayoutStep_default, __spreadProps(__spreadValues({}, props), { stepSpecification: step }))
|
|
6064
6435
|
] });
|
|
6065
6436
|
};
|
|
6066
6437
|
|
|
6067
6438
|
// src/dynamicFlow/utils/useDebouncedRefresh/useDebouncedRefresh.ts
|
|
6068
|
-
var
|
|
6439
|
+
var import_react37 = require("react");
|
|
6069
6440
|
var DEBOUNCE_DELAY = 1e3;
|
|
6070
6441
|
function useDebouncedRefresh(fetchRefresh) {
|
|
6071
|
-
const map = (0,
|
|
6442
|
+
const map = (0, import_react37.useRef)(/* @__PURE__ */ new Map());
|
|
6072
6443
|
const retrieveOrCreate = (key) => {
|
|
6073
6444
|
if (map.current.has(key)) {
|
|
6074
6445
|
return map.current.get(key);
|
|
@@ -6091,12 +6462,12 @@ function useDebouncedRefresh(fetchRefresh) {
|
|
|
6091
6462
|
var shouldDebounceSchema = (schema) => getSchemaType(schema) === "basic" && schema.type !== "boolean" && schema.format !== "base64url";
|
|
6092
6463
|
|
|
6093
6464
|
// src/dynamicFlow/utils/useDynamicFlowState.ts
|
|
6094
|
-
var
|
|
6465
|
+
var import_react38 = require("react");
|
|
6095
6466
|
var useDynamicFlowState = (initialStep) => {
|
|
6096
6467
|
var _a, _b;
|
|
6097
|
-
const [formErrors, setFormErrors] = (0,
|
|
6098
|
-
const [globalError, setGlobalError] = (0,
|
|
6099
|
-
const [stepAndModels, setStepAndModels] = (0,
|
|
6468
|
+
const [formErrors, setFormErrors] = (0, import_react38.useState)((_a = initialStep == null ? void 0 : initialStep.errors) == null ? void 0 : _a.validation);
|
|
6469
|
+
const [globalError, setGlobalError] = (0, import_react38.useState)((_b = initialStep == null ? void 0 : initialStep.errors) == null ? void 0 : _b.error);
|
|
6470
|
+
const [stepAndModels, setStepAndModels] = (0, import_react38.useState)({
|
|
6100
6471
|
step: initialStep || void 0,
|
|
6101
6472
|
models: (initialStep == null ? void 0 : initialStep.model) ? buildInitialModels(initialStep.model, getAllSchemas(initialStep)) : {},
|
|
6102
6473
|
etag: void 0
|
|
@@ -6126,7 +6497,10 @@ var useDynamicFlowState = (initialStep) => {
|
|
|
6126
6497
|
return updatedState;
|
|
6127
6498
|
});
|
|
6128
6499
|
};
|
|
6129
|
-
const modelIsValid = (0,
|
|
6500
|
+
const modelIsValid = (0, import_react38.useMemo)(
|
|
6501
|
+
() => areModelsValid(models, getAllValidatableSchemas(step)),
|
|
6502
|
+
[models, step]
|
|
6503
|
+
);
|
|
6130
6504
|
return {
|
|
6131
6505
|
formErrors,
|
|
6132
6506
|
globalError,
|
|
@@ -6166,6 +6540,22 @@ var getAllSchemasInLayout = (components) => components.flatMap((component) => {
|
|
|
6166
6540
|
return [];
|
|
6167
6541
|
}
|
|
6168
6542
|
});
|
|
6543
|
+
var getAllValidatableSchemas = (step) => [
|
|
6544
|
+
...getAllReferencedSchemaIds((step == null ? void 0 : step.layout) || []).map((id) => ((step == null ? void 0 : step.schemas) || []).find((schema) => schema.$id === id)).filter(Boolean),
|
|
6545
|
+
...getAllSchemasInLayout((step == null ? void 0 : step.layout) || [])
|
|
6546
|
+
];
|
|
6547
|
+
var getAllReferencedSchemaIds = (components) => components.flatMap((component) => {
|
|
6548
|
+
switch (component.type) {
|
|
6549
|
+
case "columns":
|
|
6550
|
+
return [...getAllReferencedSchemaIds([...component.left, ...component.right])];
|
|
6551
|
+
case "box":
|
|
6552
|
+
return getAllReferencedSchemaIds(component.components);
|
|
6553
|
+
case "form":
|
|
6554
|
+
return [getSchemaReference(component)];
|
|
6555
|
+
default:
|
|
6556
|
+
return [];
|
|
6557
|
+
}
|
|
6558
|
+
}).filter(Boolean);
|
|
6169
6559
|
var areModelsValid = (formModels, schemas = []) => {
|
|
6170
6560
|
return !(schemas == null ? void 0 : schemas.some((schema) => {
|
|
6171
6561
|
if (!schema.$id) {
|
|
@@ -6174,24 +6564,30 @@ var areModelsValid = (formModels, schemas = []) => {
|
|
|
6174
6564
|
return !isValidSchema(formModels[schema.$id || ""] || {}, schema);
|
|
6175
6565
|
}));
|
|
6176
6566
|
};
|
|
6567
|
+
var getSchemaReference = (component) => {
|
|
6568
|
+
if (component.schema && !isInlineSchema(component.schema)) {
|
|
6569
|
+
return component.schema.$ref;
|
|
6570
|
+
}
|
|
6571
|
+
return component.schemaId;
|
|
6572
|
+
};
|
|
6177
6573
|
var isInlineSchema = (schema) => {
|
|
6178
6574
|
return schema !== void 0 && typeof schema === "object" && Object.prototype.hasOwnProperty.call(schema, "$ref") === false;
|
|
6179
6575
|
};
|
|
6180
6576
|
|
|
6181
6577
|
// src/dynamicFlow/utils/useLoader.tsx
|
|
6182
|
-
var
|
|
6183
|
-
var
|
|
6184
|
-
var
|
|
6578
|
+
var import_components31 = require("@transferwise/components");
|
|
6579
|
+
var import_react39 = require("react");
|
|
6580
|
+
var import_jsx_runtime66 = require("react/jsx-runtime");
|
|
6185
6581
|
function useLoader(loaderConfig, initialState) {
|
|
6186
6582
|
const config = __spreadValues({
|
|
6187
|
-
size:
|
|
6583
|
+
size: import_components31.Size.EXTRA_LARGE,
|
|
6188
6584
|
initial: true,
|
|
6189
6585
|
submission: false
|
|
6190
6586
|
}, loaderConfig);
|
|
6191
|
-
const [loadingState, setLoadingState] = (0,
|
|
6587
|
+
const [loadingState, setLoadingState] = (0, import_react39.useState)(initialState);
|
|
6192
6588
|
const shouldDisplayLoader = config.initial && loadingState === "initial" || config.submission && loadingState === "submission";
|
|
6193
|
-
const loader = shouldDisplayLoader ? /* @__PURE__ */ (0,
|
|
6194
|
-
|
|
6589
|
+
const loader = shouldDisplayLoader ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
|
|
6590
|
+
import_components31.Loader,
|
|
6195
6591
|
{
|
|
6196
6592
|
size: config.size,
|
|
6197
6593
|
classNames: { "tw-loader": "tw-loader m-x-auto" },
|
|
@@ -6202,23 +6598,23 @@ function useLoader(loaderConfig, initialState) {
|
|
|
6202
6598
|
}
|
|
6203
6599
|
|
|
6204
6600
|
// src/dynamicFlow/utils/errorBoundary/ErrorBoundary.tsx
|
|
6205
|
-
var
|
|
6601
|
+
var import_react40 = require("react");
|
|
6206
6602
|
|
|
6207
6603
|
// src/dynamicFlow/utils/errorBoundary/ErrorBoundaryAlert.tsx
|
|
6208
|
-
var
|
|
6209
|
-
var
|
|
6210
|
-
var
|
|
6604
|
+
var import_components32 = require("@transferwise/components");
|
|
6605
|
+
var import_react_intl31 = require("react-intl");
|
|
6606
|
+
var import_jsx_runtime67 = require("react/jsx-runtime");
|
|
6211
6607
|
var ErrorBoundaryAlert = ({ onDismiss }) => {
|
|
6212
|
-
const { formatMessage } = (0,
|
|
6213
|
-
return /* @__PURE__ */ (0,
|
|
6214
|
-
|
|
6608
|
+
const { formatMessage } = (0, import_react_intl31.useIntl)();
|
|
6609
|
+
return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
6610
|
+
import_components32.Alert,
|
|
6215
6611
|
{
|
|
6216
6612
|
action: {
|
|
6217
6613
|
text: formatMessage(ErrorBoundary_messages_default.retry),
|
|
6218
6614
|
href: window.location.href
|
|
6219
6615
|
},
|
|
6220
6616
|
message: formatMessage(ErrorBoundary_messages_default.errorAlert),
|
|
6221
|
-
type:
|
|
6617
|
+
type: import_components32.Sentiment.NEGATIVE,
|
|
6222
6618
|
className: "m-b-3",
|
|
6223
6619
|
onDismiss
|
|
6224
6620
|
}
|
|
@@ -6226,10 +6622,10 @@ var ErrorBoundaryAlert = ({ onDismiss }) => {
|
|
|
6226
6622
|
};
|
|
6227
6623
|
|
|
6228
6624
|
// src/dynamicFlow/utils/errorBoundary/ErrorBoundary.tsx
|
|
6229
|
-
var
|
|
6625
|
+
var import_jsx_runtime68 = require("react/jsx-runtime");
|
|
6230
6626
|
var noop6 = () => {
|
|
6231
6627
|
};
|
|
6232
|
-
var ErrorBoundary = class extends
|
|
6628
|
+
var ErrorBoundary = class extends import_react40.Component {
|
|
6233
6629
|
constructor(props) {
|
|
6234
6630
|
super(props);
|
|
6235
6631
|
this.handleErrorReset = () => {
|
|
@@ -6247,8 +6643,8 @@ var ErrorBoundary = class extends import_react39.Component {
|
|
|
6247
6643
|
render() {
|
|
6248
6644
|
const { children } = this.props;
|
|
6249
6645
|
const { hasError, isFatalError } = this.state;
|
|
6250
|
-
return /* @__PURE__ */ (0,
|
|
6251
|
-
hasError && /* @__PURE__ */ (0,
|
|
6646
|
+
return /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(import_jsx_runtime68.Fragment, { children: [
|
|
6647
|
+
hasError && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(ErrorBoundaryAlert, { onDismiss: this.handleErrorReset }),
|
|
6252
6648
|
!isFatalError && children
|
|
6253
6649
|
] });
|
|
6254
6650
|
}
|
|
@@ -6349,7 +6745,7 @@ var assertResponseIsValid = (response) => {
|
|
|
6349
6745
|
var isResponse = (response) => typeof response === "object" && response !== null && "clone" in response && "bodyUsed" in response;
|
|
6350
6746
|
|
|
6351
6747
|
// src/dynamicFlow/DynamicFlow.tsx
|
|
6352
|
-
var
|
|
6748
|
+
var import_jsx_runtime69 = require("react/jsx-runtime");
|
|
6353
6749
|
var noop7 = () => {
|
|
6354
6750
|
};
|
|
6355
6751
|
var DynamicFlowComponent = ({
|
|
@@ -6364,7 +6760,7 @@ var DynamicFlowComponent = ({
|
|
|
6364
6760
|
onEvent = noop7,
|
|
6365
6761
|
onLog = noop7
|
|
6366
6762
|
}) => {
|
|
6367
|
-
const { locale } = (0,
|
|
6763
|
+
const { locale } = (0, import_react_intl32.useIntl)();
|
|
6368
6764
|
const {
|
|
6369
6765
|
formErrors,
|
|
6370
6766
|
globalError,
|
|
@@ -6377,24 +6773,24 @@ var DynamicFlowComponent = ({
|
|
|
6377
6773
|
setStepAndEtag,
|
|
6378
6774
|
setSchemaModel
|
|
6379
6775
|
} = useDynamicFlowState(initialStep);
|
|
6380
|
-
const [submitted, setSubmitted] = (0,
|
|
6776
|
+
const [submitted, setSubmitted] = (0, import_react41.useState)(false);
|
|
6381
6777
|
const { isLoading, loader, setLoadingState } = useLoader(
|
|
6382
6778
|
loaderConfig,
|
|
6383
6779
|
initialStep ? "idle" : "initial"
|
|
6384
6780
|
);
|
|
6385
6781
|
const logCritical = getLogger("critical", onLog, flowId, (step == null ? void 0 : step.id) || (step == null ? void 0 : step.key));
|
|
6386
|
-
const analyticsMetadata = (0,
|
|
6782
|
+
const analyticsMetadata = (0, import_react41.useMemo)(
|
|
6387
6783
|
() => {
|
|
6388
6784
|
var _a;
|
|
6389
6785
|
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 : {});
|
|
6390
6786
|
},
|
|
6391
6787
|
[flowId, step]
|
|
6392
6788
|
);
|
|
6393
|
-
const dispatchEvent = (0,
|
|
6789
|
+
const dispatchEvent = (0, import_react41.useMemo)(
|
|
6394
6790
|
() => getEventDispatcher(onEvent, analyticsMetadata),
|
|
6395
6791
|
[onEvent, analyticsMetadata]
|
|
6396
6792
|
);
|
|
6397
|
-
const dfHttpClient = (0,
|
|
6793
|
+
const dfHttpClient = (0, import_react41.useCallback)(
|
|
6398
6794
|
({ action, data, etag: etag2 }) => {
|
|
6399
6795
|
const { url, method = "POST" } = action;
|
|
6400
6796
|
return httpClient(url != null ? url : "", {
|
|
@@ -6444,17 +6840,17 @@ var DynamicFlowComponent = ({
|
|
|
6444
6840
|
dispatchEventAndComplete(__spreadValues(__spreadValues({}, exitResult), actionResult));
|
|
6445
6841
|
};
|
|
6446
6842
|
const debouncedRefresh = useDebouncedRefresh(performRefresh);
|
|
6447
|
-
const dispatchEventAndComplete = (0,
|
|
6843
|
+
const dispatchEventAndComplete = (0, import_react41.useCallback)(
|
|
6448
6844
|
(result) => {
|
|
6449
6845
|
dispatchEvent("Dynamic Flow - Flow Finished", { result: "success" });
|
|
6450
6846
|
onCompletion(result);
|
|
6451
6847
|
},
|
|
6452
6848
|
[onCompletion, dispatchEvent]
|
|
6453
6849
|
);
|
|
6454
|
-
(0,
|
|
6850
|
+
(0, import_react41.useEffect)(() => {
|
|
6455
6851
|
dispatchEvent("Dynamic Flow - Flow Started", {});
|
|
6456
6852
|
}, []);
|
|
6457
|
-
(0,
|
|
6853
|
+
(0, import_react41.useEffect)(() => {
|
|
6458
6854
|
if (!initialStep) {
|
|
6459
6855
|
const action = __spreadValues({
|
|
6460
6856
|
id: "#initial-step-request",
|
|
@@ -6569,7 +6965,7 @@ var DynamicFlowComponent = ({
|
|
|
6569
6965
|
await actionHandler(action);
|
|
6570
6966
|
}
|
|
6571
6967
|
};
|
|
6572
|
-
return /* @__PURE__ */ (0,
|
|
6968
|
+
return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(LogProvider, { flowId, stepId: (step == null ? void 0 : step.id) || (step == null ? void 0 : step.key), onLog, children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(EventsContextProvider, { metadata: analyticsMetadata, onEvent, children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(DynamicFlowProvider, { loading: isLoading, children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(HttpClientProvider, { httpClient, children: loader !== null ? loader : /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
|
|
6573
6969
|
DynamicFlowStep,
|
|
6574
6970
|
{
|
|
6575
6971
|
step,
|
|
@@ -6585,7 +6981,7 @@ var DynamicFlowComponent = ({
|
|
|
6585
6981
|
}
|
|
6586
6982
|
) }) }) }) });
|
|
6587
6983
|
};
|
|
6588
|
-
var DynamicFlow = (props) => /* @__PURE__ */ (0,
|
|
6984
|
+
var DynamicFlow = (props) => /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(ErrorBoundary_default, { onError: props.onError, children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(DynamicFlowComponent, __spreadValues({}, props)) });
|
|
6589
6985
|
var DynamicFlow_default = DynamicFlow;
|
|
6590
6986
|
var combineModels2 = (formModels) => {
|
|
6591
6987
|
return Object.values(formModels).reduce((previous, model) => __spreadValues(__spreadValues({}, previous), model), {});
|
|
@@ -6644,8 +7040,12 @@ var de_default = {
|
|
|
6644
7040
|
|
|
6645
7041
|
// src/i18n/en.json
|
|
6646
7042
|
var en_default = {
|
|
7043
|
+
"dynamicFlows.ArraySchema.addItem": "Save",
|
|
7044
|
+
"dynamicFlows.ArraySchema.addItemTitle": "Add Item",
|
|
7045
|
+
"dynamicFlows.ArraySchema.editItem": "Save",
|
|
6647
7046
|
"dynamicFlows.ArraySchema.maxItemsError": "Please add {maxItems} or fewer.",
|
|
6648
7047
|
"dynamicFlows.ArraySchema.minItemsError": "Please add at least {minItems}.",
|
|
7048
|
+
"dynamicFlows.ArraySchema.removeItem": "Remove",
|
|
6649
7049
|
"dynamicFlows.CameraCapture.CameraNotSupported.paragraph": "The browser you're using doesn't have support for a camera. Try a different browser, device, or download our mobile app.",
|
|
6650
7050
|
"dynamicFlows.CameraCapture.CameraNotSupported.title": "Camera not supported",
|
|
6651
7051
|
"dynamicFlows.CameraCapture.NoCameraAccess.action": "Enable camera access",
|