@wise/dynamic-flow-client 3.20.2 → 3.21.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.js CHANGED
@@ -144,10 +144,10 @@ var init_clsx = __esm({
144
144
  }
145
145
  });
146
146
 
147
- // ../../node_modules/.pnpm/@wise+art@2.15.0_@transferwise+neptune-css@14.18.0_@types+react@18.3.8_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wise/art/dist/index-a91e5689.esm.js
147
+ // ../../node_modules/.pnpm/@wise+art@2.15.0_@transferwise+neptune-css@14.18.0_@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
149
  var init_index_a91e5689_esm = __esm({
150
- "../../node_modules/.pnpm/@wise+art@2.15.0_@transferwise+neptune-css@14.18.0_@types+react@18.3.8_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wise/art/dist/index-a91e5689.esm.js"() {
150
+ "../../node_modules/.pnpm/@wise+art@2.15.0_@transferwise+neptune-css@14.18.0_@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");
@@ -11428,7 +11428,7 @@ var DateInputRenderer_default = DateInputRenderer;
11428
11428
  // ../renderers/src/DecisionRenderer.tsx
11429
11429
  var import_components9 = require("@transferwise/components");
11430
11430
 
11431
- // ../../node_modules/.pnpm/@wise+art@2.15.0_@transferwise+neptune-css@14.18.0_@types+react@18.3.8_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wise/art/dist/index.esm.js
11431
+ // ../../node_modules/.pnpm/@wise+art@2.15.0_@transferwise+neptune-css@14.18.0_@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
11432
11432
  init_index_a91e5689_esm();
11433
11433
  init_clsx();
11434
11434
  var import_react8 = require("react");
@@ -14732,10 +14732,9 @@ var priorities = {
14732
14732
  positive: "primary",
14733
14733
  negative: "primary"
14734
14734
  };
14735
- var getButtonPriority = (component) => {
14736
- var _a;
14737
- const actionType = component.action.type;
14738
- 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";
14739
14738
  };
14740
14739
  var contextToType = {
14741
14740
  positive: "positive",
@@ -14750,13 +14749,16 @@ var actionTypeToType = {
14750
14749
  positive: "positive",
14751
14750
  negative: "negative"
14752
14751
  };
14753
- var getButtonType = (component) => {
14754
- if (component.context) {
14755
- return contextToType[component.context];
14752
+ var getButtonType = (context, action) => {
14753
+ if (context) {
14754
+ return contextToType[context];
14756
14755
  }
14757
- const actionType = component.action.type;
14756
+ const actionType = action ? action.type : void 0;
14758
14757
  return actionType ? actionTypeToType[actionType] : "accent";
14759
14758
  };
14759
+ var getButtonTypeFromContext = (context) => {
14760
+ return context ? contextToType[context] : "accent";
14761
+ };
14760
14762
  var getButtonSize = (size) => {
14761
14763
  switch (size) {
14762
14764
  case "xs":
@@ -14774,13 +14776,23 @@ var getButtonSize = (size) => {
14774
14776
  // src/legacy/layout/button/DynamicButton.tsx
14775
14777
  var import_jsx_runtime73 = require("react/jsx-runtime");
14776
14778
  function DynamicButton(props) {
14777
- 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;
14778
14783
  const { component, onAction } = props;
14779
14784
  const componentAction = component.action;
14780
- const type = getButtonType(component);
14781
- const priority = getButtonPriority(component);
14785
+ const type = getButtonType(component.context, componentAction);
14786
+ const priority = getButtonPriority(component.control, componentAction);
14782
14787
  const { loading } = useDynamicFlow();
14783
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
+ };
14784
14796
  return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
14785
14797
  import_components42.Button,
14786
14798
  {
@@ -14789,9 +14801,41 @@ function DynamicButton(props) {
14789
14801
  priority,
14790
14802
  block: true,
14791
14803
  className,
14792
- disabled: loading || component.disabled || componentAction.disabled,
14793
- onClick: () => onAction(componentAction),
14794
- children: (_a = component.title) != null ? _a : componentAction.title
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";
14815
+ const { loading } = useDynamicFlow();
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
+ };
14828
+ return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
14829
+ import_components42.Button,
14830
+ {
14831
+ size: getButtonSize(component.size),
14832
+ type: priority === "tertiary" ? void 0 : type,
14833
+ priority,
14834
+ block: true,
14835
+ className,
14836
+ disabled,
14837
+ onClick,
14838
+ children: title
14795
14839
  }
14796
14840
  );
14797
14841
  }