@wise/dynamic-flow-client 3.24.1 → 3.25.1
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
|
@@ -6965,12 +6965,18 @@ var alertLayoutToComponent = (uid, { control, markdown, margin = "md", context =
|
|
|
6965
6965
|
control,
|
|
6966
6966
|
markdown,
|
|
6967
6967
|
margin,
|
|
6968
|
-
callToAction:
|
|
6968
|
+
callToAction: getComponentCallToAction(callToAction, onAction),
|
|
6969
6969
|
context: mapLegacyContext(context)
|
|
6970
6970
|
});
|
|
6971
6971
|
};
|
|
6972
6972
|
var getComponentCallToAction = (callToAction, onAction) => {
|
|
6973
|
+
if (!callToAction) {
|
|
6974
|
+
return void 0;
|
|
6975
|
+
}
|
|
6973
6976
|
const { accessibilityDescription, behavior, title } = callToAction;
|
|
6977
|
+
if ("type" in behavior) {
|
|
6978
|
+
return void 0;
|
|
6979
|
+
}
|
|
6974
6980
|
if (behavior.link) {
|
|
6975
6981
|
const { url } = behavior.link;
|
|
6976
6982
|
return {
|
|
@@ -7071,9 +7077,13 @@ var buttonLayoutToComponent = (uid, button, mapperProps) => {
|
|
|
7071
7077
|
var buttonLayoutToComponentWithBehavior = (uid, button, mapperProps) => {
|
|
7072
7078
|
const { onAction, onLink, step } = mapperProps;
|
|
7073
7079
|
const { context, control, disabled, margin = "md", pinOrder, size, title, behavior } = button;
|
|
7074
|
-
const
|
|
7075
|
-
|
|
7076
|
-
|
|
7080
|
+
const getOnClick = () => {
|
|
7081
|
+
if ("type" in behavior) {
|
|
7082
|
+
return () => {
|
|
7083
|
+
};
|
|
7084
|
+
}
|
|
7085
|
+
const { action, link } = behavior;
|
|
7086
|
+
const inlinedAction = action ? inlineAction(action, step == null ? void 0 : step.actions) : null;
|
|
7077
7087
|
if (inlinedAction) {
|
|
7078
7088
|
return () => {
|
|
7079
7089
|
void onAction(inlinedAction);
|
|
@@ -7086,7 +7096,7 @@ var buttonLayoutToComponentWithBehavior = (uid, button, mapperProps) => {
|
|
|
7086
7096
|
}
|
|
7087
7097
|
return () => {
|
|
7088
7098
|
};
|
|
7089
|
-
}
|
|
7099
|
+
};
|
|
7090
7100
|
return createButtonComponent({
|
|
7091
7101
|
uid,
|
|
7092
7102
|
context: mapLegacyContext(context != null ? context : "neutral"),
|
|
@@ -7096,7 +7106,7 @@ var buttonLayoutToComponentWithBehavior = (uid, button, mapperProps) => {
|
|
|
7096
7106
|
pinOrder,
|
|
7097
7107
|
size,
|
|
7098
7108
|
title: title != null ? title : "",
|
|
7099
|
-
onClick
|
|
7109
|
+
onClick: getOnClick()
|
|
7100
7110
|
});
|
|
7101
7111
|
};
|
|
7102
7112
|
var buttonLayoutToComponentWithAction = (uid, button, mapperProps) => {
|
|
@@ -10109,23 +10119,57 @@ var createReviewComponent = (reviewProps) => __spreadProps(__spreadValues({
|
|
|
10109
10119
|
});
|
|
10110
10120
|
|
|
10111
10121
|
// src/revamp/domain/mappers/layout/reviewLayoutToComponent.ts
|
|
10112
|
-
var reviewLayoutToComponent = (uid, { fields, title, callToAction, control, margin = "md", orientation, action }, { onAction }) => createReviewComponent({
|
|
10122
|
+
var reviewLayoutToComponent = (uid, { fields, title, callToAction, control, margin = "md", orientation, action }, { onAction, onLink }) => createReviewComponent({
|
|
10113
10123
|
uid,
|
|
10114
|
-
callToAction: getReviewAction(onAction, callToAction, action),
|
|
10124
|
+
callToAction: getReviewAction({ onAction, onLink, callToAction, action }),
|
|
10115
10125
|
control: getOrientationControl({ control, orientation }),
|
|
10116
|
-
fields: fields.map((
|
|
10117
|
-
|
|
10118
|
-
|
|
10119
|
-
|
|
10126
|
+
fields: fields.map(({ label, value, rawValue, help }) => ({
|
|
10127
|
+
label,
|
|
10128
|
+
value,
|
|
10129
|
+
rawValue,
|
|
10130
|
+
help: help == null ? void 0 : help.markdown
|
|
10131
|
+
})),
|
|
10120
10132
|
margin,
|
|
10121
10133
|
title
|
|
10122
10134
|
});
|
|
10123
|
-
var getReviewAction = (onAction, callToAction, action) => {
|
|
10135
|
+
var getReviewAction = ({ onAction, onLink, callToAction, action }) => {
|
|
10124
10136
|
if (callToAction) {
|
|
10137
|
+
const { action: ctaAction, behavior, title } = callToAction;
|
|
10138
|
+
if (behavior) {
|
|
10139
|
+
if ("type" in behavior) {
|
|
10140
|
+
return void 0;
|
|
10141
|
+
}
|
|
10142
|
+
const { accessibilityDescription, action: behaviorAction, link } = behavior;
|
|
10143
|
+
const onClick = () => {
|
|
10144
|
+
if (behaviorAction) {
|
|
10145
|
+
return () => {
|
|
10146
|
+
void onAction(behaviorAction);
|
|
10147
|
+
};
|
|
10148
|
+
}
|
|
10149
|
+
if (link) {
|
|
10150
|
+
return () => {
|
|
10151
|
+
onLink(link.url);
|
|
10152
|
+
};
|
|
10153
|
+
}
|
|
10154
|
+
};
|
|
10155
|
+
return {
|
|
10156
|
+
accessibilityDescription,
|
|
10157
|
+
href: link == null ? void 0 : link.url,
|
|
10158
|
+
title,
|
|
10159
|
+
onClick
|
|
10160
|
+
};
|
|
10161
|
+
}
|
|
10162
|
+
if (ctaAction) {
|
|
10163
|
+
return {
|
|
10164
|
+
title,
|
|
10165
|
+
onClick: () => {
|
|
10166
|
+
void onAction(ctaAction);
|
|
10167
|
+
}
|
|
10168
|
+
};
|
|
10169
|
+
}
|
|
10125
10170
|
return {
|
|
10126
|
-
title
|
|
10171
|
+
title,
|
|
10127
10172
|
onClick: () => {
|
|
10128
|
-
void onAction(callToAction.action);
|
|
10129
10173
|
}
|
|
10130
10174
|
};
|
|
10131
10175
|
}
|
|
@@ -10299,18 +10343,32 @@ var createStatusListComponent = (statusListProps) => __spreadProps(__spreadValue
|
|
|
10299
10343
|
var statusListLayoutToComponent = (uid, { control, items, margin = "md", title }, { onAction, onLink }) => createStatusListComponent({
|
|
10300
10344
|
uid,
|
|
10301
10345
|
control,
|
|
10302
|
-
items: items.map((item) => {
|
|
10303
|
-
|
|
10304
|
-
|
|
10305
|
-
|
|
10306
|
-
callToAction: item.callToAction ? getItemCallToAction(item.callToAction, onAction, onLink) : void 0
|
|
10307
|
-
});
|
|
10308
|
-
}),
|
|
10346
|
+
items: items.map((item) => __spreadProps(__spreadValues({}, item), {
|
|
10347
|
+
href: getItemHref(item.callToAction),
|
|
10348
|
+
callToAction: getItemCallToAction(item.callToAction, onAction, onLink)
|
|
10349
|
+
})),
|
|
10309
10350
|
margin,
|
|
10310
10351
|
title
|
|
10311
10352
|
});
|
|
10353
|
+
var getItemHref = (callToAction) => {
|
|
10354
|
+
var _a;
|
|
10355
|
+
if (!callToAction) {
|
|
10356
|
+
return void 0;
|
|
10357
|
+
}
|
|
10358
|
+
const { behavior } = callToAction;
|
|
10359
|
+
if ("type" in behavior) {
|
|
10360
|
+
return void 0;
|
|
10361
|
+
}
|
|
10362
|
+
return (_a = behavior == null ? void 0 : behavior.link) == null ? void 0 : _a.url;
|
|
10363
|
+
};
|
|
10312
10364
|
var getItemCallToAction = (callToAction, onAction, onLink) => {
|
|
10365
|
+
if (!callToAction) {
|
|
10366
|
+
return void 0;
|
|
10367
|
+
}
|
|
10313
10368
|
const { accessibilityDescription, behavior, title } = callToAction;
|
|
10369
|
+
if ("type" in behavior) {
|
|
10370
|
+
return void 0;
|
|
10371
|
+
}
|
|
10314
10372
|
if (behavior.link) {
|
|
10315
10373
|
const { url } = behavior.link;
|
|
10316
10374
|
return {
|
|
@@ -13220,15 +13278,8 @@ var ReviewRenderer = {
|
|
|
13220
13278
|
canRenderType: "review",
|
|
13221
13279
|
render: ({ callToAction, control, fields, margin, title }) => {
|
|
13222
13280
|
const orientation = mapControlToDefinitionListLayout(control);
|
|
13223
|
-
const action = callToAction ? {
|
|
13224
|
-
text: callToAction.title,
|
|
13225
|
-
onClick: (event) => {
|
|
13226
|
-
event.preventDefault();
|
|
13227
|
-
callToAction.onClick();
|
|
13228
|
-
}
|
|
13229
|
-
} : void 0;
|
|
13230
13281
|
return /* @__PURE__ */ jsxs19("div", { className: getMargin(margin), children: [
|
|
13231
|
-
(title || callToAction) && /* @__PURE__ */ jsx54(Header6, { title: title != null ? title : "", action }),
|
|
13282
|
+
(title || callToAction) && /* @__PURE__ */ jsx54(Header6, { title: title != null ? title : "", action: getReviewAction2(callToAction) }),
|
|
13232
13283
|
/* @__PURE__ */ jsx54("div", { className: margin, children: /* @__PURE__ */ jsx54(
|
|
13233
13284
|
DefinitionList,
|
|
13234
13285
|
{
|
|
@@ -13273,6 +13324,27 @@ var getFieldValue = (value, help, orientation) => {
|
|
|
13273
13324
|
}
|
|
13274
13325
|
return value;
|
|
13275
13326
|
};
|
|
13327
|
+
var getReviewAction2 = (callToAction) => {
|
|
13328
|
+
if (!callToAction) {
|
|
13329
|
+
return void 0;
|
|
13330
|
+
}
|
|
13331
|
+
const { accessibilityDescription, href, title, onClick } = callToAction;
|
|
13332
|
+
if (href) {
|
|
13333
|
+
return {
|
|
13334
|
+
"aria-label": accessibilityDescription,
|
|
13335
|
+
href,
|
|
13336
|
+
text: title
|
|
13337
|
+
};
|
|
13338
|
+
}
|
|
13339
|
+
return {
|
|
13340
|
+
"aria-label": accessibilityDescription,
|
|
13341
|
+
text: title,
|
|
13342
|
+
onClick: (event) => {
|
|
13343
|
+
event.preventDefault();
|
|
13344
|
+
onClick();
|
|
13345
|
+
}
|
|
13346
|
+
};
|
|
13347
|
+
};
|
|
13276
13348
|
|
|
13277
13349
|
// ../renderers/src/step/StepRenderer.tsx
|
|
13278
13350
|
import { useMemo as useMemo3 } from "react";
|
|
@@ -18337,21 +18409,42 @@ var getDefinitionListLayout = (review) => {
|
|
|
18337
18409
|
}
|
|
18338
18410
|
};
|
|
18339
18411
|
function DynamicReview(props) {
|
|
18412
|
+
var _a;
|
|
18340
18413
|
const review = props.component;
|
|
18341
18414
|
const margin = getMargin2(review.margin || "xs");
|
|
18342
|
-
const
|
|
18343
|
-
|
|
18344
|
-
|
|
18345
|
-
|
|
18415
|
+
const getReviewAction3 = (callToAction2) => {
|
|
18416
|
+
const { title, action, behavior } = callToAction2;
|
|
18417
|
+
if (behavior) {
|
|
18418
|
+
const { action: behaviorAction, link } = behavior;
|
|
18419
|
+
if (link) {
|
|
18420
|
+
return {
|
|
18421
|
+
text: title != null ? title : "",
|
|
18422
|
+
href: link == null ? void 0 : link.url
|
|
18423
|
+
};
|
|
18424
|
+
}
|
|
18425
|
+
if (behaviorAction) {
|
|
18426
|
+
return {
|
|
18427
|
+
text: title != null ? title : "",
|
|
18428
|
+
onClick: behaviorAction ? getOnClick(behaviorAction) : void 0
|
|
18429
|
+
};
|
|
18430
|
+
}
|
|
18431
|
+
}
|
|
18432
|
+
return {
|
|
18433
|
+
text: title != null ? title : "",
|
|
18434
|
+
onClick: action ? getOnClick(action) : void 0
|
|
18435
|
+
};
|
|
18436
|
+
};
|
|
18437
|
+
const getOnClick = (action) => {
|
|
18438
|
+
return (event) => {
|
|
18346
18439
|
event.preventDefault();
|
|
18347
18440
|
if (action) {
|
|
18348
18441
|
props.onAction(action);
|
|
18349
18442
|
}
|
|
18350
|
-
}
|
|
18351
|
-
}
|
|
18443
|
+
};
|
|
18444
|
+
};
|
|
18352
18445
|
const orientation = getDefinitionListLayout(review);
|
|
18353
|
-
const callToAction = review.callToAction ?
|
|
18354
|
-
const legacyCallToAction = !callToAction && review.action ?
|
|
18446
|
+
const callToAction = review.callToAction ? getReviewAction3(review.callToAction) : null;
|
|
18447
|
+
const legacyCallToAction = !callToAction && review.action ? { text: (_a = review.action.title) != null ? _a : "", onClick: getOnClick(review.action) } : null;
|
|
18355
18448
|
return /* @__PURE__ */ jsxs40("div", { className: margin, children: [
|
|
18356
18449
|
review.title && /* @__PURE__ */ jsx111(Header14, { title: review.title, action: callToAction || legacyCallToAction || void 0 }),
|
|
18357
18450
|
/* @__PURE__ */ jsx111("div", { className: margin, children: /* @__PURE__ */ jsx111(DefinitionList3, { layout: orientation, definitions: getDefinitions(orientation, review) }) })
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { ReviewLayout } from '@wise/dynamic-flow-types/build/next';
|
|
2
2
|
import type { MapperProps } from '../schema/types';
|
|
3
|
-
export declare const reviewLayoutToComponent: (uid: string, { fields, title, callToAction, control, margin, orientation, action }: ReviewLayout, { onAction }: MapperProps) => import("../../components/ReviewComponent").ReviewComponent;
|
|
3
|
+
export declare const reviewLayoutToComponent: (uid: string, { fields, title, callToAction, control, margin, orientation, action }: ReviewLayout, { onAction, onLink }: MapperProps) => import("../../components/ReviewComponent").ReviewComponent;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wise/dynamic-flow-client",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.25.1",
|
|
4
4
|
"description": "Dynamic Flow web client",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "./build/main.min.js",
|
|
@@ -83,8 +83,8 @@
|
|
|
83
83
|
"tsx": "4.19.1",
|
|
84
84
|
"typescript": "5.6.3",
|
|
85
85
|
"webpack": "5.95.0",
|
|
86
|
-
"@wise/dynamic-flow-
|
|
87
|
-
"@wise/dynamic-flow-
|
|
86
|
+
"@wise/dynamic-flow-fixtures": "0.0.1",
|
|
87
|
+
"@wise/dynamic-flow-renderers": "0.0.0"
|
|
88
88
|
},
|
|
89
89
|
"peerDependencies": {
|
|
90
90
|
"@transferwise/components": "^46.31",
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
"nanoid": "5.0.7",
|
|
102
102
|
"react-webcam": "^7.2.0",
|
|
103
103
|
"screenfull": "^5.2.0",
|
|
104
|
-
"@wise/dynamic-flow-types": "2.
|
|
104
|
+
"@wise/dynamic-flow-types": "2.27.0"
|
|
105
105
|
},
|
|
106
106
|
"scripts": {
|
|
107
107
|
"dev": "pnpm build:visual-tests && storybook dev -p 3003",
|