@wise/dynamic-flow-client 3.23.1 → 3.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/main.js CHANGED
@@ -144,10 +144,10 @@ var init_clsx = __esm({
144
144
  }
145
145
  });
146
146
 
147
- // ../../node_modules/.pnpm/@wise+art@2.16.2_@transferwise+neptune-css@14.19.1_@types+react@18.3.11_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wise/art/dist/index-c8ed1f53.esm.js
147
+ // ../../node_modules/.pnpm/@wise+art@2.16.3_@transferwise+neptune-css@14.19.1_@types+react@18.3.11_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wise/art/dist/index-a91e5689.esm.js
148
148
  var import_react7, import_jsx_runtime17, unknownFlagName, Flag, Sizes, ImageSizes, imageSizes, Assets, RenderMode;
149
- var init_index_c8ed1f53_esm = __esm({
150
- "../../node_modules/.pnpm/@wise+art@2.16.2_@transferwise+neptune-css@14.19.1_@types+react@18.3.11_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wise/art/dist/index-c8ed1f53.esm.js"() {
149
+ var init_index_a91e5689_esm = __esm({
150
+ "../../node_modules/.pnpm/@wise+art@2.16.3_@transferwise+neptune-css@14.19.1_@types+react@18.3.11_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wise/art/dist/index-a91e5689.esm.js"() {
151
151
  "use strict";
152
152
  init_clsx();
153
153
  import_react7 = require("react");
@@ -165,18 +165,16 @@ var init_index_c8ed1f53_esm = __esm({
165
165
  }, [code]);
166
166
  const detailed = intrinsicSize >= 150;
167
167
  const name = fallback !== "unknown" ? `${code.toLowerCase()}${fallback == null && detailed ? "-detailed" : ""}` : unknownFlagName;
168
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", {
168
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("img", {
169
169
  className: clsx(`wds-flag wds-flag-${name}`, className),
170
- children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("img", {
171
- src: `https://wise.com/web-art/assets/flags/${name}.svg`,
172
- loading,
173
- alt: "",
174
- width: intrinsicSize,
175
- height: intrinsicSize,
176
- onError: () => {
177
- setFallback((prev) => prev == null && detailed ? "simple" : "unknown");
178
- }
179
- })
170
+ src: `https://wise.com/web-art/assets/flags/${name}.svg`,
171
+ loading,
172
+ alt: "",
173
+ width: intrinsicSize,
174
+ height: intrinsicSize,
175
+ onError: () => {
176
+ setFallback((prev) => prev == null && detailed ? "simple" : "unknown");
177
+ }
180
178
  });
181
179
  };
182
180
  (function(Sizes2) {
@@ -6226,6 +6224,7 @@ var buttonLayoutSchema = z.object({
6226
6224
  var reviewLayoutFieldSchema = z.object({
6227
6225
  label: z.string(),
6228
6226
  value: z.string(),
6227
+ rawValue: z.string().optional(),
6229
6228
  help: helpSchema.optional()
6230
6229
  });
6231
6230
  var searchResultSearchSchema = z.object({
@@ -9338,6 +9337,7 @@ var createMultiUploadInputComponent = (uploadInputProps, updateComponent) => {
9338
9337
 
9339
9338
  // src/revamp/domain/mappers/schema/arraySchemaToComponent/arraySchemaToMultiUploadComponent.ts
9340
9339
  var arraySchemaToMultiUploadComponent = (schemaMapperProps, mapperProps) => {
9340
+ var _a;
9341
9341
  const { getErrorMessageFunctions } = mapperProps;
9342
9342
  const { localValue, model, schema, required = false } = schemaMapperProps;
9343
9343
  const uploadSchema = getUploadSchema(schema.items);
@@ -9351,7 +9351,10 @@ var arraySchemaToMultiUploadComponent = (schemaMapperProps, mapperProps) => {
9351
9351
  ];
9352
9352
  const persistAsyncConfig = getPersistAsyncConfig(schema.items);
9353
9353
  const format = getFormat(schema.items);
9354
- const combinedSchemaProps = __spreadProps(__spreadValues({}, schemaMapperProps), { persistAsyncConfig, schema: uploadSchema });
9354
+ const combinedSchemaProps = __spreadProps(__spreadValues({}, schemaMapperProps), {
9355
+ persistAsyncConfig,
9356
+ schema: __spreadProps(__spreadValues({}, uploadSchema), { hidden: (_a = schema.hidden) != null ? _a : uploadSchema.hidden })
9357
+ });
9355
9358
  const { onValueChange } = mapperProps;
9356
9359
  const { performPersistAsync } = getPersistAsyncInitialState(combinedSchemaProps, mapperProps);
9357
9360
  const value = performPersistAsync ? getValueForPersistAsync(localValue) : [];
@@ -9914,6 +9917,11 @@ var formLayoutToComponent = (uid, { schemaId, schema: schemaRef, control, margin
9914
9917
  const { step, stepLocalValue } = mapperProps;
9915
9918
  const { schemas, model, errors } = step;
9916
9919
  const id = schemaId != null ? schemaId : schemaRef == null ? void 0 : schemaRef.$ref;
9920
+ if (id == null) {
9921
+ throw new Error(
9922
+ "FormLayouts must refer to a schema. Set the `schemaId` property to the intended schema."
9923
+ );
9924
+ }
9917
9925
  const schema = schemas.find((s) => s.$id === id);
9918
9926
  if (!schema) {
9919
9927
  throw new Error("Schema not found in schemas array.");
@@ -11242,15 +11250,34 @@ var AlertRenderer = {
11242
11250
  type: context,
11243
11251
  className: getMargin(margin),
11244
11252
  message: markdown,
11245
- action: (callToAction == null ? void 0 : callToAction.type) === "link" ? {
11246
- text: callToAction.title,
11247
- "aria-label": callToAction.accessibilityDescription,
11248
- href: callToAction.href,
11249
- target: "_blank"
11250
- } : void 0
11253
+ action: mapCtaToAlertAction(callToAction)
11251
11254
  }
11252
11255
  )
11253
11256
  };
11257
+ var mapCtaToAlertAction = (callToAction) => {
11258
+ if (!callToAction) {
11259
+ return void 0;
11260
+ }
11261
+ const { accessibilityDescription, title } = callToAction;
11262
+ const sharedProps = {
11263
+ "aria-label": accessibilityDescription,
11264
+ text: title
11265
+ };
11266
+ if (callToAction.type === "link") {
11267
+ const { href } = callToAction;
11268
+ return __spreadProps(__spreadValues({}, sharedProps), {
11269
+ href,
11270
+ target: "_blank"
11271
+ });
11272
+ }
11273
+ if (callToAction.type === "action") {
11274
+ const { onClick } = callToAction;
11275
+ return __spreadProps(__spreadValues({}, sharedProps), {
11276
+ onClick
11277
+ });
11278
+ }
11279
+ return void 0;
11280
+ };
11254
11281
  var AlertRenderer_default = AlertRenderer;
11255
11282
 
11256
11283
  // ../renderers/src/components/FieldInput.tsx
@@ -11608,8 +11635,8 @@ var DateInputRenderer_default = DateInputRenderer;
11608
11635
  // ../renderers/src/DecisionRenderer.tsx
11609
11636
  var import_components9 = require("@transferwise/components");
11610
11637
 
11611
- // ../../node_modules/.pnpm/@wise+art@2.16.2_@transferwise+neptune-css@14.19.1_@types+react@18.3.11_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wise/art/dist/index.esm.js
11612
- init_index_c8ed1f53_esm();
11638
+ // ../../node_modules/.pnpm/@wise+art@2.16.3_@transferwise+neptune-css@14.19.1_@types+react@18.3.11_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wise/art/dist/index.esm.js
11639
+ init_index_a91e5689_esm();
11613
11640
  init_clsx();
11614
11641
  var import_react8 = require("react");
11615
11642
  var import_jsx_runtime18 = require("react/jsx-runtime");
@@ -14941,7 +14968,7 @@ var getTextAlignmentAndMargin2 = (component) => `${getTextAlignment2(component.a
14941
14968
 
14942
14969
  // src/legacy/layout/alert/DynamicAlert.tsx
14943
14970
  var import_jsx_runtime71 = require("react/jsx-runtime");
14944
- var DynamicAlert = ({ component: alert }) => {
14971
+ var DynamicAlert = ({ component: alert, onAction }) => {
14945
14972
  const { context, markdown, margin } = alert;
14946
14973
  return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
14947
14974
  import_components42.Alert,
@@ -14949,27 +14976,36 @@ var DynamicAlert = ({ component: alert }) => {
14949
14976
  type: mapContextToAlertType(legacy_mapContext(context)),
14950
14977
  className: getMargin2(margin),
14951
14978
  message: markdown,
14952
- action: getAlertAction(alert)
14979
+ action: getAlertAction(alert, onAction)
14953
14980
  }
14954
14981
  );
14955
14982
  };
14956
14983
  var isAlertLayout = (layout) => {
14957
14984
  return Object.hasOwnProperty.call(layout, "type") && layout.type === "alert";
14958
14985
  };
14959
- var getAlertAction = (component) => {
14986
+ var getAlertAction = (component, onAction) => {
14960
14987
  if (!isAlertLayout(component) || !component.callToAction) {
14961
14988
  return void 0;
14962
14989
  }
14963
14990
  const { title, accessibilityDescription, behavior } = component.callToAction;
14964
- if (!behavior.link) {
14965
- return void 0;
14991
+ const { action, link } = behavior;
14992
+ if (link) {
14993
+ return {
14994
+ text: title,
14995
+ "aria-label": accessibilityDescription,
14996
+ href: link.url,
14997
+ target: "_blank"
14998
+ };
14999
+ }
15000
+ if (action && onAction) {
15001
+ return {
15002
+ text: title,
15003
+ "aria-label": accessibilityDescription,
15004
+ onClick: () => {
15005
+ onAction(action);
15006
+ }
15007
+ };
14966
15008
  }
14967
- return {
14968
- text: title,
14969
- "aria-label": accessibilityDescription,
14970
- href: behavior.link.url,
14971
- target: "_blank"
14972
- };
14973
15009
  };
14974
15010
  var legacy_mapContext = (context) => {
14975
15011
  switch (context) {
@@ -18032,7 +18068,7 @@ function DynamicLayout(props) {
18032
18068
  case "image":
18033
18069
  return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(DynamicImage_default, { component }, getKey(component));
18034
18070
  case "alert":
18035
- return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(DynamicAlert_default, { component }, getKey(component));
18071
+ return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(DynamicAlert_default, { component, onAction }, getKey(component));
18036
18072
  case "review":
18037
18073
  return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(DynamicReview_default, { component, onAction }, getKey(component));
18038
18074
  case "divider":