@wise/dynamic-flow-client 5.2.0 → 5.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/main.css +10 -2
- package/build/main.js +235 -185
- package/build/main.mjs +235 -185
- package/build/types/domain/components/FormattedValueComponent.d.ts +16 -0
- package/build/types/domain/components/RootDomainComponent.d.ts +4 -2
- package/build/types/domain/mappers/schema/objectSchemaToComponent/objectSchemaToFormattedValueComponent.d.ts +7 -0
- package/build/types/domain/mappers/schema/oneOfSchemaToComponent/oneOfSchemaToComponent.d.ts +25 -0
- package/build/types/domain/mappers/schema/persistAsyncSchemaToComponent.d.ts +25 -0
- package/build/types/domain/types.d.ts +2 -1
- package/build/types/index.d.ts +3 -3
- package/build/types/renderers/mappers/formattedValueComponentToProps.d.ts +4 -0
- package/build/types/types.d.ts +1 -11
- package/build/types/useDynamicFlow.d.ts +12 -0
- package/build/types/{useDynamicFlowCore.d.ts → useDynamicFlowController.d.ts} +2 -1
- package/build/types/utils/{scrollToTop.d.ts → getScrollToTop.d.ts} +1 -1
- package/package.json +11 -11
- package/build/types/DynamicFormCore.d.ts +0 -11
package/build/main.css
CHANGED
|
@@ -14,7 +14,11 @@
|
|
|
14
14
|
.df-box-renderer-width-lg {
|
|
15
15
|
width: 100%;
|
|
16
16
|
}
|
|
17
|
-
@media screen and (width >=
|
|
17
|
+
@media screen and (width >=768px) {
|
|
18
|
+
.df-box-renderer-border {
|
|
19
|
+
padding: var(--size-24);
|
|
20
|
+
}
|
|
21
|
+
|
|
18
22
|
.df-box-renderer-width-xs {
|
|
19
23
|
width: 33.33%;
|
|
20
24
|
}
|
|
@@ -31,7 +35,7 @@
|
|
|
31
35
|
width: 83.33%;
|
|
32
36
|
}
|
|
33
37
|
}
|
|
34
|
-
@media screen and (width >=
|
|
38
|
+
@media screen and (width >=990px) {
|
|
35
39
|
.df-box-renderer-width-xs {
|
|
36
40
|
width: 25%;
|
|
37
41
|
}
|
|
@@ -176,6 +180,10 @@
|
|
|
176
180
|
.tw-modal-body--scrollable .df-step-fixed__footer {
|
|
177
181
|
bottom: -24px;
|
|
178
182
|
}
|
|
183
|
+
.df-modal .df-back-button {
|
|
184
|
+
position: fixed;
|
|
185
|
+
top: 24px;
|
|
186
|
+
}
|
|
179
187
|
.chips-container {
|
|
180
188
|
overflow-x: auto;
|
|
181
189
|
}
|
package/build/main.js
CHANGED
|
@@ -57,10 +57,10 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
57
57
|
var index_exports = {};
|
|
58
58
|
__export(index_exports, {
|
|
59
59
|
DynamicFlow: () => DynamicFlowCore,
|
|
60
|
-
DynamicForm: () => DynamicFormCore,
|
|
61
60
|
findRendererPropsByType: () => findRendererPropsByType,
|
|
62
61
|
makeHttpClient: () => makeHttpClient,
|
|
63
|
-
translations: () => i18n_default
|
|
62
|
+
translations: () => i18n_default,
|
|
63
|
+
useDynamicFlow: () => useDynamicFlow
|
|
64
64
|
});
|
|
65
65
|
module.exports = __toCommonJS(index_exports);
|
|
66
66
|
|
|
@@ -778,7 +778,83 @@ var translations = {
|
|
|
778
778
|
};
|
|
779
779
|
var i18n_default = translations;
|
|
780
780
|
|
|
781
|
-
// src/
|
|
781
|
+
// src/utils/type-validators.ts
|
|
782
|
+
var isString = (value) => typeof value === "string";
|
|
783
|
+
var isNumber = (value) => typeof value === "number" && !Number.isNaN(value);
|
|
784
|
+
var isInteger = (value) => isNumber(value) && Math.floor(value) === value;
|
|
785
|
+
var isBoolean = (value) => typeof value === "boolean";
|
|
786
|
+
var isObject = (value) => !isNullish(value) && (value == null ? void 0 : value.constructor) === Object;
|
|
787
|
+
var isArray = (value) => Array.isArray(value);
|
|
788
|
+
var isNull = (value) => value === null;
|
|
789
|
+
var isUndefined = (value) => typeof value === "undefined";
|
|
790
|
+
var isNullish = (v) => isNull(v) || isUndefined(v);
|
|
791
|
+
var isFile = (value) => value instanceof File;
|
|
792
|
+
var isValidDate = (value) => isString(value) && /^\d{4}-\d{2}-\d{2}$/.test(value);
|
|
793
|
+
|
|
794
|
+
// src/renderers/utils.ts
|
|
795
|
+
function findRendererPropsByType(root, type, predicate = () => true) {
|
|
796
|
+
if (isArray(root)) {
|
|
797
|
+
return root.flatMap((child) => findRendererPropsByType(child, type, predicate));
|
|
798
|
+
}
|
|
799
|
+
return [
|
|
800
|
+
...isType(root, type) && predicate(root) ? [root] : [],
|
|
801
|
+
...getChildren(root).flatMap((child) => findRendererPropsByType(child, type, predicate))
|
|
802
|
+
];
|
|
803
|
+
}
|
|
804
|
+
var isType = (node, type) => node.type === type;
|
|
805
|
+
var getChildren = (node) => {
|
|
806
|
+
switch (node.type) {
|
|
807
|
+
case "root":
|
|
808
|
+
case "box":
|
|
809
|
+
case "container":
|
|
810
|
+
case "form":
|
|
811
|
+
case "form-section":
|
|
812
|
+
case "step":
|
|
813
|
+
case "modal":
|
|
814
|
+
case "section":
|
|
815
|
+
return node.childrenProps;
|
|
816
|
+
case "columns":
|
|
817
|
+
return [...node.startChildrenProps, ...node.endChildrenProps];
|
|
818
|
+
case "modal-layout":
|
|
819
|
+
return node.content.childrenProps;
|
|
820
|
+
case "repeatable":
|
|
821
|
+
return node.editableItemProps ? [node.editableItemProps] : [];
|
|
822
|
+
case "input-select":
|
|
823
|
+
return node.childrenProps ? [node.childrenProps] : [];
|
|
824
|
+
case "tabs":
|
|
825
|
+
return node.tabs.flatMap((c) => c.childrenProps);
|
|
826
|
+
case "alert":
|
|
827
|
+
case "button":
|
|
828
|
+
case "input-checkbox":
|
|
829
|
+
case "input-date":
|
|
830
|
+
case "decision":
|
|
831
|
+
case "divider":
|
|
832
|
+
case "formatted-value":
|
|
833
|
+
case "heading":
|
|
834
|
+
case "hidden":
|
|
835
|
+
case "image":
|
|
836
|
+
case "instructions":
|
|
837
|
+
case "input-integer":
|
|
838
|
+
case "list":
|
|
839
|
+
case "loading-indicator":
|
|
840
|
+
case "markdown":
|
|
841
|
+
case "input-multi-select":
|
|
842
|
+
case "input-upload-multi":
|
|
843
|
+
case "input-number":
|
|
844
|
+
case "money-input":
|
|
845
|
+
case "paragraph":
|
|
846
|
+
case "progress":
|
|
847
|
+
case "review":
|
|
848
|
+
case "search":
|
|
849
|
+
case "status-list":
|
|
850
|
+
case "input-text":
|
|
851
|
+
case "input-upload":
|
|
852
|
+
case "external-confirmation":
|
|
853
|
+
return [];
|
|
854
|
+
}
|
|
855
|
+
};
|
|
856
|
+
|
|
857
|
+
// src/useDynamicFlow.tsx
|
|
782
858
|
var import_react4 = require("react");
|
|
783
859
|
|
|
784
860
|
// src/common/errorBoundary/ErrorBoundary.tsx
|
|
@@ -882,81 +958,6 @@ var CoreContainerRenderer = {
|
|
|
882
958
|
render: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, { children })
|
|
883
959
|
};
|
|
884
960
|
|
|
885
|
-
// src/utils/type-validators.ts
|
|
886
|
-
var isString = (value) => typeof value === "string";
|
|
887
|
-
var isNumber = (value) => typeof value === "number" && !Number.isNaN(value);
|
|
888
|
-
var isInteger = (value) => isNumber(value) && Math.floor(value) === value;
|
|
889
|
-
var isBoolean = (value) => typeof value === "boolean";
|
|
890
|
-
var isObject = (value) => !isNullish(value) && (value == null ? void 0 : value.constructor) === Object;
|
|
891
|
-
var isArray = (value) => Array.isArray(value);
|
|
892
|
-
var isNull = (value) => value === null;
|
|
893
|
-
var isUndefined = (value) => typeof value === "undefined";
|
|
894
|
-
var isNullish = (v) => isNull(v) || isUndefined(v);
|
|
895
|
-
var isFile = (value) => value instanceof File;
|
|
896
|
-
var isValidDate = (value) => isString(value) && /^\d{4}-\d{2}-\d{2}$/.test(value);
|
|
897
|
-
|
|
898
|
-
// src/renderers/utils.ts
|
|
899
|
-
function findRendererPropsByType(root, type, predicate = () => true) {
|
|
900
|
-
if (isArray(root)) {
|
|
901
|
-
return root.flatMap((child) => findRendererPropsByType(child, type, predicate));
|
|
902
|
-
}
|
|
903
|
-
return [
|
|
904
|
-
...isType(root, type) && predicate(root) ? [root] : [],
|
|
905
|
-
...getChildren(root).flatMap((child) => findRendererPropsByType(child, type, predicate))
|
|
906
|
-
];
|
|
907
|
-
}
|
|
908
|
-
var isType = (node, type) => node.type === type;
|
|
909
|
-
var getChildren = (node) => {
|
|
910
|
-
switch (node.type) {
|
|
911
|
-
case "root":
|
|
912
|
-
case "box":
|
|
913
|
-
case "container":
|
|
914
|
-
case "form":
|
|
915
|
-
case "form-section":
|
|
916
|
-
case "step":
|
|
917
|
-
case "modal":
|
|
918
|
-
case "section":
|
|
919
|
-
return node.childrenProps;
|
|
920
|
-
case "columns":
|
|
921
|
-
return [...node.startChildrenProps, ...node.endChildrenProps];
|
|
922
|
-
case "modal-layout":
|
|
923
|
-
return node.content.childrenProps;
|
|
924
|
-
case "repeatable":
|
|
925
|
-
return node.editableItemProps ? [node.editableItemProps] : [];
|
|
926
|
-
case "input-select":
|
|
927
|
-
return node.childrenProps ? [node.childrenProps] : [];
|
|
928
|
-
case "tabs":
|
|
929
|
-
return node.tabs.flatMap((c) => c.childrenProps);
|
|
930
|
-
case "alert":
|
|
931
|
-
case "button":
|
|
932
|
-
case "input-checkbox":
|
|
933
|
-
case "input-date":
|
|
934
|
-
case "decision":
|
|
935
|
-
case "divider":
|
|
936
|
-
case "heading":
|
|
937
|
-
case "hidden":
|
|
938
|
-
case "image":
|
|
939
|
-
case "instructions":
|
|
940
|
-
case "input-integer":
|
|
941
|
-
case "list":
|
|
942
|
-
case "loading-indicator":
|
|
943
|
-
case "markdown":
|
|
944
|
-
case "input-multi-select":
|
|
945
|
-
case "input-upload-multi":
|
|
946
|
-
case "input-number":
|
|
947
|
-
case "money-input":
|
|
948
|
-
case "paragraph":
|
|
949
|
-
case "progress":
|
|
950
|
-
case "review":
|
|
951
|
-
case "search":
|
|
952
|
-
case "status-list":
|
|
953
|
-
case "input-text":
|
|
954
|
-
case "input-upload":
|
|
955
|
-
case "external-confirmation":
|
|
956
|
-
return [];
|
|
957
|
-
}
|
|
958
|
-
};
|
|
959
|
-
|
|
960
961
|
// src/renderers/CoreRootRenderer.tsx
|
|
961
962
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
962
963
|
var CoreRootRenderer = {
|
|
@@ -1276,6 +1277,29 @@ var externalComponentToProps = (component, rendererMapperProps) => {
|
|
|
1276
1277
|
}, rendererMapperProps);
|
|
1277
1278
|
};
|
|
1278
1279
|
|
|
1280
|
+
// src/renderers/mappers/formattedValueComponentToProps.ts
|
|
1281
|
+
var formattedValueComponentToProps = (component, rendererMapperProps) => {
|
|
1282
|
+
return __spreadValues(__spreadProps(__spreadValues({
|
|
1283
|
+
type: "formatted-value"
|
|
1284
|
+
}, pick(
|
|
1285
|
+
component,
|
|
1286
|
+
"format",
|
|
1287
|
+
"uid",
|
|
1288
|
+
"analyticsId",
|
|
1289
|
+
"control",
|
|
1290
|
+
"description",
|
|
1291
|
+
"help",
|
|
1292
|
+
"media",
|
|
1293
|
+
"tags",
|
|
1294
|
+
"title"
|
|
1295
|
+
// for now, we don't want to pass `value` down to the renderer to avoid the "WhateverComponent".
|
|
1296
|
+
// 'value',
|
|
1297
|
+
)), {
|
|
1298
|
+
validationState: getValidationState(component.errors, void 0),
|
|
1299
|
+
onChange: component.onChange.bind(component)
|
|
1300
|
+
}), rendererMapperProps);
|
|
1301
|
+
};
|
|
1302
|
+
|
|
1279
1303
|
// src/renderers/mappers/formComponentToProps.ts
|
|
1280
1304
|
var formComponentToProps = (component, rendererMapperProps) => {
|
|
1281
1305
|
const childrenProps = component.getChildren().map((c) => componentToRendererProps(c, rendererMapperProps));
|
|
@@ -1931,6 +1955,8 @@ var getComponentProps = (component, rendererMapperProps) => {
|
|
|
1931
1955
|
return dividerComponentToProps(component, rendererMapperProps);
|
|
1932
1956
|
case "external-confirmation":
|
|
1933
1957
|
return externalComponentToProps(component, rendererMapperProps);
|
|
1958
|
+
case "formatted-value":
|
|
1959
|
+
return formattedValueComponentToProps(component, rendererMapperProps);
|
|
1934
1960
|
case "form":
|
|
1935
1961
|
return formComponentToProps(component, rendererMapperProps);
|
|
1936
1962
|
case "heading":
|
|
@@ -2003,7 +2029,7 @@ var getComponentAlertProps = (component, rendererMapperProps) => "alert" in comp
|
|
|
2003
2029
|
markdown: component.alert.content
|
|
2004
2030
|
}, rendererMapperProps) : null;
|
|
2005
2031
|
|
|
2006
|
-
// src/
|
|
2032
|
+
// src/useDynamicFlowController.tsx
|
|
2007
2033
|
var import_react3 = require("react");
|
|
2008
2034
|
var import_react_intl7 = require("react-intl");
|
|
2009
2035
|
|
|
@@ -2024,8 +2050,7 @@ var createRootDomainComponent = (updateComponent, scrollToTop, backConfig) => {
|
|
|
2024
2050
|
uid: "root",
|
|
2025
2051
|
stepComponent: null,
|
|
2026
2052
|
stepStack: [],
|
|
2027
|
-
|
|
2028
|
-
isFlowCancellable: backConfig.isFlowCancellable,
|
|
2053
|
+
backConfig,
|
|
2029
2054
|
_update(updateFn) {
|
|
2030
2055
|
update(this, updateFn);
|
|
2031
2056
|
},
|
|
@@ -2159,7 +2184,7 @@ var createRootDomainComponent = (updateComponent, scrollToTop, backConfig) => {
|
|
|
2159
2184
|
var _a, _b;
|
|
2160
2185
|
const navigation = (_a = this.getStep()) == null ? void 0 : _a.step.navigation;
|
|
2161
2186
|
const stepHasBehavior = Boolean((_b = navigation == null ? void 0 : navigation.back) != null ? _b : navigation == null ? void 0 : navigation.backButton);
|
|
2162
|
-
return this.isFlowCancellable || this.stepStack.length > 1 && this.isNativeBackEnabled || stepHasBehavior;
|
|
2187
|
+
return this.backConfig.isFlowCancellable || this.stepStack.length > 1 && this.backConfig.isNativeBackEnabled || stepHasBehavior;
|
|
2163
2188
|
}
|
|
2164
2189
|
};
|
|
2165
2190
|
return rootComponent;
|
|
@@ -5600,6 +5625,83 @@ var integerSchemaToComponent = (schemaMapperProps, mapperProps) => {
|
|
|
5600
5625
|
);
|
|
5601
5626
|
};
|
|
5602
5627
|
|
|
5628
|
+
// src/domain/components/FormattedValueComponent.ts
|
|
5629
|
+
var createFormattedValueComponent = (props, updateComponent) => {
|
|
5630
|
+
const {
|
|
5631
|
+
uid,
|
|
5632
|
+
schemaId,
|
|
5633
|
+
analyticsId,
|
|
5634
|
+
alert,
|
|
5635
|
+
control,
|
|
5636
|
+
description,
|
|
5637
|
+
errors,
|
|
5638
|
+
format,
|
|
5639
|
+
help,
|
|
5640
|
+
hidden,
|
|
5641
|
+
media,
|
|
5642
|
+
summariser,
|
|
5643
|
+
title,
|
|
5644
|
+
tags,
|
|
5645
|
+
value,
|
|
5646
|
+
schemaOnChange
|
|
5647
|
+
} = props;
|
|
5648
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
5649
|
+
return {
|
|
5650
|
+
type: "formatted-value",
|
|
5651
|
+
kind: "input",
|
|
5652
|
+
uid,
|
|
5653
|
+
schemaId,
|
|
5654
|
+
analyticsId,
|
|
5655
|
+
alert,
|
|
5656
|
+
control,
|
|
5657
|
+
description,
|
|
5658
|
+
errors,
|
|
5659
|
+
format,
|
|
5660
|
+
help,
|
|
5661
|
+
hidden,
|
|
5662
|
+
media,
|
|
5663
|
+
title,
|
|
5664
|
+
tags,
|
|
5665
|
+
value,
|
|
5666
|
+
async getSubmittableValue() {
|
|
5667
|
+
return this.getSubmittableValueSync();
|
|
5668
|
+
},
|
|
5669
|
+
getSubmittableValueSync() {
|
|
5670
|
+
return this.getLocalValue();
|
|
5671
|
+
},
|
|
5672
|
+
getSummary() {
|
|
5673
|
+
return summariser(this.getLocalValue());
|
|
5674
|
+
},
|
|
5675
|
+
getLocalValue() {
|
|
5676
|
+
return this.value;
|
|
5677
|
+
},
|
|
5678
|
+
validate() {
|
|
5679
|
+
return true;
|
|
5680
|
+
},
|
|
5681
|
+
onChange(newValue) {
|
|
5682
|
+
update(this, (draft) => {
|
|
5683
|
+
draft.value = newValue;
|
|
5684
|
+
});
|
|
5685
|
+
void (schemaOnChange == null ? void 0 : schemaOnChange());
|
|
5686
|
+
}
|
|
5687
|
+
};
|
|
5688
|
+
};
|
|
5689
|
+
|
|
5690
|
+
// src/domain/mappers/schema/objectSchemaToComponent/objectSchemaToFormattedValueComponent.ts
|
|
5691
|
+
var objectSchemaToFormattedValueComponent = (schemaMapperProps, mapperProps) => {
|
|
5692
|
+
const { onBehavior } = mapperProps;
|
|
5693
|
+
const { schema } = schemaMapperProps;
|
|
5694
|
+
const { format } = schema;
|
|
5695
|
+
return createFormattedValueComponent(
|
|
5696
|
+
__spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
|
|
5697
|
+
format,
|
|
5698
|
+
value: schemaMapperProps.model,
|
|
5699
|
+
schemaOnChange: getSchemaOnChange(schema, onBehavior)
|
|
5700
|
+
}),
|
|
5701
|
+
mapperProps.updateComponent
|
|
5702
|
+
);
|
|
5703
|
+
};
|
|
5704
|
+
|
|
5603
5705
|
// src/domain/components/MoneyInputComponent.ts
|
|
5604
5706
|
var createMoneyInputComponent = (moneyInputProps, updateComponent) => {
|
|
5605
5707
|
const _a = moneyInputProps, {
|
|
@@ -6622,9 +6724,16 @@ var mapSchemaToComponent = (schemaMapperProps, mapperProps) => {
|
|
|
6622
6724
|
return booleanSchemaToComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { schema }), mapperProps);
|
|
6623
6725
|
}
|
|
6624
6726
|
if (isObjectSchema(schema)) {
|
|
6625
|
-
|
|
6727
|
+
const { format } = schema;
|
|
6728
|
+
if (format === "money") {
|
|
6626
6729
|
return objectSchemaToMoneyInputComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { schema }), mapperProps);
|
|
6627
6730
|
}
|
|
6731
|
+
if (format != null && Object.keys(schema.properties).length === 0) {
|
|
6732
|
+
return objectSchemaToFormattedValueComponent(
|
|
6733
|
+
__spreadProps(__spreadValues({}, schemaMapperProps), { schema: __spreadProps(__spreadValues({}, schema), { format }) }),
|
|
6734
|
+
mapperProps
|
|
6735
|
+
);
|
|
6736
|
+
}
|
|
6628
6737
|
return objectSchemaToObjectComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { schema }), mapperProps);
|
|
6629
6738
|
}
|
|
6630
6739
|
if (isIntegerSchema(schema)) {
|
|
@@ -7358,8 +7467,8 @@ function useStableCallback(handler) {
|
|
|
7358
7467
|
return (0, import_react2.useCallback)((...args) => ref.current ? ref.current(...args) : null, []);
|
|
7359
7468
|
}
|
|
7360
7469
|
|
|
7361
|
-
// src/
|
|
7362
|
-
function
|
|
7470
|
+
// src/useDynamicFlowController.tsx
|
|
7471
|
+
function useDynamicFlowController(props) {
|
|
7363
7472
|
const _a = props, { flowId, initialAction, initialStep, features } = _a, rest = __objRest(_a, ["flowId", "initialAction", "initialStep", "features"]);
|
|
7364
7473
|
const httpClient = useStableCallback(rest.httpClient);
|
|
7365
7474
|
const onCancellation = useStableCallback(rest.onCancellation);
|
|
@@ -7758,20 +7867,20 @@ function useDynamicFlowCore(props) {
|
|
|
7758
7867
|
trackCoreEvent("Step Shown", { isFirstStep: true });
|
|
7759
7868
|
hasMappedInitialStep.current = true;
|
|
7760
7869
|
}
|
|
7761
|
-
return {
|
|
7870
|
+
return {
|
|
7871
|
+
rootComponent: rootComponentRef.current,
|
|
7872
|
+
cancel: closeWithCancellation
|
|
7873
|
+
};
|
|
7762
7874
|
}
|
|
7763
7875
|
var useRerender = () => {
|
|
7764
7876
|
const [, setState] = (0, import_react3.useState)({});
|
|
7765
7877
|
return (0, import_react3.useCallback)(() => setState({}), []);
|
|
7766
7878
|
};
|
|
7767
7879
|
|
|
7768
|
-
// src/utils/
|
|
7769
|
-
var
|
|
7770
|
-
|
|
7771
|
-
// src/utils/scrollToTop.ts
|
|
7772
|
-
var getScrollToTop = (normalisedFlowId, className3) => (behavior) => {
|
|
7880
|
+
// src/utils/getScrollToTop.ts
|
|
7881
|
+
var getScrollToTop = (normalisedFlowId, className2) => (behavior) => {
|
|
7773
7882
|
var _a;
|
|
7774
|
-
const element = document.querySelector(`div#${normalisedFlowId}.${
|
|
7883
|
+
const element = document.querySelector(`div#${normalisedFlowId}.${className2}`);
|
|
7775
7884
|
if (!element || !window) {
|
|
7776
7885
|
return;
|
|
7777
7886
|
}
|
|
@@ -7782,10 +7891,13 @@ var getScrollToTop = (normalisedFlowId, className3) => (behavior) => {
|
|
|
7782
7891
|
}
|
|
7783
7892
|
};
|
|
7784
7893
|
|
|
7785
|
-
// src/
|
|
7894
|
+
// src/utils/normalise-flow-id.ts
|
|
7895
|
+
var normaliseFlowId = (flowId) => flowId.toLowerCase().replace(/[^a-z-]/g, "-");
|
|
7896
|
+
|
|
7897
|
+
// src/useDynamicFlow.tsx
|
|
7786
7898
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
7787
7899
|
var className = "dynamic-flow";
|
|
7788
|
-
function
|
|
7900
|
+
function useDynamicFlow(props) {
|
|
7789
7901
|
var _a;
|
|
7790
7902
|
const { flowId, renderers, httpClient, onEvent, onError, onLog } = props;
|
|
7791
7903
|
const normalisedFlowId = normaliseFlowId(flowId);
|
|
@@ -7797,7 +7909,10 @@ function DynamicFlowCore(props) {
|
|
|
7797
7909
|
var _a2;
|
|
7798
7910
|
return new FeatureFlags((_a2 = props.features) != null ? _a2 : {});
|
|
7799
7911
|
}, []);
|
|
7800
|
-
const { rootComponent } =
|
|
7912
|
+
const { rootComponent, cancel } = useDynamicFlowController(__spreadProps(__spreadValues({}, props), {
|
|
7913
|
+
features,
|
|
7914
|
+
scrollToTop
|
|
7915
|
+
}));
|
|
7801
7916
|
const render = (0, import_react4.useMemo)(
|
|
7802
7917
|
() => getRenderFunction([CoreRootRenderer, CoreContainerRenderer, ...renderers]),
|
|
7803
7918
|
[renderers]
|
|
@@ -7810,95 +7925,30 @@ function DynamicFlowCore(props) {
|
|
|
7810
7925
|
}),
|
|
7811
7926
|
stepLoadingState: rootComponent.getLoadingState()
|
|
7812
7927
|
});
|
|
7813
|
-
return
|
|
7814
|
-
|
|
7815
|
-
|
|
7816
|
-
|
|
7817
|
-
|
|
7818
|
-
|
|
7819
|
-
|
|
7820
|
-
|
|
7821
|
-
|
|
7822
|
-
|
|
7823
|
-
|
|
7928
|
+
return {
|
|
7929
|
+
controller: {
|
|
7930
|
+
getSubmittableValue: async () => rootComponent.getSubmittableValue(),
|
|
7931
|
+
validate: () => rootComponent.validate(),
|
|
7932
|
+
cancel
|
|
7933
|
+
},
|
|
7934
|
+
view: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
7935
|
+
ErrorBoundary_default,
|
|
7936
|
+
{
|
|
7937
|
+
onError: (error) => {
|
|
7938
|
+
onEvent == null ? void 0 : onEvent("Dynamic Flow - Failed", { error });
|
|
7939
|
+
onError == null ? void 0 : onError(error);
|
|
7940
|
+
onLog == null ? void 0 : onLog("error", "Dynamic Flow - ErrorBoundary", {
|
|
7941
|
+
errorMessage: getErrorMessage(error)
|
|
7942
|
+
});
|
|
7943
|
+
},
|
|
7944
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { id: normalisedFlowId, className, children: render(tree) })
|
|
7945
|
+
}
|
|
7946
|
+
)
|
|
7947
|
+
};
|
|
7824
7948
|
}
|
|
7825
7949
|
|
|
7826
|
-
// src/
|
|
7827
|
-
|
|
7828
|
-
|
|
7829
|
-
|
|
7830
|
-
|
|
7831
|
-
var _a;
|
|
7832
|
-
try {
|
|
7833
|
-
const w = (_a = window == null ? void 0 : window.open) == null ? void 0 : _a.call(window, url, "_blank");
|
|
7834
|
-
return Boolean(w);
|
|
7835
|
-
} catch (e) {
|
|
7836
|
-
return false;
|
|
7837
|
-
}
|
|
7838
|
-
};
|
|
7839
|
-
|
|
7840
|
-
// src/DynamicFormCore.tsx
|
|
7841
|
-
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
7842
|
-
var className2 = "dynamic-flow";
|
|
7843
|
-
var DynamicFormCore = (0, import_react5.forwardRef)(function DynamicFormCore2(props, ref) {
|
|
7844
|
-
var _a;
|
|
7845
|
-
const {
|
|
7846
|
-
onCompletion = () => {
|
|
7847
|
-
},
|
|
7848
|
-
httpClient,
|
|
7849
|
-
onEvent,
|
|
7850
|
-
onError,
|
|
7851
|
-
onLink = openLinkInNewTab,
|
|
7852
|
-
renderers
|
|
7853
|
-
} = props;
|
|
7854
|
-
const normalisedFlowId = normaliseFlowId(props.flowId);
|
|
7855
|
-
const scrollToTop = (0, import_react5.useMemo)(
|
|
7856
|
-
() => getScrollToTop(normalisedFlowId, className2),
|
|
7857
|
-
[normalisedFlowId]
|
|
7858
|
-
);
|
|
7859
|
-
const features = (0, import_react5.useMemo)(() => {
|
|
7860
|
-
var _a2;
|
|
7861
|
-
return new FeatureFlags((_a2 = props.features) != null ? _a2 : {});
|
|
7862
|
-
}, []);
|
|
7863
|
-
const { rootComponent } = useDynamicFlowCore(__spreadProps(__spreadValues({
|
|
7864
|
-
onCompletion
|
|
7865
|
-
}, props), {
|
|
7866
|
-
features,
|
|
7867
|
-
scrollToTop,
|
|
7868
|
-
onLink
|
|
7869
|
-
}));
|
|
7870
|
-
(0, import_react5.useImperativeHandle)(
|
|
7871
|
-
ref,
|
|
7872
|
-
() => ({
|
|
7873
|
-
getValue: async () => {
|
|
7874
|
-
var _a2;
|
|
7875
|
-
return (_a2 = await rootComponent.getSubmittableValue()) != null ? _a2 : null;
|
|
7876
|
-
},
|
|
7877
|
-
validate: () => rootComponent.validate()
|
|
7878
|
-
}),
|
|
7879
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
7880
|
-
[]
|
|
7881
|
-
);
|
|
7882
|
-
const render = (0, import_react5.useMemo)(
|
|
7883
|
-
() => getRenderFunction([CoreRootRenderer, CoreContainerRenderer, ...renderers]),
|
|
7884
|
-
[renderers]
|
|
7885
|
-
);
|
|
7886
|
-
const tree = componentToRendererProps(rootComponent, {
|
|
7887
|
-
features,
|
|
7888
|
-
render,
|
|
7889
|
-
httpClient,
|
|
7890
|
-
trackEvent: (_a = rootComponent.getTrackEvent()) != null ? _a : (() => {
|
|
7891
|
-
}),
|
|
7892
|
-
stepLoadingState: rootComponent.getLoadingState()
|
|
7893
|
-
});
|
|
7894
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
7895
|
-
ErrorBoundary_default,
|
|
7896
|
-
{
|
|
7897
|
-
onError: (error) => {
|
|
7898
|
-
onEvent == null ? void 0 : onEvent("Dynamic Flow - Failed");
|
|
7899
|
-
onError(error);
|
|
7900
|
-
},
|
|
7901
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { id: normalisedFlowId, className: className2, children: render(tree) })
|
|
7902
|
-
}
|
|
7903
|
-
);
|
|
7904
|
-
});
|
|
7950
|
+
// src/DynamicFlowCore.tsx
|
|
7951
|
+
function DynamicFlowCore(props) {
|
|
7952
|
+
const df = useDynamicFlow(props);
|
|
7953
|
+
return df.view;
|
|
7954
|
+
}
|