@wise/dynamic-flow-client-internal 4.27.0-experimental-renderer-utils-876fd4f → 4.27.0-experimental-edf35fb
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/main.js +3534 -53
- package/build/main.mjs +3506 -31
- package/build/types/dynamicFlow/renderers.d.ts +14 -0
- package/build/types/index.d.ts +1 -1
- package/package.json +4 -5
package/build/main.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __defProps = Object.defineProperties;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
6
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
7
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
8
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
10
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
11
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
12
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -20,40 +22,3521 @@ var __spreadValues = (a, b) => {
|
|
|
20
22
|
return a;
|
|
21
23
|
};
|
|
22
24
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
25
|
+
var __objRest = (source, exclude) => {
|
|
26
|
+
var target = {};
|
|
27
|
+
for (var prop in source)
|
|
28
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
29
|
+
target[prop] = source[prop];
|
|
30
|
+
if (source != null && __getOwnPropSymbols)
|
|
31
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
32
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
33
|
+
target[prop] = source[prop];
|
|
34
|
+
}
|
|
35
|
+
return target;
|
|
36
|
+
};
|
|
23
37
|
var __export = (target, all) => {
|
|
24
38
|
for (var name in all)
|
|
25
39
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
26
40
|
};
|
|
27
|
-
var __copyProps = (to, from, except, desc) => {
|
|
28
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
29
|
-
for (let key of __getOwnPropNames(from))
|
|
30
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
31
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
41
|
+
var __copyProps = (to, from, except, desc) => {
|
|
42
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
43
|
+
for (let key of __getOwnPropNames(from))
|
|
44
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
45
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
46
|
+
}
|
|
47
|
+
return to;
|
|
48
|
+
};
|
|
49
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
50
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
51
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
52
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
53
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
54
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
55
|
+
mod
|
|
56
|
+
));
|
|
57
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
58
|
+
|
|
59
|
+
// src/index.ts
|
|
60
|
+
var index_exports = {};
|
|
61
|
+
__export(index_exports, {
|
|
62
|
+
DynamicFlowLegacy: () => DynamicFlowLegacy,
|
|
63
|
+
DynamicFlowRevamp: () => DynamicFlowRevamp,
|
|
64
|
+
DynamicForm: () => DynamicForm,
|
|
65
|
+
Header: () => Header11,
|
|
66
|
+
JsonSchemaForm: () => import_dynamic_flow_client4.JsonSchemaForm,
|
|
67
|
+
Media: () => Media2,
|
|
68
|
+
findRendererPropsByType: () => import_dynamic_flow_client4.findRendererPropsByType,
|
|
69
|
+
getButtonV2Renderers: () => getButtonV2Renderers2,
|
|
70
|
+
getListItemRenderers: () => getListItemRenderers2,
|
|
71
|
+
getMargin: () => getMargin2,
|
|
72
|
+
isValidSchema: () => import_dynamic_flow_client4.isValidSchema,
|
|
73
|
+
makeCustomFetch: () => import_dynamic_flow_client3.makeHttpClient,
|
|
74
|
+
translations: () => i18n_default
|
|
75
|
+
});
|
|
76
|
+
module.exports = __toCommonJS(index_exports);
|
|
77
|
+
var import_dynamic_flow_client3 = require("@wise/dynamic-flow-client");
|
|
78
|
+
var import_dynamic_flow_client4 = require("@wise/dynamic-flow-client");
|
|
79
|
+
|
|
80
|
+
// ../renderers/src/AlertRenderer.tsx
|
|
81
|
+
var import_components = require("@transferwise/components");
|
|
82
|
+
|
|
83
|
+
// ../renderers/src/utils/layout-utils.ts
|
|
84
|
+
var getMargin = (size) => {
|
|
85
|
+
switch (size) {
|
|
86
|
+
case "xs":
|
|
87
|
+
return "m-b-0";
|
|
88
|
+
case "sm":
|
|
89
|
+
return "m-b-1";
|
|
90
|
+
case "md":
|
|
91
|
+
return "m-b-2";
|
|
92
|
+
case "lg":
|
|
93
|
+
return "m-b-3";
|
|
94
|
+
case "xl":
|
|
95
|
+
return "m-b-5";
|
|
96
|
+
default:
|
|
97
|
+
return "";
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
var getTextAlignment = (align) => {
|
|
101
|
+
switch (align) {
|
|
102
|
+
case "end":
|
|
103
|
+
return "text-xs-right";
|
|
104
|
+
case "center":
|
|
105
|
+
return "text-xs-center";
|
|
106
|
+
case "start":
|
|
107
|
+
default:
|
|
108
|
+
return "";
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
var getTextAlignmentAndMargin = (component) => `${getTextAlignment(component.align)} ${getMargin(component.margin)}`;
|
|
112
|
+
|
|
113
|
+
// ../renderers/src/AlertRenderer.tsx
|
|
114
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
115
|
+
var AlertRenderer = {
|
|
116
|
+
canRenderType: "alert",
|
|
117
|
+
render: ({ context, markdown, margin, callToAction }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
118
|
+
import_components.Alert,
|
|
119
|
+
{
|
|
120
|
+
type: context,
|
|
121
|
+
className: getMargin(margin),
|
|
122
|
+
message: markdown,
|
|
123
|
+
action: mapCtaToAlertAction(callToAction)
|
|
124
|
+
}
|
|
125
|
+
)
|
|
126
|
+
};
|
|
127
|
+
var mapCtaToAlertAction = (callToAction) => {
|
|
128
|
+
if (callToAction) {
|
|
129
|
+
return __spreadValues(__spreadValues({
|
|
130
|
+
text: callToAction.title,
|
|
131
|
+
"aria-label": callToAction.accessibilityDescription
|
|
132
|
+
}, "onClick" in callToAction ? { onClick: callToAction.onClick } : {}), callToAction.type === "link" ? { href: callToAction.href, target: "_blank" } : {});
|
|
133
|
+
}
|
|
134
|
+
return void 0;
|
|
135
|
+
};
|
|
136
|
+
var AlertRenderer_default = AlertRenderer;
|
|
137
|
+
|
|
138
|
+
// ../renderers/src/BoxRenderer.tsx
|
|
139
|
+
var import_classnames = __toESM(require("classnames"));
|
|
140
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
141
|
+
var BoxRenderer = {
|
|
142
|
+
canRenderType: "box",
|
|
143
|
+
render: ({ children, control, margin, width }) => {
|
|
144
|
+
const hasFixedWidth = width !== "xl";
|
|
145
|
+
const hasBorder = control === "bordered" || control === "bordered-web";
|
|
146
|
+
const contents = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
147
|
+
"div",
|
|
148
|
+
{
|
|
149
|
+
className: (0, import_classnames.default)({
|
|
150
|
+
"df-box-renderer-border": hasBorder,
|
|
151
|
+
[`df-box-renderer-width-${width}`]: hasFixedWidth,
|
|
152
|
+
[getMargin(margin)]: !hasFixedWidth
|
|
153
|
+
}),
|
|
154
|
+
children
|
|
155
|
+
}
|
|
156
|
+
);
|
|
157
|
+
return hasFixedWidth ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: (0, import_classnames.default)("df-box-renderer-fixed-width", getMargin(margin)), children: contents }) : contents;
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
var BoxRenderer_default = BoxRenderer;
|
|
161
|
+
|
|
162
|
+
// ../renderers/src/ButtonRenderer/AddressValidationButtonRenderer.tsx
|
|
163
|
+
var import_components2 = require("@transferwise/components");
|
|
164
|
+
var import_react_intl2 = require("react-intl");
|
|
165
|
+
|
|
166
|
+
// ../renderers/src/messages/loading-button.messages.ts
|
|
167
|
+
var import_react_intl = require("react-intl");
|
|
168
|
+
var loading_button_messages_default = (0, import_react_intl.defineMessages)({
|
|
169
|
+
buttonLoadingMessage: {
|
|
170
|
+
id: "df.wise.ButtonLayout.buttonLoadingMessage",
|
|
171
|
+
defaultMessage: "This might take a few seconds",
|
|
172
|
+
description: "Message displayed below a button when it is in a loading state."
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
// ../renderers/src/ButtonRenderer/AddressValidationButtonRenderer.tsx
|
|
177
|
+
var import_react = require("react");
|
|
178
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
179
|
+
var AddressValidationButtonRenderer = {
|
|
180
|
+
canRenderType: "button",
|
|
181
|
+
canRender: ({ control }) => control === "address-validation",
|
|
182
|
+
render: AddressValidationButtonComponent
|
|
183
|
+
};
|
|
184
|
+
function AddressValidationButtonComponent(props) {
|
|
185
|
+
const { disabled, margin, title, stepLoadingState, onClick } = props;
|
|
186
|
+
const { formatMessage } = (0, import_react_intl2.useIntl)();
|
|
187
|
+
const [spinny, setSpinny] = (0, import_react.useState)(false);
|
|
188
|
+
(0, import_react.useEffect)(() => {
|
|
189
|
+
if (stepLoadingState === "idle") {
|
|
190
|
+
setSpinny(false);
|
|
191
|
+
}
|
|
192
|
+
}, [stepLoadingState]);
|
|
193
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: `d-flex flex-column ${getMargin(margin)}`, children: [
|
|
194
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
195
|
+
import_components2.Button,
|
|
196
|
+
{
|
|
197
|
+
v2: true,
|
|
198
|
+
block: true,
|
|
199
|
+
disabled,
|
|
200
|
+
priority: "primary",
|
|
201
|
+
size: "md",
|
|
202
|
+
loading: spinny,
|
|
203
|
+
onClick: () => {
|
|
204
|
+
setSpinny(true);
|
|
205
|
+
onClick();
|
|
206
|
+
},
|
|
207
|
+
children: title
|
|
208
|
+
}
|
|
209
|
+
),
|
|
210
|
+
spinny && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_components2.InlineAlert, { type: "warning", className: "m-x-auto", children: formatMessage(loading_button_messages_default.buttonLoadingMessage) })
|
|
211
|
+
] });
|
|
212
|
+
}
|
|
213
|
+
var AddressValidationButtonRenderer_default = AddressValidationButtonRenderer;
|
|
214
|
+
|
|
215
|
+
// ../renderers/src/ButtonRenderer/ButtonRenderer.tsx
|
|
216
|
+
var import_components3 = require("@transferwise/components");
|
|
217
|
+
var import_react2 = require("react");
|
|
218
|
+
|
|
219
|
+
// ../renderers/src/ButtonRenderer/mapButtonSize.tsx
|
|
220
|
+
var mapButtonSize = (size) => {
|
|
221
|
+
if (!size) {
|
|
222
|
+
return void 0;
|
|
223
|
+
}
|
|
224
|
+
switch (size) {
|
|
225
|
+
case "xs":
|
|
226
|
+
case "sm":
|
|
227
|
+
return "sm";
|
|
228
|
+
case "lg":
|
|
229
|
+
case "xl":
|
|
230
|
+
return "lg";
|
|
231
|
+
case "md":
|
|
232
|
+
default:
|
|
233
|
+
return "md";
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
// ../renderers/src/ButtonRenderer/ButtonRenderer.tsx
|
|
238
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
239
|
+
var ButtonRenderer = {
|
|
240
|
+
canRenderType: "button",
|
|
241
|
+
render: ButtonComponent
|
|
242
|
+
};
|
|
243
|
+
function ButtonComponent(props) {
|
|
244
|
+
const { control, context, disabled, margin, title, size, stepLoadingState, onClick } = props;
|
|
245
|
+
const [spinny, setSpinny] = (0, import_react2.useState)(false);
|
|
246
|
+
(0, import_react2.useEffect)(() => {
|
|
247
|
+
if (stepLoadingState === "idle") {
|
|
248
|
+
setSpinny(false);
|
|
249
|
+
}
|
|
250
|
+
}, [stepLoadingState]);
|
|
251
|
+
const priority = getPriority(control);
|
|
252
|
+
const type = getButtonType(context, priority);
|
|
253
|
+
const loading = spinny && stepLoadingState !== "idle";
|
|
254
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
255
|
+
import_components3.Button,
|
|
256
|
+
{
|
|
257
|
+
block: true,
|
|
258
|
+
className: getMargin(margin),
|
|
259
|
+
disabled,
|
|
260
|
+
priority,
|
|
261
|
+
size: mapButtonSize(size),
|
|
262
|
+
loading,
|
|
263
|
+
type,
|
|
264
|
+
onClick: () => {
|
|
265
|
+
setSpinny(true);
|
|
266
|
+
onClick();
|
|
267
|
+
},
|
|
268
|
+
children: title
|
|
269
|
+
}
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
var getPriority = (control) => {
|
|
273
|
+
switch (control) {
|
|
274
|
+
case "primary":
|
|
275
|
+
case "tertiary":
|
|
276
|
+
return control;
|
|
277
|
+
default:
|
|
278
|
+
return "secondary";
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
var getButtonType = (context, priority) => {
|
|
282
|
+
if (priority === "tertiary") {
|
|
283
|
+
return void 0;
|
|
284
|
+
}
|
|
285
|
+
switch (context) {
|
|
286
|
+
case "neutral":
|
|
287
|
+
case "warning":
|
|
288
|
+
return "accent";
|
|
289
|
+
default:
|
|
290
|
+
return context;
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
// ../renderers/src/components/FieldInput.tsx
|
|
295
|
+
var import_components5 = require("@transferwise/components");
|
|
296
|
+
|
|
297
|
+
// ../renderers/src/components/Help.tsx
|
|
298
|
+
var import_components4 = require("@transferwise/components");
|
|
299
|
+
var import_react_intl4 = require("react-intl");
|
|
300
|
+
|
|
301
|
+
// ../renderers/src/messages/help.messages.ts
|
|
302
|
+
var import_react_intl3 = require("react-intl");
|
|
303
|
+
var help_messages_default = (0, import_react_intl3.defineMessages)({
|
|
304
|
+
helpAria: {
|
|
305
|
+
id: "df.wise.Help.ariaLabel",
|
|
306
|
+
defaultMessage: "Click here for more info.",
|
|
307
|
+
description: "Aria label for help."
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
// ../renderers/src/components/Help.tsx
|
|
312
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
313
|
+
function Help({ help, onClick }) {
|
|
314
|
+
const intl = (0, import_react_intl4.useIntl)();
|
|
315
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
316
|
+
import_components4.Info,
|
|
317
|
+
{
|
|
318
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_components4.Markdown, { config: { link: { target: "_blank" } }, children: help }),
|
|
319
|
+
presentation: "POPOVER",
|
|
320
|
+
size: "sm",
|
|
321
|
+
"aria-label": intl.formatMessage(help_messages_default.helpAria),
|
|
322
|
+
onClick
|
|
323
|
+
}
|
|
324
|
+
);
|
|
325
|
+
}
|
|
326
|
+
var Help_default = Help;
|
|
327
|
+
|
|
328
|
+
// ../renderers/src/components/LabelContentWithHelp.tsx
|
|
329
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
330
|
+
function LabelContentWithHelp({ text, help }) {
|
|
331
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { children: [
|
|
332
|
+
text,
|
|
333
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Help_default, { help })
|
|
334
|
+
] });
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
// ../renderers/src/components/FieldInput.tsx
|
|
338
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
339
|
+
function FieldInput({ id, children, label, validation, description, help }) {
|
|
340
|
+
const labelContent = label && help ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(LabelContentWithHelp, { text: label, help }) : label;
|
|
341
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
342
|
+
import_components5.Field,
|
|
343
|
+
{
|
|
344
|
+
id,
|
|
345
|
+
label: labelContent,
|
|
346
|
+
description,
|
|
347
|
+
message: validation == null ? void 0 : validation.message,
|
|
348
|
+
sentiment: mapStatusToSentiment(validation),
|
|
349
|
+
children
|
|
350
|
+
}
|
|
351
|
+
);
|
|
352
|
+
}
|
|
353
|
+
var mapStatusToSentiment = (validation) => {
|
|
354
|
+
if (validation) {
|
|
355
|
+
if (validation.status === "valid") {
|
|
356
|
+
return "positive";
|
|
357
|
+
}
|
|
358
|
+
return "negative";
|
|
359
|
+
}
|
|
360
|
+
return void 0;
|
|
361
|
+
};
|
|
362
|
+
var FieldInput_default = FieldInput;
|
|
363
|
+
|
|
364
|
+
// ../renderers/src/CheckboxInputRenderer.tsx
|
|
365
|
+
var import_components9 = require("@transferwise/components");
|
|
366
|
+
|
|
367
|
+
// ../renderers/src/utils/UrnFlag.tsx
|
|
368
|
+
var import_art = require("@wise/art");
|
|
369
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
370
|
+
var countryUrnPrefix = "urn:wise:countries:";
|
|
371
|
+
var currencyUrnPrefix = "urn:wise:currencies:";
|
|
372
|
+
var isUrnFlag = (uri) => uri.startsWith(countryUrnPrefix) || uri.startsWith(currencyUrnPrefix);
|
|
373
|
+
function UrnFlag({ size, urn }) {
|
|
374
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_art.Flag, { code: getCode(urn), intrinsicSize: size });
|
|
375
|
+
}
|
|
376
|
+
var getCode = (urn) => {
|
|
377
|
+
return urn.replace(countryUrnPrefix, "").replace(currencyUrnPrefix, "").replace(":image", "").split("?")[0];
|
|
378
|
+
};
|
|
379
|
+
|
|
380
|
+
// ../renderers/src/components/icon/FlagIcon.tsx
|
|
381
|
+
var import_art2 = require("@wise/art");
|
|
382
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
383
|
+
var isFlagIcon = (name) => name.startsWith("flag-");
|
|
384
|
+
function FlagIcon({ name }) {
|
|
385
|
+
if (!isFlagIcon(name)) {
|
|
386
|
+
return null;
|
|
387
|
+
}
|
|
388
|
+
const code = name.substring(5);
|
|
389
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_art2.Flag, { code, intrinsicSize: 24 });
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
// ../renderers/src/components/icon/NamedIcon.tsx
|
|
393
|
+
var icons = __toESM(require("@transferwise/icons"));
|
|
394
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
395
|
+
var isNamedIcon = (name) => {
|
|
396
|
+
const iconName = toCapitalisedCamelCase(name);
|
|
397
|
+
return Object.keys(icons).includes(iconName);
|
|
398
|
+
};
|
|
399
|
+
function NamedIcon({ name }) {
|
|
400
|
+
if (!isNamedIcon(name)) {
|
|
401
|
+
return null;
|
|
402
|
+
}
|
|
403
|
+
const iconName = toCapitalisedCamelCase(name);
|
|
404
|
+
const Icon = icons[iconName];
|
|
405
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Icon, { size: 24 });
|
|
406
|
+
}
|
|
407
|
+
var toCapitalisedCamelCase = (value) => value.split("-").map(capitaliseFirstChar).join("");
|
|
408
|
+
var capitaliseFirstChar = (value) => `${value[0].toUpperCase()}${value.slice(1)}`;
|
|
409
|
+
|
|
410
|
+
// ../renderers/src/components/icon/DynamicIcon.tsx
|
|
411
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
412
|
+
function DynamicIcon({ name }) {
|
|
413
|
+
if (isFlagIcon(name)) {
|
|
414
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(FlagIcon, { name });
|
|
415
|
+
}
|
|
416
|
+
if (isNamedIcon(name)) {
|
|
417
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(NamedIcon, { name });
|
|
418
|
+
}
|
|
419
|
+
return null;
|
|
420
|
+
}
|
|
421
|
+
function isValidIconName(name) {
|
|
422
|
+
return isNamedIcon(name) || isFlagIcon(name);
|
|
423
|
+
}
|
|
424
|
+
function isValidIconUrn(uri) {
|
|
425
|
+
if (!uri.startsWith("urn:wise:icons:")) {
|
|
426
|
+
return false;
|
|
427
|
+
}
|
|
428
|
+
const name = uri.replace("urn:wise:icons:", "").split("?")[0];
|
|
429
|
+
return isValidIconName(name);
|
|
430
|
+
}
|
|
431
|
+
var DynamicIcon_default = DynamicIcon;
|
|
432
|
+
|
|
433
|
+
// ../renderers/src/components/Media/stringToURN.ts
|
|
434
|
+
var stringToURN = (uri) => {
|
|
435
|
+
var _a, _b, _c;
|
|
436
|
+
const [nameWithRQComponents, _] = uri.split("#");
|
|
437
|
+
const [nameWithRComponent, qComponent] = nameWithRQComponents.split("?=");
|
|
438
|
+
const [name, rComponent] = (_a = nameWithRComponent == null ? void 0 : nameWithRComponent.split("?+")) != null ? _a : ["", ""];
|
|
439
|
+
const rComponents = rComponent ? (_b = decodeURIComponent(rComponent)) == null ? void 0 : _b.split("&").map((c) => c.split("=")).map(([a, b]) => [a, b]) : void 0;
|
|
440
|
+
const qComponents = qComponent ? (_c = decodeURIComponent(qComponent)) == null ? void 0 : _c.split("&").map((c) => c.split("=")).map(([a, b]) => [a, b]) : void 0;
|
|
441
|
+
return {
|
|
442
|
+
name,
|
|
443
|
+
rComponents,
|
|
444
|
+
qComponents
|
|
445
|
+
};
|
|
446
|
+
};
|
|
447
|
+
|
|
448
|
+
// ../renderers/src/components/Media/resolveMediaFromUri.tsx
|
|
449
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
450
|
+
var resolveMediaFromUri = (uri, size) => {
|
|
451
|
+
var _a, _b;
|
|
452
|
+
const { name, qComponents = [] } = stringToURN(uri);
|
|
453
|
+
if (isValidIconUrn(name)) {
|
|
454
|
+
const icon = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(DynamicIcon_default, { name: name.replace("urn:wise:icons:", "") });
|
|
455
|
+
return {
|
|
456
|
+
icon,
|
|
457
|
+
backgroundColor: formatColor((_a = qComponents.find(([key]) => key === "background-color")) == null ? void 0 : _a[1])
|
|
458
|
+
};
|
|
459
|
+
}
|
|
460
|
+
if (isUrnFlag(name)) {
|
|
461
|
+
return {
|
|
462
|
+
asset: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(UrnFlag, { urn: name, size })
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
if (name.startsWith("data:text/plain,")) {
|
|
466
|
+
const text = decodeURI(name.replace("data:text/plain,", ""));
|
|
467
|
+
return {
|
|
468
|
+
asset: text,
|
|
469
|
+
backgroundColor: formatColor((_b = qComponents.find(([key]) => key === "background-color")) == null ? void 0 : _b[1])
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
if (!uri.startsWith("urn:")) {
|
|
473
|
+
return { asset: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("img", { src: uri, alt: "", width: `${size}px` }) };
|
|
474
|
+
}
|
|
475
|
+
return { asset: void 0 };
|
|
476
|
+
};
|
|
477
|
+
var formatColor = (color) => {
|
|
478
|
+
if (!color) {
|
|
479
|
+
return void 0;
|
|
480
|
+
}
|
|
481
|
+
if (color.startsWith("#")) {
|
|
482
|
+
return color;
|
|
483
|
+
}
|
|
484
|
+
return `var(--color-${color.replace(/^base-|brand-/, "")})`;
|
|
485
|
+
};
|
|
486
|
+
|
|
487
|
+
// ../renderers/src/components/Media/AvatarMedia.tsx
|
|
488
|
+
var import_components6 = require("@transferwise/components");
|
|
489
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
490
|
+
var AvatarMedia = ({
|
|
491
|
+
accessibilityDescription,
|
|
492
|
+
content,
|
|
493
|
+
size
|
|
494
|
+
}) => {
|
|
495
|
+
const getRenderableAvatar = (avatar) => {
|
|
496
|
+
if (avatar.type === "text") {
|
|
497
|
+
return { asset: avatar.text };
|
|
498
|
+
}
|
|
499
|
+
return __spreadProps(__spreadValues({}, resolveMediaFromUri(avatar.uri, size)), {
|
|
500
|
+
badge: avatar.badgeUri ? resolveMediaFromUri(avatar.badgeUri, 16) : void 0
|
|
501
|
+
});
|
|
502
|
+
};
|
|
503
|
+
const avatars = content.map(getRenderableAvatar);
|
|
504
|
+
if (avatars.length === 1) {
|
|
505
|
+
const { badge, backgroundColor, asset, icon } = avatars[0];
|
|
506
|
+
if (!asset && !icon) {
|
|
507
|
+
return null;
|
|
508
|
+
}
|
|
509
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
510
|
+
import_components6.AvatarView,
|
|
511
|
+
{
|
|
512
|
+
"aria-label": accessibilityDescription,
|
|
513
|
+
size,
|
|
514
|
+
badge: badge ? __spreadProps(__spreadValues({}, badge), {
|
|
515
|
+
type: "reference"
|
|
516
|
+
}) : void 0,
|
|
517
|
+
style: { backgroundColor },
|
|
518
|
+
children: icon != null ? icon : asset
|
|
519
|
+
}
|
|
520
|
+
);
|
|
521
|
+
}
|
|
522
|
+
const avatarsWithoutBadges = avatars.filter(({ asset }) => asset).slice(0, 2).map((_a) => {
|
|
523
|
+
var _b = _a, { badge } = _b, rest = __objRest(_b, ["badge"]);
|
|
524
|
+
return __spreadValues({}, rest);
|
|
525
|
+
});
|
|
526
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
527
|
+
import_components6.AvatarLayout,
|
|
528
|
+
{
|
|
529
|
+
"aria-label": accessibilityDescription,
|
|
530
|
+
size,
|
|
531
|
+
orientation: "diagonal",
|
|
532
|
+
avatars: avatarsWithoutBadges
|
|
533
|
+
}
|
|
534
|
+
);
|
|
535
|
+
};
|
|
536
|
+
|
|
537
|
+
// ../renderers/src/utils/image-utils.tsx
|
|
538
|
+
var import_components7 = require("@transferwise/components");
|
|
539
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
540
|
+
var getBadgedMedia = (iconNode, imageNode, size) => {
|
|
541
|
+
if (iconNode && imageNode) {
|
|
542
|
+
if (imageNode && iconNode) {
|
|
543
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_components7.AvatarView, { size, badge: { asset: iconNode, type: "reference" }, children: imageNode });
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
return null;
|
|
547
|
+
};
|
|
548
|
+
var getIconNode = (icon) => {
|
|
549
|
+
if (icon) {
|
|
550
|
+
if ("name" in icon) {
|
|
551
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(DynamicIcon_default, { name: icon.name });
|
|
552
|
+
}
|
|
553
|
+
if (icon.text) {
|
|
554
|
+
return icon.text;
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
return null;
|
|
558
|
+
};
|
|
559
|
+
var getImageNode = (image, size) => {
|
|
560
|
+
if (image) {
|
|
561
|
+
const { accessibilityDescription, uri } = image;
|
|
562
|
+
if (!uri.startsWith("urn:")) {
|
|
563
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("img", { src: uri, alt: accessibilityDescription, width: `${size}px` });
|
|
564
|
+
}
|
|
565
|
+
if (isUrnFlag(uri)) {
|
|
566
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(UrnFlag, { urn: uri, accessibilityDescription, size });
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
return null;
|
|
570
|
+
};
|
|
571
|
+
|
|
572
|
+
// ../renderers/src/components/Media/LegacyMedia.tsx
|
|
573
|
+
var import_components8 = require("@transferwise/components");
|
|
574
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
575
|
+
var LegacyMedia = ({ image, icon, preferAvatar, size }) => {
|
|
576
|
+
const imageNode = getImageNode(image, size);
|
|
577
|
+
const iconNode = getIconNode(icon);
|
|
578
|
+
const badge = getBadgedMedia(iconNode, imageNode, size);
|
|
579
|
+
if (badge) {
|
|
580
|
+
return badge;
|
|
581
|
+
}
|
|
582
|
+
if (imageNode) {
|
|
583
|
+
return preferAvatar ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_components8.AvatarView, { children: imageNode }) : imageNode;
|
|
584
|
+
}
|
|
585
|
+
if (iconNode && icon) {
|
|
586
|
+
if ("text" in icon || size === 48) {
|
|
587
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_components8.AvatarView, { size, children: iconNode });
|
|
588
|
+
}
|
|
589
|
+
return iconNode;
|
|
590
|
+
}
|
|
591
|
+
return null;
|
|
592
|
+
};
|
|
593
|
+
|
|
594
|
+
// ../renderers/src/components/Media/Media.tsx
|
|
595
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
596
|
+
function Media({
|
|
597
|
+
media,
|
|
598
|
+
preferAvatar,
|
|
599
|
+
size
|
|
600
|
+
}) {
|
|
601
|
+
switch (media == null ? void 0 : media.type) {
|
|
602
|
+
case "avatar":
|
|
603
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(AvatarMedia, __spreadProps(__spreadValues({}, media), { size }));
|
|
604
|
+
case "image": {
|
|
605
|
+
const { asset, icon } = resolveMediaFromUri(media.uri, size);
|
|
606
|
+
return icon != null ? icon : asset;
|
|
607
|
+
}
|
|
608
|
+
case "legacy": {
|
|
609
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(LegacyMedia, __spreadProps(__spreadValues({}, media), { preferAvatar, size }));
|
|
610
|
+
}
|
|
611
|
+
default:
|
|
612
|
+
return null;
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
// ../renderers/src/components/Media/OptionMedia.tsx
|
|
617
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
618
|
+
var mediaSize = 48;
|
|
619
|
+
function OptionMedia(props) {
|
|
620
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Media, __spreadProps(__spreadValues({}, props), { size: mediaSize }));
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
// ../renderers/src/components/Media/getInlineMedia.tsx
|
|
624
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
625
|
+
var getInlineMedia = (media) => media ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Media, { media, preferAvatar: false, size: 24 }) : null;
|
|
626
|
+
|
|
627
|
+
// ../renderers/src/NewListItem/getMedia.tsx
|
|
628
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
629
|
+
var getMedia = (media, preferAvatar) => media ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(OptionMedia, { media, preferAvatar }) : void 0;
|
|
630
|
+
|
|
631
|
+
// ../renderers/src/CheckboxInputRenderer.tsx
|
|
632
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
633
|
+
var CheckboxInputRenderer = {
|
|
634
|
+
canRenderType: "input-checkbox",
|
|
635
|
+
render: (props) => props.control === "switch-item" ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(SwitchComponent, __spreadValues({}, props)) : /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(CheckboxComponent, __spreadValues({}, props))
|
|
636
|
+
};
|
|
637
|
+
var CheckboxComponent = (props) => {
|
|
638
|
+
const _a = props, {
|
|
639
|
+
id,
|
|
640
|
+
control,
|
|
641
|
+
title = "",
|
|
642
|
+
description,
|
|
643
|
+
help,
|
|
644
|
+
type,
|
|
645
|
+
validationState,
|
|
646
|
+
value
|
|
647
|
+
} = _a, rest = __objRest(_a, [
|
|
648
|
+
"id",
|
|
649
|
+
"control",
|
|
650
|
+
"title",
|
|
651
|
+
"description",
|
|
652
|
+
"help",
|
|
653
|
+
"type",
|
|
654
|
+
"validationState",
|
|
655
|
+
"value"
|
|
656
|
+
]);
|
|
657
|
+
const checkboxProps = __spreadProps(__spreadValues({}, rest), { label: title, secondary: description, checked: value });
|
|
658
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(FieldInput_default, { id, label: "", description: "", validation: validationState, help, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_components9.Checkbox, __spreadValues({ id }, checkboxProps)) });
|
|
659
|
+
};
|
|
660
|
+
var SwitchComponent = (props) => {
|
|
661
|
+
const { title, description, disabled, media, validationState, value, onChange } = props;
|
|
662
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
663
|
+
import_components9.ListItem,
|
|
664
|
+
{
|
|
665
|
+
title,
|
|
666
|
+
subtitle: description,
|
|
667
|
+
media: getMedia(media, false),
|
|
668
|
+
disabled,
|
|
669
|
+
prompt: validationState && validationState.status === "invalid" ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_components9.ListItem.Prompt, { sentiment: "negative", children: validationState.message }) : void 0,
|
|
670
|
+
control: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_components9.ListItem.Switch, { checked: value, onClick: () => onChange(!value) })
|
|
671
|
+
}
|
|
672
|
+
);
|
|
673
|
+
};
|
|
674
|
+
var CheckboxInputRenderer_default = CheckboxInputRenderer;
|
|
675
|
+
|
|
676
|
+
// ../renderers/src/ColumnsRenderer.tsx
|
|
677
|
+
var import_classnames2 = __toESM(require("classnames"));
|
|
678
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
679
|
+
var ColumnsRenderer = {
|
|
680
|
+
canRenderType: "columns",
|
|
681
|
+
render: ({ bias, margin, startChildren, endChildren }) => /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
|
682
|
+
"div",
|
|
683
|
+
{
|
|
684
|
+
className: (0, import_classnames2.default)("df-columns-renderer-container", getMargin(margin), {
|
|
685
|
+
"df-columns-renderer-bias-start": bias === "start",
|
|
686
|
+
"df-columns-renderer-bias-end": bias === "end"
|
|
687
|
+
}),
|
|
688
|
+
children: [
|
|
689
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "df-columns-renderer-column", children: startChildren }),
|
|
690
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "df-columns-renderer-column", children: endChildren })
|
|
691
|
+
]
|
|
692
|
+
}
|
|
693
|
+
)
|
|
694
|
+
};
|
|
695
|
+
var ColumnsRenderer_default = ColumnsRenderer;
|
|
696
|
+
|
|
697
|
+
// ../renderers/src/components/VariableDateInput.tsx
|
|
698
|
+
var import_components10 = require("@transferwise/components");
|
|
699
|
+
|
|
700
|
+
// ../renderers/src/validators/type-validators.ts
|
|
701
|
+
var isNumber = (value) => typeof value === "number" && !Number.isNaN(value);
|
|
702
|
+
|
|
703
|
+
// ../renderers/src/utils/value-utils.ts
|
|
704
|
+
var dateStringToDateOrNull = (dateString) => {
|
|
705
|
+
if (!dateString) {
|
|
706
|
+
return null;
|
|
707
|
+
}
|
|
708
|
+
const [year, month, date] = dateString.split("-").map((number) => Number.parseInt(number, 10));
|
|
709
|
+
if (!isNumber(year) || !isNumber(month) || !isNumber(date)) {
|
|
710
|
+
return null;
|
|
711
|
+
}
|
|
712
|
+
return new Date(year, month - 1, date);
|
|
713
|
+
};
|
|
714
|
+
var dateToDateString = (date) => {
|
|
715
|
+
const d = new Date(date);
|
|
716
|
+
const month = String(d.getMonth() + 1);
|
|
717
|
+
const day = String(d.getDate());
|
|
718
|
+
const year = d.getFullYear();
|
|
719
|
+
const formattedMonth = month.length < 2 ? `0${month}` : month;
|
|
720
|
+
const formattedDay = day.length < 2 ? `0${day}` : day;
|
|
721
|
+
return [year, formattedMonth, formattedDay].join("-");
|
|
722
|
+
};
|
|
723
|
+
|
|
724
|
+
// ../renderers/src/components/VariableDateInput.tsx
|
|
725
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
726
|
+
function VariableDateInput({
|
|
727
|
+
control,
|
|
728
|
+
inputProps
|
|
729
|
+
}) {
|
|
730
|
+
const {
|
|
731
|
+
autoComplete,
|
|
732
|
+
minimumDate,
|
|
733
|
+
maximumDate,
|
|
734
|
+
placeholder,
|
|
735
|
+
disabled,
|
|
736
|
+
onBlur,
|
|
737
|
+
onChange,
|
|
738
|
+
onFocus
|
|
739
|
+
} = inputProps;
|
|
740
|
+
if (control === "date-lookup") {
|
|
741
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
742
|
+
import_components10.DateLookup,
|
|
743
|
+
{
|
|
744
|
+
value: dateStringToDateOrNull(inputProps.value),
|
|
745
|
+
min: dateStringToDateOrNull(minimumDate),
|
|
746
|
+
max: dateStringToDateOrNull(maximumDate),
|
|
747
|
+
placeholder,
|
|
748
|
+
disabled,
|
|
749
|
+
onChange: (date) => {
|
|
750
|
+
onChange(date !== null ? dateToDateString(date) : null);
|
|
751
|
+
},
|
|
752
|
+
onBlur,
|
|
753
|
+
onFocus
|
|
754
|
+
}
|
|
755
|
+
);
|
|
756
|
+
}
|
|
757
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
758
|
+
import_components10.DateInput,
|
|
759
|
+
__spreadProps(__spreadValues({}, inputProps), {
|
|
760
|
+
dayAutoComplete: getAutocompleteString(autoComplete, "day"),
|
|
761
|
+
yearAutoComplete: getAutocompleteString(autoComplete, "year")
|
|
762
|
+
})
|
|
763
|
+
);
|
|
764
|
+
}
|
|
765
|
+
var getAutocompleteString = (value, suffix) => {
|
|
766
|
+
if (value === "bday") {
|
|
767
|
+
return `${value}-${suffix}`;
|
|
768
|
+
}
|
|
769
|
+
return void 0;
|
|
770
|
+
};
|
|
771
|
+
var VariableDateInput_default = VariableDateInput;
|
|
772
|
+
|
|
773
|
+
// ../renderers/src/DateInputRenderer.tsx
|
|
774
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
775
|
+
var DateInputRenderer = {
|
|
776
|
+
canRenderType: "input-date",
|
|
777
|
+
render: (props) => {
|
|
778
|
+
const _a = props, {
|
|
779
|
+
id,
|
|
780
|
+
control,
|
|
781
|
+
description,
|
|
782
|
+
type,
|
|
783
|
+
help,
|
|
784
|
+
title,
|
|
785
|
+
validationState,
|
|
786
|
+
value: initialValue
|
|
787
|
+
} = _a, rest = __objRest(_a, [
|
|
788
|
+
"id",
|
|
789
|
+
"control",
|
|
790
|
+
"description",
|
|
791
|
+
"type",
|
|
792
|
+
"help",
|
|
793
|
+
"title",
|
|
794
|
+
"validationState",
|
|
795
|
+
"value"
|
|
796
|
+
]);
|
|
797
|
+
const value = initialValue != null ? initialValue : "";
|
|
798
|
+
const inputProps = __spreadProps(__spreadValues({}, rest), { value, id });
|
|
799
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
800
|
+
FieldInput_default,
|
|
801
|
+
{
|
|
802
|
+
id,
|
|
803
|
+
label: title,
|
|
804
|
+
description,
|
|
805
|
+
validation: validationState,
|
|
806
|
+
help,
|
|
807
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(VariableDateInput_default, { control, inputProps })
|
|
808
|
+
}
|
|
809
|
+
);
|
|
810
|
+
}
|
|
811
|
+
};
|
|
812
|
+
var DateInputRenderer_default = DateInputRenderer;
|
|
813
|
+
|
|
814
|
+
// ../renderers/src/DecisionRenderer/DecisionRenderer.tsx
|
|
815
|
+
var import_components13 = require("@transferwise/components");
|
|
816
|
+
|
|
817
|
+
// ../renderers/src/DecisionRenderer/DecisionList.tsx
|
|
818
|
+
var import_components12 = require("@transferwise/components");
|
|
819
|
+
|
|
820
|
+
// ../renderers/src/DecisionRenderer/GroupedList.tsx
|
|
821
|
+
var import_components11 = require("@transferwise/components");
|
|
822
|
+
var import_react_intl6 = require("react-intl");
|
|
823
|
+
|
|
824
|
+
// ../renderers/src/messages/decision.messages.ts
|
|
825
|
+
var import_react_intl5 = require("react-intl");
|
|
826
|
+
var decision_messages_default = (0, import_react_intl5.defineMessages)({
|
|
827
|
+
all: {
|
|
828
|
+
id: "df.wise.Decision.all",
|
|
829
|
+
defaultMessage: "All",
|
|
830
|
+
description: "Label for the group of options that encompasses all options"
|
|
831
|
+
},
|
|
832
|
+
popular: {
|
|
833
|
+
id: "df.wise.Decision.popular",
|
|
834
|
+
defaultMessage: "Popular",
|
|
835
|
+
description: "Label for the group of options that are tagged as popular"
|
|
836
|
+
},
|
|
837
|
+
recent: {
|
|
838
|
+
id: "df.wise.Decision.recent",
|
|
839
|
+
defaultMessage: "Recent",
|
|
840
|
+
description: "Label for the group of options that are tagged as recent"
|
|
841
|
+
},
|
|
842
|
+
currenciesWithAccountDetails: {
|
|
843
|
+
id: "df.wise.Decision.currenciesWithAccountDetails",
|
|
844
|
+
defaultMessage: "Currencies with account details",
|
|
845
|
+
description: "Label for the group of options that are tagged as currencies with account details"
|
|
846
|
+
},
|
|
847
|
+
filterPlaceholder: {
|
|
848
|
+
id: "df.wise.Decision.filterPlaceholder",
|
|
849
|
+
defaultMessage: "Start typing to search",
|
|
850
|
+
description: "Placeholder for the filter input"
|
|
851
|
+
},
|
|
852
|
+
results: {
|
|
853
|
+
id: "df.wise.Decision.results",
|
|
854
|
+
defaultMessage: "Search results",
|
|
855
|
+
description: "Label for the results section"
|
|
856
|
+
},
|
|
857
|
+
noResults: {
|
|
858
|
+
id: "df.wise.Decision.noResults",
|
|
859
|
+
defaultMessage: "No results",
|
|
860
|
+
description: "Message for if there are no results"
|
|
861
|
+
}
|
|
862
|
+
});
|
|
863
|
+
|
|
864
|
+
// ../renderers/src/DecisionRenderer/GroupedList.tsx
|
|
865
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
866
|
+
var OPTION_GROUPS = {
|
|
867
|
+
popular: "popular",
|
|
868
|
+
recent: "recent",
|
|
869
|
+
currencyWithAccountDetails: "currencies-with-account-details"
|
|
870
|
+
};
|
|
871
|
+
var GroupedList = (_a) => {
|
|
872
|
+
var _b = _a, { renderDecisionList: renderDecisionList3 } = _b, rest = __objRest(_b, ["renderDecisionList"]);
|
|
873
|
+
const { formatMessage } = (0, import_react_intl6.useIntl)();
|
|
874
|
+
const { options } = rest;
|
|
875
|
+
const popularOptions = options.filter((option) => option.tag === OPTION_GROUPS.popular);
|
|
876
|
+
const recentOptions = options.filter((option) => option.tag === OPTION_GROUPS.recent);
|
|
877
|
+
const currencyWithAccountDetailsOptions = options.filter(
|
|
878
|
+
(option) => option.tag === OPTION_GROUPS.currencyWithAccountDetails
|
|
879
|
+
);
|
|
880
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_jsx_runtime24.Fragment, { children: [
|
|
881
|
+
popularOptions.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_components11.Section, { children: [
|
|
882
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_components11.Header, { as: "h2", title: formatMessage(decision_messages_default.popular) }),
|
|
883
|
+
renderDecisionList3(__spreadProps(__spreadValues({}, rest), { options: popularOptions }))
|
|
884
|
+
] }) : null,
|
|
885
|
+
recentOptions.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_components11.Section, { children: [
|
|
886
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_components11.Header, { as: "h2", title: formatMessage(decision_messages_default.recent) }),
|
|
887
|
+
renderDecisionList3(__spreadProps(__spreadValues({}, rest), { options: recentOptions }))
|
|
888
|
+
] }) : null,
|
|
889
|
+
currencyWithAccountDetailsOptions.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_components11.Section, { children: [
|
|
890
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_components11.Header, { as: "h2", title: formatMessage(decision_messages_default.currenciesWithAccountDetails) }),
|
|
891
|
+
renderDecisionList3(__spreadProps(__spreadValues({}, rest), { options: currencyWithAccountDetailsOptions }))
|
|
892
|
+
] }) : null,
|
|
893
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_components11.Section, { children: [
|
|
894
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_components11.Header, { as: "h2", title: formatMessage(decision_messages_default.all) }),
|
|
895
|
+
renderDecisionList3(rest)
|
|
896
|
+
] })
|
|
897
|
+
] });
|
|
898
|
+
};
|
|
899
|
+
var isGroupedDecision = (options) => {
|
|
900
|
+
const possibleGroups = Object.values(OPTION_GROUPS);
|
|
901
|
+
return options.some(({ tag }) => tag && possibleGroups.includes(tag));
|
|
902
|
+
};
|
|
903
|
+
|
|
904
|
+
// ../renderers/src/DecisionRenderer/DecisionList.tsx
|
|
905
|
+
var import_react_intl7 = require("react-intl");
|
|
906
|
+
var import_react3 = require("react");
|
|
907
|
+
|
|
908
|
+
// ../renderers/src/DecisionRenderer/filter-and-sort-decision-options.ts
|
|
909
|
+
function filterAndSortDecisionOptions(selectOptions, query) {
|
|
910
|
+
const upperQuery = query.toUpperCase().trim();
|
|
911
|
+
const filteredItems = selectOptions.filter((option) => {
|
|
912
|
+
var _a, _b, _c, _d;
|
|
913
|
+
const searchableWords = [
|
|
914
|
+
option.title,
|
|
915
|
+
option.description,
|
|
916
|
+
option.additionalText,
|
|
917
|
+
(_a = option.supportingValues) == null ? void 0 : _a.value,
|
|
918
|
+
(_b = option.supportingValues) == null ? void 0 : _b.subvalue,
|
|
919
|
+
...(_c = option.keywords) != null ? _c : []
|
|
920
|
+
];
|
|
921
|
+
return (_d = searchableWords.some((word) => word == null ? void 0 : word.toUpperCase().includes(upperQuery))) != null ? _d : false;
|
|
922
|
+
});
|
|
923
|
+
return [...filteredItems].sort((a, b) => {
|
|
924
|
+
const aTitleUpper = a.title.toUpperCase();
|
|
925
|
+
const bTitleUpper = b.title.toUpperCase();
|
|
926
|
+
const aTitleStarts = aTitleUpper.startsWith(upperQuery);
|
|
927
|
+
const bTitleStarts = bTitleUpper.startsWith(upperQuery);
|
|
928
|
+
if (aTitleStarts && !bTitleStarts) {
|
|
929
|
+
return -1;
|
|
930
|
+
}
|
|
931
|
+
if (!aTitleStarts && bTitleStarts) {
|
|
932
|
+
return 1;
|
|
933
|
+
}
|
|
934
|
+
const aWordStarts = aTitleUpper.split(" ").some((word) => word.startsWith(upperQuery));
|
|
935
|
+
const bWordStarts = bTitleUpper.split(" ").some((word) => word.startsWith(upperQuery));
|
|
936
|
+
if (aWordStarts && !bWordStarts) {
|
|
937
|
+
return -1;
|
|
938
|
+
}
|
|
939
|
+
if (!aWordStarts && bWordStarts) {
|
|
940
|
+
return 1;
|
|
941
|
+
}
|
|
942
|
+
return a.title.localeCompare(b.title);
|
|
943
|
+
});
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
// ../renderers/src/DecisionRenderer/DecisionList.tsx
|
|
947
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
948
|
+
var DecisionWrapper = (props) => {
|
|
949
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: getMargin(props.margin), children: [
|
|
950
|
+
props.title && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_components12.Header, { as: "h2", title: props.title }),
|
|
951
|
+
props.control === "filtered" ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(FilteredDecisionList, __spreadValues({}, props)) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(UnfilteredDecisionList, __spreadValues({}, props))
|
|
952
|
+
] });
|
|
953
|
+
};
|
|
954
|
+
var UnfilteredDecisionList = (_a) => {
|
|
955
|
+
var _b = _a, { renderDecisionList: renderDecisionList3 } = _b, rest = __objRest(_b, ["renderDecisionList"]);
|
|
956
|
+
return isGroupedDecision(rest.options) ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(GroupedList, __spreadProps(__spreadValues({}, rest), { renderDecisionList: renderDecisionList3 })) : renderDecisionList3(rest);
|
|
957
|
+
};
|
|
958
|
+
var FilteredDecisionList = (props) => {
|
|
959
|
+
const { formatMessage } = (0, import_react_intl7.useIntl)();
|
|
960
|
+
const [query, setQuery] = (0, import_react3.useState)("");
|
|
961
|
+
const { control, options, renderDecisionList: renderDecisionList3 } = props;
|
|
962
|
+
const filteredOptions = filterAndSortDecisionOptions(options, query);
|
|
963
|
+
const isGrouped = isGroupedDecision(options);
|
|
964
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
|
|
965
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
966
|
+
import_components12.SearchInput,
|
|
967
|
+
{
|
|
968
|
+
placeholder: formatMessage(decision_messages_default.filterPlaceholder),
|
|
969
|
+
value: query,
|
|
970
|
+
onChange: (e) => {
|
|
971
|
+
var _a;
|
|
972
|
+
return setQuery((_a = e.target.value) != null ? _a : "");
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
),
|
|
976
|
+
isGrouped && query.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(GroupedList, __spreadValues({}, props)) : /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
|
|
977
|
+
query.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_components12.Header, { as: "h2", title: formatMessage(decision_messages_default.results), className: "m-t-4" }),
|
|
978
|
+
filteredOptions.length > 0 ? renderDecisionList3({
|
|
979
|
+
control,
|
|
980
|
+
className: query.length === 0 ? "m-t-3" : "",
|
|
981
|
+
options: filteredOptions
|
|
982
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { children: formatMessage(decision_messages_default.noResults) })
|
|
983
|
+
] })
|
|
984
|
+
] });
|
|
985
|
+
};
|
|
986
|
+
|
|
987
|
+
// ../renderers/src/DecisionRenderer/DecisionRenderer.tsx
|
|
988
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
989
|
+
var DecisionRenderer = {
|
|
990
|
+
canRenderType: "decision",
|
|
991
|
+
render: (props) => {
|
|
992
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(DecisionWrapper, __spreadProps(__spreadValues({}, props), { renderDecisionList }));
|
|
993
|
+
}
|
|
994
|
+
};
|
|
995
|
+
var renderDecisionList = ({ options, className, control }) => {
|
|
996
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_components13.NavigationOptionsList, { children: options.map((option) => {
|
|
997
|
+
const { description, disabled, media, title: itemTitle, tag, onClick } = option;
|
|
998
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
999
|
+
import_components13.NavigationOption,
|
|
1000
|
+
{
|
|
1001
|
+
title: itemTitle,
|
|
1002
|
+
content: description,
|
|
1003
|
+
disabled,
|
|
1004
|
+
media: media ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
1005
|
+
OptionMedia,
|
|
1006
|
+
{
|
|
1007
|
+
media,
|
|
1008
|
+
preferAvatar: control === "with-avatar" || tag === "with-avatar"
|
|
1009
|
+
}
|
|
1010
|
+
) : null,
|
|
1011
|
+
showMediaCircle: false,
|
|
1012
|
+
showMediaAtAllSizes: true,
|
|
1013
|
+
onClick
|
|
1014
|
+
},
|
|
1015
|
+
JSON.stringify(option)
|
|
1016
|
+
);
|
|
1017
|
+
}) }) });
|
|
1018
|
+
};
|
|
1019
|
+
var DecisionRenderer_default = DecisionRenderer;
|
|
1020
|
+
|
|
1021
|
+
// ../renderers/src/DividerRenderer.tsx
|
|
1022
|
+
var import_components14 = require("@transferwise/components");
|
|
1023
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
1024
|
+
var mapControlToLevel = (control) => {
|
|
1025
|
+
switch (control) {
|
|
1026
|
+
case "section":
|
|
1027
|
+
return "section";
|
|
1028
|
+
case "content":
|
|
1029
|
+
return "content";
|
|
1030
|
+
default:
|
|
1031
|
+
return "subsection";
|
|
1032
|
+
}
|
|
1033
|
+
};
|
|
1034
|
+
var DividerRenderer = {
|
|
1035
|
+
canRenderType: "divider",
|
|
1036
|
+
render: ({ margin, control }) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_components14.Divider, { className: `m-t-0 d-block ${getMargin(margin)}`, level: mapControlToLevel(control) })
|
|
1037
|
+
};
|
|
1038
|
+
var DividerRenderer_default = DividerRenderer;
|
|
1039
|
+
|
|
1040
|
+
// ../renderers/src/ExternalConfirmationRenderer.tsx
|
|
1041
|
+
var import_components15 = require("@transferwise/components");
|
|
1042
|
+
|
|
1043
|
+
// ../renderers/src/messages/external-confirmation.messages.ts
|
|
1044
|
+
var import_react_intl8 = require("react-intl");
|
|
1045
|
+
var external_confirmation_messages_default = (0, import_react_intl8.defineMessages)({
|
|
1046
|
+
title: {
|
|
1047
|
+
id: "df.wise.ExternalConfirmation.title",
|
|
1048
|
+
defaultMessage: "Please confirm",
|
|
1049
|
+
description: "Heading for the confirmation screen."
|
|
1050
|
+
},
|
|
1051
|
+
description: {
|
|
1052
|
+
id: "df.wise.ExternalConfirmation.description",
|
|
1053
|
+
defaultMessage: "Please confirm you want to open **{origin}** in a new browser tab.",
|
|
1054
|
+
description: "Description for the confirmation screen."
|
|
1055
|
+
},
|
|
1056
|
+
open: {
|
|
1057
|
+
id: "df.wise.ExternalConfirmation.open",
|
|
1058
|
+
defaultMessage: "Open in new tab",
|
|
1059
|
+
description: "Button text confirming opening a new browser tab."
|
|
1060
|
+
},
|
|
1061
|
+
cancel: {
|
|
1062
|
+
id: "df.wise.ExternalConfirmation.cancel",
|
|
1063
|
+
defaultMessage: "Cancel",
|
|
1064
|
+
description: "Button text rejecting opening a new browser tab."
|
|
1065
|
+
}
|
|
1066
|
+
});
|
|
1067
|
+
|
|
1068
|
+
// ../renderers/src/ExternalConfirmationRenderer.tsx
|
|
1069
|
+
var import_react_intl9 = require("react-intl");
|
|
1070
|
+
var import_react4 = require("react");
|
|
1071
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
1072
|
+
var ExternalConfirmationRenderer = {
|
|
1073
|
+
canRenderType: "external-confirmation",
|
|
1074
|
+
render: ExternalConfirmationRendererComponent
|
|
1075
|
+
};
|
|
1076
|
+
function ExternalConfirmationRendererComponent({
|
|
1077
|
+
url,
|
|
1078
|
+
status,
|
|
1079
|
+
onSuccess,
|
|
1080
|
+
onFailure,
|
|
1081
|
+
onCancel
|
|
1082
|
+
}) {
|
|
1083
|
+
const { formatMessage } = (0, import_react_intl9.useIntl)();
|
|
1084
|
+
(0, import_react4.useEffect)(() => {
|
|
1085
|
+
if (url) {
|
|
1086
|
+
const w = window.open(url, "_blank");
|
|
1087
|
+
if (w) {
|
|
1088
|
+
onSuccess();
|
|
1089
|
+
} else {
|
|
1090
|
+
onFailure();
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
}, []);
|
|
1094
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
1095
|
+
import_components15.Modal,
|
|
1096
|
+
{
|
|
1097
|
+
open: status === "failure",
|
|
1098
|
+
title: formatMessage(external_confirmation_messages_default.title),
|
|
1099
|
+
body: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_jsx_runtime28.Fragment, { children: [
|
|
1100
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_components15.Markdown, { config: { link: { target: "_blank" } }, className: "text-xs-center m-b-5", children: formatMessage(external_confirmation_messages_default.description, { origin: getOrigin(url) }) }),
|
|
1101
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "df-box-renderer-fixed-width", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "df-box-renderer-width-lg", children: [
|
|
1102
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
1103
|
+
import_components15.Button,
|
|
1104
|
+
{
|
|
1105
|
+
v2: true,
|
|
1106
|
+
block: true,
|
|
1107
|
+
className: "m-b-2",
|
|
1108
|
+
priority: "primary",
|
|
1109
|
+
size: "md",
|
|
1110
|
+
onClick: () => {
|
|
1111
|
+
window.open(url);
|
|
1112
|
+
onCancel();
|
|
1113
|
+
},
|
|
1114
|
+
children: formatMessage(external_confirmation_messages_default.open)
|
|
1115
|
+
}
|
|
1116
|
+
),
|
|
1117
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_components15.Button, { v2: true, block: true, className: "m-b-2", priority: "tertiary", size: "md", onClick: onCancel, children: formatMessage(external_confirmation_messages_default.cancel) })
|
|
1118
|
+
] }) })
|
|
1119
|
+
] }),
|
|
1120
|
+
onClose: onCancel
|
|
1121
|
+
}
|
|
1122
|
+
);
|
|
1123
|
+
}
|
|
1124
|
+
function getOrigin(url) {
|
|
1125
|
+
try {
|
|
1126
|
+
return new URL(url).origin;
|
|
1127
|
+
} catch (e) {
|
|
1128
|
+
return url;
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
var ExternalConfirmationRenderer_default = ExternalConfirmationRenderer;
|
|
1132
|
+
|
|
1133
|
+
// ../renderers/src/FormRenderer.tsx
|
|
1134
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
1135
|
+
var FormRenderer = {
|
|
1136
|
+
canRenderType: "form",
|
|
1137
|
+
render: ({ children, margin }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: getMargin(margin), children })
|
|
1138
|
+
};
|
|
1139
|
+
var FormRenderer_default = FormRenderer;
|
|
1140
|
+
|
|
1141
|
+
// ../renderers/src/FormSectionRenderer.tsx
|
|
1142
|
+
var import_components16 = require("@transferwise/components");
|
|
1143
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
1144
|
+
var FormSectionRenderer = {
|
|
1145
|
+
canRenderType: "form-section",
|
|
1146
|
+
render: ({ title, description, children }) => /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("fieldset", { children: [
|
|
1147
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
1148
|
+
import_components16.Header,
|
|
1149
|
+
{
|
|
1150
|
+
as: "h2",
|
|
1151
|
+
title
|
|
1152
|
+
}
|
|
1153
|
+
),
|
|
1154
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("p", { children: description }),
|
|
1155
|
+
children
|
|
1156
|
+
] })
|
|
1157
|
+
};
|
|
1158
|
+
var FormSectionRenderer_default = FormSectionRenderer;
|
|
1159
|
+
|
|
1160
|
+
// ../renderers/src/HeadingRenderer.tsx
|
|
1161
|
+
var import_components17 = require("@transferwise/components");
|
|
1162
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
1163
|
+
var HeadingRenderer = {
|
|
1164
|
+
canRenderType: "heading",
|
|
1165
|
+
render: (props) => /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Heading, __spreadValues({}, props))
|
|
1166
|
+
};
|
|
1167
|
+
function Heading(props) {
|
|
1168
|
+
const { text, size, align, margin, control } = props;
|
|
1169
|
+
const className = getTextAlignmentAndMargin({ align, margin });
|
|
1170
|
+
return control === "display" ? /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(DisplayHeading, { size, text, className }) : /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(StandardHeading, { size, text, className });
|
|
1171
|
+
}
|
|
1172
|
+
function DisplayHeading({ size, text, className }) {
|
|
1173
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_components17.Display, { type: getDisplayType(size), className, children: text });
|
|
1174
|
+
}
|
|
1175
|
+
var getDisplayType = (size) => {
|
|
1176
|
+
switch (size) {
|
|
1177
|
+
case "xs":
|
|
1178
|
+
case "sm":
|
|
1179
|
+
return "display-small";
|
|
1180
|
+
case "xl":
|
|
1181
|
+
case "lg":
|
|
1182
|
+
return "display-large";
|
|
1183
|
+
case "md":
|
|
1184
|
+
default:
|
|
1185
|
+
return "display-medium";
|
|
1186
|
+
}
|
|
1187
|
+
};
|
|
1188
|
+
function StandardHeading({ size, text, className }) {
|
|
1189
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_components17.Title, { type: getTitleTypeBySize(size), className, children: text });
|
|
1190
|
+
}
|
|
1191
|
+
var getTitleTypeBySize = (size) => {
|
|
1192
|
+
var _a;
|
|
1193
|
+
const titleTypes = {
|
|
1194
|
+
xs: "title-group",
|
|
1195
|
+
sm: "title-body",
|
|
1196
|
+
md: "title-subsection",
|
|
1197
|
+
lg: "title-section",
|
|
1198
|
+
xl: "title-screen"
|
|
1199
|
+
};
|
|
1200
|
+
return (_a = titleTypes[size]) != null ? _a : "title-subsection";
|
|
1201
|
+
};
|
|
1202
|
+
var HeadingRenderer_default = HeadingRenderer;
|
|
1203
|
+
|
|
1204
|
+
// ../renderers/src/ImageRenderer/UrlImage.tsx
|
|
1205
|
+
var import_components18 = require("@transferwise/components");
|
|
1206
|
+
var import_react5 = require("react");
|
|
1207
|
+
|
|
1208
|
+
// ../renderers/src/utils/api-utils.ts
|
|
1209
|
+
function isRelativePath(url = "") {
|
|
1210
|
+
return !["https://", "http://", "data:"].some(
|
|
1211
|
+
(prefix) => url.startsWith(prefix) && url.length > prefix.length
|
|
1212
|
+
);
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
// ../renderers/src/ImageRenderer/UrlImage.tsx
|
|
1216
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
1217
|
+
function UrlImage({
|
|
1218
|
+
accessibilityDescription,
|
|
1219
|
+
align,
|
|
1220
|
+
margin,
|
|
1221
|
+
size,
|
|
1222
|
+
uri,
|
|
1223
|
+
httpClient
|
|
1224
|
+
}) {
|
|
1225
|
+
const [imageSource, setImageSource] = (0, import_react5.useState)("");
|
|
1226
|
+
(0, import_react5.useEffect)(() => {
|
|
1227
|
+
if (!uri.startsWith("urn:")) {
|
|
1228
|
+
void getImageSource(httpClient, uri).then(setImageSource);
|
|
1229
|
+
}
|
|
1230
|
+
}, [uri, httpClient]);
|
|
1231
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: `df-image ${align} ${size || "md"}`, children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
1232
|
+
import_components18.Image,
|
|
1233
|
+
{
|
|
1234
|
+
className: `img-responsive ${getMargin(margin)}`,
|
|
1235
|
+
alt: accessibilityDescription != null ? accessibilityDescription : "",
|
|
1236
|
+
src: imageSource,
|
|
1237
|
+
stretch: true,
|
|
1238
|
+
shrink: true
|
|
1239
|
+
}
|
|
1240
|
+
) });
|
|
1241
|
+
}
|
|
1242
|
+
var readImageBlobAsDataURL = async (imageBlob) => (
|
|
1243
|
+
// we can safely assume the type of reader.result is string
|
|
1244
|
+
// because we're calling reader.readAsDataURL
|
|
1245
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/FileReader/result
|
|
1246
|
+
new Promise((resolve, reject) => {
|
|
1247
|
+
const reader = new FileReader();
|
|
1248
|
+
reader.addEventListener("loadend", () => resolve(reader.result));
|
|
1249
|
+
reader.addEventListener("error", reject);
|
|
1250
|
+
reader.readAsDataURL(imageBlob);
|
|
1251
|
+
})
|
|
1252
|
+
);
|
|
1253
|
+
var getImageSource = async (httpClient, imageUrl) => {
|
|
1254
|
+
var _a;
|
|
1255
|
+
try {
|
|
1256
|
+
if (isRelativePath(imageUrl) || (imageUrl == null ? void 0 : imageUrl.startsWith(`${(_a = window == null ? void 0 : window.location) == null ? void 0 : _a.origin}/`))) {
|
|
1257
|
+
return await httpClient(imageUrl, {
|
|
1258
|
+
method: "GET",
|
|
1259
|
+
headers: { "Content-Type": "image/image" },
|
|
1260
|
+
credentials: "same-origin"
|
|
1261
|
+
}).then(async (response) => {
|
|
1262
|
+
if (response.ok) {
|
|
1263
|
+
return response.blob();
|
|
1264
|
+
}
|
|
1265
|
+
throw new Error("Image fetching failed");
|
|
1266
|
+
}).then(readImageBlobAsDataURL).catch(() => imageUrl);
|
|
1267
|
+
}
|
|
1268
|
+
return imageUrl;
|
|
1269
|
+
} catch (e) {
|
|
1270
|
+
return imageUrl;
|
|
1271
|
+
}
|
|
1272
|
+
};
|
|
1273
|
+
|
|
1274
|
+
// ../renderers/src/ImageRenderer/UrnFlagImage.tsx
|
|
1275
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
1276
|
+
var maxFlagSize = 600;
|
|
1277
|
+
function UrnFlagImage({
|
|
1278
|
+
accessibilityDescription,
|
|
1279
|
+
align,
|
|
1280
|
+
margin,
|
|
1281
|
+
size,
|
|
1282
|
+
uri
|
|
1283
|
+
}) {
|
|
1284
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: `df-image ${align} ${size || "md"} ${getMargin(margin)}`, children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(UrnFlag, { size: maxFlagSize, urn: uri, accessibilityDescription }) });
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1287
|
+
// ../renderers/src/ImageRenderer/UrnIllustration.tsx
|
|
1288
|
+
var import_art4 = require("@wise/art");
|
|
1289
|
+
var import_react7 = require("react");
|
|
1290
|
+
|
|
1291
|
+
// ../renderers/src/ImageRenderer/isAnimated.ts
|
|
1292
|
+
var isAnimated = (uri) => {
|
|
1293
|
+
var _a;
|
|
1294
|
+
const { rComponents } = stringToURN(uri);
|
|
1295
|
+
return (_a = rComponents == null ? void 0 : rComponents.some(([key, value]) => key === "type" && value === "animated")) != null ? _a : false;
|
|
1296
|
+
};
|
|
1297
|
+
|
|
1298
|
+
// ../renderers/src/ImageRenderer/SafeIllustration3D.tsx
|
|
1299
|
+
var import_art3 = require("@wise/art");
|
|
1300
|
+
var import_react6 = require("react");
|
|
1301
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
1302
|
+
var Illustration3DErrorBoundary = class extends import_react6.Component {
|
|
1303
|
+
constructor(props) {
|
|
1304
|
+
super(props);
|
|
1305
|
+
this.state = { hasError: false };
|
|
1306
|
+
}
|
|
1307
|
+
static getDerivedStateFromError() {
|
|
1308
|
+
return { hasError: true };
|
|
1309
|
+
}
|
|
1310
|
+
componentDidCatch() {
|
|
1311
|
+
this.props.onError();
|
|
1312
|
+
}
|
|
1313
|
+
render() {
|
|
1314
|
+
if (this.state.hasError) {
|
|
1315
|
+
return null;
|
|
1316
|
+
}
|
|
1317
|
+
return this.props.children;
|
|
1318
|
+
}
|
|
1319
|
+
};
|
|
1320
|
+
var SafeIllustration3D = ({
|
|
1321
|
+
name,
|
|
1322
|
+
size,
|
|
1323
|
+
onError
|
|
1324
|
+
}) => {
|
|
1325
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Illustration3DErrorBoundary, { onError, children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_art3.Illustration3D, { name, size }) });
|
|
1326
|
+
};
|
|
1327
|
+
var SafeIllustration3D_default = SafeIllustration3D;
|
|
1328
|
+
|
|
1329
|
+
// ../renderers/src/ImageRenderer/UrnIllustration.tsx
|
|
1330
|
+
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
1331
|
+
var urnPrefix = "urn:wise:illustrations:";
|
|
1332
|
+
var isUrnIllustration = (uri) => uri.startsWith(urnPrefix);
|
|
1333
|
+
function UrnIllustration({
|
|
1334
|
+
accessibilityDescription,
|
|
1335
|
+
align,
|
|
1336
|
+
margin,
|
|
1337
|
+
size,
|
|
1338
|
+
uri
|
|
1339
|
+
}) {
|
|
1340
|
+
const [has3DFailed, setHas3DFailed] = (0, import_react7.useState)(false);
|
|
1341
|
+
const illustrationSize = getIllustrationSize(size);
|
|
1342
|
+
const illustrationName = getIllustrationName(uri);
|
|
1343
|
+
const illustration3DName = getIllustration3DName(uri);
|
|
1344
|
+
if (illustration3DName && isAnimated(uri) && !has3DFailed) {
|
|
1345
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: `df-image ${align} ${getMargin(margin)}`, children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
1346
|
+
SafeIllustration3D_default,
|
|
1347
|
+
{
|
|
1348
|
+
name: illustration3DName,
|
|
1349
|
+
size: illustrationSize,
|
|
1350
|
+
onError: () => setHas3DFailed(true)
|
|
1351
|
+
}
|
|
1352
|
+
) });
|
|
1353
|
+
}
|
|
1354
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: `df-image ${align} ${getMargin(margin)}`, children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
1355
|
+
import_art4.Illustration,
|
|
1356
|
+
{
|
|
1357
|
+
className: "df-illustration",
|
|
1358
|
+
name: illustrationName,
|
|
1359
|
+
size: illustrationSize,
|
|
1360
|
+
alt: accessibilityDescription
|
|
1361
|
+
}
|
|
1362
|
+
) });
|
|
1363
|
+
}
|
|
1364
|
+
var getIllustrationSize = (size) => ({ xs: "small", sm: "small", md: "medium", lg: "large", xl: "large" })[size] || "medium";
|
|
1365
|
+
var getIllustrationName = (uri) => {
|
|
1366
|
+
return uri.replace(urnPrefix, "").split("?")[0];
|
|
1367
|
+
};
|
|
1368
|
+
var getIllustration3DName = (uri) => {
|
|
1369
|
+
const illustrationName = getIllustrationName(uri);
|
|
1370
|
+
return (0, import_art4.isIllustrationSupport3D)(illustrationName) ? illustrationName : null;
|
|
1371
|
+
};
|
|
1372
|
+
|
|
1373
|
+
// ../renderers/src/ImageRenderer/UrnImage.tsx
|
|
1374
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
1375
|
+
var isUrnImage = (uri) => uri.startsWith("urn:");
|
|
1376
|
+
function UrnImage(props) {
|
|
1377
|
+
const { uri } = props;
|
|
1378
|
+
if (isUrnIllustration(uri)) {
|
|
1379
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(UrnIllustration, __spreadValues({}, props));
|
|
1380
|
+
}
|
|
1381
|
+
if (isUrnFlag(uri)) {
|
|
1382
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(UrnFlagImage, __spreadValues({}, props));
|
|
1383
|
+
}
|
|
1384
|
+
return null;
|
|
1385
|
+
}
|
|
1386
|
+
|
|
1387
|
+
// ../renderers/src/ImageRenderer/ImageRenderer.tsx
|
|
1388
|
+
var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
1389
|
+
var ImageRenderer = {
|
|
1390
|
+
canRenderType: "image",
|
|
1391
|
+
render: (props) => isUrnImage(props.uri) ? /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(UrnImage, __spreadValues({}, props)) : /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(UrlImage, __spreadValues({}, props))
|
|
1392
|
+
};
|
|
1393
|
+
|
|
1394
|
+
// ../renderers/src/ImageRenderer/index.tsx
|
|
1395
|
+
var ImageRenderer_default = ImageRenderer;
|
|
1396
|
+
|
|
1397
|
+
// ../renderers/src/InstructionsRenderer.tsx
|
|
1398
|
+
var import_components19 = require("@transferwise/components");
|
|
1399
|
+
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
1400
|
+
var doContext = ["positive", "neutral"];
|
|
1401
|
+
var dontContext = ["warning", "negative"];
|
|
1402
|
+
var InstructionsRenderer = {
|
|
1403
|
+
canRenderType: "instructions",
|
|
1404
|
+
render: ({ items, margin, title }) => {
|
|
1405
|
+
const dos = items.filter((item) => doContext.includes(item.context)).map(({ text }) => text);
|
|
1406
|
+
const donts = items.filter((item) => dontContext.includes(item.context)).map(({ text }) => text);
|
|
1407
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: getMargin(margin), children: [
|
|
1408
|
+
title ? /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_components19.Header, { title }) : null,
|
|
1409
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_components19.InstructionsList, { dos, donts })
|
|
1410
|
+
] });
|
|
1411
|
+
}
|
|
1412
|
+
};
|
|
1413
|
+
var InstructionsRenderer_default = InstructionsRenderer;
|
|
1414
|
+
|
|
1415
|
+
// ../renderers/src/IntegerInputRenderer.tsx
|
|
1416
|
+
var import_components20 = require("@transferwise/components");
|
|
1417
|
+
|
|
1418
|
+
// ../renderers/src/utils/input-utils.ts
|
|
1419
|
+
var onWheel = (event) => {
|
|
1420
|
+
if (event.target instanceof HTMLElement) {
|
|
1421
|
+
event.target.blur();
|
|
1422
|
+
}
|
|
1423
|
+
};
|
|
1424
|
+
|
|
1425
|
+
// ../renderers/src/utils/getInputGroupAddonStart.tsx
|
|
1426
|
+
var getInputGroupAddonStart = (media) => {
|
|
1427
|
+
const content = getInlineMedia(media);
|
|
1428
|
+
return content ? { content } : void 0;
|
|
1429
|
+
};
|
|
1430
|
+
|
|
1431
|
+
// ../renderers/src/utils/pick.ts
|
|
1432
|
+
function pick(obj, ...keys) {
|
|
1433
|
+
const result = {};
|
|
1434
|
+
keys.forEach((key) => {
|
|
1435
|
+
result[key] = obj[key];
|
|
1436
|
+
});
|
|
1437
|
+
return result;
|
|
1438
|
+
}
|
|
1439
|
+
|
|
1440
|
+
// ../renderers/src/IntegerInputRenderer.tsx
|
|
1441
|
+
var import_jsx_runtime39 = require("react/jsx-runtime");
|
|
1442
|
+
var IntegerInputRenderer = {
|
|
1443
|
+
canRenderType: "input-integer",
|
|
1444
|
+
render: (props) => {
|
|
1445
|
+
const { id, title, description, help, media, validationState, value, onChange } = props;
|
|
1446
|
+
const commonProps = pick(
|
|
1447
|
+
props,
|
|
1448
|
+
"autoComplete",
|
|
1449
|
+
"disabled",
|
|
1450
|
+
"onBlur",
|
|
1451
|
+
"onFocus",
|
|
1452
|
+
"placeholder",
|
|
1453
|
+
"maximum",
|
|
1454
|
+
"minimum"
|
|
1455
|
+
);
|
|
1456
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
1457
|
+
FieldInput_default,
|
|
1458
|
+
{
|
|
1459
|
+
id,
|
|
1460
|
+
label: title,
|
|
1461
|
+
description,
|
|
1462
|
+
validation: validationState,
|
|
1463
|
+
help,
|
|
1464
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_components20.InputGroup, { addonStart: getInputGroupAddonStart(media), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
1465
|
+
import_components20.Input,
|
|
1466
|
+
__spreadValues({
|
|
1467
|
+
id,
|
|
1468
|
+
name: id,
|
|
1469
|
+
type: "number",
|
|
1470
|
+
step: "1",
|
|
1471
|
+
pattern: "\\d+",
|
|
1472
|
+
value: value != null ? value : "",
|
|
1473
|
+
onChange: ({ target: { value: newValue } }) => {
|
|
1474
|
+
const parsedValue = Number.parseInt(newValue, 10);
|
|
1475
|
+
onChange(Number.isNaN(parsedValue) ? null : parsedValue);
|
|
1476
|
+
},
|
|
1477
|
+
onWheel
|
|
1478
|
+
}, commonProps)
|
|
1479
|
+
) })
|
|
1480
|
+
}
|
|
1481
|
+
);
|
|
1482
|
+
}
|
|
1483
|
+
};
|
|
1484
|
+
var IntegerInputRenderer_default = IntegerInputRenderer;
|
|
1485
|
+
|
|
1486
|
+
// ../renderers/src/ListRenderer.tsx
|
|
1487
|
+
var import_components21 = require("@transferwise/components");
|
|
1488
|
+
var import_classnames3 = __toESM(require("classnames"));
|
|
1489
|
+
var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
1490
|
+
var ListRenderer = {
|
|
1491
|
+
canRenderType: "list",
|
|
1492
|
+
render: ({ callToAction, control, margin, items, title }) => /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: getMargin(margin), children: [
|
|
1493
|
+
(title || callToAction) && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_components21.Header, { as: "h2", title: title != null ? title : "", action: getListAction(callToAction) }),
|
|
1494
|
+
items.map((props) => /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(DesignSystemListItem, __spreadProps(__spreadValues({}, props), { control }), props.title))
|
|
1495
|
+
] })
|
|
1496
|
+
};
|
|
1497
|
+
var DesignSystemListItem = ({
|
|
1498
|
+
title,
|
|
1499
|
+
description,
|
|
1500
|
+
supportingValues,
|
|
1501
|
+
icon,
|
|
1502
|
+
image,
|
|
1503
|
+
media,
|
|
1504
|
+
control,
|
|
1505
|
+
tag
|
|
1506
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
1507
|
+
"label",
|
|
1508
|
+
{
|
|
1509
|
+
className: (0, import_classnames3.default)("np-option p-a-2", {
|
|
1510
|
+
"np-option__sm-media": true,
|
|
1511
|
+
"np-option__container-aligned": true
|
|
1512
|
+
}),
|
|
1513
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "media", children: [
|
|
1514
|
+
icon || image || media ? /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: "media-left", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
1515
|
+
ListItemMedia,
|
|
1516
|
+
{
|
|
1517
|
+
icon,
|
|
1518
|
+
media,
|
|
1519
|
+
preferAvatar: control === "with-avatar" || tag === "with-avatar"
|
|
1520
|
+
}
|
|
1521
|
+
) }) : null,
|
|
1522
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "media-body", children: [
|
|
1523
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "d-flex justify-content-between", children: [
|
|
1524
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("h4", { className: "np-text-body-large-bold text-primary np-option__title", children: title }),
|
|
1525
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("h4", { className: "np-text-body-large-bold text-primary np-option__title", children: supportingValues == null ? void 0 : supportingValues.value })
|
|
1526
|
+
] }),
|
|
1527
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "d-flex justify-content-between", children: [
|
|
1528
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_components21.Body, { className: "d-block np-option__body", children: description }),
|
|
1529
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_components21.Body, { className: "d-block np-option__body", children: supportingValues == null ? void 0 : supportingValues.subvalue })
|
|
1530
|
+
] })
|
|
1531
|
+
] })
|
|
1532
|
+
] })
|
|
1533
|
+
},
|
|
1534
|
+
title
|
|
1535
|
+
);
|
|
1536
|
+
var ListItemMedia = ({
|
|
1537
|
+
icon,
|
|
1538
|
+
media,
|
|
1539
|
+
preferAvatar
|
|
1540
|
+
}) => {
|
|
1541
|
+
if (icon) {
|
|
1542
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: "circle circle-sm text-primary circle-inverse", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(OptionMedia, { media, preferAvatar }) });
|
|
1543
|
+
}
|
|
1544
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: "np-option__no-media-circle", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(OptionMedia, { media, preferAvatar }) });
|
|
1545
|
+
};
|
|
1546
|
+
var getListAction = (callToAction) => {
|
|
1547
|
+
if (callToAction) {
|
|
1548
|
+
return __spreadValues({
|
|
1549
|
+
"aria-label": callToAction.accessibilityDescription,
|
|
1550
|
+
text: callToAction.title,
|
|
1551
|
+
onClick: callToAction.onClick
|
|
1552
|
+
}, callToAction.type === "link" ? { href: callToAction.href, target: "_blank" } : {});
|
|
1553
|
+
}
|
|
1554
|
+
return void 0;
|
|
1555
|
+
};
|
|
1556
|
+
var ListRenderer_default = ListRenderer;
|
|
1557
|
+
|
|
1558
|
+
// ../renderers/src/LoadingIndicatorRenderer.tsx
|
|
1559
|
+
var import_components22 = require("@transferwise/components");
|
|
1560
|
+
var import_jsx_runtime41 = require("react/jsx-runtime");
|
|
1561
|
+
var LoadingIndicatorRenderer = {
|
|
1562
|
+
canRenderType: "loading-indicator",
|
|
1563
|
+
render: ({ margin, size }) => /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
1564
|
+
import_components22.Loader,
|
|
1565
|
+
{
|
|
1566
|
+
size,
|
|
1567
|
+
classNames: { "tw-loader": `tw-loader m-x-auto ${getMargin(margin)}` },
|
|
1568
|
+
"data-testid": "loading-indicator"
|
|
1569
|
+
}
|
|
1570
|
+
)
|
|
1571
|
+
};
|
|
1572
|
+
var LoadingIndicatorRenderer_default = LoadingIndicatorRenderer;
|
|
1573
|
+
|
|
1574
|
+
// ../renderers/src/MarkdownRenderer.tsx
|
|
1575
|
+
var import_components23 = require("@transferwise/components");
|
|
1576
|
+
var import_jsx_runtime42 = require("react/jsx-runtime");
|
|
1577
|
+
var MarkdownRenderer = {
|
|
1578
|
+
canRenderType: "markdown",
|
|
1579
|
+
render: ({ content, align, margin }) => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: getTextAlignmentAndMargin({ align, margin }), children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_components23.Markdown, { className: "np-text-body-large", config: { link: { target: "_blank" } }, children: content }) })
|
|
1580
|
+
};
|
|
1581
|
+
var MarkdownRenderer_default = MarkdownRenderer;
|
|
1582
|
+
|
|
1583
|
+
// ../renderers/src/ModalLayoutRenderer.tsx
|
|
1584
|
+
var import_components24 = require("@transferwise/components");
|
|
1585
|
+
var import_react8 = require("react");
|
|
1586
|
+
var import_jsx_runtime43 = require("react/jsx-runtime");
|
|
1587
|
+
var ModalLayoutRenderer = {
|
|
1588
|
+
canRenderType: "modal-layout",
|
|
1589
|
+
render: (props) => /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(DFModal, __spreadValues({}, props))
|
|
1590
|
+
};
|
|
1591
|
+
var ModalLayoutRenderer_default = ModalLayoutRenderer;
|
|
1592
|
+
function DFModal({ content, margin, trigger }) {
|
|
1593
|
+
const [visible, setVisible] = (0, import_react8.useState)(false);
|
|
1594
|
+
const { children, title } = content;
|
|
1595
|
+
return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: getMargin(margin), children: [
|
|
1596
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_components24.Button, { v2: true, priority: "tertiary", block: true, onClick: () => setVisible(true), children: trigger.title }),
|
|
1597
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
1598
|
+
import_components24.Modal,
|
|
1599
|
+
{
|
|
1600
|
+
scroll: "content",
|
|
1601
|
+
open: visible,
|
|
1602
|
+
size: "lg",
|
|
1603
|
+
title,
|
|
1604
|
+
body: children,
|
|
1605
|
+
onClose: () => setVisible(false)
|
|
1606
|
+
}
|
|
1607
|
+
)
|
|
1608
|
+
] });
|
|
1609
|
+
}
|
|
1610
|
+
|
|
1611
|
+
// ../renderers/src/ModalRenderer.tsx
|
|
1612
|
+
var import_components25 = require("@transferwise/components");
|
|
1613
|
+
var import_jsx_runtime44 = require("react/jsx-runtime");
|
|
1614
|
+
var ModalRenderer = {
|
|
1615
|
+
canRenderType: "modal",
|
|
1616
|
+
render: ({ title, children, open, onClose }) => {
|
|
1617
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_components25.Modal, { open, title, body: children, onClose });
|
|
1618
|
+
}
|
|
1619
|
+
};
|
|
1620
|
+
|
|
1621
|
+
// ../renderers/src/MultiSelectInputRenderer.tsx
|
|
1622
|
+
var import_components26 = require("@transferwise/components");
|
|
1623
|
+
var import_react9 = require("react");
|
|
1624
|
+
var import_react_intl11 = require("react-intl");
|
|
1625
|
+
|
|
1626
|
+
// ../renderers/src/messages/multi-select.messages.ts
|
|
1627
|
+
var import_react_intl10 = require("react-intl");
|
|
1628
|
+
var multi_select_messages_default = (0, import_react_intl10.defineMessages)({
|
|
1629
|
+
summary: {
|
|
1630
|
+
id: "df.wise.MultiSelect.summary",
|
|
1631
|
+
defaultMessage: "{first} and {count} more",
|
|
1632
|
+
description: "A summary of the multiple items selected. Showing the title of the first selected item, and the number of other items that have been selected."
|
|
1633
|
+
}
|
|
1634
|
+
});
|
|
1635
|
+
|
|
1636
|
+
// ../renderers/src/MultiSelectInputRenderer.tsx
|
|
1637
|
+
var import_jsx_runtime45 = require("react/jsx-runtime");
|
|
1638
|
+
var MultiSelectInputRenderer = {
|
|
1639
|
+
canRenderType: "input-multi-select",
|
|
1640
|
+
render: (props) => /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(MultiSelectInputRendererComponent, __spreadValues({}, props))
|
|
1641
|
+
};
|
|
1642
|
+
function MultiSelectInputRendererComponent(props) {
|
|
1643
|
+
const { formatMessage } = (0, import_react_intl11.useIntl)();
|
|
1644
|
+
const [stagedIndices, setStagedIndices] = (0, import_react9.useState)();
|
|
1645
|
+
const {
|
|
1646
|
+
id,
|
|
1647
|
+
autoComplete,
|
|
1648
|
+
description,
|
|
1649
|
+
disabled,
|
|
1650
|
+
help,
|
|
1651
|
+
options,
|
|
1652
|
+
placeholder,
|
|
1653
|
+
selectedIndices,
|
|
1654
|
+
title,
|
|
1655
|
+
validationState,
|
|
1656
|
+
onSelect
|
|
1657
|
+
} = props;
|
|
1658
|
+
const mergedIndices = stagedIndices != null ? stagedIndices : selectedIndices;
|
|
1659
|
+
const getFormattedMessage = () => {
|
|
1660
|
+
if (mergedIndices.length > 0) {
|
|
1661
|
+
if (mergedIndices.length > 1) {
|
|
1662
|
+
return formatMessage(multi_select_messages_default.summary, {
|
|
1663
|
+
first: options[mergedIndices[0]].title,
|
|
1664
|
+
count: mergedIndices.length - 1
|
|
1665
|
+
});
|
|
1666
|
+
}
|
|
1667
|
+
return options[mergedIndices[0]].title;
|
|
1668
|
+
}
|
|
1669
|
+
return void 0;
|
|
1670
|
+
};
|
|
1671
|
+
const renderValue = (index, withinTrigger) => {
|
|
1672
|
+
const option = index >= 0 ? options[index] : null;
|
|
1673
|
+
if (option === null) {
|
|
1674
|
+
return null;
|
|
1675
|
+
}
|
|
1676
|
+
if (withinTrigger) {
|
|
1677
|
+
return index === mergedIndices[0] ? getFormattedMessage() : void 0;
|
|
1678
|
+
}
|
|
1679
|
+
const contentProps = {
|
|
1680
|
+
title: option.title,
|
|
1681
|
+
description: option.description,
|
|
1682
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(OptionMedia, { media: option.media, preferAvatar: false })
|
|
1683
|
+
};
|
|
1684
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_components26.SelectInputOptionContent, __spreadValues({}, contentProps));
|
|
1685
|
+
};
|
|
1686
|
+
const extraProps = { autoComplete };
|
|
1687
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
1688
|
+
FieldInput_default,
|
|
1689
|
+
{
|
|
1690
|
+
id,
|
|
1691
|
+
label: title,
|
|
1692
|
+
help,
|
|
1693
|
+
description,
|
|
1694
|
+
validation: validationState,
|
|
1695
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
1696
|
+
import_components26.SelectInput,
|
|
1697
|
+
__spreadValues({
|
|
1698
|
+
id,
|
|
1699
|
+
items: options.map((option, index) => {
|
|
1700
|
+
var _a, _b, _c;
|
|
1701
|
+
return {
|
|
1702
|
+
type: "option",
|
|
1703
|
+
value: index,
|
|
1704
|
+
filterMatchers: [
|
|
1705
|
+
...(_a = option.keywords) != null ? _a : [],
|
|
1706
|
+
(_b = option.title) != null ? _b : "",
|
|
1707
|
+
(_c = option.description) != null ? _c : ""
|
|
1708
|
+
],
|
|
1709
|
+
disabled: option.disabled
|
|
1710
|
+
};
|
|
1711
|
+
}),
|
|
1712
|
+
disabled,
|
|
1713
|
+
placeholder,
|
|
1714
|
+
value: mergedIndices,
|
|
1715
|
+
renderValue,
|
|
1716
|
+
multiple: true,
|
|
1717
|
+
filterable: options.length >= 8,
|
|
1718
|
+
onChange: (values) => {
|
|
1719
|
+
setStagedIndices(values);
|
|
1720
|
+
},
|
|
1721
|
+
onClose: () => {
|
|
1722
|
+
if (stagedIndices) {
|
|
1723
|
+
onSelect(stagedIndices);
|
|
1724
|
+
setStagedIndices(void 0);
|
|
1725
|
+
}
|
|
1726
|
+
}
|
|
1727
|
+
}, extraProps)
|
|
1728
|
+
)
|
|
1729
|
+
}
|
|
1730
|
+
);
|
|
1731
|
+
}
|
|
1732
|
+
var MultiSelectInputRenderer_default = MultiSelectInputRenderer;
|
|
1733
|
+
|
|
1734
|
+
// ../renderers/src/MultiUploadInputRenderer.tsx
|
|
1735
|
+
var import_components28 = require("@transferwise/components");
|
|
1736
|
+
|
|
1737
|
+
// ../renderers/src/components/UploadFieldInput.tsx
|
|
1738
|
+
var import_components27 = require("@transferwise/components");
|
|
1739
|
+
var import_classnames4 = __toESM(require("classnames"));
|
|
1740
|
+
var import_jsx_runtime46 = require("react/jsx-runtime");
|
|
1741
|
+
function UploadFieldInput({
|
|
1742
|
+
id,
|
|
1743
|
+
children,
|
|
1744
|
+
label,
|
|
1745
|
+
description,
|
|
1746
|
+
help,
|
|
1747
|
+
validation
|
|
1748
|
+
}) {
|
|
1749
|
+
const labelContent = label && help ? /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(LabelContentWithHelp, { text: label, help }) : label;
|
|
1750
|
+
const descriptionId = description ? `${id}-description` : void 0;
|
|
1751
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(
|
|
1752
|
+
"div",
|
|
1753
|
+
{
|
|
1754
|
+
className: (0, import_classnames4.default)("form-group d-block", {
|
|
1755
|
+
"has-error": (validation == null ? void 0 : validation.status) === "invalid"
|
|
1756
|
+
}),
|
|
1757
|
+
children: [
|
|
1758
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("label", { htmlFor: id, className: "control-label", children: labelContent }),
|
|
1759
|
+
children,
|
|
1760
|
+
(validation == null ? void 0 : validation.status) === "invalid" && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_components27.InlineAlert, { type: "negative", id: descriptionId, children: validation.message })
|
|
1761
|
+
]
|
|
1762
|
+
}
|
|
1763
|
+
);
|
|
1764
|
+
}
|
|
1765
|
+
var UploadFieldInput_default = UploadFieldInput;
|
|
1766
|
+
|
|
1767
|
+
// ../renderers/src/utils/file-utils.ts
|
|
1768
|
+
var acceptsToFileTypes = (accepts) => Array.isArray(accepts) && accepts.length >= 1 ? accepts : "*";
|
|
1769
|
+
var toKilobytes = (sizeInBytes) => {
|
|
1770
|
+
const ONE_KB_IN_BYTES = 1024;
|
|
1771
|
+
return Math.floor(sizeInBytes / ONE_KB_IN_BYTES);
|
|
1772
|
+
};
|
|
1773
|
+
var toFile = async (base64Url, name) => {
|
|
1774
|
+
const type = getFileType(base64Url);
|
|
1775
|
+
const blob = await toBlob(base64Url);
|
|
1776
|
+
return new File([blob], name, { type });
|
|
1777
|
+
};
|
|
1778
|
+
var toBlob = async (base64Url) => (await fetch(base64Url)).blob();
|
|
1779
|
+
var getFileType = (base64Url) => {
|
|
1780
|
+
const contentTypeRegex = /^data:(.+);/;
|
|
1781
|
+
const matches = contentTypeRegex.exec(base64Url);
|
|
1782
|
+
if (matches && matches.length > 1) {
|
|
1783
|
+
return matches[1];
|
|
1784
|
+
}
|
|
1785
|
+
return void 0;
|
|
1786
|
+
};
|
|
1787
|
+
var getSizeLimit = (maxSize) => {
|
|
1788
|
+
if (maxSize === void 0) {
|
|
1789
|
+
return null;
|
|
1790
|
+
}
|
|
1791
|
+
return toKilobytes(maxSize);
|
|
1792
|
+
};
|
|
1793
|
+
|
|
1794
|
+
// ../renderers/src/MultiUploadInputRenderer.tsx
|
|
1795
|
+
var import_jsx_runtime47 = require("react/jsx-runtime");
|
|
1796
|
+
var MultiUploadInputRenderer = {
|
|
1797
|
+
canRenderType: "input-upload-multi",
|
|
1798
|
+
render: (props) => {
|
|
1799
|
+
const {
|
|
1800
|
+
id,
|
|
1801
|
+
accepts,
|
|
1802
|
+
help,
|
|
1803
|
+
title,
|
|
1804
|
+
description,
|
|
1805
|
+
disabled,
|
|
1806
|
+
maxSize,
|
|
1807
|
+
maxItems,
|
|
1808
|
+
uploadLabel,
|
|
1809
|
+
validationState,
|
|
1810
|
+
value,
|
|
1811
|
+
onInsertFile,
|
|
1812
|
+
onRemoveFile
|
|
1813
|
+
} = props;
|
|
1814
|
+
const onUploadFile = async (formData) => {
|
|
1815
|
+
const file = formData.get("file");
|
|
1816
|
+
return onInsertFile(value.length, file).then((newId) => ({ id: newId }));
|
|
1817
|
+
};
|
|
1818
|
+
const onDeleteFile = async (fileId) => onRemoveFile(value.findIndex((file) => file.id === fileId));
|
|
1819
|
+
const descriptionId = description ? `${id}-description` : void 0;
|
|
1820
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
1821
|
+
UploadFieldInput_default,
|
|
1822
|
+
{
|
|
1823
|
+
id,
|
|
1824
|
+
label: title,
|
|
1825
|
+
description,
|
|
1826
|
+
validation: validationState,
|
|
1827
|
+
help,
|
|
1828
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
1829
|
+
import_components28.UploadInput,
|
|
1830
|
+
{
|
|
1831
|
+
id,
|
|
1832
|
+
"aria-describedby": descriptionId,
|
|
1833
|
+
description,
|
|
1834
|
+
disabled,
|
|
1835
|
+
fileTypes: acceptsToFileTypes(accepts),
|
|
1836
|
+
maxFiles: maxItems,
|
|
1837
|
+
multiple: true,
|
|
1838
|
+
sizeLimit: getSizeLimit(maxSize),
|
|
1839
|
+
uploadButtonTitle: uploadLabel,
|
|
1840
|
+
onDeleteFile,
|
|
1841
|
+
onUploadFile
|
|
1842
|
+
}
|
|
1843
|
+
)
|
|
1844
|
+
}
|
|
1845
|
+
);
|
|
1846
|
+
}
|
|
1847
|
+
};
|
|
1848
|
+
var MultiUploadInputRenderer_default = MultiUploadInputRenderer;
|
|
1849
|
+
|
|
1850
|
+
// ../renderers/src/NumberInputRenderer.tsx
|
|
1851
|
+
var import_components29 = require("@transferwise/components");
|
|
1852
|
+
var import_jsx_runtime48 = require("react/jsx-runtime");
|
|
1853
|
+
var NumberInputRenderer = {
|
|
1854
|
+
canRenderType: "input-number",
|
|
1855
|
+
render: (props) => {
|
|
1856
|
+
const { id, title, description, help, media, validationState, value, onChange } = props;
|
|
1857
|
+
const commonProps = pick(
|
|
1858
|
+
props,
|
|
1859
|
+
"disabled",
|
|
1860
|
+
"onBlur",
|
|
1861
|
+
"onFocus",
|
|
1862
|
+
"placeholder",
|
|
1863
|
+
"maximum",
|
|
1864
|
+
"minimum"
|
|
1865
|
+
);
|
|
1866
|
+
return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
1867
|
+
FieldInput_default,
|
|
1868
|
+
{
|
|
1869
|
+
id,
|
|
1870
|
+
label: title,
|
|
1871
|
+
description,
|
|
1872
|
+
validation: validationState,
|
|
1873
|
+
help,
|
|
1874
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_components29.InputGroup, { addonStart: getInputGroupAddonStart(media), children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
1875
|
+
import_components29.Input,
|
|
1876
|
+
__spreadValues({
|
|
1877
|
+
id,
|
|
1878
|
+
name: id,
|
|
1879
|
+
type: "number",
|
|
1880
|
+
value: value != null ? value : "",
|
|
1881
|
+
onChange: ({ target: { value: newValue } }) => {
|
|
1882
|
+
const parsedValue = Number.parseFloat(newValue);
|
|
1883
|
+
onChange(Number.isNaN(parsedValue) ? null : parsedValue);
|
|
1884
|
+
},
|
|
1885
|
+
onWheel
|
|
1886
|
+
}, commonProps)
|
|
1887
|
+
) })
|
|
1888
|
+
}
|
|
1889
|
+
);
|
|
32
1890
|
}
|
|
33
|
-
return to;
|
|
34
1891
|
};
|
|
35
|
-
var
|
|
1892
|
+
var NumberInputRenderer_default = NumberInputRenderer;
|
|
36
1893
|
|
|
37
|
-
// src/
|
|
38
|
-
var
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
1894
|
+
// ../renderers/src/ParagraphRenderer.tsx
|
|
1895
|
+
var import_react_intl13 = require("react-intl");
|
|
1896
|
+
|
|
1897
|
+
// ../renderers/src/hooks/useSnackBarIfAvailable.ts
|
|
1898
|
+
var import_components30 = require("@transferwise/components");
|
|
1899
|
+
var import_react10 = require("react");
|
|
1900
|
+
function useSnackBarIfAvailable() {
|
|
1901
|
+
const context = (0, import_react10.useContext)(import_components30.SnackbarContext);
|
|
1902
|
+
return context ? context.createSnackbar : () => {
|
|
1903
|
+
};
|
|
1904
|
+
}
|
|
1905
|
+
|
|
1906
|
+
// ../renderers/src/ParagraphRenderer.tsx
|
|
1907
|
+
var import_components31 = require("@transferwise/components");
|
|
1908
|
+
var import_classnames5 = __toESM(require("classnames"));
|
|
1909
|
+
|
|
1910
|
+
// ../renderers/src/messages/paragraph.messages.ts
|
|
1911
|
+
var import_react_intl12 = require("react-intl");
|
|
1912
|
+
var paragraph_messages_default = (0, import_react_intl12.defineMessages)({
|
|
1913
|
+
copy: {
|
|
1914
|
+
id: "df.wise.DynamicParagraph.copy",
|
|
1915
|
+
defaultMessage: "Copy",
|
|
1916
|
+
description: "Copy to clipboard button label."
|
|
1917
|
+
},
|
|
1918
|
+
copied: {
|
|
1919
|
+
id: "df.wise.DynamicParagraph.copied",
|
|
1920
|
+
defaultMessage: "Copied to clipboard",
|
|
1921
|
+
description: "Appears in a snackbar when the copy operation succeeds."
|
|
1922
|
+
}
|
|
52
1923
|
});
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
var
|
|
56
|
-
var
|
|
1924
|
+
|
|
1925
|
+
// ../renderers/src/ParagraphRenderer.tsx
|
|
1926
|
+
var import_jsx_runtime49 = require("react/jsx-runtime");
|
|
1927
|
+
var ParagraphRenderer = {
|
|
1928
|
+
canRenderType: "paragraph",
|
|
1929
|
+
render: (props) => /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Paragraph, __spreadValues({}, props))
|
|
1930
|
+
};
|
|
1931
|
+
function Paragraph({ align, control, margin, text }) {
|
|
1932
|
+
const className = getTextAlignmentAndMargin({ align, margin });
|
|
1933
|
+
return control === "copyable" ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(CopyableParagraph, { className, align, text }) : /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(StandardParagraph, { className, text });
|
|
1934
|
+
}
|
|
1935
|
+
function StandardParagraph({ text, className }) {
|
|
1936
|
+
return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("p", { className: `np-text-body-large ${className}`, children: text });
|
|
1937
|
+
}
|
|
1938
|
+
function CopyableParagraph({
|
|
1939
|
+
text,
|
|
1940
|
+
align,
|
|
1941
|
+
className
|
|
1942
|
+
}) {
|
|
1943
|
+
const { formatMessage } = (0, import_react_intl13.useIntl)();
|
|
1944
|
+
const createSnackbar = useSnackBarIfAvailable();
|
|
1945
|
+
const copy = () => {
|
|
1946
|
+
navigator.clipboard.writeText(text).then(() => createSnackbar({ text: formatMessage(paragraph_messages_default.copied) })).catch(() => {
|
|
1947
|
+
});
|
|
1948
|
+
};
|
|
1949
|
+
const inputAlignmentClasses = getTextAlignmentAndMargin({ align, margin: "sm" });
|
|
1950
|
+
return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className, children: [
|
|
1951
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
1952
|
+
import_components31.Input,
|
|
1953
|
+
{
|
|
1954
|
+
type: "text",
|
|
1955
|
+
value: text,
|
|
1956
|
+
readOnly: true,
|
|
1957
|
+
className: (0, import_classnames5.default)("text-ellipsis", inputAlignmentClasses)
|
|
1958
|
+
}
|
|
1959
|
+
),
|
|
1960
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_components31.Button, { v2: true, block: true, onClick: copy, children: formatMessage(paragraph_messages_default.copy) })
|
|
1961
|
+
] });
|
|
1962
|
+
}
|
|
1963
|
+
var ParagraphRenderer_default = ParagraphRenderer;
|
|
1964
|
+
|
|
1965
|
+
// ../renderers/src/RepeatableRenderer.tsx
|
|
1966
|
+
var import_components32 = require("@transferwise/components");
|
|
1967
|
+
var import_icons = require("@transferwise/icons");
|
|
1968
|
+
var import_classnames6 = __toESM(require("classnames"));
|
|
1969
|
+
var import_react11 = require("react");
|
|
1970
|
+
var import_react_intl15 = require("react-intl");
|
|
1971
|
+
|
|
1972
|
+
// ../renderers/src/messages/repeatable.messages.ts
|
|
1973
|
+
var import_react_intl14 = require("react-intl");
|
|
1974
|
+
var repeatable_messages_default = (0, import_react_intl14.defineMessages)({
|
|
1975
|
+
addItemTitle: {
|
|
1976
|
+
id: "df.wise.ArraySchema.addItemTitle",
|
|
1977
|
+
defaultMessage: "Add Item",
|
|
1978
|
+
description: "Label on the button used to open a form to add an item"
|
|
1979
|
+
},
|
|
1980
|
+
addItem: {
|
|
1981
|
+
id: "df.wise.ArraySchema.addItem",
|
|
1982
|
+
defaultMessage: "Save",
|
|
1983
|
+
description: "Label on the add button used to submit a form that adds an item"
|
|
1984
|
+
},
|
|
1985
|
+
editItem: {
|
|
1986
|
+
id: "df.wise.ArraySchema.editItem",
|
|
1987
|
+
defaultMessage: "Save",
|
|
1988
|
+
description: "Label on the edit button used to submit a form that edits an item"
|
|
1989
|
+
},
|
|
1990
|
+
removeItem: {
|
|
1991
|
+
id: "df.wise.ArraySchema.removeItem",
|
|
1992
|
+
defaultMessage: "Remove",
|
|
1993
|
+
description: "Label on the remove button used to confirm deletion of an item"
|
|
1994
|
+
}
|
|
1995
|
+
});
|
|
1996
|
+
|
|
1997
|
+
// ../renderers/src/RepeatableRenderer.tsx
|
|
1998
|
+
var import_jsx_runtime50 = require("react/jsx-runtime");
|
|
1999
|
+
var RepeatableRenderer = {
|
|
2000
|
+
canRenderType: "repeatable",
|
|
2001
|
+
render: (props) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(Repeatable, __spreadValues({}, props))
|
|
2002
|
+
};
|
|
2003
|
+
function Repeatable(props) {
|
|
2004
|
+
const {
|
|
2005
|
+
addItemTitle,
|
|
2006
|
+
description,
|
|
2007
|
+
editableItem,
|
|
2008
|
+
editItemTitle,
|
|
2009
|
+
items,
|
|
2010
|
+
title,
|
|
2011
|
+
validationState,
|
|
2012
|
+
onEdit,
|
|
2013
|
+
onAdd,
|
|
2014
|
+
onSave,
|
|
2015
|
+
onRemove
|
|
2016
|
+
} = props;
|
|
2017
|
+
const { formatMessage } = (0, import_react_intl15.useIntl)();
|
|
2018
|
+
const [openModalType, setOpenModalType] = (0, import_react11.useState)(null);
|
|
2019
|
+
const onAddItem = () => {
|
|
2020
|
+
onAdd();
|
|
2021
|
+
setOpenModalType("add");
|
|
2022
|
+
};
|
|
2023
|
+
const onEditItem = (itemIndex) => {
|
|
2024
|
+
onEdit(itemIndex);
|
|
2025
|
+
setOpenModalType("edit");
|
|
2026
|
+
};
|
|
2027
|
+
const onSaveItem = () => {
|
|
2028
|
+
const saveSuccessful = onSave();
|
|
2029
|
+
if (saveSuccessful) {
|
|
2030
|
+
setOpenModalType(null);
|
|
2031
|
+
}
|
|
2032
|
+
};
|
|
2033
|
+
const onRemoveItem = () => {
|
|
2034
|
+
onRemove();
|
|
2035
|
+
setOpenModalType(null);
|
|
2036
|
+
};
|
|
2037
|
+
const onCancelEdit = () => {
|
|
2038
|
+
setOpenModalType(null);
|
|
2039
|
+
};
|
|
2040
|
+
return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_jsx_runtime50.Fragment, { children: [
|
|
2041
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_components32.Header, { title }),
|
|
2042
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("p", { children: description }),
|
|
2043
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
|
|
2044
|
+
"div",
|
|
2045
|
+
{
|
|
2046
|
+
className: (0, import_classnames6.default)("form-group", {
|
|
2047
|
+
"has-error": (validationState == null ? void 0 : validationState.status) === "invalid"
|
|
2048
|
+
}),
|
|
2049
|
+
children: [
|
|
2050
|
+
items == null ? void 0 : items.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ItemSummaryOption, { item, onClick: () => onEditItem(index) }, item.id)),
|
|
2051
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
2052
|
+
import_components32.NavigationOption,
|
|
2053
|
+
{
|
|
2054
|
+
media: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_icons.Plus, {}),
|
|
2055
|
+
title: addItemTitle || formatMessage(repeatable_messages_default.addItemTitle),
|
|
2056
|
+
showMediaAtAllSizes: true,
|
|
2057
|
+
onClick: () => onAddItem()
|
|
2058
|
+
}
|
|
2059
|
+
),
|
|
2060
|
+
(validationState == null ? void 0 : validationState.status) === "invalid" && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_components32.InlineAlert, { type: "negative", children: validationState.message })
|
|
2061
|
+
]
|
|
2062
|
+
}
|
|
2063
|
+
),
|
|
2064
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
2065
|
+
import_components32.Modal,
|
|
2066
|
+
{
|
|
2067
|
+
open: openModalType !== null,
|
|
2068
|
+
title: (openModalType === "add" ? addItemTitle : editItemTitle) || formatMessage(repeatable_messages_default.addItemTitle),
|
|
2069
|
+
body: /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_jsx_runtime50.Fragment, { children: [
|
|
2070
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "m-b-2", children: editableItem }),
|
|
2071
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("div", { children: [
|
|
2072
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_components32.Button, { priority: "primary", block: true, className: "m-b-2", onClick: () => onSaveItem(), children: formatMessage(repeatable_messages_default.addItem) }),
|
|
2073
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
2074
|
+
import_components32.Button,
|
|
2075
|
+
{
|
|
2076
|
+
v2: true,
|
|
2077
|
+
priority: "secondary",
|
|
2078
|
+
sentiment: "negative",
|
|
2079
|
+
block: true,
|
|
2080
|
+
onClick: () => onRemoveItem(),
|
|
2081
|
+
children: formatMessage(repeatable_messages_default.removeItem)
|
|
2082
|
+
}
|
|
2083
|
+
)
|
|
2084
|
+
] })
|
|
2085
|
+
] }),
|
|
2086
|
+
onClose: () => onCancelEdit()
|
|
2087
|
+
}
|
|
2088
|
+
)
|
|
2089
|
+
] });
|
|
2090
|
+
}
|
|
2091
|
+
function ItemSummaryOption({
|
|
2092
|
+
item,
|
|
2093
|
+
onClick
|
|
2094
|
+
}) {
|
|
2095
|
+
return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
2096
|
+
import_components32.NavigationOption,
|
|
2097
|
+
{
|
|
2098
|
+
media: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(OptionMedia, { media: item.media, preferAvatar: false }),
|
|
2099
|
+
title: item.title,
|
|
2100
|
+
content: item.description,
|
|
2101
|
+
showMediaAtAllSizes: true,
|
|
2102
|
+
onClick
|
|
2103
|
+
}
|
|
2104
|
+
);
|
|
2105
|
+
}
|
|
2106
|
+
var RepeatableRenderer_default = RepeatableRenderer;
|
|
2107
|
+
|
|
2108
|
+
// ../renderers/src/ReviewRenderer.tsx
|
|
2109
|
+
var import_components34 = require("@transferwise/components");
|
|
2110
|
+
|
|
2111
|
+
// ../renderers/src/components/Header.tsx
|
|
2112
|
+
var import_components33 = require("@transferwise/components");
|
|
2113
|
+
var import_jsx_runtime51 = require("react/jsx-runtime");
|
|
2114
|
+
var Header7 = ({ title, callToAction }) => (title || callToAction) && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_components33.Header, { title: title != null ? title : "", action: getHeaderAction(callToAction) });
|
|
2115
|
+
var getHeaderAction = (callToAction) => {
|
|
2116
|
+
if (!callToAction) {
|
|
2117
|
+
return void 0;
|
|
2118
|
+
}
|
|
2119
|
+
const { accessibilityDescription, href, title, onClick } = callToAction;
|
|
2120
|
+
return href ? {
|
|
2121
|
+
"aria-label": accessibilityDescription,
|
|
2122
|
+
text: title,
|
|
2123
|
+
href,
|
|
2124
|
+
target: "_blank"
|
|
2125
|
+
} : {
|
|
2126
|
+
"aria-label": accessibilityDescription,
|
|
2127
|
+
text: title,
|
|
2128
|
+
onClick: (event) => {
|
|
2129
|
+
event.preventDefault();
|
|
2130
|
+
onClick();
|
|
2131
|
+
}
|
|
2132
|
+
};
|
|
2133
|
+
};
|
|
2134
|
+
|
|
2135
|
+
// ../renderers/src/ReviewRenderer.tsx
|
|
2136
|
+
var import_jsx_runtime52 = require("react/jsx-runtime");
|
|
2137
|
+
var ReviewRenderer = {
|
|
2138
|
+
canRenderType: "review",
|
|
2139
|
+
render: ({ callToAction, control, fields, margin, title, trackEvent }) => {
|
|
2140
|
+
const orientation = mapControlToDefinitionListLayout(control);
|
|
2141
|
+
return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("div", { className: getMargin(margin), children: [
|
|
2142
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)(Header7, { title, callToAction }),
|
|
2143
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { className: margin, children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
|
|
2144
|
+
import_components34.DefinitionList,
|
|
2145
|
+
{
|
|
2146
|
+
layout: orientation,
|
|
2147
|
+
definitions: fields.map(
|
|
2148
|
+
({ label, value, help, analyticsId: fieldAnalyticsId }, index) => ({
|
|
2149
|
+
key: String(index),
|
|
2150
|
+
value,
|
|
2151
|
+
title: getFieldLabel(
|
|
2152
|
+
label,
|
|
2153
|
+
help,
|
|
2154
|
+
() => trackEvent("Help Pressed", { layoutItemId: fieldAnalyticsId })
|
|
2155
|
+
)
|
|
2156
|
+
})
|
|
2157
|
+
)
|
|
2158
|
+
}
|
|
2159
|
+
) })
|
|
2160
|
+
] });
|
|
2161
|
+
}
|
|
2162
|
+
};
|
|
2163
|
+
var ReviewRenderer_default = ReviewRenderer;
|
|
2164
|
+
var mapControlToDefinitionListLayout = (control) => {
|
|
2165
|
+
switch (control) {
|
|
2166
|
+
case "horizontal":
|
|
2167
|
+
case "horizontal-end-aligned":
|
|
2168
|
+
return "HORIZONTAL_RIGHT_ALIGNED";
|
|
2169
|
+
case "horizontal-start-aligned":
|
|
2170
|
+
return "HORIZONTAL_LEFT_ALIGNED";
|
|
2171
|
+
case "vertical-two-column":
|
|
2172
|
+
return "VERTICAL_TWO_COLUMN";
|
|
2173
|
+
case "vertical":
|
|
2174
|
+
case "vertical-one-column":
|
|
2175
|
+
default:
|
|
2176
|
+
return "VERTICAL_ONE_COLUMN";
|
|
2177
|
+
}
|
|
2178
|
+
};
|
|
2179
|
+
var getFieldLabel = (label, help, onClick) => {
|
|
2180
|
+
if (help) {
|
|
2181
|
+
return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(import_jsx_runtime52.Fragment, { children: [
|
|
2182
|
+
label,
|
|
2183
|
+
" ",
|
|
2184
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)(Help_default, { help, onClick })
|
|
2185
|
+
] });
|
|
2186
|
+
}
|
|
2187
|
+
return label;
|
|
2188
|
+
};
|
|
2189
|
+
|
|
2190
|
+
// ../renderers/src/SearchRenderer/BlockSearchRendererComponent.tsx
|
|
2191
|
+
var import_components36 = require("@transferwise/components");
|
|
2192
|
+
var import_react12 = require("react");
|
|
2193
|
+
var import_react_intl19 = require("react-intl");
|
|
2194
|
+
|
|
2195
|
+
// ../renderers/src/messages/search.messages.ts
|
|
2196
|
+
var import_react_intl16 = require("react-intl");
|
|
2197
|
+
var search_messages_default = (0, import_react_intl16.defineMessages)({
|
|
2198
|
+
loading: {
|
|
2199
|
+
id: "df.wise.SearchLayout.loading",
|
|
2200
|
+
defaultMessage: "Loading...",
|
|
2201
|
+
description: "A message shown to the user while their search is being processed, before results appear."
|
|
2202
|
+
}
|
|
2203
|
+
});
|
|
2204
|
+
|
|
2205
|
+
// ../renderers/src/SearchRenderer/ErrorResult.tsx
|
|
2206
|
+
var import_react_intl18 = require("react-intl");
|
|
2207
|
+
|
|
2208
|
+
// ../renderers/src/messages/generic-error.messages.ts
|
|
2209
|
+
var import_react_intl17 = require("react-intl");
|
|
2210
|
+
var generic_error_messages_default = (0, import_react_intl17.defineMessages)({
|
|
2211
|
+
genericErrorRetryHint: {
|
|
2212
|
+
id: "df.wise.PersistAsyncSchema.genericError",
|
|
2213
|
+
defaultMessage: "Something went wrong, please try again.",
|
|
2214
|
+
description: "Generic error message for persist async schema"
|
|
2215
|
+
},
|
|
2216
|
+
genericError: {
|
|
2217
|
+
id: "df.wise.ErrorBoundary.errorAlert",
|
|
2218
|
+
defaultMessage: "Something went wrong.",
|
|
2219
|
+
description: "Generic error message for when something has gone wrong."
|
|
2220
|
+
},
|
|
2221
|
+
retry: {
|
|
2222
|
+
id: "df.wise.ErrorBoundary.retry",
|
|
2223
|
+
defaultMessage: "Retry",
|
|
2224
|
+
description: "Usually this follows the generic error and contains a link."
|
|
2225
|
+
}
|
|
2226
|
+
});
|
|
2227
|
+
|
|
2228
|
+
// ../renderers/src/SearchRenderer/ErrorResult.tsx
|
|
2229
|
+
var import_components35 = require("@transferwise/components");
|
|
2230
|
+
var import_jsx_runtime53 = require("react/jsx-runtime");
|
|
2231
|
+
function ErrorResult({ state }) {
|
|
2232
|
+
const intl = (0, import_react_intl18.useIntl)();
|
|
2233
|
+
return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("p", { className: "m-t-2", children: [
|
|
2234
|
+
intl.formatMessage(generic_error_messages_default.genericError),
|
|
2235
|
+
"\xA0",
|
|
2236
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_components35.Link, { onClick: () => state.onRetry(), children: intl.formatMessage(generic_error_messages_default.retry) })
|
|
2237
|
+
] });
|
|
2238
|
+
}
|
|
2239
|
+
|
|
2240
|
+
// ../renderers/src/SearchRenderer/BlockSearchRendererComponent.tsx
|
|
2241
|
+
var import_jsx_runtime54 = require("react/jsx-runtime");
|
|
2242
|
+
function BlockSearchRendererComponent({
|
|
2243
|
+
id,
|
|
2244
|
+
isLoading,
|
|
2245
|
+
margin,
|
|
2246
|
+
query,
|
|
2247
|
+
state,
|
|
2248
|
+
title,
|
|
2249
|
+
trackEvent,
|
|
2250
|
+
onChange
|
|
2251
|
+
}) {
|
|
2252
|
+
const [hasSearched, setHasSearched] = (0, import_react12.useState)(false);
|
|
2253
|
+
const { formatMessage } = (0, import_react_intl19.useIntl)();
|
|
2254
|
+
return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("div", { className: getMargin(margin), children: [
|
|
2255
|
+
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)(FieldInput_default, { id, description: "", validation: void 0, help: "", label: title, children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
2256
|
+
import_components36.Input,
|
|
2257
|
+
{
|
|
2258
|
+
id,
|
|
2259
|
+
name: id,
|
|
2260
|
+
type: "text",
|
|
2261
|
+
value: query,
|
|
2262
|
+
className: "m-t-1",
|
|
2263
|
+
onChange: ({ currentTarget: { value } }) => {
|
|
2264
|
+
if (!hasSearched) {
|
|
2265
|
+
setHasSearched(true);
|
|
2266
|
+
trackEvent("Search Started");
|
|
2267
|
+
}
|
|
2268
|
+
onChange(value);
|
|
2269
|
+
}
|
|
2270
|
+
}
|
|
2271
|
+
) }),
|
|
2272
|
+
isLoading ? /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_jsx_runtime54.Fragment, { children: formatMessage(search_messages_default.loading) }) : /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(SearchResultContent, { state, trackEvent })
|
|
2273
|
+
] });
|
|
2274
|
+
}
|
|
2275
|
+
function SearchResultContent({
|
|
2276
|
+
state,
|
|
2277
|
+
trackEvent
|
|
2278
|
+
}) {
|
|
2279
|
+
switch (state.type) {
|
|
2280
|
+
case "error":
|
|
2281
|
+
return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(ErrorResult, { state });
|
|
2282
|
+
case "results":
|
|
2283
|
+
return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(SearchResults, { state, trackEvent });
|
|
2284
|
+
case "noResults":
|
|
2285
|
+
return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(EmptySearchResult, { state });
|
|
2286
|
+
case "pending":
|
|
2287
|
+
default:
|
|
2288
|
+
return null;
|
|
2289
|
+
}
|
|
2290
|
+
}
|
|
2291
|
+
function EmptySearchResult({ state }) {
|
|
2292
|
+
return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_components36.Markdown, { className: "m-t-2", config: { link: { target: "_blank" } }, children: state.message });
|
|
2293
|
+
}
|
|
2294
|
+
function SearchResults({
|
|
2295
|
+
state,
|
|
2296
|
+
trackEvent
|
|
2297
|
+
}) {
|
|
2298
|
+
return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_components36.NavigationOptionsList, { children: state.results.map((result) => {
|
|
2299
|
+
const { media } = result;
|
|
2300
|
+
return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
2301
|
+
import_components36.NavigationOption,
|
|
2302
|
+
{
|
|
2303
|
+
title: result.title,
|
|
2304
|
+
content: result.description,
|
|
2305
|
+
media: media ? /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(OptionMedia, { media, preferAvatar: false }) : void 0,
|
|
2306
|
+
showMediaCircle: false,
|
|
2307
|
+
showMediaAtAllSizes: true,
|
|
2308
|
+
onClick: () => {
|
|
2309
|
+
trackEvent("Search Result Selected", __spreadValues({
|
|
2310
|
+
type: result.type
|
|
2311
|
+
}, result.type === "action" ? { actionId: result.id } : {}));
|
|
2312
|
+
result.onClick();
|
|
2313
|
+
}
|
|
2314
|
+
},
|
|
2315
|
+
JSON.stringify(result)
|
|
2316
|
+
);
|
|
2317
|
+
}) });
|
|
2318
|
+
}
|
|
2319
|
+
var BlockSearchRendererComponent_default = BlockSearchRendererComponent;
|
|
2320
|
+
|
|
2321
|
+
// ../renderers/src/SearchRenderer/InlineSearchRendererComponent.tsx
|
|
2322
|
+
var import_components37 = require("@transferwise/components");
|
|
2323
|
+
var import_icons2 = require("@transferwise/icons");
|
|
2324
|
+
var import_react13 = require("react");
|
|
2325
|
+
var import_react_intl20 = require("react-intl");
|
|
2326
|
+
var import_jsx_runtime55 = require("react/jsx-runtime");
|
|
2327
|
+
function InlineSearchRenderer({
|
|
2328
|
+
id,
|
|
2329
|
+
isLoading,
|
|
2330
|
+
margin,
|
|
2331
|
+
onChange,
|
|
2332
|
+
state,
|
|
2333
|
+
title,
|
|
2334
|
+
trackEvent
|
|
2335
|
+
}) {
|
|
2336
|
+
const [hasSearched, setHasSearched] = (0, import_react13.useState)(false);
|
|
2337
|
+
const intl = (0, import_react_intl20.useIntl)();
|
|
2338
|
+
return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: getMargin(margin), children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(FieldInput_default, { id, description: "", validation: void 0, help: "", label: title, children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
2339
|
+
import_components37.Typeahead,
|
|
2340
|
+
{
|
|
2341
|
+
id: "typeahead-input-id",
|
|
2342
|
+
intl,
|
|
2343
|
+
name: "typeahead-input-name",
|
|
2344
|
+
size: "md",
|
|
2345
|
+
maxHeight: 100,
|
|
2346
|
+
footer: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(TypeaheadFooter, { state, isLoading }),
|
|
2347
|
+
multiple: false,
|
|
2348
|
+
clearable: false,
|
|
2349
|
+
addon: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_icons2.Search, { size: 24 }),
|
|
2350
|
+
options: state.type === "results" ? state.results.map(mapResultToTypeaheadOption) : [],
|
|
2351
|
+
minQueryLength: 1,
|
|
2352
|
+
onChange: (values) => {
|
|
2353
|
+
if (values.length > 0) {
|
|
2354
|
+
const [updatedValue] = values;
|
|
2355
|
+
const { value: result } = updatedValue;
|
|
2356
|
+
if (result) {
|
|
2357
|
+
trackEvent("Search Result Selected", __spreadValues({
|
|
2358
|
+
type: result.type
|
|
2359
|
+
}, result.type === "action" ? { actionId: result.id } : {}));
|
|
2360
|
+
result.onClick();
|
|
2361
|
+
}
|
|
2362
|
+
}
|
|
2363
|
+
},
|
|
2364
|
+
onInputChange: (query) => {
|
|
2365
|
+
if (!hasSearched) {
|
|
2366
|
+
setHasSearched(true);
|
|
2367
|
+
trackEvent("Search Started");
|
|
2368
|
+
}
|
|
2369
|
+
onChange(query);
|
|
2370
|
+
}
|
|
2371
|
+
}
|
|
2372
|
+
) }) });
|
|
2373
|
+
}
|
|
2374
|
+
function mapResultToTypeaheadOption(result) {
|
|
2375
|
+
return {
|
|
2376
|
+
label: result.title,
|
|
2377
|
+
secondary: result.description,
|
|
2378
|
+
value: result,
|
|
2379
|
+
clearQueryOnSelect: result.type === "action",
|
|
2380
|
+
keepFocusOnSelect: result.type === "search"
|
|
2381
|
+
};
|
|
2382
|
+
}
|
|
2383
|
+
function TypeaheadFooter({ state, isLoading }) {
|
|
2384
|
+
const { formatMessage } = (0, import_react_intl20.useIntl)();
|
|
2385
|
+
if (state.type === "noResults") {
|
|
2386
|
+
return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_components37.Markdown, { className: "m-t-2 m-x-2", config: { link: { target: "_blank" } }, children: state.message });
|
|
2387
|
+
}
|
|
2388
|
+
if (state.type === "error") {
|
|
2389
|
+
return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "m-t-2 m-x-2", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(ErrorResult, { state }) });
|
|
2390
|
+
}
|
|
2391
|
+
if (state.type === "pending" || isLoading) {
|
|
2392
|
+
return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("p", { className: "m-t-2 m-x-2", children: formatMessage(search_messages_default.loading) });
|
|
2393
|
+
}
|
|
2394
|
+
return null;
|
|
2395
|
+
}
|
|
2396
|
+
var InlineSearchRendererComponent_default = InlineSearchRenderer;
|
|
2397
|
+
|
|
2398
|
+
// ../renderers/src/SearchRenderer/SearchRenderer.tsx
|
|
2399
|
+
var import_jsx_runtime56 = require("react/jsx-runtime");
|
|
2400
|
+
var SearchRenderer = {
|
|
2401
|
+
canRenderType: "search",
|
|
2402
|
+
render: (props) => props.control === "inline" ? /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(InlineSearchRendererComponent_default, __spreadValues({}, props)) : /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(BlockSearchRendererComponent_default, __spreadValues({}, props))
|
|
2403
|
+
};
|
|
2404
|
+
var SearchRenderer_default = SearchRenderer;
|
|
2405
|
+
|
|
2406
|
+
// ../renderers/src/SectionRenderer.tsx
|
|
2407
|
+
var import_components38 = require("@transferwise/components");
|
|
2408
|
+
|
|
2409
|
+
// ../renderers/src/utils/getHeaderAction.tsx
|
|
2410
|
+
var getHeaderAction2 = (callToAction) => {
|
|
2411
|
+
if (!callToAction) {
|
|
2412
|
+
return void 0;
|
|
2413
|
+
}
|
|
2414
|
+
const { accessibilityDescription, href, title, onClick } = callToAction;
|
|
2415
|
+
return href ? {
|
|
2416
|
+
"aria-label": accessibilityDescription,
|
|
2417
|
+
text: title,
|
|
2418
|
+
href,
|
|
2419
|
+
target: "_blank"
|
|
2420
|
+
} : {
|
|
2421
|
+
"aria-label": accessibilityDescription,
|
|
2422
|
+
text: title,
|
|
2423
|
+
onClick: (event) => {
|
|
2424
|
+
event.preventDefault();
|
|
2425
|
+
onClick();
|
|
2426
|
+
}
|
|
2427
|
+
};
|
|
2428
|
+
};
|
|
2429
|
+
|
|
2430
|
+
// ../renderers/src/SectionRenderer.tsx
|
|
2431
|
+
var import_jsx_runtime57 = require("react/jsx-runtime");
|
|
2432
|
+
var SectionRenderer = {
|
|
2433
|
+
canRenderType: "section",
|
|
2434
|
+
render: ({ children, callToAction, margin, title }) => {
|
|
2435
|
+
return /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("section", { className: getMargin(margin), children: [
|
|
2436
|
+
(title || callToAction) && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(import_components38.Header, { title: title != null ? title : "", action: getHeaderAction2(callToAction) }),
|
|
2437
|
+
children
|
|
2438
|
+
] });
|
|
2439
|
+
}
|
|
2440
|
+
};
|
|
2441
|
+
var SectionRenderer_default = SectionRenderer;
|
|
2442
|
+
|
|
2443
|
+
// ../renderers/src/SelectInputRenderer/RadioInputRendererComponent.tsx
|
|
2444
|
+
var import_components39 = require("@transferwise/components");
|
|
2445
|
+
var import_jsx_runtime58 = require("react/jsx-runtime");
|
|
2446
|
+
function RadioInputRendererComponent(props) {
|
|
2447
|
+
const {
|
|
2448
|
+
id,
|
|
2449
|
+
children,
|
|
2450
|
+
description,
|
|
2451
|
+
disabled,
|
|
2452
|
+
help,
|
|
2453
|
+
title,
|
|
2454
|
+
options,
|
|
2455
|
+
selectedIndex,
|
|
2456
|
+
validationState,
|
|
2457
|
+
onSelect
|
|
2458
|
+
} = props;
|
|
2459
|
+
return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_jsx_runtime58.Fragment, { children: [
|
|
2460
|
+
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
|
|
2461
|
+
FieldInput_default,
|
|
2462
|
+
{
|
|
2463
|
+
id,
|
|
2464
|
+
label: title,
|
|
2465
|
+
help,
|
|
2466
|
+
description,
|
|
2467
|
+
validation: validationState,
|
|
2468
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("span", { children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
|
|
2469
|
+
import_components39.RadioGroup,
|
|
2470
|
+
{
|
|
2471
|
+
name: id,
|
|
2472
|
+
radios: options.map((option, index) => ({
|
|
2473
|
+
label: option.title,
|
|
2474
|
+
value: index,
|
|
2475
|
+
secondary: option.description,
|
|
2476
|
+
disabled: option.disabled || disabled,
|
|
2477
|
+
avatar: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(OptionMedia, { media: option.media, preferAvatar: false })
|
|
2478
|
+
})),
|
|
2479
|
+
selectedValue: selectedIndex != null ? selectedIndex : void 0,
|
|
2480
|
+
onChange: onSelect
|
|
2481
|
+
},
|
|
2482
|
+
`${id}-${selectedIndex}`
|
|
2483
|
+
) })
|
|
2484
|
+
}
|
|
2485
|
+
),
|
|
2486
|
+
children
|
|
2487
|
+
] });
|
|
2488
|
+
}
|
|
2489
|
+
|
|
2490
|
+
// ../renderers/src/SelectInputRenderer/TabInputRendererComponent.tsx
|
|
2491
|
+
var import_components40 = require("@transferwise/components");
|
|
2492
|
+
var import_react14 = require("react");
|
|
2493
|
+
var import_jsx_runtime59 = require("react/jsx-runtime");
|
|
2494
|
+
function TabInputRendererComponent(props) {
|
|
2495
|
+
const {
|
|
2496
|
+
id,
|
|
2497
|
+
children,
|
|
2498
|
+
description,
|
|
2499
|
+
disabled,
|
|
2500
|
+
help,
|
|
2501
|
+
title,
|
|
2502
|
+
options,
|
|
2503
|
+
selectedIndex,
|
|
2504
|
+
validationState,
|
|
2505
|
+
onSelect
|
|
2506
|
+
} = props;
|
|
2507
|
+
(0, import_react14.useEffect)(() => {
|
|
2508
|
+
if (!isValidIndex(selectedIndex, options.length)) {
|
|
2509
|
+
onSelect(0);
|
|
2510
|
+
}
|
|
2511
|
+
}, [selectedIndex, onSelect, options.length]);
|
|
2512
|
+
return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(import_jsx_runtime59.Fragment, { children: [
|
|
2513
|
+
/* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
|
|
2514
|
+
FieldInput_default,
|
|
2515
|
+
{
|
|
2516
|
+
id,
|
|
2517
|
+
label: title,
|
|
2518
|
+
help,
|
|
2519
|
+
description,
|
|
2520
|
+
validation: validationState,
|
|
2521
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
|
|
2522
|
+
import_components40.Tabs,
|
|
2523
|
+
{
|
|
2524
|
+
name: id,
|
|
2525
|
+
selected: selectedIndex != null ? selectedIndex : 0,
|
|
2526
|
+
tabs: options.map((option) => ({
|
|
2527
|
+
title: option.title,
|
|
2528
|
+
// if we pass null, we get some props-types console errors
|
|
2529
|
+
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
2530
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_jsx_runtime59.Fragment, {}),
|
|
2531
|
+
disabled: option.disabled || disabled
|
|
2532
|
+
})),
|
|
2533
|
+
onTabSelect: onSelect
|
|
2534
|
+
}
|
|
2535
|
+
)
|
|
2536
|
+
}
|
|
2537
|
+
),
|
|
2538
|
+
children
|
|
2539
|
+
] });
|
|
2540
|
+
}
|
|
2541
|
+
var isValidIndex = (index, options) => index !== null && index >= 0 && index < options;
|
|
2542
|
+
|
|
2543
|
+
// ../renderers/src/SelectInputRenderer/SelectInputRendererComponent.tsx
|
|
2544
|
+
var import_components41 = require("@transferwise/components");
|
|
2545
|
+
var import_jsx_runtime60 = require("react/jsx-runtime");
|
|
2546
|
+
function SelectInputRendererComponent(props) {
|
|
2547
|
+
const {
|
|
2548
|
+
id,
|
|
2549
|
+
autoComplete,
|
|
2550
|
+
children,
|
|
2551
|
+
description,
|
|
2552
|
+
disabled,
|
|
2553
|
+
help,
|
|
2554
|
+
title,
|
|
2555
|
+
options,
|
|
2556
|
+
placeholder,
|
|
2557
|
+
required,
|
|
2558
|
+
selectedIndex,
|
|
2559
|
+
validationState,
|
|
2560
|
+
onSelect
|
|
2561
|
+
} = props;
|
|
2562
|
+
const items = options.map(
|
|
2563
|
+
(option, index) => {
|
|
2564
|
+
var _a, _b, _c;
|
|
2565
|
+
return {
|
|
2566
|
+
type: "option",
|
|
2567
|
+
value: index,
|
|
2568
|
+
filterMatchers: [...(_a = option.keywords) != null ? _a : [], (_b = option.title) != null ? _b : "", (_c = option.description) != null ? _c : ""],
|
|
2569
|
+
disabled: option.disabled
|
|
2570
|
+
};
|
|
2571
|
+
}
|
|
2572
|
+
);
|
|
2573
|
+
const renderValue = (index, withinTrigger) => {
|
|
2574
|
+
const option = index >= 0 ? options[index] : null;
|
|
2575
|
+
if (option === null) {
|
|
2576
|
+
return null;
|
|
2577
|
+
}
|
|
2578
|
+
const contentProps = withinTrigger ? {
|
|
2579
|
+
title: option.title,
|
|
2580
|
+
note: option.description,
|
|
2581
|
+
icon: getInlineMedia(option.media)
|
|
2582
|
+
} : {
|
|
2583
|
+
title: option.title,
|
|
2584
|
+
description: option.description,
|
|
2585
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(OptionMedia, { media: option.media, preferAvatar: false })
|
|
2586
|
+
};
|
|
2587
|
+
return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_components41.SelectInputOptionContent, __spreadValues({}, contentProps));
|
|
2588
|
+
};
|
|
2589
|
+
const extraProps = { autoComplete };
|
|
2590
|
+
return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(import_jsx_runtime60.Fragment, { children: [
|
|
2591
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
|
|
2592
|
+
FieldInput_default,
|
|
2593
|
+
{
|
|
2594
|
+
id,
|
|
2595
|
+
label: title,
|
|
2596
|
+
help,
|
|
2597
|
+
description,
|
|
2598
|
+
validation: validationState,
|
|
2599
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
|
|
2600
|
+
import_components41.SelectInput,
|
|
2601
|
+
__spreadValues({
|
|
2602
|
+
name: id,
|
|
2603
|
+
placeholder,
|
|
2604
|
+
items,
|
|
2605
|
+
disabled,
|
|
2606
|
+
value: selectedIndex,
|
|
2607
|
+
renderValue,
|
|
2608
|
+
filterable: items.length >= 8,
|
|
2609
|
+
onChange: onSelect,
|
|
2610
|
+
onClear: required ? void 0 : () => onSelect(null)
|
|
2611
|
+
}, extraProps)
|
|
2612
|
+
)
|
|
2613
|
+
}
|
|
2614
|
+
),
|
|
2615
|
+
children
|
|
2616
|
+
] });
|
|
2617
|
+
}
|
|
2618
|
+
|
|
2619
|
+
// ../renderers/src/SelectInputRenderer/SegmentedInputRendererComponent.tsx
|
|
2620
|
+
var import_react15 = require("react");
|
|
2621
|
+
var import_components42 = require("@transferwise/components");
|
|
2622
|
+
var import_jsx_runtime61 = require("react/jsx-runtime");
|
|
2623
|
+
function SegmentedInputRendererComponent(props) {
|
|
2624
|
+
const {
|
|
2625
|
+
id,
|
|
2626
|
+
children,
|
|
2627
|
+
description,
|
|
2628
|
+
help,
|
|
2629
|
+
title,
|
|
2630
|
+
options,
|
|
2631
|
+
selectedIndex,
|
|
2632
|
+
validationState,
|
|
2633
|
+
onSelect
|
|
2634
|
+
} = props;
|
|
2635
|
+
(0, import_react15.useEffect)(() => {
|
|
2636
|
+
if (!isValidIndex2(selectedIndex, options.length)) {
|
|
2637
|
+
onSelect(0);
|
|
2638
|
+
}
|
|
2639
|
+
}, [selectedIndex, onSelect, options.length]);
|
|
2640
|
+
return /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(import_jsx_runtime61.Fragment, { children: [
|
|
2641
|
+
/* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
|
|
2642
|
+
FieldInput_default,
|
|
2643
|
+
{
|
|
2644
|
+
id,
|
|
2645
|
+
label: title,
|
|
2646
|
+
help,
|
|
2647
|
+
description,
|
|
2648
|
+
validation: validationState,
|
|
2649
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
|
|
2650
|
+
import_components42.SegmentedControl,
|
|
2651
|
+
{
|
|
2652
|
+
name: `${id}-segmented-control`,
|
|
2653
|
+
value: String(selectedIndex),
|
|
2654
|
+
mode: "view",
|
|
2655
|
+
segments: options.map((option, index) => ({
|
|
2656
|
+
id: String(index),
|
|
2657
|
+
value: String(index),
|
|
2658
|
+
label: option.title,
|
|
2659
|
+
controls: `${id}-children`
|
|
2660
|
+
})),
|
|
2661
|
+
onChange: (value) => onSelect(Number(value))
|
|
2662
|
+
}
|
|
2663
|
+
)
|
|
2664
|
+
}
|
|
2665
|
+
),
|
|
2666
|
+
/* @__PURE__ */ (0, import_jsx_runtime61.jsx)("div", { id: `${id}-children`, children })
|
|
2667
|
+
] });
|
|
2668
|
+
}
|
|
2669
|
+
var isValidIndex2 = (index, options) => index !== null && index >= 0 && index < options;
|
|
2670
|
+
|
|
2671
|
+
// ../renderers/src/SelectInputRenderer/SelectInputRenderer.tsx
|
|
2672
|
+
var import_jsx_runtime62 = require("react/jsx-runtime");
|
|
2673
|
+
var SelectInputRenderer = {
|
|
2674
|
+
canRenderType: "input-select",
|
|
2675
|
+
render: (props) => {
|
|
2676
|
+
switch (props.control) {
|
|
2677
|
+
case "radio":
|
|
2678
|
+
return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(RadioInputRendererComponent, __spreadValues({}, props));
|
|
2679
|
+
case "tab":
|
|
2680
|
+
return props.options.length > 3 ? /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(SelectInputRendererComponent, __spreadValues({}, props)) : /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(TabInputRendererComponent, __spreadValues({}, props));
|
|
2681
|
+
case "segmented":
|
|
2682
|
+
return props.options.length > 3 ? /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(SelectInputRendererComponent, __spreadValues({}, props)) : /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(SegmentedInputRendererComponent, __spreadValues({}, props));
|
|
2683
|
+
case "select":
|
|
2684
|
+
default:
|
|
2685
|
+
return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(SelectInputRendererComponent, __spreadValues({}, props));
|
|
2686
|
+
}
|
|
2687
|
+
}
|
|
2688
|
+
};
|
|
2689
|
+
var SelectInputRenderer_default = SelectInputRenderer;
|
|
2690
|
+
|
|
2691
|
+
// ../renderers/src/StatusListRenderer.tsx
|
|
2692
|
+
var import_components43 = require("@transferwise/components");
|
|
2693
|
+
var import_jsx_runtime63 = require("react/jsx-runtime");
|
|
2694
|
+
var StatusListRenderer = {
|
|
2695
|
+
canRenderType: "status-list",
|
|
2696
|
+
render: ({ margin, items, title }) => /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("div", { className: getMargin(margin), children: [
|
|
2697
|
+
title ? /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_components43.Header, { title, className: "m-b-2" }) : null,
|
|
2698
|
+
items.map(({ callToAction, description, icon, status, title: itemTitle }) => /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
|
|
2699
|
+
import_components43.Summary,
|
|
2700
|
+
{
|
|
2701
|
+
title: itemTitle,
|
|
2702
|
+
description,
|
|
2703
|
+
icon: icon && "name" in icon ? /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(DynamicIcon_default, { name: icon.name }) : null,
|
|
2704
|
+
status: mapStatus(status),
|
|
2705
|
+
action: getSummaryAction(callToAction)
|
|
2706
|
+
},
|
|
2707
|
+
`${itemTitle}/${description || ""}`
|
|
2708
|
+
))
|
|
2709
|
+
] })
|
|
2710
|
+
};
|
|
2711
|
+
var StatusListRenderer_default = StatusListRenderer;
|
|
2712
|
+
var getSummaryAction = (callToAction) => {
|
|
2713
|
+
if (!callToAction) {
|
|
2714
|
+
return void 0;
|
|
2715
|
+
}
|
|
2716
|
+
const { accessibilityDescription, href, title, onClick } = callToAction;
|
|
2717
|
+
if (!href) {
|
|
2718
|
+
return {
|
|
2719
|
+
"aria-label": accessibilityDescription,
|
|
2720
|
+
text: title,
|
|
2721
|
+
onClick
|
|
2722
|
+
};
|
|
2723
|
+
}
|
|
2724
|
+
return {
|
|
2725
|
+
"aria-label": accessibilityDescription,
|
|
2726
|
+
href,
|
|
2727
|
+
target: "_blank",
|
|
2728
|
+
text: title
|
|
2729
|
+
};
|
|
2730
|
+
};
|
|
2731
|
+
var mapStatus = (status) => {
|
|
2732
|
+
if (status === "not-done") {
|
|
2733
|
+
return "notDone";
|
|
2734
|
+
}
|
|
2735
|
+
return status;
|
|
2736
|
+
};
|
|
2737
|
+
|
|
2738
|
+
// ../renderers/src/utils/useCustomTheme.ts
|
|
2739
|
+
var import_components_theming = require("@wise/components-theming");
|
|
2740
|
+
var import_react16 = require("react");
|
|
2741
|
+
var ThemeRequiredEventName = "Theme Required";
|
|
2742
|
+
var useCustomTheme = (theme, trackEvent) => {
|
|
2743
|
+
const previousThemeHookValue = (0, import_components_theming.useTheme)();
|
|
2744
|
+
const previousTheme = (0, import_react16.useMemo)(() => previousThemeHookValue.theme, []);
|
|
2745
|
+
(0, import_react16.useEffect)(() => {
|
|
2746
|
+
trackEvent(ThemeRequiredEventName, { theme });
|
|
2747
|
+
return theme !== previousTheme ? () => {
|
|
2748
|
+
trackEvent(ThemeRequiredEventName, { theme: previousTheme });
|
|
2749
|
+
} : () => {
|
|
2750
|
+
};
|
|
2751
|
+
}, []);
|
|
2752
|
+
};
|
|
2753
|
+
|
|
2754
|
+
// ../renderers/src/step/topbar/BackButton.tsx
|
|
2755
|
+
var import_components44 = require("@transferwise/components");
|
|
2756
|
+
var import_icons3 = require("@transferwise/icons");
|
|
2757
|
+
var import_jsx_runtime64 = require("react/jsx-runtime");
|
|
2758
|
+
function BackButton({ title, onClick }) {
|
|
2759
|
+
return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(import_components44.IconButton, { priority: "tertiary", onClick, children: [
|
|
2760
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("span", { className: "sr-only", children: title }),
|
|
2761
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_icons3.ArrowLeft, {})
|
|
2762
|
+
] });
|
|
2763
|
+
}
|
|
2764
|
+
|
|
2765
|
+
// ../renderers/src/step/topbar/Toolbar.tsx
|
|
2766
|
+
var import_components45 = require("@transferwise/components");
|
|
2767
|
+
var import_jsx_runtime65 = require("react/jsx-runtime");
|
|
2768
|
+
var Toolbar = ({ items }) => {
|
|
2769
|
+
return (items == null ? void 0 : items.length) > 0 ? /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { className: "df-toolbar", children: items.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(ToolbarButton, __spreadValues({}, item), `${item.type}-${index}-${item.title}`)) }) : null;
|
|
2770
|
+
};
|
|
2771
|
+
function ToolbarButton(props) {
|
|
2772
|
+
return prefersMedia(props.control) ? /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(MediaToolbarButton, __spreadValues({}, props)) : /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(TextToolbarButton, __spreadValues({}, props));
|
|
2773
|
+
}
|
|
2774
|
+
function MediaToolbarButton(props) {
|
|
2775
|
+
var _a;
|
|
2776
|
+
const { context, control, media, accessibilityDescription, disabled, onClick } = props;
|
|
2777
|
+
const priority = getIconButtonPriority(control);
|
|
2778
|
+
const type = getSentiment(context);
|
|
2779
|
+
return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
|
|
2780
|
+
import_components45.IconButton,
|
|
2781
|
+
{
|
|
2782
|
+
className: "df-toolbar-button",
|
|
2783
|
+
disabled,
|
|
2784
|
+
priority,
|
|
2785
|
+
size: 32,
|
|
2786
|
+
type,
|
|
2787
|
+
onClick,
|
|
2788
|
+
children: [
|
|
2789
|
+
accessibilityDescription ? /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("span", { className: "sr-only", children: accessibilityDescription }) : null,
|
|
2790
|
+
media ? (_a = getAddonStart(media)) == null ? void 0 : _a.value : null
|
|
2791
|
+
]
|
|
2792
|
+
}
|
|
2793
|
+
);
|
|
2794
|
+
}
|
|
2795
|
+
function TextToolbarButton(props) {
|
|
2796
|
+
const { context, control, title, media, disabled, onClick } = props;
|
|
2797
|
+
const addonStart = media ? getAddonStart(media) : void 0;
|
|
2798
|
+
const priority = getPriority2(control);
|
|
2799
|
+
const sentiment = getSentiment(context);
|
|
2800
|
+
return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
|
|
2801
|
+
import_components45.Button,
|
|
2802
|
+
{
|
|
2803
|
+
v2: true,
|
|
2804
|
+
size: "sm",
|
|
2805
|
+
className: "df-toolbar-button",
|
|
2806
|
+
disabled,
|
|
2807
|
+
priority,
|
|
2808
|
+
addonStart,
|
|
2809
|
+
sentiment,
|
|
2810
|
+
onClick,
|
|
2811
|
+
children: title
|
|
2812
|
+
}
|
|
2813
|
+
);
|
|
2814
|
+
}
|
|
2815
|
+
var getAddonStart = (media) => {
|
|
2816
|
+
if (media.type === "avatar") {
|
|
2817
|
+
if (media.content.length > 0 && media.content[0].type === "uri" && isValidIconUrn(media.content[0].uri)) {
|
|
2818
|
+
return {
|
|
2819
|
+
type: "icon",
|
|
2820
|
+
value: getInlineMedia({
|
|
2821
|
+
type: "image",
|
|
2822
|
+
uri: media.content[0].uri
|
|
2823
|
+
})
|
|
2824
|
+
};
|
|
2825
|
+
}
|
|
2826
|
+
return void 0;
|
|
2827
|
+
}
|
|
2828
|
+
return { type: "icon", value: getInlineMedia(media) };
|
|
2829
|
+
};
|
|
2830
|
+
var getPriority2 = (control) => isKnownControl(control) ? control : "secondary";
|
|
2831
|
+
var prefersMedia = (control) => {
|
|
2832
|
+
return false;
|
|
2833
|
+
};
|
|
2834
|
+
var knownControls = ["primary", "secondary", "secondary-neutral"];
|
|
2835
|
+
var isKnownControl = (control) => control !== void 0 && knownControls.includes(control);
|
|
2836
|
+
var getSentiment = (context) => {
|
|
2837
|
+
return "default";
|
|
2838
|
+
};
|
|
2839
|
+
var getIconButtonPriority = (control) => {
|
|
2840
|
+
const priority = getPriority2(control);
|
|
2841
|
+
return priority === "secondary-neutral" ? "tertiary" : priority;
|
|
2842
|
+
};
|
|
2843
|
+
|
|
2844
|
+
// ../renderers/src/step/topbar/TopBar.tsx
|
|
2845
|
+
var import_jsx_runtime66 = require("react/jsx-runtime");
|
|
2846
|
+
function TopBar({ back, toolbar }) {
|
|
2847
|
+
return back || toolbar ? /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("div", { className: "d-flex m-b-2", children: [
|
|
2848
|
+
back ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(BackButton, __spreadValues({}, back)) : null,
|
|
2849
|
+
toolbar ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Toolbar, __spreadValues({}, toolbar)) : null
|
|
2850
|
+
] }) : null;
|
|
2851
|
+
}
|
|
2852
|
+
|
|
2853
|
+
// ../renderers/src/step/SplashCelebrationStepRenderer.tsx
|
|
2854
|
+
var import_jsx_runtime67 = require("react/jsx-runtime");
|
|
2855
|
+
var SplashCelebrationStepRenderer = {
|
|
2856
|
+
canRenderType: "step",
|
|
2857
|
+
canRender: ({ control }) => control === "splash-celebration",
|
|
2858
|
+
render: SplashCelebrationStepRendererComponent
|
|
2859
|
+
};
|
|
2860
|
+
function SplashCelebrationStepRendererComponent(props) {
|
|
2861
|
+
const { back, toolbar, children, trackEvent } = props;
|
|
2862
|
+
useCustomTheme("forest-green", trackEvent);
|
|
2863
|
+
return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("div", { className: "splash-screen m-t-5", children: [
|
|
2864
|
+
/* @__PURE__ */ (0, import_jsx_runtime67.jsx)(TopBar, { back, toolbar }),
|
|
2865
|
+
children
|
|
2866
|
+
] });
|
|
2867
|
+
}
|
|
2868
|
+
|
|
2869
|
+
// ../renderers/src/step/SplashStepRenderer.tsx
|
|
2870
|
+
var import_jsx_runtime68 = require("react/jsx-runtime");
|
|
2871
|
+
var SplashStepRenderer = {
|
|
2872
|
+
canRenderType: "step",
|
|
2873
|
+
canRender: ({ control }) => control === "splash",
|
|
2874
|
+
render: SplashStepRendererComponent
|
|
2875
|
+
};
|
|
2876
|
+
function SplashStepRendererComponent(props) {
|
|
2877
|
+
const { back, toolbar, children } = props;
|
|
2878
|
+
return /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)("div", { className: "splash-screen m-t-5", children: [
|
|
2879
|
+
/* @__PURE__ */ (0, import_jsx_runtime68.jsx)(TopBar, { back, toolbar }),
|
|
2880
|
+
children
|
|
2881
|
+
] });
|
|
2882
|
+
}
|
|
2883
|
+
|
|
2884
|
+
// ../renderers/src/step/StepRenderer.tsx
|
|
2885
|
+
var import_components46 = require("@transferwise/components");
|
|
2886
|
+
var import_jsx_runtime69 = require("react/jsx-runtime");
|
|
2887
|
+
var StepRenderer = {
|
|
2888
|
+
canRenderType: "step",
|
|
2889
|
+
render: StepRendererComponent
|
|
2890
|
+
};
|
|
2891
|
+
function StepRendererComponent(props) {
|
|
2892
|
+
const { back, description, error, title, children, toolbar } = props;
|
|
2893
|
+
return /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)(import_jsx_runtime69.Fragment, { children: [
|
|
2894
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)(TopBar, { back, toolbar }),
|
|
2895
|
+
title || description ? /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)("div", { className: "m-b-4", children: [
|
|
2896
|
+
title ? /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(import_components46.Title, { as: "h1", type: "title-section", className: "text-xs-center m-b-2", children: title }) : void 0,
|
|
2897
|
+
description ? /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("p", { className: "text-xs-center np-text-body-large", children: description }) : void 0
|
|
2898
|
+
] }) : void 0,
|
|
2899
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(import_components46.Alert, { type: "negative", className: "m-b-2", message: error }) : void 0,
|
|
2900
|
+
children
|
|
2901
|
+
] });
|
|
2902
|
+
}
|
|
2903
|
+
|
|
2904
|
+
// ../renderers/src/TabsRenderer.tsx
|
|
2905
|
+
var import_components47 = require("@transferwise/components");
|
|
2906
|
+
var import_react17 = require("react");
|
|
2907
|
+
var import_jsx_runtime70 = require("react/jsx-runtime");
|
|
2908
|
+
var TabsRenderer = {
|
|
2909
|
+
canRenderType: "tabs",
|
|
2910
|
+
render: (props) => {
|
|
2911
|
+
switch (props.control) {
|
|
2912
|
+
case "segmented":
|
|
2913
|
+
if (props.tabs.length > 3) {
|
|
2914
|
+
return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(TabsRendererComponent, __spreadValues({}, props));
|
|
2915
|
+
}
|
|
2916
|
+
return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(SegmentedTabsRendererComponent, __spreadValues({}, props));
|
|
2917
|
+
case "chips":
|
|
2918
|
+
return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(ChipsTabsRendererComponent, __spreadValues({}, props));
|
|
2919
|
+
default:
|
|
2920
|
+
return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(TabsRendererComponent, __spreadValues({}, props));
|
|
2921
|
+
}
|
|
2922
|
+
}
|
|
2923
|
+
};
|
|
2924
|
+
function TabsRendererComponent({ uid, margin, tabs }) {
|
|
2925
|
+
const [selectedIndex, setSelectedIndex] = (0, import_react17.useState)(0);
|
|
2926
|
+
return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("div", { className: getMargin(margin), children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
|
|
2927
|
+
import_components47.Tabs,
|
|
2928
|
+
{
|
|
2929
|
+
name: uid,
|
|
2930
|
+
selected: selectedIndex != null ? selectedIndex : 0,
|
|
2931
|
+
tabs: tabs.map((option) => ({
|
|
2932
|
+
title: option.title,
|
|
2933
|
+
disabled: false,
|
|
2934
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: "m-t-2", children: [
|
|
2935
|
+
" ",
|
|
2936
|
+
option.children,
|
|
2937
|
+
" "
|
|
2938
|
+
] })
|
|
2939
|
+
})),
|
|
2940
|
+
onTabSelect: setSelectedIndex
|
|
2941
|
+
}
|
|
2942
|
+
) });
|
|
2943
|
+
}
|
|
2944
|
+
function SegmentedTabsRendererComponent({ uid, margin, tabs }) {
|
|
2945
|
+
var _a;
|
|
2946
|
+
const [selectedIndex, setSelectedIndex] = (0, import_react17.useState)(0);
|
|
2947
|
+
return /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: getMargin(margin), children: [
|
|
2948
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
|
|
2949
|
+
import_components47.SegmentedControl,
|
|
2950
|
+
{
|
|
2951
|
+
name: uid,
|
|
2952
|
+
value: String(selectedIndex),
|
|
2953
|
+
mode: "view",
|
|
2954
|
+
segments: tabs.map((tab, index) => ({
|
|
2955
|
+
id: String(index),
|
|
2956
|
+
value: String(index),
|
|
2957
|
+
label: tab.title,
|
|
2958
|
+
controls: `${uid}-children`
|
|
2959
|
+
})),
|
|
2960
|
+
onChange: (value) => setSelectedIndex(Number(value))
|
|
2961
|
+
}
|
|
2962
|
+
),
|
|
2963
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)("div", { id: `${uid}-children`, className: "m-t-2", children: (_a = tabs[selectedIndex]) == null ? void 0 : _a.children })
|
|
2964
|
+
] });
|
|
2965
|
+
}
|
|
2966
|
+
function ChipsTabsRendererComponent({ margin, tabs }) {
|
|
2967
|
+
var _a;
|
|
2968
|
+
const [selectedIndex, setSelectedIndex] = (0, import_react17.useState)(0);
|
|
2969
|
+
return /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: getMargin(margin), children: [
|
|
2970
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)("div", { className: "chips-container", children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
|
|
2971
|
+
import_components47.Chips,
|
|
2972
|
+
{
|
|
2973
|
+
chips: tabs.map((tab, index) => ({ label: tab.title, value: index })),
|
|
2974
|
+
selected: selectedIndex,
|
|
2975
|
+
onChange: ({ selectedValue }) => setSelectedIndex(Number(selectedValue))
|
|
2976
|
+
}
|
|
2977
|
+
) }),
|
|
2978
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)("div", { className: "m-t-2", children: (_a = tabs[selectedIndex]) == null ? void 0 : _a.children })
|
|
2979
|
+
] });
|
|
2980
|
+
}
|
|
2981
|
+
|
|
2982
|
+
// ../renderers/src/TextInputRenderer.tsx
|
|
2983
|
+
var import_components49 = require("@transferwise/components");
|
|
2984
|
+
|
|
2985
|
+
// ../renderers/src/components/VariableTextInput.tsx
|
|
2986
|
+
var import_components48 = require("@transferwise/components");
|
|
2987
|
+
var import_jsx_runtime71 = require("react/jsx-runtime");
|
|
2988
|
+
var commonKeys = [
|
|
2989
|
+
"autoComplete",
|
|
2990
|
+
"autoCapitalize",
|
|
2991
|
+
"placeholder",
|
|
2992
|
+
"control",
|
|
2993
|
+
"disabled",
|
|
2994
|
+
"displayFormat",
|
|
2995
|
+
"id",
|
|
2996
|
+
"onBlur",
|
|
2997
|
+
"onFocus",
|
|
2998
|
+
"placeholder",
|
|
2999
|
+
"value"
|
|
3000
|
+
];
|
|
3001
|
+
function VariableTextInput(inputProps) {
|
|
3002
|
+
const { id, value, control, onChange } = inputProps;
|
|
3003
|
+
const commonProps = __spreadProps(__spreadValues({}, pick(inputProps, ...commonKeys)), { name: id });
|
|
3004
|
+
switch (control) {
|
|
3005
|
+
case "email":
|
|
3006
|
+
return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(TextInput, __spreadProps(__spreadValues({}, commonProps), { type: "email", onChange }));
|
|
3007
|
+
case "password":
|
|
3008
|
+
return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(TextInput, __spreadProps(__spreadValues({}, commonProps), { type: "password", onChange }));
|
|
3009
|
+
case "numeric": {
|
|
3010
|
+
const numericProps = __spreadProps(__spreadValues({}, commonProps), { type: "number", onWheel });
|
|
3011
|
+
return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
|
|
3012
|
+
TextInput,
|
|
3013
|
+
__spreadProps(__spreadValues({}, numericProps), {
|
|
3014
|
+
onChange: (newValue) => {
|
|
3015
|
+
const numericValueOrNull = !Number.isNaN(Number.parseFloat(newValue)) ? newValue : null;
|
|
3016
|
+
onChange(numericValueOrNull);
|
|
3017
|
+
}
|
|
3018
|
+
})
|
|
3019
|
+
);
|
|
3020
|
+
}
|
|
3021
|
+
case "phone-number":
|
|
3022
|
+
return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(import_components48.PhoneNumberInput, __spreadProps(__spreadValues({ initialValue: value }, commonProps), { onChange }));
|
|
3023
|
+
default: {
|
|
3024
|
+
return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(TextInput, __spreadProps(__spreadValues({}, commonProps), { type: "text", onChange }));
|
|
3025
|
+
}
|
|
3026
|
+
}
|
|
3027
|
+
}
|
|
3028
|
+
function TextInput(props) {
|
|
3029
|
+
const _a = props, { control, displayFormat, onChange } = _a, commonProps = __objRest(_a, ["control", "displayFormat", "onChange"]);
|
|
3030
|
+
const InputWithPattern = control === "textarea" ? import_components48.TextareaWithDisplayFormat : import_components48.InputWithDisplayFormat;
|
|
3031
|
+
const InputWithoutPattern = control === "textarea" ? import_components48.TextArea : import_components48.Input;
|
|
3032
|
+
return displayFormat ? /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(InputWithPattern, __spreadProps(__spreadValues({ displayPattern: displayFormat }, commonProps), { onChange })) : /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(InputWithoutPattern, __spreadProps(__spreadValues({}, commonProps), { onChange: (e) => onChange(e.target.value) }));
|
|
3033
|
+
}
|
|
3034
|
+
|
|
3035
|
+
// ../renderers/src/TextInputRenderer.tsx
|
|
3036
|
+
var import_jsx_runtime72 = require("react/jsx-runtime");
|
|
3037
|
+
var TextInputRenderer = {
|
|
3038
|
+
canRenderType: "input-text",
|
|
3039
|
+
render: (props) => {
|
|
3040
|
+
const _a = props, {
|
|
3041
|
+
id,
|
|
3042
|
+
title,
|
|
3043
|
+
description,
|
|
3044
|
+
help,
|
|
3045
|
+
media,
|
|
3046
|
+
validationState,
|
|
3047
|
+
value: initialValue,
|
|
3048
|
+
onChange
|
|
3049
|
+
} = _a, rest = __objRest(_a, [
|
|
3050
|
+
"id",
|
|
3051
|
+
"title",
|
|
3052
|
+
"description",
|
|
3053
|
+
"help",
|
|
3054
|
+
"media",
|
|
3055
|
+
"validationState",
|
|
3056
|
+
"value",
|
|
3057
|
+
"onChange"
|
|
3058
|
+
]);
|
|
3059
|
+
const value = initialValue != null ? initialValue : "";
|
|
3060
|
+
const inputProps = __spreadProps(__spreadValues({}, rest), {
|
|
3061
|
+
value,
|
|
3062
|
+
id,
|
|
3063
|
+
onChange: (newValue) => {
|
|
3064
|
+
if ((value != null ? value : "") !== (newValue != null ? newValue : "")) {
|
|
3065
|
+
onChange(newValue);
|
|
3066
|
+
}
|
|
3067
|
+
}
|
|
3068
|
+
});
|
|
3069
|
+
return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
|
|
3070
|
+
FieldInput_default,
|
|
3071
|
+
{
|
|
3072
|
+
id,
|
|
3073
|
+
label: title,
|
|
3074
|
+
description,
|
|
3075
|
+
validation: validationState,
|
|
3076
|
+
help,
|
|
3077
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(import_components49.InputGroup, { addonStart: getInputGroupAddonStart(media), children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(VariableTextInput, __spreadValues({}, inputProps)) })
|
|
3078
|
+
}
|
|
3079
|
+
);
|
|
3080
|
+
}
|
|
3081
|
+
};
|
|
3082
|
+
var TextInputRenderer_default = TextInputRenderer;
|
|
3083
|
+
|
|
3084
|
+
// ../renderers/src/UploadInputRenderer.tsx
|
|
3085
|
+
var import_components50 = require("@transferwise/components");
|
|
3086
|
+
|
|
3087
|
+
// ../renderers/src/utils/getRandomId.ts
|
|
3088
|
+
var getRandomId = () => Math.random().toString(36).substring(2);
|
|
3089
|
+
|
|
3090
|
+
// ../renderers/src/UploadInputRenderer.tsx
|
|
3091
|
+
var import_jsx_runtime73 = require("react/jsx-runtime");
|
|
3092
|
+
var UploadInputRenderer = {
|
|
3093
|
+
canRenderType: "input-upload",
|
|
3094
|
+
render: (props) => {
|
|
3095
|
+
const { id, accepts, title, description, disabled, maxSize, validationState, onUpload } = props;
|
|
3096
|
+
const onUploadFile = async (formData) => {
|
|
3097
|
+
const file = formData.get("file");
|
|
3098
|
+
return onUpload(file).then(() => ({
|
|
3099
|
+
id: getRandomId()
|
|
3100
|
+
}));
|
|
3101
|
+
};
|
|
3102
|
+
const onDeleteFile = async () => {
|
|
3103
|
+
await onUpload(null);
|
|
3104
|
+
};
|
|
3105
|
+
return (
|
|
3106
|
+
// We don't pass help here as there is no sensible place to display it
|
|
3107
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
|
|
3108
|
+
UploadFieldInput_default,
|
|
3109
|
+
{
|
|
3110
|
+
id,
|
|
3111
|
+
label: void 0,
|
|
3112
|
+
description: void 0,
|
|
3113
|
+
validation: validationState,
|
|
3114
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
|
|
3115
|
+
import_components50.UploadInput,
|
|
3116
|
+
{
|
|
3117
|
+
id,
|
|
3118
|
+
description,
|
|
3119
|
+
disabled,
|
|
3120
|
+
sizeLimit: getSizeLimit(maxSize),
|
|
3121
|
+
fileTypes: acceptsToFileTypes(accepts),
|
|
3122
|
+
uploadButtonTitle: title,
|
|
3123
|
+
onDeleteFile,
|
|
3124
|
+
onUploadFile
|
|
3125
|
+
}
|
|
3126
|
+
)
|
|
3127
|
+
}
|
|
3128
|
+
)
|
|
3129
|
+
);
|
|
3130
|
+
}
|
|
3131
|
+
};
|
|
3132
|
+
var LargeUploadRenderer = {
|
|
3133
|
+
canRenderType: "input-upload",
|
|
3134
|
+
canRender: (props) => props.control === "upload-large",
|
|
3135
|
+
render: (props) => {
|
|
3136
|
+
const _a = props, {
|
|
3137
|
+
id,
|
|
3138
|
+
accepts,
|
|
3139
|
+
control,
|
|
3140
|
+
title,
|
|
3141
|
+
description,
|
|
3142
|
+
disabled,
|
|
3143
|
+
help,
|
|
3144
|
+
type,
|
|
3145
|
+
validationState,
|
|
3146
|
+
maxSize = null,
|
|
3147
|
+
onUpload
|
|
3148
|
+
} = _a, rest = __objRest(_a, [
|
|
3149
|
+
"id",
|
|
3150
|
+
"accepts",
|
|
3151
|
+
"control",
|
|
3152
|
+
"title",
|
|
3153
|
+
"description",
|
|
3154
|
+
"disabled",
|
|
3155
|
+
"help",
|
|
3156
|
+
"type",
|
|
3157
|
+
"validationState",
|
|
3158
|
+
"maxSize",
|
|
3159
|
+
"onUpload"
|
|
3160
|
+
]);
|
|
3161
|
+
const uploadProps = __spreadProps(__spreadValues({}, rest), { id, name: id, maxSize });
|
|
3162
|
+
const onUploadFile = async (file, fileName) => {
|
|
3163
|
+
try {
|
|
3164
|
+
const convertedFile = file ? await toFile(file, fileName) : null;
|
|
3165
|
+
await onUpload(convertedFile);
|
|
3166
|
+
} catch (e) {
|
|
3167
|
+
await onUpload(null);
|
|
3168
|
+
throw e;
|
|
3169
|
+
}
|
|
3170
|
+
};
|
|
3171
|
+
const filetypes = acceptsToFileTypes(accepts);
|
|
3172
|
+
const usAccept = filetypes === "*" ? "*" : filetypes.join(",");
|
|
3173
|
+
return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
|
|
3174
|
+
FieldInput_default,
|
|
3175
|
+
{
|
|
3176
|
+
id,
|
|
3177
|
+
label: title,
|
|
3178
|
+
description,
|
|
3179
|
+
validation: validationState,
|
|
3180
|
+
help,
|
|
3181
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
|
|
3182
|
+
import_components50.Upload,
|
|
3183
|
+
__spreadProps(__spreadValues({}, uploadProps), {
|
|
3184
|
+
usAccept,
|
|
3185
|
+
usDisabled: disabled,
|
|
3186
|
+
onSuccess: onUploadFile,
|
|
3187
|
+
onFailure: async () => onUpload(null),
|
|
3188
|
+
onCancel: async () => onUpload(null)
|
|
3189
|
+
})
|
|
3190
|
+
)
|
|
3191
|
+
}
|
|
3192
|
+
);
|
|
3193
|
+
}
|
|
3194
|
+
};
|
|
3195
|
+
|
|
3196
|
+
// ../renderers/src/NewListItem/NewDecisionRenderer.tsx
|
|
3197
|
+
var import_components53 = require("@transferwise/components");
|
|
3198
|
+
|
|
3199
|
+
// ../renderers/src/NewListItem/getInlineAlert.tsx
|
|
3200
|
+
var import_components51 = require("@transferwise/components");
|
|
3201
|
+
var import_jsx_runtime74 = require("react/jsx-runtime");
|
|
3202
|
+
var getInlineAlert = (inlineAlert) => inlineAlert ? /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(import_components51.ListItem.Prompt, { sentiment: inlineAlert == null ? void 0 : inlineAlert.context, children: inlineAlert.content }) : void 0;
|
|
3203
|
+
|
|
3204
|
+
// ../renderers/src/NewListItem/getAdditionalInfo.tsx
|
|
3205
|
+
var import_components52 = require("@transferwise/components");
|
|
3206
|
+
var import_jsx_runtime75 = require("react/jsx-runtime");
|
|
3207
|
+
var getAdditionalInfo = (additionalInfo) => {
|
|
3208
|
+
if (!additionalInfo) {
|
|
3209
|
+
return void 0;
|
|
3210
|
+
}
|
|
3211
|
+
const { href, text, onClick } = additionalInfo;
|
|
3212
|
+
if (href || onClick) {
|
|
3213
|
+
return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
|
|
3214
|
+
import_components52.ListItem.AdditionalInfo,
|
|
3215
|
+
{
|
|
3216
|
+
action: {
|
|
3217
|
+
label: text,
|
|
3218
|
+
href,
|
|
3219
|
+
onClick,
|
|
3220
|
+
target: "_blank"
|
|
3221
|
+
}
|
|
3222
|
+
}
|
|
3223
|
+
);
|
|
3224
|
+
}
|
|
3225
|
+
return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(import_components52.ListItem.AdditionalInfo, { children: additionalInfo == null ? void 0 : additionalInfo.text });
|
|
3226
|
+
};
|
|
3227
|
+
|
|
3228
|
+
// ../renderers/src/NewListItem/NewDecisionRenderer.tsx
|
|
3229
|
+
var import_jsx_runtime76 = require("react/jsx-runtime");
|
|
3230
|
+
var DecisionRenderer2 = {
|
|
3231
|
+
canRenderType: "decision",
|
|
3232
|
+
render: (props) => /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(DecisionWrapper, __spreadProps(__spreadValues({}, props), { renderDecisionList: renderDecisionList2 }))
|
|
3233
|
+
};
|
|
3234
|
+
var renderDecisionList2 = ({ options, control }) => {
|
|
3235
|
+
return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(import_jsx_runtime76.Fragment, { children: options.map((option) => {
|
|
3236
|
+
const {
|
|
3237
|
+
description,
|
|
3238
|
+
disabled,
|
|
3239
|
+
media,
|
|
3240
|
+
title: itemTitle,
|
|
3241
|
+
tag,
|
|
3242
|
+
href,
|
|
3243
|
+
additionalText,
|
|
3244
|
+
inlineAlert,
|
|
3245
|
+
supportingValues,
|
|
3246
|
+
onClick
|
|
3247
|
+
} = option;
|
|
3248
|
+
return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
|
|
3249
|
+
import_components53.ListItem,
|
|
3250
|
+
{
|
|
3251
|
+
title: itemTitle,
|
|
3252
|
+
subtitle: description,
|
|
3253
|
+
spotlight: control === "spotlight" ? tag === "spotlight-active" ? "active" : "inactive" : void 0,
|
|
3254
|
+
disabled,
|
|
3255
|
+
valueTitle: supportingValues == null ? void 0 : supportingValues.value,
|
|
3256
|
+
valueSubtitle: supportingValues == null ? void 0 : supportingValues.subvalue,
|
|
3257
|
+
media: getMedia(media, control === "with-avatar" || tag === "with-avatar"),
|
|
3258
|
+
prompt: getInlineAlert(inlineAlert),
|
|
3259
|
+
additionalInfo: additionalText ? getAdditionalInfo({ text: additionalText }) : void 0,
|
|
3260
|
+
control: href ? /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(import_components53.ListItem.Navigation, { href, target: "_blank" }) : /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(import_components53.ListItem.Navigation, { onClick })
|
|
3261
|
+
},
|
|
3262
|
+
JSON.stringify(option)
|
|
3263
|
+
);
|
|
3264
|
+
}) });
|
|
3265
|
+
};
|
|
3266
|
+
var NewDecisionRenderer_default = DecisionRenderer2;
|
|
3267
|
+
|
|
3268
|
+
// ../renderers/src/NewListItem/NewListRenderer.tsx
|
|
3269
|
+
var import_components54 = require("@transferwise/components");
|
|
3270
|
+
var import_jsx_runtime77 = require("react/jsx-runtime");
|
|
3271
|
+
var ListRenderer2 = {
|
|
3272
|
+
canRenderType: "list",
|
|
3273
|
+
render: ({ callToAction, control, margin, items, title }) => /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)("div", { className: getMargin(margin), children: [
|
|
3274
|
+
/* @__PURE__ */ (0, import_jsx_runtime77.jsx)(Header7, { title, callToAction }),
|
|
3275
|
+
items.map((item) => {
|
|
3276
|
+
const {
|
|
3277
|
+
title: itemTitle,
|
|
3278
|
+
description,
|
|
3279
|
+
supportingValues,
|
|
3280
|
+
media,
|
|
3281
|
+
tag,
|
|
3282
|
+
additionalInfo,
|
|
3283
|
+
inlineAlert
|
|
3284
|
+
} = item;
|
|
3285
|
+
return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
|
|
3286
|
+
import_components54.ListItem,
|
|
3287
|
+
{
|
|
3288
|
+
title: itemTitle,
|
|
3289
|
+
subtitle: description,
|
|
3290
|
+
valueTitle: supportingValues == null ? void 0 : supportingValues.value,
|
|
3291
|
+
valueSubtitle: supportingValues == null ? void 0 : supportingValues.subvalue,
|
|
3292
|
+
media: getMedia(media, control === "with-avatar" || tag === "with-avatar"),
|
|
3293
|
+
prompt: getInlineAlert(inlineAlert),
|
|
3294
|
+
additionalInfo: getAdditionalInfo(additionalInfo)
|
|
3295
|
+
},
|
|
3296
|
+
itemTitle
|
|
3297
|
+
);
|
|
3298
|
+
})
|
|
3299
|
+
] })
|
|
3300
|
+
};
|
|
3301
|
+
var NewListRenderer_default = ListRenderer2;
|
|
3302
|
+
|
|
3303
|
+
// ../renderers/src/NewListItem/NewReviewRenderer.tsx
|
|
3304
|
+
var import_components55 = require("@transferwise/components");
|
|
3305
|
+
var import_icons4 = require("@transferwise/icons");
|
|
3306
|
+
var import_jsx_runtime78 = require("react/jsx-runtime");
|
|
3307
|
+
var IGNORED_CONTROLS = [
|
|
3308
|
+
"horizontal",
|
|
3309
|
+
"horizontal-end-aligned",
|
|
3310
|
+
"horizontal-start-aligned",
|
|
3311
|
+
"vertical-two-column"
|
|
3312
|
+
];
|
|
3313
|
+
var ReviewRenderer2 = {
|
|
3314
|
+
canRenderType: "review",
|
|
3315
|
+
canRender: ({ control }) => control ? !IGNORED_CONTROLS.includes(control) : true,
|
|
3316
|
+
render: ({ callToAction, control, margin, fields, title }) => /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)("div", { className: getMargin(margin), children: [
|
|
3317
|
+
/* @__PURE__ */ (0, import_jsx_runtime78.jsx)(Header7, { title, callToAction }),
|
|
3318
|
+
fields.map((field) => {
|
|
3319
|
+
var _a;
|
|
3320
|
+
const {
|
|
3321
|
+
label,
|
|
3322
|
+
value,
|
|
3323
|
+
media,
|
|
3324
|
+
tag,
|
|
3325
|
+
additionalInfo,
|
|
3326
|
+
inlineAlert,
|
|
3327
|
+
help,
|
|
3328
|
+
callToAction: itemCallToAction
|
|
3329
|
+
} = field;
|
|
3330
|
+
return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
|
|
3331
|
+
import_components55.ListItem,
|
|
3332
|
+
{
|
|
3333
|
+
title: value,
|
|
3334
|
+
subtitle: label,
|
|
3335
|
+
inverted: true,
|
|
3336
|
+
media: getMedia(media, control === "with-avatar" || tag === "with-avatar"),
|
|
3337
|
+
control: (_a = getCTAControl(itemCallToAction)) != null ? _a : getHelpControl(help),
|
|
3338
|
+
prompt: getInlineAlert(inlineAlert),
|
|
3339
|
+
additionalInfo: getAdditionalInfo(additionalInfo)
|
|
3340
|
+
},
|
|
3341
|
+
JSON.stringify(field)
|
|
3342
|
+
);
|
|
3343
|
+
})
|
|
3344
|
+
] })
|
|
3345
|
+
};
|
|
3346
|
+
var getCTAControl = (callToAction) => {
|
|
3347
|
+
if (!callToAction) {
|
|
3348
|
+
return void 0;
|
|
3349
|
+
}
|
|
3350
|
+
const { accessibilityDescription, href, title, onClick } = callToAction;
|
|
3351
|
+
if (href) {
|
|
3352
|
+
return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(import_components55.ListItem.Button, { href, partiallyInteractive: true, "aria-description": accessibilityDescription, children: title });
|
|
3353
|
+
}
|
|
3354
|
+
return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
|
|
3355
|
+
import_components55.ListItem.Button,
|
|
3356
|
+
{
|
|
3357
|
+
"aria-description": accessibilityDescription,
|
|
3358
|
+
partiallyInteractive: true,
|
|
3359
|
+
onClick,
|
|
3360
|
+
children: title
|
|
3361
|
+
}
|
|
3362
|
+
);
|
|
3363
|
+
};
|
|
3364
|
+
var getHelpControl = (help) => {
|
|
3365
|
+
if (!help) {
|
|
3366
|
+
return void 0;
|
|
3367
|
+
}
|
|
3368
|
+
return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(import_components55.Popover, { content: help, children: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(import_components55.ListItem.IconButton, { partiallyInteractive: true, children: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(import_icons4.QuestionMarkCircle, {}) }) });
|
|
3369
|
+
};
|
|
3370
|
+
var NewReviewRenderer_default = ReviewRenderer2;
|
|
3371
|
+
|
|
3372
|
+
// ../renderers/src/NewListItem/NewStatusListRenderer.tsx
|
|
3373
|
+
var import_components56 = require("@transferwise/components");
|
|
3374
|
+
var import_jsx_runtime79 = require("react/jsx-runtime");
|
|
3375
|
+
var NewStatusListRenderer = {
|
|
3376
|
+
canRenderType: "status-list",
|
|
3377
|
+
render: ({ margin, items, title }) => /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)("div", { className: getMargin(margin), children: [
|
|
3378
|
+
title ? /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(import_components56.Header, { title, className: "m-b-2" }) : null,
|
|
3379
|
+
items.map((item) => {
|
|
3380
|
+
const { callToAction, description, icon, status, title: itemTitle } = item;
|
|
3381
|
+
return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
|
|
3382
|
+
import_components56.ListItem,
|
|
3383
|
+
{
|
|
3384
|
+
title: itemTitle,
|
|
3385
|
+
subtitle: description,
|
|
3386
|
+
media: icon && "name" in icon ? /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(import_components56.AvatarView, { badge: { status: mapStatus2(status) }, children: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(DynamicIcon_default, { name: icon.name }) }) : void 0,
|
|
3387
|
+
additionalInfo: callToAction ? /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
|
|
3388
|
+
import_components56.ListItem.AdditionalInfo,
|
|
3389
|
+
{
|
|
3390
|
+
action: {
|
|
3391
|
+
href: callToAction.href,
|
|
3392
|
+
onClick: callToAction.href ? void 0 : callToAction.onClick,
|
|
3393
|
+
label: callToAction.title,
|
|
3394
|
+
target: "_blank"
|
|
3395
|
+
}
|
|
3396
|
+
}
|
|
3397
|
+
) : void 0
|
|
3398
|
+
},
|
|
3399
|
+
JSON.stringify(item)
|
|
3400
|
+
);
|
|
3401
|
+
})
|
|
3402
|
+
] })
|
|
3403
|
+
};
|
|
3404
|
+
var mapStatus2 = (status) => {
|
|
3405
|
+
switch (status) {
|
|
3406
|
+
case "done":
|
|
3407
|
+
return "positive";
|
|
3408
|
+
case "pending":
|
|
3409
|
+
return "pending";
|
|
3410
|
+
default:
|
|
3411
|
+
return void 0;
|
|
3412
|
+
}
|
|
3413
|
+
};
|
|
3414
|
+
var NewStatusListRenderer_default = NewStatusListRenderer;
|
|
3415
|
+
|
|
3416
|
+
// ../renderers/src/ButtonRenderer/ButtonRendererV2.tsx
|
|
3417
|
+
var import_components57 = require("@transferwise/components");
|
|
3418
|
+
|
|
3419
|
+
// ../renderers/src/utils/isButtonPriority.ts
|
|
3420
|
+
var validPriorities = ["primary", "secondary", "secondary-neutral", "tertiary"];
|
|
3421
|
+
var isButtonPriority = (control) => validPriorities.includes(control);
|
|
3422
|
+
|
|
3423
|
+
// ../renderers/src/ButtonRenderer/ButtonRendererV2.tsx
|
|
3424
|
+
var import_react18 = require("react");
|
|
3425
|
+
var import_jsx_runtime80 = require("react/jsx-runtime");
|
|
3426
|
+
var ButtonRendererV2 = {
|
|
3427
|
+
canRenderType: "button",
|
|
3428
|
+
render: ButtonComponent2
|
|
3429
|
+
};
|
|
3430
|
+
function ButtonComponent2(props) {
|
|
3431
|
+
const { control, context, disabled, margin, title, size, stepLoadingState, onClick } = props;
|
|
3432
|
+
const [spinny, setSpinny] = (0, import_react18.useState)(false);
|
|
3433
|
+
(0, import_react18.useEffect)(() => {
|
|
3434
|
+
if (stepLoadingState === "idle") {
|
|
3435
|
+
setSpinny(false);
|
|
3436
|
+
}
|
|
3437
|
+
}, [stepLoadingState]);
|
|
3438
|
+
const loading = spinny && stepLoadingState !== "idle";
|
|
3439
|
+
return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
|
|
3440
|
+
import_components57.Button,
|
|
3441
|
+
{
|
|
3442
|
+
v2: true,
|
|
3443
|
+
block: true,
|
|
3444
|
+
className: getMargin(margin),
|
|
3445
|
+
disabled,
|
|
3446
|
+
priority: getPriority3(control),
|
|
3447
|
+
loading,
|
|
3448
|
+
size: mapButtonSize(size),
|
|
3449
|
+
sentiment: getSentiment2(context),
|
|
3450
|
+
onClick: () => {
|
|
3451
|
+
setSpinny(true);
|
|
3452
|
+
onClick();
|
|
3453
|
+
},
|
|
3454
|
+
children: title
|
|
3455
|
+
}
|
|
3456
|
+
);
|
|
3457
|
+
}
|
|
3458
|
+
var getSentiment2 = (context) => context === "negative" ? "negative" : "default";
|
|
3459
|
+
var getPriority3 = (control) => control && isButtonPriority(control) ? control : "secondary";
|
|
3460
|
+
|
|
3461
|
+
// ../renderers/src/ProgressRenderer.tsx
|
|
3462
|
+
var import_components58 = require("@transferwise/components");
|
|
3463
|
+
var import_jsx_runtime81 = require("react/jsx-runtime");
|
|
3464
|
+
var ProgressRenderer = {
|
|
3465
|
+
canRenderType: "progress",
|
|
3466
|
+
render: ({ uid, title, help, progress, progressText, margin, description }) => {
|
|
3467
|
+
return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
|
|
3468
|
+
import_components58.ProgressBar,
|
|
3469
|
+
{
|
|
3470
|
+
id: uid,
|
|
3471
|
+
className: getMargin(margin),
|
|
3472
|
+
title: title && help ? /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(LabelContentWithHelp, { text: title, help }) : title,
|
|
3473
|
+
description,
|
|
3474
|
+
progress: {
|
|
3475
|
+
max: 1,
|
|
3476
|
+
value: progress
|
|
3477
|
+
},
|
|
3478
|
+
textEnd: progressText
|
|
3479
|
+
}
|
|
3480
|
+
);
|
|
3481
|
+
}
|
|
3482
|
+
};
|
|
3483
|
+
|
|
3484
|
+
// ../renderers/src/getWiseRenderers.ts
|
|
3485
|
+
var getListItemRenderers = () => [
|
|
3486
|
+
NewDecisionRenderer_default,
|
|
3487
|
+
NewListRenderer_default,
|
|
3488
|
+
NewReviewRenderer_default,
|
|
3489
|
+
NewStatusListRenderer_default
|
|
3490
|
+
];
|
|
3491
|
+
var getButtonV2Renderers = () => [ButtonRendererV2];
|
|
3492
|
+
var getWiseRenderers = () => [
|
|
3493
|
+
AddressValidationButtonRenderer_default,
|
|
3494
|
+
AlertRenderer_default,
|
|
3495
|
+
CheckboxInputRenderer_default,
|
|
3496
|
+
BoxRenderer_default,
|
|
3497
|
+
ButtonRenderer,
|
|
3498
|
+
ColumnsRenderer_default,
|
|
3499
|
+
DateInputRenderer_default,
|
|
3500
|
+
DecisionRenderer_default,
|
|
3501
|
+
DividerRenderer_default,
|
|
3502
|
+
ExternalConfirmationRenderer_default,
|
|
3503
|
+
FormRenderer_default,
|
|
3504
|
+
FormSectionRenderer_default,
|
|
3505
|
+
HeadingRenderer_default,
|
|
3506
|
+
ImageRenderer_default,
|
|
3507
|
+
InstructionsRenderer_default,
|
|
3508
|
+
IntegerInputRenderer_default,
|
|
3509
|
+
LargeUploadRenderer,
|
|
3510
|
+
ListRenderer_default,
|
|
3511
|
+
LoadingIndicatorRenderer_default,
|
|
3512
|
+
MarkdownRenderer_default,
|
|
3513
|
+
ModalRenderer,
|
|
3514
|
+
ModalLayoutRenderer_default,
|
|
3515
|
+
MultiSelectInputRenderer_default,
|
|
3516
|
+
MultiUploadInputRenderer_default,
|
|
3517
|
+
NumberInputRenderer_default,
|
|
3518
|
+
ParagraphRenderer_default,
|
|
3519
|
+
ProgressRenderer,
|
|
3520
|
+
RepeatableRenderer_default,
|
|
3521
|
+
ReviewRenderer_default,
|
|
3522
|
+
SearchRenderer_default,
|
|
3523
|
+
SelectInputRenderer_default,
|
|
3524
|
+
SectionRenderer_default,
|
|
3525
|
+
StatusListRenderer_default,
|
|
3526
|
+
TabsRenderer,
|
|
3527
|
+
TextInputRenderer_default,
|
|
3528
|
+
UploadInputRenderer,
|
|
3529
|
+
SplashStepRenderer,
|
|
3530
|
+
SplashCelebrationStepRenderer,
|
|
3531
|
+
StepRenderer
|
|
3532
|
+
];
|
|
3533
|
+
|
|
3534
|
+
// src/dynamicFlow/renderers.ts
|
|
3535
|
+
var Header11 = Header7;
|
|
3536
|
+
var Media2 = Media;
|
|
3537
|
+
var getMargin2 = getMargin;
|
|
3538
|
+
var getListItemRenderers2 = getListItemRenderers;
|
|
3539
|
+
var getButtonV2Renderers2 = getButtonV2Renderers;
|
|
57
3540
|
|
|
58
3541
|
// src/i18n/index.ts
|
|
59
3542
|
var import_dynamic_flow_client = require("@wise/dynamic-flow-client");
|
|
@@ -900,10 +4383,9 @@ var translations = languages.reduce(
|
|
|
900
4383
|
var i18n_default = translations;
|
|
901
4384
|
|
|
902
4385
|
// src/dynamicFlow/DynamicFlow.tsx
|
|
903
|
-
var
|
|
904
|
-
var
|
|
4386
|
+
var import_react19 = require("react");
|
|
4387
|
+
var import_react_intl22 = require("react-intl");
|
|
905
4388
|
var import_dynamic_flow_client2 = require("@wise/dynamic-flow-client");
|
|
906
|
-
var import_dynamic_flow_renderers2 = require("@wise/dynamic-flow-renderers");
|
|
907
4389
|
|
|
908
4390
|
// src/dynamicFlow/telemetry/app-version.ts
|
|
909
4391
|
var appVersion = (
|
|
@@ -934,13 +4416,12 @@ var logToRollbar = (level, message, extra) => {
|
|
|
934
4416
|
};
|
|
935
4417
|
|
|
936
4418
|
// src/dynamicFlow/telemetry/getTrackEvent.ts
|
|
937
|
-
var
|
|
938
|
-
var import_dynamic_flow_renderers = require("@wise/dynamic-flow-renderers");
|
|
4419
|
+
var import_components_theming2 = require("@wise/components-theming");
|
|
939
4420
|
var getTrackEvent = (onEvent, onAnalytics, onThemeChange) => (name, properties) => {
|
|
940
4421
|
onEvent == null ? void 0 : onEvent(name, properties);
|
|
941
|
-
if (name.includes(
|
|
4422
|
+
if (name.includes(ThemeRequiredEventName)) {
|
|
942
4423
|
const { theme } = properties != null ? properties : { theme: "personal" };
|
|
943
|
-
if (theme && (0,
|
|
4424
|
+
if (theme && (0, import_components_theming2.isThemeModern)(theme)) {
|
|
944
4425
|
onThemeChange == null ? void 0 : onThemeChange(theme);
|
|
945
4426
|
}
|
|
946
4427
|
} else {
|
|
@@ -949,8 +4430,8 @@ var getTrackEvent = (onEvent, onAnalytics, onThemeChange) => (name, properties)
|
|
|
949
4430
|
};
|
|
950
4431
|
|
|
951
4432
|
// src/dynamicFlow/messages.ts
|
|
952
|
-
var
|
|
953
|
-
var messages_default = (0,
|
|
4433
|
+
var import_react_intl21 = require("react-intl");
|
|
4434
|
+
var messages_default = (0, import_react_intl21.defineMessages)({
|
|
954
4435
|
copied: {
|
|
955
4436
|
id: "df.wise.CopyFeedback.copy",
|
|
956
4437
|
defaultMessage: "Copied to clipboard",
|
|
@@ -964,12 +4445,12 @@ var messages_default = (0, import_react_intl.defineMessages)({
|
|
|
964
4445
|
});
|
|
965
4446
|
|
|
966
4447
|
// src/dynamicFlow/DynamicFlow.tsx
|
|
967
|
-
var
|
|
968
|
-
var wiseRenderers =
|
|
4448
|
+
var import_jsx_runtime82 = require("react/jsx-runtime");
|
|
4449
|
+
var wiseRenderers = getWiseRenderers();
|
|
969
4450
|
function DynamicFlowLegacy(props) {
|
|
970
4451
|
const { customFetch = globalThis.fetch } = props;
|
|
971
4452
|
const coreProps = __spreadProps(__spreadValues({}, props), { httpClient: customFetch });
|
|
972
|
-
return /* @__PURE__ */ (0,
|
|
4453
|
+
return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_dynamic_flow_client2.DynamicFlow, __spreadValues({}, coreProps));
|
|
973
4454
|
}
|
|
974
4455
|
function DynamicFlowRevamp(props) {
|
|
975
4456
|
const {
|
|
@@ -982,12 +4463,12 @@ function DynamicFlowRevamp(props) {
|
|
|
982
4463
|
onLink = openLinkInNewTab,
|
|
983
4464
|
onThemeChange
|
|
984
4465
|
} = props;
|
|
985
|
-
const { formatMessage } = (0,
|
|
986
|
-
const createSnackBar =
|
|
4466
|
+
const { formatMessage } = (0, import_react_intl22.useIntl)();
|
|
4467
|
+
const createSnackBar = useSnackBarIfAvailable();
|
|
987
4468
|
const httpClient = useWiseHttpClient(customFetch);
|
|
988
|
-
const mergedRenderers = (0,
|
|
989
|
-
const logEvent = (0,
|
|
990
|
-
const trackEvent = (0,
|
|
4469
|
+
const mergedRenderers = (0, import_react19.useMemo)(() => [...renderers != null ? renderers : [], ...wiseRenderers], [renderers]);
|
|
4470
|
+
const logEvent = (0, import_react19.useMemo)(() => getLogEvent(onLog), [onLog]);
|
|
4471
|
+
const trackEvent = (0, import_react19.useMemo)(
|
|
991
4472
|
() => getTrackEvent(onEvent, onAnalytics, onThemeChange),
|
|
992
4473
|
[onEvent, onAnalytics, onThemeChange]
|
|
993
4474
|
);
|
|
@@ -1006,9 +4487,9 @@ function DynamicFlowRevamp(props) {
|
|
|
1006
4487
|
onLink,
|
|
1007
4488
|
onCopy
|
|
1008
4489
|
});
|
|
1009
|
-
return /* @__PURE__ */ (0,
|
|
4490
|
+
return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_dynamic_flow_client2.DynamicFlowCoreRevamp, __spreadValues({}, coreProps)) });
|
|
1010
4491
|
}
|
|
1011
|
-
var DynamicForm = (0,
|
|
4492
|
+
var DynamicForm = (0, import_react19.forwardRef)(function DynamicForm2(props, ref) {
|
|
1012
4493
|
const {
|
|
1013
4494
|
className = "",
|
|
1014
4495
|
customFetch = globalThis.fetch,
|
|
@@ -1019,12 +4500,12 @@ var DynamicForm = (0, import_react.forwardRef)(function DynamicForm2(props, ref)
|
|
|
1019
4500
|
onLink = openLinkInNewTab,
|
|
1020
4501
|
onThemeChange
|
|
1021
4502
|
} = props;
|
|
1022
|
-
const { formatMessage } = (0,
|
|
1023
|
-
const createSnackBar =
|
|
4503
|
+
const { formatMessage } = (0, import_react_intl22.useIntl)();
|
|
4504
|
+
const createSnackBar = useSnackBarIfAvailable();
|
|
1024
4505
|
const httpClient = useWiseHttpClient(customFetch);
|
|
1025
|
-
const mergedRenderers = (0,
|
|
1026
|
-
const logEvent = (0,
|
|
1027
|
-
const trackEvent = (0,
|
|
4506
|
+
const mergedRenderers = (0, import_react19.useMemo)(() => [...renderers != null ? renderers : [], ...wiseRenderers], [renderers]);
|
|
4507
|
+
const logEvent = (0, import_react19.useMemo)(() => getLogEvent(onLog), [onLog]);
|
|
4508
|
+
const trackEvent = (0, import_react19.useMemo)(
|
|
1028
4509
|
() => getTrackEvent(onEvent, onAnalytics, onThemeChange),
|
|
1029
4510
|
[onEvent, onAnalytics, onThemeChange]
|
|
1030
4511
|
);
|
|
@@ -1043,11 +4524,11 @@ var DynamicForm = (0, import_react.forwardRef)(function DynamicForm2(props, ref)
|
|
|
1043
4524
|
onLink,
|
|
1044
4525
|
onCopy
|
|
1045
4526
|
});
|
|
1046
|
-
return /* @__PURE__ */ (0,
|
|
4527
|
+
return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_dynamic_flow_client2.DynamicFormCore, __spreadProps(__spreadValues({}, coreProps), { ref })) });
|
|
1047
4528
|
});
|
|
1048
4529
|
var useWiseHttpClient = (httpClient) => {
|
|
1049
|
-
const { locale } = (0,
|
|
1050
|
-
return (0,
|
|
4530
|
+
const { locale } = (0, import_react_intl22.useIntl)();
|
|
4531
|
+
return (0, import_react19.useCallback)(
|
|
1051
4532
|
async (input, init = {}) => {
|
|
1052
4533
|
const headers = new Headers(init.headers);
|
|
1053
4534
|
headers.set("accept-language", locale);
|