@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.mjs CHANGED
@@ -138,12 +138,12 @@ var init_clsx = __esm({
138
138
  }
139
139
  });
140
140
 
141
- // ../../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
141
+ // ../../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
142
142
  import { useState as useState2, useEffect as useEffect2, forwardRef, Suspense, lazy } from "react";
143
143
  import { jsx as jsx17, jsxs as jsxs4, Fragment as Fragment3 } from "react/jsx-runtime";
144
144
  var unknownFlagName, Flag, Sizes, ImageSizes, imageSizes, Assets, RenderMode;
145
145
  var init_index_a91e5689_esm = __esm({
146
- "../../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"() {
146
+ "../../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"() {
147
147
  "use strict";
148
148
  init_clsx();
149
149
  unknownFlagName = "wise";
@@ -11404,7 +11404,7 @@ var DateInputRenderer_default = DateInputRenderer;
11404
11404
  // ../renderers/src/DecisionRenderer.tsx
11405
11405
  import { NavigationOptionsList, NavigationOption, Header } from "@transferwise/components";
11406
11406
 
11407
- // ../../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
11407
+ // ../../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
11408
11408
  init_index_a91e5689_esm();
11409
11409
  init_clsx();
11410
11410
  import "react";
@@ -14714,10 +14714,9 @@ var priorities = {
14714
14714
  positive: "primary",
14715
14715
  negative: "primary"
14716
14716
  };
14717
- var getButtonPriority = (component) => {
14718
- var _a;
14719
- const actionType = component.action.type;
14720
- return (_a = component.control) != null ? _a : actionType ? priorities[actionType] : "secondary";
14717
+ var getButtonPriority = (control, action) => {
14718
+ const actionType = action ? action.type : void 0;
14719
+ return control != null ? control : actionType ? priorities[actionType] : "secondary";
14721
14720
  };
14722
14721
  var contextToType = {
14723
14722
  positive: "positive",
@@ -14732,13 +14731,16 @@ var actionTypeToType = {
14732
14731
  positive: "positive",
14733
14732
  negative: "negative"
14734
14733
  };
14735
- var getButtonType = (component) => {
14736
- if (component.context) {
14737
- return contextToType[component.context];
14734
+ var getButtonType = (context, action) => {
14735
+ if (context) {
14736
+ return contextToType[context];
14738
14737
  }
14739
- const actionType = component.action.type;
14738
+ const actionType = action ? action.type : void 0;
14740
14739
  return actionType ? actionTypeToType[actionType] : "accent";
14741
14740
  };
14741
+ var getButtonTypeFromContext = (context) => {
14742
+ return context ? contextToType[context] : "accent";
14743
+ };
14742
14744
  var getButtonSize = (size) => {
14743
14745
  switch (size) {
14744
14746
  case "xs":
@@ -14756,13 +14758,23 @@ var getButtonSize = (size) => {
14756
14758
  // src/legacy/layout/button/DynamicButton.tsx
14757
14759
  import { jsx as jsx72 } from "react/jsx-runtime";
14758
14760
  function DynamicButton(props) {
14759
- var _a;
14761
+ return props.component.behavior ? /* @__PURE__ */ jsx72(DynamicButtonWithBehavior, __spreadValues({}, props)) : /* @__PURE__ */ jsx72(DynamicButtonWithoutBehavior, __spreadValues({}, props));
14762
+ }
14763
+ function DynamicButtonWithoutBehavior(props) {
14764
+ var _a, _b;
14760
14765
  const { component, onAction } = props;
14761
14766
  const componentAction = component.action;
14762
- const type = getButtonType(component);
14763
- const priority = getButtonPriority(component);
14767
+ const type = getButtonType(component.context, componentAction);
14768
+ const priority = getButtonPriority(component.control, componentAction);
14764
14769
  const { loading } = useDynamicFlow();
14765
14770
  const className = getMargin2(component.margin || "md");
14771
+ const disabled = loading || component.disabled || (componentAction == null ? void 0 : componentAction.disabled);
14772
+ const title = (_b = (_a = component.title) != null ? _a : componentAction == null ? void 0 : componentAction.title) != null ? _b : "";
14773
+ const onClick = () => {
14774
+ if (componentAction) {
14775
+ onAction(componentAction);
14776
+ }
14777
+ };
14766
14778
  return /* @__PURE__ */ jsx72(
14767
14779
  Button6,
14768
14780
  {
@@ -14771,9 +14783,41 @@ function DynamicButton(props) {
14771
14783
  priority,
14772
14784
  block: true,
14773
14785
  className,
14774
- disabled: loading || component.disabled || componentAction.disabled,
14775
- onClick: () => onAction(componentAction),
14776
- children: (_a = component.title) != null ? _a : componentAction.title
14786
+ disabled,
14787
+ onClick,
14788
+ children: title
14789
+ }
14790
+ );
14791
+ }
14792
+ function DynamicButtonWithBehavior(props) {
14793
+ var _a, _b;
14794
+ const { component } = props;
14795
+ const type = getButtonTypeFromContext(component.context);
14796
+ const priority = (_a = component.control) != null ? _a : "secondary";
14797
+ const { loading } = useDynamicFlow();
14798
+ const className = getMargin2(component.margin || "md");
14799
+ const disabled = loading || component.disabled;
14800
+ const title = (_b = component.title) != null ? _b : "";
14801
+ const onClick = () => {
14802
+ const { behavior } = component;
14803
+ if (behavior == null ? void 0 : behavior.action) {
14804
+ props.onAction(behavior.action);
14805
+ }
14806
+ if (behavior == null ? void 0 : behavior.link) {
14807
+ window.open(behavior.link.url, "_blank");
14808
+ }
14809
+ };
14810
+ return /* @__PURE__ */ jsx72(
14811
+ Button6,
14812
+ {
14813
+ size: getButtonSize(component.size),
14814
+ type: priority === "tertiary" ? void 0 : type,
14815
+ priority,
14816
+ block: true,
14817
+ className,
14818
+ disabled,
14819
+ onClick,
14820
+ children: title
14777
14821
  }
14778
14822
  );
14779
14823
  }
@@ -1,7 +1,9 @@
1
- import type { ButtonLayout } from '@wise/dynamic-flow-types';
1
+ import type { Behavior, ButtonLayout } from '@wise/dynamic-flow-types';
2
2
  import type { CommonLayoutProps } from '../DynamicLayout';
3
3
  type Props = Omit<CommonLayoutProps, 'submitted' | 'onModelChange' | 'onPersistAsync'> & {
4
- component: ButtonLayout;
4
+ component: ButtonLayout & {
5
+ behavior?: Behavior;
6
+ };
5
7
  };
6
8
  declare function DynamicButton(props: Props): import("react/jsx-runtime").JSX.Element;
7
9
  export default DynamicButton;
@@ -1,4 +1,5 @@
1
- import type { ButtonLayout, Size } from '@wise/dynamic-flow-types';
2
- export declare const getButtonPriority: (component: ButtonLayout) => "primary" | "secondary" | "tertiary";
3
- export declare const getButtonType: (component: ButtonLayout) => "positive" | "negative" | "accent";
1
+ import type { Action, Size } from '@wise/dynamic-flow-types';
2
+ export declare const getButtonPriority: (control: "primary" | "secondary" | "tertiary" | undefined, action: Action | undefined) => "primary" | "secondary" | "tertiary";
3
+ export declare const getButtonType: (context: "positive" | "negative" | "neutral" | undefined, action: Action | undefined) => "positive" | "negative" | "accent";
4
+ export declare const getButtonTypeFromContext: (context: "positive" | "negative" | "neutral" | undefined) => "positive" | "negative" | "accent";
4
5
  export declare const getButtonSize: (size: Size | undefined) => "sm" | "md" | "lg";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wise/dynamic-flow-client",
3
- "version": "3.20.2",
3
+ "version": "3.21.1",
4
4
  "description": "Dynamic Flow web client",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./build/main.min.js",
@@ -27,26 +27,26 @@
27
27
  "url": "git+https://github.com/transferwise/dynamic-flow.git"
28
28
  },
29
29
  "devDependencies": {
30
- "@babel/core": "7.25.2",
31
- "@babel/plugin-syntax-flow": "7.24.7",
32
- "@babel/plugin-transform-react-jsx": "7.25.2",
33
- "@babel/preset-env": "7.25.4",
34
- "@babel/preset-react": "7.24.7",
35
- "@babel/preset-typescript": "7.24.7",
30
+ "@babel/core": "7.25.7",
31
+ "@babel/plugin-syntax-flow": "7.25.7",
32
+ "@babel/plugin-transform-react-jsx": "7.25.7",
33
+ "@babel/preset-env": "7.25.7",
34
+ "@babel/preset-react": "7.25.7",
35
+ "@babel/preset-typescript": "7.25.7",
36
36
  "@cfaester/enzyme-adapter-react-18": "0.8.0",
37
- "@chromatic-com/storybook": "1.9.0",
37
+ "@chromatic-com/storybook": "2.0.2",
38
38
  "@formatjs/cli": "^6.2.12",
39
- "@storybook/addon-a11y": "^8.3.2",
40
- "@storybook/addon-actions": "^8.3.2",
41
- "@storybook/addon-essentials": "^8.3.2",
42
- "@storybook/addon-interactions": "^8.3.2",
43
- "@storybook/addon-links": "^8.3.2",
39
+ "@storybook/addon-a11y": "^8.3.5",
40
+ "@storybook/addon-actions": "^8.3.5",
41
+ "@storybook/addon-essentials": "^8.3.5",
42
+ "@storybook/addon-interactions": "^8.3.5",
43
+ "@storybook/addon-links": "^8.3.5",
44
44
  "@storybook/addon-webpack5-compiler-babel": "^3.0.3",
45
- "@storybook/manager-api": "^8.3.2",
46
- "@storybook/react": "^8.3.2",
47
- "@storybook/react-webpack5": "^8.3.2",
48
- "@storybook/test": "^8.3.2",
49
- "@storybook/types": "^8.3.2",
45
+ "@storybook/manager-api": "^8.3.5",
46
+ "@storybook/react": "^8.3.5",
47
+ "@storybook/react-webpack5": "^8.3.5",
48
+ "@storybook/test": "^8.3.5",
49
+ "@storybook/types": "^8.3.5",
50
50
  "@testing-library/dom": "10.4.0",
51
51
  "@testing-library/jest-dom": "6.5.0",
52
52
  "@testing-library/react": "16.0.1",
@@ -57,14 +57,14 @@
57
57
  "@transferwise/neptune-css": "14.18.0",
58
58
  "@types/enzyme": "^3.10.18",
59
59
  "@types/jest": "29.5.13",
60
- "@types/react": "18.3.8",
60
+ "@types/react": "18.3.11",
61
61
  "@types/react-dom": "18.3.0",
62
62
  "@types/react-intl": "3.0.0",
63
63
  "@wise/art": "2.15.0",
64
64
  "@wise/components-theming": "^1.6.0",
65
65
  "babel-jest": "29.7.0",
66
66
  "enzyme": "^3.11.0",
67
- "esbuild": "0.23.1",
67
+ "esbuild": "0.24.0",
68
68
  "jest": "29.7.0",
69
69
  "jest-environment-jsdom": "29.7.0",
70
70
  "jest-fetch-mock": "^3.0.3",
@@ -77,16 +77,16 @@
77
77
  "react": "18.3.1",
78
78
  "react-dom": "18.3.1",
79
79
  "react-intl": "6.7.0",
80
- "storybook": "^8.3.2",
80
+ "storybook": "^8.3.5",
81
81
  "stylelint": "16.9.0",
82
82
  "stylelint-config-standard": "36.0.1",
83
83
  "stylelint-no-unsupported-browser-features": "8.0.1",
84
84
  "stylelint-value-no-unknown-custom-properties": "6.0.1",
85
85
  "tsx": "4.19.1",
86
86
  "typescript": "5.6.2",
87
- "webpack": "5.94.0",
88
- "@wise/dynamic-flow-fixtures": "0.0.1",
89
- "@wise/dynamic-flow-renderers": "0.0.0"
87
+ "webpack": "5.95.0",
88
+ "@wise/dynamic-flow-renderers": "0.0.0",
89
+ "@wise/dynamic-flow-fixtures": "0.0.1"
90
90
  },
91
91
  "peerDependencies": {
92
92
  "@transferwise/components": "^46.31",
@@ -103,7 +103,7 @@
103
103
  "nanoid": "5.0.7",
104
104
  "react-webcam": "^7.2.0",
105
105
  "screenfull": "^5.2.0",
106
- "@wise/dynamic-flow-types": "2.23.0"
106
+ "@wise/dynamic-flow-types": "2.23.2"
107
107
  },
108
108
  "scripts": {
109
109
  "dev": "pnpm build:visual-tests && storybook dev -p 3003",