@wise/dynamic-flow-client 4.10.0 → 4.11.0-experimental-1c8f72d
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.css +1 -1
- package/build/main.js +12 -0
- package/build/main.mjs +12 -0
- package/build/types/revamp/domain/types.d.ts +3 -4
- package/build/types/revamp/types.d.ts +1 -0
- package/package.json +7 -7
package/build/main.css
CHANGED
package/build/main.js
CHANGED
|
@@ -2148,6 +2148,7 @@ var getCallToAction = ({ title, accessibilityDescription }, behavior, onBehavior
|
|
|
2148
2148
|
switch (behavior.type) {
|
|
2149
2149
|
case "action":
|
|
2150
2150
|
case "modal":
|
|
2151
|
+
case "copy":
|
|
2151
2152
|
case "dismiss": {
|
|
2152
2153
|
return {
|
|
2153
2154
|
type: behavior.type,
|
|
@@ -6558,6 +6559,7 @@ function useDynamicFlowCore(props) {
|
|
|
6558
6559
|
const _a = props, { flowId, initialAction, initialStep, displayStepTitle = true } = _a, rest = __objRest(_a, ["flowId", "initialAction", "initialStep", "displayStepTitle"]);
|
|
6559
6560
|
const httpClient = useStableCallback(rest.httpClient);
|
|
6560
6561
|
const onCompletion = useStableCallback(rest.onCompletion);
|
|
6562
|
+
const onCopy = useStableCallback(props.onCopy);
|
|
6561
6563
|
const onValueChange = useStableCallback(props.onValueChange);
|
|
6562
6564
|
const onLink = useStableCallback(props.onLink);
|
|
6563
6565
|
const onError = useStableCallback(rest.onError);
|
|
@@ -6678,6 +6680,7 @@ function useDynamicFlowCore(props) {
|
|
|
6678
6680
|
const onBehavior = (0, import_react3.useCallback)(async (behavior) => {
|
|
6679
6681
|
switch (behavior.type) {
|
|
6680
6682
|
case "action": {
|
|
6683
|
+
rootComponentRef.current.setLoadingState("submitting");
|
|
6681
6684
|
rootComponentRef.current.dismissAllModals();
|
|
6682
6685
|
try {
|
|
6683
6686
|
const { action } = behavior;
|
|
@@ -6686,11 +6689,18 @@ function useDynamicFlowCore(props) {
|
|
|
6686
6689
|
const canSubmit = skipValidation || rootComponentRef.current.validate();
|
|
6687
6690
|
if (canSubmit) {
|
|
6688
6691
|
void onAction(action, model);
|
|
6692
|
+
} else {
|
|
6693
|
+
rootComponentRef.current.setLoadingState("idle");
|
|
6689
6694
|
}
|
|
6690
6695
|
} catch (e) {
|
|
6696
|
+
rootComponentRef.current.setLoadingState("idle");
|
|
6691
6697
|
}
|
|
6692
6698
|
break;
|
|
6693
6699
|
}
|
|
6700
|
+
case "copy": {
|
|
6701
|
+
navigator.clipboard.writeText(behavior.content).then(() => onCopy(behavior.content)).catch(() => onCopy(null));
|
|
6702
|
+
break;
|
|
6703
|
+
}
|
|
6694
6704
|
case "non-merging-action": {
|
|
6695
6705
|
rootComponentRef.current.dismissAllModals();
|
|
6696
6706
|
const { action } = behavior;
|
|
@@ -6743,6 +6753,7 @@ function useDynamicFlowCore(props) {
|
|
|
6743
6753
|
});
|
|
6744
6754
|
switch (command.type) {
|
|
6745
6755
|
case "complete": {
|
|
6756
|
+
rootComponentRef.current.setLoadingState("idle");
|
|
6746
6757
|
onCompletion(command.result);
|
|
6747
6758
|
rootComponentRef.current.stop();
|
|
6748
6759
|
trackCoreEvent("Succeeded");
|
|
@@ -6755,6 +6766,7 @@ function useDynamicFlowCore(props) {
|
|
|
6755
6766
|
break;
|
|
6756
6767
|
}
|
|
6757
6768
|
case "error": {
|
|
6769
|
+
rootComponentRef.current.setLoadingState("idle");
|
|
6758
6770
|
const genericErrorMessage = getErrorMessageFunctions().genericErrorWithRetry();
|
|
6759
6771
|
const errors = (_b = (_a2 = command.body) == null ? void 0 : _a2.errors) != null ? _b : { error: genericErrorMessage };
|
|
6760
6772
|
if (stepRef.current) {
|
package/build/main.mjs
CHANGED
|
@@ -2105,6 +2105,7 @@ var getCallToAction = ({ title, accessibilityDescription }, behavior, onBehavior
|
|
|
2105
2105
|
switch (behavior.type) {
|
|
2106
2106
|
case "action":
|
|
2107
2107
|
case "modal":
|
|
2108
|
+
case "copy":
|
|
2108
2109
|
case "dismiss": {
|
|
2109
2110
|
return {
|
|
2110
2111
|
type: behavior.type,
|
|
@@ -6515,6 +6516,7 @@ function useDynamicFlowCore(props) {
|
|
|
6515
6516
|
const _a = props, { flowId, initialAction, initialStep, displayStepTitle = true } = _a, rest = __objRest(_a, ["flowId", "initialAction", "initialStep", "displayStepTitle"]);
|
|
6516
6517
|
const httpClient = useStableCallback(rest.httpClient);
|
|
6517
6518
|
const onCompletion = useStableCallback(rest.onCompletion);
|
|
6519
|
+
const onCopy = useStableCallback(props.onCopy);
|
|
6518
6520
|
const onValueChange = useStableCallback(props.onValueChange);
|
|
6519
6521
|
const onLink = useStableCallback(props.onLink);
|
|
6520
6522
|
const onError = useStableCallback(rest.onError);
|
|
@@ -6635,6 +6637,7 @@ function useDynamicFlowCore(props) {
|
|
|
6635
6637
|
const onBehavior = useCallback2(async (behavior) => {
|
|
6636
6638
|
switch (behavior.type) {
|
|
6637
6639
|
case "action": {
|
|
6640
|
+
rootComponentRef.current.setLoadingState("submitting");
|
|
6638
6641
|
rootComponentRef.current.dismissAllModals();
|
|
6639
6642
|
try {
|
|
6640
6643
|
const { action } = behavior;
|
|
@@ -6643,11 +6646,18 @@ function useDynamicFlowCore(props) {
|
|
|
6643
6646
|
const canSubmit = skipValidation || rootComponentRef.current.validate();
|
|
6644
6647
|
if (canSubmit) {
|
|
6645
6648
|
void onAction(action, model);
|
|
6649
|
+
} else {
|
|
6650
|
+
rootComponentRef.current.setLoadingState("idle");
|
|
6646
6651
|
}
|
|
6647
6652
|
} catch (e) {
|
|
6653
|
+
rootComponentRef.current.setLoadingState("idle");
|
|
6648
6654
|
}
|
|
6649
6655
|
break;
|
|
6650
6656
|
}
|
|
6657
|
+
case "copy": {
|
|
6658
|
+
navigator.clipboard.writeText(behavior.content).then(() => onCopy(behavior.content)).catch(() => onCopy(null));
|
|
6659
|
+
break;
|
|
6660
|
+
}
|
|
6651
6661
|
case "non-merging-action": {
|
|
6652
6662
|
rootComponentRef.current.dismissAllModals();
|
|
6653
6663
|
const { action } = behavior;
|
|
@@ -6700,6 +6710,7 @@ function useDynamicFlowCore(props) {
|
|
|
6700
6710
|
});
|
|
6701
6711
|
switch (command.type) {
|
|
6702
6712
|
case "complete": {
|
|
6713
|
+
rootComponentRef.current.setLoadingState("idle");
|
|
6703
6714
|
onCompletion(command.result);
|
|
6704
6715
|
rootComponentRef.current.stop();
|
|
6705
6716
|
trackCoreEvent("Succeeded");
|
|
@@ -6712,6 +6723,7 @@ function useDynamicFlowCore(props) {
|
|
|
6712
6723
|
break;
|
|
6713
6724
|
}
|
|
6714
6725
|
case "error": {
|
|
6726
|
+
rootComponentRef.current.setLoadingState("idle");
|
|
6715
6727
|
const genericErrorMessage = getErrorMessageFunctions().genericErrorWithRetry();
|
|
6716
6728
|
const errors = (_b = (_a2 = command.body) == null ? void 0 : _a2.errors) != null ? _b : { error: genericErrorMessage };
|
|
6717
6729
|
if (stepRef.current) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ActionBehavior, CopyBehavior, DismissBehavior, Icon, JsonElement, LinkBehavior, Margin, ModalBehavior, Model } from '@wise/dynamic-flow-types/build/next';
|
|
2
2
|
import type { AlertComponent } from './components/AlertComponent';
|
|
3
3
|
import type { AllOfComponent } from './components/AllOfComponent';
|
|
4
4
|
import type { BooleanInputComponent } from './components/BooleanInputComponent';
|
|
@@ -53,7 +53,7 @@ export interface LocalValueObject extends Record<string, LocalValuePrimitive | L
|
|
|
53
53
|
export interface LocalValueArray extends Array<LocalValuePrimitive | LocalValueObject | LocalValueArray> {
|
|
54
54
|
}
|
|
55
55
|
export type CallToAction = {
|
|
56
|
-
type: 'action' | 'modal' | 'dismiss';
|
|
56
|
+
type: 'action' | 'modal' | 'dismiss' | 'copy';
|
|
57
57
|
title: string;
|
|
58
58
|
accessibilityDescription?: string;
|
|
59
59
|
onClick: () => void;
|
|
@@ -64,7 +64,7 @@ export type CallToAction = {
|
|
|
64
64
|
href: string;
|
|
65
65
|
onClick: () => void;
|
|
66
66
|
};
|
|
67
|
-
export type Behavior = (ActionBehavior |
|
|
67
|
+
export type Behavior = (ActionBehavior | CopyBehavior | DismissBehavior | LinkBehavior | ModalBehavior | NonMergingActionBehaviour | NullAction | RefreshBehavior) & {
|
|
68
68
|
analytics?: Record<string, unknown>;
|
|
69
69
|
};
|
|
70
70
|
type NonMergingActionBehaviour = Omit<ActionBehavior, 'type'> & {
|
|
@@ -127,7 +127,6 @@ export type BaseInputComponent<LV extends LocalValue> = BaseSchemaComponent<LV>
|
|
|
127
127
|
};
|
|
128
128
|
export type UpdateComponent = () => void;
|
|
129
129
|
export type OnBehavior = (behavior: Behavior) => Promise<void>;
|
|
130
|
-
export type OnAction = (action: Action) => Promise<void>;
|
|
131
130
|
export type OnPoll = (url: string, errorBehavior: Behavior, signal: AbortSignal) => Promise<boolean>;
|
|
132
131
|
export type OnLink = (url: string) => boolean;
|
|
133
132
|
export type OnValueChange = () => void;
|
|
@@ -7,6 +7,7 @@ type DynamicFlowCorePropsBasic = {
|
|
|
7
7
|
httpClient: HttpClient;
|
|
8
8
|
renderers: Renderers;
|
|
9
9
|
onCompletion: (result: Model) => void;
|
|
10
|
+
onCopy?: (copiedString: string | null) => void;
|
|
10
11
|
onError: (error: unknown, status?: number) => void;
|
|
11
12
|
onEvent?: AnalyticsEventHandler;
|
|
12
13
|
onLog?: LoggingEventHandler;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wise/dynamic-flow-client",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.11.0-experimental-1c8f72d",
|
|
4
4
|
"description": "Dynamic Flow web client",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "./build/main.js",
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"@storybook/addon-docs": "^9.0.18",
|
|
43
43
|
"@storybook/addon-links": "^9.0.18",
|
|
44
44
|
"@storybook/react-vite": "9.0.18",
|
|
45
|
-
"@testing-library/dom": "10.4.
|
|
46
|
-
"@testing-library/jest-dom": "6.6.
|
|
45
|
+
"@testing-library/dom": "10.4.1",
|
|
46
|
+
"@testing-library/jest-dom": "6.6.4",
|
|
47
47
|
"@testing-library/react": "16.3.0",
|
|
48
48
|
"@testing-library/user-event": "14.6.1",
|
|
49
49
|
"@transferwise/components": "46.100.1",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"jest-environment-jsdom": "30.0.5",
|
|
65
65
|
"jest-fetch-mock": "^3.0.3",
|
|
66
66
|
"jest-watch-typeahead": "^3.0.1",
|
|
67
|
-
"npm-run-all2": "
|
|
67
|
+
"npm-run-all2": "8.0.4",
|
|
68
68
|
"postcss": "^8.5.6",
|
|
69
69
|
"postcss-cli": "^11.0.1",
|
|
70
70
|
"postcss-import": "^16.1.1",
|
|
@@ -78,8 +78,8 @@
|
|
|
78
78
|
"stylelint-value-no-unknown-custom-properties": "6.0.1",
|
|
79
79
|
"tsx": "4.20.3",
|
|
80
80
|
"typescript": "5.8.3",
|
|
81
|
-
"@wise/dynamic-flow-
|
|
82
|
-
"@wise/dynamic-flow-
|
|
81
|
+
"@wise/dynamic-flow-fixtures": "0.0.1",
|
|
82
|
+
"@wise/dynamic-flow-renderers": "0.0.0"
|
|
83
83
|
},
|
|
84
84
|
"peerDependencies": {
|
|
85
85
|
"@transferwise/components": "^46.92.0",
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
"classnames": "2.5.1",
|
|
96
96
|
"react-webcam": "^7.2.0",
|
|
97
97
|
"screenfull": "^5.2.0",
|
|
98
|
-
"@wise/dynamic-flow-types": "3.
|
|
98
|
+
"@wise/dynamic-flow-types": "3.9.0-experimental-1c8f72d"
|
|
99
99
|
},
|
|
100
100
|
"scripts": {
|
|
101
101
|
"dev": "pnpm build:visual-tests && storybook dev -p 3003",
|