@wise/dynamic-flow-client 3.20.1 → 3.21.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
@@ -6147,12 +6147,6 @@ var decisionLayoutOptionSchema = z.object({
6147
6147
  icon: iconSchema.optional(),
6148
6148
  image: imageLayoutSchema.optional()
6149
6149
  });
6150
- var statusListLayoutItemSchema = z.object({
6151
- title: z.string(),
6152
- description: z.string().optional(),
6153
- icon: iconSchema,
6154
- status: statusListLayoutStatusSchema.optional()
6155
- });
6156
6150
  var instructionsLayoutSchema = z.object({
6157
6151
  type: z.literal("instructions"),
6158
6152
  title: z.string().optional(),
@@ -6160,6 +6154,10 @@ var instructionsLayoutSchema = z.object({
6160
6154
  control: z.string().optional(),
6161
6155
  margin: sizeSchema.optional()
6162
6156
  });
6157
+ var behaviorSchema = z.object({
6158
+ action: actionSchema.optional(),
6159
+ link: linkSchema.optional()
6160
+ });
6163
6161
  var buttonLayoutSchema = z.object({
6164
6162
  type: z.literal("button"),
6165
6163
  size: sizeSchema.optional(),
@@ -6176,10 +6174,6 @@ var reviewLayoutFieldSchema = z.object({
6176
6174
  value: z.string(),
6177
6175
  help: helpSchema.optional()
6178
6176
  });
6179
- var behaviorSchema = z.object({
6180
- action: actionSchema.optional(),
6181
- link: linkSchema.optional()
6182
- });
6183
6177
  var searchResultSearchSchema = z.object({
6184
6178
  type: z.literal("search"),
6185
6179
  title: z.string(),
@@ -6240,12 +6234,10 @@ var decisionLayoutSchema = z.object({
6240
6234
  control: z.string().optional(),
6241
6235
  margin: sizeSchema.optional()
6242
6236
  });
6243
- var statusListLayoutSchema = z.object({
6244
- type: z.literal("status-list"),
6245
- items: z.array(statusListLayoutItemSchema),
6246
- title: z.string().optional(),
6247
- control: z.string().optional(),
6248
- margin: sizeSchema.optional()
6237
+ var itemCallToActionSchema = z.object({
6238
+ title: z.string(),
6239
+ accessibilityDescription: z.string().optional(),
6240
+ behavior: behaviorSchema
6249
6241
  });
6250
6242
  var reviewLayoutSchema = z.object({
6251
6243
  type: z.literal("review"),
@@ -6279,6 +6271,13 @@ var alertLayoutSchema = z.object({
6279
6271
  margin: sizeSchema.optional(),
6280
6272
  callToAction: alertLayoutCallToActionSchema.optional()
6281
6273
  });
6274
+ var statusListLayoutItemSchema = z.object({
6275
+ title: z.string(),
6276
+ description: z.string().optional(),
6277
+ icon: iconSchema,
6278
+ status: statusListLayoutStatusSchema.optional(),
6279
+ callToAction: itemCallToActionSchema.optional()
6280
+ });
6282
6281
  var searchResponseBodySchema = z.object({
6283
6282
  results: z.array(searchResultSchema)
6284
6283
  });
@@ -6320,6 +6319,13 @@ var constSchemaSchema = z.object({
6320
6319
  analyticsId: z.string().optional(),
6321
6320
  disabled: z.boolean().optional()
6322
6321
  });
6322
+ var statusListLayoutSchema = z.object({
6323
+ type: z.literal("status-list"),
6324
+ items: z.array(statusListLayoutItemSchema),
6325
+ title: z.string().optional(),
6326
+ control: z.string().optional(),
6327
+ margin: sizeSchema.optional()
6328
+ });
6323
6329
  var layoutSchema = z.lazy(
6324
6330
  () => z.union([
6325
6331
  alertLayoutSchema,
@@ -14726,10 +14732,9 @@ var priorities = {
14726
14732
  positive: "primary",
14727
14733
  negative: "primary"
14728
14734
  };
14729
- var getButtonPriority = (component) => {
14730
- var _a;
14731
- const actionType = component.action.type;
14732
- return (_a = component.control) != null ? _a : actionType ? priorities[actionType] : "secondary";
14735
+ var getButtonPriority = (control, action) => {
14736
+ const actionType = action ? action.type : void 0;
14737
+ return control != null ? control : actionType ? priorities[actionType] : "secondary";
14733
14738
  };
14734
14739
  var contextToType = {
14735
14740
  positive: "positive",
@@ -14744,13 +14749,16 @@ var actionTypeToType = {
14744
14749
  positive: "positive",
14745
14750
  negative: "negative"
14746
14751
  };
14747
- var getButtonType = (component) => {
14748
- if (component.context) {
14749
- return contextToType[component.context];
14752
+ var getButtonType = (context, action) => {
14753
+ if (context) {
14754
+ return contextToType[context];
14750
14755
  }
14751
- const actionType = component.action.type;
14756
+ const actionType = action ? action.type : void 0;
14752
14757
  return actionType ? actionTypeToType[actionType] : "accent";
14753
14758
  };
14759
+ var getButtonTypeFromContext = (context) => {
14760
+ return context ? contextToType[context] : "accent";
14761
+ };
14754
14762
  var getButtonSize = (size) => {
14755
14763
  switch (size) {
14756
14764
  case "xs":
@@ -14768,13 +14776,55 @@ var getButtonSize = (size) => {
14768
14776
  // src/legacy/layout/button/DynamicButton.tsx
14769
14777
  var import_jsx_runtime73 = require("react/jsx-runtime");
14770
14778
  function DynamicButton(props) {
14771
- var _a;
14779
+ return props.component.behavior ? /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(DynamicButtonWithBehavior, __spreadValues({}, props)) : /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(DynamicButtonWithoutBehavior, __spreadValues({}, props));
14780
+ }
14781
+ function DynamicButtonWithoutBehavior(props) {
14782
+ var _a, _b;
14772
14783
  const { component, onAction } = props;
14773
14784
  const componentAction = component.action;
14774
- const type = getButtonType(component);
14775
- const priority = getButtonPriority(component);
14785
+ const type = getButtonType(component.context, componentAction);
14786
+ const priority = getButtonPriority(component.control, componentAction);
14787
+ const { loading } = useDynamicFlow();
14788
+ const className = getMargin2(component.margin || "md");
14789
+ const disabled = loading || component.disabled || (componentAction == null ? void 0 : componentAction.disabled);
14790
+ const title = (_b = (_a = component.title) != null ? _a : componentAction == null ? void 0 : componentAction.title) != null ? _b : "";
14791
+ const onClick = () => {
14792
+ if (componentAction) {
14793
+ onAction(componentAction);
14794
+ }
14795
+ };
14796
+ return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
14797
+ import_components42.Button,
14798
+ {
14799
+ size: getButtonSize(component.size),
14800
+ type: priority === "tertiary" ? void 0 : type,
14801
+ priority,
14802
+ block: true,
14803
+ className,
14804
+ disabled,
14805
+ onClick,
14806
+ children: title
14807
+ }
14808
+ );
14809
+ }
14810
+ function DynamicButtonWithBehavior(props) {
14811
+ var _a, _b;
14812
+ const { component } = props;
14813
+ const type = getButtonTypeFromContext(component.context);
14814
+ const priority = (_a = component.control) != null ? _a : "secondary";
14776
14815
  const { loading } = useDynamicFlow();
14777
14816
  const className = getMargin2(component.margin || "md");
14817
+ const disabled = loading || component.disabled;
14818
+ const title = (_b = component.title) != null ? _b : "";
14819
+ const onClick = () => {
14820
+ const { behavior } = component;
14821
+ if (behavior == null ? void 0 : behavior.action) {
14822
+ props.onAction(behavior.action);
14823
+ }
14824
+ if (behavior == null ? void 0 : behavior.link) {
14825
+ window.open(behavior.link.url, "_blank");
14826
+ }
14827
+ };
14778
14828
  return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
14779
14829
  import_components42.Button,
14780
14830
  {
@@ -14783,9 +14833,9 @@ function DynamicButton(props) {
14783
14833
  priority,
14784
14834
  block: true,
14785
14835
  className,
14786
- disabled: loading || component.disabled || componentAction.disabled,
14787
- onClick: () => onAction(componentAction),
14788
- children: (_a = component.title) != null ? _a : componentAction.title
14836
+ disabled,
14837
+ onClick,
14838
+ children: title
14789
14839
  }
14790
14840
  );
14791
14841
  }
@@ -16314,7 +16364,7 @@ var _FormControl = class _FormControl extends import_react39.PureComponent {
16314
16364
  UNSAFE_inputAttributes: {
16315
16365
  id,
16316
16366
  "aria-invalid": invalid,
16317
- "aria-labelledby": void 0,
16367
+ "aria-labelledby": labelledBy,
16318
16368
  "aria-describedby": describedBy
16319
16369
  },
16320
16370
  onChange: this.handleOnChange
@@ -16346,7 +16396,7 @@ var _FormControl = class _FormControl extends import_react39.PureComponent {
16346
16396
  UNSAFE_triggerButtonProps: {
16347
16397
  id,
16348
16398
  "aria-invalid": invalid,
16349
- "aria-labelledby": void 0,
16399
+ "aria-labelledby": labelledBy,
16350
16400
  "aria-describedby": describedBy
16351
16401
  },
16352
16402
  items: items.map((value2) => ({
@@ -16867,11 +16917,12 @@ function OneOfSchema(props) {
16867
16917
  "has-error": !changed && props.errors && !isEmpty(props.errors) || (props.submitted || changed && blurred) && validations.length
16868
16918
  };
16869
16919
  const feedbackId = `${id}-feedback`;
16920
+ const labelId = `${id}-label`;
16870
16921
  return /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)(import_jsx_runtime92.Fragment, { children: [
16871
16922
  (props.schema.oneOf.length > 1 || isConstSchema2(props.schema.oneOf[0])) && /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)(import_jsx_runtime92.Fragment, { children: [
16872
16923
  props.schema.alert && /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(DynamicAlert_default, { component: props.schema.alert }),
16873
16924
  /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)("div", { className: (0, import_classnames11.default)(formGroupClasses), children: [
16874
- getTitleAndHelp(props.schema, id),
16925
+ getTitleAndHelp(props.schema, id, labelId),
16875
16926
  /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
16876
16927
  SchemaFormControl_default,
16877
16928
  {
@@ -16881,6 +16932,7 @@ function OneOfSchema(props) {
16881
16932
  disabled,
16882
16933
  invalid: !isEmpty(props.errors) || validations.length > 0,
16883
16934
  describedBy: feedbackId,
16935
+ labelledBy: labelId,
16884
16936
  required,
16885
16937
  onChange: onChooseNewSchema,
16886
16938
  onFocus,
@@ -16919,10 +16971,10 @@ function OneOfSchema(props) {
16919
16971
  )
16920
16972
  ] });
16921
16973
  }
16922
- function getTitleAndHelp(schema, forId) {
16974
+ function getTitleAndHelp(schema, forId, labelId) {
16923
16975
  var _a;
16924
16976
  const helpElement = schema.help ? /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(Help_default2, { help: schema.help }) : null;
16925
- const titleElement = isConstSchema2(schema.oneOf[0]) ? /* @__PURE__ */ (0, import_jsx_runtime92.jsx)("div", { className: "m-b-1", children: /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)("label", { className: "control-label d-inline", htmlFor: forId, children: [
16977
+ const titleElement = isConstSchema2(schema.oneOf[0]) ? /* @__PURE__ */ (0, import_jsx_runtime92.jsx)("div", { className: "m-b-1", children: /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)("label", { className: "control-label d-inline", id: labelId, htmlFor: forId, children: [
16926
16978
  schema.title,
16927
16979
  " ",
16928
16980
  helpElement