@wise/dynamic-flow-client 3.19.6 → 3.20.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 +101 -24
- package/build/main.min.js +1 -1
- package/build/main.mjs +101 -24
- package/build/types/revamp/domain/mappers/layout/buttonLayoutToComponent.d.ts +4 -1
- package/build/types/revamp/domain/mappers/schema/tests/test-utils.d.ts +1 -0
- package/build/types/revamp/domain/mappers/schema/types.d.ts +2 -1
- package/build/types/revamp/domain/types.d.ts +2 -1
- package/build/types/revamp/types.d.ts +3 -2
- package/build/types/revamp/useDynamicFlowCore.d.ts +1 -0
- package/build/types/revamp/utils/openLinkInNewTab.d.ts +1 -0
- package/package.json +8 -8
package/build/main.mjs
CHANGED
|
@@ -6990,25 +6990,89 @@ var getActionByReference = ($ref, actions = []) => {
|
|
|
6990
6990
|
};
|
|
6991
6991
|
|
|
6992
6992
|
// src/revamp/domain/mappers/layout/buttonLayoutToComponent.ts
|
|
6993
|
-
var buttonLayoutToComponent = (uid, button,
|
|
6993
|
+
var buttonLayoutToComponent = (uid, button, mapperProps) => {
|
|
6994
|
+
if (button.behavior) {
|
|
6995
|
+
return buttonLayoutToComponentWithBehavior(
|
|
6996
|
+
uid,
|
|
6997
|
+
__spreadProps(__spreadValues({}, button), { behavior: button.behavior }),
|
|
6998
|
+
mapperProps
|
|
6999
|
+
);
|
|
7000
|
+
}
|
|
7001
|
+
if (button.action) {
|
|
7002
|
+
return buttonLayoutToComponentWithAction(
|
|
7003
|
+
uid,
|
|
7004
|
+
__spreadProps(__spreadValues({}, button), { action: button.action }),
|
|
7005
|
+
mapperProps
|
|
7006
|
+
);
|
|
7007
|
+
}
|
|
7008
|
+
return buttonLayoutToComponentWithNoop(uid, button);
|
|
7009
|
+
};
|
|
7010
|
+
var buttonLayoutToComponentWithBehavior = (uid, button, mapperProps) => {
|
|
7011
|
+
const { onAction, onLink, step } = mapperProps;
|
|
7012
|
+
const { context, control, disabled, margin = "md", pinOrder, size, title, behavior } = button;
|
|
7013
|
+
const { action, link } = behavior;
|
|
7014
|
+
const inlinedAction = action ? inlineAction(action, step == null ? void 0 : step.actions) : null;
|
|
7015
|
+
const onClick = (() => {
|
|
7016
|
+
if (inlinedAction) {
|
|
7017
|
+
return () => {
|
|
7018
|
+
void onAction(inlinedAction);
|
|
7019
|
+
};
|
|
7020
|
+
}
|
|
7021
|
+
if (link) {
|
|
7022
|
+
return () => {
|
|
7023
|
+
onLink(link.url);
|
|
7024
|
+
};
|
|
7025
|
+
}
|
|
7026
|
+
return () => {
|
|
7027
|
+
};
|
|
7028
|
+
})();
|
|
7029
|
+
return createButtonComponent({
|
|
7030
|
+
uid,
|
|
7031
|
+
context: mapLegacyContext(context != null ? context : "neutral"),
|
|
7032
|
+
control,
|
|
7033
|
+
disabled: disabled != null ? disabled : false,
|
|
7034
|
+
margin,
|
|
7035
|
+
pinOrder,
|
|
7036
|
+
size,
|
|
7037
|
+
title: title != null ? title : "",
|
|
7038
|
+
onClick
|
|
7039
|
+
});
|
|
7040
|
+
};
|
|
7041
|
+
var buttonLayoutToComponentWithAction = (uid, button, mapperProps) => {
|
|
7042
|
+
const { onAction, step } = mapperProps;
|
|
6994
7043
|
const { context, control, disabled, margin = "md", pinOrder, size, title } = button;
|
|
6995
|
-
const action = button
|
|
6996
|
-
const
|
|
6997
|
-
|
|
6998
|
-
|
|
7044
|
+
const { action } = button;
|
|
7045
|
+
const inlinedAction = action ? inlineAction(action, step == null ? void 0 : step.actions) : {};
|
|
7046
|
+
const onClick = () => {
|
|
7047
|
+
void onAction(inlinedAction);
|
|
6999
7048
|
};
|
|
7000
7049
|
return createButtonComponent({
|
|
7001
7050
|
uid,
|
|
7002
|
-
context: getButtonContext({ context, action }),
|
|
7003
|
-
control: getButtonControl({ control, action }),
|
|
7004
|
-
disabled: getButtonDisabled({ disabled, action }),
|
|
7051
|
+
context: getButtonContext({ context, action: inlinedAction }),
|
|
7052
|
+
control: getButtonControl({ control, action: inlinedAction }),
|
|
7053
|
+
disabled: getButtonDisabled({ disabled, action: inlinedAction }),
|
|
7005
7054
|
margin,
|
|
7006
7055
|
pinOrder,
|
|
7007
7056
|
size,
|
|
7008
|
-
title: getButtonTitle({ title, action }),
|
|
7057
|
+
title: getButtonTitle({ title, action: inlinedAction }),
|
|
7009
7058
|
onClick
|
|
7010
7059
|
});
|
|
7011
7060
|
};
|
|
7061
|
+
var buttonLayoutToComponentWithNoop = (uid, button) => {
|
|
7062
|
+
const { context, control, disabled, margin = "md", pinOrder, size, title } = button;
|
|
7063
|
+
return createButtonComponent({
|
|
7064
|
+
uid,
|
|
7065
|
+
context: mapLegacyContext(context != null ? context : "neutral"),
|
|
7066
|
+
control,
|
|
7067
|
+
disabled: disabled != null ? disabled : false,
|
|
7068
|
+
margin,
|
|
7069
|
+
pinOrder,
|
|
7070
|
+
size,
|
|
7071
|
+
title: title != null ? title : "",
|
|
7072
|
+
onClick: () => {
|
|
7073
|
+
}
|
|
7074
|
+
});
|
|
7075
|
+
};
|
|
7012
7076
|
var getButtonTitle = ({ title, action }) => {
|
|
7013
7077
|
var _a;
|
|
7014
7078
|
return (_a = title != null ? title : action == null ? void 0 : action.title) != null ? _a : "";
|
|
@@ -10707,6 +10771,7 @@ function useDynamicFlowCore(props) {
|
|
|
10707
10771
|
const httpClient = useStableCallback(rest.httpClient);
|
|
10708
10772
|
const onCompletion = useStableCallback(rest.onCompletion);
|
|
10709
10773
|
const onValueChange = useStableCallback(props.onValueChange);
|
|
10774
|
+
const onLink = useStableCallback(props.onLink);
|
|
10710
10775
|
const onError = useStableCallback(rest.onError);
|
|
10711
10776
|
const onEvent = useStableCallback(rest.onEvent);
|
|
10712
10777
|
const onLog = useStableCallback(rest.onLog);
|
|
@@ -10770,6 +10835,7 @@ function useDynamicFlowCore(props) {
|
|
|
10770
10835
|
onAction,
|
|
10771
10836
|
onRefresh,
|
|
10772
10837
|
onPoll,
|
|
10838
|
+
onLink,
|
|
10773
10839
|
onValueChange
|
|
10774
10840
|
});
|
|
10775
10841
|
setStepComponent(() => {
|
|
@@ -10948,14 +11014,7 @@ function DynamicFlowCore(props) {
|
|
|
10948
11014
|
onEvent == null ? void 0 : onEvent("Dynamic Flow - Failed", { error });
|
|
10949
11015
|
onError == null ? void 0 : onError(error);
|
|
10950
11016
|
},
|
|
10951
|
-
children: /* @__PURE__ */ jsx5(
|
|
10952
|
-
"div",
|
|
10953
|
-
{
|
|
10954
|
-
id: (_b = (_a = stepComponentRef.current) == null ? void 0 : _a.step) == null ? void 0 : _b.id,
|
|
10955
|
-
className: "dynamic-flow",
|
|
10956
|
-
children: stepComponentRef.current ? render(stepComponentRef.current) : null
|
|
10957
|
-
}
|
|
10958
|
-
)
|
|
11017
|
+
children: /* @__PURE__ */ jsx5("div", { id: (_b = (_a = stepComponentRef.current) == null ? void 0 : _a.step) == null ? void 0 : _b.id, className: "dynamic-flow", children: stepComponentRef.current ? render(stepComponentRef.current) : null })
|
|
10959
11018
|
}
|
|
10960
11019
|
);
|
|
10961
11020
|
}
|
|
@@ -13021,13 +13080,24 @@ var getWiseRenderers = () => [
|
|
|
13021
13080
|
StepRenderer
|
|
13022
13081
|
];
|
|
13023
13082
|
|
|
13083
|
+
// src/revamp/utils/openLinkInNewTab.tsx
|
|
13084
|
+
var openLinkInNewTab = (url) => {
|
|
13085
|
+
var _a;
|
|
13086
|
+
try {
|
|
13087
|
+
const w = (_a = window == null ? void 0 : window.open) == null ? void 0 : _a.call(window, url, "_blank");
|
|
13088
|
+
return Boolean(w);
|
|
13089
|
+
} catch (e) {
|
|
13090
|
+
return false;
|
|
13091
|
+
}
|
|
13092
|
+
};
|
|
13093
|
+
|
|
13024
13094
|
// src/revamp/DynamicFlowWise.tsx
|
|
13025
13095
|
import { jsx as jsx58 } from "react/jsx-runtime";
|
|
13026
13096
|
var wiseRenderers = getWiseRenderers();
|
|
13027
13097
|
function DynamicFlowWise(props) {
|
|
13028
|
-
const { httpClient, renderers } = props;
|
|
13098
|
+
const { httpClient, renderers, onLink = openLinkInNewTab } = props;
|
|
13029
13099
|
const mergedRenderers = useMemo4(() => [...renderers != null ? renderers : [], ...wiseRenderers], [renderers]);
|
|
13030
|
-
return /* @__PURE__ */ jsx58(RendererHttpClientProvider, { httpClient, children: /* @__PURE__ */ jsx58(DynamicFlowCore, __spreadProps(__spreadValues({}, props), { renderers: mergedRenderers })) });
|
|
13100
|
+
return /* @__PURE__ */ jsx58(RendererHttpClientProvider, { httpClient, children: /* @__PURE__ */ jsx58(DynamicFlowCore, __spreadProps(__spreadValues({}, props), { renderers: mergedRenderers, onLink })) });
|
|
13031
13101
|
}
|
|
13032
13102
|
var DynamicFlowWise_default = DynamicFlowWise;
|
|
13033
13103
|
|
|
@@ -13058,10 +13128,17 @@ var useHasHttpClientProvider = () => {
|
|
|
13058
13128
|
import { jsx as jsx60 } from "react/jsx-runtime";
|
|
13059
13129
|
var wiseRenderers2 = getWiseRenderers();
|
|
13060
13130
|
var DynamicFragmentWise = forwardRef2(function DynamicFragmentWise2(props, ref) {
|
|
13061
|
-
const {
|
|
13062
|
-
|
|
13131
|
+
const {
|
|
13132
|
+
httpClient,
|
|
13133
|
+
onCompletion = () => {
|
|
13134
|
+
},
|
|
13135
|
+
onEvent,
|
|
13136
|
+
onError,
|
|
13137
|
+
renderers,
|
|
13138
|
+
onLink = openLinkInNewTab
|
|
13139
|
+
} = props;
|
|
13063
13140
|
const mergedRenderers = useMemo6(() => [...renderers != null ? renderers : [], ...wiseRenderers2], [renderers]);
|
|
13064
|
-
const { stepComponentRef } = useDynamicFlowCore(__spreadValues({ onCompletion }, props));
|
|
13141
|
+
const { stepComponentRef } = useDynamicFlowCore(__spreadProps(__spreadValues({ onCompletion }, props), { onLink }));
|
|
13065
13142
|
useImperativeHandle(
|
|
13066
13143
|
ref,
|
|
13067
13144
|
() => ({
|
|
@@ -13099,8 +13176,8 @@ import { forwardRef as forwardRef3, useImperativeHandle as useImperativeHandle2,
|
|
|
13099
13176
|
import { jsx as jsx61 } from "react/jsx-runtime";
|
|
13100
13177
|
var DynamicFragmentCore = forwardRef3(function DynamicFragmentCore2(props, ref) {
|
|
13101
13178
|
const { onCompletion = () => {
|
|
13102
|
-
}, onEvent, onError, renderers } = props;
|
|
13103
|
-
const { stepComponentRef } = useDynamicFlowCore(__spreadValues({ onCompletion }, props));
|
|
13179
|
+
}, onEvent, onError, onLink = openLinkInNewTab, renderers } = props;
|
|
13180
|
+
const { stepComponentRef } = useDynamicFlowCore(__spreadProps(__spreadValues({ onCompletion }, props), { onLink }));
|
|
13104
13181
|
useImperativeHandle2(
|
|
13105
13182
|
ref,
|
|
13106
13183
|
() => ({
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import type { ButtonLayout } from '@wise/dynamic-flow-types/build/next';
|
|
2
|
+
import type { Behavior } from '@wise/dynamic-flow-types/build/next/feature/Behavior';
|
|
2
3
|
import type { MapperProps } from '../schema/types';
|
|
3
|
-
export declare const buttonLayoutToComponent: (uid: string, button: ButtonLayout
|
|
4
|
+
export declare const buttonLayoutToComponent: (uid: string, button: ButtonLayout & {
|
|
5
|
+
behavior?: Behavior;
|
|
6
|
+
}, mapperProps: MapperProps) => import("../../components/ButtonComponent").ButtonComponent;
|
|
@@ -6,6 +6,7 @@ export declare const getMockMapperProps: (mapperProps?: Partial<MapperProps>) =>
|
|
|
6
6
|
step: Step;
|
|
7
7
|
getErrorMessageFunctions: import("../../types").GetErrorMessageFunctions | jest.Mock<any, any, any>;
|
|
8
8
|
httpClient: typeof fetch | jest.Mock<any, any, any>;
|
|
9
|
+
onLink: import("../../../types").OnLink | jest.Mock<any, any, any>;
|
|
9
10
|
onAction: import("../../../types").OnAction | jest.Mock<any, any, any>;
|
|
10
11
|
onRefresh: import("../../../types").OnRefresh | jest.Mock<any, any, any>;
|
|
11
12
|
onValueChange: import("../../../types").OnValueChange | jest.Mock<any, any, any>;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import type { Step as DFStep, Model, Schema, ValidationError } from '@wise/dynamic-flow-types/build/next';
|
|
2
2
|
import type { HttpClient } from '../../../types';
|
|
3
3
|
import type { AnalyticsEventDispatcher, LoggingEventDispatcher } from '../../features/events';
|
|
4
|
-
import type { LocalValue, OnAction, OnRefresh, OnValueChange, UpdateComponent } from '../../types';
|
|
4
|
+
import type { LocalValue, OnAction, OnLink, OnRefresh, OnValueChange, UpdateComponent } from '../../types';
|
|
5
5
|
import type { GetErrorMessageFunctions, PersistAsyncConfig } from '../types';
|
|
6
6
|
export type MapperProps = {
|
|
7
7
|
stepLocalValue: LocalValue;
|
|
8
8
|
step: DFStep;
|
|
9
9
|
getErrorMessageFunctions: GetErrorMessageFunctions;
|
|
10
10
|
httpClient: HttpClient;
|
|
11
|
+
onLink: OnLink;
|
|
11
12
|
onAction: OnAction;
|
|
12
13
|
onRefresh: OnRefresh;
|
|
13
14
|
onValueChange: OnValueChange;
|
|
@@ -76,8 +76,9 @@ export type InputComponent<V extends LocalValue> = ComponentWithTitle & {
|
|
|
76
76
|
};
|
|
77
77
|
export type UpdateComponent = (id: string, update: (component: DomainComponent) => void) => void;
|
|
78
78
|
export type OnAction = (action: Action) => Promise<void>;
|
|
79
|
-
export type OnPoll = (url: string, errorAction: Action, signal: AbortSignal) => Promise<boolean>;
|
|
80
79
|
export type OnRefresh = (schemaId: string | undefined, url?: string) => Promise<void> | void;
|
|
80
|
+
export type OnPoll = (url: string, errorAction: Action, signal: AbortSignal) => Promise<boolean>;
|
|
81
|
+
export type OnLink = (url: string) => boolean;
|
|
81
82
|
export type OnValueChange = () => void;
|
|
82
83
|
export type Align = 'start' | 'center' | 'end';
|
|
83
84
|
export type Bias = 'none' | 'start' | 'end';
|
|
@@ -11,8 +11,8 @@ export type DynamicFlowCorePropsWithInitialStep = DynamicFlowCorePropsBasic & {
|
|
|
11
11
|
initialStep: Step;
|
|
12
12
|
};
|
|
13
13
|
type MakeOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
14
|
-
export type DynamicFlowWisePropsWithInitialAction = MakeOptional<DynamicFlowCorePropsWithInitialAction, 'renderers'>;
|
|
15
|
-
export type DynamicFlowWisePropsWithInitialStep = MakeOptional<DynamicFlowCorePropsWithInitialStep, 'renderers'>;
|
|
14
|
+
export type DynamicFlowWisePropsWithInitialAction = MakeOptional<DynamicFlowCorePropsWithInitialAction, 'renderers' | 'onLink'>;
|
|
15
|
+
export type DynamicFlowWisePropsWithInitialStep = MakeOptional<DynamicFlowCorePropsWithInitialStep, 'renderers' | 'onLink'>;
|
|
16
16
|
export type DynamicFlowWiseProps = DynamicFlowWisePropsWithInitialAction | DynamicFlowWisePropsWithInitialStep;
|
|
17
17
|
export type DynamicFragmentController = {
|
|
18
18
|
/**
|
|
@@ -45,6 +45,7 @@ type DynamicFlowCorePropsBasic = {
|
|
|
45
45
|
onError: (error: unknown, status?: number) => void;
|
|
46
46
|
onEvent?: AnalyticsEventHandler;
|
|
47
47
|
onLog?: LoggingEventHandler;
|
|
48
|
+
onLink: (url: string) => boolean;
|
|
48
49
|
};
|
|
49
50
|
export type HttpClient = typeof fetch;
|
|
50
51
|
type Feature = {
|
|
@@ -3,6 +3,7 @@ import type { OnValueChange } from './domain/types';
|
|
|
3
3
|
import type { DynamicFlowCoreProps } from './types';
|
|
4
4
|
type UseDynamicFlowCoreProps = Omit<DynamicFlowCoreProps, 'renderers'> & {
|
|
5
5
|
onValueChange?: OnValueChange;
|
|
6
|
+
onLink: (url: string) => boolean;
|
|
6
7
|
};
|
|
7
8
|
export declare function useDynamicFlowCore(props: UseDynamicFlowCoreProps): {
|
|
8
9
|
stepComponentRef: import("react").MutableRefObject<StepDomainComponent | null>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const openLinkInNewTab: (url: string) => boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wise/dynamic-flow-client",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.20.0",
|
|
4
4
|
"description": "Dynamic Flow web client",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "./build/main.min.js",
|
|
@@ -52,12 +52,12 @@
|
|
|
52
52
|
"@testing-library/react": "16.0.1",
|
|
53
53
|
"@testing-library/react-hooks": "8.0.1",
|
|
54
54
|
"@testing-library/user-event": "14.5.2",
|
|
55
|
-
"@transferwise/components": "46.70.
|
|
55
|
+
"@transferwise/components": "46.70.3",
|
|
56
56
|
"@transferwise/formatting": "^2.13.0",
|
|
57
57
|
"@transferwise/icons": "3.13.0",
|
|
58
58
|
"@transferwise/neptune-css": "14.18.0",
|
|
59
59
|
"@types/enzyme": "^3.10.18",
|
|
60
|
-
"@types/jest": "29.5.
|
|
60
|
+
"@types/jest": "29.5.13",
|
|
61
61
|
"@types/react": "18.3.5",
|
|
62
62
|
"@types/react-dom": "18.3.0",
|
|
63
63
|
"@types/react-intl": "3.0.0",
|
|
@@ -71,8 +71,8 @@
|
|
|
71
71
|
"jest-fetch-mock": "^3.0.3",
|
|
72
72
|
"jest-watch-typeahead": "^2.2.2",
|
|
73
73
|
"nanoid": "5.0.7",
|
|
74
|
-
"npm-run-all2": "6.2.
|
|
75
|
-
"postcss": "^8.4.
|
|
74
|
+
"npm-run-all2": "6.2.3",
|
|
75
|
+
"postcss": "^8.4.47",
|
|
76
76
|
"postcss-cli": "^11.0.0",
|
|
77
77
|
"postcss-import": "^15.1.0",
|
|
78
78
|
"react": "18.3.1",
|
|
@@ -83,8 +83,8 @@
|
|
|
83
83
|
"stylelint-config-standard": "36.0.1",
|
|
84
84
|
"stylelint-no-unsupported-browser-features": "8.0.1",
|
|
85
85
|
"stylelint-value-no-unknown-custom-properties": "6.0.1",
|
|
86
|
-
"tsx": "4.19.
|
|
87
|
-
"typescript": "5.
|
|
86
|
+
"tsx": "4.19.1",
|
|
87
|
+
"typescript": "5.6.2",
|
|
88
88
|
"webpack": "5.94.0",
|
|
89
89
|
"@wise/dynamic-flow-fixtures": "0.0.1",
|
|
90
90
|
"@wise/dynamic-flow-renderers": "0.0.0"
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
"nanoid": "5.0.7",
|
|
105
105
|
"react-webcam": "^7.2.0",
|
|
106
106
|
"screenfull": "^5.2.0",
|
|
107
|
-
"@wise/dynamic-flow-types": "2.22.
|
|
107
|
+
"@wise/dynamic-flow-types": "2.22.4"
|
|
108
108
|
},
|
|
109
109
|
"scripts": {
|
|
110
110
|
"dev": "pnpm build:visual-tests && storybook dev -p 3003",
|