@wise/dynamic-flow-client-internal 4.26.0 → 4.27.0-experimental-renderer-utils-876fd4f

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