@wise/dynamic-flow-client 1.12.1 → 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 +924 -537
- 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");
|
|
@@ -1027,7 +1027,7 @@ var isUndefined = (value) => typeof value === "undefined";
|
|
|
1027
1027
|
// src/common/validators/values/value-validators.ts
|
|
1028
1028
|
var isEmpty = (value) => isString(value) && value.length === 0 || (isObject(value) || isArray(value)) && Object.keys(value).length === 0;
|
|
1029
1029
|
|
|
1030
|
-
// src/common/validators/models/
|
|
1030
|
+
// src/common/validators/models/model-utils.ts
|
|
1031
1031
|
function cleanBasicModelWithOneOfSchema(model, schema) {
|
|
1032
1032
|
return schema.oneOf.some(
|
|
1033
1033
|
(nestedSchema) => getValidBasicModelOrNull(model, nestedSchema) === model
|
|
@@ -1072,7 +1072,7 @@ function cleanModelWithArraySchema(model, schema) {
|
|
|
1072
1072
|
return new Array(model.length).fill(null);
|
|
1073
1073
|
}
|
|
1074
1074
|
}
|
|
1075
|
-
return model.map((childModel) =>
|
|
1075
|
+
return model.map((childModel) => getValidModelParts(childModel, schema.items));
|
|
1076
1076
|
}
|
|
1077
1077
|
function cleanObjectModelWithObjectSchema(model, schema) {
|
|
1078
1078
|
return Object.keys(schema.properties).reduce((cleanedModel, property) => {
|
|
@@ -1381,6 +1381,9 @@ function isValidObjectSchema(value, schema) {
|
|
|
1381
1381
|
).every((property) => property);
|
|
1382
1382
|
}
|
|
1383
1383
|
function isObjectPropertyValid(propertyValue, propertySchema, isRequired) {
|
|
1384
|
+
if (propertySchema.hidden) {
|
|
1385
|
+
return true;
|
|
1386
|
+
}
|
|
1384
1387
|
if (typeof propertyValue === "undefined") {
|
|
1385
1388
|
return !isRequired;
|
|
1386
1389
|
}
|
|
@@ -1412,6 +1415,9 @@ function isValidBlobSchema(value, schema) {
|
|
|
1412
1415
|
return !getBlobValidationFailures(value, schema).length;
|
|
1413
1416
|
}
|
|
1414
1417
|
function isValidSchema(value, schema) {
|
|
1418
|
+
if (schema.hidden) {
|
|
1419
|
+
return true;
|
|
1420
|
+
}
|
|
1415
1421
|
if (schema.oneOf) {
|
|
1416
1422
|
return isValidOneOfSchema(value, schema);
|
|
1417
1423
|
}
|
|
@@ -1691,7 +1697,7 @@ var isArrayModel = (model) => {
|
|
|
1691
1697
|
return true;
|
|
1692
1698
|
}
|
|
1693
1699
|
return model.every(
|
|
1694
|
-
(item) => typeof item === "string" || typeof item === "number" || typeof item === "boolean"
|
|
1700
|
+
(item) => typeof item === "string" || typeof item === "number" || typeof item === "boolean" || typeof item === "object"
|
|
1695
1701
|
);
|
|
1696
1702
|
}
|
|
1697
1703
|
return false;
|
|
@@ -1787,8 +1793,8 @@ function useExternalStepPolling(polling, onAction) {
|
|
|
1787
1793
|
}
|
|
1788
1794
|
|
|
1789
1795
|
// src/common/hooks/usePersistAsync/usePersistAsync.ts
|
|
1790
|
-
var
|
|
1791
|
-
var
|
|
1796
|
+
var import_react29 = require("react");
|
|
1797
|
+
var import_react_intl21 = require("react-intl");
|
|
1792
1798
|
|
|
1793
1799
|
// src/jsonSchemaForm/persistAsyncSchema/PersistAsyncSchema.messages.js
|
|
1794
1800
|
var import_react_intl = require("react-intl");
|
|
@@ -1801,8 +1807,8 @@ var PersistAsyncSchema_messages_default = (0, import_react_intl.defineMessages)(
|
|
|
1801
1807
|
});
|
|
1802
1808
|
|
|
1803
1809
|
// src/jsonSchemaForm/persistAsyncSchema/persistAsyncBasicSchema/PersistAsyncBasicSchema.tsx
|
|
1804
|
-
var
|
|
1805
|
-
var
|
|
1810
|
+
var import_react28 = require("react");
|
|
1811
|
+
var import_react_intl20 = require("react-intl");
|
|
1806
1812
|
|
|
1807
1813
|
// src/common/constants/DateMode.ts
|
|
1808
1814
|
var DateMode = {
|
|
@@ -1846,7 +1852,7 @@ var Size = {
|
|
|
1846
1852
|
|
|
1847
1853
|
// src/jsonSchemaForm/basicTypeSchema/BasicTypeSchema.tsx
|
|
1848
1854
|
var import_classnames6 = __toESM(require_classnames());
|
|
1849
|
-
var
|
|
1855
|
+
var import_react27 = require("react");
|
|
1850
1856
|
|
|
1851
1857
|
// src/layout/alert/DynamicAlert.tsx
|
|
1852
1858
|
var import_components2 = require("@transferwise/components");
|
|
@@ -2110,18 +2116,18 @@ var getNavigationOptionMedia = ({ icon, image }) => {
|
|
|
2110
2116
|
};
|
|
2111
2117
|
|
|
2112
2118
|
// src/layout/utils/index.ts
|
|
2113
|
-
var
|
|
2119
|
+
var getMargin = (size) => {
|
|
2114
2120
|
switch (size) {
|
|
2115
2121
|
case "xs":
|
|
2116
|
-
return "m-
|
|
2122
|
+
return "m-t-0";
|
|
2117
2123
|
case "sm":
|
|
2118
|
-
return "m-
|
|
2124
|
+
return "m-t-1";
|
|
2119
2125
|
case "md":
|
|
2120
|
-
return "m-
|
|
2126
|
+
return "m-t-2";
|
|
2121
2127
|
case "lg":
|
|
2122
|
-
return "m-
|
|
2128
|
+
return "m-t-3";
|
|
2123
2129
|
case "xl":
|
|
2124
|
-
return "m-
|
|
2130
|
+
return "m-t-5";
|
|
2125
2131
|
default:
|
|
2126
2132
|
return "";
|
|
2127
2133
|
}
|
|
@@ -2137,7 +2143,7 @@ var getTextAlignment = (align) => {
|
|
|
2137
2143
|
return "";
|
|
2138
2144
|
}
|
|
2139
2145
|
};
|
|
2140
|
-
var getTextAlignmentAndMargin = (component) => `${getTextAlignment(component.align)} ${
|
|
2146
|
+
var getTextAlignmentAndMargin = (component) => `${getTextAlignment(component.align)} ${getMargin(component.margin)}`;
|
|
2141
2147
|
|
|
2142
2148
|
// src/layout/alert/DynamicAlert.tsx
|
|
2143
2149
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
@@ -2147,7 +2153,7 @@ var DynamicAlert = (props) => {
|
|
|
2147
2153
|
import_components2.Alert,
|
|
2148
2154
|
{
|
|
2149
2155
|
type: mapContextToAlertType(legacy_mapContext(alert.context)),
|
|
2150
|
-
className:
|
|
2156
|
+
className: getMargin(alert.margin),
|
|
2151
2157
|
message: alert.markdown
|
|
2152
2158
|
}
|
|
2153
2159
|
);
|
|
@@ -2179,7 +2185,7 @@ var DynamicAlert_default = DynamicAlert;
|
|
|
2179
2185
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
2180
2186
|
var DynamicBox = (props) => {
|
|
2181
2187
|
const box = props.component;
|
|
2182
|
-
const margin =
|
|
2188
|
+
const margin = getMargin(box.margin || box.border ? "lg" : "xs");
|
|
2183
2189
|
if (!box.width || box.width === "xl") {
|
|
2184
2190
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: margin + getBorderClass(box.border), children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
2185
2191
|
DynamicLayout_default,
|
|
@@ -2279,7 +2285,7 @@ var DynamicButton = (props) => {
|
|
|
2279
2285
|
const type = getButtonType(component);
|
|
2280
2286
|
const priority = getButtonPriority(component);
|
|
2281
2287
|
const { loading } = useDynamicFlow();
|
|
2282
|
-
const className =
|
|
2288
|
+
const className = getMargin(component.margin || "md");
|
|
2283
2289
|
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2284
2290
|
import_components3.Button,
|
|
2285
2291
|
{
|
|
@@ -2301,7 +2307,7 @@ var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
|
2301
2307
|
var DynamicColumns = (props) => {
|
|
2302
2308
|
const columns = props.component;
|
|
2303
2309
|
const { leftWidth, rightWidth } = getWidth(columns.bias);
|
|
2304
|
-
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: [
|
|
2305
2311
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: `${leftWidth} m-b-0`, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
2306
2312
|
DynamicLayout_default,
|
|
2307
2313
|
{
|
|
@@ -2351,7 +2357,7 @@ var DynamicColumns_default = DynamicColumns;
|
|
|
2351
2357
|
// src/layout/decision/DynamicDecision.tsx
|
|
2352
2358
|
var import_components4 = require("@transferwise/components");
|
|
2353
2359
|
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
2354
|
-
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)(
|
|
2355
2361
|
import_components4.NavigationOption,
|
|
2356
2362
|
{
|
|
2357
2363
|
title: option.title,
|
|
@@ -2369,7 +2375,7 @@ var DynamicDecision_default = DynamicDecision;
|
|
|
2369
2375
|
// src/layout/divider/DynamicDivider.tsx
|
|
2370
2376
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
2371
2377
|
var DynamicDivider = ({ component }) => {
|
|
2372
|
-
const margin =
|
|
2378
|
+
const margin = getMargin(component.margin);
|
|
2373
2379
|
const className = `m-t-0 ${margin}`;
|
|
2374
2380
|
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("hr", { className });
|
|
2375
2381
|
};
|
|
@@ -2415,7 +2421,7 @@ var DynamicExternal = ({ component, onAction }) => {
|
|
|
2415
2421
|
var DynamicExternal_default = DynamicExternal;
|
|
2416
2422
|
|
|
2417
2423
|
// src/jsonSchemaForm/genericSchema/GenericSchema.tsx
|
|
2418
|
-
var
|
|
2424
|
+
var import_react21 = require("react");
|
|
2419
2425
|
|
|
2420
2426
|
// src/jsonSchemaForm/allOfSchema/AllOfSchema.tsx
|
|
2421
2427
|
var import_classnames = __toESM(require_classnames());
|
|
@@ -2797,14 +2803,418 @@ function getValidationMessages(schema, required, defaultErrorMessages) {
|
|
|
2797
2803
|
return __spreadValues(__spreadValues(__spreadValues({}, required && { required: defaultErrorMessages.requiredMessage }), minItems && { minItems: defaultErrorMessages.minItemsErrorMessage }), maxItems && { maxItems: defaultErrorMessages.maxItemsErrorMessage });
|
|
2798
2804
|
}
|
|
2799
2805
|
|
|
2800
|
-
// 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");
|
|
2801
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");
|
|
2802
3209
|
var ArrayListSchema = (props) => {
|
|
2803
3210
|
const { schema } = props;
|
|
2804
3211
|
if (isMultipleFileUploadSchema(schema)) {
|
|
2805
|
-
return /* @__PURE__ */ (0,
|
|
3212
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(MultipleFileUploadSchema_default, __spreadProps(__spreadValues({}, props), { schema }));
|
|
2806
3213
|
}
|
|
2807
|
-
|
|
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");
|
|
2808
3218
|
};
|
|
2809
3219
|
ArrayListSchema.defaultProps = {
|
|
2810
3220
|
errors: null,
|
|
@@ -2813,11 +3223,11 @@ ArrayListSchema.defaultProps = {
|
|
|
2813
3223
|
var ArrayListSchema_default = ArrayListSchema;
|
|
2814
3224
|
|
|
2815
3225
|
// src/jsonSchemaForm/arrayTypeSchema/ArraySchema.tsx
|
|
2816
|
-
var
|
|
3226
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
2817
3227
|
var ArraySchema = (props) => {
|
|
2818
3228
|
const { schema } = props;
|
|
2819
3229
|
if (isListArraySchema(schema)) {
|
|
2820
|
-
return /* @__PURE__ */ (0,
|
|
3230
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ArrayListSchema_default, __spreadValues({}, props));
|
|
2821
3231
|
}
|
|
2822
3232
|
throw new Error("Not implemented");
|
|
2823
3233
|
};
|
|
@@ -2828,8 +3238,8 @@ var ArraySchema_default = ArraySchema;
|
|
|
2828
3238
|
|
|
2829
3239
|
// src/jsonSchemaForm/objectSchema/ObjectSchema.tsx
|
|
2830
3240
|
var import_classnames3 = __toESM(require_classnames());
|
|
2831
|
-
var
|
|
2832
|
-
var
|
|
3241
|
+
var import_react13 = require("react");
|
|
3242
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
2833
3243
|
var getSchemaColumnClasses2 = (width) => {
|
|
2834
3244
|
return {
|
|
2835
3245
|
"col-xs-12": true,
|
|
@@ -2838,7 +3248,7 @@ var getSchemaColumnClasses2 = (width) => {
|
|
|
2838
3248
|
};
|
|
2839
3249
|
};
|
|
2840
3250
|
var ObjectSchema = (props) => {
|
|
2841
|
-
const [model, setModel] = (0,
|
|
3251
|
+
const [model, setModel] = (0, import_react13.useState)(() => __spreadValues({}, getValidObjectModelParts(props.model, props.schema)));
|
|
2842
3252
|
const onChangeProperty = (propertyName, onChangeProps) => {
|
|
2843
3253
|
if (onChangeProps.model !== null) {
|
|
2844
3254
|
model[propertyName] = onChangeProps.model;
|
|
@@ -2849,7 +3259,7 @@ var ObjectSchema = (props) => {
|
|
|
2849
3259
|
props.onChange(__spreadProps(__spreadValues({}, onChangeProps), { model }));
|
|
2850
3260
|
};
|
|
2851
3261
|
const isRequired = (propertyName) => props.schema.required && props.schema.required.includes(propertyName);
|
|
2852
|
-
(0,
|
|
3262
|
+
(0, import_react13.useEffect)(() => {
|
|
2853
3263
|
const newModel = getValidObjectModelParts(model, props.schema) || {};
|
|
2854
3264
|
setModel(newModel);
|
|
2855
3265
|
if (!isEqual(newModel, model)) {
|
|
@@ -2867,25 +3277,25 @@ var ObjectSchema = (props) => {
|
|
|
2867
3277
|
const isPropertyDefined = (propertyName) => typeof props.schema.properties[propertyName] !== "undefined";
|
|
2868
3278
|
const orderedPropertyNames = Array.from(allorderedPropertiesSet).filter(isPropertyDefined);
|
|
2869
3279
|
const propsErrors = props.errors;
|
|
2870
|
-
return /* @__PURE__ */ (0,
|
|
2871
|
-
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: [
|
|
2872
3282
|
" ",
|
|
2873
3283
|
props.schema.title,
|
|
2874
3284
|
" "
|
|
2875
3285
|
] }),
|
|
2876
|
-
props.schema.description && !props.hideTitle && /* @__PURE__ */ (0,
|
|
3286
|
+
props.schema.description && !props.hideTitle && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("p", { children: [
|
|
2877
3287
|
" ",
|
|
2878
3288
|
props.schema.description,
|
|
2879
3289
|
" "
|
|
2880
3290
|
] }),
|
|
2881
|
-
props.schema.alert && /* @__PURE__ */ (0,
|
|
2882
|
-
/* @__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)(
|
|
2883
3293
|
"div",
|
|
2884
3294
|
{
|
|
2885
3295
|
className: (0, import_classnames3.default)(
|
|
2886
3296
|
getSchemaColumnClasses2(props.schema.properties[propertyName].width)
|
|
2887
3297
|
),
|
|
2888
|
-
children: /* @__PURE__ */ (0,
|
|
3298
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2889
3299
|
GenericSchema_default,
|
|
2890
3300
|
{
|
|
2891
3301
|
schema: props.schema.properties[propertyName],
|
|
@@ -2911,15 +3321,15 @@ var ObjectSchema_default = ObjectSchema;
|
|
|
2911
3321
|
|
|
2912
3322
|
// src/jsonSchemaForm/oneOfSchema/OneOfSchema.tsx
|
|
2913
3323
|
var import_classnames4 = __toESM(require_classnames());
|
|
2914
|
-
var
|
|
3324
|
+
var import_react16 = require("react");
|
|
2915
3325
|
|
|
2916
3326
|
// src/jsonSchemaForm/help/Help.tsx
|
|
2917
|
-
var
|
|
2918
|
-
var
|
|
3327
|
+
var import_components10 = require("@transferwise/components");
|
|
3328
|
+
var import_react_intl13 = require("react-intl");
|
|
2919
3329
|
|
|
2920
3330
|
// src/jsonSchemaForm/help/Help.messages.js
|
|
2921
|
-
var
|
|
2922
|
-
var Help_messages_default = (0,
|
|
3331
|
+
var import_react_intl12 = require("react-intl");
|
|
3332
|
+
var Help_messages_default = (0, import_react_intl12.defineMessages)({
|
|
2923
3333
|
helpAria: {
|
|
2924
3334
|
id: "dynamicFlows.Help.ariaLabel",
|
|
2925
3335
|
defaultMessage: "Click here for more info.",
|
|
@@ -2928,14 +3338,14 @@ var Help_messages_default = (0, import_react_intl9.defineMessages)({
|
|
|
2928
3338
|
});
|
|
2929
3339
|
|
|
2930
3340
|
// src/jsonSchemaForm/help/Help.tsx
|
|
2931
|
-
var
|
|
3341
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
2932
3342
|
var Help = (props) => {
|
|
2933
|
-
const intl = (0,
|
|
2934
|
-
return /* @__PURE__ */ (0,
|
|
2935
|
-
|
|
3343
|
+
const intl = (0, import_react_intl13.useIntl)();
|
|
3344
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
3345
|
+
import_components10.Info,
|
|
2936
3346
|
{
|
|
2937
3347
|
className: "m-l-1",
|
|
2938
|
-
content: /* @__PURE__ */ (0,
|
|
3348
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_components10.Markdown, { children: props.help.markdown }),
|
|
2939
3349
|
presentation: "POPOVER",
|
|
2940
3350
|
size: "sm",
|
|
2941
3351
|
"aria-label": intl.formatMessage(Help_messages_default.helpAria)
|
|
@@ -2945,11 +3355,11 @@ var Help = (props) => {
|
|
|
2945
3355
|
var Help_default = Help;
|
|
2946
3356
|
|
|
2947
3357
|
// src/jsonSchemaForm/schemaFormControl/SchemaFormControl.tsx
|
|
2948
|
-
var
|
|
3358
|
+
var import_react15 = require("react");
|
|
2949
3359
|
|
|
2950
3360
|
// src/formControl/FormControl.tsx
|
|
2951
|
-
var
|
|
2952
|
-
var
|
|
3361
|
+
var import_components11 = require("@transferwise/components");
|
|
3362
|
+
var import_react14 = require("react");
|
|
2953
3363
|
|
|
2954
3364
|
// src/formControl/utils/value-utils.ts
|
|
2955
3365
|
var getSafeStringValue = (value, options = {}) => {
|
|
@@ -3059,8 +3469,8 @@ var logInvalidTypeFallbackWarning = ({
|
|
|
3059
3469
|
};
|
|
3060
3470
|
|
|
3061
3471
|
// src/formControl/FormControl.tsx
|
|
3062
|
-
var
|
|
3063
|
-
var _FormControl = class extends
|
|
3472
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
3473
|
+
var _FormControl = class extends import_react14.PureComponent {
|
|
3064
3474
|
constructor(props) {
|
|
3065
3475
|
super(props);
|
|
3066
3476
|
/**
|
|
@@ -3098,6 +3508,7 @@ var _FormControl = class extends import_react13.PureComponent {
|
|
|
3098
3508
|
this.mapOption = (option) => {
|
|
3099
3509
|
return __spreadProps(__spreadValues({}, option), {
|
|
3100
3510
|
value: isNumber(option.value) || isString(option.value) ? option.value : void 0,
|
|
3511
|
+
secondary: option.note,
|
|
3101
3512
|
disabled: option.disabled || this.props.disabled,
|
|
3102
3513
|
readOnly: this.props.readOnly
|
|
3103
3514
|
});
|
|
@@ -3146,8 +3557,8 @@ var _FormControl = class extends import_react13.PureComponent {
|
|
|
3146
3557
|
} = this.props;
|
|
3147
3558
|
switch (type) {
|
|
3148
3559
|
case FormControlType.RADIO:
|
|
3149
|
-
return /* @__PURE__ */ (0,
|
|
3150
|
-
|
|
3560
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3561
|
+
import_components11.RadioGroup,
|
|
3151
3562
|
{
|
|
3152
3563
|
radios: options.map(this.mapOption),
|
|
3153
3564
|
name,
|
|
@@ -3156,8 +3567,8 @@ var _FormControl = class extends import_react13.PureComponent {
|
|
|
3156
3567
|
}
|
|
3157
3568
|
);
|
|
3158
3569
|
case FormControlType.CHECKBOX:
|
|
3159
|
-
return /* @__PURE__ */ (0,
|
|
3160
|
-
|
|
3570
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3571
|
+
import_components11.Checkbox,
|
|
3161
3572
|
{
|
|
3162
3573
|
checked: getSafeBooleanValue(value, { coerceValue: true }),
|
|
3163
3574
|
disabled,
|
|
@@ -3171,8 +3582,8 @@ var _FormControl = class extends import_react13.PureComponent {
|
|
|
3171
3582
|
);
|
|
3172
3583
|
case FormControlType.SELECT: {
|
|
3173
3584
|
const search = options.length >= 20;
|
|
3174
|
-
return /* @__PURE__ */ (0,
|
|
3175
|
-
|
|
3585
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3586
|
+
import_components11.Select,
|
|
3176
3587
|
{
|
|
3177
3588
|
id,
|
|
3178
3589
|
selected: this.getSelectedOption(options),
|
|
@@ -3195,13 +3606,13 @@ var _FormControl = class extends import_react13.PureComponent {
|
|
|
3195
3606
|
);
|
|
3196
3607
|
}
|
|
3197
3608
|
case FormControlType.TAB:
|
|
3198
|
-
return /* @__PURE__ */ (0,
|
|
3199
|
-
|
|
3609
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3610
|
+
import_components11.Tabs,
|
|
3200
3611
|
{
|
|
3201
3612
|
selected: ((_a = this.getSelectedOption(options)) == null ? void 0 : _a.value) || 0,
|
|
3202
3613
|
tabs: options.map((option) => ({
|
|
3203
3614
|
title: option.label,
|
|
3204
|
-
content: /* @__PURE__ */ (0,
|
|
3615
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_jsx_runtime26.Fragment, {}),
|
|
3205
3616
|
disabled: option.disabled || false
|
|
3206
3617
|
})),
|
|
3207
3618
|
name: id,
|
|
@@ -3215,7 +3626,7 @@ var _FormControl = class extends import_react13.PureComponent {
|
|
|
3215
3626
|
}
|
|
3216
3627
|
);
|
|
3217
3628
|
case FormControlType.NUMBER:
|
|
3218
|
-
return /* @__PURE__ */ (0,
|
|
3629
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3219
3630
|
"input",
|
|
3220
3631
|
{
|
|
3221
3632
|
autoComplete: this.getAutocompleteStatus(),
|
|
@@ -3243,7 +3654,7 @@ var _FormControl = class extends import_react13.PureComponent {
|
|
|
3243
3654
|
}
|
|
3244
3655
|
);
|
|
3245
3656
|
case FormControlType.HIDDEN:
|
|
3246
|
-
return /* @__PURE__ */ (0,
|
|
3657
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3247
3658
|
"input",
|
|
3248
3659
|
{
|
|
3249
3660
|
type: "hidden",
|
|
@@ -3253,7 +3664,7 @@ var _FormControl = class extends import_react13.PureComponent {
|
|
|
3253
3664
|
}
|
|
3254
3665
|
);
|
|
3255
3666
|
case FormControlType.PASSWORD:
|
|
3256
|
-
return /* @__PURE__ */ (0,
|
|
3667
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3257
3668
|
"input",
|
|
3258
3669
|
{
|
|
3259
3670
|
autoComplete: this.getAutocompleteStatus(),
|
|
@@ -3272,8 +3683,8 @@ var _FormControl = class extends import_react13.PureComponent {
|
|
|
3272
3683
|
);
|
|
3273
3684
|
case FormControlType.DATE:
|
|
3274
3685
|
case FormControlType.DATETIME:
|
|
3275
|
-
return /* @__PURE__ */ (0,
|
|
3276
|
-
|
|
3686
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3687
|
+
import_components11.DateInput,
|
|
3277
3688
|
{
|
|
3278
3689
|
disabled,
|
|
3279
3690
|
size,
|
|
@@ -3286,8 +3697,8 @@ var _FormControl = class extends import_react13.PureComponent {
|
|
|
3286
3697
|
}
|
|
3287
3698
|
);
|
|
3288
3699
|
case FormControlType.DATELOOKUP: {
|
|
3289
|
-
return /* @__PURE__ */ (0,
|
|
3290
|
-
|
|
3700
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3701
|
+
import_components11.DateLookup,
|
|
3291
3702
|
{
|
|
3292
3703
|
value: getSafeDateStringValue(value),
|
|
3293
3704
|
min: minDate,
|
|
@@ -3304,8 +3715,8 @@ var _FormControl = class extends import_react13.PureComponent {
|
|
|
3304
3715
|
);
|
|
3305
3716
|
}
|
|
3306
3717
|
case FormControlType.TEL:
|
|
3307
|
-
return /* @__PURE__ */ (0,
|
|
3308
|
-
|
|
3718
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3719
|
+
import_components11.PhoneNumberInput,
|
|
3309
3720
|
{
|
|
3310
3721
|
disabled,
|
|
3311
3722
|
countryCode,
|
|
@@ -3336,8 +3747,8 @@ var _FormControl = class extends import_react13.PureComponent {
|
|
|
3336
3747
|
autoComplete: this.getAutocompleteStatus()
|
|
3337
3748
|
};
|
|
3338
3749
|
if (this.props.displayPattern) {
|
|
3339
|
-
return /* @__PURE__ */ (0,
|
|
3340
|
-
|
|
3750
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3751
|
+
import_components11.TextareaWithDisplayFormat,
|
|
3341
3752
|
__spreadProps(__spreadValues({
|
|
3342
3753
|
displayPattern: this.props.displayPattern
|
|
3343
3754
|
}, textareaProps), {
|
|
@@ -3345,15 +3756,15 @@ var _FormControl = class extends import_react13.PureComponent {
|
|
|
3345
3756
|
})
|
|
3346
3757
|
);
|
|
3347
3758
|
}
|
|
3348
|
-
return /* @__PURE__ */ (0,
|
|
3759
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("textarea", __spreadProps(__spreadValues({}, textareaProps), { onChange: this.handleInputOnChange }));
|
|
3349
3760
|
}
|
|
3350
3761
|
case FormControlType.FILE:
|
|
3351
3762
|
case FormControlType.UPLOAD: {
|
|
3352
3763
|
return (
|
|
3353
3764
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3354
3765
|
// @ts-expect-error - TODO: Remove this once Upload is migrated to TypeScript
|
|
3355
|
-
/* @__PURE__ */ (0,
|
|
3356
|
-
|
|
3766
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3767
|
+
import_components11.Upload,
|
|
3357
3768
|
__spreadProps(__spreadValues({}, uploadProps), {
|
|
3358
3769
|
usAccept: uploadProps.usAccept || "*",
|
|
3359
3770
|
usDisabled: uploadProps.usDisabled || disabled,
|
|
@@ -3389,8 +3800,8 @@ var _FormControl = class extends import_react13.PureComponent {
|
|
|
3389
3800
|
autoComplete: this.getAutocompleteStatus()
|
|
3390
3801
|
};
|
|
3391
3802
|
if (this.props.displayPattern) {
|
|
3392
|
-
return /* @__PURE__ */ (0,
|
|
3393
|
-
|
|
3803
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3804
|
+
import_components11.InputWithDisplayFormat,
|
|
3394
3805
|
__spreadProps(__spreadValues({
|
|
3395
3806
|
displayPattern: this.props.displayPattern
|
|
3396
3807
|
}, inputProps), {
|
|
@@ -3398,7 +3809,7 @@ var _FormControl = class extends import_react13.PureComponent {
|
|
|
3398
3809
|
})
|
|
3399
3810
|
);
|
|
3400
3811
|
}
|
|
3401
|
-
return /* @__PURE__ */ (0,
|
|
3812
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("input", __spreadProps(__spreadValues({}, inputProps), { onChange: this.handleInputOnChange }));
|
|
3402
3813
|
}
|
|
3403
3814
|
}
|
|
3404
3815
|
}
|
|
@@ -3441,8 +3852,8 @@ FormControl.defaultProps = {
|
|
|
3441
3852
|
};
|
|
3442
3853
|
|
|
3443
3854
|
// src/jsonSchemaForm/schemaFormControl/utils/mapping-utils.tsx
|
|
3444
|
-
var
|
|
3445
|
-
var
|
|
3855
|
+
var import_components12 = require("@transferwise/components");
|
|
3856
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
3446
3857
|
var mapConstSchemaToOption = (schema, controlType) => {
|
|
3447
3858
|
switch (controlType) {
|
|
3448
3859
|
case "select":
|
|
@@ -3470,7 +3881,7 @@ var mapKeywordsToSearchStrings = (searchStrings) => isArray(searchStrings) ? { s
|
|
|
3470
3881
|
var mapImage = (image) => {
|
|
3471
3882
|
if (image == null ? void 0 : image.url) {
|
|
3472
3883
|
return {
|
|
3473
|
-
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 || "" }) }) })
|
|
3474
3885
|
};
|
|
3475
3886
|
}
|
|
3476
3887
|
return null;
|
|
@@ -3480,27 +3891,27 @@ var getIconPropertyForSelectOption = (icon) => {
|
|
|
3480
3891
|
return { currency: icon.name.substring(5) };
|
|
3481
3892
|
}
|
|
3482
3893
|
if ((icon == null ? void 0 : icon.name) && isValidIconName(icon.name)) {
|
|
3483
|
-
return { icon: /* @__PURE__ */ (0,
|
|
3894
|
+
return { icon: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(DynamicIcon_default, { type: icon.name }) };
|
|
3484
3895
|
}
|
|
3485
3896
|
if (icon == null ? void 0 : icon.text) {
|
|
3486
|
-
return { icon: /* @__PURE__ */ (0,
|
|
3897
|
+
return { icon: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { children: icon.text }) };
|
|
3487
3898
|
}
|
|
3488
3899
|
return null;
|
|
3489
3900
|
};
|
|
3490
3901
|
var getAvatarPropertyForRadioOption = ({ image, icon }) => {
|
|
3491
3902
|
if (image == null ? void 0 : image.url) {
|
|
3492
3903
|
return {
|
|
3493
|
-
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: "" }) })
|
|
3494
3905
|
};
|
|
3495
3906
|
}
|
|
3496
3907
|
if ((icon == null ? void 0 : icon.name) && isValidIconName(icon.name)) {
|
|
3497
3908
|
return {
|
|
3498
|
-
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 }) })
|
|
3499
3910
|
};
|
|
3500
3911
|
}
|
|
3501
3912
|
if (icon == null ? void 0 : icon.text) {
|
|
3502
3913
|
return {
|
|
3503
|
-
avatar: /* @__PURE__ */ (0,
|
|
3914
|
+
avatar: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_components12.Avatar, { type: import_components12.AvatarType.INITIALS, children: icon.text })
|
|
3504
3915
|
};
|
|
3505
3916
|
}
|
|
3506
3917
|
return null;
|
|
@@ -3521,7 +3932,7 @@ var getDisabled = (disabled) => {
|
|
|
3521
3932
|
};
|
|
3522
3933
|
|
|
3523
3934
|
// src/jsonSchemaForm/schemaFormControl/SchemaFormControl.tsx
|
|
3524
|
-
var
|
|
3935
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
3525
3936
|
var isNativeInput = (propsSchemaType) => {
|
|
3526
3937
|
return propsSchemaType === "string" || propsSchemaType === "number";
|
|
3527
3938
|
};
|
|
@@ -3574,7 +3985,7 @@ var SchemaFormControl = (props) => {
|
|
|
3574
3985
|
onChange(getValidBasicModelOrNull(value2, schema), type);
|
|
3575
3986
|
};
|
|
3576
3987
|
const controlType = getControlType(schema);
|
|
3577
|
-
(0,
|
|
3988
|
+
(0, import_react15.useEffect)(() => {
|
|
3578
3989
|
warnIfInvalidSchema(schema, log, controlType);
|
|
3579
3990
|
}, [JSON.stringify(schema), log, controlType]);
|
|
3580
3991
|
const options = schema.values || getOptions(schema, controlType);
|
|
@@ -3597,7 +4008,7 @@ var SchemaFormControl = (props) => {
|
|
|
3597
4008
|
// TODO: LOW avoid type assertion below
|
|
3598
4009
|
uploadProps: mapSchemaToUploadOptions(schema)
|
|
3599
4010
|
};
|
|
3600
|
-
return /* @__PURE__ */ (0,
|
|
4011
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(FormControl, __spreadValues(__spreadValues({ type: controlType, value: safeValue }, events), controlProps));
|
|
3601
4012
|
};
|
|
3602
4013
|
SchemaFormControl.defaultProps = {
|
|
3603
4014
|
value: null,
|
|
@@ -3625,69 +4036,18 @@ var warnIfInvalidSchema = (schema, log, controlType) => {
|
|
|
3625
4036
|
};
|
|
3626
4037
|
var SchemaFormControl_default = SchemaFormControl;
|
|
3627
4038
|
|
|
3628
|
-
// src/jsonSchemaForm/oneOfSchema/utils.ts
|
|
3629
|
-
var getActiveSchemaIndex = (schema, model) => {
|
|
3630
|
-
const indexFromModel = getValidIndexFromValue(schema, model);
|
|
3631
|
-
if (indexFromModel >= 0) {
|
|
3632
|
-
return indexFromModel;
|
|
3633
|
-
}
|
|
3634
|
-
if (schema.oneOf.length === 1 && isNoNConstSchema(schema.oneOf[0])) {
|
|
3635
|
-
return 0;
|
|
3636
|
-
}
|
|
3637
|
-
if (isConstSchema(schema.oneOf[0])) {
|
|
3638
|
-
const indexFromDefault = getValidIndexFromValue(schema, schema.default);
|
|
3639
|
-
if (indexFromDefault >= 0) {
|
|
3640
|
-
return indexFromDefault;
|
|
3641
|
-
}
|
|
3642
|
-
}
|
|
3643
|
-
if (isOneOfObjectSchema(schema) && isObjectModel(model) && Object.keys(model).length >= 1) {
|
|
3644
|
-
return getBestMatchingSchemaIndexForValue(schema, model);
|
|
3645
|
-
}
|
|
3646
|
-
if (isOneOfObjectSchema(schema) && !isUndefined(schema.default) && isObjectModel(schema.default) && Object.keys(schema.default).length >= 1) {
|
|
3647
|
-
return getBestMatchingSchemaIndexForValue(schema, schema.default);
|
|
3648
|
-
}
|
|
3649
|
-
return null;
|
|
3650
|
-
};
|
|
3651
|
-
var getValidIndexFromValue = (schema, value) => {
|
|
3652
|
-
return schema.oneOf.findIndex(
|
|
3653
|
-
(childSchema) => !isUndefined(value) && isValidSchema(value, childSchema)
|
|
3654
|
-
);
|
|
3655
|
-
};
|
|
3656
|
-
function getBestMatchingSchemaIndexForValue(schema, value) {
|
|
3657
|
-
if (value === null || value === void 0) {
|
|
3658
|
-
return null;
|
|
3659
|
-
}
|
|
3660
|
-
const schemaPoints = schema.oneOf.map((childSchema) => {
|
|
3661
|
-
return getSchemaProperties(childSchema).reduce((total, [key, propertySchema]) => {
|
|
3662
|
-
if (isConstSchema(propertySchema) && propertySchema.const === value[key]) {
|
|
3663
|
-
return total + 2;
|
|
3664
|
-
} else if (isNoNConstSchema(propertySchema) && typeof value[key] !== "undefined") {
|
|
3665
|
-
return total + 1;
|
|
3666
|
-
}
|
|
3667
|
-
return total;
|
|
3668
|
-
}, 0);
|
|
3669
|
-
});
|
|
3670
|
-
if (schemaPoints.every((p) => p === schemaPoints[0])) {
|
|
3671
|
-
return null;
|
|
3672
|
-
}
|
|
3673
|
-
return schemaPoints.indexOf(Math.max(...schemaPoints));
|
|
3674
|
-
}
|
|
3675
|
-
function getSchemaProperties(childSchema) {
|
|
3676
|
-
return childSchema.properties !== null && typeof childSchema.properties === "object" ? Object.entries(childSchema.properties) : [];
|
|
3677
|
-
}
|
|
3678
|
-
|
|
3679
4039
|
// src/jsonSchemaForm/oneOfSchema/OneOfSchema.tsx
|
|
3680
|
-
var
|
|
4040
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
3681
4041
|
var OneOfSchema = (props) => {
|
|
3682
4042
|
const onEvent = useEventDispatcher();
|
|
3683
|
-
const [changed, setChanged] = (0,
|
|
3684
|
-
const [focused, setFocused] = (0,
|
|
3685
|
-
const [blurred, setBlurred] = (0,
|
|
3686
|
-
const id = (0,
|
|
3687
|
-
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)(
|
|
3688
4048
|
getActiveSchemaIndex(props.schema, props.model)
|
|
3689
4049
|
);
|
|
3690
|
-
const [models, setModels] = (0,
|
|
4050
|
+
const [models, setModels] = (0, import_react16.useState)(getModelPartsForSchemas(props.model, props.schema.oneOf));
|
|
3691
4051
|
const debouncedTrackEvent = useDebouncedFunction(onEvent, 200);
|
|
3692
4052
|
const onSearchChange = (searchValue) => {
|
|
3693
4053
|
debouncedTrackEvent("Dynamic Flow - OneOf Searched", {
|
|
@@ -3695,7 +4055,7 @@ var OneOfSchema = (props) => {
|
|
|
3695
4055
|
searchValueLength: searchValue.length
|
|
3696
4056
|
});
|
|
3697
4057
|
};
|
|
3698
|
-
(0,
|
|
4058
|
+
(0, import_react16.useEffect)(() => {
|
|
3699
4059
|
const modelIndex = getValidIndexFromValue(props.schema, props.model);
|
|
3700
4060
|
const defaultIndex = getValidIndexFromValue(props.schema, props.schema.default);
|
|
3701
4061
|
if (modelIndex === -1 && defaultIndex >= 0) {
|
|
@@ -3750,11 +4110,11 @@ var OneOfSchema = (props) => {
|
|
|
3750
4110
|
"form-group": true,
|
|
3751
4111
|
"has-error": !changed && props.errors && !isEmpty(props.errors) || (props.submitted || changed && blurred) && validations.length
|
|
3752
4112
|
};
|
|
3753
|
-
return /* @__PURE__ */ (0,
|
|
3754
|
-
(props.schema.oneOf.length > 1 || isConstSchema(props.schema.oneOf[0])) && /* @__PURE__ */ (0,
|
|
3755
|
-
/* @__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: [
|
|
3756
4116
|
getTitleAndHelp(props.schema, id),
|
|
3757
|
-
/* @__PURE__ */ (0,
|
|
4117
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3758
4118
|
SchemaFormControl_default,
|
|
3759
4119
|
{
|
|
3760
4120
|
id,
|
|
@@ -3767,7 +4127,7 @@ var OneOfSchema = (props) => {
|
|
|
3767
4127
|
onSearchChange
|
|
3768
4128
|
}
|
|
3769
4129
|
),
|
|
3770
|
-
/* @__PURE__ */ (0,
|
|
4130
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3771
4131
|
ControlFeedback_default,
|
|
3772
4132
|
{
|
|
3773
4133
|
changed,
|
|
@@ -3781,9 +4141,9 @@ var OneOfSchema = (props) => {
|
|
|
3781
4141
|
}
|
|
3782
4142
|
)
|
|
3783
4143
|
] }),
|
|
3784
|
-
props.schema.alert && /* @__PURE__ */ (0,
|
|
4144
|
+
props.schema.alert && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(DynamicAlert_default, { component: props.schema.alert })
|
|
3785
4145
|
] }),
|
|
3786
|
-
isNoNConstSchema(props.schema.oneOf[schemaIndex]) && /* @__PURE__ */ (0,
|
|
4146
|
+
isNoNConstSchema(props.schema.oneOf[schemaIndex]) && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3787
4147
|
GenericSchema_default,
|
|
3788
4148
|
{
|
|
3789
4149
|
schema: props.schema.oneOf[schemaIndex],
|
|
@@ -3799,12 +4159,12 @@ var OneOfSchema = (props) => {
|
|
|
3799
4159
|
] });
|
|
3800
4160
|
};
|
|
3801
4161
|
function getTitleAndHelp(schema, id) {
|
|
3802
|
-
const helpElement = schema.help ? /* @__PURE__ */ (0,
|
|
3803
|
-
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: [
|
|
3804
4164
|
schema.title,
|
|
3805
4165
|
" ",
|
|
3806
4166
|
helpElement
|
|
3807
|
-
] }) : /* @__PURE__ */ (0,
|
|
4167
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("h4", { className: "m-b-2", children: [
|
|
3808
4168
|
schema.title,
|
|
3809
4169
|
" ",
|
|
3810
4170
|
helpElement
|
|
@@ -3845,12 +4205,12 @@ var OneOfSchema_default = OneOfSchema;
|
|
|
3845
4205
|
|
|
3846
4206
|
// src/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/PersistAsyncBlobSchema.tsx
|
|
3847
4207
|
var import_classnames5 = __toESM(require_classnames());
|
|
3848
|
-
var
|
|
4208
|
+
var import_react18 = require("react");
|
|
3849
4209
|
|
|
3850
4210
|
// src/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/UploadInputAdapter.tsx
|
|
3851
|
-
var
|
|
3852
|
-
var
|
|
3853
|
-
var
|
|
4211
|
+
var import_components13 = require("@transferwise/components");
|
|
4212
|
+
var import_react17 = require("react");
|
|
4213
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
3854
4214
|
var UploadInputAdapter = (props) => {
|
|
3855
4215
|
const {
|
|
3856
4216
|
id,
|
|
@@ -3866,7 +4226,7 @@ var UploadInputAdapter = (props) => {
|
|
|
3866
4226
|
onCancel
|
|
3867
4227
|
} = props;
|
|
3868
4228
|
const onEvent = useEventDispatcher();
|
|
3869
|
-
const files = (0,
|
|
4229
|
+
const files = (0, import_react17.useMemo)(() => fileId ? [{ id: fileId, status: import_components13.Status.SUCCEEDED }] : [], [fileId]);
|
|
3870
4230
|
const uploadFile = (formData) => {
|
|
3871
4231
|
onEvent("Dynamic Flow - PersistAsync", { status: "pending", schemaId: id });
|
|
3872
4232
|
return httpClient(`${httpOptions.url}`, {
|
|
@@ -3884,8 +4244,8 @@ var UploadInputAdapter = (props) => {
|
|
|
3884
4244
|
}
|
|
3885
4245
|
});
|
|
3886
4246
|
};
|
|
3887
|
-
return /* @__PURE__ */ (0,
|
|
3888
|
-
|
|
4247
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
4248
|
+
import_components13.UploadInput,
|
|
3889
4249
|
{
|
|
3890
4250
|
id,
|
|
3891
4251
|
fileInputName: httpOptions.fileInputName,
|
|
@@ -3904,12 +4264,12 @@ var UploadInputAdapter = (props) => {
|
|
|
3904
4264
|
};
|
|
3905
4265
|
|
|
3906
4266
|
// src/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/PersistAsyncBlobSchema.tsx
|
|
3907
|
-
var
|
|
4267
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
3908
4268
|
var PersistAsyncBlobSchema = (props) => {
|
|
3909
|
-
const [persistAsyncValidationMessages, setPersistAsyncValidationMessages] = (0,
|
|
3910
|
-
const [persistAsyncValidations, setPersistAsyncValidations] = (0,
|
|
3911
|
-
const [validations, setValidations] = (0,
|
|
3912
|
-
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);
|
|
3913
4273
|
const httpClient = useHttpClient();
|
|
3914
4274
|
const onEvent = useEventDispatcher();
|
|
3915
4275
|
const refreshValidations = () => {
|
|
@@ -3917,7 +4277,7 @@ var PersistAsyncBlobSchema = (props) => {
|
|
|
3917
4277
|
setValidations(getValidationFailures(props.model, props.schema, !!props.required));
|
|
3918
4278
|
}
|
|
3919
4279
|
};
|
|
3920
|
-
(0,
|
|
4280
|
+
(0, import_react18.useEffect)(refreshValidations, [props.model, props.submitted]);
|
|
3921
4281
|
const onSuccess = async (httpResponse, _fileName) => {
|
|
3922
4282
|
const jsonResponse = await httpResponse.json();
|
|
3923
4283
|
const id = getIdFromResponse(props.schema.persistAsync.idProperty, jsonResponse);
|
|
@@ -3946,8 +4306,8 @@ var PersistAsyncBlobSchema = (props) => {
|
|
|
3946
4306
|
"form-group": true,
|
|
3947
4307
|
"has-error": (props.submitted || changed) && !!combinedValidations.length
|
|
3948
4308
|
};
|
|
3949
|
-
return /* @__PURE__ */ (0,
|
|
3950
|
-
/* @__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)(
|
|
3951
4311
|
UploadInputAdapter,
|
|
3952
4312
|
__spreadValues({
|
|
3953
4313
|
id: props.schema.$id || props.schema.persistAsync.schema.$id || props.schema.persistAsync.idProperty,
|
|
@@ -3964,7 +4324,7 @@ var PersistAsyncBlobSchema = (props) => {
|
|
|
3964
4324
|
onCancel
|
|
3965
4325
|
}, mapSchemaToUploadOptions(props.schema.persistAsync.schema))
|
|
3966
4326
|
),
|
|
3967
|
-
/* @__PURE__ */ (0,
|
|
4327
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
3968
4328
|
ControlFeedback_default,
|
|
3969
4329
|
{
|
|
3970
4330
|
blurred: true,
|
|
@@ -3988,17 +4348,17 @@ PersistAsyncBlobSchema.defaultProps = {
|
|
|
3988
4348
|
var PersistAsyncBlobSchema_default = PersistAsyncBlobSchema;
|
|
3989
4349
|
|
|
3990
4350
|
// src/jsonSchemaForm/persistAsyncSchema/PersistAsyncSchema.tsx
|
|
3991
|
-
var
|
|
4351
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
3992
4352
|
var PersistAsyncSchema = (props) => {
|
|
3993
4353
|
const { schema } = props;
|
|
3994
4354
|
const persistAsyncSchemaType = schema.persistAsync.schema.type;
|
|
3995
4355
|
if (persistAsyncSchemaType === "blob") {
|
|
3996
|
-
return /* @__PURE__ */ (0,
|
|
4356
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
3997
4357
|
PersistAsyncBlobSchema_default,
|
|
3998
4358
|
__spreadValues({}, props)
|
|
3999
4359
|
);
|
|
4000
4360
|
}
|
|
4001
|
-
return /* @__PURE__ */ (0,
|
|
4361
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(PersistAsyncBasicSchema_default, __spreadValues({}, props));
|
|
4002
4362
|
};
|
|
4003
4363
|
PersistAsyncSchema.defaultProps = {
|
|
4004
4364
|
required: false
|
|
@@ -4006,7 +4366,7 @@ PersistAsyncSchema.defaultProps = {
|
|
|
4006
4366
|
var PersistAsyncSchema_default = PersistAsyncSchema;
|
|
4007
4367
|
|
|
4008
4368
|
// src/jsonSchemaForm/promotedOneOfSchema/PromotedOneOfSchema.tsx
|
|
4009
|
-
var
|
|
4369
|
+
var import_react19 = require("react");
|
|
4010
4370
|
|
|
4011
4371
|
// src/jsonSchemaForm/promotedOneOfSchema/promoted-one-of-utils.ts
|
|
4012
4372
|
var getSelectionFromModel = (schema, model) => {
|
|
@@ -4018,8 +4378,8 @@ var getSelectionFromModel = (schema, model) => {
|
|
|
4018
4378
|
};
|
|
4019
4379
|
|
|
4020
4380
|
// src/jsonSchemaForm/promotedOneOfSchema/promotedOneOfControl/PromotedOneOfCheckboxControl.tsx
|
|
4021
|
-
var
|
|
4022
|
-
var
|
|
4381
|
+
var import_components14 = require("@transferwise/components");
|
|
4382
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
4023
4383
|
var PromotedOneOfCheckboxControl = (props) => {
|
|
4024
4384
|
const { id, selection, setSelection } = props;
|
|
4025
4385
|
const { promoted, other, checkedMeans } = props.promotion;
|
|
@@ -4030,14 +4390,14 @@ var PromotedOneOfCheckboxControl = (props) => {
|
|
|
4030
4390
|
const toggleSelection = () => {
|
|
4031
4391
|
setSelection(checked ? selectionWhenUnchecked : selectionWhenChecked);
|
|
4032
4392
|
};
|
|
4033
|
-
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 }) });
|
|
4034
4394
|
};
|
|
4035
4395
|
PromotedOneOfCheckboxControl.defaultProps = {};
|
|
4036
4396
|
var PromotedOneOfCheckboxControl_default = PromotedOneOfCheckboxControl;
|
|
4037
4397
|
|
|
4038
4398
|
// src/jsonSchemaForm/promotedOneOfSchema/promotedOneOfControl/PromotedOneOfRadioControl.tsx
|
|
4039
|
-
var
|
|
4040
|
-
var
|
|
4399
|
+
var import_components15 = require("@transferwise/components");
|
|
4400
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
4041
4401
|
var PromotedOneOfRadioControl = (props) => {
|
|
4042
4402
|
var _a, _b;
|
|
4043
4403
|
const { id, selection, setSelection, promotion, promotedOneOf, title } = props;
|
|
@@ -4054,10 +4414,10 @@ var PromotedOneOfRadioControl = (props) => {
|
|
|
4054
4414
|
secondary: promotion.other.description
|
|
4055
4415
|
}, getAvatarPropertyForRadioOption(promotion.other))
|
|
4056
4416
|
];
|
|
4057
|
-
return /* @__PURE__ */ (0,
|
|
4058
|
-
title && /* @__PURE__ */ (0,
|
|
4059
|
-
/* @__PURE__ */ (0,
|
|
4060
|
-
|
|
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,
|
|
4061
4421
|
{
|
|
4062
4422
|
name: "promoted-selection",
|
|
4063
4423
|
selectedValue: selection,
|
|
@@ -4074,16 +4434,16 @@ PromotedOneOfRadioControl.defaultProps = {
|
|
|
4074
4434
|
var PromotedOneOfRadioControl_default = PromotedOneOfRadioControl;
|
|
4075
4435
|
|
|
4076
4436
|
// src/jsonSchemaForm/promotedOneOfSchema/promotedOneOfControl/PromotedOneOfControl.tsx
|
|
4077
|
-
var
|
|
4437
|
+
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
4078
4438
|
var PromotedOneOfControl = (props) => {
|
|
4079
4439
|
const controlType = props.promotion.control || "radio";
|
|
4080
4440
|
switch (controlType) {
|
|
4081
4441
|
case "radio":
|
|
4082
|
-
return /* @__PURE__ */ (0,
|
|
4442
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(PromotedOneOfRadioControl_default, __spreadValues({}, props));
|
|
4083
4443
|
case "checkbox":
|
|
4084
|
-
return /* @__PURE__ */ (0,
|
|
4444
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(PromotedOneOfCheckboxControl_default, __spreadValues({}, props));
|
|
4085
4445
|
default:
|
|
4086
|
-
return /* @__PURE__ */ (0,
|
|
4446
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_jsx_runtime35.Fragment, {});
|
|
4087
4447
|
}
|
|
4088
4448
|
};
|
|
4089
4449
|
PromotedOneOfControl.defaultProps = {
|
|
@@ -4093,20 +4453,20 @@ PromotedOneOfControl.defaultProps = {
|
|
|
4093
4453
|
var PromotedOneOfControl_default = PromotedOneOfControl;
|
|
4094
4454
|
|
|
4095
4455
|
// src/jsonSchemaForm/promotedOneOfSchema/PromotedOneOfSchema.tsx
|
|
4096
|
-
var
|
|
4456
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
4097
4457
|
var isPromoted = (schema) => schema.promoted === true;
|
|
4098
4458
|
var PromotedOneOfSchema = (props) => {
|
|
4099
4459
|
var _a;
|
|
4100
|
-
const [selection, setSelection] = (0,
|
|
4460
|
+
const [selection, setSelection] = (0, import_react19.useState)(
|
|
4101
4461
|
getSelectionFromModel(props.schema, props.model) || ((_a = props.schema.promotion) == null ? void 0 : _a.default) || "promoted"
|
|
4102
4462
|
);
|
|
4103
4463
|
const promotedAlert = props.schema.alert;
|
|
4104
4464
|
const promotedOneOf = props.schema.oneOf.find(isPromoted);
|
|
4105
4465
|
const promotedObjectSchema = getPromotedObjectSchema(promotedOneOf);
|
|
4106
4466
|
const otherOneOf = getOtherOneOf(props.schema);
|
|
4107
|
-
return /* @__PURE__ */ (0,
|
|
4108
|
-
promotedAlert && /* @__PURE__ */ (0,
|
|
4109
|
-
/* @__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)(
|
|
4110
4470
|
PromotedOneOfControl_default,
|
|
4111
4471
|
{
|
|
4112
4472
|
id: props.schema.$id,
|
|
@@ -4117,8 +4477,8 @@ var PromotedOneOfSchema = (props) => {
|
|
|
4117
4477
|
setSelection
|
|
4118
4478
|
}
|
|
4119
4479
|
),
|
|
4120
|
-
selection === "promoted" && /* @__PURE__ */ (0,
|
|
4121
|
-
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 }))
|
|
4122
4482
|
] });
|
|
4123
4483
|
};
|
|
4124
4484
|
function getPromotedObjectSchema(promotedSchema) {
|
|
@@ -4148,12 +4508,12 @@ function getOtherOneOf(schema) {
|
|
|
4148
4508
|
var PromotedOneOfSchema_default = PromotedOneOfSchema;
|
|
4149
4509
|
|
|
4150
4510
|
// src/jsonSchemaForm/readOnlySchema/ReadOnlySchema.tsx
|
|
4151
|
-
var
|
|
4152
|
-
var
|
|
4511
|
+
var import_components16 = require("@transferwise/components");
|
|
4512
|
+
var import_react_intl15 = require("react-intl");
|
|
4153
4513
|
|
|
4154
4514
|
// src/jsonSchemaForm/readOnlySchema/ReadOnlySchema.messages.js
|
|
4155
|
-
var
|
|
4156
|
-
var ReadOnlySchema_messages_default = (0,
|
|
4515
|
+
var import_react_intl14 = require("react-intl");
|
|
4516
|
+
var ReadOnlySchema_messages_default = (0, import_react_intl14.defineMessages)({
|
|
4157
4517
|
yes: {
|
|
4158
4518
|
id: "dynamicFlows.ReadOnlySchema.yes",
|
|
4159
4519
|
defaultMessage: "Yes",
|
|
@@ -4167,12 +4527,12 @@ var ReadOnlySchema_messages_default = (0, import_react_intl11.defineMessages)({
|
|
|
4167
4527
|
});
|
|
4168
4528
|
|
|
4169
4529
|
// src/jsonSchemaForm/readOnlySchema/ReadOnlySchema.tsx
|
|
4170
|
-
var
|
|
4530
|
+
var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
4171
4531
|
var ReadOnlySchema = ({ schema, model }) => {
|
|
4172
4532
|
const { title = "" } = schema;
|
|
4173
|
-
const { formatMessage } = (0,
|
|
4533
|
+
const { formatMessage } = (0, import_react_intl15.useIntl)();
|
|
4174
4534
|
const value = getValueForSchema({ schema, model, formatMessage });
|
|
4175
|
-
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: "" }] });
|
|
4176
4536
|
};
|
|
4177
4537
|
var ReadOnlySchema_default = ReadOnlySchema;
|
|
4178
4538
|
function getValueForSchema({
|
|
@@ -4205,7 +4565,7 @@ function getSelectedOneOf(schema, model) {
|
|
|
4205
4565
|
function getValueFromOption(option) {
|
|
4206
4566
|
const text = option.title && option.description ? `${option.title} - ${option.description}` : option.title || "";
|
|
4207
4567
|
const icon = getAvatarPropertyForRadioOption({ icon: option.icon });
|
|
4208
|
-
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: [
|
|
4209
4569
|
icon.avatar,
|
|
4210
4570
|
" ",
|
|
4211
4571
|
text
|
|
@@ -4213,22 +4573,22 @@ function getValueFromOption(option) {
|
|
|
4213
4573
|
}
|
|
4214
4574
|
|
|
4215
4575
|
// src/jsonSchemaForm/validationAsyncSchema/ValidationAsyncSchema.tsx
|
|
4216
|
-
var
|
|
4217
|
-
var
|
|
4576
|
+
var import_react20 = require("react");
|
|
4577
|
+
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
4218
4578
|
var ValidationAsyncSchema = (props) => {
|
|
4219
4579
|
const { schema, model, required, submitted, errors, onChange } = props;
|
|
4220
|
-
const [validationAsyncModel, setValidationAsyncModel] = (0,
|
|
4221
|
-
const previousRequestedModelReference = (0,
|
|
4222
|
-
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)(
|
|
4223
4583
|
null
|
|
4224
4584
|
);
|
|
4225
|
-
const [validationAsyncErrors, setValidationAsyncErrors] = (0,
|
|
4226
|
-
const [fieldSubmitted, setFieldSubmitted] = (0,
|
|
4227
|
-
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);
|
|
4228
4588
|
const httpClient = useHttpClient();
|
|
4229
4589
|
const onEvent = useEventDispatcher();
|
|
4230
4590
|
const log = useLogger();
|
|
4231
|
-
(0,
|
|
4591
|
+
(0, import_react20.useEffect)(() => {
|
|
4232
4592
|
if (!schema.validationAsync.method) {
|
|
4233
4593
|
log.warning(
|
|
4234
4594
|
"Invalid schema or model",
|
|
@@ -4275,7 +4635,7 @@ var ValidationAsyncSchema = (props) => {
|
|
|
4275
4635
|
return newAbortController.signal;
|
|
4276
4636
|
};
|
|
4277
4637
|
const onBlur = () => {
|
|
4278
|
-
if (!isNull(validationAsyncModel) && !isEqual(validationAsyncModel, previousRequestedModelReference.current)) {
|
|
4638
|
+
if (!isNull(validationAsyncModel) && !isEqual(validationAsyncModel, previousRequestedModelReference.current) && isValidSchema(validationAsyncModel, schema)) {
|
|
4279
4639
|
void getValidationAsyncResponse(validationAsyncModel, schema.validationAsync);
|
|
4280
4640
|
}
|
|
4281
4641
|
};
|
|
@@ -4286,9 +4646,7 @@ var ValidationAsyncSchema = (props) => {
|
|
|
4286
4646
|
}));
|
|
4287
4647
|
setValidationAsyncErrors(null);
|
|
4288
4648
|
setValidationAsyncSuccessMessage(null);
|
|
4289
|
-
|
|
4290
|
-
setValidationAsyncModel(parameters.model);
|
|
4291
|
-
}
|
|
4649
|
+
setValidationAsyncModel(parameters.model);
|
|
4292
4650
|
};
|
|
4293
4651
|
const basicTypeSchemaProps = {
|
|
4294
4652
|
submitted: submitted || fieldSubmitted,
|
|
@@ -4300,20 +4658,20 @@ var ValidationAsyncSchema = (props) => {
|
|
|
4300
4658
|
required,
|
|
4301
4659
|
schema
|
|
4302
4660
|
};
|
|
4303
|
-
return /* @__PURE__ */ (0,
|
|
4661
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(BasicTypeSchema_default, __spreadValues({}, basicTypeSchemaProps));
|
|
4304
4662
|
};
|
|
4305
4663
|
ValidationAsyncSchema.defaultProps = { required: false };
|
|
4306
4664
|
var ValidationAsyncSchema_default = ValidationAsyncSchema;
|
|
4307
4665
|
|
|
4308
4666
|
// src/jsonSchemaForm/genericSchema/GenericSchema.tsx
|
|
4309
|
-
var
|
|
4310
|
-
var
|
|
4667
|
+
var import_jsx_runtime39 = require("react/jsx-runtime");
|
|
4668
|
+
var import_react22 = require("react");
|
|
4311
4669
|
var GenericSchemaForm = (props) => {
|
|
4312
4670
|
const { schema, model = null, errors = null, hideTitle = false, disabled = false } = props;
|
|
4313
4671
|
const schemaProps = __spreadProps(__spreadValues({}, props), { model, errors, hideTitle, disabled });
|
|
4314
4672
|
const type = getSchemaType(schema);
|
|
4315
4673
|
const log = useLogger();
|
|
4316
|
-
(0,
|
|
4674
|
+
(0, import_react21.useEffect)(() => {
|
|
4317
4675
|
if (!isValidGenericSchema(schema, model, errors)) {
|
|
4318
4676
|
log.error(
|
|
4319
4677
|
"Invalid schema or model",
|
|
@@ -4323,27 +4681,27 @@ var GenericSchemaForm = (props) => {
|
|
|
4323
4681
|
}, [JSON.stringify(schema), JSON.stringify(model), JSON.stringify(errors), type, log]);
|
|
4324
4682
|
switch (type) {
|
|
4325
4683
|
case "readOnly":
|
|
4326
|
-
return /* @__PURE__ */ (0,
|
|
4684
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ReadOnlySchema_default, __spreadValues({}, schemaProps));
|
|
4327
4685
|
case "persistAsync":
|
|
4328
|
-
return /* @__PURE__ */ (0,
|
|
4686
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(PersistAsyncSchema_default, __spreadValues({}, schemaProps));
|
|
4329
4687
|
case "validationAsync":
|
|
4330
|
-
return /* @__PURE__ */ (0,
|
|
4688
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ValidationAsyncSchema_default, __spreadValues({}, schemaProps));
|
|
4331
4689
|
case "basic": {
|
|
4332
4690
|
const basicTypeProps = __spreadValues({ infoMessage: null }, schemaProps);
|
|
4333
|
-
return /* @__PURE__ */ (0,
|
|
4691
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(BasicTypeSchema_default, __spreadValues({}, basicTypeProps));
|
|
4334
4692
|
}
|
|
4335
4693
|
case "object":
|
|
4336
|
-
return /* @__PURE__ */ (0,
|
|
4694
|
+
return /* @__PURE__ */ (0, import_react22.createElement)(ObjectSchema_default, __spreadProps(__spreadValues({}, schemaProps), { key: JSON.stringify(schema) }));
|
|
4337
4695
|
case "array":
|
|
4338
|
-
return /* @__PURE__ */ (0,
|
|
4696
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ArraySchema_default, __spreadValues({}, schemaProps));
|
|
4339
4697
|
case "promotedOneOf":
|
|
4340
|
-
return /* @__PURE__ */ (0,
|
|
4698
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(PromotedOneOfSchema_default, __spreadValues({}, schemaProps));
|
|
4341
4699
|
case "oneOf":
|
|
4342
|
-
return /* @__PURE__ */ (0,
|
|
4700
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(OneOfSchema_default, __spreadValues({}, schemaProps));
|
|
4343
4701
|
case "allOf":
|
|
4344
|
-
return /* @__PURE__ */ (0,
|
|
4702
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(AllOfSchema_default, __spreadValues({}, schemaProps));
|
|
4345
4703
|
}
|
|
4346
|
-
return /* @__PURE__ */ (0,
|
|
4704
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_jsx_runtime39.Fragment, {});
|
|
4347
4705
|
};
|
|
4348
4706
|
var GenericSchema_default = GenericSchemaForm;
|
|
4349
4707
|
var isValidGenericSchema = (schema, model, errors) => {
|
|
@@ -4370,7 +4728,7 @@ var isValidGenericSchema = (schema, model, errors) => {
|
|
|
4370
4728
|
};
|
|
4371
4729
|
|
|
4372
4730
|
// src/jsonSchemaForm/JsonSchemaForm.tsx
|
|
4373
|
-
var
|
|
4731
|
+
var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
4374
4732
|
var JsonSchemaForm = (props) => {
|
|
4375
4733
|
const schemaProps = __spreadValues({
|
|
4376
4734
|
model: null,
|
|
@@ -4379,26 +4737,26 @@ var JsonSchemaForm = (props) => {
|
|
|
4379
4737
|
baseUrl: ""
|
|
4380
4738
|
}, props);
|
|
4381
4739
|
if (useHasHttpClientProvider() || schemaProps.baseUrl == null) {
|
|
4382
|
-
return /* @__PURE__ */ (0,
|
|
4740
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(GenericSchema_default, __spreadValues({}, schemaProps));
|
|
4383
4741
|
}
|
|
4384
|
-
return /* @__PURE__ */ (0,
|
|
4742
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
4385
4743
|
Providers,
|
|
4386
4744
|
{
|
|
4387
4745
|
baseUrl: schemaProps.baseUrl,
|
|
4388
4746
|
onEvent: schemaProps.onEvent,
|
|
4389
4747
|
onLog: schemaProps.onLog,
|
|
4390
|
-
children: /* @__PURE__ */ (0,
|
|
4748
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(GenericSchema_default, __spreadValues({}, schemaProps))
|
|
4391
4749
|
}
|
|
4392
4750
|
);
|
|
4393
4751
|
};
|
|
4394
4752
|
var JsonSchemaForm_default = JsonSchemaForm;
|
|
4395
4753
|
var Providers = ({ baseUrl, onEvent, onLog, children }) => {
|
|
4396
|
-
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)(
|
|
4397
4755
|
EventsContextProvider,
|
|
4398
4756
|
{
|
|
4399
4757
|
metadata: { flowId: "JsonSchemaForm", stepId: "JsonSchemaForm" },
|
|
4400
4758
|
onEvent: onEvent != null ? onEvent : noop2,
|
|
4401
|
-
children: /* @__PURE__ */ (0,
|
|
4759
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(HttpClientProviderFromBaseUrl, { baseUrl, children })
|
|
4402
4760
|
}
|
|
4403
4761
|
) });
|
|
4404
4762
|
};
|
|
@@ -4406,11 +4764,11 @@ var noop2 = () => {
|
|
|
4406
4764
|
};
|
|
4407
4765
|
|
|
4408
4766
|
// src/layout/form/DynamicForm.tsx
|
|
4409
|
-
var
|
|
4767
|
+
var import_jsx_runtime41 = require("react/jsx-runtime");
|
|
4410
4768
|
var DynamicForm = (props) => {
|
|
4411
4769
|
const form = props.component;
|
|
4412
4770
|
const formSchema = form.schema;
|
|
4413
|
-
return /* @__PURE__ */ (0,
|
|
4771
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: getMargin(form.margin || "md"), children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
4414
4772
|
JsonSchemaForm_default,
|
|
4415
4773
|
{
|
|
4416
4774
|
schema: formSchema,
|
|
@@ -4427,46 +4785,46 @@ var DynamicForm = (props) => {
|
|
|
4427
4785
|
var DynamicForm_default = DynamicForm;
|
|
4428
4786
|
|
|
4429
4787
|
// src/layout/heading/DynamicHeading.tsx
|
|
4430
|
-
var
|
|
4788
|
+
var import_jsx_runtime42 = require("react/jsx-runtime");
|
|
4431
4789
|
var DynamicHeading = (props) => {
|
|
4432
4790
|
const { text, size = "md", align = "left", margin = "md" } = props.component;
|
|
4433
4791
|
const classes = getTextAlignmentAndMargin({ align, margin });
|
|
4434
4792
|
switch (size) {
|
|
4435
4793
|
case "xs":
|
|
4436
|
-
return /* @__PURE__ */ (0,
|
|
4794
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("h5", { className: classes, children: text });
|
|
4437
4795
|
case "sm":
|
|
4438
|
-
return /* @__PURE__ */ (0,
|
|
4796
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("h4", { className: classes, children: text });
|
|
4439
4797
|
case "lg":
|
|
4440
|
-
return /* @__PURE__ */ (0,
|
|
4798
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("h2", { className: classes, children: text });
|
|
4441
4799
|
case "xl":
|
|
4442
|
-
return /* @__PURE__ */ (0,
|
|
4800
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("h1", { className: classes, children: text });
|
|
4443
4801
|
case "md":
|
|
4444
4802
|
default:
|
|
4445
|
-
return /* @__PURE__ */ (0,
|
|
4803
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("h3", { className: classes, children: text });
|
|
4446
4804
|
}
|
|
4447
4805
|
};
|
|
4448
4806
|
var DynamicHeading_default = DynamicHeading;
|
|
4449
4807
|
|
|
4450
4808
|
// src/layout/markdown/DynamicMarkdown.tsx
|
|
4451
|
-
var
|
|
4452
|
-
var
|
|
4809
|
+
var import_components17 = require("@transferwise/components");
|
|
4810
|
+
var import_jsx_runtime43 = require("react/jsx-runtime");
|
|
4453
4811
|
var DynamicMarkdown = ({ component }) => {
|
|
4454
4812
|
const { content, align, margin } = component;
|
|
4455
|
-
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 }) });
|
|
4456
4814
|
};
|
|
4457
4815
|
var DynamicInfo = ({ component }) => {
|
|
4458
|
-
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 }) });
|
|
4459
4817
|
};
|
|
4460
4818
|
|
|
4461
4819
|
// src/layout/image/DynamicImage.tsx
|
|
4462
|
-
var
|
|
4463
|
-
var
|
|
4464
|
-
var
|
|
4820
|
+
var import_components18 = require("@transferwise/components");
|
|
4821
|
+
var import_react23 = require("react");
|
|
4822
|
+
var import_jsx_runtime44 = require("react/jsx-runtime");
|
|
4465
4823
|
var DynamicImage = ({ component: image }) => {
|
|
4466
4824
|
const { url, size, text, margin, accessibilityDescription } = image;
|
|
4467
4825
|
const httpClient = useHttpClient();
|
|
4468
|
-
const [imageSource, setImageSource] = (0,
|
|
4469
|
-
(0,
|
|
4826
|
+
const [imageSource, setImageSource] = (0, import_react23.useState)("");
|
|
4827
|
+
(0, import_react23.useEffect)(() => {
|
|
4470
4828
|
void getImageSource(httpClient, url).then(setImageSource);
|
|
4471
4829
|
}, [url, httpClient]);
|
|
4472
4830
|
const imageProps = {
|
|
@@ -4478,7 +4836,7 @@ var DynamicImage = ({ component: image }) => {
|
|
|
4478
4836
|
if (!imageSource) {
|
|
4479
4837
|
return null;
|
|
4480
4838
|
}
|
|
4481
|
-
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)) });
|
|
4482
4840
|
};
|
|
4483
4841
|
var readImageBlobAsDataURL = (imageBlob) => {
|
|
4484
4842
|
return new Promise((resolve, reject) => {
|
|
@@ -4511,48 +4869,48 @@ var getImageSource = async (httpClient, imageUrl) => {
|
|
|
4511
4869
|
var DynamicImage_default = DynamicImage;
|
|
4512
4870
|
|
|
4513
4871
|
// src/layout/instructions/DynamicInstructions.tsx
|
|
4514
|
-
var
|
|
4515
|
-
var
|
|
4872
|
+
var import_components19 = require("@transferwise/components");
|
|
4873
|
+
var import_jsx_runtime45 = require("react/jsx-runtime");
|
|
4516
4874
|
var doContext = ["positive", "neutral"];
|
|
4517
4875
|
var dontContext = ["warning", "negative"];
|
|
4518
4876
|
var DynamicInstructions = ({ component }) => {
|
|
4519
4877
|
const { items } = component;
|
|
4520
4878
|
const dos = items.filter((item) => doContext.includes(item.context)).map(({ text }) => text);
|
|
4521
4879
|
const donts = items.filter((item) => dontContext.includes(item.context)).map(({ text }) => text);
|
|
4522
|
-
return /* @__PURE__ */ (0,
|
|
4523
|
-
component.title ? /* @__PURE__ */ (0,
|
|
4524
|
-
/* @__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 })
|
|
4525
4883
|
] });
|
|
4526
4884
|
};
|
|
4527
4885
|
var DynamicInstructions_default = DynamicInstructions;
|
|
4528
4886
|
|
|
4529
4887
|
// src/layout/DynamicLayout.tsx
|
|
4530
|
-
var
|
|
4888
|
+
var import_jsx_runtime46 = require("react/jsx-runtime");
|
|
4531
4889
|
var getKey = (component) => JSON.stringify(component);
|
|
4532
4890
|
var DynamicLayout = (props) => {
|
|
4533
4891
|
const { components, model, submitted, errors, onModelChange, onAction, onPersistAsync, baseUrl } = props;
|
|
4534
4892
|
const renderComponent = (component) => {
|
|
4535
4893
|
switch (component.type) {
|
|
4536
4894
|
case "heading":
|
|
4537
|
-
return /* @__PURE__ */ (0,
|
|
4895
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(DynamicHeading_default, { component }, getKey(component));
|
|
4538
4896
|
case "paragraph":
|
|
4539
|
-
return /* @__PURE__ */ (0,
|
|
4897
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(DynamicParagraph_default, { component }, getKey(component));
|
|
4540
4898
|
case "image":
|
|
4541
|
-
return /* @__PURE__ */ (0,
|
|
4899
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(DynamicImage_default, { component }, getKey(component));
|
|
4542
4900
|
case "alert":
|
|
4543
|
-
return /* @__PURE__ */ (0,
|
|
4901
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(DynamicAlert_default, { component }, getKey(component));
|
|
4544
4902
|
case "review":
|
|
4545
|
-
return /* @__PURE__ */ (0,
|
|
4903
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(DynamicReview_default, { component, onAction }, getKey(component));
|
|
4546
4904
|
case "divider":
|
|
4547
|
-
return /* @__PURE__ */ (0,
|
|
4905
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(DynamicDivider_default, { component }, getKey(component));
|
|
4548
4906
|
case "info":
|
|
4549
|
-
return /* @__PURE__ */ (0,
|
|
4907
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(DynamicInfo, { component }, getKey(component));
|
|
4550
4908
|
case "instructions":
|
|
4551
|
-
return /* @__PURE__ */ (0,
|
|
4909
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(DynamicInstructions_default, { component }, getKey(component));
|
|
4552
4910
|
case "markdown":
|
|
4553
|
-
return /* @__PURE__ */ (0,
|
|
4911
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(DynamicMarkdown, { component }, getKey(component));
|
|
4554
4912
|
case "columns":
|
|
4555
|
-
return /* @__PURE__ */ (0,
|
|
4913
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
4556
4914
|
DynamicColumns_default,
|
|
4557
4915
|
{
|
|
4558
4916
|
component,
|
|
@@ -4566,7 +4924,7 @@ var DynamicLayout = (props) => {
|
|
|
4566
4924
|
getKey(component)
|
|
4567
4925
|
);
|
|
4568
4926
|
case "form":
|
|
4569
|
-
return /* @__PURE__ */ (0,
|
|
4927
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
4570
4928
|
DynamicForm_default,
|
|
4571
4929
|
{
|
|
4572
4930
|
component,
|
|
@@ -4579,9 +4937,9 @@ var DynamicLayout = (props) => {
|
|
|
4579
4937
|
getKey(__spreadProps(__spreadValues({}, component), { errors: errors != null ? errors : null }))
|
|
4580
4938
|
);
|
|
4581
4939
|
case "button":
|
|
4582
|
-
return /* @__PURE__ */ (0,
|
|
4940
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(DynamicButton_default, { component, onAction }, getKey(component));
|
|
4583
4941
|
case "box":
|
|
4584
|
-
return /* @__PURE__ */ (0,
|
|
4942
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
4585
4943
|
DynamicBox_default,
|
|
4586
4944
|
{
|
|
4587
4945
|
component,
|
|
@@ -4595,34 +4953,34 @@ var DynamicLayout = (props) => {
|
|
|
4595
4953
|
getKey(component)
|
|
4596
4954
|
);
|
|
4597
4955
|
case "decision":
|
|
4598
|
-
return /* @__PURE__ */ (0,
|
|
4956
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(DynamicDecision_default, { component, onAction }, getKey(component));
|
|
4599
4957
|
case "external":
|
|
4600
|
-
return /* @__PURE__ */ (0,
|
|
4958
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(DynamicExternal_default, { component, onAction }, getKey(component));
|
|
4601
4959
|
case "list":
|
|
4602
4960
|
case "status-list":
|
|
4603
|
-
return /* @__PURE__ */ (0,
|
|
4961
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(DynamicStatusList_default, { component, onAction }, getKey(component));
|
|
4604
4962
|
case "loading-indicator":
|
|
4605
|
-
return /* @__PURE__ */ (0,
|
|
4963
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(DynamicLoadingIndicator_default, { component }, getKey(component));
|
|
4606
4964
|
case "search":
|
|
4607
|
-
return /* @__PURE__ */ (0,
|
|
4965
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(DynamicSearch_default, { component, onAction }, getKey(component));
|
|
4608
4966
|
default:
|
|
4609
|
-
return /* @__PURE__ */ (0,
|
|
4967
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", {}, getKey(component));
|
|
4610
4968
|
}
|
|
4611
4969
|
};
|
|
4612
4970
|
if (useHasHttpClientProvider() || baseUrl == null) {
|
|
4613
|
-
return /* @__PURE__ */ (0,
|
|
4971
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_jsx_runtime46.Fragment, { children: components.map(renderComponent) });
|
|
4614
4972
|
} else {
|
|
4615
|
-
return /* @__PURE__ */ (0,
|
|
4973
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(HttpClientProviderFromBaseUrl, { baseUrl, children: components.map(renderComponent) });
|
|
4616
4974
|
}
|
|
4617
4975
|
};
|
|
4618
4976
|
var DynamicLayout_default = DynamicLayout;
|
|
4619
4977
|
|
|
4620
4978
|
// src/layout/list/DynamicStatusList.tsx
|
|
4621
|
-
var
|
|
4622
|
-
var
|
|
4979
|
+
var import_components20 = require("@transferwise/components");
|
|
4980
|
+
var import_jsx_runtime47 = require("react/jsx-runtime");
|
|
4623
4981
|
var DynamicStatusList = ({ component }) => {
|
|
4624
|
-
return /* @__PURE__ */ (0,
|
|
4625
|
-
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: [
|
|
4626
4984
|
" ",
|
|
4627
4985
|
component.title,
|
|
4628
4986
|
" "
|
|
@@ -4635,8 +4993,8 @@ var mapListItemToSummary = ({ title, description, icon, status }) => {
|
|
|
4635
4993
|
key: `${title}/${description || ""}`,
|
|
4636
4994
|
title,
|
|
4637
4995
|
description
|
|
4638
|
-
}, (icon == null ? void 0 : icon.name) ? { icon: /* @__PURE__ */ (0,
|
|
4639
|
-
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));
|
|
4640
4998
|
};
|
|
4641
4999
|
var statusListMap = {
|
|
4642
5000
|
done: "done",
|
|
@@ -4652,16 +5010,16 @@ var statusMap = __spreadValues(__spreadValues({}, statusListMap), legacyStatusMa
|
|
|
4652
5010
|
var DynamicStatusList_default = DynamicStatusList;
|
|
4653
5011
|
|
|
4654
5012
|
// src/layout/loadingIndicator/DynamicLoadingIndicator.tsx
|
|
4655
|
-
var
|
|
4656
|
-
var
|
|
5013
|
+
var import_components21 = require("@transferwise/components");
|
|
5014
|
+
var import_jsx_runtime48 = require("react/jsx-runtime");
|
|
4657
5015
|
var DynamicLoadingIndicator = ({ component }) => {
|
|
4658
5016
|
const { margin, size = "md" } = component;
|
|
4659
|
-
return /* @__PURE__ */ (0,
|
|
4660
|
-
|
|
5017
|
+
return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
5018
|
+
import_components21.Loader,
|
|
4661
5019
|
{
|
|
4662
5020
|
size,
|
|
4663
5021
|
classNames: {
|
|
4664
|
-
"tw-loader": `tw-loader m-x-auto ${
|
|
5022
|
+
"tw-loader": `tw-loader m-x-auto ${getMargin(margin)}`
|
|
4665
5023
|
},
|
|
4666
5024
|
"data-testid": "loading-indicator"
|
|
4667
5025
|
}
|
|
@@ -4670,12 +5028,12 @@ var DynamicLoadingIndicator = ({ component }) => {
|
|
|
4670
5028
|
var DynamicLoadingIndicator_default = DynamicLoadingIndicator;
|
|
4671
5029
|
|
|
4672
5030
|
// src/layout/paragraph/DynamicParagraph.tsx
|
|
4673
|
-
var
|
|
4674
|
-
var
|
|
5031
|
+
var import_components23 = require("@transferwise/components");
|
|
5032
|
+
var import_react_intl17 = require("react-intl");
|
|
4675
5033
|
|
|
4676
5034
|
// src/layout/paragraph/DynamicParagraph.messages.ts
|
|
4677
|
-
var
|
|
4678
|
-
var DynamicParagraph_messages_default = (0,
|
|
5035
|
+
var import_react_intl16 = require("react-intl");
|
|
5036
|
+
var DynamicParagraph_messages_default = (0, import_react_intl16.defineMessages)({
|
|
4679
5037
|
copy: {
|
|
4680
5038
|
id: "dynamicFlows.DynamicParagraph.copy",
|
|
4681
5039
|
defaultMessage: "Copy",
|
|
@@ -4689,25 +5047,25 @@ var DynamicParagraph_messages_default = (0, import_react_intl13.defineMessages)(
|
|
|
4689
5047
|
});
|
|
4690
5048
|
|
|
4691
5049
|
// src/layout/paragraph/useSnackBarIfAvailable.ts
|
|
4692
|
-
var
|
|
4693
|
-
var
|
|
5050
|
+
var import_components22 = require("@transferwise/components");
|
|
5051
|
+
var import_react24 = require("react");
|
|
4694
5052
|
function useSnackBarIfAvailable() {
|
|
4695
|
-
const context = (0,
|
|
5053
|
+
const context = (0, import_react24.useContext)(import_components22.SnackbarContext);
|
|
4696
5054
|
return context ? context.createSnackbar : noop3;
|
|
4697
5055
|
}
|
|
4698
5056
|
function noop3() {
|
|
4699
5057
|
}
|
|
4700
5058
|
|
|
4701
5059
|
// src/layout/paragraph/DynamicParagraph.tsx
|
|
4702
|
-
var
|
|
4703
|
-
var DynamicParagraph = ({ component }) => component.control === "copyable" ? /* @__PURE__ */ (0,
|
|
4704
|
-
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: [
|
|
4705
5063
|
" ",
|
|
4706
5064
|
component.text,
|
|
4707
5065
|
" "
|
|
4708
5066
|
] });
|
|
4709
5067
|
var CopyableDynamicParagraph = ({ component }) => {
|
|
4710
|
-
const { formatMessage } = (0,
|
|
5068
|
+
const { formatMessage } = (0, import_react_intl17.useIntl)();
|
|
4711
5069
|
const createSnackbar = useSnackBarIfAvailable();
|
|
4712
5070
|
const { text } = component;
|
|
4713
5071
|
const copy = () => {
|
|
@@ -4715,8 +5073,8 @@ var CopyableDynamicParagraph = ({ component }) => {
|
|
|
4715
5073
|
(_a = navigator.clipboard) == null ? void 0 : _a.writeText(text).then(() => createSnackbar({ text: formatMessage(DynamicParagraph_messages_default.copied) })).catch(noop4);
|
|
4716
5074
|
};
|
|
4717
5075
|
const classNames7 = getTextAlignmentAndMargin({ align: component.align, margin: "sm" }) + " form-control";
|
|
4718
|
-
return /* @__PURE__ */ (0,
|
|
4719
|
-
/* @__PURE__ */ (0,
|
|
5076
|
+
return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className: getTextAlignmentAndMargin(component), children: [
|
|
5077
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
4720
5078
|
"input",
|
|
4721
5079
|
{
|
|
4722
5080
|
type: "text",
|
|
@@ -4726,7 +5084,7 @@ var CopyableDynamicParagraph = ({ component }) => {
|
|
|
4726
5084
|
style: { textOverflow: "ellipsis" }
|
|
4727
5085
|
}
|
|
4728
5086
|
),
|
|
4729
|
-
/* @__PURE__ */ (0,
|
|
5087
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_components23.Button, { block: true, onClick: copy, children: formatMessage(DynamicParagraph_messages_default.copy) })
|
|
4730
5088
|
] });
|
|
4731
5089
|
};
|
|
4732
5090
|
function noop4() {
|
|
@@ -4734,8 +5092,8 @@ function noop4() {
|
|
|
4734
5092
|
var DynamicParagraph_default = DynamicParagraph;
|
|
4735
5093
|
|
|
4736
5094
|
// src/layout/review/DynamicReview.tsx
|
|
4737
|
-
var
|
|
4738
|
-
var
|
|
5095
|
+
var import_components24 = require("@transferwise/components");
|
|
5096
|
+
var import_jsx_runtime50 = require("react/jsx-runtime");
|
|
4739
5097
|
var getDefinitions = (orientation, review) => {
|
|
4740
5098
|
return review.fields.map(
|
|
4741
5099
|
({ label, value, help }, index) => {
|
|
@@ -4749,14 +5107,14 @@ var getDefinitions = (orientation, review) => {
|
|
|
4749
5107
|
};
|
|
4750
5108
|
var getFieldValue = (value, help, orientation) => {
|
|
4751
5109
|
if (help) {
|
|
4752
|
-
return orientation === "HORIZONTAL_RIGHT_ALIGNED" ? /* @__PURE__ */ (0,
|
|
4753
|
-
/* @__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 }),
|
|
4754
5112
|
" ",
|
|
4755
5113
|
value
|
|
4756
|
-
] }) : /* @__PURE__ */ (0,
|
|
5114
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_jsx_runtime50.Fragment, { children: [
|
|
4757
5115
|
value,
|
|
4758
5116
|
" ",
|
|
4759
|
-
/* @__PURE__ */ (0,
|
|
5117
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Help_default, { help })
|
|
4760
5118
|
] });
|
|
4761
5119
|
}
|
|
4762
5120
|
return value;
|
|
@@ -4767,9 +5125,9 @@ var getReviewLayout = (review) => {
|
|
|
4767
5125
|
};
|
|
4768
5126
|
var DynamicReview = (props) => {
|
|
4769
5127
|
const review = props.component;
|
|
4770
|
-
const margin =
|
|
5128
|
+
const margin = getMargin(review.margin || "xs");
|
|
4771
5129
|
const getReviewAction = (action) => {
|
|
4772
|
-
return /* @__PURE__ */ (0,
|
|
5130
|
+
return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
4773
5131
|
"a",
|
|
4774
5132
|
{
|
|
4775
5133
|
href: action.url,
|
|
@@ -4784,36 +5142,36 @@ var DynamicReview = (props) => {
|
|
|
4784
5142
|
);
|
|
4785
5143
|
};
|
|
4786
5144
|
const orientation = getReviewLayout(review);
|
|
4787
|
-
return /* @__PURE__ */ (0,
|
|
4788
|
-
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: [
|
|
4789
5147
|
review.title,
|
|
4790
5148
|
review.action && getReviewAction(review.action)
|
|
4791
5149
|
] }),
|
|
4792
|
-
/* @__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) }) })
|
|
4793
5151
|
] });
|
|
4794
5152
|
};
|
|
4795
5153
|
var DynamicReview_default = DynamicReview;
|
|
4796
5154
|
|
|
4797
5155
|
// src/layout/search/DynamicSearch.tsx
|
|
4798
|
-
var
|
|
5156
|
+
var import_react26 = require("react");
|
|
4799
5157
|
|
|
4800
5158
|
// src/layout/search/SearchInput.tsx
|
|
4801
|
-
var
|
|
4802
|
-
var
|
|
5159
|
+
var import_components25 = require("@transferwise/components");
|
|
5160
|
+
var import_jsx_runtime51 = require("react/jsx-runtime");
|
|
4803
5161
|
var SearchInput = ({ title, value, onChange }) => {
|
|
4804
|
-
return /* @__PURE__ */ (0,
|
|
5162
|
+
return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("label", { className: "control-label d-inline", children: [
|
|
4805
5163
|
title,
|
|
4806
|
-
/* @__PURE__ */ (0,
|
|
5164
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_components25.Input, { type: "text", value, onChange: (event) => onChange(event.currentTarget.value) })
|
|
4807
5165
|
] });
|
|
4808
5166
|
};
|
|
4809
5167
|
|
|
4810
5168
|
// src/layout/search/SearchResults.tsx
|
|
4811
|
-
var
|
|
4812
|
-
var
|
|
5169
|
+
var import_components26 = require("@transferwise/components");
|
|
5170
|
+
var import_react_intl19 = require("react-intl");
|
|
4813
5171
|
|
|
4814
5172
|
// src/dynamicFlow/utils/errorBoundary/ErrorBoundary.messages.ts
|
|
4815
|
-
var
|
|
4816
|
-
var ErrorBoundary_messages_default = (0,
|
|
5173
|
+
var import_react_intl18 = require("react-intl");
|
|
5174
|
+
var ErrorBoundary_messages_default = (0, import_react_intl18.defineMessages)({
|
|
4817
5175
|
errorAlert: {
|
|
4818
5176
|
id: "dynamicFlows.ErrorBoundary.errorAlert",
|
|
4819
5177
|
defaultMessage: "Oops. Something went wrong...",
|
|
@@ -4827,14 +5185,14 @@ var ErrorBoundary_messages_default = (0, import_react_intl15.defineMessages)({
|
|
|
4827
5185
|
});
|
|
4828
5186
|
|
|
4829
5187
|
// src/layout/search/SearchResults.tsx
|
|
4830
|
-
var
|
|
5188
|
+
var import_jsx_runtime52 = require("react/jsx-runtime");
|
|
4831
5189
|
var SearchResults = ({ results, emptyMessage, onSelect }) => {
|
|
4832
5190
|
if (results.length === 0) {
|
|
4833
|
-
return /* @__PURE__ */ (0,
|
|
5191
|
+
return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("p", { className: "m-t-2", children: emptyMessage });
|
|
4834
5192
|
}
|
|
4835
|
-
return /* @__PURE__ */ (0,
|
|
4836
|
-
return /* @__PURE__ */ (0,
|
|
4837
|
-
|
|
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,
|
|
4838
5196
|
{
|
|
4839
5197
|
title: result.title,
|
|
4840
5198
|
content: result.description,
|
|
@@ -4848,11 +5206,11 @@ var SearchResults = ({ results, emptyMessage, onSelect }) => {
|
|
|
4848
5206
|
}) });
|
|
4849
5207
|
};
|
|
4850
5208
|
var ErrorResult = ({ onRetrySearch }) => {
|
|
4851
|
-
const intl = (0,
|
|
4852
|
-
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: [
|
|
4853
5211
|
intl.formatMessage(ErrorBoundary_messages_default.errorAlert),
|
|
4854
5212
|
"\xA0",
|
|
4855
|
-
/* @__PURE__ */ (0,
|
|
5213
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
|
|
4856
5214
|
"a",
|
|
4857
5215
|
{
|
|
4858
5216
|
href: "/",
|
|
@@ -4867,15 +5225,15 @@ var ErrorResult = ({ onRetrySearch }) => {
|
|
|
4867
5225
|
};
|
|
4868
5226
|
|
|
4869
5227
|
// src/layout/search/useSearch.tsx
|
|
4870
|
-
var
|
|
5228
|
+
var import_react25 = require("react");
|
|
4871
5229
|
var headers = { "Content-Type": "application/json" };
|
|
4872
5230
|
var useSearch = (defaultSearchConfig) => {
|
|
4873
|
-
const [state, setState] = (0,
|
|
5231
|
+
const [state, setState] = (0, import_react25.useState)({
|
|
4874
5232
|
status: "idle"
|
|
4875
5233
|
});
|
|
4876
|
-
const abortControllerRef = (0,
|
|
5234
|
+
const abortControllerRef = (0, import_react25.useRef)(null);
|
|
4877
5235
|
const httpClient = useHttpClient();
|
|
4878
|
-
const search = (0,
|
|
5236
|
+
const search = (0, import_react25.useCallback)(
|
|
4879
5237
|
async (query, { url, method, param } = defaultSearchConfig) => {
|
|
4880
5238
|
var _a;
|
|
4881
5239
|
(_a = abortControllerRef.current) == null ? void 0 : _a.abort();
|
|
@@ -4928,13 +5286,13 @@ var isValidResponseBody = (body) => {
|
|
|
4928
5286
|
var isAbortError = (error) => error instanceof DOMException && error.name === "AbortError";
|
|
4929
5287
|
|
|
4930
5288
|
// src/layout/search/DynamicSearch.tsx
|
|
4931
|
-
var
|
|
5289
|
+
var import_jsx_runtime53 = require("react/jsx-runtime");
|
|
4932
5290
|
var DEBOUNCE_TIME = 400;
|
|
4933
5291
|
var DynamicSearch = ({ component, onAction }) => {
|
|
4934
|
-
const [query, setQuery] = (0,
|
|
5292
|
+
const [query, setQuery] = (0, import_react26.useState)("");
|
|
4935
5293
|
const { title, margin, url, method, param, emptyMessage } = component;
|
|
4936
5294
|
const { status, results, search } = useSearch({ url, method, param });
|
|
4937
|
-
const debouncedSearch = (0,
|
|
5295
|
+
const debouncedSearch = (0, import_react26.useMemo)(() => debounce(search, DEBOUNCE_TIME), [search]);
|
|
4938
5296
|
const onChange = (value) => {
|
|
4939
5297
|
setQuery(value);
|
|
4940
5298
|
debouncedSearch(value);
|
|
@@ -4953,17 +5311,17 @@ var DynamicSearch = ({ component, onAction }) => {
|
|
|
4953
5311
|
setQuery(query);
|
|
4954
5312
|
void search(query);
|
|
4955
5313
|
};
|
|
4956
|
-
return /* @__PURE__ */ (0,
|
|
4957
|
-
/* @__PURE__ */ (0,
|
|
4958
|
-
status === "loading" && /* @__PURE__ */ (0,
|
|
4959
|
-
status === "error" && /* @__PURE__ */ (0,
|
|
4960
|
-
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 })
|
|
4961
5319
|
] });
|
|
4962
5320
|
};
|
|
4963
5321
|
var DynamicSearch_default = DynamicSearch;
|
|
4964
5322
|
|
|
4965
5323
|
// src/jsonSchemaForm/basicTypeSchema/BasicTypeSchema.tsx
|
|
4966
|
-
var
|
|
5324
|
+
var import_jsx_runtime54 = require("react/jsx-runtime");
|
|
4967
5325
|
var isNullish = (value) => isNull(value) || isUndefined(value);
|
|
4968
5326
|
var getDefaultValue = (schema) => {
|
|
4969
5327
|
return schema.type === "boolean" && isNullish(schema.default) ? false : schema.default;
|
|
@@ -5000,13 +5358,13 @@ var BasicTypeSchema = (props) => {
|
|
|
5000
5358
|
props.onBlur();
|
|
5001
5359
|
}
|
|
5002
5360
|
};
|
|
5003
|
-
const [model, setModel] = (0,
|
|
5004
|
-
const [lastModel, setLastModel] = (0,
|
|
5005
|
-
const [changed, setChanged] = (0,
|
|
5006
|
-
const [focused, setFocused] = (0,
|
|
5007
|
-
const [blurred, setBlurred] = (0,
|
|
5008
|
-
const [validations, setValidations] = (0,
|
|
5009
|
-
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]);
|
|
5010
5368
|
const onSchemaChange = () => {
|
|
5011
5369
|
const defaultValue = getDefaultValue(props.schema);
|
|
5012
5370
|
if (isNullish(model) && !isNullish(defaultValue)) {
|
|
@@ -5021,9 +5379,9 @@ var BasicTypeSchema = (props) => {
|
|
|
5021
5379
|
};
|
|
5022
5380
|
const isConst = props.schema.const;
|
|
5023
5381
|
const isHidden = props.schema.hidden || isConst;
|
|
5024
|
-
(0,
|
|
5025
|
-
(0,
|
|
5026
|
-
(0,
|
|
5382
|
+
(0, import_react27.useEffect)(refreshValidations, [props.model, props.submitted]);
|
|
5383
|
+
(0, import_react27.useEffect)(onSchemaChange, [props.schema]);
|
|
5384
|
+
(0, import_react27.useEffect)(() => {
|
|
5027
5385
|
var _a2;
|
|
5028
5386
|
const newModel = (_a2 = props.model) != null ? _a2 : null;
|
|
5029
5387
|
if (newModel !== model) {
|
|
@@ -5037,15 +5395,15 @@ var BasicTypeSchema = (props) => {
|
|
|
5037
5395
|
};
|
|
5038
5396
|
const showLabel = props.schema.format !== "file" && props.schema.type !== "boolean";
|
|
5039
5397
|
const schemaHelp = props.schema.help;
|
|
5040
|
-
return !isHidden ? /* @__PURE__ */ (0,
|
|
5041
|
-
props.schema.alert && /* @__PURE__ */ (0,
|
|
5042
|
-
/* @__PURE__ */ (0,
|
|
5043
|
-
showLabel && /* @__PURE__ */ (0,
|
|
5044
|
-
/* @__PURE__ */ (0,
|
|
5045
|
-
!!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 })
|
|
5046
5404
|
] }),
|
|
5047
|
-
!showLabel && !!schemaHelp && /* @__PURE__ */ (0,
|
|
5048
|
-
/* @__PURE__ */ (0,
|
|
5405
|
+
!showLabel && !!schemaHelp && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(Help_default, { help: schemaHelp }),
|
|
5406
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
5049
5407
|
SchemaFormControl_default,
|
|
5050
5408
|
{
|
|
5051
5409
|
id,
|
|
@@ -5057,7 +5415,7 @@ var BasicTypeSchema = (props) => {
|
|
|
5057
5415
|
onBlur
|
|
5058
5416
|
}
|
|
5059
5417
|
),
|
|
5060
|
-
/* @__PURE__ */ (0,
|
|
5418
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
5061
5419
|
ControlFeedback_default,
|
|
5062
5420
|
{
|
|
5063
5421
|
changed,
|
|
@@ -5081,7 +5439,7 @@ BasicTypeSchema.defaultProps = {
|
|
|
5081
5439
|
var BasicTypeSchema_default = BasicTypeSchema;
|
|
5082
5440
|
|
|
5083
5441
|
// src/jsonSchemaForm/persistAsyncSchema/persistAsyncBasicSchema/PersistAsyncBasicSchema.tsx
|
|
5084
|
-
var
|
|
5442
|
+
var import_jsx_runtime55 = require("react/jsx-runtime");
|
|
5085
5443
|
var getIdFromResponse = (idProperty, response) => {
|
|
5086
5444
|
return response[idProperty];
|
|
5087
5445
|
};
|
|
@@ -5098,15 +5456,15 @@ var controlTypesWithPersistOnChange = /* @__PURE__ */ new Set([
|
|
|
5098
5456
|
]);
|
|
5099
5457
|
var PersistAsyncBasicSchema = (props) => {
|
|
5100
5458
|
const { schema, required, submitted, errors, onChange, onPersistAsync } = props;
|
|
5101
|
-
const intl = (0,
|
|
5459
|
+
const intl = (0, import_react_intl20.useIntl)();
|
|
5102
5460
|
const httpClient = useHttpClient();
|
|
5103
5461
|
const onEvent = useEventDispatcher();
|
|
5104
|
-
const [persistAsyncModel, setPersistAsyncModel] = (0,
|
|
5462
|
+
const [persistAsyncModel, setPersistAsyncModel] = (0, import_react28.useState)(null);
|
|
5105
5463
|
const previousPersistAsyncModel = usePrevious(persistAsyncModel);
|
|
5106
|
-
const [persistAsyncError, setPersistAsyncError] = (0,
|
|
5107
|
-
const [fieldSubmitted, setFieldSubmitted] = (0,
|
|
5108
|
-
const [abortController, setAbortController] = (0,
|
|
5109
|
-
(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)(() => {
|
|
5110
5468
|
if (controlTypesWithPersistOnChange.has(
|
|
5111
5469
|
// TODO: LOW avoid type assertion below -- control type may be nullish. consider ?? ''
|
|
5112
5470
|
getControlType(schema.persistAsync.schema)
|
|
@@ -5173,7 +5531,7 @@ var PersistAsyncBasicSchema = (props) => {
|
|
|
5173
5531
|
setPersistAsyncModel(newPersistAsyncModel);
|
|
5174
5532
|
}
|
|
5175
5533
|
};
|
|
5176
|
-
return /* @__PURE__ */ (0,
|
|
5534
|
+
return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
5177
5535
|
BasicTypeSchema_default,
|
|
5178
5536
|
{
|
|
5179
5537
|
required,
|
|
@@ -5194,9 +5552,9 @@ var PersistAsyncBasicSchema_default = PersistAsyncBasicSchema;
|
|
|
5194
5552
|
|
|
5195
5553
|
// src/common/hooks/usePersistAsync/usePersistAsync.ts
|
|
5196
5554
|
var usePersistAsync = (persistAsync) => {
|
|
5197
|
-
const [abortController, setAbortController] = (0,
|
|
5555
|
+
const [abortController, setAbortController] = (0, import_react29.useState)(null);
|
|
5198
5556
|
const httpClient = useHttpClient();
|
|
5199
|
-
const intl = (0,
|
|
5557
|
+
const intl = (0, import_react_intl21.useIntl)();
|
|
5200
5558
|
const { schema } = persistAsync;
|
|
5201
5559
|
async function handlePersistAsync(model) {
|
|
5202
5560
|
const isInvalidSchema = model instanceof Blob ? !isBlobSchema(schema) : !isValidSchema(model, schema);
|
|
@@ -5273,7 +5631,7 @@ function hasStringMessage(value) {
|
|
|
5273
5631
|
}
|
|
5274
5632
|
|
|
5275
5633
|
// src/common/hooks/usePolling/usePolling.tsx
|
|
5276
|
-
var
|
|
5634
|
+
var import_react30 = require("react");
|
|
5277
5635
|
function usePolling({
|
|
5278
5636
|
asyncFn,
|
|
5279
5637
|
interval,
|
|
@@ -5282,9 +5640,9 @@ function usePolling({
|
|
|
5282
5640
|
onPollingResponse,
|
|
5283
5641
|
onFailure
|
|
5284
5642
|
}) {
|
|
5285
|
-
const onPollingResponseReference = (0,
|
|
5286
|
-
const onFailureReference = (0,
|
|
5287
|
-
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)(
|
|
5288
5646
|
() => createPollingClosure(
|
|
5289
5647
|
asyncFn,
|
|
5290
5648
|
maxAttempts,
|
|
@@ -5294,7 +5652,7 @@ function usePolling({
|
|
|
5294
5652
|
),
|
|
5295
5653
|
[asyncFn, maxAttempts, maxConsecutiveFails]
|
|
5296
5654
|
);
|
|
5297
|
-
(0,
|
|
5655
|
+
(0, import_react30.useEffect)(() => {
|
|
5298
5656
|
if (interval > 0) {
|
|
5299
5657
|
const intervalReference = setInterval(() => {
|
|
5300
5658
|
poll();
|
|
@@ -5302,7 +5660,7 @@ function usePolling({
|
|
|
5302
5660
|
return () => clearInterval(intervalReference);
|
|
5303
5661
|
}
|
|
5304
5662
|
}, [poll, interval]);
|
|
5305
|
-
(0,
|
|
5663
|
+
(0, import_react30.useEffect)(() => {
|
|
5306
5664
|
onPollingResponseReference.current = onPollingResponse;
|
|
5307
5665
|
onFailureReference.current = onFailure;
|
|
5308
5666
|
}, [onPollingResponse, onFailure]);
|
|
@@ -5331,20 +5689,20 @@ function createPollingClosure(asyncFn, maxAttempts, maxConsecutiveFails, onPolli
|
|
|
5331
5689
|
}
|
|
5332
5690
|
|
|
5333
5691
|
// src/common/hooks/usePrevious/usePrevious.js
|
|
5334
|
-
var
|
|
5692
|
+
var import_react31 = require("react");
|
|
5335
5693
|
var usePrevious = (value) => {
|
|
5336
|
-
const reference = (0,
|
|
5337
|
-
(0,
|
|
5694
|
+
const reference = (0, import_react31.useRef)();
|
|
5695
|
+
(0, import_react31.useEffect)(() => {
|
|
5338
5696
|
reference.current = value;
|
|
5339
5697
|
}, [value]);
|
|
5340
5698
|
return reference.current;
|
|
5341
5699
|
};
|
|
5342
5700
|
|
|
5343
5701
|
// src/common/hooks/useStepPolling/useStepPolling.tsx
|
|
5344
|
-
var
|
|
5702
|
+
var import_react32 = require("react");
|
|
5345
5703
|
function useStepPolling(polling, onAction) {
|
|
5346
5704
|
const httpClient = useHttpClient();
|
|
5347
|
-
const asyncFn = (0,
|
|
5705
|
+
const asyncFn = (0, import_react32.useMemo)(() => {
|
|
5348
5706
|
if (polling) {
|
|
5349
5707
|
return () => {
|
|
5350
5708
|
return httpClient(polling.url).then((response) => {
|
|
@@ -5359,7 +5717,7 @@ function useStepPolling(polling, onAction) {
|
|
|
5359
5717
|
return void 0;
|
|
5360
5718
|
}
|
|
5361
5719
|
}, [polling, httpClient]);
|
|
5362
|
-
const onPollingResponse = (0,
|
|
5720
|
+
const onPollingResponse = (0, import_react32.useCallback)(
|
|
5363
5721
|
(pollingResponse) => {
|
|
5364
5722
|
if (pollingResponse == null ? void 0 : pollingResponse.action) {
|
|
5365
5723
|
onAction(pollingResponse.action);
|
|
@@ -5375,7 +5733,7 @@ function useStepPolling(polling, onAction) {
|
|
|
5375
5733
|
maxAttempts: (polling == null ? void 0 : polling.maxAttempts) || 0,
|
|
5376
5734
|
maxConsecutiveFails: 1,
|
|
5377
5735
|
onPollingResponse,
|
|
5378
|
-
onFailure: (0,
|
|
5736
|
+
onFailure: (0, import_react32.useCallback)(() => {
|
|
5379
5737
|
if (polling) {
|
|
5380
5738
|
onAction(polling.onError.action);
|
|
5381
5739
|
}
|
|
@@ -5384,7 +5742,7 @@ function useStepPolling(polling, onAction) {
|
|
|
5384
5742
|
}
|
|
5385
5743
|
|
|
5386
5744
|
// src/step/layoutStep/LayoutStep.tsx
|
|
5387
|
-
var
|
|
5745
|
+
var import_jsx_runtime56 = require("react/jsx-runtime");
|
|
5388
5746
|
var getComponents = (step, options) => {
|
|
5389
5747
|
var _a;
|
|
5390
5748
|
if (isEmpty(step)) {
|
|
@@ -5407,7 +5765,7 @@ var LayoutStep = (props) => {
|
|
|
5407
5765
|
onEvent("Dynamic Flow - onAction supressed", { reason: "LayoutStep - loading state" });
|
|
5408
5766
|
};
|
|
5409
5767
|
useStepPolling(stepSpecification.polling, onAction);
|
|
5410
|
-
return /* @__PURE__ */ (0,
|
|
5768
|
+
return /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
5411
5769
|
DynamicLayout_default,
|
|
5412
5770
|
{
|
|
5413
5771
|
components,
|
|
@@ -5423,16 +5781,16 @@ var LayoutStep = (props) => {
|
|
|
5423
5781
|
var LayoutStep_default = LayoutStep;
|
|
5424
5782
|
|
|
5425
5783
|
// src/step/cameraStep/CameraStep.tsx
|
|
5426
|
-
var
|
|
5784
|
+
var import_react36 = require("react");
|
|
5427
5785
|
|
|
5428
5786
|
// src/step/cameraStep/cameraCapture/CameraCapture.tsx
|
|
5429
|
-
var
|
|
5430
|
-
var
|
|
5787
|
+
var import_react35 = require("react");
|
|
5788
|
+
var import_react_intl28 = require("react-intl");
|
|
5431
5789
|
var import_react_webcam = __toESM(require_react_webcam());
|
|
5432
5790
|
|
|
5433
5791
|
// src/step/cameraStep/cameraCapture/CameraCapture.messages.ts
|
|
5434
|
-
var
|
|
5435
|
-
var CameraCapture_messages_default = (0,
|
|
5792
|
+
var import_react_intl22 = require("react-intl");
|
|
5793
|
+
var CameraCapture_messages_default = (0, import_react_intl22.defineMessages)({
|
|
5436
5794
|
reviewSubmit: {
|
|
5437
5795
|
id: "dynamicFlows.CameraCapture.reviewSubmit",
|
|
5438
5796
|
defaultMessage: "Yes, submit",
|
|
@@ -5451,54 +5809,54 @@ var CameraCapture_messages_default = (0, import_react_intl19.defineMessages)({
|
|
|
5451
5809
|
});
|
|
5452
5810
|
|
|
5453
5811
|
// src/step/cameraStep/cameraCapture/components/index.tsx
|
|
5454
|
-
var
|
|
5455
|
-
var
|
|
5456
|
-
var
|
|
5457
|
-
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 }) });
|
|
5458
5816
|
var ReviewBottomBar = ({
|
|
5459
5817
|
onSubmit,
|
|
5460
5818
|
onRetry
|
|
5461
5819
|
}) => {
|
|
5462
|
-
const intl = (0,
|
|
5463
|
-
return /* @__PURE__ */ (0,
|
|
5464
|
-
/* @__PURE__ */ (0,
|
|
5465
|
-
|
|
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,
|
|
5466
5824
|
{
|
|
5467
5825
|
className: "m-b-1",
|
|
5468
5826
|
block: true,
|
|
5469
|
-
size:
|
|
5470
|
-
type:
|
|
5827
|
+
size: import_components27.Size.MEDIUM,
|
|
5828
|
+
type: import_components27.ControlType.ACCENT,
|
|
5471
5829
|
onClick: onSubmit,
|
|
5472
5830
|
children: intl.formatMessage(CameraCapture_messages_default.reviewSubmit)
|
|
5473
5831
|
}
|
|
5474
5832
|
),
|
|
5475
|
-
/* @__PURE__ */ (0,
|
|
5476
|
-
|
|
5833
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
|
|
5834
|
+
import_components27.Button,
|
|
5477
5835
|
{
|
|
5478
5836
|
className: "m-b-2",
|
|
5479
5837
|
block: true,
|
|
5480
|
-
size:
|
|
5481
|
-
type:
|
|
5482
|
-
priority:
|
|
5838
|
+
size: import_components27.Size.MEDIUM,
|
|
5839
|
+
type: import_components27.ControlType.ACCENT,
|
|
5840
|
+
priority: import_components27.Priority.SECONDARY,
|
|
5483
5841
|
onClick: onRetry,
|
|
5484
5842
|
children: intl.formatMessage(CameraCapture_messages_default.reviewRetry)
|
|
5485
5843
|
}
|
|
5486
5844
|
)
|
|
5487
5845
|
] }) }) });
|
|
5488
5846
|
};
|
|
5489
|
-
var CaptureButton = ({ onClick }) => /* @__PURE__ */ (0,
|
|
5847
|
+
var CaptureButton = ({ onClick }) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
|
|
5490
5848
|
"button",
|
|
5491
5849
|
{
|
|
5492
5850
|
type: "button",
|
|
5493
5851
|
className: "camera-capture-btn m-b-2",
|
|
5494
5852
|
"data-testid": "camera-capture-button",
|
|
5495
5853
|
onClick,
|
|
5496
|
-
children: /* @__PURE__ */ (0,
|
|
5854
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("span", { className: "camera-capture-btn-inner" })
|
|
5497
5855
|
}
|
|
5498
5856
|
);
|
|
5499
5857
|
|
|
5500
5858
|
// src/step/cameraStep/cameraCapture/hooks/index.ts
|
|
5501
|
-
var
|
|
5859
|
+
var import_react33 = require("react");
|
|
5502
5860
|
|
|
5503
5861
|
// src/step/cameraStep/cameraCapture/utils/index.ts
|
|
5504
5862
|
var isSelfieCamera = (stream) => {
|
|
@@ -5546,7 +5904,7 @@ var getVideoCapabilities = (videoStream) => {
|
|
|
5546
5904
|
|
|
5547
5905
|
// src/step/cameraStep/cameraCapture/hooks/index.ts
|
|
5548
5906
|
var useVideoConstraints = (direction) => {
|
|
5549
|
-
const [videoConstraints, setVideoConstraints] = (0,
|
|
5907
|
+
const [videoConstraints, setVideoConstraints] = (0, import_react33.useState)();
|
|
5550
5908
|
const defaultVideoConstraints = {
|
|
5551
5909
|
facingMode: direction === "front" ? "user" : "environment",
|
|
5552
5910
|
height: { min: 480, max: 1080, ideal: 720 },
|
|
@@ -5554,7 +5912,7 @@ var useVideoConstraints = (direction) => {
|
|
|
5554
5912
|
frameRate: 30,
|
|
5555
5913
|
aspectRatio: 16 / 9
|
|
5556
5914
|
};
|
|
5557
|
-
(0,
|
|
5915
|
+
(0, import_react33.useEffect)(() => {
|
|
5558
5916
|
void getVideoConstraints(direction).then(setVideoConstraints);
|
|
5559
5917
|
}, [direction]);
|
|
5560
5918
|
const getVideoConstraints = async (direction2) => {
|
|
@@ -5572,8 +5930,8 @@ var useVideoConstraints = (direction) => {
|
|
|
5572
5930
|
};
|
|
5573
5931
|
|
|
5574
5932
|
// src/step/cameraStep/cameraCapture/overlay/Overlay.tsx
|
|
5575
|
-
var
|
|
5576
|
-
var
|
|
5933
|
+
var import_react34 = require("react");
|
|
5934
|
+
var import_jsx_runtime58 = require("react/jsx-runtime");
|
|
5577
5935
|
var captureButtonHeight = 92;
|
|
5578
5936
|
var reviewButtonsHeight = 120;
|
|
5579
5937
|
var imageHeight = 40;
|
|
@@ -5589,8 +5947,8 @@ var Overlay = ({
|
|
|
5589
5947
|
instructions,
|
|
5590
5948
|
reviewInstructions
|
|
5591
5949
|
}) => {
|
|
5592
|
-
const svgReference = (0,
|
|
5593
|
-
(0,
|
|
5950
|
+
const svgReference = (0, import_react34.useRef)(null);
|
|
5951
|
+
(0, import_react34.useEffect)(() => {
|
|
5594
5952
|
const listener = debounce(() => {
|
|
5595
5953
|
var _a;
|
|
5596
5954
|
if ((_a = svgReference.current) == null ? void 0 : _a.innerHTML) {
|
|
@@ -5602,18 +5960,18 @@ var Overlay = ({
|
|
|
5602
5960
|
return () => window.removeEventListener("resize", listener);
|
|
5603
5961
|
});
|
|
5604
5962
|
let helperBoxHeight = (imageUrl ? imageHeight : 0) + (title ? titleHeight : 0) + (instructions ? instructionsHeight : 0);
|
|
5605
|
-
let helperBox = /* @__PURE__ */ (0,
|
|
5606
|
-
imageUrl && /* @__PURE__ */ (0,
|
|
5607
|
-
title && /* @__PURE__ */ (0,
|
|
5608
|
-
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 })
|
|
5609
5967
|
] });
|
|
5610
5968
|
const frameBottomMargin = captureButtonHeight + helperBoxHeight;
|
|
5611
5969
|
if (reviewInstructions) {
|
|
5612
5970
|
helperBoxHeight = frameBottomMargin - reviewButtonsHeight;
|
|
5613
|
-
helperBox = /* @__PURE__ */ (0,
|
|
5971
|
+
helperBox = /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("small", { className: "camera-capture-instructions", children: reviewInstructions });
|
|
5614
5972
|
const frameWithReviewInstructionsMinBottomMargin = reviewButtonsHeight + reviewInstructionsHeight;
|
|
5615
5973
|
if (frameBottomMargin < frameWithReviewInstructionsMinBottomMargin) {
|
|
5616
|
-
helperBox = /* @__PURE__ */ (0,
|
|
5974
|
+
helperBox = /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_jsx_runtime58.Fragment, {});
|
|
5617
5975
|
}
|
|
5618
5976
|
}
|
|
5619
5977
|
const framePosition = {
|
|
@@ -5631,25 +5989,25 @@ var Overlay = ({
|
|
|
5631
5989
|
width: "90%"
|
|
5632
5990
|
}
|
|
5633
5991
|
};
|
|
5634
|
-
return /* @__PURE__ */ (0,
|
|
5635
|
-
/* @__PURE__ */ (0,
|
|
5636
|
-
/* @__PURE__ */ (0,
|
|
5637
|
-
/* @__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))
|
|
5638
5996
|
] }) }),
|
|
5639
|
-
overlay && /* @__PURE__ */ (0,
|
|
5640
|
-
outline && /* @__PURE__ */ (0,
|
|
5641
|
-
/* @__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 })) })
|
|
5642
6000
|
] });
|
|
5643
6001
|
};
|
|
5644
6002
|
var Overlay_default = Overlay;
|
|
5645
6003
|
|
|
5646
6004
|
// src/step/cameraStep/cameraCapture/screens/NoCameraAccess/NoCameraAccess.tsx
|
|
5647
|
-
var
|
|
5648
|
-
var
|
|
6005
|
+
var import_components28 = require("@transferwise/components");
|
|
6006
|
+
var import_react_intl25 = require("react-intl");
|
|
5649
6007
|
|
|
5650
6008
|
// src/step/cameraStep/cameraCapture/screens/NoCameraAccess/NoCameraAccess.messages.ts
|
|
5651
|
-
var
|
|
5652
|
-
var NoCameraAccess_messages_default = (0,
|
|
6009
|
+
var import_react_intl24 = require("react-intl");
|
|
6010
|
+
var NoCameraAccess_messages_default = (0, import_react_intl24.defineMessages)({
|
|
5653
6011
|
title: {
|
|
5654
6012
|
id: "dynamicFlows.CameraCapture.NoCameraAccess.title",
|
|
5655
6013
|
defaultMessage: "We can't access your camera",
|
|
@@ -5668,23 +6026,23 @@ var NoCameraAccess_messages_default = (0, import_react_intl21.defineMessages)({
|
|
|
5668
6026
|
});
|
|
5669
6027
|
|
|
5670
6028
|
// src/step/cameraStep/cameraCapture/screens/NoCameraAccess/NoCameraAccess.tsx
|
|
5671
|
-
var
|
|
6029
|
+
var import_jsx_runtime59 = require("react/jsx-runtime");
|
|
5672
6030
|
var NoCameraAccess = ({ onAction }) => {
|
|
5673
|
-
const intl = (0,
|
|
5674
|
-
return /* @__PURE__ */ (0,
|
|
5675
|
-
/* @__PURE__ */ (0,
|
|
5676
|
-
/* @__PURE__ */ (0,
|
|
5677
|
-
/* @__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) })
|
|
5678
6036
|
] }) }) }) });
|
|
5679
6037
|
};
|
|
5680
6038
|
var NoCameraAccess_default = NoCameraAccess;
|
|
5681
6039
|
|
|
5682
6040
|
// src/step/cameraStep/cameraCapture/screens/CameraNotSupported/CameraNotSupported.tsx
|
|
5683
|
-
var
|
|
6041
|
+
var import_react_intl27 = require("react-intl");
|
|
5684
6042
|
|
|
5685
6043
|
// src/step/cameraStep/cameraCapture/screens/CameraNotSupported/CameraNotSupported.messages.ts
|
|
5686
|
-
var
|
|
5687
|
-
var CameraNotSupported_messages_default = (0,
|
|
6044
|
+
var import_react_intl26 = require("react-intl");
|
|
6045
|
+
var CameraNotSupported_messages_default = (0, import_react_intl26.defineMessages)({
|
|
5688
6046
|
title: {
|
|
5689
6047
|
id: "dynamicFlows.CameraCapture.CameraNotSupported.title",
|
|
5690
6048
|
defaultMessage: "Camera not supported",
|
|
@@ -5698,12 +6056,12 @@ var CameraNotSupported_messages_default = (0, import_react_intl23.defineMessages
|
|
|
5698
6056
|
});
|
|
5699
6057
|
|
|
5700
6058
|
// src/step/cameraStep/cameraCapture/screens/CameraNotSupported/CameraNotSupported.tsx
|
|
5701
|
-
var
|
|
6059
|
+
var import_jsx_runtime60 = require("react/jsx-runtime");
|
|
5702
6060
|
var CameraNotSupported = () => {
|
|
5703
|
-
const intl = (0,
|
|
5704
|
-
return /* @__PURE__ */ (0,
|
|
5705
|
-
/* @__PURE__ */ (0,
|
|
5706
|
-
/* @__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) })
|
|
5707
6065
|
] }) }) }) });
|
|
5708
6066
|
};
|
|
5709
6067
|
var CameraNotSupported_default = CameraNotSupported;
|
|
@@ -5728,7 +6086,7 @@ var getCameraStartedProperties = async (props, videoStream) => {
|
|
|
5728
6086
|
};
|
|
5729
6087
|
|
|
5730
6088
|
// src/step/cameraStep/cameraCapture/CameraCapture.tsx
|
|
5731
|
-
var
|
|
6089
|
+
var import_jsx_runtime61 = require("react/jsx-runtime");
|
|
5732
6090
|
var CameraCapture = ({
|
|
5733
6091
|
direction = "back",
|
|
5734
6092
|
overlay = "",
|
|
@@ -5740,14 +6098,14 @@ var CameraCapture = ({
|
|
|
5740
6098
|
onCapture,
|
|
5741
6099
|
onEvent
|
|
5742
6100
|
}) => {
|
|
5743
|
-
const [mode, setMode] = (0,
|
|
5744
|
-
const [isVideoMirrored, setIsVideoMirrored] = (0,
|
|
5745
|
-
const [ready, setReady] = (0,
|
|
5746
|
-
const [reviewImage, setReviewImage] = (0,
|
|
5747
|
-
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);
|
|
5748
6106
|
const { videoConstraints } = useVideoConstraints(direction);
|
|
5749
|
-
const intl = (0,
|
|
5750
|
-
const handleCapture = (0,
|
|
6107
|
+
const intl = (0, import_react_intl28.useIntl)();
|
|
6108
|
+
const handleCapture = (0, import_react35.useCallback)(async () => {
|
|
5751
6109
|
var _a, _b, _c, _d, _e, _f;
|
|
5752
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) {
|
|
5753
6111
|
(_e = (_d = webcamReference == null ? void 0 : webcamReference.current) == null ? void 0 : _d.video) == null ? void 0 : _e.pause();
|
|
@@ -5769,7 +6127,7 @@ var CameraCapture = ({
|
|
|
5769
6127
|
);
|
|
5770
6128
|
}
|
|
5771
6129
|
}, [webcamReference, showReview, setReviewImage, setMode, onCapture, isVideoMirrored]);
|
|
5772
|
-
const handleUserMediaError = (0,
|
|
6130
|
+
const handleUserMediaError = (0, import_react35.useCallback)(
|
|
5773
6131
|
(error) => {
|
|
5774
6132
|
if (error instanceof DOMException && (error == null ? void 0 : error.name) === "NotAllowedError") {
|
|
5775
6133
|
setMode("NO_CAMERA_ACCESS");
|
|
@@ -5781,7 +6139,7 @@ var CameraCapture = ({
|
|
|
5781
6139
|
},
|
|
5782
6140
|
[setMode, onEvent]
|
|
5783
6141
|
);
|
|
5784
|
-
const handleUserMedia = (0,
|
|
6142
|
+
const handleUserMedia = (0, import_react35.useCallback)(
|
|
5785
6143
|
(stream) => {
|
|
5786
6144
|
setReady(true);
|
|
5787
6145
|
setIsVideoMirrored(isSelfieCamera(stream));
|
|
@@ -5797,8 +6155,8 @@ var CameraCapture = ({
|
|
|
5797
6155
|
setReviewImage(void 0);
|
|
5798
6156
|
};
|
|
5799
6157
|
const handleRetryCameraAccess = () => setMode("CAPTURE");
|
|
5800
|
-
const captureScreen = /* @__PURE__ */ (0,
|
|
5801
|
-
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)(
|
|
5802
6160
|
import_react_webcam.default,
|
|
5803
6161
|
{
|
|
5804
6162
|
ref: webcamReference,
|
|
@@ -5809,7 +6167,7 @@ var CameraCapture = ({
|
|
|
5809
6167
|
onUserMedia: handleUserMedia
|
|
5810
6168
|
}
|
|
5811
6169
|
),
|
|
5812
|
-
/* @__PURE__ */ (0,
|
|
6170
|
+
/* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
|
|
5813
6171
|
Overlay_default,
|
|
5814
6172
|
{
|
|
5815
6173
|
overlay,
|
|
@@ -5819,11 +6177,11 @@ var CameraCapture = ({
|
|
|
5819
6177
|
instructions
|
|
5820
6178
|
}
|
|
5821
6179
|
),
|
|
5822
|
-
ready && /* @__PURE__ */ (0,
|
|
6180
|
+
ready && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(CaptureBottomBar, { onCapture: () => void handleCapture() })
|
|
5823
6181
|
] });
|
|
5824
|
-
const reviewScreen = /* @__PURE__ */ (0,
|
|
5825
|
-
/* @__PURE__ */ (0,
|
|
5826
|
-
/* @__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)(
|
|
5827
6185
|
Overlay_default,
|
|
5828
6186
|
{
|
|
5829
6187
|
overlay,
|
|
@@ -5833,19 +6191,19 @@ var CameraCapture = ({
|
|
|
5833
6191
|
reviewInstructions: intl.formatMessage(CameraCapture_messages_default.reviewInstructions)
|
|
5834
6192
|
}
|
|
5835
6193
|
),
|
|
5836
|
-
/* @__PURE__ */ (0,
|
|
6194
|
+
/* @__PURE__ */ (0, import_jsx_runtime61.jsx)(ReviewBottomBar, { onSubmit: handleReviewSubmit, onRetry: handleReviewRetry })
|
|
5837
6195
|
] });
|
|
5838
|
-
return /* @__PURE__ */ (0,
|
|
6196
|
+
return /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)("section", { className: "camera-capture", children: [
|
|
5839
6197
|
mode === "CAPTURE" && captureScreen,
|
|
5840
6198
|
mode === "REVIEW" && reviewScreen,
|
|
5841
|
-
mode === "NO_CAMERA_ACCESS" && /* @__PURE__ */ (0,
|
|
5842
|
-
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, {})
|
|
5843
6201
|
] });
|
|
5844
6202
|
};
|
|
5845
6203
|
var CameraCapture_default = CameraCapture;
|
|
5846
6204
|
|
|
5847
6205
|
// src/step/cameraStep/CameraStep.tsx
|
|
5848
|
-
var
|
|
6206
|
+
var import_jsx_runtime62 = require("react/jsx-runtime");
|
|
5849
6207
|
function blobToBase64(blob) {
|
|
5850
6208
|
return new Promise((resolve, _) => {
|
|
5851
6209
|
const reader = new FileReader();
|
|
@@ -5863,8 +6221,8 @@ var CameraStep = (props) => {
|
|
|
5863
6221
|
const { assets, direction, instructions } = cameraConfig || {};
|
|
5864
6222
|
const { overlay, outline } = assets || {};
|
|
5865
6223
|
const { url: imageUrl } = image || {};
|
|
5866
|
-
const [captureClicked, setCaptureClicked] = (0,
|
|
5867
|
-
(0,
|
|
6224
|
+
const [captureClicked, setCaptureClicked] = (0, import_react36.useState)(false);
|
|
6225
|
+
(0, import_react36.useEffect)(() => {
|
|
5868
6226
|
if (captureClicked) {
|
|
5869
6227
|
onAction(action);
|
|
5870
6228
|
}
|
|
@@ -5883,7 +6241,7 @@ var CameraStep = (props) => {
|
|
|
5883
6241
|
});
|
|
5884
6242
|
}
|
|
5885
6243
|
};
|
|
5886
|
-
return /* @__PURE__ */ (0,
|
|
6244
|
+
return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
|
|
5887
6245
|
CameraCapture_default,
|
|
5888
6246
|
{
|
|
5889
6247
|
overlay,
|
|
@@ -5932,11 +6290,11 @@ function getFirstAction(step) {
|
|
|
5932
6290
|
}
|
|
5933
6291
|
|
|
5934
6292
|
// src/step/externalConfirmationStep/ExternalConfirmationStep.tsx
|
|
5935
|
-
var
|
|
6293
|
+
var import_react_intl30 = require("react-intl");
|
|
5936
6294
|
|
|
5937
6295
|
// src/step/externalConfirmationStep/ExternalConfirmationStep.messages.ts
|
|
5938
|
-
var
|
|
5939
|
-
var ExternalConfirmationStep_messages_default = (0,
|
|
6296
|
+
var import_react_intl29 = require("react-intl");
|
|
6297
|
+
var ExternalConfirmationStep_messages_default = (0, import_react_intl29.defineMessages)({
|
|
5940
6298
|
title: {
|
|
5941
6299
|
id: "dynamicFlows.ExternalConfirmation.title",
|
|
5942
6300
|
defaultMessage: "Please confirm",
|
|
@@ -5960,12 +6318,12 @@ var ExternalConfirmationStep_messages_default = (0, import_react_intl26.defineMe
|
|
|
5960
6318
|
});
|
|
5961
6319
|
|
|
5962
6320
|
// src/step/externalConfirmationStep/ExternalConfirmationStep.tsx
|
|
5963
|
-
var
|
|
6321
|
+
var import_jsx_runtime63 = require("react/jsx-runtime");
|
|
5964
6322
|
var noop5 = () => {
|
|
5965
6323
|
};
|
|
5966
6324
|
var ExternalConfirmationStep = ({ url, onClose }) => {
|
|
5967
|
-
const { formatMessage } = (0,
|
|
5968
|
-
return /* @__PURE__ */ (0,
|
|
6325
|
+
const { formatMessage } = (0, import_react_intl30.useIntl)();
|
|
6326
|
+
return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
|
|
5969
6327
|
DynamicLayout_default,
|
|
5970
6328
|
{
|
|
5971
6329
|
components: [
|
|
@@ -6030,11 +6388,11 @@ function getOrigin(url) {
|
|
|
6030
6388
|
}
|
|
6031
6389
|
|
|
6032
6390
|
// src/dynamicFlow/BackButton.tsx
|
|
6033
|
-
var
|
|
6034
|
-
var
|
|
6035
|
-
var
|
|
6391
|
+
var import_components30 = require("@transferwise/components");
|
|
6392
|
+
var import_icons2 = require("@transferwise/icons");
|
|
6393
|
+
var import_jsx_runtime64 = require("react/jsx-runtime");
|
|
6036
6394
|
var BackButton = ({ title, action, onAction }) => {
|
|
6037
|
-
return /* @__PURE__ */ (0,
|
|
6395
|
+
return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(
|
|
6038
6396
|
"a",
|
|
6039
6397
|
{
|
|
6040
6398
|
onClick: (event) => {
|
|
@@ -6045,8 +6403,8 @@ var BackButton = ({ title, action, onAction }) => {
|
|
|
6045
6403
|
className: "df-back-btn",
|
|
6046
6404
|
"aria-label": title,
|
|
6047
6405
|
children: [
|
|
6048
|
-
/* @__PURE__ */ (0,
|
|
6049
|
-
/* @__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" }) })
|
|
6050
6408
|
]
|
|
6051
6409
|
}
|
|
6052
6410
|
);
|
|
@@ -6054,7 +6412,7 @@ var BackButton = ({ title, action, onAction }) => {
|
|
|
6054
6412
|
var BackButton_default = BackButton;
|
|
6055
6413
|
|
|
6056
6414
|
// src/dynamicFlow/DynamicFlowStep.tsx
|
|
6057
|
-
var
|
|
6415
|
+
var import_jsx_runtime65 = require("react/jsx-runtime");
|
|
6058
6416
|
var DynamicFlowStep = (props) => {
|
|
6059
6417
|
var _a, _b;
|
|
6060
6418
|
const { step, globalError, onAction } = props;
|
|
@@ -6065,23 +6423,23 @@ var DynamicFlowStep = (props) => {
|
|
|
6065
6423
|
return null;
|
|
6066
6424
|
}
|
|
6067
6425
|
if (externalUrl && requiresManualTrigger) {
|
|
6068
|
-
return /* @__PURE__ */ (0,
|
|
6426
|
+
return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(ExternalConfirmationStep_default, { url: externalUrl, onClose: dismissConfirmation });
|
|
6069
6427
|
}
|
|
6070
6428
|
if (isCameraStep(step)) {
|
|
6071
|
-
return /* @__PURE__ */ (0,
|
|
6429
|
+
return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(CameraStep_default, __spreadProps(__spreadValues({}, props), { step }));
|
|
6072
6430
|
}
|
|
6073
|
-
return /* @__PURE__ */ (0,
|
|
6074
|
-
backButton && /* @__PURE__ */ (0,
|
|
6075
|
-
globalError ? /* @__PURE__ */ (0,
|
|
6076
|
-
/* @__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 }))
|
|
6077
6435
|
] });
|
|
6078
6436
|
};
|
|
6079
6437
|
|
|
6080
6438
|
// src/dynamicFlow/utils/useDebouncedRefresh/useDebouncedRefresh.ts
|
|
6081
|
-
var
|
|
6439
|
+
var import_react37 = require("react");
|
|
6082
6440
|
var DEBOUNCE_DELAY = 1e3;
|
|
6083
6441
|
function useDebouncedRefresh(fetchRefresh) {
|
|
6084
|
-
const map = (0,
|
|
6442
|
+
const map = (0, import_react37.useRef)(/* @__PURE__ */ new Map());
|
|
6085
6443
|
const retrieveOrCreate = (key) => {
|
|
6086
6444
|
if (map.current.has(key)) {
|
|
6087
6445
|
return map.current.get(key);
|
|
@@ -6104,12 +6462,12 @@ function useDebouncedRefresh(fetchRefresh) {
|
|
|
6104
6462
|
var shouldDebounceSchema = (schema) => getSchemaType(schema) === "basic" && schema.type !== "boolean" && schema.format !== "base64url";
|
|
6105
6463
|
|
|
6106
6464
|
// src/dynamicFlow/utils/useDynamicFlowState.ts
|
|
6107
|
-
var
|
|
6465
|
+
var import_react38 = require("react");
|
|
6108
6466
|
var useDynamicFlowState = (initialStep) => {
|
|
6109
6467
|
var _a, _b;
|
|
6110
|
-
const [formErrors, setFormErrors] = (0,
|
|
6111
|
-
const [globalError, setGlobalError] = (0,
|
|
6112
|
-
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)({
|
|
6113
6471
|
step: initialStep || void 0,
|
|
6114
6472
|
models: (initialStep == null ? void 0 : initialStep.model) ? buildInitialModels(initialStep.model, getAllSchemas(initialStep)) : {},
|
|
6115
6473
|
etag: void 0
|
|
@@ -6139,7 +6497,10 @@ var useDynamicFlowState = (initialStep) => {
|
|
|
6139
6497
|
return updatedState;
|
|
6140
6498
|
});
|
|
6141
6499
|
};
|
|
6142
|
-
const modelIsValid = (0,
|
|
6500
|
+
const modelIsValid = (0, import_react38.useMemo)(
|
|
6501
|
+
() => areModelsValid(models, getAllValidatableSchemas(step)),
|
|
6502
|
+
[models, step]
|
|
6503
|
+
);
|
|
6143
6504
|
return {
|
|
6144
6505
|
formErrors,
|
|
6145
6506
|
globalError,
|
|
@@ -6179,6 +6540,22 @@ var getAllSchemasInLayout = (components) => components.flatMap((component) => {
|
|
|
6179
6540
|
return [];
|
|
6180
6541
|
}
|
|
6181
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);
|
|
6182
6559
|
var areModelsValid = (formModels, schemas = []) => {
|
|
6183
6560
|
return !(schemas == null ? void 0 : schemas.some((schema) => {
|
|
6184
6561
|
if (!schema.$id) {
|
|
@@ -6187,24 +6564,30 @@ var areModelsValid = (formModels, schemas = []) => {
|
|
|
6187
6564
|
return !isValidSchema(formModels[schema.$id || ""] || {}, schema);
|
|
6188
6565
|
}));
|
|
6189
6566
|
};
|
|
6567
|
+
var getSchemaReference = (component) => {
|
|
6568
|
+
if (component.schema && !isInlineSchema(component.schema)) {
|
|
6569
|
+
return component.schema.$ref;
|
|
6570
|
+
}
|
|
6571
|
+
return component.schemaId;
|
|
6572
|
+
};
|
|
6190
6573
|
var isInlineSchema = (schema) => {
|
|
6191
6574
|
return schema !== void 0 && typeof schema === "object" && Object.prototype.hasOwnProperty.call(schema, "$ref") === false;
|
|
6192
6575
|
};
|
|
6193
6576
|
|
|
6194
6577
|
// src/dynamicFlow/utils/useLoader.tsx
|
|
6195
|
-
var
|
|
6196
|
-
var
|
|
6197
|
-
var
|
|
6578
|
+
var import_components31 = require("@transferwise/components");
|
|
6579
|
+
var import_react39 = require("react");
|
|
6580
|
+
var import_jsx_runtime66 = require("react/jsx-runtime");
|
|
6198
6581
|
function useLoader(loaderConfig, initialState) {
|
|
6199
6582
|
const config = __spreadValues({
|
|
6200
|
-
size:
|
|
6583
|
+
size: import_components31.Size.EXTRA_LARGE,
|
|
6201
6584
|
initial: true,
|
|
6202
6585
|
submission: false
|
|
6203
6586
|
}, loaderConfig);
|
|
6204
|
-
const [loadingState, setLoadingState] = (0,
|
|
6587
|
+
const [loadingState, setLoadingState] = (0, import_react39.useState)(initialState);
|
|
6205
6588
|
const shouldDisplayLoader = config.initial && loadingState === "initial" || config.submission && loadingState === "submission";
|
|
6206
|
-
const loader = shouldDisplayLoader ? /* @__PURE__ */ (0,
|
|
6207
|
-
|
|
6589
|
+
const loader = shouldDisplayLoader ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
|
|
6590
|
+
import_components31.Loader,
|
|
6208
6591
|
{
|
|
6209
6592
|
size: config.size,
|
|
6210
6593
|
classNames: { "tw-loader": "tw-loader m-x-auto" },
|
|
@@ -6215,23 +6598,23 @@ function useLoader(loaderConfig, initialState) {
|
|
|
6215
6598
|
}
|
|
6216
6599
|
|
|
6217
6600
|
// src/dynamicFlow/utils/errorBoundary/ErrorBoundary.tsx
|
|
6218
|
-
var
|
|
6601
|
+
var import_react40 = require("react");
|
|
6219
6602
|
|
|
6220
6603
|
// src/dynamicFlow/utils/errorBoundary/ErrorBoundaryAlert.tsx
|
|
6221
|
-
var
|
|
6222
|
-
var
|
|
6223
|
-
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");
|
|
6224
6607
|
var ErrorBoundaryAlert = ({ onDismiss }) => {
|
|
6225
|
-
const { formatMessage } = (0,
|
|
6226
|
-
return /* @__PURE__ */ (0,
|
|
6227
|
-
|
|
6608
|
+
const { formatMessage } = (0, import_react_intl31.useIntl)();
|
|
6609
|
+
return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
6610
|
+
import_components32.Alert,
|
|
6228
6611
|
{
|
|
6229
6612
|
action: {
|
|
6230
6613
|
text: formatMessage(ErrorBoundary_messages_default.retry),
|
|
6231
6614
|
href: window.location.href
|
|
6232
6615
|
},
|
|
6233
6616
|
message: formatMessage(ErrorBoundary_messages_default.errorAlert),
|
|
6234
|
-
type:
|
|
6617
|
+
type: import_components32.Sentiment.NEGATIVE,
|
|
6235
6618
|
className: "m-b-3",
|
|
6236
6619
|
onDismiss
|
|
6237
6620
|
}
|
|
@@ -6239,10 +6622,10 @@ var ErrorBoundaryAlert = ({ onDismiss }) => {
|
|
|
6239
6622
|
};
|
|
6240
6623
|
|
|
6241
6624
|
// src/dynamicFlow/utils/errorBoundary/ErrorBoundary.tsx
|
|
6242
|
-
var
|
|
6625
|
+
var import_jsx_runtime68 = require("react/jsx-runtime");
|
|
6243
6626
|
var noop6 = () => {
|
|
6244
6627
|
};
|
|
6245
|
-
var ErrorBoundary = class extends
|
|
6628
|
+
var ErrorBoundary = class extends import_react40.Component {
|
|
6246
6629
|
constructor(props) {
|
|
6247
6630
|
super(props);
|
|
6248
6631
|
this.handleErrorReset = () => {
|
|
@@ -6260,8 +6643,8 @@ var ErrorBoundary = class extends import_react39.Component {
|
|
|
6260
6643
|
render() {
|
|
6261
6644
|
const { children } = this.props;
|
|
6262
6645
|
const { hasError, isFatalError } = this.state;
|
|
6263
|
-
return /* @__PURE__ */ (0,
|
|
6264
|
-
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 }),
|
|
6265
6648
|
!isFatalError && children
|
|
6266
6649
|
] });
|
|
6267
6650
|
}
|
|
@@ -6362,7 +6745,7 @@ var assertResponseIsValid = (response) => {
|
|
|
6362
6745
|
var isResponse = (response) => typeof response === "object" && response !== null && "clone" in response && "bodyUsed" in response;
|
|
6363
6746
|
|
|
6364
6747
|
// src/dynamicFlow/DynamicFlow.tsx
|
|
6365
|
-
var
|
|
6748
|
+
var import_jsx_runtime69 = require("react/jsx-runtime");
|
|
6366
6749
|
var noop7 = () => {
|
|
6367
6750
|
};
|
|
6368
6751
|
var DynamicFlowComponent = ({
|
|
@@ -6377,7 +6760,7 @@ var DynamicFlowComponent = ({
|
|
|
6377
6760
|
onEvent = noop7,
|
|
6378
6761
|
onLog = noop7
|
|
6379
6762
|
}) => {
|
|
6380
|
-
const { locale } = (0,
|
|
6763
|
+
const { locale } = (0, import_react_intl32.useIntl)();
|
|
6381
6764
|
const {
|
|
6382
6765
|
formErrors,
|
|
6383
6766
|
globalError,
|
|
@@ -6390,24 +6773,24 @@ var DynamicFlowComponent = ({
|
|
|
6390
6773
|
setStepAndEtag,
|
|
6391
6774
|
setSchemaModel
|
|
6392
6775
|
} = useDynamicFlowState(initialStep);
|
|
6393
|
-
const [submitted, setSubmitted] = (0,
|
|
6776
|
+
const [submitted, setSubmitted] = (0, import_react41.useState)(false);
|
|
6394
6777
|
const { isLoading, loader, setLoadingState } = useLoader(
|
|
6395
6778
|
loaderConfig,
|
|
6396
6779
|
initialStep ? "idle" : "initial"
|
|
6397
6780
|
);
|
|
6398
6781
|
const logCritical = getLogger("critical", onLog, flowId, (step == null ? void 0 : step.id) || (step == null ? void 0 : step.key));
|
|
6399
|
-
const analyticsMetadata = (0,
|
|
6782
|
+
const analyticsMetadata = (0, import_react41.useMemo)(
|
|
6400
6783
|
() => {
|
|
6401
6784
|
var _a;
|
|
6402
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 : {});
|
|
6403
6786
|
},
|
|
6404
6787
|
[flowId, step]
|
|
6405
6788
|
);
|
|
6406
|
-
const dispatchEvent = (0,
|
|
6789
|
+
const dispatchEvent = (0, import_react41.useMemo)(
|
|
6407
6790
|
() => getEventDispatcher(onEvent, analyticsMetadata),
|
|
6408
6791
|
[onEvent, analyticsMetadata]
|
|
6409
6792
|
);
|
|
6410
|
-
const dfHttpClient = (0,
|
|
6793
|
+
const dfHttpClient = (0, import_react41.useCallback)(
|
|
6411
6794
|
({ action, data, etag: etag2 }) => {
|
|
6412
6795
|
const { url, method = "POST" } = action;
|
|
6413
6796
|
return httpClient(url != null ? url : "", {
|
|
@@ -6457,17 +6840,17 @@ var DynamicFlowComponent = ({
|
|
|
6457
6840
|
dispatchEventAndComplete(__spreadValues(__spreadValues({}, exitResult), actionResult));
|
|
6458
6841
|
};
|
|
6459
6842
|
const debouncedRefresh = useDebouncedRefresh(performRefresh);
|
|
6460
|
-
const dispatchEventAndComplete = (0,
|
|
6843
|
+
const dispatchEventAndComplete = (0, import_react41.useCallback)(
|
|
6461
6844
|
(result) => {
|
|
6462
6845
|
dispatchEvent("Dynamic Flow - Flow Finished", { result: "success" });
|
|
6463
6846
|
onCompletion(result);
|
|
6464
6847
|
},
|
|
6465
6848
|
[onCompletion, dispatchEvent]
|
|
6466
6849
|
);
|
|
6467
|
-
(0,
|
|
6850
|
+
(0, import_react41.useEffect)(() => {
|
|
6468
6851
|
dispatchEvent("Dynamic Flow - Flow Started", {});
|
|
6469
6852
|
}, []);
|
|
6470
|
-
(0,
|
|
6853
|
+
(0, import_react41.useEffect)(() => {
|
|
6471
6854
|
if (!initialStep) {
|
|
6472
6855
|
const action = __spreadValues({
|
|
6473
6856
|
id: "#initial-step-request",
|
|
@@ -6582,7 +6965,7 @@ var DynamicFlowComponent = ({
|
|
|
6582
6965
|
await actionHandler(action);
|
|
6583
6966
|
}
|
|
6584
6967
|
};
|
|
6585
|
-
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)(
|
|
6586
6969
|
DynamicFlowStep,
|
|
6587
6970
|
{
|
|
6588
6971
|
step,
|
|
@@ -6598,7 +6981,7 @@ var DynamicFlowComponent = ({
|
|
|
6598
6981
|
}
|
|
6599
6982
|
) }) }) }) });
|
|
6600
6983
|
};
|
|
6601
|
-
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)) });
|
|
6602
6985
|
var DynamicFlow_default = DynamicFlow;
|
|
6603
6986
|
var combineModels2 = (formModels) => {
|
|
6604
6987
|
return Object.values(formModels).reduce((previous, model) => __spreadValues(__spreadValues({}, previous), model), {});
|
|
@@ -6657,8 +7040,12 @@ var de_default = {
|
|
|
6657
7040
|
|
|
6658
7041
|
// src/i18n/en.json
|
|
6659
7042
|
var en_default = {
|
|
7043
|
+
"dynamicFlows.ArraySchema.addItem": "Save",
|
|
7044
|
+
"dynamicFlows.ArraySchema.addItemTitle": "Add Item",
|
|
7045
|
+
"dynamicFlows.ArraySchema.editItem": "Save",
|
|
6660
7046
|
"dynamicFlows.ArraySchema.maxItemsError": "Please add {maxItems} or fewer.",
|
|
6661
7047
|
"dynamicFlows.ArraySchema.minItemsError": "Please add at least {minItems}.",
|
|
7048
|
+
"dynamicFlows.ArraySchema.removeItem": "Remove",
|
|
6662
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.",
|
|
6663
7050
|
"dynamicFlows.CameraCapture.CameraNotSupported.title": "Camera not supported",
|
|
6664
7051
|
"dynamicFlows.CameraCapture.NoCameraAccess.action": "Enable camera access",
|