@wise/dynamic-flow-client 1.1.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/main.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(step33, { displayStepTitle = true } = {}) {
545
- if (!step33 || !step33.type) {
546
- throw new Error("Missing step type");
544
+ function convertStepToLayout(step35, { displayStepTitle = true } = {}) {
545
+ if (step35.layout) {
546
+ return addMissingTitleAndDescriptionToStep(step35, displayStepTitle);
547
547
  }
548
- if (step33.layout) {
549
- return addMissingTitleAndDescriptionToStep(step33, displayStepTitle);
550
- }
551
- switch (step33.type) {
548
+ switch (step35.type) {
552
549
  case "final":
553
- return convertFinalStepToDynamicLayout(step33);
550
+ return convertFinalStepToDynamicLayout(step35);
554
551
  case "decision":
555
- return convertDecisionStepToDynamicLayout(step33);
556
- case "form":
557
- return convertFormStepToDynamicLayout(step33);
552
+ return convertDecisionStepToDynamicLayout(step35);
558
553
  case "external":
559
- return convertExternalStepToDynamicLayout(step33);
554
+ return convertExternalStepToDynamicLayout(step35);
560
555
  default:
561
- throw new Error("invalid step type");
556
+ return convertFormStepToDynamicLayout(step35);
562
557
  }
563
558
  }
564
- function convertCommonComponents(step33) {
559
+ function convertCommonComponents(step35) {
565
560
  const layout6 = [];
566
- if (step33.title) {
567
- layout6.push(convertStepTitleToDynamicHeading(step33.title));
561
+ if (step35.title) {
562
+ layout6.push(convertStepTitleToDynamicHeading(step35.title));
568
563
  }
569
- if (step33.image) {
570
- const image = convertStepImageToDynamicImage(step33.image);
564
+ if (step35.image) {
565
+ const image = convertStepImageToDynamicImage(step35.image);
571
566
  layout6.push(image);
572
567
  }
573
- if (step33.description) {
574
- layout6.push(convertStepDescriptionToDynamicParagraph(step33.description));
568
+ if (step35.description) {
569
+ layout6.push(convertStepDescriptionToDynamicParagraph(step35.description));
575
570
  }
576
571
  return layout6;
577
572
  }
578
- function convertExternalStepToDynamicLayout(step33) {
579
- return [...convertCommonComponents(step33), convertStepToExternalComponent(step33)];
573
+ function convertExternalStepToDynamicLayout(step35) {
574
+ return [...convertCommonComponents(step35), convertStepToExternalComponent(step35)];
580
575
  }
581
- function convertStepToExternalComponent(step33) {
576
+ function convertStepToExternalComponent(step35) {
582
577
  return {
583
578
  type: "external",
584
- requestUrl: step33.requestUrl,
585
- polling: step33.polling,
586
- responseHandlers: step33.responseHandlers,
587
- retryTitle: step33.retryTitle
579
+ requestUrl: step35.requestUrl,
580
+ polling: step35.polling,
581
+ responseHandlers: step35.responseHandlers,
582
+ retryTitle: step35.retryTitle
588
583
  };
589
584
  }
590
- function convertFormStepToDynamicLayout(step33) {
591
- const layout6 = convertCommonComponents(step33);
592
- if (step33.reviewFields) {
593
- layout6.push(convertStepReviewToDynamicReview(step33.reviewFields));
585
+ function convertFormStepToDynamicLayout(step35) {
586
+ const layout6 = convertCommonComponents(step35);
587
+ if (step35.reviewFields) {
588
+ layout6.push(convertStepReviewToDynamicReview(step35.reviewFields));
594
589
  }
595
- if (step33.schemas) {
596
- layout6.push(...getSchemaLayout(step33));
590
+ if (step35.schemas) {
591
+ layout6.push(...getSchemaLayout(step35));
597
592
  }
598
- if (step33.actions) {
599
- const actions = step33.actions.map(convertStepActionToDynamicAction);
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(step33) {
599
+ function convertFinalStepToDynamicLayout(step35) {
605
600
  const layout6 = [];
606
- if (step33.details) {
607
- if (step33.details.image) {
608
- const image = convertFinalStepImageToDynamicImage(step33.details.image);
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 (step33.details.title) {
612
- layout6.push(convertStepTitleToDynamicHeading(step33.details.title));
606
+ if (step35.details.title) {
607
+ layout6.push(convertStepTitleToDynamicHeading(step35.details.title));
613
608
  }
614
- if (step33.details.description) {
615
- layout6.push(convertStepDescriptionToDynamicParagraph(step33.details.description));
609
+ if (step35.details.description) {
610
+ layout6.push(convertStepDescriptionToDynamicParagraph(step35.details.description));
616
611
  }
617
612
  }
618
- if (step33.actions) {
619
- const actions = step33.actions.map(
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(step33) {
627
- const layout6 = convertCommonComponents(step33);
628
- if (step33.options) {
629
- layout6.push(convertStepDecisionToDynamicDecision(step33.options));
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(step33) {
710
+ function getSchemaLayout(step35) {
716
711
  const layout6 = [];
717
- if (step33.schemas && step33.schemas[0]) {
718
- const schema2 = step33.schemas[0];
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(step33, displayStepTitle) {
726
+ function addMissingTitleAndDescriptionToStep(step35, displayStepTitle) {
732
727
  return [
733
- ...displayStepTitle && step33.title ? [convertStepTitleToDynamicHeading(step33.title)] : [],
734
- ...step33.description ? [convertStepDescriptionToDynamicParagraph(step33.description)] : [],
735
- ...step33.layout || []
728
+ ...displayStepTitle && step35.title ? [convertStepTitleToDynamicHeading(step35.title)] : [],
729
+ ...step35.description ? [convertStepDescriptionToDynamicParagraph(step35.description)] : [],
730
+ ...step35.layout || []
736
731
  ];
737
732
  }
738
733
 
@@ -844,7 +839,7 @@ function isReference(block) {
844
839
  }
845
840
 
846
841
  // src/dynamicFlow/DynamicFlow.tsx
847
- var import_react35 = require("react");
842
+ var import_react38 = require("react");
848
843
  var import_react_intl28 = require("react-intl");
849
844
 
850
845
  // src/common/contexts/dynamicFlowContexts/DynamicFlowContexts.tsx
@@ -1711,23 +1706,19 @@ function shouldDebounceSchema(schema2) {
1711
1706
  }
1712
1707
 
1713
1708
  // src/common/utils/step-utils.ts
1714
- var stepType = {
1715
- LAYOUT: "layout",
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 = (step33) => (step33 == null ? void 0 : step33.type) === "form";
1722
- var hasSingleAction = (step33) => {
1712
+ var isFormStep = (step35) => !step35.type || step35.type === "form";
1713
+ var hasSingleAction = (step35) => {
1723
1714
  var _a;
1724
- return ((_a = step33 == null ? void 0 : step33.actions) == null ? void 0 : _a.length) === 1;
1715
+ return ((_a = step35 == null ? void 0 : step35.actions) == null ? void 0 : _a.length) === 1;
1725
1716
  };
1726
- var hasSingleFileUploadSchemaWithCameraOnly = (step33) => {
1727
- if (!step33.schemas) {
1717
+ var hasSingleFileUploadSchemaWithCameraOnly = (step35) => {
1718
+ if (!step35.schemas) {
1728
1719
  return false;
1729
1720
  }
1730
- const schemas = filterHiddenSchemas(step33.schemas);
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) {
@@ -1836,7 +1821,7 @@ function useExternalStepPolling(polling, onAction) {
1836
1821
  }
1837
1822
 
1838
1823
  // src/common/hooks/usePersistAsync/usePersistAsync.ts
1839
- var import_react23 = require("react");
1824
+ var import_react26 = require("react");
1840
1825
  var import_react_intl16 = require("react-intl");
1841
1826
 
1842
1827
  // src/jsonSchemaForm/persistAsyncSchema/PersistAsyncSchema.messages.js
@@ -1850,7 +1835,7 @@ var PersistAsyncSchema_messages_default = (0, import_react_intl.defineMessages)(
1850
1835
  });
1851
1836
 
1852
1837
  // src/jsonSchemaForm/persistAsyncSchema/persistAsyncBasicSchema/PersistAsyncBasicSchema.tsx
1853
- var import_react22 = require("react");
1838
+ var import_react25 = require("react");
1854
1839
  var import_react_intl15 = require("react-intl");
1855
1840
 
1856
1841
  // src/fixtures/jsonSchemaForm/allOf.ts
@@ -1976,7 +1961,7 @@ var allOf_default = schema;
1976
1961
 
1977
1962
  // src/jsonSchemaForm/basicTypeSchema/BasicTypeSchema.tsx
1978
1963
  var import_classnames6 = __toESM(require_classnames());
1979
- var import_react21 = require("react");
1964
+ var import_react24 = require("react");
1980
1965
 
1981
1966
  // src/layout/alert/DynamicAlert.tsx
1982
1967
  var import_components = require("@transferwise/components");
@@ -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 { type, priority } = getButtonTypeAndPriority(componentAction);
2136
+ const type = getButtonType(component);
2137
+ const priority = getButtonPriority(component);
2109
2138
  const { loading } = useDynamicFlow();
2110
- const className = getMarginBottom(component.margin || "md") + " " + getActionClasses(componentAction);
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
@@ -2295,6 +2292,9 @@ var DynamicExternal = ({ component, onAction }) => {
2295
2292
  };
2296
2293
  var DynamicExternal_default = DynamicExternal;
2297
2294
 
2295
+ // src/jsonSchemaForm/genericSchema/GenericSchema.tsx
2296
+ var import_react20 = require("react");
2297
+
2298
2298
  // src/jsonSchemaForm/allOfSchema/AllOfSchema.tsx
2299
2299
  var import_classnames = __toESM(require_classnames());
2300
2300
  var import_react10 = require("react");
@@ -2789,7 +2789,7 @@ var ObjectSchema_default = ObjectSchema3;
2789
2789
 
2790
2790
  // src/jsonSchemaForm/oneOfSchema/OneOfSchema.tsx
2791
2791
  var import_classnames4 = __toESM(require_classnames());
2792
- var import_react14 = require("react");
2792
+ var import_react15 = require("react");
2793
2793
 
2794
2794
  // src/jsonSchemaForm/help/Help.tsx
2795
2795
  var import_components7 = require("@transferwise/components");
@@ -2822,6 +2822,9 @@ var Help = (props) => {
2822
2822
  };
2823
2823
  var Help_default = Help;
2824
2824
 
2825
+ // src/jsonSchemaForm/schemaFormControl/SchemaFormControl.tsx
2826
+ var import_react14 = require("react");
2827
+
2825
2828
  // src/formControl/FormControl.tsx
2826
2829
  var import_components8 = require("@transferwise/components");
2827
2830
  var import_react13 = require("react");
@@ -2994,7 +2997,7 @@ var _FormControl = class extends import_react13.PureComponent {
2994
2997
  const {
2995
2998
  name,
2996
2999
  placeholder,
2997
- step: step33,
3000
+ step: step35,
2998
3001
  countryCode,
2999
3002
  type,
3000
3003
  options,
@@ -3102,7 +3105,7 @@ var _FormControl = class extends import_react13.PureComponent {
3102
3105
  placeholder,
3103
3106
  readOnly,
3104
3107
  required,
3105
- step: step33,
3108
+ step: step35,
3106
3109
  type: "number",
3107
3110
  value: getSafeStringOrNumberValue(value, { coerceValue: true }),
3108
3111
  onBlur: this.handleOnBlur,
@@ -3524,16 +3527,12 @@ var import_jsx_runtime24 = require("react/jsx-runtime");
3524
3527
  var isNativeInput = (propsSchemaType) => {
3525
3528
  return propsSchemaType === "string" || propsSchemaType === "number";
3526
3529
  };
3527
- var getControlType = (schema2, log) => {
3530
+ var getControlType = (schema2) => {
3528
3531
  if (isOneOfSchema(schema2)) {
3529
3532
  if (schema2.control === FormControlType.TAB && schema2.oneOf.length > 3) {
3530
3533
  return FormControlType.SELECT;
3531
3534
  }
3532
3535
  if (schema2.oneOf.length === 2 && !schema2.control) {
3533
- log.warning(
3534
- "Deprecation warning",
3535
- 'A oneOf schema with 2 options and no control type currently renders as a "radio" but will be changed to render as a "select". Please specify control radio to retain the existing behaviour.'
3536
- );
3537
3536
  return FormControlType.RADIO;
3538
3537
  }
3539
3538
  return schema2.control || FormControlType.SELECT;
@@ -3570,40 +3569,35 @@ var getOptions = (schema2, controlType) => {
3570
3569
  return null;
3571
3570
  };
3572
3571
  var SchemaFormControl = (props) => {
3572
+ const { id, schema: schema2, value, disabled, onChange, onFocus, onBlur, onSearchChange } = props;
3573
3573
  const log = useLogger();
3574
- const getSanitisedValue = (value) => isNativeInput(props.schema.type) && (isNull(value) || isUndefined(value)) ? "" : value;
3575
- const onChange = (value, type) => {
3576
- props.onChange(getValidBasicModelOrNull(value, props.schema), type);
3574
+ const getSanitisedValue = (value2) => isNativeInput(schema2.type) && (isNull(value2) || isUndefined(value2)) ? "" : value2;
3575
+ const onModelChange = (value2, type) => {
3576
+ onChange(getValidBasicModelOrNull(value2, schema2), type);
3577
3577
  };
3578
- const controlType = getControlType(props.schema, log);
3579
- if (controlType === "file") {
3580
- log.warning(
3581
- "Deprecation warning",
3582
- "Please use a persist-async blob schema instead of string with base64url for file uploads. The base64url does not perform well on low end devices. Support for this schema will be removed in a later release."
3583
- );
3584
- }
3585
- if (props.schema.values) {
3586
- log.error("Deprecated schema", "Schema.values is a legacy approach. Please use oneOf.");
3587
- }
3588
- const options = props.schema.values || getOptions(props.schema, controlType);
3578
+ const controlType = getControlType(schema2);
3579
+ (0, import_react14.useEffect)(() => {
3580
+ warnIfInvalidSchema(schema2, log, controlType);
3581
+ }, [schema2, log, controlType]);
3582
+ const options = schema2.values || getOptions(schema2, controlType);
3589
3583
  const events = {
3590
- onFocus: props.onFocus,
3591
- onBlur: props.onBlur,
3592
- onSearchChange: props.onSearchChange,
3593
- onChange
3584
+ onFocus,
3585
+ onBlur,
3586
+ onSearchChange,
3587
+ onChange: onModelChange
3594
3588
  };
3595
- const safeValue = getSanitisedValue(props.value);
3589
+ const safeValue = getSanitisedValue(value);
3596
3590
  const controlProps = {
3597
- id: props.id,
3598
- name: props.id,
3599
- label: props.schema.title,
3591
+ id,
3592
+ name: id,
3593
+ label: schema2.title,
3600
3594
  options: options || [],
3601
- placeholder: props.schema.placeholder,
3602
- autoComplete: !props.schema.help,
3603
- disabled: props.disabled || props.schema.disabled,
3604
- displayPattern: props.schema.displayFormat,
3595
+ placeholder: schema2.placeholder,
3596
+ autoComplete: !schema2.help,
3597
+ disabled: disabled || schema2.disabled,
3598
+ displayPattern: schema2.displayFormat,
3605
3599
  // TODO: LOW avoid type assertion below
3606
- uploadProps: mapSchemaToUploadOptions(props.schema)
3600
+ uploadProps: mapSchemaToUploadOptions(schema2)
3607
3601
  };
3608
3602
  return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(FormControl, __spreadValues(__spreadValues({ type: controlType, value: safeValue }, events), controlProps));
3609
3603
  };
@@ -3614,6 +3608,23 @@ SchemaFormControl.defaultProps = {
3614
3608
  onSearchChange: null,
3615
3609
  disabled: false
3616
3610
  };
3611
+ var warnIfInvalidSchema = (schema2, log, controlType) => {
3612
+ if (isOneOfSchema(schema2) && schema2.oneOf.length === 2 && !schema2.control) {
3613
+ log.warning(
3614
+ "Deprecation warning",
3615
+ 'A oneOf schema with 2 options and no control type currently renders as a "radio" but will be changed to render as a "select". Please specify control radio to retain the existing behaviour.'
3616
+ );
3617
+ }
3618
+ if (controlType === "file") {
3619
+ log.warning(
3620
+ "Deprecation warning",
3621
+ "Please use a persist-async blob schema instead of string with base64url for file uploads. The base64url does not perform well on low end devices. Support for this schema will be removed in a later release."
3622
+ );
3623
+ }
3624
+ if (schema2.values) {
3625
+ log.warning("Deprecated schema", "Schema.values is a legacy approach. Please use oneOf.");
3626
+ }
3627
+ };
3617
3628
  var SchemaFormControl_default = SchemaFormControl;
3618
3629
 
3619
3630
  // src/jsonSchemaForm/oneOfSchema/utils/const-schema-utils.ts
@@ -3679,14 +3690,14 @@ function getSchemaProperties(childSchema) {
3679
3690
  var import_jsx_runtime25 = require("react/jsx-runtime");
3680
3691
  var OneOfSchema5 = (props) => {
3681
3692
  const onEvent = useEventDispatcher();
3682
- const [changed, setChanged] = (0, import_react14.useState)(false);
3683
- const [focused, setFocused] = (0, import_react14.useState)(false);
3684
- const [blurred, setBlurred] = (0, import_react14.useState)(false);
3685
- const id = (0, import_react14.useMemo)(() => props.schema.$id || generateRandomId(), [props.schema.$id]);
3686
- const [schemaIndex, setSchemaIndex] = (0, import_react14.useState)(
3693
+ const [changed, setChanged] = (0, import_react15.useState)(false);
3694
+ const [focused, setFocused] = (0, import_react15.useState)(false);
3695
+ const [blurred, setBlurred] = (0, import_react15.useState)(false);
3696
+ const id = (0, import_react15.useMemo)(() => props.schema.$id || generateRandomId(), [props.schema.$id]);
3697
+ const [schemaIndex, setSchemaIndex] = (0, import_react15.useState)(
3687
3698
  getActiveSchemaIndex(props.schema, props.model)
3688
3699
  );
3689
- const [models, setModels] = (0, import_react14.useState)(getModelPartsForSchemas(props.model, props.schema.oneOf));
3700
+ const [models, setModels] = (0, import_react15.useState)(getModelPartsForSchemas(props.model, props.schema.oneOf));
3690
3701
  const debouncedTrackEvent = useDebouncedFunction(onEvent, 200);
3691
3702
  const onSearchChange = (searchValue) => {
3692
3703
  debouncedTrackEvent("Dynamic Flow - OneOf Searched", {
@@ -3694,7 +3705,7 @@ var OneOfSchema5 = (props) => {
3694
3705
  searchValueLength: searchValue.length
3695
3706
  });
3696
3707
  };
3697
- (0, import_react14.useEffect)(() => {
3708
+ (0, import_react15.useEffect)(() => {
3698
3709
  const modelIndex = getValidIndexFromValue(props.schema, props.model);
3699
3710
  const defaultIndex = getValidIndexFromValue(props.schema, props.schema.default);
3700
3711
  if (modelIndex === -1 && defaultIndex >= 0) {
@@ -3844,11 +3855,11 @@ var OneOfSchema_default = OneOfSchema5;
3844
3855
 
3845
3856
  // src/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/PersistAsyncBlobSchema.tsx
3846
3857
  var import_classnames5 = __toESM(require_classnames());
3847
- var import_react16 = require("react");
3858
+ var import_react17 = require("react");
3848
3859
 
3849
3860
  // src/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/UploadInputAdapter.tsx
3850
3861
  var import_components10 = require("@transferwise/components");
3851
- var import_react15 = require("react");
3862
+ var import_react16 = require("react");
3852
3863
  var import_jsx_runtime26 = require("react/jsx-runtime");
3853
3864
  var UploadInputAdapter = (props) => {
3854
3865
  const {
@@ -3865,7 +3876,7 @@ var UploadInputAdapter = (props) => {
3865
3876
  onCancel
3866
3877
  } = props;
3867
3878
  const onEvent = useEventDispatcher();
3868
- const files = (0, import_react15.useMemo)(() => fileId ? [{ id: fileId, status: import_components10.Status.SUCCEEDED }] : [], [fileId]);
3879
+ const files = (0, import_react16.useMemo)(() => fileId ? [{ id: fileId, status: import_components10.Status.SUCCEEDED }] : [], [fileId]);
3869
3880
  const uploadFile = (formData) => {
3870
3881
  onEvent("Dynamic Flow - PersistAsync", { status: "pending", schemaId: id });
3871
3882
  return httpClient(`${httpOptions.url}`, {
@@ -3905,10 +3916,10 @@ var UploadInputAdapter = (props) => {
3905
3916
  // src/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/PersistAsyncBlobSchema.tsx
3906
3917
  var import_jsx_runtime27 = require("react/jsx-runtime");
3907
3918
  var PersistAsyncBlobSchema = (props) => {
3908
- const [persistAsyncValidationMessages, setPersistAsyncValidationMessages] = (0, import_react16.useState)({});
3909
- const [persistAsyncValidations, setPersistAsyncValidations] = (0, import_react16.useState)(null);
3910
- const [validations, setValidations] = (0, import_react16.useState)([]);
3911
- const [changed, setChanged] = (0, import_react16.useState)(false);
3919
+ const [persistAsyncValidationMessages, setPersistAsyncValidationMessages] = (0, import_react17.useState)({});
3920
+ const [persistAsyncValidations, setPersistAsyncValidations] = (0, import_react17.useState)(null);
3921
+ const [validations, setValidations] = (0, import_react17.useState)([]);
3922
+ const [changed, setChanged] = (0, import_react17.useState)(false);
3912
3923
  const httpClient = useHttpClient();
3913
3924
  const onEvent = useEventDispatcher();
3914
3925
  const refreshValidations = () => {
@@ -3916,7 +3927,7 @@ var PersistAsyncBlobSchema = (props) => {
3916
3927
  setValidations(getValidationFailures(props.model, props.schema, !!props.required));
3917
3928
  }
3918
3929
  };
3919
- (0, import_react16.useEffect)(refreshValidations, [props.model, props.submitted]);
3930
+ (0, import_react17.useEffect)(refreshValidations, [props.model, props.submitted]);
3920
3931
  const onSuccess = async (httpResponse, _fileName) => {
3921
3932
  const jsonResponse = await httpResponse.json();
3922
3933
  const id = getIdFromResponse(props.schema.persistAsync.idProperty, jsonResponse);
@@ -4005,7 +4016,7 @@ PersistAsyncSchema.defaultProps = {
4005
4016
  var PersistAsyncSchema_default = PersistAsyncSchema;
4006
4017
 
4007
4018
  // src/jsonSchemaForm/promotedOneOfSchema/PromotedOneOfSchema.tsx
4008
- var import_react17 = require("react");
4019
+ var import_react18 = require("react");
4009
4020
 
4010
4021
  // src/jsonSchemaForm/promotedOneOfSchema/promoted-one-of-utils.ts
4011
4022
  var getSelectionFromModel = (schema2, model) => {
@@ -4096,7 +4107,7 @@ var import_jsx_runtime32 = require("react/jsx-runtime");
4096
4107
  var isPromoted = (schema2) => schema2.promoted === true;
4097
4108
  var PromotedOneOfSchema = (props) => {
4098
4109
  var _a;
4099
- const [selection, setSelection] = (0, import_react17.useState)(
4110
+ const [selection, setSelection] = (0, import_react18.useState)(
4100
4111
  getSelectionFromModel(props.schema, props.model) || ((_a = props.schema.promotion) == null ? void 0 : _a.default) || "promoted"
4101
4112
  );
4102
4113
  const promotedAlert = props.schema.alert;
@@ -4212,32 +4223,35 @@ function getValueFromOption(option) {
4212
4223
  }
4213
4224
 
4214
4225
  // src/jsonSchemaForm/validationAsyncSchema/ValidationAsyncSchema.tsx
4215
- var import_react18 = require("react");
4226
+ var import_react19 = require("react");
4216
4227
  var import_jsx_runtime34 = require("react/jsx-runtime");
4217
4228
  var ValidationAsyncSchema = (props) => {
4218
- const [validationAsyncModel, setValidationAsyncModel] = (0, import_react18.useState)(props.model);
4219
- const previousRequestedModelReference = (0, import_react18.useRef)(null);
4220
- const [validationAsyncSuccessMessage, setValidationAsyncSuccessMessage] = (0, import_react18.useState)(
4229
+ const { schema: schema2, model, required, submitted, errors, onChange } = props;
4230
+ const [validationAsyncModel, setValidationAsyncModel] = (0, import_react19.useState)(model);
4231
+ const previousRequestedModelReference = (0, import_react19.useRef)(null);
4232
+ const [validationAsyncSuccessMessage, setValidationAsyncSuccessMessage] = (0, import_react19.useState)(
4221
4233
  null
4222
4234
  );
4223
- const [validationAsyncErrors, setValidationAsyncErrors] = (0, import_react18.useState)(null);
4224
- const [fieldSubmitted, setFieldSubmitted] = (0, import_react18.useState)(false);
4225
- const [abortController, setAbortController] = (0, import_react18.useState)(null);
4235
+ const [validationAsyncErrors, setValidationAsyncErrors] = (0, import_react19.useState)(null);
4236
+ const [fieldSubmitted, setFieldSubmitted] = (0, import_react19.useState)(false);
4237
+ const [abortController, setAbortController] = (0, import_react19.useState)(null);
4226
4238
  const httpClient = useHttpClient();
4227
4239
  const onEvent = useEventDispatcher();
4228
- const logger = useLogger();
4229
- const getValidationAsyncResponse = async (currentValidationAsyncModel, validationAsyncSpec) => {
4230
- const signal = abortCurrentRequestAndGetNewAbortSignal();
4231
- const requestBody = { [validationAsyncSpec.param]: currentValidationAsyncModel };
4232
- previousRequestedModelReference.current = currentValidationAsyncModel;
4233
- setFieldSubmitted(true);
4234
- if (!validationAsyncSpec.method) {
4235
- logger.warning(
4240
+ const log = useLogger();
4241
+ (0, import_react19.useEffect)(() => {
4242
+ if (!schema2.validationAsync.method) {
4243
+ log.warning(
4236
4244
  "Invalid schema or model",
4237
4245
  'ValidationAsyncSchema without a "method" property would have defaulted to "GET" in previous versions. Now defaults to "POST".',
4238
4246
  {}
4239
4247
  );
4240
4248
  }
4249
+ }, [log, schema2.validationAsync.method]);
4250
+ const getValidationAsyncResponse = async (currentValidationAsyncModel, validationAsyncSpec) => {
4251
+ const signal = abortCurrentRequestAndGetNewAbortSignal();
4252
+ const requestBody = { [validationAsyncSpec.param]: currentValidationAsyncModel };
4253
+ previousRequestedModelReference.current = currentValidationAsyncModel;
4254
+ setFieldSubmitted(true);
4241
4255
  onEvent("Dynamic Flow - ValidationAsync", { status: "pending" });
4242
4256
  const response = await httpClient(validationAsyncSpec.url, {
4243
4257
  method: validationAsyncSpec.method || "POST",
@@ -4272,29 +4286,29 @@ var ValidationAsyncSchema = (props) => {
4272
4286
  };
4273
4287
  const onBlur = () => {
4274
4288
  if (!isNull(validationAsyncModel) && !isEqual(validationAsyncModel, previousRequestedModelReference.current)) {
4275
- void getValidationAsyncResponse(validationAsyncModel, props.schema.validationAsync);
4289
+ void getValidationAsyncResponse(validationAsyncModel, schema2.validationAsync);
4276
4290
  }
4277
4291
  };
4278
- const validationAsyncOnChange = (parameters) => {
4279
- props.onChange(__spreadProps(__spreadValues({}, parameters), {
4280
- triggerSchema: props.schema,
4292
+ const onValidationAsyncChange = (parameters) => {
4293
+ onChange(__spreadProps(__spreadValues({}, parameters), {
4294
+ triggerSchema: schema2,
4281
4295
  triggerModel: parameters.model
4282
4296
  }));
4283
4297
  setValidationAsyncErrors(null);
4284
4298
  setValidationAsyncSuccessMessage(null);
4285
- if (isValidSchema(parameters.model, props.schema)) {
4299
+ if (isValidSchema(parameters.model, schema2)) {
4286
4300
  setValidationAsyncModel(parameters.model);
4287
4301
  }
4288
4302
  };
4289
4303
  const basicTypeSchemaProps = {
4290
- required: props.required,
4291
- submitted: props.submitted || fieldSubmitted,
4292
- schema: props.schema,
4304
+ submitted: submitted || fieldSubmitted,
4293
4305
  model: validationAsyncModel,
4294
- errors: validationAsyncErrors || props.errors,
4295
- onChange: validationAsyncOnChange,
4306
+ errors: validationAsyncErrors || errors,
4307
+ infoMessage: validationAsyncSuccessMessage,
4308
+ onChange: onValidationAsyncChange,
4296
4309
  onBlur,
4297
- infoMessage: validationAsyncSuccessMessage
4310
+ required,
4311
+ schema: schema2
4298
4312
  };
4299
4313
  return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(BasicTypeSchema_default, __spreadValues({}, basicTypeSchemaProps));
4300
4314
  };
@@ -4303,100 +4317,67 @@ var ValidationAsyncSchema_default = ValidationAsyncSchema;
4303
4317
 
4304
4318
  // src/jsonSchemaForm/genericSchema/GenericSchema.tsx
4305
4319
  var import_jsx_runtime35 = require("react/jsx-runtime");
4320
+ var import_react21 = require("react");
4306
4321
  var GenericSchemaForm = (props) => {
4307
4322
  const { schema: schema2, model = null, errors = null, hideTitle = false, disabled = false } = props;
4308
4323
  const schemaProps = __spreadProps(__spreadValues({}, props), { model, errors, hideTitle, disabled });
4309
4324
  const type = getSchemaType(schema2);
4310
4325
  const log = useLogger();
4311
- const logInvalidSchemaWarning = () => log.error(
4312
- "Invalid schema or model",
4313
- `Schema of type ${type || "undefined"} requested, but schema did not pass validation.`
4314
- );
4326
+ (0, import_react20.useEffect)(() => {
4327
+ if (!isValidGenericSchema(schema2, model, errors)) {
4328
+ log.error(
4329
+ "Invalid schema or model",
4330
+ `Schema of type ${type || "undefined"} requested, but schema did not pass validation.`
4331
+ );
4332
+ }
4333
+ }, [schema2, model, errors, type, log]);
4315
4334
  switch (type) {
4316
4335
  case "readOnly":
4317
4336
  return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(ReadOnlySchema_default, __spreadValues({}, schemaProps));
4318
4337
  case "persistAsync":
4319
- if (isPersistAsyncSchema(schema2) && isNullableStringModel(model) && isBasicError(errors)) {
4320
- const filteredProps = __spreadProps(__spreadValues({}, schemaProps), { schema: schema2, model, errors });
4321
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(PersistAsyncSchema_default, __spreadValues({}, filteredProps));
4322
- } else {
4323
- logInvalidSchemaWarning();
4324
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(PersistAsyncSchema_default, __spreadValues({}, props));
4325
- }
4338
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(PersistAsyncSchema_default, __spreadValues({}, schemaProps));
4326
4339
  case "validationAsync":
4327
- if (isValidationAsyncSchema(schema2) && isNullableBasicModel(model) && isBasicError(errors)) {
4328
- const filteredProps = __spreadProps(__spreadValues({}, schemaProps), { schema: schema2, model, errors });
4329
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(ValidationAsyncSchema_default, __spreadValues({}, filteredProps));
4330
- } else {
4331
- logInvalidSchemaWarning();
4332
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(ValidationAsyncSchema_default, __spreadValues({}, props));
4333
- }
4340
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(ValidationAsyncSchema_default, __spreadValues({}, schemaProps));
4334
4341
  case "basic": {
4335
- if (isBasicSchema(schema2) && isNullableBasicModel(model) && isBasicError(errors)) {
4336
- const filteredProps = __spreadProps(__spreadValues({
4337
- infoMessage: null
4338
- }, schemaProps), {
4339
- schema: schema2,
4340
- model,
4341
- errors
4342
- });
4343
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(BasicTypeSchema_default, __spreadValues({}, filteredProps));
4344
- } else {
4345
- const filteredProps = __spreadProps(__spreadValues({
4346
- infoMessage: null
4347
- }, schemaProps), {
4348
- schema: schema2,
4349
- model,
4350
- errors
4351
- });
4352
- logInvalidSchemaWarning();
4353
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(BasicTypeSchema_default, __spreadValues({}, filteredProps));
4354
- }
4342
+ const basicTypeProps = __spreadValues({ infoMessage: null }, schemaProps);
4343
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(BasicTypeSchema_default, __spreadValues({}, basicTypeProps));
4355
4344
  }
4356
4345
  case "object":
4357
- if (isObjectSchema(schema2) && isNullableObjectModel(model)) {
4358
- const filteredProps = __spreadProps(__spreadValues({}, schemaProps), { schema: schema2, model, errors });
4359
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(ObjectSchema_default, __spreadValues({}, filteredProps), JSON.stringify(schema2));
4360
- } else {
4361
- logInvalidSchemaWarning();
4362
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(ObjectSchema_default, __spreadValues({}, props));
4363
- }
4346
+ return /* @__PURE__ */ (0, import_react21.createElement)(ObjectSchema_default, __spreadProps(__spreadValues({}, schemaProps), { key: JSON.stringify(schema2) }));
4364
4347
  case "array":
4365
- if (isArraySchema(schema2) && isNullableArrayModel(model) && isBasicError(errors)) {
4366
- const filteredProps = __spreadProps(__spreadValues({}, schemaProps), { schema: schema2, model, errors });
4367
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(ArraySchema_default, __spreadValues({}, filteredProps));
4368
- } else {
4369
- logInvalidSchemaWarning();
4370
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(ArraySchema_default, __spreadValues({}, props));
4371
- }
4348
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(ArraySchema_default, __spreadValues({}, schemaProps));
4372
4349
  case "promotedOneOf":
4373
- if (isOneOfObjectSchema(schema2) && isNullableObjectModel(model)) {
4374
- const filteredProps = __spreadProps(__spreadValues({}, schemaProps), { schema: schema2, model, errors });
4375
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(PromotedOneOfSchema_default, __spreadValues({}, filteredProps));
4376
- } else {
4377
- logInvalidSchemaWarning();
4378
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(PromotedOneOfSchema_default, __spreadValues({}, props));
4379
- }
4350
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(PromotedOneOfSchema_default, __spreadValues({}, schemaProps));
4380
4351
  case "oneOf":
4381
- if (isOneOfSchema(schema2)) {
4382
- const filteredProps = __spreadProps(__spreadValues({}, schemaProps), { schema: schema2, model, errors });
4383
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(OneOfSchema_default, __spreadValues({}, filteredProps));
4384
- } else {
4385
- logInvalidSchemaWarning();
4386
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(OneOfSchema_default, __spreadValues({}, props));
4387
- }
4352
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(OneOfSchema_default, __spreadValues({}, schemaProps));
4388
4353
  case "allOf":
4389
- if (isAllOfSchema(schema2) && isObjectModel(model)) {
4390
- const filteredProps = __spreadProps(__spreadValues({}, schemaProps), { schema: schema2, model, errors });
4391
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(AllOfSchema_default, __spreadValues({}, filteredProps));
4392
- } else {
4393
- logInvalidSchemaWarning();
4394
- return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(AllOfSchema_default, __spreadValues({}, props));
4395
- }
4354
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(AllOfSchema_default, __spreadValues({}, schemaProps));
4396
4355
  }
4397
4356
  return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_jsx_runtime35.Fragment, {});
4398
4357
  };
4399
4358
  var GenericSchema_default = GenericSchemaForm;
4359
+ var isValidGenericSchema = (schema2, model, errors) => {
4360
+ const type = getSchemaType(schema2);
4361
+ switch (type) {
4362
+ case "persistAsync":
4363
+ return isPersistAsyncSchema(schema2) && isNullableStringModel(model) && isBasicError(errors);
4364
+ case "validationAsync":
4365
+ return isValidationAsyncSchema(schema2) && isNullableBasicModel(model) && isBasicError(errors);
4366
+ case "basic":
4367
+ return isBasicSchema(schema2) && isNullableBasicModel(model) && isBasicError(errors);
4368
+ case "object":
4369
+ return isObjectSchema(schema2) && isNullableObjectModel(model);
4370
+ case "array":
4371
+ return isArraySchema(schema2) && isNullableArrayModel(model) && isBasicError(errors);
4372
+ case "promotedOneOf":
4373
+ return isOneOfObjectSchema(schema2) && isNullableObjectModel(model);
4374
+ case "oneOf":
4375
+ return isOneOfSchema(schema2);
4376
+ case "allOf":
4377
+ return isAllOfSchema(schema2) && isObjectModel(model);
4378
+ }
4379
+ return false;
4380
+ };
4400
4381
 
4401
4382
  // src/jsonSchemaForm/JsonSchemaForm.tsx
4402
4383
  var import_jsx_runtime36 = require("react/jsx-runtime");
@@ -4476,23 +4457,26 @@ var DynamicHeading = (props) => {
4476
4457
  };
4477
4458
  var DynamicHeading_default = DynamicHeading;
4478
4459
 
4479
- // src/layout/info/DynamicInfo.tsx
4460
+ // src/layout/markdown/DynamicMarkdown.tsx
4480
4461
  var import_components14 = require("@transferwise/components");
4481
4462
  var import_jsx_runtime39 = require("react/jsx-runtime");
4463
+ var DynamicMarkdown = ({ component }) => {
4464
+ const { content, align, margin } = component;
4465
+ 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 }) });
4466
+ };
4482
4467
  var DynamicInfo = ({ component }) => {
4483
4468
  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
4469
  };
4485
- var DynamicInfo_default = DynamicInfo;
4486
4470
 
4487
4471
  // src/layout/image/DynamicImage.tsx
4488
4472
  var import_components15 = require("@transferwise/components");
4489
- var import_react19 = require("react");
4473
+ var import_react22 = require("react");
4490
4474
  var import_jsx_runtime40 = require("react/jsx-runtime");
4491
4475
  var DynamicImage = ({ component: image }) => {
4492
4476
  const { url, size, text, margin } = image;
4493
4477
  const httpClient = useHttpClient();
4494
- const [imageSource, setImageSource] = (0, import_react19.useState)("");
4495
- (0, import_react19.useEffect)(() => {
4478
+ const [imageSource, setImageSource] = (0, import_react22.useState)("");
4479
+ (0, import_react22.useEffect)(() => {
4496
4480
  void getImageSource(httpClient, url).then(setImageSource);
4497
4481
  }, [url, httpClient]);
4498
4482
  const imageProps = {
@@ -4556,7 +4540,9 @@ var DynamicLayout = (props) => {
4556
4540
  case "divider":
4557
4541
  return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(DynamicDivider_default, { component }, getKey(component));
4558
4542
  case "info":
4559
- return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(DynamicInfo_default, { component }, getKey(component));
4543
+ return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(DynamicInfo, { component }, getKey(component));
4544
+ case "markdown":
4545
+ return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(DynamicMarkdown, { component }, getKey(component));
4560
4546
  case "columns":
4561
4547
  return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4562
4548
  DynamicColumns_default,
@@ -4582,7 +4568,7 @@ var DynamicLayout = (props) => {
4582
4568
  onModelChange,
4583
4569
  onPersistAsync
4584
4570
  },
4585
- getKey(component)
4571
+ getKey(__spreadProps(__spreadValues({}, component), { errors }))
4586
4572
  );
4587
4573
  case "button":
4588
4574
  return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(DynamicButton_default, { component, onAction }, getKey(component));
@@ -4687,9 +4673,9 @@ var DynamicParagraph_messages_default = (0, import_react_intl13.defineMessages)(
4687
4673
 
4688
4674
  // src/layout/paragraph/useSnackBarIfAvailable.ts
4689
4675
  var import_components18 = require("@transferwise/components");
4690
- var import_react20 = require("react");
4676
+ var import_react23 = require("react");
4691
4677
  function useSnackBarIfAvailable() {
4692
- const context = (0, import_react20.useContext)(import_components18.SnackbarContext);
4678
+ const context = (0, import_react23.useContext)(import_components18.SnackbarContext);
4693
4679
  return context ? context.createSnackbar : noop3;
4694
4680
  }
4695
4681
  function noop3() {
@@ -4811,13 +4797,13 @@ var BasicTypeSchema = (props) => {
4811
4797
  props.onBlur();
4812
4798
  }
4813
4799
  };
4814
- const [model, setModel] = (0, import_react21.useState)((_a = props.model) != null ? _a : null);
4815
- const [lastModel, setLastModel] = (0, import_react21.useState)((_b = props.model) != null ? _b : null);
4816
- const [changed, setChanged] = (0, import_react21.useState)(false);
4817
- const [focused, setFocused] = (0, import_react21.useState)(false);
4818
- const [blurred, setBlurred] = (0, import_react21.useState)(false);
4819
- const [validations, setValidations] = (0, import_react21.useState)([]);
4820
- const id = (0, import_react21.useMemo)(() => props.schema.$id || generateRandomId(), [props.schema.$id]);
4800
+ const [model, setModel] = (0, import_react24.useState)((_a = props.model) != null ? _a : null);
4801
+ const [lastModel, setLastModel] = (0, import_react24.useState)((_b = props.model) != null ? _b : null);
4802
+ const [changed, setChanged] = (0, import_react24.useState)(false);
4803
+ const [focused, setFocused] = (0, import_react24.useState)(false);
4804
+ const [blurred, setBlurred] = (0, import_react24.useState)(false);
4805
+ const [validations, setValidations] = (0, import_react24.useState)([]);
4806
+ const id = (0, import_react24.useMemo)(() => props.schema.$id || generateRandomId(), [props.schema.$id]);
4821
4807
  const onSchemaChange = () => {
4822
4808
  const defaultValue = getDefaultValue(props.schema);
4823
4809
  if (isNullish(model) && !isNullish(defaultValue)) {
@@ -4832,11 +4818,14 @@ var BasicTypeSchema = (props) => {
4832
4818
  };
4833
4819
  const isConst = props.schema.const;
4834
4820
  const isHidden = props.schema.hidden || isConst;
4835
- (0, import_react21.useEffect)(refreshValidations, [props.model, props.submitted]);
4836
- (0, import_react21.useEffect)(onSchemaChange, [props.schema]);
4837
- (0, import_react21.useEffect)(() => {
4821
+ (0, import_react24.useEffect)(refreshValidations, [props.model, props.submitted]);
4822
+ (0, import_react24.useEffect)(onSchemaChange, [props.schema]);
4823
+ (0, import_react24.useEffect)(() => {
4838
4824
  var _a2;
4839
- return setModel((_a2 = props.model) != null ? _a2 : null);
4825
+ const newModel = (_a2 = props.model) != null ? _a2 : null;
4826
+ if (newModel !== model) {
4827
+ setModel(newModel);
4828
+ }
4840
4829
  }, [props.model]);
4841
4830
  const formGroupClasses = {
4842
4831
  "form-group": true,
@@ -4908,16 +4897,15 @@ var PersistAsyncBasicSchema = (props) => {
4908
4897
  const intl = (0, import_react_intl15.useIntl)();
4909
4898
  const httpClient = useHttpClient();
4910
4899
  const onEvent = useEventDispatcher();
4911
- const [persistAsyncModel, setPersistAsyncModel] = (0, import_react22.useState)(null);
4900
+ const [persistAsyncModel, setPersistAsyncModel] = (0, import_react25.useState)(null);
4912
4901
  const previousPersistAsyncModel = usePrevious(persistAsyncModel);
4913
- const [persistAsyncError, setPersistAsyncError] = (0, import_react22.useState)(null);
4914
- const [fieldSubmitted, setFieldSubmitted] = (0, import_react22.useState)(false);
4915
- const [abortController, setAbortController] = (0, import_react22.useState)(null);
4916
- const log = useLogger();
4917
- (0, import_react22.useEffect)(() => {
4902
+ const [persistAsyncError, setPersistAsyncError] = (0, import_react25.useState)(null);
4903
+ const [fieldSubmitted, setFieldSubmitted] = (0, import_react25.useState)(false);
4904
+ const [abortController, setAbortController] = (0, import_react25.useState)(null);
4905
+ (0, import_react25.useEffect)(() => {
4918
4906
  if (controlTypesWithPersistOnChange.has(
4919
4907
  // TODO: LOW avoid type assertion below -- control type may be nullish. consider ?? ''
4920
- getControlType(props.schema.persistAsync.schema, log)
4908
+ getControlType(props.schema.persistAsync.schema)
4921
4909
  )) {
4922
4910
  persistAsyncIfValid();
4923
4911
  }
@@ -5002,7 +4990,7 @@ var PersistAsyncBasicSchema_default = PersistAsyncBasicSchema;
5002
4990
 
5003
4991
  // src/common/hooks/usePersistAsync/usePersistAsync.ts
5004
4992
  var usePersistAsync = (persistAsync) => {
5005
- const [abortController, setAbortController] = (0, import_react23.useState)(null);
4993
+ const [abortController, setAbortController] = (0, import_react26.useState)(null);
5006
4994
  const httpClient = useHttpClient();
5007
4995
  const intl = (0, import_react_intl16.useIntl)();
5008
4996
  const { schema: schema2 } = persistAsync;
@@ -5081,7 +5069,7 @@ function hasStringMessage(value) {
5081
5069
  }
5082
5070
 
5083
5071
  // src/common/hooks/usePolling/usePolling.tsx
5084
- var import_react24 = require("react");
5072
+ var import_react27 = require("react");
5085
5073
  function usePolling({
5086
5074
  asyncFn,
5087
5075
  interval,
@@ -5090,9 +5078,9 @@ function usePolling({
5090
5078
  onPollingResponse,
5091
5079
  onFailure
5092
5080
  }) {
5093
- const onPollingResponseReference = (0, import_react24.useRef)(onPollingResponse);
5094
- const onFailureReference = (0, import_react24.useRef)(onFailure);
5095
- const poll = (0, import_react24.useMemo)(
5081
+ const onPollingResponseReference = (0, import_react27.useRef)(onPollingResponse);
5082
+ const onFailureReference = (0, import_react27.useRef)(onFailure);
5083
+ const poll = (0, import_react27.useMemo)(
5096
5084
  () => createPollingClosure(
5097
5085
  asyncFn,
5098
5086
  maxAttempts,
@@ -5102,7 +5090,7 @@ function usePolling({
5102
5090
  ),
5103
5091
  [asyncFn, maxAttempts, maxConsecutiveFails]
5104
5092
  );
5105
- (0, import_react24.useEffect)(() => {
5093
+ (0, import_react27.useEffect)(() => {
5106
5094
  if (interval > 0) {
5107
5095
  const intervalReference = setInterval(() => {
5108
5096
  poll();
@@ -5110,7 +5098,7 @@ function usePolling({
5110
5098
  return () => clearInterval(intervalReference);
5111
5099
  }
5112
5100
  }, [poll, interval]);
5113
- (0, import_react24.useEffect)(() => {
5101
+ (0, import_react27.useEffect)(() => {
5114
5102
  onPollingResponseReference.current = onPollingResponse;
5115
5103
  onFailureReference.current = onFailure;
5116
5104
  }, [onPollingResponse, onFailure]);
@@ -5139,20 +5127,20 @@ function createPollingClosure(asyncFn, maxAttempts, maxConsecutiveFails, onPolli
5139
5127
  }
5140
5128
 
5141
5129
  // src/common/hooks/usePrevious/usePrevious.js
5142
- var import_react25 = require("react");
5130
+ var import_react28 = require("react");
5143
5131
  var usePrevious = (value) => {
5144
- const reference = (0, import_react25.useRef)();
5145
- (0, import_react25.useEffect)(() => {
5132
+ const reference = (0, import_react28.useRef)();
5133
+ (0, import_react28.useEffect)(() => {
5146
5134
  reference.current = value;
5147
5135
  }, [value]);
5148
5136
  return reference.current;
5149
5137
  };
5150
5138
 
5151
5139
  // src/common/hooks/useStepPolling/useStepPolling.tsx
5152
- var import_react26 = require("react");
5140
+ var import_react29 = require("react");
5153
5141
  function useStepPolling(polling, onAction) {
5154
5142
  const httpClient = useHttpClient();
5155
- const asyncFn = (0, import_react26.useMemo)(() => {
5143
+ const asyncFn = (0, import_react29.useMemo)(() => {
5156
5144
  if (polling) {
5157
5145
  return () => {
5158
5146
  return httpClient(polling.url).then((response) => {
@@ -5167,7 +5155,7 @@ function useStepPolling(polling, onAction) {
5167
5155
  return void 0;
5168
5156
  }
5169
5157
  }, [polling, httpClient]);
5170
- const onPollingResponse = (0, import_react26.useCallback)(
5158
+ const onPollingResponse = (0, import_react29.useCallback)(
5171
5159
  (pollingResponse) => {
5172
5160
  if (pollingResponse == null ? void 0 : pollingResponse.action) {
5173
5161
  onAction(pollingResponse.action);
@@ -5183,7 +5171,7 @@ function useStepPolling(polling, onAction) {
5183
5171
  maxAttempts: (polling == null ? void 0 : polling.maxAttempts) || 0,
5184
5172
  maxConsecutiveFails: 1,
5185
5173
  onPollingResponse,
5186
- onFailure: (0, import_react26.useCallback)(() => {
5174
+ onFailure: (0, import_react29.useCallback)(() => {
5187
5175
  if (polling) {
5188
5176
  onAction(polling.onError.action);
5189
5177
  }
@@ -5193,17 +5181,17 @@ function useStepPolling(polling, onAction) {
5193
5181
 
5194
5182
  // src/step/layoutStep/LayoutStep.tsx
5195
5183
  var import_jsx_runtime48 = require("react/jsx-runtime");
5196
- var getComponents = (step33, options) => {
5184
+ var getComponents = (step35, options) => {
5197
5185
  var _a;
5198
- if (!step33 || isEmpty(step33) || !step33.layout && !step33.type) {
5186
+ if (isEmpty(step35)) {
5199
5187
  return [];
5200
5188
  }
5201
- const layout6 = convertStepToLayout(step33, options);
5189
+ const layout6 = convertStepToLayout(step35, options);
5202
5190
  return inlineReferences({
5203
5191
  layout: layout6,
5204
- schemas: step33.schemas || [],
5205
- actions: step33.actions || [],
5206
- model: (_a = step33.model) != null ? _a : null
5192
+ schemas: step35.schemas || [],
5193
+ actions: step35.actions || [],
5194
+ model: (_a = step35.model) != null ? _a : null
5207
5195
  });
5208
5196
  };
5209
5197
  var LayoutStep = (props) => {
@@ -5231,10 +5219,10 @@ var LayoutStep = (props) => {
5231
5219
  var LayoutStep_default = LayoutStep;
5232
5220
 
5233
5221
  // src/step/cameraStep/CameraStep.tsx
5234
- var import_react30 = require("react");
5222
+ var import_react33 = require("react");
5235
5223
 
5236
5224
  // src/step/cameraStep/cameraCapture/CameraCapture.tsx
5237
- var import_react29 = require("react");
5225
+ var import_react32 = require("react");
5238
5226
  var import_react_intl23 = require("react-intl");
5239
5227
  var import_react_webcam = __toESM(require_react_webcam());
5240
5228
 
@@ -5306,7 +5294,7 @@ var CaptureButton = ({ onClick }) => /* @__PURE__ */ (0, import_jsx_runtime49.js
5306
5294
  );
5307
5295
 
5308
5296
  // src/step/cameraStep/cameraCapture/hooks/index.ts
5309
- var import_react27 = require("react");
5297
+ var import_react30 = require("react");
5310
5298
 
5311
5299
  // src/step/cameraStep/cameraCapture/utils/index.ts
5312
5300
  var isSelfieCamera = (stream) => {
@@ -5354,7 +5342,7 @@ var getVideoCapabilities = (videoStream) => {
5354
5342
 
5355
5343
  // src/step/cameraStep/cameraCapture/hooks/index.ts
5356
5344
  var useVideoConstraints = (direction) => {
5357
- const [videoConstraints, setVideoConstraints] = (0, import_react27.useState)();
5345
+ const [videoConstraints, setVideoConstraints] = (0, import_react30.useState)();
5358
5346
  const defaultVideoConstraints = {
5359
5347
  facingMode: direction === "front" ? "user" : "environment",
5360
5348
  height: { min: 480, max: 1080, ideal: 720 },
@@ -5362,7 +5350,7 @@ var useVideoConstraints = (direction) => {
5362
5350
  frameRate: 30,
5363
5351
  aspectRatio: 16 / 9
5364
5352
  };
5365
- (0, import_react27.useEffect)(() => {
5353
+ (0, import_react30.useEffect)(() => {
5366
5354
  void getVideoConstraints(direction).then(setVideoConstraints);
5367
5355
  }, [direction]);
5368
5356
  const getVideoConstraints = async (direction2) => {
@@ -5380,7 +5368,7 @@ var useVideoConstraints = (direction) => {
5380
5368
  };
5381
5369
 
5382
5370
  // src/step/cameraStep/cameraCapture/overlay/Overlay.tsx
5383
- var import_react28 = require("react");
5371
+ var import_react31 = require("react");
5384
5372
  var import_jsx_runtime50 = require("react/jsx-runtime");
5385
5373
  var captureButtonHeight = 92;
5386
5374
  var reviewButtonsHeight = 120;
@@ -5397,8 +5385,8 @@ var Overlay = ({
5397
5385
  instructions,
5398
5386
  reviewInstructions
5399
5387
  }) => {
5400
- const svgReference = (0, import_react28.useRef)(null);
5401
- (0, import_react28.useEffect)(() => {
5388
+ const svgReference = (0, import_react31.useRef)(null);
5389
+ (0, import_react31.useEffect)(() => {
5402
5390
  const listener = debounce(() => {
5403
5391
  var _a;
5404
5392
  if ((_a = svgReference.current) == null ? void 0 : _a.innerHTML) {
@@ -5548,14 +5536,14 @@ var CameraCapture = ({
5548
5536
  onCapture,
5549
5537
  onEvent
5550
5538
  }) => {
5551
- const [mode, setMode] = (0, import_react29.useState)("CAPTURE");
5552
- const [isVideoMirrored, setIsVideoMirrored] = (0, import_react29.useState)(false);
5553
- const [ready, setReady] = (0, import_react29.useState)(false);
5554
- const [reviewImage, setReviewImage] = (0, import_react29.useState)();
5555
- const webcamReference = (0, import_react29.useRef)(null);
5539
+ const [mode, setMode] = (0, import_react32.useState)("CAPTURE");
5540
+ const [isVideoMirrored, setIsVideoMirrored] = (0, import_react32.useState)(false);
5541
+ const [ready, setReady] = (0, import_react32.useState)(false);
5542
+ const [reviewImage, setReviewImage] = (0, import_react32.useState)();
5543
+ const webcamReference = (0, import_react32.useRef)(null);
5556
5544
  const { videoConstraints } = useVideoConstraints(direction);
5557
5545
  const intl = (0, import_react_intl23.useIntl)();
5558
- const handleCapture = (0, import_react29.useCallback)(async () => {
5546
+ const handleCapture = (0, import_react32.useCallback)(async () => {
5559
5547
  var _a, _b, _c, _d, _e, _f;
5560
5548
  if (((_a = webcamReference == null ? void 0 : webcamReference.current) == null ? void 0 : _a.video) && ((_c = (_b = webcamReference == null ? void 0 : webcamReference.current) == null ? void 0 : _b.video) == null ? void 0 : _c.readyState) >= 3) {
5561
5549
  (_e = (_d = webcamReference == null ? void 0 : webcamReference.current) == null ? void 0 : _d.video) == null ? void 0 : _e.pause();
@@ -5577,7 +5565,7 @@ var CameraCapture = ({
5577
5565
  );
5578
5566
  }
5579
5567
  }, [webcamReference, showReview, setReviewImage, setMode, onCapture, isVideoMirrored]);
5580
- const handleUserMediaError = (0, import_react29.useCallback)(
5568
+ const handleUserMediaError = (0, import_react32.useCallback)(
5581
5569
  (error) => {
5582
5570
  if (error instanceof DOMException && (error == null ? void 0 : error.name) === "NotAllowedError") {
5583
5571
  setMode("NO_CAMERA_ACCESS");
@@ -5589,7 +5577,7 @@ var CameraCapture = ({
5589
5577
  },
5590
5578
  [setMode, onEvent]
5591
5579
  );
5592
- const handleUserMedia = (0, import_react29.useCallback)(
5580
+ const handleUserMedia = (0, import_react32.useCallback)(
5593
5581
  (stream) => {
5594
5582
  setReady(true);
5595
5583
  setIsVideoMirrored(isSelfieCamera(stream));
@@ -5662,17 +5650,17 @@ function blobToBase64(blob) {
5662
5650
  });
5663
5651
  }
5664
5652
  var CameraStep = (props) => {
5665
- const { step: step33, model, onModelChange, onAction } = props;
5653
+ const { step: step35, model, onModelChange, onAction } = props;
5666
5654
  const onEvent = useEventDispatcher();
5667
- const objectSchema = getObjectSchema(step33);
5668
- const cameraSchema = getCameraSchema(step33);
5669
- const action2 = getFirstAction(step33);
5655
+ const objectSchema = getObjectSchema(step35);
5656
+ const cameraSchema = getCameraSchema(step35);
5657
+ const action2 = getFirstAction(step35);
5670
5658
  const { title, image, cameraConfig } = cameraSchema;
5671
5659
  const { assets, direction, instructions } = cameraConfig || {};
5672
5660
  const { overlay, outline } = assets || {};
5673
5661
  const { url: imageUrl } = image || {};
5674
- const [captureClicked, setCaptureClicked] = (0, import_react30.useState)(false);
5675
- (0, import_react30.useEffect)(() => {
5662
+ const [captureClicked, setCaptureClicked] = (0, import_react33.useState)(false);
5663
+ (0, import_react33.useEffect)(() => {
5676
5664
  if (captureClicked) {
5677
5665
  onAction(action2);
5678
5666
  }
@@ -5708,8 +5696,8 @@ var CameraStep = (props) => {
5708
5696
  );
5709
5697
  };
5710
5698
  var CameraStep_default = CameraStep;
5711
- function getObjectSchema(step33) {
5712
- const nonHiddenSchemas = filterHiddenSchemas(step33.schemas || []);
5699
+ function getObjectSchema(step35) {
5700
+ const nonHiddenSchemas = filterHiddenSchemas(step35.schemas || []);
5713
5701
  const objectSchema = nonHiddenSchemas[0];
5714
5702
  if (!objectSchema || !isObjectSchema(objectSchema)) {
5715
5703
  throw new Error(
@@ -5718,8 +5706,8 @@ function getObjectSchema(step33) {
5718
5706
  }
5719
5707
  return objectSchema;
5720
5708
  }
5721
- function getCameraSchema(step33) {
5722
- const objectSchema = getObjectSchema(step33);
5709
+ function getCameraSchema(step35) {
5710
+ const objectSchema = getObjectSchema(step35);
5723
5711
  const firstProperty = Object.values(objectSchema.properties)[0];
5724
5712
  if (!firstProperty) {
5725
5713
  throw new Error(
@@ -5728,15 +5716,15 @@ function getCameraSchema(step33) {
5728
5716
  }
5729
5717
  return firstProperty;
5730
5718
  }
5731
- function getFirstAction(step33) {
5719
+ function getFirstAction(step35) {
5732
5720
  var _a, _b;
5733
- if (!step33.schemas || ((_a = filterHiddenSchemas(step33.schemas)) == null ? void 0 : _a.length) !== 1) {
5721
+ if (!step35.schemas || ((_a = filterHiddenSchemas(step35.schemas)) == null ? void 0 : _a.length) !== 1) {
5734
5722
  throw new Error("camera step expects 1 non-hidden object schema");
5735
5723
  }
5736
- if (((_b = step33 == null ? void 0 : step33.actions) == null ? void 0 : _b.length) !== 1) {
5724
+ if (((_b = step35 == null ? void 0 : step35.actions) == null ? void 0 : _b.length) !== 1) {
5737
5725
  throw new Error("camera step expects 1 action");
5738
5726
  }
5739
- return step33.actions[0];
5727
+ return step35.actions[0];
5740
5728
  }
5741
5729
 
5742
5730
  // src/step/externalConfirmationStep/ExternalConfirmationStep.tsx
@@ -5841,44 +5829,43 @@ function getOrigin(url) {
5841
5829
  var import_jsx_runtime56 = require("react/jsx-runtime");
5842
5830
  var DynamicFlowStep = (props) => {
5843
5831
  var _a;
5844
- const { step: step33, globalError } = props;
5845
- const externalUrl = (_a = step33 == null ? void 0 : step33.external) == null ? void 0 : _a.url;
5832
+ const { step: step35, globalError } = props;
5833
+ const externalUrl = (_a = step35 == null ? void 0 : step35.external) == null ? void 0 : _a.url;
5846
5834
  const { requiresManualTrigger, dismissConfirmation } = useExternal(externalUrl);
5847
- if (step33 === void 0) {
5835
+ if (step35 === void 0) {
5848
5836
  return null;
5849
5837
  }
5850
5838
  if (externalUrl && requiresManualTrigger) {
5851
5839
  return /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(ExternalConfirmationStep_default, { url: externalUrl, onClose: dismissConfirmation });
5852
5840
  }
5853
- if (getStepType(step33) === "camera") {
5854
- return /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(CameraStep_default, __spreadProps(__spreadValues({}, props), { step: step33 }));
5841
+ if (isCameraStep(step35)) {
5842
+ return /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(CameraStep_default, __spreadProps(__spreadValues({}, props), { step: step35 }));
5855
5843
  }
5856
5844
  return /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(import_jsx_runtime56.Fragment, { children: [
5857
5845
  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: step33 }))
5846
+ /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(LayoutStep_default, __spreadProps(__spreadValues({}, props), { stepSpecification: step35 }))
5859
5847
  ] });
5860
5848
  };
5861
5849
 
5862
5850
  // src/dynamicFlow/utils/useDebouncedRefresh/useDebouncedRefresh.ts
5863
- var import_react31 = require("react");
5851
+ var import_react34 = require("react");
5864
5852
  var DEBOUNCE_DELAY = 1e3;
5865
5853
  function useDebouncedRefresh(fetchRefresh) {
5866
- const map = (0, import_react31.useRef)(/* @__PURE__ */ new Map());
5854
+ const map = (0, import_react34.useRef)(/* @__PURE__ */ new Map());
5867
5855
  const retrieveOrCreate = (key) => {
5868
5856
  if (map.current.has(key)) {
5869
5857
  return map.current.get(key);
5870
5858
  }
5871
5859
  const debouncedFetchRefresh = debounce(
5872
- (action2, data, etag) => fetchRefresh(action2, data, etag),
5860
+ (url, data, etag) => fetchRefresh(url, data, etag),
5873
5861
  DEBOUNCE_DELAY
5874
5862
  );
5875
5863
  map.current.set(key, debouncedFetchRefresh);
5876
5864
  return debouncedFetchRefresh;
5877
5865
  };
5878
- return function(action2, data, etag, schema2) {
5879
- const key = action2.url || "";
5880
- const debouncedFetchRefresh = retrieveOrCreate(key);
5881
- void debouncedFetchRefresh(action2, data, etag);
5866
+ return function(url, data, etag, schema2) {
5867
+ const debouncedFetchRefresh = retrieveOrCreate(url);
5868
+ void debouncedFetchRefresh(url, data, etag);
5882
5869
  if (!schema2 || !shouldDebounceSchema(schema2)) {
5883
5870
  void debouncedFetchRefresh.flush();
5884
5871
  }
@@ -5886,7 +5873,7 @@ function useDebouncedRefresh(fetchRefresh) {
5886
5873
  }
5887
5874
 
5888
5875
  // src/dynamicFlow/utils/useDynamicFlowState.ts
5889
- var import_react32 = require("react");
5876
+ var import_react35 = require("react");
5890
5877
 
5891
5878
  // src/dynamicFlow/DynamicFlowTypes.ts
5892
5879
  function isSchema(schema2) {
@@ -5896,23 +5883,23 @@ function isSchema(schema2) {
5896
5883
  // src/dynamicFlow/utils/useDynamicFlowState.ts
5897
5884
  var useDynamicFlowState = (initialStep) => {
5898
5885
  var _a, _b;
5899
- const [formErrors, setFormErrors] = (0, import_react32.useState)((_a = initialStep == null ? void 0 : initialStep.errors) == null ? void 0 : _a.validation);
5900
- const [globalError, setGlobalError] = (0, import_react32.useState)((_b = initialStep == null ? void 0 : initialStep.errors) == null ? void 0 : _b.error);
5901
- const [stepAndModels, setStepAndModels] = (0, import_react32.useState)({
5886
+ const [formErrors, setFormErrors] = (0, import_react35.useState)((_a = initialStep == null ? void 0 : initialStep.errors) == null ? void 0 : _a.validation);
5887
+ const [globalError, setGlobalError] = (0, import_react35.useState)((_b = initialStep == null ? void 0 : initialStep.errors) == null ? void 0 : _b.error);
5888
+ const [stepAndModels, setStepAndModels] = (0, import_react35.useState)({
5902
5889
  step: initialStep || void 0,
5903
5890
  models: (initialStep == null ? void 0 : initialStep.model) ? buildInitialModels(initialStep.model, getAllSchemas(initialStep)) : {},
5904
5891
  etag: void 0
5905
5892
  });
5906
- const { step: step33, models, etag } = stepAndModels;
5907
- const setStepAndEtag = (step34, etag2) => {
5893
+ const { step: step35, models, etag } = stepAndModels;
5894
+ const setStepAndEtag = (step36, etag2) => {
5908
5895
  var _a2, _b2, _c, _d;
5909
5896
  setStepAndModels((previous) => ({
5910
- step: step34,
5911
- models: step34.model ? buildInitialModels(step34.model, getAllSchemas(step34)) : previous.models,
5897
+ step: step36,
5898
+ models: step36.model ? buildInitialModels(step36.model, getAllSchemas(step36)) : previous.models,
5912
5899
  etag: etag2
5913
5900
  }));
5914
- setFormErrors((_b2 = (_a2 = step34 == null ? void 0 : step34.errors) == null ? void 0 : _a2.validation) != null ? _b2 : null);
5915
- setGlobalError((_d = (_c = step34 == null ? void 0 : step34.errors) == null ? void 0 : _c.error) != null ? _d : null);
5901
+ setFormErrors((_b2 = (_a2 = step36 == null ? void 0 : step36.errors) == null ? void 0 : _a2.validation) != null ? _b2 : null);
5902
+ setGlobalError((_d = (_c = step36 == null ? void 0 : step36.errors) == null ? void 0 : _c.error) != null ? _d : null);
5916
5903
  };
5917
5904
  const setSchemaModel = (schemaId, objectModel, onModelsUpdated) => {
5918
5905
  setStepAndModels((previous) => {
@@ -5928,11 +5915,11 @@ var useDynamicFlowState = (initialStep) => {
5928
5915
  return updatedState;
5929
5916
  });
5930
5917
  };
5931
- const modelIsValid = (0, import_react32.useMemo)(() => areModelsValid(models, getAllSchemas(step33)), [models, step33]);
5918
+ const modelIsValid = (0, import_react35.useMemo)(() => areModelsValid(models, getAllSchemas(step35)), [models, step35]);
5932
5919
  return {
5933
5920
  formErrors,
5934
5921
  globalError,
5935
- step: step33,
5922
+ step: step35,
5936
5923
  models,
5937
5924
  etag,
5938
5925
  modelIsValid,
@@ -5952,9 +5939,9 @@ var buildInitialModels = (model, schemas = []) => {
5952
5939
  });
5953
5940
  }, {});
5954
5941
  };
5955
- var getAllSchemas = (step33) => [
5956
- ...getAllSchemasInLayout((step33 == null ? void 0 : step33.layout) || []),
5957
- ...(step33 == null ? void 0 : step33.schemas) || []
5942
+ var getAllSchemas = (step35) => [
5943
+ ...getAllSchemasInLayout((step35 == null ? void 0 : step35.layout) || []),
5944
+ ...(step35 == null ? void 0 : step35.schemas) || []
5958
5945
  ];
5959
5946
  var getAllSchemasInLayout = (components) => components.flatMap((component) => {
5960
5947
  switch (component.type) {
@@ -5979,7 +5966,7 @@ var areModelsValid = (formModels, schemas = []) => {
5979
5966
 
5980
5967
  // src/dynamicFlow/utils/useLoader.tsx
5981
5968
  var import_components24 = require("@transferwise/components");
5982
- var import_react33 = require("react");
5969
+ var import_react36 = require("react");
5983
5970
  var import_jsx_runtime57 = require("react/jsx-runtime");
5984
5971
  function useLoader(loaderConfig, initialState) {
5985
5972
  const config = __spreadValues({
@@ -5987,7 +5974,7 @@ function useLoader(loaderConfig, initialState) {
5987
5974
  initial: true,
5988
5975
  submission: false
5989
5976
  }, loaderConfig);
5990
- const [loadingState, setLoadingState] = (0, import_react33.useState)(initialState);
5977
+ const [loadingState, setLoadingState] = (0, import_react36.useState)(initialState);
5991
5978
  const shouldDisplayLoader = config.initial && loadingState === "initial" || config.submission && loadingState === "submission";
5992
5979
  const loader = shouldDisplayLoader ? /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
5993
5980
  import_components24.Loader,
@@ -5997,11 +5984,11 @@ function useLoader(loaderConfig, initialState) {
5997
5984
  "data-testid": "loader"
5998
5985
  }
5999
5986
  ) : null;
6000
- return { loadingState, setLoadingState, loader };
5987
+ return { isLoading: loadingState !== "idle", setLoadingState, loader };
6001
5988
  }
6002
5989
 
6003
5990
  // src/dynamicFlow/utils/errorBoundary/ErrorBoundary.tsx
6004
- var import_react34 = require("react");
5991
+ var import_react37 = require("react");
6005
5992
 
6006
5993
  // src/dynamicFlow/utils/errorBoundary/ErrorBoundaryAlert.tsx
6007
5994
  var import_components25 = require("@transferwise/components");
@@ -6045,7 +6032,7 @@ var ErrorBoundaryAlert = ({ onDismiss }) => {
6045
6032
  var import_jsx_runtime59 = require("react/jsx-runtime");
6046
6033
  var noop6 = () => {
6047
6034
  };
6048
- var ErrorBoundary = class extends import_react34.Component {
6035
+ var ErrorBoundary = class extends import_react37.Component {
6049
6036
  constructor(props) {
6050
6037
  super(props);
6051
6038
  this.handleErrorReset = () => {
@@ -6072,46 +6059,78 @@ var ErrorBoundary = class extends import_react34.Component {
6072
6059
  var ErrorBoundary_default = ErrorBoundary;
6073
6060
 
6074
6061
  // src/dynamicFlow/utils/responseParsers/response-parsers.ts
6075
- var parseFetchResponse = async (response) => {
6076
- var _a;
6077
- assertResponseIsValid(response);
6078
- if ((_a = response.headers) == null ? void 0 : _a.has("X-Df-Exit")) {
6079
- return { type: "exit", result: await parseExitResponse(response) };
6062
+ var parseFetchResponseByResponseType = async (response) => {
6063
+ const type = response.headers.get("X-Df-ResponseType");
6064
+ switch (type) {
6065
+ case "step":
6066
+ return parseStepResponse(response);
6067
+ case "exit":
6068
+ return parseExitResponse(response);
6069
+ case "action":
6070
+ return parseActionResponse(response);
6071
+ default:
6072
+ throw new Error(
6073
+ "Unsupported X-Df-ResponseType. Allowed values are 'step', 'action', 'exit'."
6074
+ );
6080
6075
  }
6076
+ };
6077
+ var parseStepResponse = async (response) => {
6081
6078
  const jsonBody = await parseResponseJson(response);
6082
6079
  if (!isObject(jsonBody)) {
6083
6080
  throw new Error("Incorrect response body in response. Expected an object.");
6084
6081
  }
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
6082
  const etag = response.headers.get("etag") || void 0;
6098
6083
  return { type: "step", step: jsonBody, etag };
6099
6084
  };
6085
+ var parseActionResponse = async (response) => {
6086
+ const jsonBody = await parseResponseJson(response);
6087
+ if (!isObject(jsonBody)) {
6088
+ throw new Error("Incorrect response body in response. Expected an object.");
6089
+ }
6090
+ if (!isObject(jsonBody.action)) {
6091
+ throw new Error(
6092
+ "Incorrect response body in action response. Expected an object satisfying the type { action: Action }."
6093
+ );
6094
+ }
6095
+ const action2 = jsonBody.action;
6096
+ if (action2.exit === true && isObject(action2.result)) {
6097
+ return { type: "exit", result: action2.result };
6098
+ }
6099
+ return { type: "action", action: jsonBody.action };
6100
+ };
6101
+ var parseExitResponse = async (response) => {
6102
+ return { type: "exit", result: await getJsonObjectOrNull(response) };
6103
+ };
6104
+ var parseFetchResponse = async (response) => {
6105
+ var _a, _b;
6106
+ assertResponseIsValid(response);
6107
+ if ((_a = response.headers) == null ? void 0 : _a.has("X-Df-ResponseType")) {
6108
+ return parseFetchResponseByResponseType(response);
6109
+ }
6110
+ if ((_b = response.headers) == null ? void 0 : _b.has("X-Df-Exit")) {
6111
+ return parseExitResponse(response);
6112
+ }
6113
+ const jsonBody = await parseResponseJson(response.clone());
6114
+ if (isObject(jsonBody) && jsonBody.action) {
6115
+ return parseActionResponse(response);
6116
+ }
6117
+ return parseStepResponse(response);
6118
+ };
6100
6119
  var parseErrorResponse = async (response) => {
6101
6120
  assertResponseIsValid(response);
6102
6121
  const jsonBody = await parseResponseJson(response);
6103
6122
  if (!isObject(jsonBody)) {
6104
6123
  throw new Error("Incorrect response body in error response. Expected an object.");
6105
6124
  }
6125
+ if (!jsonBody.refreshFormUrl && !jsonBody.validation && !jsonBody.error) {
6126
+ throw jsonBody;
6127
+ }
6106
6128
  return jsonBody;
6107
6129
  };
6108
- var parseExitResponse = async (response) => {
6130
+ var getJsonObjectOrNull = async (response) => {
6109
6131
  assertResponseIsValid(response);
6110
6132
  const result = await parseResponseJson(response);
6111
- if (isObject(result) || result === null) {
6112
- return result;
6113
- }
6114
- return null;
6133
+ return isObject(result) ? result : null;
6115
6134
  };
6116
6135
  var parseResponseJson = async (response) => {
6117
6136
  try {
@@ -6152,7 +6171,7 @@ var DynamicFlowComponent = ({
6152
6171
  const {
6153
6172
  formErrors,
6154
6173
  globalError,
6155
- step: step33,
6174
+ step: step35,
6156
6175
  models,
6157
6176
  etag,
6158
6177
  modelIsValid,
@@ -6161,26 +6180,24 @@ var DynamicFlowComponent = ({
6161
6180
  setStepAndEtag,
6162
6181
  setSchemaModel
6163
6182
  } = useDynamicFlowState(initialStep);
6164
- const [submitted, setSubmitted] = (0, import_react35.useState)(false);
6165
- const { loadingState, setLoadingState, loader } = useLoader(
6183
+ const [submitted, setSubmitted] = (0, import_react38.useState)(false);
6184
+ const { isLoading, loader, setLoadingState } = useLoader(
6166
6185
  loaderConfig,
6167
6186
  initialStep ? "idle" : "initial"
6168
6187
  );
6169
- const logWarning = getLogger("warning", onLog, flowId, step33 == null ? void 0 : step33.key);
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);
6172
- const analyticsMetadata = (0, import_react35.useMemo)(
6188
+ const logCritical = getLogger("critical", onLog, flowId, (step35 == null ? void 0 : step35.id) || (step35 == null ? void 0 : step35.key));
6189
+ const analyticsMetadata = (0, import_react38.useMemo)(
6173
6190
  () => {
6174
6191
  var _a;
6175
- return __spreadValues({ flowId, stepId: step33 == null ? void 0 : step33.key }, (_a = step33 == null ? void 0 : step33.analytics) != null ? _a : {});
6192
+ 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
6193
  },
6177
- [flowId, step33]
6194
+ [flowId, step35]
6178
6195
  );
6179
- const dispatchEvent = (0, import_react35.useMemo)(
6196
+ const dispatchEvent = (0, import_react38.useMemo)(
6180
6197
  () => getEventDispatcher(onEvent, analyticsMetadata),
6181
6198
  [onEvent, analyticsMetadata]
6182
6199
  );
6183
- const triggerActionRequest = (0, import_react35.useCallback)(
6200
+ const dfHttpClient = (0, import_react38.useCallback)(
6184
6201
  ({ action: action2, data, etag: etag2 }) => {
6185
6202
  const { url, method = "POST" } = action2;
6186
6203
  return httpClient(url != null ? url : "", {
@@ -6196,126 +6213,113 @@ var DynamicFlowComponent = ({
6196
6213
  },
6197
6214
  [httpClient, locale]
6198
6215
  );
6199
- const fetchNextStep = async (action2, data = {}) => {
6200
- setLoadingState(loadingState === "initial" ? "initial" : "submission");
6216
+ const performAction = async (action2, data = {}) => {
6217
+ setLoadingState(!step35 ? "initial" : "submission");
6218
+ dispatchEvent("Dynamic Flow - Step Submitted", { actionId: action2.$id });
6201
6219
  try {
6202
- dispatchEvent("Dynamic Flow - Step Submitted", { actionId: action2.$id });
6203
- const response = await triggerActionRequest({ action: action2, data });
6204
- return handleFetchResponse(response, "submission");
6220
+ const response = await dfHttpClient({ action: action2, data });
6221
+ await handleResponse(response, "submission");
6205
6222
  } catch (error) {
6206
- handleFetchError(error, "Error fetching next step");
6223
+ completeWithError(error, "Error fetching next step");
6207
6224
  }
6208
6225
  };
6209
- const fetchRefreshStep = async (action2, data, etag2) => {
6226
+ const performRefresh = async (url, data, etag2) => {
6210
6227
  setLoadingState("refresh");
6228
+ dispatchEvent("Dynamic Flow - Step Refreshed", { status: "pending" });
6211
6229
  try {
6212
- dispatchEvent("Dynamic Flow - Step Refreshed", { status: "pending" });
6213
- const response = await triggerActionRequest({ action: action2, data, etag: etag2 });
6214
- await handleFetchResponse(response, "refresh");
6215
- setLoadingState("idle");
6230
+ const response = await dfHttpClient({ action: { url, method: "POST" }, data, etag: etag2 });
6231
+ await handleResponse(response, "refresh");
6216
6232
  } catch (error) {
6217
- handleFetchError(error, "Error fetching refresh step");
6233
+ completeWithError(error, "Error fetching refresh step");
6218
6234
  }
6219
6235
  };
6220
- const fetchExitResult = async (action2, data) => {
6236
+ const performExitAction = async (action2, data) => {
6237
+ setLoadingState("submission");
6221
6238
  try {
6222
- const response = await triggerActionRequest({ action: action2, data });
6223
- const exitResult = await parseExitResponse(response);
6224
- dispatchEventAndComplete(__spreadValues(__spreadValues({}, exitResult), action2.result));
6239
+ const response = await dfHttpClient({ action: action2, data });
6240
+ await handleExitResponse(response, action2.result);
6225
6241
  } catch (error) {
6226
- handleFetchError(error, "Error fetching exit result");
6242
+ completeWithError(error, "Error fetching exit result");
6227
6243
  }
6228
6244
  };
6229
- const debouncedFetchRefresh = useDebouncedRefresh(fetchRefreshStep);
6230
- const dispatchEventAndComplete = (0, import_react35.useCallback)(
6245
+ const handleExitResponse = async (response, actionResult) => {
6246
+ const exitResult = await getJsonObjectOrNull(response);
6247
+ dispatchEventAndComplete(__spreadValues(__spreadValues({}, exitResult), actionResult));
6248
+ };
6249
+ const debouncedRefresh = useDebouncedRefresh(performRefresh);
6250
+ const dispatchEventAndComplete = (0, import_react38.useCallback)(
6231
6251
  (result) => {
6232
6252
  dispatchEvent("Dynamic Flow - Flow Finished", { result: "success" });
6233
6253
  onCompletion(result);
6234
6254
  },
6235
6255
  [onCompletion, dispatchEvent]
6236
6256
  );
6237
- (0, import_react35.useEffect)(() => {
6257
+ (0, import_react38.useEffect)(() => {
6238
6258
  dispatchEvent("Dynamic Flow - Flow Started", {});
6239
6259
  }, []);
6240
- (0, import_react35.useEffect)(() => {
6260
+ (0, import_react38.useEffect)(() => {
6241
6261
  if (!initialStep) {
6242
6262
  const action2 = __spreadValues({
6243
6263
  $id: "#initial-step-request",
6244
6264
  method: "GET"
6245
6265
  }, initialAction);
6246
- void fetchNextStep(action2, action2.data);
6266
+ void performAction(action2, action2.data);
6247
6267
  }
6248
6268
  }, [httpClient, locale, JSON.stringify(initialStep), JSON.stringify(initialAction)]);
6249
- const handleFetchResponse = async (response, fetchType) => {
6250
- if (response.ok) {
6251
- try {
6252
- const parsedResponse = await parseFetchResponse(response);
6253
- switch (parsedResponse.type) {
6254
- case "action":
6255
- void fetchNextStep(parsedResponse.action, parsedResponse.action.data);
6256
- return;
6257
- case "exit":
6258
- return dispatchEventAndComplete(parsedResponse.result);
6259
- case "step":
6260
- default: {
6261
- const { step: step34, etag: etag2 } = parsedResponse;
6262
- return fetchType === "submission" ? updateStepAfterSubmission(step34, etag2) : updateStepAfterRefresh(step34, etag2);
6263
- }
6264
- }
6265
- } catch (error) {
6266
- return handleFetchError(error, "Error parsing fetch response");
6269
+ const handleResponse = async (response, fetchType) => {
6270
+ try {
6271
+ if (response.status === 304) {
6272
+ setLoadingState("idle");
6273
+ return;
6274
+ }
6275
+ if (!response.ok) {
6276
+ const errorResponse = await parseErrorResponse(response);
6277
+ void updateAfterError(errorResponse);
6278
+ return;
6279
+ }
6280
+ const result = await parseFetchResponse(response);
6281
+ if (result.type === "action") {
6282
+ void performAction(result.action, result.action.data);
6283
+ } else if (result.type === "exit") {
6284
+ dispatchEventAndComplete(result.result);
6285
+ } else {
6286
+ updateStep(result.step, result.etag, fetchType);
6267
6287
  }
6288
+ } catch (error) {
6289
+ return completeWithError(error, "Error parsing fetch response", fetchType, response.status);
6268
6290
  }
6269
- return handleErrorResponse(response, fetchType);
6270
6291
  };
6271
- const updateStepAfterSubmission = (newStep, etag2) => {
6292
+ const updateStep = (newStep, etag2, fetchType) => {
6272
6293
  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
6294
  setLoadingState("idle");
6280
- dispatchEvent("Dynamic Flow - Step Refreshed", { status: "success" });
6295
+ if (fetchType === "submission") {
6296
+ setSubmitted(false);
6297
+ dispatchEvent("Dynamic Flow - Step Started", __spreadValues({
6298
+ stepId: newStep.id || newStep.key
6299
+ }, newStep == null ? void 0 : newStep.analytics));
6300
+ } else {
6301
+ dispatchEvent("Dynamic Flow - Step Refreshed", { status: "success" });
6302
+ }
6281
6303
  };
6282
- const handleErrorResponse = async (response, fetchType) => {
6283
- if (response.status === 304) {
6284
- setLoadingState("idle");
6285
- return;
6304
+ const updateAfterError = async (errorBody) => {
6305
+ if (errorBody.refreshFormUrl) {
6306
+ await performRefresh(errorBody.refreshFormUrl, combineModels2(models), etag);
6286
6307
  }
6287
- try {
6288
- const errorBody = await parseErrorResponse(response);
6289
- if (errorBody.refreshFormUrl) {
6290
- const action2 = { url: errorBody == null ? void 0 : errorBody.refreshFormUrl, method: "POST" };
6291
- await fetchRefreshStep(action2, combineModels2(models), etag);
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.");
6308
+ if (errorBody.validation) {
6309
+ setFormErrors(errorBody.validation);
6310
+ }
6311
+ if (errorBody.error) {
6312
+ setGlobalError(errorBody.error);
6313
6313
  }
6314
6314
  setLoadingState("idle");
6315
6315
  };
6316
- const handleFetchError = (error, message) => {
6316
+ const completeWithError = (error, message, fetchType, responseStatus) => {
6317
6317
  logCritical("Error fetching", message);
6318
- onError(error);
6318
+ if (fetchType === "refresh") {
6319
+ dispatchEvent("Dynamic Flow - Step Refreshed", { status: "failure" });
6320
+ }
6321
+ dispatchEvent("Dynamic Flow - Flow Finished", { status: "failure" });
6322
+ onError(error, responseStatus);
6319
6323
  setLoadingState("idle");
6320
6324
  };
6321
6325
  const onModelChange = (onModelChangeProps) => {
@@ -6336,62 +6340,37 @@ var DynamicFlowComponent = ({
6336
6340
  const refreshOnChangeIfNeeded = (props, updatedModels) => {
6337
6341
  const { triggerSchema } = props;
6338
6342
  if (shouldTriggerRefresh(props)) {
6339
- const url = triggerSchema.refreshFormUrl || (step33 == null ? void 0 : step33.refreshFormUrl);
6340
- const action2 = { url, method: "POST" };
6341
- debouncedFetchRefresh(action2, combineModels2(updatedModels), etag, triggerSchema);
6343
+ const url = triggerSchema.refreshFormUrl || (step35 == null ? void 0 : step35.refreshFormUrl);
6344
+ if (url) {
6345
+ debouncedRefresh(url, combineModels2(updatedModels), etag, triggerSchema);
6346
+ }
6342
6347
  }
6343
6348
  };
6344
6349
  const onAction = async (action2) => {
6345
- const { data, method, exit: exit2, url, result } = action2;
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
- );
6350
+ if (isLoading || action2.disabled) {
6359
6351
  return;
6360
6352
  }
6361
- if (exit2) {
6362
- if (url) {
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);
6353
+ if (action2.exit && !action2.url) {
6354
+ dispatchEventAndComplete(action2.result);
6375
6355
  return;
6376
6356
  }
6357
+ const actionHandler = action2.exit ? performExitAction : performAction;
6358
+ const { data, method } = action2;
6359
+ const submissionData = __spreadValues(__spreadValues({}, combineModels2(models)), data);
6377
6360
  if (isSubmissionMethod(method)) {
6378
6361
  setFormErrors(null);
6379
6362
  setSubmitted(true);
6380
6363
  if (modelIsValid) {
6381
- void fetchNextStep(action2, submissionData);
6382
- } else {
6383
- dispatchEvent("Dynamic Flow - onAction supressed", __spreadValues({
6384
- reason: "invalid model"
6385
- }, extraLoggingProps));
6364
+ await actionHandler(action2, submissionData);
6386
6365
  }
6387
- return;
6366
+ } else {
6367
+ await actionHandler(action2);
6388
6368
  }
6389
- void fetchNextStep(action2);
6390
6369
  };
6391
- return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(LogProvider, { flowId, stepId: step33 == null ? void 0 : step33.key, onLog, children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(EventsContextProvider, { metadata: analyticsMetadata, onEvent, children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(DynamicFlowProvider, { loading: loadingState !== "idle", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(HttpClientProvider, { httpClient, children: loader !== null ? loader : /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
6370
+ 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
6371
  DynamicFlowStep,
6393
6372
  {
6394
- step: step33,
6373
+ step: step35,
6395
6374
  model: combineModels2(models),
6396
6375
  submitted,
6397
6376
  globalError,
@@ -6442,11 +6421,9 @@ __export(components_exports, {
6442
6421
 
6443
6422
  // src/fixtures/components/alert.ts
6444
6423
  var step = {
6445
- type: "form",
6446
- key: "Components/Alert",
6424
+ id: "Components/Alert",
6447
6425
  title: "Alert Component",
6448
6426
  description: "Alerts can have different contexts.",
6449
- actions: [],
6450
6427
  schemas: [],
6451
6428
  layout: [
6452
6429
  {
@@ -6475,11 +6452,9 @@ var alert_default = step;
6475
6452
 
6476
6453
  // src/fixtures/components/box.ts
6477
6454
  var step2 = {
6478
- type: "form",
6479
- key: "Components/Box",
6455
+ id: "Components/Box",
6480
6456
  title: "Box Component",
6481
6457
  description: "Box is a container for other layour components. It can have a border!",
6482
- actions: [],
6483
6458
  schemas: [],
6484
6459
  layout: ["xs", "sm", "md", "lg", "xl"].map((size) => ({
6485
6460
  type: "box",
@@ -6509,11 +6484,9 @@ var buttons = ["primary", "secondary", "negative", "link"].map(
6509
6484
  })
6510
6485
  );
6511
6486
  var step3 = {
6512
- type: "form",
6513
- key: "Components/Button",
6487
+ id: "Components/Button",
6514
6488
  title: "Button Component",
6515
6489
  description: "Buttons typically trigger actions.",
6516
- actions: [],
6517
6490
  schemas: [
6518
6491
  {
6519
6492
  $id: "#schema",
@@ -6555,11 +6528,9 @@ var button_default = step3;
6555
6528
 
6556
6529
  // src/fixtures/components/columns.ts
6557
6530
  var step4 = {
6558
- type: "form",
6559
- key: "Components/Columns",
6531
+ id: "Components/Columns",
6560
6532
  title: "Columns Component",
6561
6533
  description: `Arrange components in two columns (when there's enough space)`,
6562
- actions: [],
6563
6534
  schemas: [],
6564
6535
  layout: [
6565
6536
  {
@@ -6593,11 +6564,9 @@ var columns_default = step4;
6593
6564
 
6594
6565
  // src/fixtures/components/copyable.ts
6595
6566
  var step5 = {
6596
- key: "Components/Copyable",
6597
- type: "form",
6567
+ id: "Components/Copyable",
6598
6568
  title: "Copyable Text",
6599
6569
  description: "Copyable Text Component.",
6600
- actions: [],
6601
6570
  layout: [
6602
6571
  {
6603
6572
  type: "paragraph",
@@ -6617,11 +6586,9 @@ var copyable_default = step5;
6617
6586
 
6618
6587
  // src/fixtures/components/decision.ts
6619
6588
  var step6 = {
6620
- type: "form",
6621
- key: "Components/Decision",
6589
+ id: "Components/Decision",
6622
6590
  title: "Decision Component",
6623
6591
  description: "A step with a decision Component.",
6624
- actions: [],
6625
6592
  schemas: [],
6626
6593
  layout: [
6627
6594
  {
@@ -6684,11 +6651,9 @@ var decision_default = step6;
6684
6651
 
6685
6652
  // src/fixtures/components/decision-flags.ts
6686
6653
  var step7 = {
6687
- type: "form",
6688
- key: "Components/Decision Flags",
6654
+ id: "Components/Decision Flags",
6689
6655
  title: "Decision Component",
6690
6656
  description: "A step with a decision Component.",
6691
- actions: [],
6692
6657
  schemas: [],
6693
6658
  layout: [
6694
6659
  {
@@ -6715,11 +6680,9 @@ var decision_flags_default = step7;
6715
6680
  // src/fixtures/components/decision-icons.ts
6716
6681
  var icons2 = __toESM(require("@transferwise/icons"));
6717
6682
  var step8 = {
6718
- type: "form",
6719
- key: "Components/Decision Icons",
6683
+ id: "Components/Decision Icons",
6720
6684
  title: "Decision Component",
6721
6685
  description: "A step with a decision Component.",
6722
- actions: [],
6723
6686
  schemas: [],
6724
6687
  layout: [
6725
6688
  {
@@ -6745,11 +6708,9 @@ var decision_icons_default = step8;
6745
6708
 
6746
6709
  // src/fixtures/components/heading.ts
6747
6710
  var step9 = {
6748
- type: "form",
6749
- key: "Components/Heading",
6711
+ id: "Components/Heading",
6750
6712
  title: "Heading Component",
6751
6713
  description: 'Headings can have different sizes: "xs", "sm", "md", "lg", "xl".',
6752
- actions: [],
6753
6714
  schemas: [],
6754
6715
  layout: ["xs", "sm", "md", "lg", "xl"].map((size) => ({
6755
6716
  type: "heading",
@@ -6762,11 +6723,9 @@ var heading_default = step9;
6762
6723
  // src/fixtures/components/image.ts
6763
6724
  var sizes = ["xs", "sm", "md", "lg", "xl"];
6764
6725
  var step10 = {
6765
- type: "form",
6766
- key: "Components/Image",
6726
+ id: "Components/Image",
6767
6727
  title: "Image Component",
6768
6728
  description: 'Images can have different sizes: "xs", "sm", "md", "lg", "xl".',
6769
- actions: [],
6770
6729
  schemas: [],
6771
6730
  layout: sizes.flatMap((size) => [
6772
6731
  {
@@ -6776,7 +6735,7 @@ var step10 = {
6776
6735
  },
6777
6736
  {
6778
6737
  type: "image",
6779
- url: "http://placekitten.com/g/400/400",
6738
+ 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
6739
  text: `This is an image with size: "${size}"`,
6781
6740
  size
6782
6741
  }
@@ -6786,11 +6745,9 @@ var image_default = step10;
6786
6745
 
6787
6746
  // src/fixtures/components/info.ts
6788
6747
  var step11 = {
6789
- type: "form",
6790
- key: "Components/Info",
6748
+ id: "Components/Info",
6791
6749
  title: "Info Component",
6792
6750
  description: "A block of markdown content.",
6793
- actions: [],
6794
6751
  schemas: [],
6795
6752
  layout: [
6796
6753
  {
@@ -6821,11 +6778,9 @@ var info_default = step11;
6821
6778
 
6822
6779
  // src/fixtures/components/list.ts
6823
6780
  var step12 = {
6824
- type: "form",
6825
- key: "Components/List",
6781
+ id: "Components/List",
6826
6782
  title: "List Component",
6827
6783
  description: "A list of items with optional states, subtitles, and images.",
6828
- actions: [],
6829
6784
  schemas: [],
6830
6785
  layout: [
6831
6786
  {
@@ -6857,11 +6812,9 @@ var list_default = step12;
6857
6812
 
6858
6813
  // src/fixtures/components/loading-indicator.ts
6859
6814
  var step13 = {
6860
- type: "form",
6861
- key: "Components/Loading Indicator",
6815
+ id: "Components/Loading Indicator",
6862
6816
  title: "Loading Indicator Component",
6863
6817
  description: "A loading indicator to be displayed within a layout.",
6864
- actions: [],
6865
6818
  schemas: [],
6866
6819
  layout: [
6867
6820
  {
@@ -6875,11 +6828,9 @@ var loading_indicator_default = step13;
6875
6828
 
6876
6829
  // src/fixtures/components/paragraph.ts
6877
6830
  var step14 = {
6878
- type: "form",
6879
- key: "Components/Paragraph",
6831
+ id: "Components/Paragraph",
6880
6832
  title: "Paragraph Component",
6881
6833
  description: `A block of plain text.`,
6882
- actions: [],
6883
6834
  schemas: [],
6884
6835
  layout: [
6885
6836
  {
@@ -6905,11 +6856,9 @@ var paragraph_default = step14;
6905
6856
 
6906
6857
  // src/fixtures/components/review.ts
6907
6858
  var step15 = {
6908
- type: "form",
6909
- key: "Components/Review",
6859
+ id: "Components/Review",
6910
6860
  title: "Review Component",
6911
6861
  description: `Show a list of read-only fields.`,
6912
- actions: [],
6913
6862
  schemas: [],
6914
6863
  layout: [
6915
6864
  {
@@ -6977,9 +6926,8 @@ __export(examples_exports, {
6977
6926
 
6978
6927
  // src/fixtures/examples/camera-capture.ts
6979
6928
  var step16 = {
6980
- key: "Examples/Camera Capture",
6929
+ id: "Examples/Camera Capture",
6981
6930
  title: "Camera Capture Example",
6982
- type: "form",
6983
6931
  schemas: [
6984
6932
  {
6985
6933
  properties: {
@@ -7100,11 +7048,9 @@ var camera_capture_default = step16;
7100
7048
 
7101
7049
  // src/fixtures/examples/recipient.ts
7102
7050
  var step17 = {
7103
- key: "Examples/Recipient Creation",
7104
- type: "form",
7051
+ id: "Examples/Recipient Creation",
7105
7052
  title: "Recipient Creation Example",
7106
7053
  description: "A form step with the typical recipient creation form.",
7107
- actions: [],
7108
7054
  schemas: [
7109
7055
  {
7110
7056
  $id: "#new-recipient",
@@ -7415,18 +7361,8 @@ var recipient_default = step17;
7415
7361
 
7416
7362
  // src/fixtures/examples/recipient-update.ts
7417
7363
  var step18 = {
7418
- key: "Examples/Recipient Update",
7419
- type: "form",
7364
+ id: "Examples/Recipient Update",
7420
7365
  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
7366
  schemas: [
7431
7367
  {
7432
7368
  $id: "form",
@@ -7658,7 +7594,11 @@ var step18 = {
7658
7594
  {
7659
7595
  type: "button",
7660
7596
  action: {
7661
- $ref: "submit"
7597
+ $id: "submit",
7598
+ title: "Update",
7599
+ url: "/responses/recipientUpdate/?delay=5000",
7600
+ type: "primary",
7601
+ method: "PATCH"
7662
7602
  }
7663
7603
  }
7664
7604
  ]
@@ -7667,10 +7607,8 @@ var recipient_update_default = step18;
7667
7607
 
7668
7608
  // src/fixtures/examples/single-file-upload.ts
7669
7609
  var step19 = {
7670
- key: "Examples/Single File Upload",
7671
- type: "form",
7610
+ id: "Examples/Single File Upload",
7672
7611
  title: "Single File Upload Example",
7673
- actions: [],
7674
7612
  schemas: [
7675
7613
  {
7676
7614
  $id: "#schema-1",
@@ -7767,9 +7705,8 @@ var single_file_upload_default = step19;
7767
7705
 
7768
7706
  // src/fixtures/examples/step-validation-errors.ts
7769
7707
  var step20 = {
7770
- key: "Examples/Step Validation Errors",
7708
+ id: "Examples/Step Validation Errors",
7771
7709
  title: "Step with validation errors",
7772
- type: "form",
7773
7710
  errors: {
7774
7711
  validation: {
7775
7712
  "bridekeeper-questions": {
@@ -7777,7 +7714,6 @@ var step20 = {
7777
7714
  }
7778
7715
  }
7779
7716
  },
7780
- actions: [],
7781
7717
  layout: [
7782
7718
  {
7783
7719
  type: "form",
@@ -7854,11 +7790,10 @@ __export(features_exports, {
7854
7790
 
7855
7791
  // src/fixtures/features/action-response.ts
7856
7792
  var step21 = {
7857
- key: "Features/Action Response",
7793
+ id: "Features/Action Response",
7858
7794
  title: "Action Response",
7859
7795
  description: "",
7860
7796
  type: "form",
7861
- actions: [],
7862
7797
  schemas: [],
7863
7798
  layout: [
7864
7799
  {
@@ -7886,7 +7821,7 @@ var action_response_default = step21;
7886
7821
  // src/fixtures/features/external.ts
7887
7822
  var step22 = {
7888
7823
  type: "form",
7889
- key: "Features/External",
7824
+ id: "Features/External",
7890
7825
  title: "External Feature",
7891
7826
  description: "Your bank is opening in another window.",
7892
7827
  external: { url: "http://google.com/" },
@@ -7911,15 +7846,13 @@ var step22 = {
7911
7846
  markdown: `If it didn't work, you can [reopen](http://google.com/) the tab`
7912
7847
  }
7913
7848
  ],
7914
- actions: [],
7915
7849
  schemas: []
7916
7850
  };
7917
7851
  var external_default = step22;
7918
7852
 
7919
7853
  // src/fixtures/features/persist-async.ts
7920
7854
  var step23 = {
7921
- type: "form",
7922
- key: "Features/Persist Async",
7855
+ id: "Features/Persist Async",
7923
7856
  title: "Persist Async Feature",
7924
7857
  schemas: [
7925
7858
  {
@@ -7945,14 +7878,6 @@ var step23 = {
7945
7878
  }
7946
7879
  }
7947
7880
  ],
7948
- actions: [
7949
- {
7950
- title: "Submit Persist Async",
7951
- url: "/persist-async-submit",
7952
- method: "POST",
7953
- type: "primary"
7954
- }
7955
- ],
7956
7881
  layout: [
7957
7882
  {
7958
7883
  type: "form",
@@ -7964,8 +7889,7 @@ var persist_async_default = step23;
7964
7889
 
7965
7890
  // src/fixtures/features/polling.ts
7966
7891
  var step24 = {
7967
- type: "form",
7968
- key: "Features/Polling",
7892
+ id: "Features/Polling",
7969
7893
  title: "Polling Feature",
7970
7894
  description: "Polling feature in a form step.",
7971
7895
  polling: {
@@ -7992,7 +7916,6 @@ var step24 = {
7992
7916
  }
7993
7917
  }
7994
7918
  ],
7995
- actions: [],
7996
7919
  schemas: []
7997
7920
  };
7998
7921
  var polling_default = step24;
@@ -8000,7 +7923,7 @@ var polling_default = step24;
8000
7923
  // src/fixtures/features/validation-async.ts
8001
7924
  var step25 = {
8002
7925
  type: "form",
8003
- key: "Features/Validation Async",
7926
+ id: "Features/Validation Async",
8004
7927
  title: "Validation Async Feature",
8005
7928
  schemas: [
8006
7929
  {
@@ -8030,7 +7953,6 @@ var step25 = {
8030
7953
  }
8031
7954
  }
8032
7955
  ],
8033
- actions: [],
8034
7956
  model: {
8035
7957
  // name: 'Colin Robinson',
8036
7958
  }
@@ -8304,29 +8226,9 @@ var list_default2 = layout3;
8304
8226
 
8305
8227
  // src/fixtures/layouts/pay-in.ts
8306
8228
  var step26 = {
8307
- key: "PAY_ID",
8229
+ id: "PAY_ID",
8308
8230
  type: "form",
8309
8231
  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
8232
  schemas: [
8331
8233
  {
8332
8234
  title: "Pay Using PayID",
@@ -8388,13 +8290,25 @@ var step26 = {
8388
8290
  {
8389
8291
  type: "button",
8390
8292
  action: {
8391
- $ref: "#payNow"
8293
+ title: "I have paid",
8294
+ type: "primary",
8295
+ exit: true,
8296
+ result: {
8297
+ paid: "POTENTIALLY_PAID"
8298
+ },
8299
+ $id: "#payNow"
8392
8300
  }
8393
8301
  },
8394
8302
  {
8395
8303
  type: "button",
8396
8304
  action: {
8397
- $ref: "#payLater"
8305
+ $id: "#payLater",
8306
+ title: "I'll transfer my money later",
8307
+ type: "secondary",
8308
+ exit: true,
8309
+ result: {
8310
+ paid: "NOT_PAID"
8311
+ }
8398
8312
  }
8399
8313
  }
8400
8314
  ]
@@ -8646,11 +8560,9 @@ var action_default = action;
8646
8560
 
8647
8561
  // src/fixtures/responses/action-response-final.ts
8648
8562
  var step27 = {
8649
- type: "form",
8650
- key: "action-response-final",
8563
+ id: "action-response-final",
8651
8564
  title: "Action Response Final Step",
8652
8565
  description: `This step was loaded as a result of an Action Response.`,
8653
- actions: [],
8654
8566
  schemas: [],
8655
8567
  layout: [
8656
8568
  {
@@ -8676,11 +8588,9 @@ var exit_default = exit;
8676
8588
 
8677
8589
  // src/fixtures/responses/recipient-update-final.ts
8678
8590
  var step28 = {
8679
- type: "form",
8680
- key: "recipient-update-final",
8591
+ id: "recipient-update-final",
8681
8592
  title: "Recipient Update Final Step",
8682
8593
  description: `The recipient has been updated.`,
8683
- actions: [],
8684
8594
  schemas: [],
8685
8595
  layout: [
8686
8596
  {
@@ -8703,6 +8613,8 @@ var recipient_update_final_default = step28;
8703
8613
  // src/fixtures/schemas/index.ts
8704
8614
  var schemas_exports = {};
8705
8615
  __export(schemas_exports, {
8616
+ allOf: () => all_of_default,
8617
+ boolean: () => boolean_default,
8706
8618
  numberAndInteger: () => number_and_integer_default,
8707
8619
  oneOf: () => one_of_default,
8708
8620
  simpleForm: () => basic_form_default,
@@ -8711,11 +8623,9 @@ __export(schemas_exports, {
8711
8623
 
8712
8624
  // src/fixtures/schemas/basic-form.ts
8713
8625
  var step29 = {
8714
- key: "Schemas/Basic Form",
8626
+ id: "Schemas/Basic Form",
8715
8627
  title: "Simple Form",
8716
8628
  description: "A simple form with text fields and a checkbox.",
8717
- type: "form",
8718
- actions: [],
8719
8629
  schemas: [
8720
8630
  {
8721
8631
  $id: "#the-schema",
@@ -8752,11 +8662,9 @@ var basic_form_default = step29;
8752
8662
 
8753
8663
  // src/fixtures/schemas/number-and-integer.ts
8754
8664
  var step30 = {
8755
- key: "Schemas/Number And Integer",
8665
+ id: "Schemas/Number And Integer",
8756
8666
  title: "Number and Integer Schemas",
8757
8667
  description: "Number and Integer Schemas.",
8758
- type: "form",
8759
- actions: [],
8760
8668
  schemas: [
8761
8669
  {
8762
8670
  $id: "#the-schema",
@@ -8857,12 +8765,10 @@ var currencies = [
8857
8765
  ["ZMW", "Zambian kwacha"]
8858
8766
  ];
8859
8767
  var step31 = {
8860
- key: "Schemas/OneOf",
8768
+ id: "Schemas/OneOf",
8861
8769
  title: "OneOf Schemas",
8862
8770
  description: "OneOf Schema using select, radio buttons and tabs.",
8863
- type: "form",
8864
8771
  analytics: { custom: "this is the oneOf fixture" },
8865
- actions: [],
8866
8772
  schemas: [
8867
8773
  {
8868
8774
  $id: "#the-schema",
@@ -9018,11 +8924,9 @@ var one_of_default = step31;
9018
8924
 
9019
8925
  // src/fixtures/schemas/string-formats.ts
9020
8926
  var step32 = {
9021
- key: "Schemas/String Formats",
8927
+ id: "Schemas/String Formats",
9022
8928
  title: "String Schema Formats",
9023
8929
  description: "String schemas with different formats (password, date, telephone).",
9024
- type: "form",
9025
- actions: [],
9026
8930
  schemas: [
9027
8931
  {
9028
8932
  $id: "#the-schema",
@@ -9080,19 +8984,140 @@ var step32 = {
9080
8984
  };
9081
8985
  var string_formats_default = step32;
9082
8986
 
8987
+ // src/fixtures/schemas/boolean.ts
8988
+ var step33 = {
8989
+ key: "Schemas/Boolean Schema",
8990
+ title: "Boolean Schema",
8991
+ description: "A simple form with a boolean schema with no default value.",
8992
+ actions: [],
8993
+ schemas: [
8994
+ {
8995
+ $id: "#schema-1",
8996
+ type: "object",
8997
+ displayOrder: ["pineapple"],
8998
+ required: ["pineapple"],
8999
+ properties: {
9000
+ pineapple: {
9001
+ title: "Pineapple on pizza (boolean schema)",
9002
+ type: "boolean"
9003
+ }
9004
+ }
9005
+ }
9006
+ ],
9007
+ layout: [
9008
+ {
9009
+ type: "form",
9010
+ schema: { $ref: "#schema-1" }
9011
+ },
9012
+ {
9013
+ type: "button",
9014
+ action: {
9015
+ url: "/submit",
9016
+ title: "Submit",
9017
+ type: "primary"
9018
+ }
9019
+ }
9020
+ ]
9021
+ };
9022
+ var boolean_default = step33;
9023
+
9024
+ // src/fixtures/schemas/all-of.ts
9025
+ var step34 = {
9026
+ key: "Schemas/AllOf",
9027
+ title: "AllOf Schemas",
9028
+ description: "Three object schemas wrapped in an allOf.",
9029
+ analytics: { custom: "this is the allOf fixture" },
9030
+ actions: [],
9031
+ schemas: [
9032
+ {
9033
+ $id: "#the-schema",
9034
+ allOf: [
9035
+ {
9036
+ $id: "#schema-1",
9037
+ type: "object",
9038
+ properties: {
9039
+ name: { title: "Name", type: "string" }
9040
+ },
9041
+ displayOrder: ["name"]
9042
+ },
9043
+ {
9044
+ $id: "#schema-2",
9045
+ type: "object",
9046
+ properties: {
9047
+ city: { title: "City", type: "string" }
9048
+ },
9049
+ displayOrder: ["city"]
9050
+ },
9051
+ {
9052
+ $id: "#schema-3",
9053
+ type: "object",
9054
+ properties: {
9055
+ color: {
9056
+ title: 'What is your favourite colour? (oneOf schema with more than two options default to control: "select")',
9057
+ placeholder: "Please select a colour",
9058
+ analyticsId: "colour-select",
9059
+ oneOf: [
9060
+ {
9061
+ title: "Blue",
9062
+ analyticsId: "colour-select-blue",
9063
+ image: {
9064
+ url: "https://placeholder.pics/svg/64/0099ff/FFFFFF"
9065
+ },
9066
+ const: 1
9067
+ },
9068
+ {
9069
+ title: "Yellow",
9070
+ analyticsId: "colour-select-yellow",
9071
+ image: {
9072
+ url: "https://placeholder.pics/svg/64/ffcc00/FFFFFF"
9073
+ },
9074
+ const: 2
9075
+ },
9076
+ {
9077
+ title: "Red",
9078
+ analyticsId: "colour-select-red",
9079
+ image: {
9080
+ url: "https://placeholder.pics/svg/64/ff6600/FFFFFF"
9081
+ },
9082
+ const: 3
9083
+ }
9084
+ ]
9085
+ }
9086
+ },
9087
+ displayOrder: ["color"]
9088
+ }
9089
+ ]
9090
+ }
9091
+ ],
9092
+ layout: [
9093
+ {
9094
+ type: "form",
9095
+ schema: { $ref: "#the-schema" }
9096
+ },
9097
+ {
9098
+ type: "button",
9099
+ action: {
9100
+ url: "/submit",
9101
+ title: "Submit",
9102
+ type: "primary"
9103
+ }
9104
+ }
9105
+ ]
9106
+ };
9107
+ var all_of_default = step34;
9108
+
9083
9109
  // src/fixtures/utils/image-util.ts
9084
9110
  var getImageStep = (size) => {
9085
9111
  return {
9086
9112
  type: "form",
9087
- key: `Components/Image-${size}`,
9113
+ id: `Components/Image-${size}`,
9088
9114
  title: `Image Component - ${size}`,
9089
9115
  description: `This is an image with size: "${size}"`,
9090
- actions: [],
9091
9116
  schemas: [],
9092
9117
  layout: [
9093
9118
  {
9094
9119
  type: "image",
9095
- url: "http://placekitten.com/g/400/400",
9120
+ 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
9121
  text: `This is an image with size: "${size}"`,
9097
9122
  size
9098
9123
  }