@wise/dynamic-flow-client 3.15.2 → 3.16.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
@@ -1452,11 +1452,19 @@ var stepComponentToProps = ({
1452
1452
 
1453
1453
  // src/revamp/renderers/mappers/alertComponentToProps.ts
1454
1454
  var alertComponentToProps = ({
1455
+ callToAction,
1456
+ context,
1457
+ control,
1458
+ margin,
1459
+ markdown
1460
+ }) => ({
1461
+ type: "alert",
1462
+ callToAction,
1455
1463
  context,
1456
1464
  control,
1457
1465
  margin,
1458
1466
  markdown
1459
- }) => ({ type: "alert", context, control, margin, markdown });
1467
+ });
1460
1468
 
1461
1469
  // src/revamp/renderers/mappers/allOfComponentToProps.ts
1462
1470
  var allOfComponentToProps = ({ control, description, help, title }, children) => ({
@@ -5951,13 +5959,6 @@ var loadingIndicatorLayoutSchema = z.object({
5951
5959
  control: z.string().optional(),
5952
5960
  margin: sizeSchema.optional()
5953
5961
  });
5954
- var alertLayoutSchema = z.object({
5955
- type: z.literal("alert"),
5956
- markdown: z.string(),
5957
- context: contextSchema.optional(),
5958
- control: z.string().optional(),
5959
- margin: sizeSchema.optional()
5960
- });
5961
5962
  var paragraphLayoutSchema = z.object({
5962
5963
  type: z.literal("paragraph"),
5963
5964
  text: z.string(),
@@ -6112,6 +6113,9 @@ var actionTypeSchema = z.union([
6112
6113
  z.literal("negative")
6113
6114
  ]);
6114
6115
  var summarySchema = z.union([summaryProviderSchema, summarySummariserSchema]);
6116
+ var linkSchema = z.object({
6117
+ url: z.string()
6118
+ });
6115
6119
  var actionSchema = z.object({
6116
6120
  title: z.string().optional(),
6117
6121
  type: actionTypeSchema.optional(),
@@ -6170,6 +6174,10 @@ var reviewLayoutFieldSchema = z.object({
6170
6174
  value: z.string(),
6171
6175
  help: helpSchema.optional()
6172
6176
  });
6177
+ var behaviorSchema = z.object({
6178
+ action: actionSchema.optional(),
6179
+ link: linkSchema.optional()
6180
+ });
6173
6181
  var searchResultSearchSchema = z.object({
6174
6182
  type: z.literal("search"),
6175
6183
  title: z.string(),
@@ -6200,44 +6208,6 @@ var linkHandlerSchema = z.object({
6200
6208
  regexPattern: z.string(),
6201
6209
  action: actionSchema
6202
6210
  });
6203
- var blobSchemaSchema = z.object({
6204
- type: z.literal("blob"),
6205
- promoted: z.boolean().optional(),
6206
- $id: z.string().optional(),
6207
- title: z.string().optional(),
6208
- description: z.string().optional(),
6209
- control: z.string().optional(),
6210
- hidden: z.boolean().optional(),
6211
- icon: iconSchema.optional(),
6212
- image: imageSchema.optional(),
6213
- keywords: z.array(z.string()).optional(),
6214
- summary: summaryProviderSchema.optional(),
6215
- analyticsId: z.string().optional(),
6216
- validationAsync: validateAsyncSchema.optional(),
6217
- validationMessages: z.record(z.string()).optional(),
6218
- alert: alertLayoutSchema.optional(),
6219
- cameraConfig: jsonElementSchema.optional(),
6220
- accepts: z.array(z.string()).optional(),
6221
- maxSize: z.number().optional(),
6222
- source: uploadSourceSchema.optional(),
6223
- disabled: z.boolean().optional()
6224
- });
6225
- var constSchemaSchema = z.object({
6226
- hidden: z.boolean().optional(),
6227
- alert: alertLayoutSchema.optional(),
6228
- control: z.string().optional(),
6229
- promoted: z.boolean().optional(),
6230
- $id: z.string().optional(),
6231
- const: jsonElementSchema,
6232
- title: z.string().optional(),
6233
- description: z.string().optional(),
6234
- icon: iconSchema.optional(),
6235
- image: imageSchema.optional(),
6236
- keywords: z.array(z.string()).optional(),
6237
- summary: summaryProviderSchema.optional(),
6238
- analyticsId: z.string().optional(),
6239
- disabled: z.boolean().optional()
6240
- });
6241
6211
  var pollingOnErrorSchema = z.object({
6242
6212
  action: actionSchema
6243
6213
  });
@@ -6249,6 +6219,11 @@ var reviewLayoutCallToActionSchema = z.object({
6249
6219
  title: z.string(),
6250
6220
  action: actionSchema
6251
6221
  });
6222
+ var alertLayoutCallToActionSchema = z.object({
6223
+ title: z.string(),
6224
+ accessibilityDescription: z.string().optional(),
6225
+ behavior: behaviorSchema
6226
+ });
6252
6227
  var listLayoutSchema = z.object({
6253
6228
  type: z.literal("list"),
6254
6229
  items: z.array(listLayoutItemSchema),
@@ -6292,9 +6267,55 @@ var navigationSchema = z.object({
6292
6267
  back: navigationBackBehaviourSchema.optional(),
6293
6268
  stackBehavior: navigationStackBehaviorSchema.optional()
6294
6269
  });
6270
+ var alertLayoutSchema = z.object({
6271
+ type: z.literal("alert"),
6272
+ markdown: z.string(),
6273
+ context: contextSchema.optional(),
6274
+ control: z.string().optional(),
6275
+ margin: sizeSchema.optional(),
6276
+ callToAction: alertLayoutCallToActionSchema.optional()
6277
+ });
6295
6278
  var searchResponseBodySchema = z.object({
6296
6279
  results: z.array(searchResultSchema)
6297
6280
  });
6281
+ var blobSchemaSchema = z.object({
6282
+ type: z.literal("blob"),
6283
+ promoted: z.boolean().optional(),
6284
+ $id: z.string().optional(),
6285
+ title: z.string().optional(),
6286
+ description: z.string().optional(),
6287
+ control: z.string().optional(),
6288
+ hidden: z.boolean().optional(),
6289
+ icon: iconSchema.optional(),
6290
+ image: imageSchema.optional(),
6291
+ keywords: z.array(z.string()).optional(),
6292
+ summary: summaryProviderSchema.optional(),
6293
+ analyticsId: z.string().optional(),
6294
+ validationAsync: validateAsyncSchema.optional(),
6295
+ validationMessages: z.record(z.string()).optional(),
6296
+ alert: alertLayoutSchema.optional(),
6297
+ cameraConfig: jsonElementSchema.optional(),
6298
+ accepts: z.array(z.string()).optional(),
6299
+ maxSize: z.number().optional(),
6300
+ source: uploadSourceSchema.optional(),
6301
+ disabled: z.boolean().optional()
6302
+ });
6303
+ var constSchemaSchema = z.object({
6304
+ hidden: z.boolean().optional(),
6305
+ alert: alertLayoutSchema.optional(),
6306
+ control: z.string().optional(),
6307
+ promoted: z.boolean().optional(),
6308
+ $id: z.string().optional(),
6309
+ const: jsonElementSchema,
6310
+ title: z.string().optional(),
6311
+ description: z.string().optional(),
6312
+ icon: iconSchema.optional(),
6313
+ image: imageSchema.optional(),
6314
+ keywords: z.array(z.string()).optional(),
6315
+ summary: summaryProviderSchema.optional(),
6316
+ analyticsId: z.string().optional(),
6317
+ disabled: z.boolean().optional()
6318
+ });
6298
6319
  var layoutSchema = z.lazy(
6299
6320
  () => z.union([
6300
6321
  alertLayoutSchema,
@@ -6939,13 +6960,39 @@ var legacyActionTypeToControl = {
6939
6960
  var mapLegacyActionTypeToControl = (type) => type && type in legacyActionTypeToControl ? legacyActionTypeToControl[type] : "secondary";
6940
6961
 
6941
6962
  // src/revamp/domain/mappers/layout/alertLayoutToComponent.ts
6942
- var alertLayoutToComponent = (uid, { control, markdown, margin = "md", context = "neutral" }) => createAlertComponent({
6943
- uid,
6944
- control,
6945
- markdown,
6946
- margin,
6947
- context: mapLegacyContext(context)
6948
- });
6963
+ var alertLayoutToComponent = (uid, { control, markdown, margin = "md", context = "neutral", callToAction }, { onAction }) => {
6964
+ return createAlertComponent({
6965
+ uid,
6966
+ control,
6967
+ markdown,
6968
+ margin,
6969
+ callToAction: callToAction ? getComponentCallToAction(callToAction, onAction) : void 0,
6970
+ context: mapLegacyContext(context)
6971
+ });
6972
+ };
6973
+ var getComponentCallToAction = (callToAction, onAction) => {
6974
+ const { accessibilityDescription, behavior, title } = callToAction;
6975
+ if (behavior.link) {
6976
+ const { url } = behavior.link;
6977
+ return {
6978
+ type: "link",
6979
+ accessibilityDescription,
6980
+ href: url,
6981
+ title
6982
+ };
6983
+ }
6984
+ if (behavior.action) {
6985
+ const { action } = behavior;
6986
+ return {
6987
+ type: "action",
6988
+ accessibilityDescription,
6989
+ title,
6990
+ onClick: () => {
6991
+ void onAction(action);
6992
+ }
6993
+ };
6994
+ }
6995
+ };
6949
6996
 
6950
6997
  // src/revamp/domain/components/BoxComponent.ts
6951
6998
  var createBoxComponent = (boxProps) => __spreadProps(__spreadValues({}, boxProps), {
@@ -9629,7 +9676,7 @@ var mapSchemaToComponent = (schemaMapperProps, mapperProps) => {
9629
9676
  return createContainerComponent({
9630
9677
  uid,
9631
9678
  components: [
9632
- alertLayoutToComponent(`${uid}.container.alert`, alert),
9679
+ alertLayoutToComponent(`${uid}.container.alert`, alert, mapperProps),
9633
9680
  getSchemaComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { uid: `${uid}.container` }), mapperProps)
9634
9681
  ]
9635
9682
  });
@@ -9925,13 +9972,17 @@ var getReviewAction = (onAction, callToAction, action) => {
9925
9972
  if (callToAction) {
9926
9973
  return {
9927
9974
  title: callToAction.title,
9928
- onClick: () => onAction(callToAction.action)
9975
+ onClick: () => {
9976
+ void onAction(callToAction.action);
9977
+ }
9929
9978
  };
9930
9979
  }
9931
9980
  if (action == null ? void 0 : action.title) {
9932
9981
  return {
9933
9982
  title: action.title,
9934
- onClick: () => onAction(action)
9983
+ onClick: () => {
9984
+ void onAction(action);
9985
+ }
9935
9986
  };
9936
9987
  }
9937
9988
  return void 0;
@@ -10128,7 +10179,7 @@ var mapLegacyStatus = (status) => {
10128
10179
  var mapLayoutToComponent = (uid, layout, mapperProps) => {
10129
10180
  switch (layout.type) {
10130
10181
  case "alert":
10131
- return alertLayoutToComponent(uid, layout);
10182
+ return alertLayoutToComponent(uid, layout, mapperProps);
10132
10183
  case "box":
10133
10184
  return boxLayoutToComponent(uid, layout, mapperProps);
10134
10185
  case "button":
@@ -10901,7 +10952,20 @@ var getTextAlignmentAndMargin = (component) => `${getTextAlignment(component.ali
10901
10952
  var import_jsx_runtime7 = require("react/jsx-runtime");
10902
10953
  var AlertRenderer = {
10903
10954
  canRenderType: "alert",
10904
- render: ({ context, markdown, margin }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_components2.Alert, { type: context, className: getMargin(margin), message: markdown })
10955
+ render: ({ context, markdown, margin, callToAction }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
10956
+ import_components2.Alert,
10957
+ {
10958
+ type: context,
10959
+ className: getMargin(margin),
10960
+ message: markdown,
10961
+ action: (callToAction == null ? void 0 : callToAction.type) === "link" ? {
10962
+ text: callToAction.title,
10963
+ "aria-label": callToAction.accessibilityDescription,
10964
+ href: callToAction.href,
10965
+ target: "_blank"
10966
+ } : void 0
10967
+ }
10968
+ )
10905
10969
  };
10906
10970
  var AlertRenderer_default = AlertRenderer;
10907
10971
 
@@ -12123,23 +12187,26 @@ function SearchResults({
12123
12187
  state
12124
12188
  }) {
12125
12189
  const trackEvent = useTrackEvent();
12126
- return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_components26.NavigationOptionsList, { children: state.results.map((result) => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
12127
- import_components26.NavigationOption,
12128
- {
12129
- title: result.title,
12130
- content: result.description,
12131
- media: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(NavigationOptionMedia, __spreadValues({}, result)),
12132
- showMediaCircle: false,
12133
- showMediaAtAllSizes: true,
12134
- onClick: () => {
12135
- trackEvent("Search Result Selected", __spreadValues({
12136
- type: result.type
12137
- }, result.type === "action" ? { actionId: result.id } : {}));
12138
- result.onClick();
12139
- }
12140
- },
12141
- JSON.stringify(result)
12142
- )) });
12190
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_components26.NavigationOptionsList, { children: state.results.map((result) => {
12191
+ const { icon, image } = result;
12192
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
12193
+ import_components26.NavigationOption,
12194
+ {
12195
+ title: result.title,
12196
+ content: result.description,
12197
+ media: NavigationOptionMedia({ icon, image }),
12198
+ showMediaCircle: false,
12199
+ showMediaAtAllSizes: true,
12200
+ onClick: () => {
12201
+ trackEvent("Search Result Selected", __spreadValues({
12202
+ type: result.type
12203
+ }, result.type === "action" ? { actionId: result.id } : {}));
12204
+ result.onClick();
12205
+ }
12206
+ },
12207
+ JSON.stringify(result)
12208
+ );
12209
+ }) });
12143
12210
  }
12144
12211
  var BlockSearchRendererComponent_default = BlockSearchRendererComponent;
12145
12212
 
@@ -14367,17 +14434,36 @@ var getTextAlignmentAndMargin2 = (component) => `${getTextAlignment2(component.a
14367
14434
 
14368
14435
  // src/legacy/layout/alert/DynamicAlert.tsx
14369
14436
  var import_jsx_runtime71 = require("react/jsx-runtime");
14370
- var DynamicAlert = (props) => {
14371
- const alert = props.component;
14437
+ var DynamicAlert = ({ component: alert }) => {
14438
+ const { context, markdown, margin } = alert;
14372
14439
  return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
14373
14440
  import_components41.Alert,
14374
14441
  {
14375
- type: mapContextToAlertType(legacy_mapContext(alert.context)),
14376
- className: getMargin2(alert.margin),
14377
- message: alert.markdown
14442
+ type: mapContextToAlertType(legacy_mapContext(context)),
14443
+ className: getMargin2(margin),
14444
+ message: markdown,
14445
+ action: getAlertAction(alert)
14378
14446
  }
14379
14447
  );
14380
14448
  };
14449
+ var isAlertLayout = (layout) => {
14450
+ return Object.hasOwnProperty.call(layout, "type") && layout.type === "alert";
14451
+ };
14452
+ var getAlertAction = (component) => {
14453
+ if (!isAlertLayout(component) || !component.callToAction) {
14454
+ return void 0;
14455
+ }
14456
+ const { title, accessibilityDescription, behavior } = component.callToAction;
14457
+ if (!behavior.link) {
14458
+ return void 0;
14459
+ }
14460
+ return {
14461
+ text: title,
14462
+ "aria-label": accessibilityDescription,
14463
+ href: behavior.link.url,
14464
+ target: "_blank"
14465
+ };
14466
+ };
14381
14467
  var legacy_mapContext = (context) => {
14382
14468
  switch (context) {
14383
14469
  case "success":
@@ -16065,7 +16151,8 @@ var _FormControl = class _FormControl extends import_react39.PureComponent {
16065
16151
  maxDate,
16066
16152
  value,
16067
16153
  mode,
16068
- describedBy
16154
+ describedBy,
16155
+ labelledBy
16069
16156
  } = this.props;
16070
16157
  switch (type) {
16071
16158
  case FormControlType.RADIO:
@@ -16230,6 +16317,7 @@ var _FormControl = class _FormControl extends import_react39.PureComponent {
16230
16317
  return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
16231
16318
  import_components54.DateInput,
16232
16319
  {
16320
+ "aria-labelledby": labelledBy,
16233
16321
  dayAutoComplete: this.getAutocompleteValue({ suffix: "-day" }),
16234
16322
  yearAutoComplete: this.getAutocompleteValue({ suffix: "-year" }),
16235
16323
  disabled,
@@ -16480,7 +16568,8 @@ function SchemaFormControl(props) {
16480
16568
  onFocus,
16481
16569
  onBlur,
16482
16570
  onSearchChange,
16483
- describedBy
16571
+ describedBy,
16572
+ labelledBy
16484
16573
  } = props;
16485
16574
  const log = useLogger();
16486
16575
  const intl = (0, import_react_intl31.useIntl)();
@@ -16517,6 +16606,7 @@ function SchemaFormControl(props) {
16517
16606
  intl
16518
16607
  }, mapSchemaToUploadOptions(schema)),
16519
16608
  describedBy,
16609
+ labelledBy,
16520
16610
  required
16521
16611
  };
16522
16612
  return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("div", { "aria-describedby": describedBy, children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(FormControl, __spreadValues(__spreadValues({ type: controlType, value: safeValue }, events), controlProps)) });
@@ -18041,11 +18131,12 @@ var BasicTypeSchema = (props) => {
18041
18131
  const showLabel = props.schema.format !== "file" && props.schema.type !== "boolean";
18042
18132
  const schemaHelp = props.schema.help;
18043
18133
  const feedbackId = `${id}-feedback`;
18134
+ const labelId = `${id}-label`;
18044
18135
  return !isHidden ? /* @__PURE__ */ (0, import_jsx_runtime117.jsxs)(import_jsx_runtime117.Fragment, { children: [
18045
18136
  props.schema.alert && /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(DynamicAlert_default, { component: props.schema.alert }),
18046
18137
  /* @__PURE__ */ (0, import_jsx_runtime117.jsxs)("div", { className: (0, import_classnames15.default)(formGroupClasses), children: [
18047
18138
  showLabel && /* @__PURE__ */ (0, import_jsx_runtime117.jsxs)("div", { className: "d-inline-block m-b-1", children: [
18048
- /* @__PURE__ */ (0, import_jsx_runtime117.jsx)("label", { className: "control-label d-inline", htmlFor: id, children: props.schema.title }),
18139
+ /* @__PURE__ */ (0, import_jsx_runtime117.jsx)("label", { className: "control-label d-inline", htmlFor: id, id: labelId, children: props.schema.title }),
18049
18140
  !!schemaHelp && /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(Help_default2, { help: schemaHelp })
18050
18141
  ] }),
18051
18142
  !showLabel && !!schemaHelp && /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(Help_default2, { help: schemaHelp }),
@@ -18059,7 +18150,8 @@ var BasicTypeSchema = (props) => {
18059
18150
  onChange,
18060
18151
  onFocus,
18061
18152
  onBlur,
18062
- describedBy: feedbackId
18153
+ describedBy: feedbackId,
18154
+ labelledBy: labelId
18063
18155
  }
18064
18156
  ),
18065
18157
  /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(