@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.mjs
CHANGED
|
@@ -751,7 +751,83 @@ var translations = {
|
|
|
751
751
|
};
|
|
752
752
|
var i18n_default = translations;
|
|
753
753
|
|
|
754
|
-
// src/
|
|
754
|
+
// src/utils/type-validators.ts
|
|
755
|
+
var isString = (value) => typeof value === "string";
|
|
756
|
+
var isNumber = (value) => typeof value === "number" && !Number.isNaN(value);
|
|
757
|
+
var isInteger = (value) => isNumber(value) && Math.floor(value) === value;
|
|
758
|
+
var isBoolean = (value) => typeof value === "boolean";
|
|
759
|
+
var isObject = (value) => !isNullish(value) && (value == null ? void 0 : value.constructor) === Object;
|
|
760
|
+
var isArray = (value) => Array.isArray(value);
|
|
761
|
+
var isNull = (value) => value === null;
|
|
762
|
+
var isUndefined = (value) => typeof value === "undefined";
|
|
763
|
+
var isNullish = (v) => isNull(v) || isUndefined(v);
|
|
764
|
+
var isFile = (value) => value instanceof File;
|
|
765
|
+
var isValidDate = (value) => isString(value) && /^\d{4}-\d{2}-\d{2}$/.test(value);
|
|
766
|
+
|
|
767
|
+
// src/renderers/utils.ts
|
|
768
|
+
function findRendererPropsByType(root, type, predicate = () => true) {
|
|
769
|
+
if (isArray(root)) {
|
|
770
|
+
return root.flatMap((child) => findRendererPropsByType(child, type, predicate));
|
|
771
|
+
}
|
|
772
|
+
return [
|
|
773
|
+
...isType(root, type) && predicate(root) ? [root] : [],
|
|
774
|
+
...getChildren(root).flatMap((child) => findRendererPropsByType(child, type, predicate))
|
|
775
|
+
];
|
|
776
|
+
}
|
|
777
|
+
var isType = (node, type) => node.type === type;
|
|
778
|
+
var getChildren = (node) => {
|
|
779
|
+
switch (node.type) {
|
|
780
|
+
case "root":
|
|
781
|
+
case "box":
|
|
782
|
+
case "container":
|
|
783
|
+
case "form":
|
|
784
|
+
case "form-section":
|
|
785
|
+
case "step":
|
|
786
|
+
case "modal":
|
|
787
|
+
case "section":
|
|
788
|
+
return node.childrenProps;
|
|
789
|
+
case "columns":
|
|
790
|
+
return [...node.startChildrenProps, ...node.endChildrenProps];
|
|
791
|
+
case "modal-layout":
|
|
792
|
+
return node.content.childrenProps;
|
|
793
|
+
case "repeatable":
|
|
794
|
+
return node.editableItemProps ? [node.editableItemProps] : [];
|
|
795
|
+
case "input-select":
|
|
796
|
+
return node.childrenProps ? [node.childrenProps] : [];
|
|
797
|
+
case "tabs":
|
|
798
|
+
return node.tabs.flatMap((c) => c.childrenProps);
|
|
799
|
+
case "alert":
|
|
800
|
+
case "button":
|
|
801
|
+
case "input-checkbox":
|
|
802
|
+
case "input-date":
|
|
803
|
+
case "decision":
|
|
804
|
+
case "divider":
|
|
805
|
+
case "formatted-value":
|
|
806
|
+
case "heading":
|
|
807
|
+
case "hidden":
|
|
808
|
+
case "image":
|
|
809
|
+
case "instructions":
|
|
810
|
+
case "input-integer":
|
|
811
|
+
case "list":
|
|
812
|
+
case "loading-indicator":
|
|
813
|
+
case "markdown":
|
|
814
|
+
case "input-multi-select":
|
|
815
|
+
case "input-upload-multi":
|
|
816
|
+
case "input-number":
|
|
817
|
+
case "money-input":
|
|
818
|
+
case "paragraph":
|
|
819
|
+
case "progress":
|
|
820
|
+
case "review":
|
|
821
|
+
case "search":
|
|
822
|
+
case "status-list":
|
|
823
|
+
case "input-text":
|
|
824
|
+
case "input-upload":
|
|
825
|
+
case "external-confirmation":
|
|
826
|
+
return [];
|
|
827
|
+
}
|
|
828
|
+
};
|
|
829
|
+
|
|
830
|
+
// src/useDynamicFlow.tsx
|
|
755
831
|
import { useMemo as useMemo2 } from "react";
|
|
756
832
|
|
|
757
833
|
// src/common/errorBoundary/ErrorBoundary.tsx
|
|
@@ -855,81 +931,6 @@ var CoreContainerRenderer = {
|
|
|
855
931
|
render: ({ children }) => /* @__PURE__ */ jsx3(Fragment2, { children })
|
|
856
932
|
};
|
|
857
933
|
|
|
858
|
-
// src/utils/type-validators.ts
|
|
859
|
-
var isString = (value) => typeof value === "string";
|
|
860
|
-
var isNumber = (value) => typeof value === "number" && !Number.isNaN(value);
|
|
861
|
-
var isInteger = (value) => isNumber(value) && Math.floor(value) === value;
|
|
862
|
-
var isBoolean = (value) => typeof value === "boolean";
|
|
863
|
-
var isObject = (value) => !isNullish(value) && (value == null ? void 0 : value.constructor) === Object;
|
|
864
|
-
var isArray = (value) => Array.isArray(value);
|
|
865
|
-
var isNull = (value) => value === null;
|
|
866
|
-
var isUndefined = (value) => typeof value === "undefined";
|
|
867
|
-
var isNullish = (v) => isNull(v) || isUndefined(v);
|
|
868
|
-
var isFile = (value) => value instanceof File;
|
|
869
|
-
var isValidDate = (value) => isString(value) && /^\d{4}-\d{2}-\d{2}$/.test(value);
|
|
870
|
-
|
|
871
|
-
// src/renderers/utils.ts
|
|
872
|
-
function findRendererPropsByType(root, type, predicate = () => true) {
|
|
873
|
-
if (isArray(root)) {
|
|
874
|
-
return root.flatMap((child) => findRendererPropsByType(child, type, predicate));
|
|
875
|
-
}
|
|
876
|
-
return [
|
|
877
|
-
...isType(root, type) && predicate(root) ? [root] : [],
|
|
878
|
-
...getChildren(root).flatMap((child) => findRendererPropsByType(child, type, predicate))
|
|
879
|
-
];
|
|
880
|
-
}
|
|
881
|
-
var isType = (node, type) => node.type === type;
|
|
882
|
-
var getChildren = (node) => {
|
|
883
|
-
switch (node.type) {
|
|
884
|
-
case "root":
|
|
885
|
-
case "box":
|
|
886
|
-
case "container":
|
|
887
|
-
case "form":
|
|
888
|
-
case "form-section":
|
|
889
|
-
case "step":
|
|
890
|
-
case "modal":
|
|
891
|
-
case "section":
|
|
892
|
-
return node.childrenProps;
|
|
893
|
-
case "columns":
|
|
894
|
-
return [...node.startChildrenProps, ...node.endChildrenProps];
|
|
895
|
-
case "modal-layout":
|
|
896
|
-
return node.content.childrenProps;
|
|
897
|
-
case "repeatable":
|
|
898
|
-
return node.editableItemProps ? [node.editableItemProps] : [];
|
|
899
|
-
case "input-select":
|
|
900
|
-
return node.childrenProps ? [node.childrenProps] : [];
|
|
901
|
-
case "tabs":
|
|
902
|
-
return node.tabs.flatMap((c) => c.childrenProps);
|
|
903
|
-
case "alert":
|
|
904
|
-
case "button":
|
|
905
|
-
case "input-checkbox":
|
|
906
|
-
case "input-date":
|
|
907
|
-
case "decision":
|
|
908
|
-
case "divider":
|
|
909
|
-
case "heading":
|
|
910
|
-
case "hidden":
|
|
911
|
-
case "image":
|
|
912
|
-
case "instructions":
|
|
913
|
-
case "input-integer":
|
|
914
|
-
case "list":
|
|
915
|
-
case "loading-indicator":
|
|
916
|
-
case "markdown":
|
|
917
|
-
case "input-multi-select":
|
|
918
|
-
case "input-upload-multi":
|
|
919
|
-
case "input-number":
|
|
920
|
-
case "money-input":
|
|
921
|
-
case "paragraph":
|
|
922
|
-
case "progress":
|
|
923
|
-
case "review":
|
|
924
|
-
case "search":
|
|
925
|
-
case "status-list":
|
|
926
|
-
case "input-text":
|
|
927
|
-
case "input-upload":
|
|
928
|
-
case "external-confirmation":
|
|
929
|
-
return [];
|
|
930
|
-
}
|
|
931
|
-
};
|
|
932
|
-
|
|
933
934
|
// src/renderers/CoreRootRenderer.tsx
|
|
934
935
|
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
935
936
|
var CoreRootRenderer = {
|
|
@@ -1249,6 +1250,29 @@ var externalComponentToProps = (component, rendererMapperProps) => {
|
|
|
1249
1250
|
}, rendererMapperProps);
|
|
1250
1251
|
};
|
|
1251
1252
|
|
|
1253
|
+
// src/renderers/mappers/formattedValueComponentToProps.ts
|
|
1254
|
+
var formattedValueComponentToProps = (component, rendererMapperProps) => {
|
|
1255
|
+
return __spreadValues(__spreadProps(__spreadValues({
|
|
1256
|
+
type: "formatted-value"
|
|
1257
|
+
}, pick(
|
|
1258
|
+
component,
|
|
1259
|
+
"format",
|
|
1260
|
+
"uid",
|
|
1261
|
+
"analyticsId",
|
|
1262
|
+
"control",
|
|
1263
|
+
"description",
|
|
1264
|
+
"help",
|
|
1265
|
+
"media",
|
|
1266
|
+
"tags",
|
|
1267
|
+
"title"
|
|
1268
|
+
// for now, we don't want to pass `value` down to the renderer to avoid the "WhateverComponent".
|
|
1269
|
+
// 'value',
|
|
1270
|
+
)), {
|
|
1271
|
+
validationState: getValidationState(component.errors, void 0),
|
|
1272
|
+
onChange: component.onChange.bind(component)
|
|
1273
|
+
}), rendererMapperProps);
|
|
1274
|
+
};
|
|
1275
|
+
|
|
1252
1276
|
// src/renderers/mappers/formComponentToProps.ts
|
|
1253
1277
|
var formComponentToProps = (component, rendererMapperProps) => {
|
|
1254
1278
|
const childrenProps = component.getChildren().map((c) => componentToRendererProps(c, rendererMapperProps));
|
|
@@ -1904,6 +1928,8 @@ var getComponentProps = (component, rendererMapperProps) => {
|
|
|
1904
1928
|
return dividerComponentToProps(component, rendererMapperProps);
|
|
1905
1929
|
case "external-confirmation":
|
|
1906
1930
|
return externalComponentToProps(component, rendererMapperProps);
|
|
1931
|
+
case "formatted-value":
|
|
1932
|
+
return formattedValueComponentToProps(component, rendererMapperProps);
|
|
1907
1933
|
case "form":
|
|
1908
1934
|
return formComponentToProps(component, rendererMapperProps);
|
|
1909
1935
|
case "heading":
|
|
@@ -1976,7 +2002,7 @@ var getComponentAlertProps = (component, rendererMapperProps) => "alert" in comp
|
|
|
1976
2002
|
markdown: component.alert.content
|
|
1977
2003
|
}, rendererMapperProps) : null;
|
|
1978
2004
|
|
|
1979
|
-
// src/
|
|
2005
|
+
// src/useDynamicFlowController.tsx
|
|
1980
2006
|
import { useCallback as useCallback2, useEffect, useMemo, useRef as useRef2, useState } from "react";
|
|
1981
2007
|
import { useIntl as useIntl2 } from "react-intl";
|
|
1982
2008
|
|
|
@@ -1997,8 +2023,7 @@ var createRootDomainComponent = (updateComponent, scrollToTop, backConfig) => {
|
|
|
1997
2023
|
uid: "root",
|
|
1998
2024
|
stepComponent: null,
|
|
1999
2025
|
stepStack: [],
|
|
2000
|
-
|
|
2001
|
-
isFlowCancellable: backConfig.isFlowCancellable,
|
|
2026
|
+
backConfig,
|
|
2002
2027
|
_update(updateFn) {
|
|
2003
2028
|
update(this, updateFn);
|
|
2004
2029
|
},
|
|
@@ -2132,7 +2157,7 @@ var createRootDomainComponent = (updateComponent, scrollToTop, backConfig) => {
|
|
|
2132
2157
|
var _a, _b;
|
|
2133
2158
|
const navigation = (_a = this.getStep()) == null ? void 0 : _a.step.navigation;
|
|
2134
2159
|
const stepHasBehavior = Boolean((_b = navigation == null ? void 0 : navigation.back) != null ? _b : navigation == null ? void 0 : navigation.backButton);
|
|
2135
|
-
return this.isFlowCancellable || this.stepStack.length > 1 && this.isNativeBackEnabled || stepHasBehavior;
|
|
2160
|
+
return this.backConfig.isFlowCancellable || this.stepStack.length > 1 && this.backConfig.isNativeBackEnabled || stepHasBehavior;
|
|
2136
2161
|
}
|
|
2137
2162
|
};
|
|
2138
2163
|
return rootComponent;
|
|
@@ -5573,6 +5598,83 @@ var integerSchemaToComponent = (schemaMapperProps, mapperProps) => {
|
|
|
5573
5598
|
);
|
|
5574
5599
|
};
|
|
5575
5600
|
|
|
5601
|
+
// src/domain/components/FormattedValueComponent.ts
|
|
5602
|
+
var createFormattedValueComponent = (props, updateComponent) => {
|
|
5603
|
+
const {
|
|
5604
|
+
uid,
|
|
5605
|
+
schemaId,
|
|
5606
|
+
analyticsId,
|
|
5607
|
+
alert,
|
|
5608
|
+
control,
|
|
5609
|
+
description,
|
|
5610
|
+
errors,
|
|
5611
|
+
format,
|
|
5612
|
+
help,
|
|
5613
|
+
hidden,
|
|
5614
|
+
media,
|
|
5615
|
+
summariser,
|
|
5616
|
+
title,
|
|
5617
|
+
tags,
|
|
5618
|
+
value,
|
|
5619
|
+
schemaOnChange
|
|
5620
|
+
} = props;
|
|
5621
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
5622
|
+
return {
|
|
5623
|
+
type: "formatted-value",
|
|
5624
|
+
kind: "input",
|
|
5625
|
+
uid,
|
|
5626
|
+
schemaId,
|
|
5627
|
+
analyticsId,
|
|
5628
|
+
alert,
|
|
5629
|
+
control,
|
|
5630
|
+
description,
|
|
5631
|
+
errors,
|
|
5632
|
+
format,
|
|
5633
|
+
help,
|
|
5634
|
+
hidden,
|
|
5635
|
+
media,
|
|
5636
|
+
title,
|
|
5637
|
+
tags,
|
|
5638
|
+
value,
|
|
5639
|
+
async getSubmittableValue() {
|
|
5640
|
+
return this.getSubmittableValueSync();
|
|
5641
|
+
},
|
|
5642
|
+
getSubmittableValueSync() {
|
|
5643
|
+
return this.getLocalValue();
|
|
5644
|
+
},
|
|
5645
|
+
getSummary() {
|
|
5646
|
+
return summariser(this.getLocalValue());
|
|
5647
|
+
},
|
|
5648
|
+
getLocalValue() {
|
|
5649
|
+
return this.value;
|
|
5650
|
+
},
|
|
5651
|
+
validate() {
|
|
5652
|
+
return true;
|
|
5653
|
+
},
|
|
5654
|
+
onChange(newValue) {
|
|
5655
|
+
update(this, (draft) => {
|
|
5656
|
+
draft.value = newValue;
|
|
5657
|
+
});
|
|
5658
|
+
void (schemaOnChange == null ? void 0 : schemaOnChange());
|
|
5659
|
+
}
|
|
5660
|
+
};
|
|
5661
|
+
};
|
|
5662
|
+
|
|
5663
|
+
// src/domain/mappers/schema/objectSchemaToComponent/objectSchemaToFormattedValueComponent.ts
|
|
5664
|
+
var objectSchemaToFormattedValueComponent = (schemaMapperProps, mapperProps) => {
|
|
5665
|
+
const { onBehavior } = mapperProps;
|
|
5666
|
+
const { schema } = schemaMapperProps;
|
|
5667
|
+
const { format } = schema;
|
|
5668
|
+
return createFormattedValueComponent(
|
|
5669
|
+
__spreadProps(__spreadValues({}, mapCommonSchemaProps(schemaMapperProps)), {
|
|
5670
|
+
format,
|
|
5671
|
+
value: schemaMapperProps.model,
|
|
5672
|
+
schemaOnChange: getSchemaOnChange(schema, onBehavior)
|
|
5673
|
+
}),
|
|
5674
|
+
mapperProps.updateComponent
|
|
5675
|
+
);
|
|
5676
|
+
};
|
|
5677
|
+
|
|
5576
5678
|
// src/domain/components/MoneyInputComponent.ts
|
|
5577
5679
|
var createMoneyInputComponent = (moneyInputProps, updateComponent) => {
|
|
5578
5680
|
const _a = moneyInputProps, {
|
|
@@ -6595,9 +6697,16 @@ var mapSchemaToComponent = (schemaMapperProps, mapperProps) => {
|
|
|
6595
6697
|
return booleanSchemaToComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { schema }), mapperProps);
|
|
6596
6698
|
}
|
|
6597
6699
|
if (isObjectSchema(schema)) {
|
|
6598
|
-
|
|
6700
|
+
const { format } = schema;
|
|
6701
|
+
if (format === "money") {
|
|
6599
6702
|
return objectSchemaToMoneyInputComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { schema }), mapperProps);
|
|
6600
6703
|
}
|
|
6704
|
+
if (format != null && Object.keys(schema.properties).length === 0) {
|
|
6705
|
+
return objectSchemaToFormattedValueComponent(
|
|
6706
|
+
__spreadProps(__spreadValues({}, schemaMapperProps), { schema: __spreadProps(__spreadValues({}, schema), { format }) }),
|
|
6707
|
+
mapperProps
|
|
6708
|
+
);
|
|
6709
|
+
}
|
|
6601
6710
|
return objectSchemaToObjectComponent(__spreadProps(__spreadValues({}, schemaMapperProps), { schema }), mapperProps);
|
|
6602
6711
|
}
|
|
6603
6712
|
if (isIntegerSchema(schema)) {
|
|
@@ -7331,8 +7440,8 @@ function useStableCallback(handler) {
|
|
|
7331
7440
|
return useCallback((...args) => ref.current ? ref.current(...args) : null, []);
|
|
7332
7441
|
}
|
|
7333
7442
|
|
|
7334
|
-
// src/
|
|
7335
|
-
function
|
|
7443
|
+
// src/useDynamicFlowController.tsx
|
|
7444
|
+
function useDynamicFlowController(props) {
|
|
7336
7445
|
const _a = props, { flowId, initialAction, initialStep, features } = _a, rest = __objRest(_a, ["flowId", "initialAction", "initialStep", "features"]);
|
|
7337
7446
|
const httpClient = useStableCallback(rest.httpClient);
|
|
7338
7447
|
const onCancellation = useStableCallback(rest.onCancellation);
|
|
@@ -7731,20 +7840,20 @@ function useDynamicFlowCore(props) {
|
|
|
7731
7840
|
trackCoreEvent("Step Shown", { isFirstStep: true });
|
|
7732
7841
|
hasMappedInitialStep.current = true;
|
|
7733
7842
|
}
|
|
7734
|
-
return {
|
|
7843
|
+
return {
|
|
7844
|
+
rootComponent: rootComponentRef.current,
|
|
7845
|
+
cancel: closeWithCancellation
|
|
7846
|
+
};
|
|
7735
7847
|
}
|
|
7736
7848
|
var useRerender = () => {
|
|
7737
7849
|
const [, setState] = useState({});
|
|
7738
7850
|
return useCallback2(() => setState({}), []);
|
|
7739
7851
|
};
|
|
7740
7852
|
|
|
7741
|
-
// src/utils/
|
|
7742
|
-
var
|
|
7743
|
-
|
|
7744
|
-
// src/utils/scrollToTop.ts
|
|
7745
|
-
var getScrollToTop = (normalisedFlowId, className3) => (behavior) => {
|
|
7853
|
+
// src/utils/getScrollToTop.ts
|
|
7854
|
+
var getScrollToTop = (normalisedFlowId, className2) => (behavior) => {
|
|
7746
7855
|
var _a;
|
|
7747
|
-
const element = document.querySelector(`div#${normalisedFlowId}.${
|
|
7856
|
+
const element = document.querySelector(`div#${normalisedFlowId}.${className2}`);
|
|
7748
7857
|
if (!element || !window) {
|
|
7749
7858
|
return;
|
|
7750
7859
|
}
|
|
@@ -7755,10 +7864,13 @@ var getScrollToTop = (normalisedFlowId, className3) => (behavior) => {
|
|
|
7755
7864
|
}
|
|
7756
7865
|
};
|
|
7757
7866
|
|
|
7758
|
-
// src/
|
|
7867
|
+
// src/utils/normalise-flow-id.ts
|
|
7868
|
+
var normaliseFlowId = (flowId) => flowId.toLowerCase().replace(/[^a-z-]/g, "-");
|
|
7869
|
+
|
|
7870
|
+
// src/useDynamicFlow.tsx
|
|
7759
7871
|
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
7760
7872
|
var className = "dynamic-flow";
|
|
7761
|
-
function
|
|
7873
|
+
function useDynamicFlow(props) {
|
|
7762
7874
|
var _a;
|
|
7763
7875
|
const { flowId, renderers, httpClient, onEvent, onError, onLog } = props;
|
|
7764
7876
|
const normalisedFlowId = normaliseFlowId(flowId);
|
|
@@ -7770,7 +7882,10 @@ function DynamicFlowCore(props) {
|
|
|
7770
7882
|
var _a2;
|
|
7771
7883
|
return new FeatureFlags((_a2 = props.features) != null ? _a2 : {});
|
|
7772
7884
|
}, []);
|
|
7773
|
-
const { rootComponent } =
|
|
7885
|
+
const { rootComponent, cancel } = useDynamicFlowController(__spreadProps(__spreadValues({}, props), {
|
|
7886
|
+
features,
|
|
7887
|
+
scrollToTop
|
|
7888
|
+
}));
|
|
7774
7889
|
const render = useMemo2(
|
|
7775
7890
|
() => getRenderFunction([CoreRootRenderer, CoreContainerRenderer, ...renderers]),
|
|
7776
7891
|
[renderers]
|
|
@@ -7783,102 +7898,37 @@ function DynamicFlowCore(props) {
|
|
|
7783
7898
|
}),
|
|
7784
7899
|
stepLoadingState: rootComponent.getLoadingState()
|
|
7785
7900
|
});
|
|
7786
|
-
return
|
|
7787
|
-
|
|
7788
|
-
|
|
7789
|
-
|
|
7790
|
-
|
|
7791
|
-
|
|
7792
|
-
|
|
7793
|
-
|
|
7794
|
-
|
|
7795
|
-
|
|
7796
|
-
|
|
7901
|
+
return {
|
|
7902
|
+
controller: {
|
|
7903
|
+
getSubmittableValue: async () => rootComponent.getSubmittableValue(),
|
|
7904
|
+
validate: () => rootComponent.validate(),
|
|
7905
|
+
cancel
|
|
7906
|
+
},
|
|
7907
|
+
view: /* @__PURE__ */ jsx6(
|
|
7908
|
+
ErrorBoundary_default,
|
|
7909
|
+
{
|
|
7910
|
+
onError: (error) => {
|
|
7911
|
+
onEvent == null ? void 0 : onEvent("Dynamic Flow - Failed", { error });
|
|
7912
|
+
onError == null ? void 0 : onError(error);
|
|
7913
|
+
onLog == null ? void 0 : onLog("error", "Dynamic Flow - ErrorBoundary", {
|
|
7914
|
+
errorMessage: getErrorMessage(error)
|
|
7915
|
+
});
|
|
7916
|
+
},
|
|
7917
|
+
children: /* @__PURE__ */ jsx6("div", { id: normalisedFlowId, className, children: render(tree) })
|
|
7918
|
+
}
|
|
7919
|
+
)
|
|
7920
|
+
};
|
|
7797
7921
|
}
|
|
7798
7922
|
|
|
7799
|
-
// src/
|
|
7800
|
-
|
|
7801
|
-
|
|
7802
|
-
|
|
7803
|
-
|
|
7804
|
-
var _a;
|
|
7805
|
-
try {
|
|
7806
|
-
const w = (_a = window == null ? void 0 : window.open) == null ? void 0 : _a.call(window, url, "_blank");
|
|
7807
|
-
return Boolean(w);
|
|
7808
|
-
} catch (e) {
|
|
7809
|
-
return false;
|
|
7810
|
-
}
|
|
7811
|
-
};
|
|
7812
|
-
|
|
7813
|
-
// src/DynamicFormCore.tsx
|
|
7814
|
-
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
7815
|
-
var className2 = "dynamic-flow";
|
|
7816
|
-
var DynamicFormCore = forwardRef(function DynamicFormCore2(props, ref) {
|
|
7817
|
-
var _a;
|
|
7818
|
-
const {
|
|
7819
|
-
onCompletion = () => {
|
|
7820
|
-
},
|
|
7821
|
-
httpClient,
|
|
7822
|
-
onEvent,
|
|
7823
|
-
onError,
|
|
7824
|
-
onLink = openLinkInNewTab,
|
|
7825
|
-
renderers
|
|
7826
|
-
} = props;
|
|
7827
|
-
const normalisedFlowId = normaliseFlowId(props.flowId);
|
|
7828
|
-
const scrollToTop = useMemo3(
|
|
7829
|
-
() => getScrollToTop(normalisedFlowId, className2),
|
|
7830
|
-
[normalisedFlowId]
|
|
7831
|
-
);
|
|
7832
|
-
const features = useMemo3(() => {
|
|
7833
|
-
var _a2;
|
|
7834
|
-
return new FeatureFlags((_a2 = props.features) != null ? _a2 : {});
|
|
7835
|
-
}, []);
|
|
7836
|
-
const { rootComponent } = useDynamicFlowCore(__spreadProps(__spreadValues({
|
|
7837
|
-
onCompletion
|
|
7838
|
-
}, props), {
|
|
7839
|
-
features,
|
|
7840
|
-
scrollToTop,
|
|
7841
|
-
onLink
|
|
7842
|
-
}));
|
|
7843
|
-
useImperativeHandle(
|
|
7844
|
-
ref,
|
|
7845
|
-
() => ({
|
|
7846
|
-
getValue: async () => {
|
|
7847
|
-
var _a2;
|
|
7848
|
-
return (_a2 = await rootComponent.getSubmittableValue()) != null ? _a2 : null;
|
|
7849
|
-
},
|
|
7850
|
-
validate: () => rootComponent.validate()
|
|
7851
|
-
}),
|
|
7852
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
7853
|
-
[]
|
|
7854
|
-
);
|
|
7855
|
-
const render = useMemo3(
|
|
7856
|
-
() => getRenderFunction([CoreRootRenderer, CoreContainerRenderer, ...renderers]),
|
|
7857
|
-
[renderers]
|
|
7858
|
-
);
|
|
7859
|
-
const tree = componentToRendererProps(rootComponent, {
|
|
7860
|
-
features,
|
|
7861
|
-
render,
|
|
7862
|
-
httpClient,
|
|
7863
|
-
trackEvent: (_a = rootComponent.getTrackEvent()) != null ? _a : (() => {
|
|
7864
|
-
}),
|
|
7865
|
-
stepLoadingState: rootComponent.getLoadingState()
|
|
7866
|
-
});
|
|
7867
|
-
return /* @__PURE__ */ jsx7(
|
|
7868
|
-
ErrorBoundary_default,
|
|
7869
|
-
{
|
|
7870
|
-
onError: (error) => {
|
|
7871
|
-
onEvent == null ? void 0 : onEvent("Dynamic Flow - Failed");
|
|
7872
|
-
onError(error);
|
|
7873
|
-
},
|
|
7874
|
-
children: /* @__PURE__ */ jsx7("div", { id: normalisedFlowId, className: className2, children: render(tree) })
|
|
7875
|
-
}
|
|
7876
|
-
);
|
|
7877
|
-
});
|
|
7923
|
+
// src/DynamicFlowCore.tsx
|
|
7924
|
+
function DynamicFlowCore(props) {
|
|
7925
|
+
const df = useDynamicFlow(props);
|
|
7926
|
+
return df.view;
|
|
7927
|
+
}
|
|
7878
7928
|
export {
|
|
7879
7929
|
DynamicFlowCore as DynamicFlow,
|
|
7880
|
-
DynamicFormCore as DynamicForm,
|
|
7881
7930
|
findRendererPropsByType,
|
|
7882
7931
|
makeHttpClient,
|
|
7883
|
-
i18n_default as translations
|
|
7932
|
+
i18n_default as translations,
|
|
7933
|
+
useDynamicFlow
|
|
7884
7934
|
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { JsonElement } from '@wise/dynamic-flow-types/spec';
|
|
2
|
+
import { SchemaOnChange } from '../features/schema-on-change/getSchemaOnChange';
|
|
3
|
+
import type { BaseSchemaComponent, InlineAlert, LocalValue, RepeatableSummary, UpdateComponent } from '../types';
|
|
4
|
+
export type FormattedValueComponent = BaseSchemaComponent<JsonElement> & {
|
|
5
|
+
type: 'formatted-value';
|
|
6
|
+
kind: 'input';
|
|
7
|
+
format: string;
|
|
8
|
+
alert?: InlineAlert;
|
|
9
|
+
errors: string[] | undefined;
|
|
10
|
+
value: JsonElement;
|
|
11
|
+
onChange: (newValue: JsonElement) => void;
|
|
12
|
+
};
|
|
13
|
+
export declare const createFormattedValueComponent: (props: Pick<FormattedValueComponent, "uid" | "schemaId" | "analyticsId" | "alert" | "control" | "description" | "errors" | "format" | "help" | "hidden" | "media" | "title" | "tags" | "value"> & {
|
|
14
|
+
summariser: (value: LocalValue | null) => RepeatableSummary;
|
|
15
|
+
schemaOnChange: SchemaOnChange | undefined;
|
|
16
|
+
}, updateComponent: UpdateComponent) => FormattedValueComponent;
|
|
@@ -8,8 +8,10 @@ export type RootDomainComponent = BaseComponent & {
|
|
|
8
8
|
kind: 'step';
|
|
9
9
|
stepComponent: StepDomainComponent | null;
|
|
10
10
|
stepStack: StepDomainComponent[];
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
backConfig: {
|
|
12
|
+
isNativeBackEnabled: boolean;
|
|
13
|
+
isFlowCancellable: boolean;
|
|
14
|
+
};
|
|
13
15
|
canPerformBack: () => boolean;
|
|
14
16
|
dismissAllModals: () => void;
|
|
15
17
|
dismissModal: () => void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ObjectSchema } from '@wise/dynamic-flow-types/spec';
|
|
2
|
+
import type { MapperProps, SchemaMapperProps } from '../types';
|
|
3
|
+
export declare const objectSchemaToFormattedValueComponent: (schemaMapperProps: SchemaMapperProps & {
|
|
4
|
+
schema: ObjectSchema & {
|
|
5
|
+
format: string;
|
|
6
|
+
};
|
|
7
|
+
}, mapperProps: MapperProps) => import("../../../components/FormattedValueComponent").FormattedValueComponent;
|
package/build/types/domain/mappers/schema/oneOfSchemaToComponent/oneOfSchemaToComponent.d.ts
CHANGED
|
@@ -471,6 +471,31 @@ export declare const oneOfSchemaToComponent: (schemaMapperProps: SchemaMapperPro
|
|
|
471
471
|
onUpload: (value: File | null) => Promise<void>;
|
|
472
472
|
} & {
|
|
473
473
|
kind: "input";
|
|
474
|
+
}) | (import("../../../types").BaseComponent & {
|
|
475
|
+
schemaId?: string;
|
|
476
|
+
isSchemaReferencedInStep?: boolean;
|
|
477
|
+
control?: string;
|
|
478
|
+
description?: string;
|
|
479
|
+
help?: string;
|
|
480
|
+
hidden: boolean;
|
|
481
|
+
media?: import("../../../types").Media;
|
|
482
|
+
title?: string;
|
|
483
|
+
tags?: string[];
|
|
484
|
+
getLocalValue: () => import("@wise/dynamic-flow-types/spec").JsonElement;
|
|
485
|
+
getSubmittableValueSync: () => import("@wise/dynamic-flow-types/spec").Model;
|
|
486
|
+
getSummary: () => import("../../../types").RepeatableSummary;
|
|
487
|
+
getSubmittableValue: () => Promise<import("@wise/dynamic-flow-types/spec").Model>;
|
|
488
|
+
validate: () => boolean;
|
|
489
|
+
} & {
|
|
490
|
+
type: "formatted-value";
|
|
491
|
+
kind: "input";
|
|
492
|
+
format: string;
|
|
493
|
+
alert?: import("../../../types").InlineAlert;
|
|
494
|
+
errors: string[] | undefined;
|
|
495
|
+
value: import("@wise/dynamic-flow-types/spec").JsonElement;
|
|
496
|
+
onChange: (newValue: import("@wise/dynamic-flow-types/spec").JsonElement) => void;
|
|
497
|
+
} & {
|
|
498
|
+
kind: "input";
|
|
474
499
|
}) | (import("../../../types").BaseComponent & {
|
|
475
500
|
schemaId?: string;
|
|
476
501
|
isSchemaReferencedInStep?: boolean;
|
|
@@ -484,6 +484,31 @@ export declare const persistAsyncSchemaToComponent: (schemaMapperProps: SchemaMa
|
|
|
484
484
|
onUpload: (value: File | null) => Promise<void>;
|
|
485
485
|
} & {
|
|
486
486
|
kind: "input";
|
|
487
|
+
}) | (import("../../types").BaseComponent & {
|
|
488
|
+
schemaId?: string;
|
|
489
|
+
isSchemaReferencedInStep?: boolean;
|
|
490
|
+
control?: string;
|
|
491
|
+
description?: string;
|
|
492
|
+
help?: string;
|
|
493
|
+
hidden: boolean;
|
|
494
|
+
media?: import("../../types").Media;
|
|
495
|
+
title?: string;
|
|
496
|
+
tags?: string[];
|
|
497
|
+
getLocalValue: () => import("@wise/dynamic-flow-types/spec").JsonElement;
|
|
498
|
+
getSubmittableValueSync: () => import("@wise/dynamic-flow-types/spec").Model;
|
|
499
|
+
getSummary: () => import("../../types").RepeatableSummary;
|
|
500
|
+
getSubmittableValue: () => Promise<import("@wise/dynamic-flow-types/spec").Model>;
|
|
501
|
+
validate: () => boolean;
|
|
502
|
+
} & {
|
|
503
|
+
type: "formatted-value";
|
|
504
|
+
kind: "input";
|
|
505
|
+
format: string;
|
|
506
|
+
alert?: import("../../types").InlineAlert;
|
|
507
|
+
errors: string[] | undefined;
|
|
508
|
+
value: import("@wise/dynamic-flow-types/spec").JsonElement;
|
|
509
|
+
onChange: (newValue: import("@wise/dynamic-flow-types/spec").JsonElement) => void;
|
|
510
|
+
} & {
|
|
511
|
+
kind: "input";
|
|
487
512
|
}) | (import("../../types").BaseComponent & {
|
|
488
513
|
schemaId?: string;
|
|
489
514
|
isSchemaReferencedInStep?: boolean;
|
|
@@ -10,6 +10,7 @@ import type { ContainerComponent } from './components/ContainerComponent';
|
|
|
10
10
|
import type { DateInputComponent } from './components/DateInputComponent';
|
|
11
11
|
import type { DecisionComponent } from './components/DecisionComponent';
|
|
12
12
|
import type { DividerComponent } from './components/DividerComponent';
|
|
13
|
+
import type { FormattedValueComponent } from './components/FormattedValueComponent';
|
|
13
14
|
import type { FormComponent } from './components/FormComponent';
|
|
14
15
|
import type { HeadingComponent } from './components/HeadingComponent';
|
|
15
16
|
import type { ImageComponent } from './components/ImageComponent';
|
|
@@ -41,7 +42,7 @@ import type { TabsComponent } from './components/TabsComponent';
|
|
|
41
42
|
import type { TextInputComponent } from './components/TextInputComponent';
|
|
42
43
|
import type { TupleComponent } from './components/TupleComponent';
|
|
43
44
|
import type { UploadInputComponent } from './components/UploadInputComponent';
|
|
44
|
-
export type DomainComponent = RootDomainComponent | StepDomainComponent | PersistAsyncComponent | AllOfComponent | BooleanInputComponent | ConstComponent | DateInputComponent | IntegerInputComponent | MultiSelectComponent | MultiUploadInputComponent | NumberInputComponent | ObjectComponent | RepeatableComponent | SelectInputComponent | TextInputComponent | TupleComponent | UploadInputComponent | AlertComponent | BoxComponent | ButtonComponent | ColumnsComponent | ContainerComponent | DecisionComponent | DividerComponent | ExternalConfirmationComponent | FormComponent | HeadingComponent | ImageComponent | InstructionsComponent | ListComponent | LoadingIndicatorComponent | MarkdownComponent | ModalLayoutComponent | ModalComponent | MoneyInputComponent | ParagraphComponent | ProgressComponent | ReviewComponent | SearchComponent | SectionComponent | StatusListComponent | TabsComponent;
|
|
45
|
+
export type DomainComponent = RootDomainComponent | StepDomainComponent | PersistAsyncComponent | AllOfComponent | BooleanInputComponent | ConstComponent | DateInputComponent | IntegerInputComponent | MultiSelectComponent | MultiUploadInputComponent | NumberInputComponent | ObjectComponent | RepeatableComponent | SelectInputComponent | TextInputComponent | TupleComponent | UploadInputComponent | AlertComponent | BoxComponent | ButtonComponent | ColumnsComponent | ContainerComponent | DecisionComponent | DividerComponent | ExternalConfirmationComponent | FormattedValueComponent | FormComponent | HeadingComponent | ImageComponent | InstructionsComponent | ListComponent | LoadingIndicatorComponent | MarkdownComponent | ModalLayoutComponent | ModalComponent | MoneyInputComponent | ParagraphComponent | ProgressComponent | ReviewComponent | SearchComponent | SectionComponent | StatusListComponent | TabsComponent;
|
|
45
46
|
export type SchemaComponent = DomainComponent & {
|
|
46
47
|
kind: 'input';
|
|
47
48
|
};
|
package/build/types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { makeHttpClient } from './common/makeHttpClient';
|
|
2
2
|
export { default as translations } from './i18n';
|
|
3
|
-
export type { DynamicFlowCoreProps as DynamicFlowProps
|
|
4
|
-
export { DynamicFlowCore as DynamicFlow } from './DynamicFlowCore';
|
|
5
|
-
export { DynamicFormCore as DynamicForm } from './DynamicFormCore';
|
|
3
|
+
export type { DynamicFlowCoreProps as DynamicFlowProps } from './types';
|
|
6
4
|
export { findRendererPropsByType } from './renderers/utils';
|
|
5
|
+
export { useDynamicFlow } from './useDynamicFlow';
|
|
6
|
+
export { DynamicFlowCore as DynamicFlow } from './DynamicFlowCore';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { FormattedValueRendererProps } from '@wise/dynamic-flow-types/renderers';
|
|
2
|
+
import type { FormattedValueComponent } from '../../domain/components/FormattedValueComponent';
|
|
3
|
+
import type { RendererMapperProps } from './componentToRendererProps';
|
|
4
|
+
export declare const formattedValueComponentToProps: (component: FormattedValueComponent, rendererMapperProps: RendererMapperProps) => FormattedValueRendererProps;
|