@wise/dynamic-flow-client-internal 5.31.0-experimental-a2135d6 → 5.31.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/dynamicFlow/DynamicFlow.js +11 -0
- package/build/dynamicFlow/DynamicFlowModal.js +21 -0
- package/build/dynamicFlow/DynamicFlowWiseProps.js +1 -0
- package/build/dynamicFlow/DynamicFlowWithRef.js +19 -0
- package/build/dynamicFlow/context-menu/useContextMenu.js +33 -0
- package/build/dynamicFlow/context-menu/useDFContextMenu.js +135 -0
- package/build/dynamicFlow/context-menu/useDFContextMenu.test.js +101 -0
- package/build/dynamicFlow/getMergedRenderers.js +36 -0
- package/build/dynamicFlow/messages.js +13 -0
- package/build/dynamicFlow/renderers.js +10 -0
- package/build/dynamicFlow/telemetry/app-version.js +4 -0
- package/build/dynamicFlow/telemetry/dispatchAnalyticsEvent.js +8 -0
- package/build/dynamicFlow/telemetry/getLogEvent.js +22 -0
- package/build/dynamicFlow/telemetry/getTrackEvent.js +39 -0
- package/build/dynamicFlow/telemetry/index.js +2 -0
- package/build/dynamicFlow/useCreateSnackBar.js +9 -0
- package/build/dynamicFlow/useOnCopy.js +16 -0
- package/build/dynamicFlow/useWiseHttpClient.js +24 -0
- package/build/dynamicFlow/useWiseToCoreProps.js +42 -0
- package/build/i18n/en.json +0 -2
- package/build/i18n/index.js +43 -0
- package/build/index.js +6 -0
- package/build/main.js +67 -296
- package/build/main.mjs +56 -286
- package/build/stories/ButtonLoader.story.js +109 -0
- package/build/stories/ContainerQueries.story.js +74 -0
- package/build/stories/DynamicFlow.story.js +37 -0
- package/build/stories/DynamicFlowWithRef.story.js +72 -0
- package/build/stories/Editable.story.js +58 -0
- package/build/stories/Initialisation.story.js +33 -0
- package/build/stories/PinnedButtons.story.js +94 -0
- package/build/stories/SCAIntegration.story.js +67 -0
- package/build/stories/utils/fixtureHttpClient.js +59 -0
- package/build/test-utils/NeptuneProviders.js +11 -0
- package/build/test-utils/index.js +4 -0
- package/build/test-utils/respond-with.js +6 -0
- package/build/test-utils/rtl-utils.js +7 -0
- package/build/test-utils/wait.js +3 -0
- package/build/tests/DynamicFlow.test.js +177 -0
- package/build/tests/HideStepTitle.test.js +58 -0
- package/build/tests/RequestCache.test.js +34 -0
- package/build/tests/SCARejectionHandling.test.js +71 -0
- package/build/tests/Subflow.Wise.test.js +650 -0
- package/build/tests/events.test.js +124 -0
- package/build/tests/logging.test.js +12 -0
- package/build/tests/onNotification.test.js +96 -0
- package/build/tests/renderers/ControlAndTags.test.js +225 -0
- package/build/tests/renderers/ImageRenderer.test.js +129 -0
- package/build/tests/renderers/RadioInputRendererComponent.test.js +89 -0
- package/build/tests/renderers/ReviewRenderer.test.js +41 -0
- package/build/tests/renderers/TextInputRenderer.test.js +44 -0
- package/build/tests/renderers/TimeZoneHeader.test.js +19 -0
- package/build/tests/renderers/UploadInputRenderer.maxSize.test.js +22 -0
- package/build/tests/renderers/value-utils.test.js +24 -0
- package/build/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +4 -4
package/build/main.mjs
CHANGED
|
@@ -127,7 +127,7 @@ import { useDynamicFlow } from "@wise/dynamic-flow-client";
|
|
|
127
127
|
// src/dynamicFlow/telemetry/app-version.ts
|
|
128
128
|
var appVersion = (
|
|
129
129
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
130
|
-
typeof process !== "undefined" ? "5.
|
|
130
|
+
typeof process !== "undefined" ? "5.31.0" : "0.0.0"
|
|
131
131
|
);
|
|
132
132
|
|
|
133
133
|
// src/dynamicFlow/context-menu/useContextMenu.tsx
|
|
@@ -6768,108 +6768,15 @@ function ChipsTabsRendererComponent({ margin, tabs, control, tags }) {
|
|
|
6768
6768
|
|
|
6769
6769
|
// ../renderers/src/TextInputRenderer.tsx
|
|
6770
6770
|
import { InputGroup as InputGroup5 } from "@transferwise/components";
|
|
6771
|
-
import { useState as useState21 } from "react";
|
|
6772
6771
|
|
|
6773
6772
|
// ../renderers/src/components/VariableTextInput.tsx
|
|
6774
6773
|
import {
|
|
6775
|
-
IconButton as IconButton4,
|
|
6776
6774
|
Input as Input6,
|
|
6777
6775
|
InputWithDisplayFormat,
|
|
6778
6776
|
PhoneNumberInput,
|
|
6779
6777
|
TextArea,
|
|
6780
6778
|
TextareaWithDisplayFormat
|
|
6781
6779
|
} from "@transferwise/components";
|
|
6782
|
-
import { Eye, EyeShut } from "@transferwise/icons";
|
|
6783
|
-
import { useIntl as useIntl21 } from "react-intl";
|
|
6784
|
-
import { useLayoutEffect as useLayoutEffect3, useRef as useRef5, useState as useState20 } from "react";
|
|
6785
|
-
|
|
6786
|
-
// ../renderers/src/messages/ssn-input.messages.ts
|
|
6787
|
-
import { defineMessages as defineMessages15 } from "react-intl";
|
|
6788
|
-
var ssn_input_messages_default = defineMessages15({
|
|
6789
|
-
showValue: {
|
|
6790
|
-
id: "df.wise.ssnInput.showValue",
|
|
6791
|
-
defaultMessage: "Show value",
|
|
6792
|
-
description: "Accessible label for showing a masked SSN or SIN value"
|
|
6793
|
-
},
|
|
6794
|
-
hideValue: {
|
|
6795
|
-
id: "df.wise.ssnInput.hideValue",
|
|
6796
|
-
defaultMessage: "Hide value",
|
|
6797
|
-
description: "Accessible label for hiding an SSN or SIN value"
|
|
6798
|
-
}
|
|
6799
|
-
});
|
|
6800
|
-
|
|
6801
|
-
// ../renderers/src/components/ssnInputUtils.ts
|
|
6802
|
-
function formatSsnValue(rawValue, displayFormat, isVisible) {
|
|
6803
|
-
if (!displayFormat) {
|
|
6804
|
-
return isVisible ? rawValue : "\u2022".repeat(rawValue.length);
|
|
6805
|
-
}
|
|
6806
|
-
const formattedValue = displayFormat.split("").reduce(
|
|
6807
|
-
({ display, digitsUsed }, character) => {
|
|
6808
|
-
if (character === "*") {
|
|
6809
|
-
return digitsUsed < rawValue.length ? {
|
|
6810
|
-
display: `${display}${isVisible ? rawValue[digitsUsed] : "\u2022"}`,
|
|
6811
|
-
digitsUsed: digitsUsed + 1
|
|
6812
|
-
} : { display, digitsUsed };
|
|
6813
|
-
}
|
|
6814
|
-
return digitsUsed > 0 && digitsUsed < rawValue.length ? { display: `${display}${character}`, digitsUsed } : { display, digitsUsed };
|
|
6815
|
-
},
|
|
6816
|
-
{ display: "", digitsUsed: 0 }
|
|
6817
|
-
).display;
|
|
6818
|
-
const displayFormatDigitCount = displayFormat.split("").filter((character) => character === "*").length;
|
|
6819
|
-
const extraValue = rawValue.slice(displayFormatDigitCount);
|
|
6820
|
-
return `${formattedValue}${isVisible ? extraValue : "\u2022".repeat(extraValue.length)}`;
|
|
6821
|
-
}
|
|
6822
|
-
function getRawOffset(displayValue, displayOffset, rawValueLength) {
|
|
6823
|
-
return Math.min(
|
|
6824
|
-
displayValue.slice(0, displayOffset).split("").filter((character) => character === "\u2022" || /\d/.test(character)).length,
|
|
6825
|
-
rawValueLength
|
|
6826
|
-
);
|
|
6827
|
-
}
|
|
6828
|
-
function replaceSsnSelection(rawValue, displayValue, insertedValue, start, end) {
|
|
6829
|
-
const startOffset = getRawOffset(displayValue, start, rawValue.length);
|
|
6830
|
-
const endOffset = getRawOffset(displayValue, end, rawValue.length);
|
|
6831
|
-
if (!insertedValue) {
|
|
6832
|
-
return void 0;
|
|
6833
|
-
}
|
|
6834
|
-
return {
|
|
6835
|
-
value: `${rawValue.slice(0, startOffset)}${insertedValue}${rawValue.slice(endOffset)}`,
|
|
6836
|
-
caret: startOffset + insertedValue.length
|
|
6837
|
-
};
|
|
6838
|
-
}
|
|
6839
|
-
function deleteSsnSelection(rawValue, displayValue, start, end, backward) {
|
|
6840
|
-
let startOffset = getRawOffset(displayValue, start, rawValue.length);
|
|
6841
|
-
let endOffset = getRawOffset(displayValue, end, rawValue.length);
|
|
6842
|
-
if (startOffset === endOffset) {
|
|
6843
|
-
if (backward) {
|
|
6844
|
-
startOffset = Math.max(0, startOffset - 1);
|
|
6845
|
-
} else {
|
|
6846
|
-
endOffset = Math.min(rawValue.length, endOffset + 1);
|
|
6847
|
-
}
|
|
6848
|
-
}
|
|
6849
|
-
return {
|
|
6850
|
-
value: `${rawValue.slice(0, startOffset)}${rawValue.slice(endOffset)}`,
|
|
6851
|
-
caret: startOffset
|
|
6852
|
-
};
|
|
6853
|
-
}
|
|
6854
|
-
function getDisplayOffset(displayValue, rawOffset) {
|
|
6855
|
-
if (rawOffset === 0) {
|
|
6856
|
-
return 0;
|
|
6857
|
-
}
|
|
6858
|
-
let displayOffset = 0;
|
|
6859
|
-
let digitsSeen = 0;
|
|
6860
|
-
for (const character of displayValue) {
|
|
6861
|
-
if (character === "\u2022" || /\d/.test(character)) {
|
|
6862
|
-
digitsSeen += 1;
|
|
6863
|
-
if (digitsSeen === rawOffset) {
|
|
6864
|
-
return displayOffset + 1;
|
|
6865
|
-
}
|
|
6866
|
-
}
|
|
6867
|
-
displayOffset += 1;
|
|
6868
|
-
}
|
|
6869
|
-
return displayOffset;
|
|
6870
|
-
}
|
|
6871
|
-
|
|
6872
|
-
// ../renderers/src/components/VariableTextInput.tsx
|
|
6873
6780
|
import { jsx as jsx100 } from "react/jsx-runtime";
|
|
6874
6781
|
var commonKeys = [
|
|
6875
6782
|
"autoComplete",
|
|
@@ -6885,15 +6792,13 @@ var commonKeys = [
|
|
|
6885
6792
|
"value"
|
|
6886
6793
|
];
|
|
6887
6794
|
function VariableTextInput(inputProps) {
|
|
6888
|
-
const { id, value, control, onChange
|
|
6795
|
+
const { id, value, control, onChange } = inputProps;
|
|
6889
6796
|
const commonProps = __spreadProps(__spreadValues({}, pick(inputProps, ...commonKeys)), { name: id });
|
|
6890
6797
|
switch (control) {
|
|
6891
6798
|
case "email":
|
|
6892
6799
|
return /* @__PURE__ */ jsx100(TextInput, __spreadProps(__spreadValues({}, commonProps), { type: "email", onChange }));
|
|
6893
6800
|
case "password":
|
|
6894
6801
|
return /* @__PURE__ */ jsx100(TextInput, __spreadProps(__spreadValues({}, commonProps), { type: "password", onChange }));
|
|
6895
|
-
case "ssn-input":
|
|
6896
|
-
return /* @__PURE__ */ jsx100(SsnInput, __spreadProps(__spreadValues({}, commonProps), { isVisible: isSsnVisible, onChange }));
|
|
6897
6802
|
case "numeric": {
|
|
6898
6803
|
const numericProps = __spreadProps(__spreadValues({}, commonProps), { type: "number", onWheel });
|
|
6899
6804
|
return /* @__PURE__ */ jsx100(
|
|
@@ -6913,198 +6818,65 @@ function VariableTextInput(inputProps) {
|
|
|
6913
6818
|
}
|
|
6914
6819
|
}
|
|
6915
6820
|
}
|
|
6916
|
-
function SsnInputToggle({
|
|
6917
|
-
isVisible,
|
|
6918
|
-
onClick
|
|
6919
|
-
}) {
|
|
6920
|
-
const { formatMessage } = useIntl21();
|
|
6921
|
-
return /* @__PURE__ */ jsx100(
|
|
6922
|
-
IconButton4,
|
|
6923
|
-
{
|
|
6924
|
-
priority: "minimal",
|
|
6925
|
-
size: 24,
|
|
6926
|
-
"aria-label": formatMessage(isVisible ? ssn_input_messages_default.hideValue : ssn_input_messages_default.showValue),
|
|
6927
|
-
"aria-pressed": isVisible,
|
|
6928
|
-
onClick,
|
|
6929
|
-
children: isVisible ? /* @__PURE__ */ jsx100(EyeShut, { size: 24 }) : /* @__PURE__ */ jsx100(Eye, { size: 24 })
|
|
6930
|
-
}
|
|
6931
|
-
);
|
|
6932
|
-
}
|
|
6933
6821
|
function TextInput(props) {
|
|
6934
|
-
const _a = props, { control, displayFormat, onChange
|
|
6822
|
+
const _a = props, { control, displayFormat, onChange } = _a, commonProps = __objRest(_a, ["control", "displayFormat", "onChange"]);
|
|
6935
6823
|
const InputWithPattern = control === "textarea" ? TextareaWithDisplayFormat : InputWithDisplayFormat;
|
|
6936
6824
|
const InputWithoutPattern = control === "textarea" ? TextArea : Input6;
|
|
6937
|
-
return displayFormat ? /* @__PURE__ */ jsx100(InputWithPattern, __spreadProps(__spreadValues({ displayPattern: displayFormat }, commonProps), { onChange })) : /* @__PURE__ */ jsx100(InputWithoutPattern, __spreadProps(__spreadValues({}, commonProps), {
|
|
6938
|
-
}
|
|
6939
|
-
function SsnInput(props) {
|
|
6940
|
-
const _a = props, { displayFormat = "", isVisible = false, onChange, value = "" } = _a, commonProps = __objRest(_a, ["displayFormat", "isVisible", "onChange", "value"]);
|
|
6941
|
-
const [editVersion, setEditVersion] = useState20(0);
|
|
6942
|
-
const inputRef = useRef5(null);
|
|
6943
|
-
const selection = useRef5({ start: 0, end: 0 });
|
|
6944
|
-
const pendingCaret = useRef5(null);
|
|
6945
|
-
const rawValue = value.replace(/\D/g, "");
|
|
6946
|
-
const formattedValue = formatSsnValue(rawValue, displayFormat, isVisible);
|
|
6947
|
-
const scheduleCaret = (rawOffset) => {
|
|
6948
|
-
pendingCaret.current = rawOffset;
|
|
6949
|
-
setEditVersion((version) => version + 1);
|
|
6950
|
-
};
|
|
6951
|
-
const replaceSelection = (insertedValue, start, end) => {
|
|
6952
|
-
const result = replaceSsnSelection(rawValue, formattedValue, insertedValue, start, end);
|
|
6953
|
-
if (!result) {
|
|
6954
|
-
return;
|
|
6955
|
-
}
|
|
6956
|
-
scheduleCaret(result.caret);
|
|
6957
|
-
onChange(result.value);
|
|
6958
|
-
};
|
|
6959
|
-
const deleteSelection = (start, end, backward) => {
|
|
6960
|
-
const result = deleteSsnSelection(rawValue, formattedValue, start, end, backward);
|
|
6961
|
-
scheduleCaret(result.caret);
|
|
6962
|
-
onChange(result.value);
|
|
6963
|
-
};
|
|
6964
|
-
useLayoutEffect3(() => {
|
|
6965
|
-
if (pendingCaret.current === null || !inputRef.current) {
|
|
6966
|
-
return;
|
|
6967
|
-
}
|
|
6968
|
-
inputRef.current.setSelectionRange(
|
|
6969
|
-
getDisplayOffset(formattedValue, pendingCaret.current),
|
|
6970
|
-
getDisplayOffset(formattedValue, pendingCaret.current)
|
|
6971
|
-
);
|
|
6972
|
-
pendingCaret.current = null;
|
|
6973
|
-
}, [editVersion, formattedValue, rawValue]);
|
|
6974
|
-
return /* @__PURE__ */ jsx100(
|
|
6975
|
-
"input",
|
|
6976
|
-
__spreadProps(__spreadValues({
|
|
6977
|
-
ref: inputRef
|
|
6978
|
-
}, commonProps), {
|
|
6979
|
-
className: "form-control np-form-control np-input np-input--shape-rectangle",
|
|
6980
|
-
type: "text",
|
|
6981
|
-
inputMode: "numeric",
|
|
6982
|
-
value: formattedValue,
|
|
6983
|
-
onChange: (event) => {
|
|
6984
|
-
const nextValue = event.currentTarget.value;
|
|
6985
|
-
const inputType = event.nativeEvent.inputType;
|
|
6986
|
-
const start = selection.current.start;
|
|
6987
|
-
const end = selection.current.end;
|
|
6988
|
-
if (isVisible || /^\d+$/.test(nextValue)) {
|
|
6989
|
-
const nextRawValue = nextValue.replace(/\D/g, "");
|
|
6990
|
-
scheduleCaret(nextRawValue.length);
|
|
6991
|
-
onChange(nextRawValue);
|
|
6992
|
-
} else if ((inputType == null ? void 0 : inputType.startsWith("delete")) || nextValue.length < formattedValue.length) {
|
|
6993
|
-
deleteSelection(start, end, inputType === "deleteContentBackward");
|
|
6994
|
-
} else {
|
|
6995
|
-
replaceSelection(nextValue.replace(/\D/g, ""), start, end);
|
|
6996
|
-
}
|
|
6997
|
-
},
|
|
6998
|
-
onSelect: (event) => {
|
|
6999
|
-
var _a2, _b;
|
|
7000
|
-
selection.current = {
|
|
7001
|
-
start: (_a2 = event.currentTarget.selectionStart) != null ? _a2 : 0,
|
|
7002
|
-
end: (_b = event.currentTarget.selectionEnd) != null ? _b : 0
|
|
7003
|
-
};
|
|
7004
|
-
},
|
|
7005
|
-
onKeyDown: (event) => {
|
|
7006
|
-
var _a2, _b;
|
|
7007
|
-
selection.current = {
|
|
7008
|
-
start: (_a2 = event.currentTarget.selectionStart) != null ? _a2 : 0,
|
|
7009
|
-
end: (_b = event.currentTarget.selectionEnd) != null ? _b : 0
|
|
7010
|
-
};
|
|
7011
|
-
if (/^\d$/.test(event.key)) {
|
|
7012
|
-
event.preventDefault();
|
|
7013
|
-
replaceSelection(event.key, selection.current.start, selection.current.end);
|
|
7014
|
-
} else if (event.key === "Backspace") {
|
|
7015
|
-
event.preventDefault();
|
|
7016
|
-
deleteSelection(selection.current.start, selection.current.end, true);
|
|
7017
|
-
} else if (event.key === "Delete") {
|
|
7018
|
-
event.preventDefault();
|
|
7019
|
-
deleteSelection(selection.current.start, selection.current.end, false);
|
|
7020
|
-
}
|
|
7021
|
-
},
|
|
7022
|
-
onPaste: (event) => {
|
|
7023
|
-
var _a2, _b;
|
|
7024
|
-
event.preventDefault();
|
|
7025
|
-
selection.current = {
|
|
7026
|
-
start: (_a2 = event.currentTarget.selectionStart) != null ? _a2 : 0,
|
|
7027
|
-
end: (_b = event.currentTarget.selectionEnd) != null ? _b : 0
|
|
7028
|
-
};
|
|
7029
|
-
const pastedValue = event.clipboardData.getData("text").replace(/\D/g, "");
|
|
7030
|
-
replaceSelection(pastedValue, selection.current.start, selection.current.end);
|
|
7031
|
-
}
|
|
7032
|
-
})
|
|
7033
|
-
);
|
|
6825
|
+
return displayFormat ? /* @__PURE__ */ jsx100(InputWithPattern, __spreadProps(__spreadValues({ displayPattern: displayFormat }, commonProps), { onChange })) : /* @__PURE__ */ jsx100(InputWithoutPattern, __spreadProps(__spreadValues({}, commonProps), { onChange: (e) => onChange(e.target.value) }));
|
|
7034
6826
|
}
|
|
7035
6827
|
|
|
7036
6828
|
// ../renderers/src/TextInputRenderer.tsx
|
|
7037
6829
|
import { jsx as jsx101 } from "react/jsx-runtime";
|
|
7038
6830
|
var TextInputRenderer = {
|
|
7039
6831
|
canRenderType: "input-text",
|
|
7040
|
-
render: (props) =>
|
|
7041
|
-
|
|
7042
|
-
function TextInputRendererComponent(props) {
|
|
7043
|
-
const [isSsnVisible, setIsSsnVisible] = useState21(false);
|
|
7044
|
-
const _a = props, {
|
|
7045
|
-
id,
|
|
7046
|
-
title,
|
|
7047
|
-
description,
|
|
7048
|
-
help,
|
|
7049
|
-
media,
|
|
7050
|
-
validationState,
|
|
7051
|
-
value: initialValue,
|
|
7052
|
-
onChange
|
|
7053
|
-
} = _a, rest = __objRest(_a, [
|
|
7054
|
-
"id",
|
|
7055
|
-
"title",
|
|
7056
|
-
"description",
|
|
7057
|
-
"help",
|
|
7058
|
-
"media",
|
|
7059
|
-
"validationState",
|
|
7060
|
-
"value",
|
|
7061
|
-
"onChange"
|
|
7062
|
-
]);
|
|
7063
|
-
const value = initialValue != null ? initialValue : "";
|
|
7064
|
-
const isSsnInput = props.control === "ssn-input";
|
|
7065
|
-
const inputProps = __spreadProps(__spreadValues({}, rest), {
|
|
7066
|
-
value,
|
|
7067
|
-
id,
|
|
7068
|
-
isSsnVisible,
|
|
7069
|
-
onChange: (newValue) => {
|
|
7070
|
-
if ((value != null ? value : "") !== (newValue != null ? newValue : "")) {
|
|
7071
|
-
onChange(newValue);
|
|
7072
|
-
}
|
|
7073
|
-
}
|
|
7074
|
-
});
|
|
7075
|
-
return /* @__PURE__ */ jsx101(
|
|
7076
|
-
FieldInput_default,
|
|
7077
|
-
{
|
|
6832
|
+
render: (props) => {
|
|
6833
|
+
const _a = props, {
|
|
7078
6834
|
id,
|
|
7079
|
-
|
|
6835
|
+
title,
|
|
7080
6836
|
description,
|
|
7081
|
-
validation: validationState,
|
|
7082
|
-
inlineAlert: props.inlineAlert,
|
|
7083
|
-
loadingState: props.fieldLoadingState,
|
|
7084
6837
|
help,
|
|
7085
|
-
|
|
7086
|
-
|
|
7087
|
-
|
|
7088
|
-
|
|
7089
|
-
|
|
7090
|
-
|
|
7091
|
-
|
|
7092
|
-
|
|
7093
|
-
|
|
7094
|
-
|
|
7095
|
-
|
|
7096
|
-
|
|
7097
|
-
|
|
7098
|
-
|
|
7099
|
-
|
|
7100
|
-
|
|
7101
|
-
|
|
7102
|
-
|
|
6838
|
+
media,
|
|
6839
|
+
validationState,
|
|
6840
|
+
value: initialValue,
|
|
6841
|
+
onChange
|
|
6842
|
+
} = _a, rest = __objRest(_a, [
|
|
6843
|
+
"id",
|
|
6844
|
+
"title",
|
|
6845
|
+
"description",
|
|
6846
|
+
"help",
|
|
6847
|
+
"media",
|
|
6848
|
+
"validationState",
|
|
6849
|
+
"value",
|
|
6850
|
+
"onChange"
|
|
6851
|
+
]);
|
|
6852
|
+
const value = initialValue != null ? initialValue : "";
|
|
6853
|
+
const inputProps = __spreadProps(__spreadValues({}, rest), {
|
|
6854
|
+
value,
|
|
6855
|
+
id,
|
|
6856
|
+
onChange: (newValue) => {
|
|
6857
|
+
if ((value != null ? value : "") !== (newValue != null ? newValue : "")) {
|
|
6858
|
+
onChange(newValue);
|
|
7103
6859
|
}
|
|
7104
|
-
|
|
7105
|
-
}
|
|
7106
|
-
|
|
7107
|
-
|
|
6860
|
+
}
|
|
6861
|
+
});
|
|
6862
|
+
return /* @__PURE__ */ jsx101(
|
|
6863
|
+
FieldInput_default,
|
|
6864
|
+
{
|
|
6865
|
+
id,
|
|
6866
|
+
label: title,
|
|
6867
|
+
description,
|
|
6868
|
+
validation: validationState,
|
|
6869
|
+
inlineAlert: props.inlineAlert,
|
|
6870
|
+
loadingState: props.fieldLoadingState,
|
|
6871
|
+
help,
|
|
6872
|
+
features: props.features,
|
|
6873
|
+
control: props.control,
|
|
6874
|
+
tags: props.tags,
|
|
6875
|
+
children: /* @__PURE__ */ jsx101(InputGroup5, { addonStart: getInputGroupAddonStart(media), children: /* @__PURE__ */ jsx101(VariableTextInput, __spreadValues({}, inputProps)) })
|
|
6876
|
+
}
|
|
6877
|
+
);
|
|
6878
|
+
}
|
|
6879
|
+
};
|
|
7108
6880
|
var TextInputRenderer_default = TextInputRenderer;
|
|
7109
6881
|
|
|
7110
6882
|
// ../renderers/src/UpdatableRenderer.tsx
|
|
@@ -7262,7 +7034,7 @@ var LargeUploadRenderer = {
|
|
|
7262
7034
|
// ../renderers/src/UpsellRenderer.tsx
|
|
7263
7035
|
var import_classnames35 = __toESM(require_classnames());
|
|
7264
7036
|
import { Nudge } from "@transferwise/components";
|
|
7265
|
-
import { useState as
|
|
7037
|
+
import { useState as useState20 } from "react";
|
|
7266
7038
|
import { jsx as jsx104 } from "react/jsx-runtime";
|
|
7267
7039
|
var UpsellRenderer = {
|
|
7268
7040
|
canRenderType: "upsell",
|
|
@@ -7270,7 +7042,7 @@ var UpsellRenderer = {
|
|
|
7270
7042
|
};
|
|
7271
7043
|
function UpsellRendererComponent(props) {
|
|
7272
7044
|
const { text, callToAction, media, margin, onDismiss, control, tags } = props;
|
|
7273
|
-
const [isVisible, setIsVisible] =
|
|
7045
|
+
const [isVisible, setIsVisible] = useState20(true);
|
|
7274
7046
|
return isVisible ? /* @__PURE__ */ jsx104(
|
|
7275
7047
|
Nudge,
|
|
7276
7048
|
{
|
|
@@ -7500,11 +7272,11 @@ var customEventsToAnalytics = {
|
|
|
7500
7272
|
|
|
7501
7273
|
// src/dynamicFlow/useOnCopy.tsx
|
|
7502
7274
|
import { useCallback as useCallback2 } from "react";
|
|
7503
|
-
import { useIntl as
|
|
7275
|
+
import { useIntl as useIntl21 } from "react-intl";
|
|
7504
7276
|
|
|
7505
7277
|
// src/dynamicFlow/messages.ts
|
|
7506
|
-
import { defineMessages as
|
|
7507
|
-
var messages_default =
|
|
7278
|
+
import { defineMessages as defineMessages15 } from "react-intl";
|
|
7279
|
+
var messages_default = defineMessages15({
|
|
7508
7280
|
copied: {
|
|
7509
7281
|
id: "df.wise.CopyFeedback.copy",
|
|
7510
7282
|
defaultMessage: "Copied to clipboard",
|
|
@@ -7519,7 +7291,7 @@ var messages_default = defineMessages16({
|
|
|
7519
7291
|
|
|
7520
7292
|
// src/dynamicFlow/useOnCopy.tsx
|
|
7521
7293
|
var useOnCopy = () => {
|
|
7522
|
-
const { formatMessage } =
|
|
7294
|
+
const { formatMessage } = useIntl21();
|
|
7523
7295
|
const createSnackBar = useSnackBarIfAvailable();
|
|
7524
7296
|
return useCallback2(
|
|
7525
7297
|
(copiedContent) => {
|
|
@@ -7535,9 +7307,9 @@ var useOnCopy = () => {
|
|
|
7535
7307
|
|
|
7536
7308
|
// src/dynamicFlow/useWiseHttpClient.tsx
|
|
7537
7309
|
import { useCallback as useCallback3 } from "react";
|
|
7538
|
-
import { useIntl as
|
|
7310
|
+
import { useIntl as useIntl22 } from "react-intl";
|
|
7539
7311
|
var useWiseHttpClient = (httpClient) => {
|
|
7540
|
-
const { locale } =
|
|
7312
|
+
const { locale } = useIntl22();
|
|
7541
7313
|
return useCallback3(
|
|
7542
7314
|
async (input, init = {}) => {
|
|
7543
7315
|
const headers = new Headers(init.headers);
|
|
@@ -7813,8 +7585,6 @@ var en_default = {
|
|
|
7813
7585
|
"df.wise.group.currencies-with-account-details": "Currencies with account details",
|
|
7814
7586
|
"df.wise.group.popular": "Popular",
|
|
7815
7587
|
"df.wise.group.recent": "Recent",
|
|
7816
|
-
"df.wise.ssnInput.hideValue": "Hide value",
|
|
7817
|
-
"df.wise.ssnInput.showValue": "Show value",
|
|
7818
7588
|
"df.wise.step.scrollToBottom": "Scroll to bottom"
|
|
7819
7589
|
};
|
|
7820
7590
|
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { action } from 'storybook/actions';
|
|
3
|
+
import { DynamicFlow } from '../dynamicFlow/DynamicFlow';
|
|
4
|
+
import { fixtureHttpClient } from './utils/fixtureHttpClient';
|
|
5
|
+
export default {
|
|
6
|
+
title: 'Initialisation',
|
|
7
|
+
component: DynamicFlow,
|
|
8
|
+
};
|
|
9
|
+
const onCompletion = action('onCompletion');
|
|
10
|
+
const onError = action('onError');
|
|
11
|
+
const onEvent = action('onEvent');
|
|
12
|
+
const onLog = action('onLog');
|
|
13
|
+
export const ButtonLoader = {
|
|
14
|
+
render: () => (_jsx(DynamicFlow, { flowId: "initialisation-telemetry", customFetch: fixtureHttpClient, initialStep: step, onCompletion: onCompletion, onError: onError, onEvent: onEvent, onLog: onLog })),
|
|
15
|
+
};
|
|
16
|
+
const step = {
|
|
17
|
+
id: 'convert-review',
|
|
18
|
+
title: 'Does everything look right?',
|
|
19
|
+
schemas: [
|
|
20
|
+
{
|
|
21
|
+
properties: {
|
|
22
|
+
quoteId: {
|
|
23
|
+
const: '123',
|
|
24
|
+
},
|
|
25
|
+
profileId: {
|
|
26
|
+
const: 6666,
|
|
27
|
+
},
|
|
28
|
+
context: {
|
|
29
|
+
const: 'CONVERT',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
displayOrder: ['quoteId', 'profileId', 'context'],
|
|
33
|
+
required: ['quoteId', 'profileId', 'context'],
|
|
34
|
+
hidden: true,
|
|
35
|
+
type: 'object',
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
layout: [
|
|
39
|
+
{
|
|
40
|
+
components: [
|
|
41
|
+
{
|
|
42
|
+
fields: [
|
|
43
|
+
{
|
|
44
|
+
label: "You're converting",
|
|
45
|
+
value: '123 EUR',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
label: 'To',
|
|
49
|
+
value: '101.61 GBP',
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
label: 'Our fee',
|
|
53
|
+
value: '6.15 EUR',
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
label: 'Rate',
|
|
57
|
+
value: '1 EUR = 0.8696 GBP',
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
title: 'Conversion details',
|
|
61
|
+
callToAction: {
|
|
62
|
+
title: 'Edit',
|
|
63
|
+
behavior: {
|
|
64
|
+
action: {
|
|
65
|
+
exit: true,
|
|
66
|
+
result: {
|
|
67
|
+
action: 'EDIT',
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
type: 'action',
|
|
71
|
+
},
|
|
72
|
+
action: {
|
|
73
|
+
exit: true,
|
|
74
|
+
result: {
|
|
75
|
+
action: 'EDIT',
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
control: 'horizontal',
|
|
80
|
+
type: 'review',
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
title: 'Convert',
|
|
84
|
+
behavior: {
|
|
85
|
+
action: {
|
|
86
|
+
exit: true,
|
|
87
|
+
result: {
|
|
88
|
+
action: 'CONVERT',
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
type: 'action',
|
|
92
|
+
},
|
|
93
|
+
control: 'primary',
|
|
94
|
+
margin: 'xs',
|
|
95
|
+
type: 'button',
|
|
96
|
+
action: {
|
|
97
|
+
exit: true,
|
|
98
|
+
result: {
|
|
99
|
+
action: 'CONVERT',
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
control: 'bordered',
|
|
105
|
+
type: 'box',
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
refreshUrl: '/v1/convert/review?refresh=true',
|
|
109
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { action } from 'storybook/actions';
|
|
3
|
+
import { DynamicFlow } from '../dynamicFlow/DynamicFlow';
|
|
4
|
+
import { Fragment } from 'react/jsx-runtime';
|
|
5
|
+
export default {
|
|
6
|
+
component: ImageLayoutWithSize,
|
|
7
|
+
title: 'Dev Tools/Container Queries',
|
|
8
|
+
argTypes: {
|
|
9
|
+
width: {
|
|
10
|
+
options: ['100%', '900px', '600px', '575px', '400px'],
|
|
11
|
+
control: { type: 'select' },
|
|
12
|
+
description: 'Width of the div containing the DynamicFlow component',
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
args: {
|
|
16
|
+
width: '575px',
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
export function ImageLayoutWithSize({ width }) {
|
|
20
|
+
return _jsx(Fragment, { children: renderWithStep(imageLayoutStep, width) }, width);
|
|
21
|
+
}
|
|
22
|
+
function renderWithStep(step, width) {
|
|
23
|
+
const getDF = () => (_jsx(DynamicFlow, { flowId: "new-df-flow-id", className: "df-prefer-container-queries", customFetch: async (input, init) => {
|
|
24
|
+
action('httpClient')(input, init === null || init === void 0 ? void 0 : init.body);
|
|
25
|
+
return fetch(input, init);
|
|
26
|
+
}, initialStep: Object.assign(Object.assign({}, step), { title: `Dynamic Flow Step - ${width}`, description: `This is a DynamicFlow component inside a ${width}-wide <div> container. You can change the width in the Storybook controls.` }), onCompletion: action('onCompletion'), onEvent: action('onEvent'), onLog: action('onLog'), onError: (error) => {
|
|
27
|
+
action('onError');
|
|
28
|
+
console.error(error);
|
|
29
|
+
} }));
|
|
30
|
+
return (_jsxs("div", { className: "d-flex", children: [_jsx("div", { style: { flexGrow: 1, backgroundColor: '#EEE', textAlign: 'center' }, children: " NOT-DF " }), _jsx("div", { style: { width, backgroundColor: 'white' }, children: getDF() }), _jsx("div", { style: { flexGrow: 1, backgroundColor: '#EEE', textAlign: 'center' }, children: " NOT-DF " })] }));
|
|
31
|
+
}
|
|
32
|
+
const imageLayoutStep = {
|
|
33
|
+
id: 'step-id',
|
|
34
|
+
title: 'Dynamic Flow Step',
|
|
35
|
+
description: 'This is a step in the dynamic flow.',
|
|
36
|
+
schemas: [],
|
|
37
|
+
layout: [
|
|
38
|
+
{
|
|
39
|
+
type: 'image',
|
|
40
|
+
size: 'xs',
|
|
41
|
+
content: {
|
|
42
|
+
uri: 'https://placehold.co/600x600?text=Cat',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
type: 'image',
|
|
47
|
+
size: 'sm',
|
|
48
|
+
content: {
|
|
49
|
+
uri: 'https://placehold.co/600x600?text=Cat',
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
type: 'image',
|
|
54
|
+
size: 'md',
|
|
55
|
+
content: {
|
|
56
|
+
uri: 'https://placehold.co/600x600?text=Cat',
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
type: 'image',
|
|
61
|
+
size: 'lg',
|
|
62
|
+
content: {
|
|
63
|
+
uri: 'https://placehold.co/600x600?text=Cat',
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
type: 'image',
|
|
68
|
+
size: 'xl',
|
|
69
|
+
content: {
|
|
70
|
+
uri: 'https://placehold.co/600x600?text=Cat',
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { action } from 'storybook/actions';
|
|
3
|
+
import { layouts, schemas, misc, step } from '@wise/dynamic-flow-fixtures';
|
|
4
|
+
import { DynamicFlow } from '../index';
|
|
5
|
+
import { fixtureHttpClient } from './utils/fixtureHttpClient';
|
|
6
|
+
const fixtures = Object.assign(Object.assign(Object.assign(Object.assign({}, schemas), layouts), misc), step);
|
|
7
|
+
function DynamicFlowRenderer({ initialStepName = '', }) {
|
|
8
|
+
const selectedStep = fixtures[initialStepName] || {};
|
|
9
|
+
const parsedStep = typeof selectedStep === 'string' ? JSON.parse(selectedStep) : selectedStep;
|
|
10
|
+
const props = {
|
|
11
|
+
flowId: 'storybook',
|
|
12
|
+
customFetch: fixtureHttpClient,
|
|
13
|
+
onCompletion: action('onCompletion'),
|
|
14
|
+
onError: action('onError'),
|
|
15
|
+
onEvent: action('onEvent'),
|
|
16
|
+
onLog: action('onLog'),
|
|
17
|
+
};
|
|
18
|
+
return (_jsx(DynamicFlow, Object.assign({}, props, { initialAction: { method: 'GET', url: `/steps/${initialStepName}` } }), parsedStep.id));
|
|
19
|
+
}
|
|
20
|
+
const meta = {
|
|
21
|
+
title: 'Multi-fixture',
|
|
22
|
+
component: DynamicFlowRenderer,
|
|
23
|
+
};
|
|
24
|
+
export const AllFixtures = {
|
|
25
|
+
argTypes: {
|
|
26
|
+
initialStepName: {
|
|
27
|
+
label: 'Initial Step',
|
|
28
|
+
control: 'select',
|
|
29
|
+
options: Object.keys(fixtures),
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
args: { initialStepName: Object.keys(fixtures)[1], revampEnabled: false },
|
|
33
|
+
parameters: {
|
|
34
|
+
chromatic: { disableSnapshot: true },
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
export default meta;
|