@wise/dynamic-flow-client 1.1.0 → 1.2.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 +480 -438
- package/build/main.min.js +3 -3
- package/build/types/common/utils/step-utils.d.ts +1 -5
- package/build/types/dynamicFlow/utils/responseParsers/response-parsers.d.ts +1 -1
- package/build/types/dynamicFlow/utils/useDebouncedRefresh/useDebouncedRefresh.d.ts +3 -3
- package/build/types/dynamicFlow/utils/useLoader.d.ts +1 -1
- package/build/types/fixtures/index.d.ts +2 -0
- package/build/types/fixtures/schemas/all-of.d.ts +3 -0
- package/build/types/fixtures/schemas/boolean.d.ts +3 -0
- package/build/types/fixtures/schemas/index.d.ts +2 -0
- package/build/types/layout/button/utils.d.ts +5 -0
- package/build/types/layout/index.d.ts +1 -1
- package/build/types/layout/markdown/DynamicMarkdown.d.ts +10 -0
- package/build/types/types/specification/LayoutComponent.d.ts +11 -1
- package/build/types/types/specification/Step.d.ts +9 -26
- package/package.json +2 -1
- package/build/types/layout/info/DynamicInfo.d.ts +0 -6
package/build/main.js
CHANGED
|
@@ -541,92 +541,87 @@ __export(src_exports, {
|
|
|
541
541
|
module.exports = __toCommonJS(src_exports);
|
|
542
542
|
|
|
543
543
|
// src/step/layoutStep/utils/layout-utils.ts
|
|
544
|
-
function convertStepToLayout(
|
|
545
|
-
if (
|
|
546
|
-
|
|
544
|
+
function convertStepToLayout(step35, { displayStepTitle = true } = {}) {
|
|
545
|
+
if (step35.layout) {
|
|
546
|
+
return addMissingTitleAndDescriptionToStep(step35, displayStepTitle);
|
|
547
547
|
}
|
|
548
|
-
|
|
549
|
-
return addMissingTitleAndDescriptionToStep(step33, displayStepTitle);
|
|
550
|
-
}
|
|
551
|
-
switch (step33.type) {
|
|
548
|
+
switch (step35.type) {
|
|
552
549
|
case "final":
|
|
553
|
-
return convertFinalStepToDynamicLayout(
|
|
550
|
+
return convertFinalStepToDynamicLayout(step35);
|
|
554
551
|
case "decision":
|
|
555
|
-
return convertDecisionStepToDynamicLayout(
|
|
556
|
-
case "form":
|
|
557
|
-
return convertFormStepToDynamicLayout(step33);
|
|
552
|
+
return convertDecisionStepToDynamicLayout(step35);
|
|
558
553
|
case "external":
|
|
559
|
-
return convertExternalStepToDynamicLayout(
|
|
554
|
+
return convertExternalStepToDynamicLayout(step35);
|
|
560
555
|
default:
|
|
561
|
-
|
|
556
|
+
return convertFormStepToDynamicLayout(step35);
|
|
562
557
|
}
|
|
563
558
|
}
|
|
564
|
-
function convertCommonComponents(
|
|
559
|
+
function convertCommonComponents(step35) {
|
|
565
560
|
const layout6 = [];
|
|
566
|
-
if (
|
|
567
|
-
layout6.push(convertStepTitleToDynamicHeading(
|
|
561
|
+
if (step35.title) {
|
|
562
|
+
layout6.push(convertStepTitleToDynamicHeading(step35.title));
|
|
568
563
|
}
|
|
569
|
-
if (
|
|
570
|
-
const image = convertStepImageToDynamicImage(
|
|
564
|
+
if (step35.image) {
|
|
565
|
+
const image = convertStepImageToDynamicImage(step35.image);
|
|
571
566
|
layout6.push(image);
|
|
572
567
|
}
|
|
573
|
-
if (
|
|
574
|
-
layout6.push(convertStepDescriptionToDynamicParagraph(
|
|
568
|
+
if (step35.description) {
|
|
569
|
+
layout6.push(convertStepDescriptionToDynamicParagraph(step35.description));
|
|
575
570
|
}
|
|
576
571
|
return layout6;
|
|
577
572
|
}
|
|
578
|
-
function convertExternalStepToDynamicLayout(
|
|
579
|
-
return [...convertCommonComponents(
|
|
573
|
+
function convertExternalStepToDynamicLayout(step35) {
|
|
574
|
+
return [...convertCommonComponents(step35), convertStepToExternalComponent(step35)];
|
|
580
575
|
}
|
|
581
|
-
function convertStepToExternalComponent(
|
|
576
|
+
function convertStepToExternalComponent(step35) {
|
|
582
577
|
return {
|
|
583
578
|
type: "external",
|
|
584
|
-
requestUrl:
|
|
585
|
-
polling:
|
|
586
|
-
responseHandlers:
|
|
587
|
-
retryTitle:
|
|
579
|
+
requestUrl: step35.requestUrl,
|
|
580
|
+
polling: step35.polling,
|
|
581
|
+
responseHandlers: step35.responseHandlers,
|
|
582
|
+
retryTitle: step35.retryTitle
|
|
588
583
|
};
|
|
589
584
|
}
|
|
590
|
-
function convertFormStepToDynamicLayout(
|
|
591
|
-
const layout6 = convertCommonComponents(
|
|
592
|
-
if (
|
|
593
|
-
layout6.push(convertStepReviewToDynamicReview(
|
|
585
|
+
function convertFormStepToDynamicLayout(step35) {
|
|
586
|
+
const layout6 = convertCommonComponents(step35);
|
|
587
|
+
if (step35.reviewFields) {
|
|
588
|
+
layout6.push(convertStepReviewToDynamicReview(step35.reviewFields));
|
|
594
589
|
}
|
|
595
|
-
if (
|
|
596
|
-
layout6.push(...getSchemaLayout(
|
|
590
|
+
if (step35.schemas) {
|
|
591
|
+
layout6.push(...getSchemaLayout(step35));
|
|
597
592
|
}
|
|
598
|
-
if (
|
|
599
|
-
const actions =
|
|
593
|
+
if (step35.actions) {
|
|
594
|
+
const actions = step35.actions.map(convertStepActionToDynamicAction);
|
|
600
595
|
layout6.push(dynamicBox(actions, "md"));
|
|
601
596
|
}
|
|
602
597
|
return layout6;
|
|
603
598
|
}
|
|
604
|
-
function convertFinalStepToDynamicLayout(
|
|
599
|
+
function convertFinalStepToDynamicLayout(step35) {
|
|
605
600
|
const layout6 = [];
|
|
606
|
-
if (
|
|
607
|
-
if (
|
|
608
|
-
const image = convertFinalStepImageToDynamicImage(
|
|
601
|
+
if (step35.details) {
|
|
602
|
+
if (step35.details.image) {
|
|
603
|
+
const image = convertFinalStepImageToDynamicImage(step35.details.image);
|
|
609
604
|
layout6.push(image);
|
|
610
605
|
}
|
|
611
|
-
if (
|
|
612
|
-
layout6.push(convertStepTitleToDynamicHeading(
|
|
606
|
+
if (step35.details.title) {
|
|
607
|
+
layout6.push(convertStepTitleToDynamicHeading(step35.details.title));
|
|
613
608
|
}
|
|
614
|
-
if (
|
|
615
|
-
layout6.push(convertStepDescriptionToDynamicParagraph(
|
|
609
|
+
if (step35.details.description) {
|
|
610
|
+
layout6.push(convertStepDescriptionToDynamicParagraph(step35.details.description));
|
|
616
611
|
}
|
|
617
612
|
}
|
|
618
|
-
if (
|
|
619
|
-
const actions =
|
|
613
|
+
if (step35.actions) {
|
|
614
|
+
const actions = step35.actions.map(
|
|
620
615
|
(action2) => convertStepActionToDynamicAction(__spreadProps(__spreadValues({}, action2), { type: action2.type || "primary" }))
|
|
621
616
|
);
|
|
622
617
|
layout6.push(dynamicBox(actions, "md"));
|
|
623
618
|
}
|
|
624
619
|
return layout6;
|
|
625
620
|
}
|
|
626
|
-
function convertDecisionStepToDynamicLayout(
|
|
627
|
-
const layout6 = convertCommonComponents(
|
|
628
|
-
if (
|
|
629
|
-
layout6.push(convertStepDecisionToDynamicDecision(
|
|
621
|
+
function convertDecisionStepToDynamicLayout(step35) {
|
|
622
|
+
const layout6 = convertCommonComponents(step35);
|
|
623
|
+
if (step35.options) {
|
|
624
|
+
layout6.push(convertStepDecisionToDynamicDecision(step35.options));
|
|
630
625
|
}
|
|
631
626
|
return layout6;
|
|
632
627
|
}
|
|
@@ -712,10 +707,10 @@ function convertReviewFieldToDefinition(reviewField) {
|
|
|
712
707
|
value: reviewField.value
|
|
713
708
|
};
|
|
714
709
|
}
|
|
715
|
-
function getSchemaLayout(
|
|
710
|
+
function getSchemaLayout(step35) {
|
|
716
711
|
const layout6 = [];
|
|
717
|
-
if (
|
|
718
|
-
const schema2 =
|
|
712
|
+
if (step35.schemas && step35.schemas[0]) {
|
|
713
|
+
const schema2 = step35.schemas[0];
|
|
719
714
|
const dynamicForm = convertStepSchemaToDynamicForm(schema2);
|
|
720
715
|
if (isWideForm()) {
|
|
721
716
|
layout6.push(dynamicForm);
|
|
@@ -728,11 +723,11 @@ function getSchemaLayout(step33) {
|
|
|
728
723
|
function isWideForm() {
|
|
729
724
|
return false;
|
|
730
725
|
}
|
|
731
|
-
function addMissingTitleAndDescriptionToStep(
|
|
726
|
+
function addMissingTitleAndDescriptionToStep(step35, displayStepTitle) {
|
|
732
727
|
return [
|
|
733
|
-
...displayStepTitle &&
|
|
734
|
-
...
|
|
735
|
-
...
|
|
728
|
+
...displayStepTitle && step35.title ? [convertStepTitleToDynamicHeading(step35.title)] : [],
|
|
729
|
+
...step35.description ? [convertStepDescriptionToDynamicParagraph(step35.description)] : [],
|
|
730
|
+
...step35.layout || []
|
|
736
731
|
];
|
|
737
732
|
}
|
|
738
733
|
|
|
@@ -1711,23 +1706,19 @@ function shouldDebounceSchema(schema2) {
|
|
|
1711
1706
|
}
|
|
1712
1707
|
|
|
1713
1708
|
// src/common/utils/step-utils.ts
|
|
1714
|
-
var
|
|
1715
|
-
|
|
1716
|
-
CAMERA: "camera"
|
|
1717
|
-
};
|
|
1718
|
-
var isCameraStep = (step33) => {
|
|
1719
|
-
return isFormStep(step33) && hasSingleAction(step33) && hasSingleFileUploadSchemaWithCameraOnly(step33);
|
|
1709
|
+
var isCameraStep = (step35) => {
|
|
1710
|
+
return isFormStep(step35) && hasSingleAction(step35) && hasSingleFileUploadSchemaWithCameraOnly(step35);
|
|
1720
1711
|
};
|
|
1721
|
-
var isFormStep = (
|
|
1722
|
-
var hasSingleAction = (
|
|
1712
|
+
var isFormStep = (step35) => !step35.type || step35.type === "form";
|
|
1713
|
+
var hasSingleAction = (step35) => {
|
|
1723
1714
|
var _a;
|
|
1724
|
-
return ((_a =
|
|
1715
|
+
return ((_a = step35 == null ? void 0 : step35.actions) == null ? void 0 : _a.length) === 1;
|
|
1725
1716
|
};
|
|
1726
|
-
var hasSingleFileUploadSchemaWithCameraOnly = (
|
|
1727
|
-
if (!
|
|
1717
|
+
var hasSingleFileUploadSchemaWithCameraOnly = (step35) => {
|
|
1718
|
+
if (!step35.schemas) {
|
|
1728
1719
|
return false;
|
|
1729
1720
|
}
|
|
1730
|
-
const schemas = filterHiddenSchemas(
|
|
1721
|
+
const schemas = filterHiddenSchemas(step35.schemas);
|
|
1731
1722
|
if ((schemas == null ? void 0 : schemas.length) !== 1) {
|
|
1732
1723
|
return false;
|
|
1733
1724
|
}
|
|
@@ -1749,12 +1740,6 @@ var filterHiddenSchemas = (schemas) => {
|
|
|
1749
1740
|
return (schema2 == null ? void 0 : schema2.hidden) !== true;
|
|
1750
1741
|
});
|
|
1751
1742
|
};
|
|
1752
|
-
var getStepType = (step33) => {
|
|
1753
|
-
if (isCameraStep(step33)) {
|
|
1754
|
-
return stepType.CAMERA;
|
|
1755
|
-
}
|
|
1756
|
-
return stepType.LAYOUT;
|
|
1757
|
-
};
|
|
1758
1743
|
|
|
1759
1744
|
// src/common/hooks/useDebouncedFunction/useDebouncedFunction.tsx
|
|
1760
1745
|
function useDebouncedFunction(callback, waitMs) {
|
|
@@ -2101,13 +2086,57 @@ var DynamicBox_default = DynamicBox;
|
|
|
2101
2086
|
|
|
2102
2087
|
// src/layout/button/DynamicButton.tsx
|
|
2103
2088
|
var import_components2 = require("@transferwise/components");
|
|
2089
|
+
|
|
2090
|
+
// src/layout/button/utils.ts
|
|
2091
|
+
var priorities = {
|
|
2092
|
+
primary: "primary",
|
|
2093
|
+
secondary: "secondary",
|
|
2094
|
+
link: "tertiary",
|
|
2095
|
+
positive: "primary",
|
|
2096
|
+
negative: "primary"
|
|
2097
|
+
};
|
|
2098
|
+
var getButtonPriority = (component) => {
|
|
2099
|
+
var _a;
|
|
2100
|
+
const actionType = component.action.type;
|
|
2101
|
+
return (_a = component.control) != null ? _a : actionType ? priorities[actionType] : "secondary";
|
|
2102
|
+
};
|
|
2103
|
+
var types = {
|
|
2104
|
+
primary: "neutral",
|
|
2105
|
+
secondary: "neutral",
|
|
2106
|
+
link: "neutral",
|
|
2107
|
+
positive: "positive",
|
|
2108
|
+
negative: "negative"
|
|
2109
|
+
};
|
|
2110
|
+
var getButtonType = (component) => {
|
|
2111
|
+
var _a;
|
|
2112
|
+
const actionType = component.action.type;
|
|
2113
|
+
const type = (_a = component.context) != null ? _a : actionType ? types[actionType] : "neutral";
|
|
2114
|
+
return type === "neutral" ? "accent" : type;
|
|
2115
|
+
};
|
|
2116
|
+
var getButtonSize = (size) => {
|
|
2117
|
+
switch (size) {
|
|
2118
|
+
case "xs":
|
|
2119
|
+
case "sm":
|
|
2120
|
+
return "sm";
|
|
2121
|
+
case "lg":
|
|
2122
|
+
case "xl":
|
|
2123
|
+
return "lg";
|
|
2124
|
+
case "md":
|
|
2125
|
+
default:
|
|
2126
|
+
return "md";
|
|
2127
|
+
}
|
|
2128
|
+
};
|
|
2129
|
+
|
|
2130
|
+
// src/layout/button/DynamicButton.tsx
|
|
2104
2131
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
2105
2132
|
var DynamicButton = (props) => {
|
|
2133
|
+
var _a;
|
|
2106
2134
|
const { component, onAction } = props;
|
|
2107
2135
|
const componentAction = component.action;
|
|
2108
|
-
const
|
|
2136
|
+
const type = getButtonType(component);
|
|
2137
|
+
const priority = getButtonPriority(component);
|
|
2109
2138
|
const { loading } = useDynamicFlow();
|
|
2110
|
-
const className = getMarginBottom(component.margin || "md")
|
|
2139
|
+
const className = getMarginBottom(component.margin || "md");
|
|
2111
2140
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2112
2141
|
import_components2.Button,
|
|
2113
2142
|
{
|
|
@@ -2116,44 +2145,12 @@ var DynamicButton = (props) => {
|
|
|
2116
2145
|
priority,
|
|
2117
2146
|
block: true,
|
|
2118
2147
|
className,
|
|
2119
|
-
disabled: componentAction.disabled || loading,
|
|
2148
|
+
disabled: component.disabled || componentAction.disabled || loading,
|
|
2120
2149
|
onClick: () => onAction(componentAction),
|
|
2121
|
-
children: componentAction.title
|
|
2150
|
+
children: (_a = component.title) != null ? _a : componentAction.title
|
|
2122
2151
|
}
|
|
2123
2152
|
);
|
|
2124
2153
|
};
|
|
2125
|
-
var getActionClasses = (action2) => {
|
|
2126
|
-
return action2.primary ? "btn-primary" : "";
|
|
2127
|
-
};
|
|
2128
|
-
var getButtonSize = (size) => {
|
|
2129
|
-
switch (size) {
|
|
2130
|
-
case "xs":
|
|
2131
|
-
case "sm":
|
|
2132
|
-
return "sm";
|
|
2133
|
-
case "lg":
|
|
2134
|
-
case "xl":
|
|
2135
|
-
return "lg";
|
|
2136
|
-
case "md":
|
|
2137
|
-
default:
|
|
2138
|
-
return "md";
|
|
2139
|
-
}
|
|
2140
|
-
};
|
|
2141
|
-
var getButtonTypeAndPriority = (action2) => {
|
|
2142
|
-
switch (action2.type) {
|
|
2143
|
-
case "link":
|
|
2144
|
-
return { type: "accent", priority: "tertiary" };
|
|
2145
|
-
case "primary":
|
|
2146
|
-
return { type: "accent", priority: "primary" };
|
|
2147
|
-
case "secondary":
|
|
2148
|
-
return { type: "accent", priority: "secondary" };
|
|
2149
|
-
case "positive":
|
|
2150
|
-
return { type: "positive", priority: "primary" };
|
|
2151
|
-
case "negative":
|
|
2152
|
-
return { type: "negative", priority: "primary" };
|
|
2153
|
-
default:
|
|
2154
|
-
return { type: "accent", priority: "secondary" };
|
|
2155
|
-
}
|
|
2156
|
-
};
|
|
2157
2154
|
var DynamicButton_default = DynamicButton;
|
|
2158
2155
|
|
|
2159
2156
|
// src/layout/columns/DynamicColumns.tsx
|
|
@@ -2994,7 +2991,7 @@ var _FormControl = class extends import_react13.PureComponent {
|
|
|
2994
2991
|
const {
|
|
2995
2992
|
name,
|
|
2996
2993
|
placeholder,
|
|
2997
|
-
step:
|
|
2994
|
+
step: step35,
|
|
2998
2995
|
countryCode,
|
|
2999
2996
|
type,
|
|
3000
2997
|
options,
|
|
@@ -3102,7 +3099,7 @@ var _FormControl = class extends import_react13.PureComponent {
|
|
|
3102
3099
|
placeholder,
|
|
3103
3100
|
readOnly,
|
|
3104
3101
|
required,
|
|
3105
|
-
step:
|
|
3102
|
+
step: step35,
|
|
3106
3103
|
type: "number",
|
|
3107
3104
|
value: getSafeStringOrNumberValue(value, { coerceValue: true }),
|
|
3108
3105
|
onBlur: this.handleOnBlur,
|
|
@@ -4476,13 +4473,16 @@ var DynamicHeading = (props) => {
|
|
|
4476
4473
|
};
|
|
4477
4474
|
var DynamicHeading_default = DynamicHeading;
|
|
4478
4475
|
|
|
4479
|
-
// src/layout/
|
|
4476
|
+
// src/layout/markdown/DynamicMarkdown.tsx
|
|
4480
4477
|
var import_components14 = require("@transferwise/components");
|
|
4481
4478
|
var import_jsx_runtime39 = require("react/jsx-runtime");
|
|
4479
|
+
var DynamicMarkdown = ({ component }) => {
|
|
4480
|
+
const { content, align, margin } = component;
|
|
4481
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getTextAlignmentAndMargin({ align, margin }), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_components14.Markdown, { config: { link: { target: "_blank" } }, children: content }) });
|
|
4482
|
+
};
|
|
4482
4483
|
var DynamicInfo = ({ component }) => {
|
|
4483
4484
|
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getTextAlignmentAndMargin(component), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_components14.Markdown, { config: { link: { target: "_blank" } }, children: component.markdown }) });
|
|
4484
4485
|
};
|
|
4485
|
-
var DynamicInfo_default = DynamicInfo;
|
|
4486
4486
|
|
|
4487
4487
|
// src/layout/image/DynamicImage.tsx
|
|
4488
4488
|
var import_components15 = require("@transferwise/components");
|
|
@@ -4556,7 +4556,9 @@ var DynamicLayout = (props) => {
|
|
|
4556
4556
|
case "divider":
|
|
4557
4557
|
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(DynamicDivider_default, { component }, getKey(component));
|
|
4558
4558
|
case "info":
|
|
4559
|
-
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
4559
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(DynamicInfo, { component }, getKey(component));
|
|
4560
|
+
case "markdown":
|
|
4561
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(DynamicMarkdown, { component }, getKey(component));
|
|
4560
4562
|
case "columns":
|
|
4561
4563
|
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
4562
4564
|
DynamicColumns_default,
|
|
@@ -4582,7 +4584,7 @@ var DynamicLayout = (props) => {
|
|
|
4582
4584
|
onModelChange,
|
|
4583
4585
|
onPersistAsync
|
|
4584
4586
|
},
|
|
4585
|
-
getKey(component)
|
|
4587
|
+
getKey(__spreadProps(__spreadValues({}, component), { errors }))
|
|
4586
4588
|
);
|
|
4587
4589
|
case "button":
|
|
4588
4590
|
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(DynamicButton_default, { component, onAction }, getKey(component));
|
|
@@ -4836,7 +4838,10 @@ var BasicTypeSchema = (props) => {
|
|
|
4836
4838
|
(0, import_react21.useEffect)(onSchemaChange, [props.schema]);
|
|
4837
4839
|
(0, import_react21.useEffect)(() => {
|
|
4838
4840
|
var _a2;
|
|
4839
|
-
|
|
4841
|
+
const newModel = (_a2 = props.model) != null ? _a2 : null;
|
|
4842
|
+
if (newModel !== model) {
|
|
4843
|
+
setModel(newModel);
|
|
4844
|
+
}
|
|
4840
4845
|
}, [props.model]);
|
|
4841
4846
|
const formGroupClasses = {
|
|
4842
4847
|
"form-group": true,
|
|
@@ -5193,17 +5198,17 @@ function useStepPolling(polling, onAction) {
|
|
|
5193
5198
|
|
|
5194
5199
|
// src/step/layoutStep/LayoutStep.tsx
|
|
5195
5200
|
var import_jsx_runtime48 = require("react/jsx-runtime");
|
|
5196
|
-
var getComponents = (
|
|
5201
|
+
var getComponents = (step35, options) => {
|
|
5197
5202
|
var _a;
|
|
5198
|
-
if (
|
|
5203
|
+
if (isEmpty(step35)) {
|
|
5199
5204
|
return [];
|
|
5200
5205
|
}
|
|
5201
|
-
const layout6 = convertStepToLayout(
|
|
5206
|
+
const layout6 = convertStepToLayout(step35, options);
|
|
5202
5207
|
return inlineReferences({
|
|
5203
5208
|
layout: layout6,
|
|
5204
|
-
schemas:
|
|
5205
|
-
actions:
|
|
5206
|
-
model: (_a =
|
|
5209
|
+
schemas: step35.schemas || [],
|
|
5210
|
+
actions: step35.actions || [],
|
|
5211
|
+
model: (_a = step35.model) != null ? _a : null
|
|
5207
5212
|
});
|
|
5208
5213
|
};
|
|
5209
5214
|
var LayoutStep = (props) => {
|
|
@@ -5662,11 +5667,11 @@ function blobToBase64(blob) {
|
|
|
5662
5667
|
});
|
|
5663
5668
|
}
|
|
5664
5669
|
var CameraStep = (props) => {
|
|
5665
|
-
const { step:
|
|
5670
|
+
const { step: step35, model, onModelChange, onAction } = props;
|
|
5666
5671
|
const onEvent = useEventDispatcher();
|
|
5667
|
-
const objectSchema = getObjectSchema(
|
|
5668
|
-
const cameraSchema = getCameraSchema(
|
|
5669
|
-
const action2 = getFirstAction(
|
|
5672
|
+
const objectSchema = getObjectSchema(step35);
|
|
5673
|
+
const cameraSchema = getCameraSchema(step35);
|
|
5674
|
+
const action2 = getFirstAction(step35);
|
|
5670
5675
|
const { title, image, cameraConfig } = cameraSchema;
|
|
5671
5676
|
const { assets, direction, instructions } = cameraConfig || {};
|
|
5672
5677
|
const { overlay, outline } = assets || {};
|
|
@@ -5708,8 +5713,8 @@ var CameraStep = (props) => {
|
|
|
5708
5713
|
);
|
|
5709
5714
|
};
|
|
5710
5715
|
var CameraStep_default = CameraStep;
|
|
5711
|
-
function getObjectSchema(
|
|
5712
|
-
const nonHiddenSchemas = filterHiddenSchemas(
|
|
5716
|
+
function getObjectSchema(step35) {
|
|
5717
|
+
const nonHiddenSchemas = filterHiddenSchemas(step35.schemas || []);
|
|
5713
5718
|
const objectSchema = nonHiddenSchemas[0];
|
|
5714
5719
|
if (!objectSchema || !isObjectSchema(objectSchema)) {
|
|
5715
5720
|
throw new Error(
|
|
@@ -5718,8 +5723,8 @@ function getObjectSchema(step33) {
|
|
|
5718
5723
|
}
|
|
5719
5724
|
return objectSchema;
|
|
5720
5725
|
}
|
|
5721
|
-
function getCameraSchema(
|
|
5722
|
-
const objectSchema = getObjectSchema(
|
|
5726
|
+
function getCameraSchema(step35) {
|
|
5727
|
+
const objectSchema = getObjectSchema(step35);
|
|
5723
5728
|
const firstProperty = Object.values(objectSchema.properties)[0];
|
|
5724
5729
|
if (!firstProperty) {
|
|
5725
5730
|
throw new Error(
|
|
@@ -5728,15 +5733,15 @@ function getCameraSchema(step33) {
|
|
|
5728
5733
|
}
|
|
5729
5734
|
return firstProperty;
|
|
5730
5735
|
}
|
|
5731
|
-
function getFirstAction(
|
|
5736
|
+
function getFirstAction(step35) {
|
|
5732
5737
|
var _a, _b;
|
|
5733
|
-
if (!
|
|
5738
|
+
if (!step35.schemas || ((_a = filterHiddenSchemas(step35.schemas)) == null ? void 0 : _a.length) !== 1) {
|
|
5734
5739
|
throw new Error("camera step expects 1 non-hidden object schema");
|
|
5735
5740
|
}
|
|
5736
|
-
if (((_b =
|
|
5741
|
+
if (((_b = step35 == null ? void 0 : step35.actions) == null ? void 0 : _b.length) !== 1) {
|
|
5737
5742
|
throw new Error("camera step expects 1 action");
|
|
5738
5743
|
}
|
|
5739
|
-
return
|
|
5744
|
+
return step35.actions[0];
|
|
5740
5745
|
}
|
|
5741
5746
|
|
|
5742
5747
|
// src/step/externalConfirmationStep/ExternalConfirmationStep.tsx
|
|
@@ -5841,21 +5846,21 @@ function getOrigin(url) {
|
|
|
5841
5846
|
var import_jsx_runtime56 = require("react/jsx-runtime");
|
|
5842
5847
|
var DynamicFlowStep = (props) => {
|
|
5843
5848
|
var _a;
|
|
5844
|
-
const { step:
|
|
5845
|
-
const externalUrl = (_a =
|
|
5849
|
+
const { step: step35, globalError } = props;
|
|
5850
|
+
const externalUrl = (_a = step35 == null ? void 0 : step35.external) == null ? void 0 : _a.url;
|
|
5846
5851
|
const { requiresManualTrigger, dismissConfirmation } = useExternal(externalUrl);
|
|
5847
|
-
if (
|
|
5852
|
+
if (step35 === void 0) {
|
|
5848
5853
|
return null;
|
|
5849
5854
|
}
|
|
5850
5855
|
if (externalUrl && requiresManualTrigger) {
|
|
5851
5856
|
return /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(ExternalConfirmationStep_default, { url: externalUrl, onClose: dismissConfirmation });
|
|
5852
5857
|
}
|
|
5853
|
-
if (
|
|
5854
|
-
return /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(CameraStep_default, __spreadProps(__spreadValues({}, props), { step:
|
|
5858
|
+
if (isCameraStep(step35)) {
|
|
5859
|
+
return /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(CameraStep_default, __spreadProps(__spreadValues({}, props), { step: step35 }));
|
|
5855
5860
|
}
|
|
5856
5861
|
return /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(import_jsx_runtime56.Fragment, { children: [
|
|
5857
5862
|
globalError ? /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(DynamicAlert_default, { component: { context: "negative", markdown: globalError, margin: "lg" } }) : null,
|
|
5858
|
-
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(LayoutStep_default, __spreadProps(__spreadValues({}, props), { stepSpecification:
|
|
5863
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(LayoutStep_default, __spreadProps(__spreadValues({}, props), { stepSpecification: step35 }))
|
|
5859
5864
|
] });
|
|
5860
5865
|
};
|
|
5861
5866
|
|
|
@@ -5869,16 +5874,15 @@ function useDebouncedRefresh(fetchRefresh) {
|
|
|
5869
5874
|
return map.current.get(key);
|
|
5870
5875
|
}
|
|
5871
5876
|
const debouncedFetchRefresh = debounce(
|
|
5872
|
-
(
|
|
5877
|
+
(url, data, etag) => fetchRefresh(url, data, etag),
|
|
5873
5878
|
DEBOUNCE_DELAY
|
|
5874
5879
|
);
|
|
5875
5880
|
map.current.set(key, debouncedFetchRefresh);
|
|
5876
5881
|
return debouncedFetchRefresh;
|
|
5877
5882
|
};
|
|
5878
|
-
return function(
|
|
5879
|
-
const
|
|
5880
|
-
|
|
5881
|
-
void debouncedFetchRefresh(action2, data, etag);
|
|
5883
|
+
return function(url, data, etag, schema2) {
|
|
5884
|
+
const debouncedFetchRefresh = retrieveOrCreate(url);
|
|
5885
|
+
void debouncedFetchRefresh(url, data, etag);
|
|
5882
5886
|
if (!schema2 || !shouldDebounceSchema(schema2)) {
|
|
5883
5887
|
void debouncedFetchRefresh.flush();
|
|
5884
5888
|
}
|
|
@@ -5903,16 +5907,16 @@ var useDynamicFlowState = (initialStep) => {
|
|
|
5903
5907
|
models: (initialStep == null ? void 0 : initialStep.model) ? buildInitialModels(initialStep.model, getAllSchemas(initialStep)) : {},
|
|
5904
5908
|
etag: void 0
|
|
5905
5909
|
});
|
|
5906
|
-
const { step:
|
|
5907
|
-
const setStepAndEtag = (
|
|
5910
|
+
const { step: step35, models, etag } = stepAndModels;
|
|
5911
|
+
const setStepAndEtag = (step36, etag2) => {
|
|
5908
5912
|
var _a2, _b2, _c, _d;
|
|
5909
5913
|
setStepAndModels((previous) => ({
|
|
5910
|
-
step:
|
|
5911
|
-
models:
|
|
5914
|
+
step: step36,
|
|
5915
|
+
models: step36.model ? buildInitialModels(step36.model, getAllSchemas(step36)) : previous.models,
|
|
5912
5916
|
etag: etag2
|
|
5913
5917
|
}));
|
|
5914
|
-
setFormErrors((_b2 = (_a2 =
|
|
5915
|
-
setGlobalError((_d = (_c =
|
|
5918
|
+
setFormErrors((_b2 = (_a2 = step36 == null ? void 0 : step36.errors) == null ? void 0 : _a2.validation) != null ? _b2 : null);
|
|
5919
|
+
setGlobalError((_d = (_c = step36 == null ? void 0 : step36.errors) == null ? void 0 : _c.error) != null ? _d : null);
|
|
5916
5920
|
};
|
|
5917
5921
|
const setSchemaModel = (schemaId, objectModel, onModelsUpdated) => {
|
|
5918
5922
|
setStepAndModels((previous) => {
|
|
@@ -5928,11 +5932,11 @@ var useDynamicFlowState = (initialStep) => {
|
|
|
5928
5932
|
return updatedState;
|
|
5929
5933
|
});
|
|
5930
5934
|
};
|
|
5931
|
-
const modelIsValid = (0, import_react32.useMemo)(() => areModelsValid(models, getAllSchemas(
|
|
5935
|
+
const modelIsValid = (0, import_react32.useMemo)(() => areModelsValid(models, getAllSchemas(step35)), [models, step35]);
|
|
5932
5936
|
return {
|
|
5933
5937
|
formErrors,
|
|
5934
5938
|
globalError,
|
|
5935
|
-
step:
|
|
5939
|
+
step: step35,
|
|
5936
5940
|
models,
|
|
5937
5941
|
etag,
|
|
5938
5942
|
modelIsValid,
|
|
@@ -5952,9 +5956,9 @@ var buildInitialModels = (model, schemas = []) => {
|
|
|
5952
5956
|
});
|
|
5953
5957
|
}, {});
|
|
5954
5958
|
};
|
|
5955
|
-
var getAllSchemas = (
|
|
5956
|
-
...getAllSchemasInLayout((
|
|
5957
|
-
...(
|
|
5959
|
+
var getAllSchemas = (step35) => [
|
|
5960
|
+
...getAllSchemasInLayout((step35 == null ? void 0 : step35.layout) || []),
|
|
5961
|
+
...(step35 == null ? void 0 : step35.schemas) || []
|
|
5958
5962
|
];
|
|
5959
5963
|
var getAllSchemasInLayout = (components) => components.flatMap((component) => {
|
|
5960
5964
|
switch (component.type) {
|
|
@@ -5997,7 +6001,7 @@ function useLoader(loaderConfig, initialState) {
|
|
|
5997
6001
|
"data-testid": "loader"
|
|
5998
6002
|
}
|
|
5999
6003
|
) : null;
|
|
6000
|
-
return { loadingState, setLoadingState, loader };
|
|
6004
|
+
return { isLoading: loadingState !== "idle", setLoadingState, loader };
|
|
6001
6005
|
}
|
|
6002
6006
|
|
|
6003
6007
|
// src/dynamicFlow/utils/errorBoundary/ErrorBoundary.tsx
|
|
@@ -6072,46 +6076,78 @@ var ErrorBoundary = class extends import_react34.Component {
|
|
|
6072
6076
|
var ErrorBoundary_default = ErrorBoundary;
|
|
6073
6077
|
|
|
6074
6078
|
// src/dynamicFlow/utils/responseParsers/response-parsers.ts
|
|
6075
|
-
var
|
|
6076
|
-
|
|
6077
|
-
|
|
6078
|
-
|
|
6079
|
-
|
|
6079
|
+
var parseFetchResponseByResponseType = async (response) => {
|
|
6080
|
+
const type = response.headers.get("X-Df-ResponseType");
|
|
6081
|
+
switch (type) {
|
|
6082
|
+
case "step":
|
|
6083
|
+
return parseStepResponse(response);
|
|
6084
|
+
case "exit":
|
|
6085
|
+
return parseExitResponse(response);
|
|
6086
|
+
case "action":
|
|
6087
|
+
return parseActionResponse(response);
|
|
6088
|
+
default:
|
|
6089
|
+
throw new Error(
|
|
6090
|
+
"Unsupported X-Df-ResponseType. Allowed values are 'step', 'action', 'exit'."
|
|
6091
|
+
);
|
|
6080
6092
|
}
|
|
6093
|
+
};
|
|
6094
|
+
var parseStepResponse = async (response) => {
|
|
6081
6095
|
const jsonBody = await parseResponseJson(response);
|
|
6082
6096
|
if (!isObject(jsonBody)) {
|
|
6083
6097
|
throw new Error("Incorrect response body in response. Expected an object.");
|
|
6084
6098
|
}
|
|
6085
|
-
if (jsonBody.action) {
|
|
6086
|
-
if (!isObject(jsonBody.action)) {
|
|
6087
|
-
throw new Error(
|
|
6088
|
-
"Incorrect response body in action response. Expected an object satisfying the type { action: Action }."
|
|
6089
|
-
);
|
|
6090
|
-
}
|
|
6091
|
-
const action2 = jsonBody.action;
|
|
6092
|
-
if (action2.exit === true && isObject(action2.result)) {
|
|
6093
|
-
return { type: "exit", result: action2.result };
|
|
6094
|
-
}
|
|
6095
|
-
return { type: "action", action: jsonBody.action };
|
|
6096
|
-
}
|
|
6097
6099
|
const etag = response.headers.get("etag") || void 0;
|
|
6098
6100
|
return { type: "step", step: jsonBody, etag };
|
|
6099
6101
|
};
|
|
6102
|
+
var parseActionResponse = async (response) => {
|
|
6103
|
+
const jsonBody = await parseResponseJson(response);
|
|
6104
|
+
if (!isObject(jsonBody)) {
|
|
6105
|
+
throw new Error("Incorrect response body in response. Expected an object.");
|
|
6106
|
+
}
|
|
6107
|
+
if (!isObject(jsonBody.action)) {
|
|
6108
|
+
throw new Error(
|
|
6109
|
+
"Incorrect response body in action response. Expected an object satisfying the type { action: Action }."
|
|
6110
|
+
);
|
|
6111
|
+
}
|
|
6112
|
+
const action2 = jsonBody.action;
|
|
6113
|
+
if (action2.exit === true && isObject(action2.result)) {
|
|
6114
|
+
return { type: "exit", result: action2.result };
|
|
6115
|
+
}
|
|
6116
|
+
return { type: "action", action: jsonBody.action };
|
|
6117
|
+
};
|
|
6118
|
+
var parseExitResponse = async (response) => {
|
|
6119
|
+
return { type: "exit", result: await getJsonObjectOrNull(response) };
|
|
6120
|
+
};
|
|
6121
|
+
var parseFetchResponse = async (response) => {
|
|
6122
|
+
var _a, _b;
|
|
6123
|
+
assertResponseIsValid(response);
|
|
6124
|
+
if ((_a = response.headers) == null ? void 0 : _a.has("X-Df-ResponseType")) {
|
|
6125
|
+
return parseFetchResponseByResponseType(response);
|
|
6126
|
+
}
|
|
6127
|
+
if ((_b = response.headers) == null ? void 0 : _b.has("X-Df-Exit")) {
|
|
6128
|
+
return parseExitResponse(response);
|
|
6129
|
+
}
|
|
6130
|
+
const jsonBody = await parseResponseJson(response.clone());
|
|
6131
|
+
if (isObject(jsonBody) && jsonBody.action) {
|
|
6132
|
+
return parseActionResponse(response);
|
|
6133
|
+
}
|
|
6134
|
+
return parseStepResponse(response);
|
|
6135
|
+
};
|
|
6100
6136
|
var parseErrorResponse = async (response) => {
|
|
6101
6137
|
assertResponseIsValid(response);
|
|
6102
6138
|
const jsonBody = await parseResponseJson(response);
|
|
6103
6139
|
if (!isObject(jsonBody)) {
|
|
6104
6140
|
throw new Error("Incorrect response body in error response. Expected an object.");
|
|
6105
6141
|
}
|
|
6142
|
+
if (!jsonBody.refreshFormUrl && !jsonBody.validation && !jsonBody.error) {
|
|
6143
|
+
throw jsonBody;
|
|
6144
|
+
}
|
|
6106
6145
|
return jsonBody;
|
|
6107
6146
|
};
|
|
6108
|
-
var
|
|
6147
|
+
var getJsonObjectOrNull = async (response) => {
|
|
6109
6148
|
assertResponseIsValid(response);
|
|
6110
6149
|
const result = await parseResponseJson(response);
|
|
6111
|
-
|
|
6112
|
-
return result;
|
|
6113
|
-
}
|
|
6114
|
-
return null;
|
|
6150
|
+
return isObject(result) ? result : null;
|
|
6115
6151
|
};
|
|
6116
6152
|
var parseResponseJson = async (response) => {
|
|
6117
6153
|
try {
|
|
@@ -6152,7 +6188,7 @@ var DynamicFlowComponent = ({
|
|
|
6152
6188
|
const {
|
|
6153
6189
|
formErrors,
|
|
6154
6190
|
globalError,
|
|
6155
|
-
step:
|
|
6191
|
+
step: step35,
|
|
6156
6192
|
models,
|
|
6157
6193
|
etag,
|
|
6158
6194
|
modelIsValid,
|
|
@@ -6162,25 +6198,23 @@ var DynamicFlowComponent = ({
|
|
|
6162
6198
|
setSchemaModel
|
|
6163
6199
|
} = useDynamicFlowState(initialStep);
|
|
6164
6200
|
const [submitted, setSubmitted] = (0, import_react35.useState)(false);
|
|
6165
|
-
const {
|
|
6201
|
+
const { isLoading, loader, setLoadingState } = useLoader(
|
|
6166
6202
|
loaderConfig,
|
|
6167
6203
|
initialStep ? "idle" : "initial"
|
|
6168
6204
|
);
|
|
6169
|
-
const
|
|
6170
|
-
const logError = getLogger("error", onLog, flowId, step33 == null ? void 0 : step33.key);
|
|
6171
|
-
const logCritical = getLogger("critical", onLog, flowId, step33 == null ? void 0 : step33.key);
|
|
6205
|
+
const logCritical = getLogger("critical", onLog, flowId, (step35 == null ? void 0 : step35.id) || (step35 == null ? void 0 : step35.key));
|
|
6172
6206
|
const analyticsMetadata = (0, import_react35.useMemo)(
|
|
6173
6207
|
() => {
|
|
6174
6208
|
var _a;
|
|
6175
|
-
return __spreadValues({ flowId, stepId:
|
|
6209
|
+
return __spreadValues({ flowId, stepId: (step35 == null ? void 0 : step35.id) || (step35 == null ? void 0 : step35.key) }, (_a = step35 == null ? void 0 : step35.analytics) != null ? _a : {});
|
|
6176
6210
|
},
|
|
6177
|
-
[flowId,
|
|
6211
|
+
[flowId, step35]
|
|
6178
6212
|
);
|
|
6179
6213
|
const dispatchEvent = (0, import_react35.useMemo)(
|
|
6180
6214
|
() => getEventDispatcher(onEvent, analyticsMetadata),
|
|
6181
6215
|
[onEvent, analyticsMetadata]
|
|
6182
6216
|
);
|
|
6183
|
-
const
|
|
6217
|
+
const dfHttpClient = (0, import_react35.useCallback)(
|
|
6184
6218
|
({ action: action2, data, etag: etag2 }) => {
|
|
6185
6219
|
const { url, method = "POST" } = action2;
|
|
6186
6220
|
return httpClient(url != null ? url : "", {
|
|
@@ -6196,37 +6230,40 @@ var DynamicFlowComponent = ({
|
|
|
6196
6230
|
},
|
|
6197
6231
|
[httpClient, locale]
|
|
6198
6232
|
);
|
|
6199
|
-
const
|
|
6200
|
-
setLoadingState(
|
|
6233
|
+
const performAction = async (action2, data = {}) => {
|
|
6234
|
+
setLoadingState(!step35 ? "initial" : "submission");
|
|
6235
|
+
dispatchEvent("Dynamic Flow - Step Submitted", { actionId: action2.$id });
|
|
6201
6236
|
try {
|
|
6202
|
-
|
|
6203
|
-
|
|
6204
|
-
return handleFetchResponse(response, "submission");
|
|
6237
|
+
const response = await dfHttpClient({ action: action2, data });
|
|
6238
|
+
await handleResponse(response, "submission");
|
|
6205
6239
|
} catch (error) {
|
|
6206
|
-
|
|
6240
|
+
completeWithError(error, "Error fetching next step");
|
|
6207
6241
|
}
|
|
6208
6242
|
};
|
|
6209
|
-
const
|
|
6243
|
+
const performRefresh = async (url, data, etag2) => {
|
|
6210
6244
|
setLoadingState("refresh");
|
|
6245
|
+
dispatchEvent("Dynamic Flow - Step Refreshed", { status: "pending" });
|
|
6211
6246
|
try {
|
|
6212
|
-
|
|
6213
|
-
|
|
6214
|
-
await handleFetchResponse(response, "refresh");
|
|
6215
|
-
setLoadingState("idle");
|
|
6247
|
+
const response = await dfHttpClient({ action: { url, method: "POST" }, data, etag: etag2 });
|
|
6248
|
+
await handleResponse(response, "refresh");
|
|
6216
6249
|
} catch (error) {
|
|
6217
|
-
|
|
6250
|
+
completeWithError(error, "Error fetching refresh step");
|
|
6218
6251
|
}
|
|
6219
6252
|
};
|
|
6220
|
-
const
|
|
6253
|
+
const performExitAction = async (action2, data) => {
|
|
6254
|
+
setLoadingState("submission");
|
|
6221
6255
|
try {
|
|
6222
|
-
const response = await
|
|
6223
|
-
|
|
6224
|
-
dispatchEventAndComplete(__spreadValues(__spreadValues({}, exitResult), action2.result));
|
|
6256
|
+
const response = await dfHttpClient({ action: action2, data });
|
|
6257
|
+
await handleExitResponse(response, action2.result);
|
|
6225
6258
|
} catch (error) {
|
|
6226
|
-
|
|
6259
|
+
completeWithError(error, "Error fetching exit result");
|
|
6227
6260
|
}
|
|
6228
6261
|
};
|
|
6229
|
-
const
|
|
6262
|
+
const handleExitResponse = async (response, actionResult) => {
|
|
6263
|
+
const exitResult = await getJsonObjectOrNull(response);
|
|
6264
|
+
dispatchEventAndComplete(__spreadValues(__spreadValues({}, exitResult), actionResult));
|
|
6265
|
+
};
|
|
6266
|
+
const debouncedRefresh = useDebouncedRefresh(performRefresh);
|
|
6230
6267
|
const dispatchEventAndComplete = (0, import_react35.useCallback)(
|
|
6231
6268
|
(result) => {
|
|
6232
6269
|
dispatchEvent("Dynamic Flow - Flow Finished", { result: "success" });
|
|
@@ -6243,79 +6280,63 @@ var DynamicFlowComponent = ({
|
|
|
6243
6280
|
$id: "#initial-step-request",
|
|
6244
6281
|
method: "GET"
|
|
6245
6282
|
}, initialAction);
|
|
6246
|
-
void
|
|
6283
|
+
void performAction(action2, action2.data);
|
|
6247
6284
|
}
|
|
6248
6285
|
}, [httpClient, locale, JSON.stringify(initialStep), JSON.stringify(initialAction)]);
|
|
6249
|
-
const
|
|
6250
|
-
|
|
6251
|
-
|
|
6252
|
-
|
|
6253
|
-
|
|
6254
|
-
|
|
6255
|
-
|
|
6256
|
-
|
|
6257
|
-
|
|
6258
|
-
|
|
6259
|
-
|
|
6260
|
-
|
|
6261
|
-
|
|
6262
|
-
|
|
6263
|
-
|
|
6264
|
-
|
|
6265
|
-
}
|
|
6266
|
-
|
|
6286
|
+
const handleResponse = async (response, fetchType) => {
|
|
6287
|
+
try {
|
|
6288
|
+
if (response.status === 304) {
|
|
6289
|
+
setLoadingState("idle");
|
|
6290
|
+
return;
|
|
6291
|
+
}
|
|
6292
|
+
if (!response.ok) {
|
|
6293
|
+
const errorResponse = await parseErrorResponse(response);
|
|
6294
|
+
void updateAfterError(errorResponse);
|
|
6295
|
+
return;
|
|
6296
|
+
}
|
|
6297
|
+
const result = await parseFetchResponse(response);
|
|
6298
|
+
if (result.type === "action") {
|
|
6299
|
+
void performAction(result.action, result.action.data);
|
|
6300
|
+
} else if (result.type === "exit") {
|
|
6301
|
+
dispatchEventAndComplete(result.result);
|
|
6302
|
+
} else {
|
|
6303
|
+
updateStep(result.step, result.etag, fetchType);
|
|
6267
6304
|
}
|
|
6305
|
+
} catch (error) {
|
|
6306
|
+
return completeWithError(error, "Error parsing fetch response", fetchType, response.status);
|
|
6268
6307
|
}
|
|
6269
|
-
return handleErrorResponse(response, fetchType);
|
|
6270
6308
|
};
|
|
6271
|
-
const
|
|
6309
|
+
const updateStep = (newStep, etag2, fetchType) => {
|
|
6272
6310
|
setStepAndEtag(newStep, etag2);
|
|
6273
|
-
setSubmitted(false);
|
|
6274
|
-
setLoadingState("idle");
|
|
6275
|
-
dispatchEvent("Dynamic Flow - Step Started", __spreadValues({ stepId: newStep.key }, newStep == null ? void 0 : newStep.analytics));
|
|
6276
|
-
};
|
|
6277
|
-
const updateStepAfterRefresh = (step34, etag2) => {
|
|
6278
|
-
setStepAndEtag(step34, etag2);
|
|
6279
6311
|
setLoadingState("idle");
|
|
6280
|
-
|
|
6312
|
+
if (fetchType === "submission") {
|
|
6313
|
+
setSubmitted(false);
|
|
6314
|
+
dispatchEvent("Dynamic Flow - Step Started", __spreadValues({
|
|
6315
|
+
stepId: newStep.id || newStep.key
|
|
6316
|
+
}, newStep == null ? void 0 : newStep.analytics));
|
|
6317
|
+
} else {
|
|
6318
|
+
dispatchEvent("Dynamic Flow - Step Refreshed", { status: "success" });
|
|
6319
|
+
}
|
|
6281
6320
|
};
|
|
6282
|
-
const
|
|
6283
|
-
if (
|
|
6284
|
-
|
|
6285
|
-
return;
|
|
6321
|
+
const updateAfterError = async (errorBody) => {
|
|
6322
|
+
if (errorBody.refreshFormUrl) {
|
|
6323
|
+
await performRefresh(errorBody.refreshFormUrl, combineModels2(models), etag);
|
|
6286
6324
|
}
|
|
6287
|
-
|
|
6288
|
-
|
|
6289
|
-
|
|
6290
|
-
|
|
6291
|
-
|
|
6292
|
-
}
|
|
6293
|
-
if (errorBody.validation) {
|
|
6294
|
-
setFormErrors(errorBody.validation);
|
|
6295
|
-
}
|
|
6296
|
-
if (errorBody.error) {
|
|
6297
|
-
setGlobalError(errorBody.error);
|
|
6298
|
-
}
|
|
6299
|
-
if (!errorBody.refreshFormUrl && !errorBody.validation && !errorBody.error) {
|
|
6300
|
-
logError(
|
|
6301
|
-
"Invalid response",
|
|
6302
|
-
"Response body must contain at least one of the following properties: refreshFormUrl, validation, or error."
|
|
6303
|
-
);
|
|
6304
|
-
throw errorBody;
|
|
6305
|
-
}
|
|
6306
|
-
} catch (error) {
|
|
6307
|
-
if (fetchType === "refresh") {
|
|
6308
|
-
dispatchEvent("Dynamic Flow - Step Refreshed", { status: "failure" });
|
|
6309
|
-
}
|
|
6310
|
-
dispatchEvent("Dynamic Flow - Flow Finished", { status: "failure" });
|
|
6311
|
-
onError(error, response.status);
|
|
6312
|
-
logError("Invalid response", "Error response body must be an object.");
|
|
6325
|
+
if (errorBody.validation) {
|
|
6326
|
+
setFormErrors(errorBody.validation);
|
|
6327
|
+
}
|
|
6328
|
+
if (errorBody.error) {
|
|
6329
|
+
setGlobalError(errorBody.error);
|
|
6313
6330
|
}
|
|
6314
6331
|
setLoadingState("idle");
|
|
6315
6332
|
};
|
|
6316
|
-
const
|
|
6333
|
+
const completeWithError = (error, message, fetchType, responseStatus) => {
|
|
6317
6334
|
logCritical("Error fetching", message);
|
|
6318
|
-
|
|
6335
|
+
if (fetchType === "refresh") {
|
|
6336
|
+
dispatchEvent("Dynamic Flow - Step Refreshed", { status: "failure" });
|
|
6337
|
+
}
|
|
6338
|
+
dispatchEvent("Dynamic Flow - Flow Finished", { status: "failure" });
|
|
6339
|
+
onError(error, responseStatus);
|
|
6319
6340
|
setLoadingState("idle");
|
|
6320
6341
|
};
|
|
6321
6342
|
const onModelChange = (onModelChangeProps) => {
|
|
@@ -6336,62 +6357,37 @@ var DynamicFlowComponent = ({
|
|
|
6336
6357
|
const refreshOnChangeIfNeeded = (props, updatedModels) => {
|
|
6337
6358
|
const { triggerSchema } = props;
|
|
6338
6359
|
if (shouldTriggerRefresh(props)) {
|
|
6339
|
-
const url = triggerSchema.refreshFormUrl || (
|
|
6340
|
-
|
|
6341
|
-
|
|
6360
|
+
const url = triggerSchema.refreshFormUrl || (step35 == null ? void 0 : step35.refreshFormUrl);
|
|
6361
|
+
if (url) {
|
|
6362
|
+
debouncedRefresh(url, combineModels2(updatedModels), etag, triggerSchema);
|
|
6363
|
+
}
|
|
6342
6364
|
}
|
|
6343
6365
|
};
|
|
6344
6366
|
const onAction = async (action2) => {
|
|
6345
|
-
|
|
6346
|
-
const submissionData = __spreadValues(__spreadValues({}, combineModels2(models)), data);
|
|
6347
|
-
const extraLoggingProps = {
|
|
6348
|
-
url: action2.url,
|
|
6349
|
-
method: action2.method,
|
|
6350
|
-
currency: submissionData.currency,
|
|
6351
|
-
type: submissionData.type
|
|
6352
|
-
};
|
|
6353
|
-
if (loadingState !== "idle" || action2.disabled) {
|
|
6354
|
-
logWarning(
|
|
6355
|
-
"Action supressed",
|
|
6356
|
-
loadingState !== "idle" ? `onAction was supressed because loadingState is ${loadingState}` : `onAction was supressed because action is disabled`,
|
|
6357
|
-
extraLoggingProps
|
|
6358
|
-
);
|
|
6367
|
+
if (isLoading || action2.disabled) {
|
|
6359
6368
|
return;
|
|
6360
6369
|
}
|
|
6361
|
-
if (
|
|
6362
|
-
|
|
6363
|
-
if (isSubmissionMethod(method)) {
|
|
6364
|
-
setFormErrors(null);
|
|
6365
|
-
setSubmitted(true);
|
|
6366
|
-
if (modelIsValid) {
|
|
6367
|
-
await fetchExitResult(action2, submissionData);
|
|
6368
|
-
}
|
|
6369
|
-
} else {
|
|
6370
|
-
await fetchExitResult(action2);
|
|
6371
|
-
}
|
|
6372
|
-
return;
|
|
6373
|
-
}
|
|
6374
|
-
dispatchEventAndComplete(result);
|
|
6370
|
+
if (action2.exit && !action2.url) {
|
|
6371
|
+
dispatchEventAndComplete(action2.result);
|
|
6375
6372
|
return;
|
|
6376
6373
|
}
|
|
6374
|
+
const actionHandler = action2.exit ? performExitAction : performAction;
|
|
6375
|
+
const { data, method } = action2;
|
|
6376
|
+
const submissionData = __spreadValues(__spreadValues({}, combineModels2(models)), data);
|
|
6377
6377
|
if (isSubmissionMethod(method)) {
|
|
6378
6378
|
setFormErrors(null);
|
|
6379
6379
|
setSubmitted(true);
|
|
6380
6380
|
if (modelIsValid) {
|
|
6381
|
-
|
|
6382
|
-
} else {
|
|
6383
|
-
dispatchEvent("Dynamic Flow - onAction supressed", __spreadValues({
|
|
6384
|
-
reason: "invalid model"
|
|
6385
|
-
}, extraLoggingProps));
|
|
6381
|
+
await actionHandler(action2, submissionData);
|
|
6386
6382
|
}
|
|
6387
|
-
|
|
6383
|
+
} else {
|
|
6384
|
+
await actionHandler(action2);
|
|
6388
6385
|
}
|
|
6389
|
-
void fetchNextStep(action2);
|
|
6390
6386
|
};
|
|
6391
|
-
return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(LogProvider, { flowId, stepId:
|
|
6387
|
+
return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(LogProvider, { flowId, stepId: (step35 == null ? void 0 : step35.id) || (step35 == null ? void 0 : step35.key), onLog, children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(EventsContextProvider, { metadata: analyticsMetadata, onEvent, children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(DynamicFlowProvider, { loading: isLoading, children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(HttpClientProvider, { httpClient, children: loader !== null ? loader : /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
|
|
6392
6388
|
DynamicFlowStep,
|
|
6393
6389
|
{
|
|
6394
|
-
step:
|
|
6390
|
+
step: step35,
|
|
6395
6391
|
model: combineModels2(models),
|
|
6396
6392
|
submitted,
|
|
6397
6393
|
globalError,
|
|
@@ -6442,11 +6438,9 @@ __export(components_exports, {
|
|
|
6442
6438
|
|
|
6443
6439
|
// src/fixtures/components/alert.ts
|
|
6444
6440
|
var step = {
|
|
6445
|
-
|
|
6446
|
-
key: "Components/Alert",
|
|
6441
|
+
id: "Components/Alert",
|
|
6447
6442
|
title: "Alert Component",
|
|
6448
6443
|
description: "Alerts can have different contexts.",
|
|
6449
|
-
actions: [],
|
|
6450
6444
|
schemas: [],
|
|
6451
6445
|
layout: [
|
|
6452
6446
|
{
|
|
@@ -6475,11 +6469,9 @@ var alert_default = step;
|
|
|
6475
6469
|
|
|
6476
6470
|
// src/fixtures/components/box.ts
|
|
6477
6471
|
var step2 = {
|
|
6478
|
-
|
|
6479
|
-
key: "Components/Box",
|
|
6472
|
+
id: "Components/Box",
|
|
6480
6473
|
title: "Box Component",
|
|
6481
6474
|
description: "Box is a container for other layour components. It can have a border!",
|
|
6482
|
-
actions: [],
|
|
6483
6475
|
schemas: [],
|
|
6484
6476
|
layout: ["xs", "sm", "md", "lg", "xl"].map((size) => ({
|
|
6485
6477
|
type: "box",
|
|
@@ -6509,11 +6501,9 @@ var buttons = ["primary", "secondary", "negative", "link"].map(
|
|
|
6509
6501
|
})
|
|
6510
6502
|
);
|
|
6511
6503
|
var step3 = {
|
|
6512
|
-
|
|
6513
|
-
key: "Components/Button",
|
|
6504
|
+
id: "Components/Button",
|
|
6514
6505
|
title: "Button Component",
|
|
6515
6506
|
description: "Buttons typically trigger actions.",
|
|
6516
|
-
actions: [],
|
|
6517
6507
|
schemas: [
|
|
6518
6508
|
{
|
|
6519
6509
|
$id: "#schema",
|
|
@@ -6555,11 +6545,9 @@ var button_default = step3;
|
|
|
6555
6545
|
|
|
6556
6546
|
// src/fixtures/components/columns.ts
|
|
6557
6547
|
var step4 = {
|
|
6558
|
-
|
|
6559
|
-
key: "Components/Columns",
|
|
6548
|
+
id: "Components/Columns",
|
|
6560
6549
|
title: "Columns Component",
|
|
6561
6550
|
description: `Arrange components in two columns (when there's enough space)`,
|
|
6562
|
-
actions: [],
|
|
6563
6551
|
schemas: [],
|
|
6564
6552
|
layout: [
|
|
6565
6553
|
{
|
|
@@ -6593,11 +6581,9 @@ var columns_default = step4;
|
|
|
6593
6581
|
|
|
6594
6582
|
// src/fixtures/components/copyable.ts
|
|
6595
6583
|
var step5 = {
|
|
6596
|
-
|
|
6597
|
-
type: "form",
|
|
6584
|
+
id: "Components/Copyable",
|
|
6598
6585
|
title: "Copyable Text",
|
|
6599
6586
|
description: "Copyable Text Component.",
|
|
6600
|
-
actions: [],
|
|
6601
6587
|
layout: [
|
|
6602
6588
|
{
|
|
6603
6589
|
type: "paragraph",
|
|
@@ -6617,11 +6603,9 @@ var copyable_default = step5;
|
|
|
6617
6603
|
|
|
6618
6604
|
// src/fixtures/components/decision.ts
|
|
6619
6605
|
var step6 = {
|
|
6620
|
-
|
|
6621
|
-
key: "Components/Decision",
|
|
6606
|
+
id: "Components/Decision",
|
|
6622
6607
|
title: "Decision Component",
|
|
6623
6608
|
description: "A step with a decision Component.",
|
|
6624
|
-
actions: [],
|
|
6625
6609
|
schemas: [],
|
|
6626
6610
|
layout: [
|
|
6627
6611
|
{
|
|
@@ -6684,11 +6668,9 @@ var decision_default = step6;
|
|
|
6684
6668
|
|
|
6685
6669
|
// src/fixtures/components/decision-flags.ts
|
|
6686
6670
|
var step7 = {
|
|
6687
|
-
|
|
6688
|
-
key: "Components/Decision Flags",
|
|
6671
|
+
id: "Components/Decision Flags",
|
|
6689
6672
|
title: "Decision Component",
|
|
6690
6673
|
description: "A step with a decision Component.",
|
|
6691
|
-
actions: [],
|
|
6692
6674
|
schemas: [],
|
|
6693
6675
|
layout: [
|
|
6694
6676
|
{
|
|
@@ -6715,11 +6697,9 @@ var decision_flags_default = step7;
|
|
|
6715
6697
|
// src/fixtures/components/decision-icons.ts
|
|
6716
6698
|
var icons2 = __toESM(require("@transferwise/icons"));
|
|
6717
6699
|
var step8 = {
|
|
6718
|
-
|
|
6719
|
-
key: "Components/Decision Icons",
|
|
6700
|
+
id: "Components/Decision Icons",
|
|
6720
6701
|
title: "Decision Component",
|
|
6721
6702
|
description: "A step with a decision Component.",
|
|
6722
|
-
actions: [],
|
|
6723
6703
|
schemas: [],
|
|
6724
6704
|
layout: [
|
|
6725
6705
|
{
|
|
@@ -6745,11 +6725,9 @@ var decision_icons_default = step8;
|
|
|
6745
6725
|
|
|
6746
6726
|
// src/fixtures/components/heading.ts
|
|
6747
6727
|
var step9 = {
|
|
6748
|
-
|
|
6749
|
-
key: "Components/Heading",
|
|
6728
|
+
id: "Components/Heading",
|
|
6750
6729
|
title: "Heading Component",
|
|
6751
6730
|
description: 'Headings can have different sizes: "xs", "sm", "md", "lg", "xl".',
|
|
6752
|
-
actions: [],
|
|
6753
6731
|
schemas: [],
|
|
6754
6732
|
layout: ["xs", "sm", "md", "lg", "xl"].map((size) => ({
|
|
6755
6733
|
type: "heading",
|
|
@@ -6762,11 +6740,9 @@ var heading_default = step9;
|
|
|
6762
6740
|
// src/fixtures/components/image.ts
|
|
6763
6741
|
var sizes = ["xs", "sm", "md", "lg", "xl"];
|
|
6764
6742
|
var step10 = {
|
|
6765
|
-
|
|
6766
|
-
key: "Components/Image",
|
|
6743
|
+
id: "Components/Image",
|
|
6767
6744
|
title: "Image Component",
|
|
6768
6745
|
description: 'Images can have different sizes: "xs", "sm", "md", "lg", "xl".',
|
|
6769
|
-
actions: [],
|
|
6770
6746
|
schemas: [],
|
|
6771
6747
|
layout: sizes.flatMap((size) => [
|
|
6772
6748
|
{
|
|
@@ -6776,7 +6752,7 @@ var step10 = {
|
|
|
6776
6752
|
},
|
|
6777
6753
|
{
|
|
6778
6754
|
type: "image",
|
|
6779
|
-
url: "
|
|
6755
|
+
url: "https://images.unsplash.com/photo-1542736705-53f0131d1e98?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=400&q=80",
|
|
6780
6756
|
text: `This is an image with size: "${size}"`,
|
|
6781
6757
|
size
|
|
6782
6758
|
}
|
|
@@ -6786,11 +6762,9 @@ var image_default = step10;
|
|
|
6786
6762
|
|
|
6787
6763
|
// src/fixtures/components/info.ts
|
|
6788
6764
|
var step11 = {
|
|
6789
|
-
|
|
6790
|
-
key: "Components/Info",
|
|
6765
|
+
id: "Components/Info",
|
|
6791
6766
|
title: "Info Component",
|
|
6792
6767
|
description: "A block of markdown content.",
|
|
6793
|
-
actions: [],
|
|
6794
6768
|
schemas: [],
|
|
6795
6769
|
layout: [
|
|
6796
6770
|
{
|
|
@@ -6821,11 +6795,9 @@ var info_default = step11;
|
|
|
6821
6795
|
|
|
6822
6796
|
// src/fixtures/components/list.ts
|
|
6823
6797
|
var step12 = {
|
|
6824
|
-
|
|
6825
|
-
key: "Components/List",
|
|
6798
|
+
id: "Components/List",
|
|
6826
6799
|
title: "List Component",
|
|
6827
6800
|
description: "A list of items with optional states, subtitles, and images.",
|
|
6828
|
-
actions: [],
|
|
6829
6801
|
schemas: [],
|
|
6830
6802
|
layout: [
|
|
6831
6803
|
{
|
|
@@ -6857,11 +6829,9 @@ var list_default = step12;
|
|
|
6857
6829
|
|
|
6858
6830
|
// src/fixtures/components/loading-indicator.ts
|
|
6859
6831
|
var step13 = {
|
|
6860
|
-
|
|
6861
|
-
key: "Components/Loading Indicator",
|
|
6832
|
+
id: "Components/Loading Indicator",
|
|
6862
6833
|
title: "Loading Indicator Component",
|
|
6863
6834
|
description: "A loading indicator to be displayed within a layout.",
|
|
6864
|
-
actions: [],
|
|
6865
6835
|
schemas: [],
|
|
6866
6836
|
layout: [
|
|
6867
6837
|
{
|
|
@@ -6875,11 +6845,9 @@ var loading_indicator_default = step13;
|
|
|
6875
6845
|
|
|
6876
6846
|
// src/fixtures/components/paragraph.ts
|
|
6877
6847
|
var step14 = {
|
|
6878
|
-
|
|
6879
|
-
key: "Components/Paragraph",
|
|
6848
|
+
id: "Components/Paragraph",
|
|
6880
6849
|
title: "Paragraph Component",
|
|
6881
6850
|
description: `A block of plain text.`,
|
|
6882
|
-
actions: [],
|
|
6883
6851
|
schemas: [],
|
|
6884
6852
|
layout: [
|
|
6885
6853
|
{
|
|
@@ -6905,11 +6873,9 @@ var paragraph_default = step14;
|
|
|
6905
6873
|
|
|
6906
6874
|
// src/fixtures/components/review.ts
|
|
6907
6875
|
var step15 = {
|
|
6908
|
-
|
|
6909
|
-
key: "Components/Review",
|
|
6876
|
+
id: "Components/Review",
|
|
6910
6877
|
title: "Review Component",
|
|
6911
6878
|
description: `Show a list of read-only fields.`,
|
|
6912
|
-
actions: [],
|
|
6913
6879
|
schemas: [],
|
|
6914
6880
|
layout: [
|
|
6915
6881
|
{
|
|
@@ -6977,9 +6943,8 @@ __export(examples_exports, {
|
|
|
6977
6943
|
|
|
6978
6944
|
// src/fixtures/examples/camera-capture.ts
|
|
6979
6945
|
var step16 = {
|
|
6980
|
-
|
|
6946
|
+
id: "Examples/Camera Capture",
|
|
6981
6947
|
title: "Camera Capture Example",
|
|
6982
|
-
type: "form",
|
|
6983
6948
|
schemas: [
|
|
6984
6949
|
{
|
|
6985
6950
|
properties: {
|
|
@@ -7100,11 +7065,9 @@ var camera_capture_default = step16;
|
|
|
7100
7065
|
|
|
7101
7066
|
// src/fixtures/examples/recipient.ts
|
|
7102
7067
|
var step17 = {
|
|
7103
|
-
|
|
7104
|
-
type: "form",
|
|
7068
|
+
id: "Examples/Recipient Creation",
|
|
7105
7069
|
title: "Recipient Creation Example",
|
|
7106
7070
|
description: "A form step with the typical recipient creation form.",
|
|
7107
|
-
actions: [],
|
|
7108
7071
|
schemas: [
|
|
7109
7072
|
{
|
|
7110
7073
|
$id: "#new-recipient",
|
|
@@ -7415,18 +7378,8 @@ var recipient_default = step17;
|
|
|
7415
7378
|
|
|
7416
7379
|
// src/fixtures/examples/recipient-update.ts
|
|
7417
7380
|
var step18 = {
|
|
7418
|
-
|
|
7419
|
-
type: "form",
|
|
7381
|
+
id: "Examples/Recipient Update",
|
|
7420
7382
|
title: "Edit recipient",
|
|
7421
|
-
actions: [
|
|
7422
|
-
{
|
|
7423
|
-
title: "Update",
|
|
7424
|
-
url: "/responses/recipientUpdate/?delay=5000",
|
|
7425
|
-
type: "primary",
|
|
7426
|
-
method: "PATCH",
|
|
7427
|
-
$id: "submit"
|
|
7428
|
-
}
|
|
7429
|
-
],
|
|
7430
7383
|
schemas: [
|
|
7431
7384
|
{
|
|
7432
7385
|
$id: "form",
|
|
@@ -7658,7 +7611,11 @@ var step18 = {
|
|
|
7658
7611
|
{
|
|
7659
7612
|
type: "button",
|
|
7660
7613
|
action: {
|
|
7661
|
-
$
|
|
7614
|
+
$id: "submit",
|
|
7615
|
+
title: "Update",
|
|
7616
|
+
url: "/responses/recipientUpdate/?delay=5000",
|
|
7617
|
+
type: "primary",
|
|
7618
|
+
method: "PATCH"
|
|
7662
7619
|
}
|
|
7663
7620
|
}
|
|
7664
7621
|
]
|
|
@@ -7667,10 +7624,8 @@ var recipient_update_default = step18;
|
|
|
7667
7624
|
|
|
7668
7625
|
// src/fixtures/examples/single-file-upload.ts
|
|
7669
7626
|
var step19 = {
|
|
7670
|
-
|
|
7671
|
-
type: "form",
|
|
7627
|
+
id: "Examples/Single File Upload",
|
|
7672
7628
|
title: "Single File Upload Example",
|
|
7673
|
-
actions: [],
|
|
7674
7629
|
schemas: [
|
|
7675
7630
|
{
|
|
7676
7631
|
$id: "#schema-1",
|
|
@@ -7767,9 +7722,8 @@ var single_file_upload_default = step19;
|
|
|
7767
7722
|
|
|
7768
7723
|
// src/fixtures/examples/step-validation-errors.ts
|
|
7769
7724
|
var step20 = {
|
|
7770
|
-
|
|
7725
|
+
id: "Examples/Step Validation Errors",
|
|
7771
7726
|
title: "Step with validation errors",
|
|
7772
|
-
type: "form",
|
|
7773
7727
|
errors: {
|
|
7774
7728
|
validation: {
|
|
7775
7729
|
"bridekeeper-questions": {
|
|
@@ -7777,7 +7731,6 @@ var step20 = {
|
|
|
7777
7731
|
}
|
|
7778
7732
|
}
|
|
7779
7733
|
},
|
|
7780
|
-
actions: [],
|
|
7781
7734
|
layout: [
|
|
7782
7735
|
{
|
|
7783
7736
|
type: "form",
|
|
@@ -7854,11 +7807,10 @@ __export(features_exports, {
|
|
|
7854
7807
|
|
|
7855
7808
|
// src/fixtures/features/action-response.ts
|
|
7856
7809
|
var step21 = {
|
|
7857
|
-
|
|
7810
|
+
id: "Features/Action Response",
|
|
7858
7811
|
title: "Action Response",
|
|
7859
7812
|
description: "",
|
|
7860
7813
|
type: "form",
|
|
7861
|
-
actions: [],
|
|
7862
7814
|
schemas: [],
|
|
7863
7815
|
layout: [
|
|
7864
7816
|
{
|
|
@@ -7886,7 +7838,7 @@ var action_response_default = step21;
|
|
|
7886
7838
|
// src/fixtures/features/external.ts
|
|
7887
7839
|
var step22 = {
|
|
7888
7840
|
type: "form",
|
|
7889
|
-
|
|
7841
|
+
id: "Features/External",
|
|
7890
7842
|
title: "External Feature",
|
|
7891
7843
|
description: "Your bank is opening in another window.",
|
|
7892
7844
|
external: { url: "http://google.com/" },
|
|
@@ -7911,15 +7863,13 @@ var step22 = {
|
|
|
7911
7863
|
markdown: `If it didn't work, you can [reopen](http://google.com/) the tab`
|
|
7912
7864
|
}
|
|
7913
7865
|
],
|
|
7914
|
-
actions: [],
|
|
7915
7866
|
schemas: []
|
|
7916
7867
|
};
|
|
7917
7868
|
var external_default = step22;
|
|
7918
7869
|
|
|
7919
7870
|
// src/fixtures/features/persist-async.ts
|
|
7920
7871
|
var step23 = {
|
|
7921
|
-
|
|
7922
|
-
key: "Features/Persist Async",
|
|
7872
|
+
id: "Features/Persist Async",
|
|
7923
7873
|
title: "Persist Async Feature",
|
|
7924
7874
|
schemas: [
|
|
7925
7875
|
{
|
|
@@ -7945,14 +7895,6 @@ var step23 = {
|
|
|
7945
7895
|
}
|
|
7946
7896
|
}
|
|
7947
7897
|
],
|
|
7948
|
-
actions: [
|
|
7949
|
-
{
|
|
7950
|
-
title: "Submit Persist Async",
|
|
7951
|
-
url: "/persist-async-submit",
|
|
7952
|
-
method: "POST",
|
|
7953
|
-
type: "primary"
|
|
7954
|
-
}
|
|
7955
|
-
],
|
|
7956
7898
|
layout: [
|
|
7957
7899
|
{
|
|
7958
7900
|
type: "form",
|
|
@@ -7964,8 +7906,7 @@ var persist_async_default = step23;
|
|
|
7964
7906
|
|
|
7965
7907
|
// src/fixtures/features/polling.ts
|
|
7966
7908
|
var step24 = {
|
|
7967
|
-
|
|
7968
|
-
key: "Features/Polling",
|
|
7909
|
+
id: "Features/Polling",
|
|
7969
7910
|
title: "Polling Feature",
|
|
7970
7911
|
description: "Polling feature in a form step.",
|
|
7971
7912
|
polling: {
|
|
@@ -7992,7 +7933,6 @@ var step24 = {
|
|
|
7992
7933
|
}
|
|
7993
7934
|
}
|
|
7994
7935
|
],
|
|
7995
|
-
actions: [],
|
|
7996
7936
|
schemas: []
|
|
7997
7937
|
};
|
|
7998
7938
|
var polling_default = step24;
|
|
@@ -8000,7 +7940,7 @@ var polling_default = step24;
|
|
|
8000
7940
|
// src/fixtures/features/validation-async.ts
|
|
8001
7941
|
var step25 = {
|
|
8002
7942
|
type: "form",
|
|
8003
|
-
|
|
7943
|
+
id: "Features/Validation Async",
|
|
8004
7944
|
title: "Validation Async Feature",
|
|
8005
7945
|
schemas: [
|
|
8006
7946
|
{
|
|
@@ -8030,7 +7970,6 @@ var step25 = {
|
|
|
8030
7970
|
}
|
|
8031
7971
|
}
|
|
8032
7972
|
],
|
|
8033
|
-
actions: [],
|
|
8034
7973
|
model: {
|
|
8035
7974
|
// name: 'Colin Robinson',
|
|
8036
7975
|
}
|
|
@@ -8304,29 +8243,9 @@ var list_default2 = layout3;
|
|
|
8304
8243
|
|
|
8305
8244
|
// src/fixtures/layouts/pay-in.ts
|
|
8306
8245
|
var step26 = {
|
|
8307
|
-
|
|
8246
|
+
id: "PAY_ID",
|
|
8308
8247
|
type: "form",
|
|
8309
8248
|
title: "Pay Using PayID",
|
|
8310
|
-
actions: [
|
|
8311
|
-
{
|
|
8312
|
-
title: "I have paid",
|
|
8313
|
-
type: "primary",
|
|
8314
|
-
exit: true,
|
|
8315
|
-
result: {
|
|
8316
|
-
paid: "POTENTIALLY_PAID"
|
|
8317
|
-
},
|
|
8318
|
-
$id: "#payNow"
|
|
8319
|
-
},
|
|
8320
|
-
{
|
|
8321
|
-
title: "I'll transfer my money later",
|
|
8322
|
-
type: "secondary",
|
|
8323
|
-
exit: true,
|
|
8324
|
-
result: {
|
|
8325
|
-
paid: "NOT_PAID"
|
|
8326
|
-
},
|
|
8327
|
-
$id: "#payLater"
|
|
8328
|
-
}
|
|
8329
|
-
],
|
|
8330
8249
|
schemas: [
|
|
8331
8250
|
{
|
|
8332
8251
|
title: "Pay Using PayID",
|
|
@@ -8388,13 +8307,25 @@ var step26 = {
|
|
|
8388
8307
|
{
|
|
8389
8308
|
type: "button",
|
|
8390
8309
|
action: {
|
|
8391
|
-
|
|
8310
|
+
title: "I have paid",
|
|
8311
|
+
type: "primary",
|
|
8312
|
+
exit: true,
|
|
8313
|
+
result: {
|
|
8314
|
+
paid: "POTENTIALLY_PAID"
|
|
8315
|
+
},
|
|
8316
|
+
$id: "#payNow"
|
|
8392
8317
|
}
|
|
8393
8318
|
},
|
|
8394
8319
|
{
|
|
8395
8320
|
type: "button",
|
|
8396
8321
|
action: {
|
|
8397
|
-
$
|
|
8322
|
+
$id: "#payLater",
|
|
8323
|
+
title: "I'll transfer my money later",
|
|
8324
|
+
type: "secondary",
|
|
8325
|
+
exit: true,
|
|
8326
|
+
result: {
|
|
8327
|
+
paid: "NOT_PAID"
|
|
8328
|
+
}
|
|
8398
8329
|
}
|
|
8399
8330
|
}
|
|
8400
8331
|
]
|
|
@@ -8646,11 +8577,9 @@ var action_default = action;
|
|
|
8646
8577
|
|
|
8647
8578
|
// src/fixtures/responses/action-response-final.ts
|
|
8648
8579
|
var step27 = {
|
|
8649
|
-
|
|
8650
|
-
key: "action-response-final",
|
|
8580
|
+
id: "action-response-final",
|
|
8651
8581
|
title: "Action Response Final Step",
|
|
8652
8582
|
description: `This step was loaded as a result of an Action Response.`,
|
|
8653
|
-
actions: [],
|
|
8654
8583
|
schemas: [],
|
|
8655
8584
|
layout: [
|
|
8656
8585
|
{
|
|
@@ -8676,11 +8605,9 @@ var exit_default = exit;
|
|
|
8676
8605
|
|
|
8677
8606
|
// src/fixtures/responses/recipient-update-final.ts
|
|
8678
8607
|
var step28 = {
|
|
8679
|
-
|
|
8680
|
-
key: "recipient-update-final",
|
|
8608
|
+
id: "recipient-update-final",
|
|
8681
8609
|
title: "Recipient Update Final Step",
|
|
8682
8610
|
description: `The recipient has been updated.`,
|
|
8683
|
-
actions: [],
|
|
8684
8611
|
schemas: [],
|
|
8685
8612
|
layout: [
|
|
8686
8613
|
{
|
|
@@ -8703,6 +8630,8 @@ var recipient_update_final_default = step28;
|
|
|
8703
8630
|
// src/fixtures/schemas/index.ts
|
|
8704
8631
|
var schemas_exports = {};
|
|
8705
8632
|
__export(schemas_exports, {
|
|
8633
|
+
allOf: () => all_of_default,
|
|
8634
|
+
boolean: () => boolean_default,
|
|
8706
8635
|
numberAndInteger: () => number_and_integer_default,
|
|
8707
8636
|
oneOf: () => one_of_default,
|
|
8708
8637
|
simpleForm: () => basic_form_default,
|
|
@@ -8711,11 +8640,9 @@ __export(schemas_exports, {
|
|
|
8711
8640
|
|
|
8712
8641
|
// src/fixtures/schemas/basic-form.ts
|
|
8713
8642
|
var step29 = {
|
|
8714
|
-
|
|
8643
|
+
id: "Schemas/Basic Form",
|
|
8715
8644
|
title: "Simple Form",
|
|
8716
8645
|
description: "A simple form with text fields and a checkbox.",
|
|
8717
|
-
type: "form",
|
|
8718
|
-
actions: [],
|
|
8719
8646
|
schemas: [
|
|
8720
8647
|
{
|
|
8721
8648
|
$id: "#the-schema",
|
|
@@ -8752,11 +8679,9 @@ var basic_form_default = step29;
|
|
|
8752
8679
|
|
|
8753
8680
|
// src/fixtures/schemas/number-and-integer.ts
|
|
8754
8681
|
var step30 = {
|
|
8755
|
-
|
|
8682
|
+
id: "Schemas/Number And Integer",
|
|
8756
8683
|
title: "Number and Integer Schemas",
|
|
8757
8684
|
description: "Number and Integer Schemas.",
|
|
8758
|
-
type: "form",
|
|
8759
|
-
actions: [],
|
|
8760
8685
|
schemas: [
|
|
8761
8686
|
{
|
|
8762
8687
|
$id: "#the-schema",
|
|
@@ -8857,12 +8782,10 @@ var currencies = [
|
|
|
8857
8782
|
["ZMW", "Zambian kwacha"]
|
|
8858
8783
|
];
|
|
8859
8784
|
var step31 = {
|
|
8860
|
-
|
|
8785
|
+
id: "Schemas/OneOf",
|
|
8861
8786
|
title: "OneOf Schemas",
|
|
8862
8787
|
description: "OneOf Schema using select, radio buttons and tabs.",
|
|
8863
|
-
type: "form",
|
|
8864
8788
|
analytics: { custom: "this is the oneOf fixture" },
|
|
8865
|
-
actions: [],
|
|
8866
8789
|
schemas: [
|
|
8867
8790
|
{
|
|
8868
8791
|
$id: "#the-schema",
|
|
@@ -9018,11 +8941,9 @@ var one_of_default = step31;
|
|
|
9018
8941
|
|
|
9019
8942
|
// src/fixtures/schemas/string-formats.ts
|
|
9020
8943
|
var step32 = {
|
|
9021
|
-
|
|
8944
|
+
id: "Schemas/String Formats",
|
|
9022
8945
|
title: "String Schema Formats",
|
|
9023
8946
|
description: "String schemas with different formats (password, date, telephone).",
|
|
9024
|
-
type: "form",
|
|
9025
|
-
actions: [],
|
|
9026
8947
|
schemas: [
|
|
9027
8948
|
{
|
|
9028
8949
|
$id: "#the-schema",
|
|
@@ -9080,19 +9001,140 @@ var step32 = {
|
|
|
9080
9001
|
};
|
|
9081
9002
|
var string_formats_default = step32;
|
|
9082
9003
|
|
|
9004
|
+
// src/fixtures/schemas/boolean.ts
|
|
9005
|
+
var step33 = {
|
|
9006
|
+
key: "Schemas/Boolean Schema",
|
|
9007
|
+
title: "Boolean Schema",
|
|
9008
|
+
description: "A simple form with a boolean schema with no default value.",
|
|
9009
|
+
actions: [],
|
|
9010
|
+
schemas: [
|
|
9011
|
+
{
|
|
9012
|
+
$id: "#schema-1",
|
|
9013
|
+
type: "object",
|
|
9014
|
+
displayOrder: ["pineapple"],
|
|
9015
|
+
required: ["pineapple"],
|
|
9016
|
+
properties: {
|
|
9017
|
+
pineapple: {
|
|
9018
|
+
title: "Pineapple on pizza (boolean schema)",
|
|
9019
|
+
type: "boolean"
|
|
9020
|
+
}
|
|
9021
|
+
}
|
|
9022
|
+
}
|
|
9023
|
+
],
|
|
9024
|
+
layout: [
|
|
9025
|
+
{
|
|
9026
|
+
type: "form",
|
|
9027
|
+
schema: { $ref: "#schema-1" }
|
|
9028
|
+
},
|
|
9029
|
+
{
|
|
9030
|
+
type: "button",
|
|
9031
|
+
action: {
|
|
9032
|
+
url: "/submit",
|
|
9033
|
+
title: "Submit",
|
|
9034
|
+
type: "primary"
|
|
9035
|
+
}
|
|
9036
|
+
}
|
|
9037
|
+
]
|
|
9038
|
+
};
|
|
9039
|
+
var boolean_default = step33;
|
|
9040
|
+
|
|
9041
|
+
// src/fixtures/schemas/all-of.ts
|
|
9042
|
+
var step34 = {
|
|
9043
|
+
key: "Schemas/AllOf",
|
|
9044
|
+
title: "AllOf Schemas",
|
|
9045
|
+
description: "Three object schemas wrapped in an allOf.",
|
|
9046
|
+
analytics: { custom: "this is the allOf fixture" },
|
|
9047
|
+
actions: [],
|
|
9048
|
+
schemas: [
|
|
9049
|
+
{
|
|
9050
|
+
$id: "#the-schema",
|
|
9051
|
+
allOf: [
|
|
9052
|
+
{
|
|
9053
|
+
$id: "#schema-1",
|
|
9054
|
+
type: "object",
|
|
9055
|
+
properties: {
|
|
9056
|
+
name: { title: "Name", type: "string" }
|
|
9057
|
+
},
|
|
9058
|
+
displayOrder: ["name"]
|
|
9059
|
+
},
|
|
9060
|
+
{
|
|
9061
|
+
$id: "#schema-2",
|
|
9062
|
+
type: "object",
|
|
9063
|
+
properties: {
|
|
9064
|
+
city: { title: "City", type: "string" }
|
|
9065
|
+
},
|
|
9066
|
+
displayOrder: ["city"]
|
|
9067
|
+
},
|
|
9068
|
+
{
|
|
9069
|
+
$id: "#schema-3",
|
|
9070
|
+
type: "object",
|
|
9071
|
+
properties: {
|
|
9072
|
+
color: {
|
|
9073
|
+
title: 'What is your favourite colour? (oneOf schema with more than two options default to control: "select")',
|
|
9074
|
+
placeholder: "Please select a colour",
|
|
9075
|
+
analyticsId: "colour-select",
|
|
9076
|
+
oneOf: [
|
|
9077
|
+
{
|
|
9078
|
+
title: "Blue",
|
|
9079
|
+
analyticsId: "colour-select-blue",
|
|
9080
|
+
image: {
|
|
9081
|
+
url: "https://placeholder.pics/svg/64/0099ff/FFFFFF"
|
|
9082
|
+
},
|
|
9083
|
+
const: 1
|
|
9084
|
+
},
|
|
9085
|
+
{
|
|
9086
|
+
title: "Yellow",
|
|
9087
|
+
analyticsId: "colour-select-yellow",
|
|
9088
|
+
image: {
|
|
9089
|
+
url: "https://placeholder.pics/svg/64/ffcc00/FFFFFF"
|
|
9090
|
+
},
|
|
9091
|
+
const: 2
|
|
9092
|
+
},
|
|
9093
|
+
{
|
|
9094
|
+
title: "Red",
|
|
9095
|
+
analyticsId: "colour-select-red",
|
|
9096
|
+
image: {
|
|
9097
|
+
url: "https://placeholder.pics/svg/64/ff6600/FFFFFF"
|
|
9098
|
+
},
|
|
9099
|
+
const: 3
|
|
9100
|
+
}
|
|
9101
|
+
]
|
|
9102
|
+
}
|
|
9103
|
+
},
|
|
9104
|
+
displayOrder: ["color"]
|
|
9105
|
+
}
|
|
9106
|
+
]
|
|
9107
|
+
}
|
|
9108
|
+
],
|
|
9109
|
+
layout: [
|
|
9110
|
+
{
|
|
9111
|
+
type: "form",
|
|
9112
|
+
schema: { $ref: "#the-schema" }
|
|
9113
|
+
},
|
|
9114
|
+
{
|
|
9115
|
+
type: "button",
|
|
9116
|
+
action: {
|
|
9117
|
+
url: "/submit",
|
|
9118
|
+
title: "Submit",
|
|
9119
|
+
type: "primary"
|
|
9120
|
+
}
|
|
9121
|
+
}
|
|
9122
|
+
]
|
|
9123
|
+
};
|
|
9124
|
+
var all_of_default = step34;
|
|
9125
|
+
|
|
9083
9126
|
// src/fixtures/utils/image-util.ts
|
|
9084
9127
|
var getImageStep = (size) => {
|
|
9085
9128
|
return {
|
|
9086
9129
|
type: "form",
|
|
9087
|
-
|
|
9130
|
+
id: `Components/Image-${size}`,
|
|
9088
9131
|
title: `Image Component - ${size}`,
|
|
9089
9132
|
description: `This is an image with size: "${size}"`,
|
|
9090
|
-
actions: [],
|
|
9091
9133
|
schemas: [],
|
|
9092
9134
|
layout: [
|
|
9093
9135
|
{
|
|
9094
9136
|
type: "image",
|
|
9095
|
-
url: "
|
|
9137
|
+
url: "https://images.unsplash.com/photo-1542736705-53f0131d1e98?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=400&q=80",
|
|
9096
9138
|
text: `This is an image with size: "${size}"`,
|
|
9097
9139
|
size
|
|
9098
9140
|
}
|