chayns-api 1.0.13 → 1.1.0-2
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/.babelrc +30 -30
- package/.eslintrc +17 -17
- package/.github/workflows/deploy_docs.yml +28 -28
- package/.github/workflows/publish.yml +21 -21
- package/LICENSE +21 -21
- package/README.md +54 -54
- package/dist/cjs/calls/dialogs/date.js +10 -10
- package/dist/cjs/calls/index.js +102 -97
- package/dist/cjs/calls/sendMessage.js +8 -8
- package/dist/cjs/calls/visibilityChangeListener.js +4 -4
- package/dist/cjs/components/AppDialogWrapper.js +42 -0
- package/dist/cjs/components/ChaynsProvider.js +5 -2
- package/dist/cjs/handler/DialogHandler.js +63 -0
- package/dist/cjs/hooks/geoLocationListener.js +4 -4
- package/dist/cjs/hooks/index.js +14 -1
- package/dist/cjs/hooks/scrollListener.js +8 -8
- package/dist/cjs/hooks/useAccessToken.js +2 -2
- package/dist/cjs/hooks/useCurrentPage.js +2 -2
- package/dist/cjs/hooks/useCustomData.js +2 -2
- package/dist/cjs/hooks/useDevice.js +2 -2
- package/dist/cjs/hooks/useDialogState.js +39 -0
- package/dist/cjs/hooks/useEnvironment.js +2 -2
- package/dist/cjs/hooks/useFunctions.js +2 -2
- package/dist/cjs/hooks/useIsAdminMode.js +2 -2
- package/dist/cjs/hooks/useLanguage.js +2 -2
- package/dist/cjs/hooks/usePages.js +4 -4
- package/dist/cjs/hooks/useParameters.js +2 -2
- package/dist/cjs/hooks/useSite.js +2 -2
- package/dist/cjs/hooks/useUser.js +2 -2
- package/dist/cjs/hooks/useValues.js +2 -2
- package/dist/cjs/hooks/windowMetricsListener.js +4 -4
- package/dist/cjs/host/ChaynsHost.js +10 -5
- package/dist/cjs/host/iframe/HostIframe.js +5 -2
- package/dist/cjs/host/module/ModuleHost.js +4 -0
- package/dist/cjs/types/IChaynsReact.js +22 -2
- package/dist/cjs/util/deviceHelper.js +7 -6
- package/dist/cjs/wrapper/AppWrapper.js +42 -6
- package/dist/cjs/wrapper/FrameWrapper.js +52 -1
- package/dist/cjs/wrapper/ModuleFederationWrapper.js +4 -0
- package/dist/esm/calls/dialogs/date.js +34 -34
- package/dist/esm/calls/index.js +102 -96
- package/dist/esm/calls/sendMessage.js +8 -8
- package/dist/esm/calls/visibilityChangeListener.js +4 -4
- package/dist/esm/components/AppDialogWrapper.js +33 -0
- package/dist/esm/components/ChaynsProvider.js +5 -2
- package/dist/esm/handler/DialogHandler.js +59 -0
- package/dist/esm/hooks/geoLocationListener.js +4 -4
- package/dist/esm/hooks/index.js +2 -1
- package/dist/esm/hooks/scrollListener.js +8 -8
- package/dist/esm/hooks/useAccessToken.js +2 -2
- package/dist/esm/hooks/useCurrentPage.js +2 -2
- package/dist/esm/hooks/useCustomData.js +2 -2
- package/dist/esm/hooks/useDevice.js +2 -2
- package/dist/esm/hooks/useDialogState.js +32 -0
- package/dist/esm/hooks/useEnvironment.js +2 -2
- package/dist/esm/hooks/useFunctions.js +2 -2
- package/dist/esm/hooks/useIsAdminMode.js +2 -2
- package/dist/esm/hooks/useLanguage.js +2 -2
- package/dist/esm/hooks/usePages.js +4 -4
- package/dist/esm/hooks/useParameters.js +2 -2
- package/dist/esm/hooks/useSite.js +2 -2
- package/dist/esm/hooks/useUser.js +2 -2
- package/dist/esm/hooks/useValues.js +2 -2
- package/dist/esm/hooks/windowMetricsListener.js +4 -4
- package/dist/esm/host/ChaynsHost.js +10 -5
- package/dist/esm/host/iframe/HostIframe.js +5 -2
- package/dist/esm/host/module/ModuleHost.js +4 -0
- package/dist/esm/types/IChaynsReact.js +19 -1
- package/dist/esm/util/deviceHelper.js +7 -6
- package/dist/esm/wrapper/AppWrapper.js +42 -6
- package/dist/esm/wrapper/FrameWrapper.js +52 -1
- package/dist/esm/wrapper/ModuleFederationWrapper.js +4 -0
- package/dist/types/calls/dialogs/alert.d.ts +1 -1
- package/dist/types/calls/dialogs/chaynsDialog.d.ts +24 -24
- package/dist/types/calls/dialogs/close.d.ts +1 -1
- package/dist/types/calls/dialogs/communication.d.ts +3 -3
- package/dist/types/calls/dialogs/confirm.d.ts +13 -13
- package/dist/types/calls/dialogs/date.d.ts +96 -96
- package/dist/types/calls/dialogs/dropUpAlert.d.ts +5 -5
- package/dist/types/calls/dialogs/fileSelect.d.ts +16 -16
- package/dist/types/calls/dialogs/iFrame.d.ts +10 -10
- package/dist/types/calls/dialogs/index.d.ts +14 -14
- package/dist/types/calls/dialogs/input.d.ts +15 -15
- package/dist/types/calls/dialogs/mediaSelect.d.ts +8 -8
- package/dist/types/calls/dialogs/open.d.ts +1 -1
- package/dist/types/calls/dialogs/select.d.ts +6 -6
- package/dist/types/calls/dialogs/signature.d.ts +7 -7
- package/dist/types/calls/dialogs/toast.d.ts +1 -1
- package/dist/types/calls/dialogs/utils/callback.d.ts +1 -1
- package/dist/types/calls/dialogs/utils/is.d.ts +4 -4
- package/dist/types/calls/getUserInfo.d.ts +9 -9
- package/dist/types/calls/index.d.ts +237 -233
- package/dist/types/calls/sendMessage.d.ts +13 -13
- package/dist/types/calls/visibilityChangeListener.d.ts +9 -9
- package/dist/types/components/AppDialogWrapper.d.ts +5 -0
- package/dist/types/components/ChaynsContext.d.ts +3 -3
- package/dist/types/components/ChaynsProvider.d.ts +14 -14
- package/dist/types/components/WaitUntil.d.ts +7 -8
- package/dist/types/components/withCompatMode.d.ts +13 -13
- package/dist/types/handler/DialogHandler.d.ts +19 -0
- package/dist/types/helper/apiListenerHelper.d.ts +6 -6
- package/dist/types/hooks/geoLocationListener.d.ts +18 -18
- package/dist/types/hooks/index.d.ts +17 -16
- package/dist/types/hooks/scrollListener.d.ts +28 -28
- package/dist/types/hooks/useAccessToken.d.ts +5 -5
- package/dist/types/hooks/useCurrentPage.d.ts +4 -4
- package/dist/types/hooks/useCustomData.d.ts +4 -4
- package/dist/types/hooks/useDevice.d.ts +5 -5
- package/dist/types/hooks/useDialogState.d.ts +9 -0
- package/dist/types/hooks/useEnvironment.d.ts +5 -5
- package/dist/types/hooks/useFunctions.d.ts +5 -5
- package/dist/types/hooks/useIsAdminMode.d.ts +4 -4
- package/dist/types/hooks/useLanguage.d.ts +5 -5
- package/dist/types/hooks/usePages.d.ts +18 -18
- package/dist/types/hooks/useParameters.d.ts +5 -5
- package/dist/types/hooks/useSite.d.ts +5 -5
- package/dist/types/hooks/useUser.d.ts +5 -5
- package/dist/types/hooks/useValues.d.ts +5 -5
- package/dist/types/hooks/windowMetricsListener.d.ts +11 -11
- package/dist/types/host/ChaynsHost.d.ts +30 -29
- package/dist/types/host/iframe/HostIframe.d.ts +26 -25
- package/dist/types/host/iframe/utils/useUpdateData.d.ts +3 -3
- package/dist/types/host/module/ModuleHost.d.ts +26 -25
- package/dist/types/host/module/utils/loadComponent.d.ts +1 -1
- package/dist/types/host/module/utils/useDynamicScript.d.ts +9 -9
- package/dist/types/index.d.ts +16 -16
- package/dist/types/types/IChaynsReact.d.ts +708 -624
- package/dist/types/types/dialog.d.ts +41 -41
- package/dist/types/util/appCall.d.ts +2 -2
- package/dist/types/util/deviceHelper.d.ts +7 -7
- package/dist/types/util/heightHelper.d.ts +1 -1
- package/dist/types/util/postIframeForm.d.ts +1 -1
- package/dist/types/util/url.d.ts +1 -1
- package/dist/types/wrapper/AppWrapper.d.ts +22 -18
- package/dist/types/wrapper/FrameWrapper.d.ts +15 -15
- package/dist/types/wrapper/ModuleFederationWrapper.d.ts +10 -10
- package/dist/types/wrapper/SsrWrapper.d.ts +11 -11
- package/package.json +75 -75
- package/tsconfig.json +56 -56
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useContextSelector } from 'use-context-selector';
|
|
2
|
+
import { ChaynsContext, ChaynsFunctionsContext } from '../components/ChaynsContext';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @category Hooks
|
|
6
|
+
*/
|
|
7
|
+
export const useDialogState = () => {
|
|
8
|
+
const setResult = useContextSelector(ChaynsFunctionsContext, v => v === null || v === void 0 ? void 0 : v.setDialogResult);
|
|
9
|
+
const sendData = useContextSelector(ChaynsFunctionsContext, v => v === null || v === void 0 ? void 0 : v.dispatchEventToDialogHost);
|
|
10
|
+
const addDataListener = useContextSelector(ChaynsFunctionsContext, v => v === null || v === void 0 ? void 0 : v.addDialogHostEventListener);
|
|
11
|
+
const isClosingRequested = useContextSelector(ChaynsContext, v => {
|
|
12
|
+
var _v$dialog;
|
|
13
|
+
return v === null || v === void 0 ? void 0 : (_v$dialog = v.dialog) === null || _v$dialog === void 0 ? void 0 : _v$dialog.isClosingRequested;
|
|
14
|
+
});
|
|
15
|
+
return {
|
|
16
|
+
setResult,
|
|
17
|
+
sendData,
|
|
18
|
+
addDataListener,
|
|
19
|
+
isClosingRequested
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @category Hooks
|
|
25
|
+
*/
|
|
26
|
+
export const useDialogData = () => {
|
|
27
|
+
const inputData = useContextSelector(ChaynsContext, v => {
|
|
28
|
+
var _v$dialog2;
|
|
29
|
+
return v === null || v === void 0 ? void 0 : (_v$dialog2 = v.dialog) === null || _v$dialog2 === void 0 ? void 0 : _v$dialog2.dialogInput;
|
|
30
|
+
});
|
|
31
|
+
return inputData;
|
|
32
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useContextSelector } from 'use-context-selector';
|
|
2
2
|
import { ChaynsContext } from '../components/ChaynsContext';
|
|
3
|
-
/**
|
|
4
|
-
* @category Hooks
|
|
3
|
+
/**
|
|
4
|
+
* @category Hooks
|
|
5
5
|
*/
|
|
6
6
|
export const useEnvironment = () => useContextSelector(ChaynsContext, v => v === null || v === void 0 ? void 0 : v.environment);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useContextSelector } from "use-context-selector";
|
|
2
2
|
import { ChaynsFunctionsContext } from "../components/ChaynsContext";
|
|
3
|
-
/**
|
|
4
|
-
* @category Hooks
|
|
3
|
+
/**
|
|
4
|
+
* @category Hooks
|
|
5
5
|
*/
|
|
6
6
|
export const useFunctions = () => {
|
|
7
7
|
const t = useContextSelector(ChaynsFunctionsContext, f => f || {});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useContextSelector } from 'use-context-selector';
|
|
2
2
|
import { ChaynsContext } from '../components/ChaynsContext';
|
|
3
|
-
/**
|
|
4
|
-
* @category Hooks
|
|
3
|
+
/**
|
|
4
|
+
* @category Hooks
|
|
5
5
|
*/
|
|
6
6
|
export const useLanguage = () => useContextSelector(ChaynsContext, v => v === null || v === void 0 ? void 0 : v.language);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useContextSelector } from 'use-context-selector';
|
|
2
2
|
import { ChaynsContext } from '../components/ChaynsContext';
|
|
3
3
|
import { moduleWrapper } from "../components/ChaynsProvider";
|
|
4
|
-
/**
|
|
5
|
-
* @category Hooks
|
|
4
|
+
/**
|
|
5
|
+
* @category Hooks
|
|
6
6
|
*/
|
|
7
7
|
export const usePages = function () {
|
|
8
8
|
let {
|
|
@@ -16,8 +16,8 @@ export const usePages = function () {
|
|
|
16
16
|
}
|
|
17
17
|
return pages;
|
|
18
18
|
};
|
|
19
|
-
/**
|
|
20
|
-
* @category Hooks
|
|
19
|
+
/**
|
|
20
|
+
* @category Hooks
|
|
21
21
|
*/
|
|
22
22
|
export const usePage = _ref => {
|
|
23
23
|
let {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useContextSelector } from 'use-context-selector';
|
|
2
2
|
import { ChaynsContext } from '../components/ChaynsContext';
|
|
3
|
-
/**
|
|
4
|
-
* @category Hooks
|
|
3
|
+
/**
|
|
4
|
+
* @category Hooks
|
|
5
5
|
*/
|
|
6
6
|
export const useParameters = () => useContextSelector(ChaynsContext, v => (v === null || v === void 0 ? void 0 : v.parameters) || []);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useContextSelector } from 'use-context-selector';
|
|
2
2
|
import { ChaynsContext } from '../components/ChaynsContext';
|
|
3
|
-
/**
|
|
4
|
-
* @category Hooks
|
|
3
|
+
/**
|
|
4
|
+
* @category Hooks
|
|
5
5
|
*/
|
|
6
6
|
export const useSite = () => useContextSelector(ChaynsContext, v => v === null || v === void 0 ? void 0 : v.site);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useContextSelector } from 'use-context-selector';
|
|
2
2
|
import { ChaynsContext } from '../components/ChaynsContext';
|
|
3
|
-
/**
|
|
4
|
-
* @category Hooks
|
|
3
|
+
/**
|
|
4
|
+
* @category Hooks
|
|
5
5
|
*/
|
|
6
6
|
export const useUser = () => useContextSelector(ChaynsContext, v => (v === null || v === void 0 ? void 0 : v.user) || {});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useContextSelector } from 'use-context-selector';
|
|
2
2
|
import { ChaynsContext } from '../components/ChaynsContext';
|
|
3
|
-
/**
|
|
4
|
-
* @category Hooks
|
|
3
|
+
/**
|
|
4
|
+
* @category Hooks
|
|
5
5
|
*/
|
|
6
6
|
export const useValues = () => {
|
|
7
7
|
const t = useContextSelector(ChaynsContext, v => v || {});
|
|
@@ -2,8 +2,8 @@ import { useContextSelector } from 'use-context-selector';
|
|
|
2
2
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
3
3
|
import { ChaynsFunctionsContext } from '../components/ChaynsContext';
|
|
4
4
|
import { ScreenSize } from '../types/IChaynsReact';
|
|
5
|
-
/**
|
|
6
|
-
* @category Hooks
|
|
5
|
+
/**
|
|
6
|
+
* @category Hooks
|
|
7
7
|
*/
|
|
8
8
|
export const useWindowMetricsListener = () => {
|
|
9
9
|
const addListener = useContextSelector(ChaynsFunctionsContext, v => v.addWindowMetricsListener);
|
|
@@ -18,8 +18,8 @@ export const useWindowMetricsListener = () => {
|
|
|
18
18
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
19
19
|
}, []);
|
|
20
20
|
};
|
|
21
|
-
/**
|
|
22
|
-
* @category Hooks
|
|
21
|
+
/**
|
|
22
|
+
* @category Hooks
|
|
23
23
|
*/
|
|
24
24
|
export const useWindowMetrics = function () {
|
|
25
25
|
let {
|
|
@@ -22,7 +22,8 @@ const ChaynsHost = _ref => {
|
|
|
22
22
|
parameters,
|
|
23
23
|
customData,
|
|
24
24
|
environment,
|
|
25
|
-
preventStagingReplacement
|
|
25
|
+
preventStagingReplacement,
|
|
26
|
+
dialog
|
|
26
27
|
} = _ref;
|
|
27
28
|
switch (type) {
|
|
28
29
|
case 'client-iframe':
|
|
@@ -41,7 +42,8 @@ const ChaynsHost = _ref => {
|
|
|
41
42
|
parameters: parameters,
|
|
42
43
|
environment: environment,
|
|
43
44
|
customData: customData,
|
|
44
|
-
preventStagingReplacement: preventStagingReplacement
|
|
45
|
+
preventStagingReplacement: preventStagingReplacement,
|
|
46
|
+
dialog: dialog
|
|
45
47
|
});
|
|
46
48
|
case 'client-module':
|
|
47
49
|
return /*#__PURE__*/React.createElement(ModuleHost, {
|
|
@@ -58,7 +60,8 @@ const ChaynsHost = _ref => {
|
|
|
58
60
|
parameters: parameters,
|
|
59
61
|
customData: customData,
|
|
60
62
|
environment: environment,
|
|
61
|
-
preventStagingReplacement: preventStagingReplacement
|
|
63
|
+
preventStagingReplacement: preventStagingReplacement,
|
|
64
|
+
dialog: dialog
|
|
62
65
|
});
|
|
63
66
|
case 'server-iframe':
|
|
64
67
|
return /*#__PURE__*/React.createElement(HostIframe, {
|
|
@@ -77,7 +80,8 @@ const ChaynsHost = _ref => {
|
|
|
77
80
|
parameters: parameters,
|
|
78
81
|
environment: environment,
|
|
79
82
|
customData: customData,
|
|
80
|
-
preventStagingReplacement: preventStagingReplacement
|
|
83
|
+
preventStagingReplacement: preventStagingReplacement,
|
|
84
|
+
dialog: dialog
|
|
81
85
|
});
|
|
82
86
|
case 'server-module':
|
|
83
87
|
return /*#__PURE__*/React.createElement(ModuleHost, {
|
|
@@ -93,7 +97,8 @@ const ChaynsHost = _ref => {
|
|
|
93
97
|
parameters: parameters,
|
|
94
98
|
customData: customData,
|
|
95
99
|
environment: environment,
|
|
96
|
-
preventStagingReplacement: preventStagingReplacement
|
|
100
|
+
preventStagingReplacement: preventStagingReplacement,
|
|
101
|
+
dialog: dialog
|
|
97
102
|
}, children);
|
|
98
103
|
default:
|
|
99
104
|
return null;
|
|
@@ -22,7 +22,8 @@ const HostIframe = _ref => {
|
|
|
22
22
|
parameters,
|
|
23
23
|
environment,
|
|
24
24
|
customData,
|
|
25
|
-
preventStagingReplacement
|
|
25
|
+
preventStagingReplacement,
|
|
26
|
+
dialog
|
|
26
27
|
} = _ref;
|
|
27
28
|
const eventTarget = useRef();
|
|
28
29
|
const ref = useRef();
|
|
@@ -48,7 +49,8 @@ const HostIframe = _ref => {
|
|
|
48
49
|
language,
|
|
49
50
|
parameters,
|
|
50
51
|
environment,
|
|
51
|
-
customData
|
|
52
|
+
customData,
|
|
53
|
+
dialog
|
|
52
54
|
};
|
|
53
55
|
// endregion
|
|
54
56
|
|
|
@@ -108,6 +110,7 @@ const HostIframe = _ref => {
|
|
|
108
110
|
useUpdateData(eventTarget.current, 'parameters', parameters);
|
|
109
111
|
useUpdateData(eventTarget.current, 'environment', environment);
|
|
110
112
|
useUpdateData(eventTarget.current, 'customData', customData);
|
|
113
|
+
useUpdateData(eventTarget.current, 'dialog', dialog);
|
|
111
114
|
// endregion
|
|
112
115
|
|
|
113
116
|
return /*#__PURE__*/React.createElement("iframe", _extends({
|
|
@@ -43,6 +43,7 @@ const ModuleHost = _ref2 => {
|
|
|
43
43
|
language,
|
|
44
44
|
parameters,
|
|
45
45
|
customData,
|
|
46
|
+
dialog,
|
|
46
47
|
environment,
|
|
47
48
|
preventStagingReplacement
|
|
48
49
|
} = _ref2;
|
|
@@ -61,6 +62,9 @@ const ModuleHost = _ref2 => {
|
|
|
61
62
|
if (user) {
|
|
62
63
|
initialData.user = user;
|
|
63
64
|
}
|
|
65
|
+
if (dialog) {
|
|
66
|
+
initialData.dialog = dialog;
|
|
67
|
+
}
|
|
64
68
|
// endregion
|
|
65
69
|
|
|
66
70
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
export let DialogButtonType;
|
|
2
|
+
(function (DialogButtonType) {
|
|
3
|
+
DialogButtonType[DialogButtonType["OK"] = 1] = "OK";
|
|
4
|
+
DialogButtonType[DialogButtonType["CANCEL"] = -1] = "CANCEL";
|
|
5
|
+
DialogButtonType[DialogButtonType["NEGATIVE"] = 0] = "NEGATIVE";
|
|
6
|
+
})(DialogButtonType || (DialogButtonType = {}));
|
|
1
7
|
export let ScreenSize;
|
|
2
8
|
(function (ScreenSize) {
|
|
3
9
|
ScreenSize[ScreenSize["XS"] = 0] = "XS";
|
|
@@ -235,4 +241,16 @@ var selectType;
|
|
|
235
241
|
(function (selectType) {
|
|
236
242
|
selectType[selectType["DEFAULT"] = 0] = "DEFAULT";
|
|
237
243
|
selectType[selectType["ICON"] = 1] = "ICON";
|
|
238
|
-
})(selectType || (selectType = {}));
|
|
244
|
+
})(selectType || (selectType = {}));
|
|
245
|
+
export let DialogType;
|
|
246
|
+
(function (DialogType) {
|
|
247
|
+
DialogType["ALERT"] = "alert";
|
|
248
|
+
DialogType["CONFIRM"] = "confirm";
|
|
249
|
+
DialogType["DATE"] = "date";
|
|
250
|
+
DialogType["FILE_SELECT"] = "fileSelect";
|
|
251
|
+
DialogType["IFRAME"] = "iframe";
|
|
252
|
+
DialogType["MODULE"] = "module";
|
|
253
|
+
DialogType["INPUT"] = "input";
|
|
254
|
+
DialogType["SELECT"] = "select";
|
|
255
|
+
DialogType["TOAST"] = "toast";
|
|
256
|
+
})(DialogType || (DialogType = {}));
|
|
@@ -29,7 +29,7 @@ const getDeviceInfo = (userAgent, acceptHeader) => {
|
|
|
29
29
|
result.accessToken = undefined; // TODO
|
|
30
30
|
result.os = parsedUA === null || parsedUA === void 0 ? void 0 : parsedUA.os;
|
|
31
31
|
if (typeof window !== 'undefined') {
|
|
32
|
-
result.screenSize = getScreenSize(window.innerWidth);
|
|
32
|
+
result.screenSize = getScreenSize(window.innerWidth, window.innerHeight);
|
|
33
33
|
} else {
|
|
34
34
|
// estimate size over user agent, very inaccurate, could be improved by setting a cookie with the screensize
|
|
35
35
|
const screenSizeByUA = /mobi/i.test(userAgent) ? ScreenSize.SM : ScreenSize.XL;
|
|
@@ -42,15 +42,16 @@ const getDeviceInfo = (userAgent, acceptHeader) => {
|
|
|
42
42
|
export const getClientDeviceInfo = () => ({
|
|
43
43
|
isTouch: navigator.maxTouchPoints > 0 && window.matchMedia('(pointer: coarse)')
|
|
44
44
|
});
|
|
45
|
-
export const getScreenSize = width => {
|
|
45
|
+
export const getScreenSize = (width, height) => {
|
|
46
|
+
const size = Math.max(width, height);
|
|
46
47
|
let value;
|
|
47
|
-
if (
|
|
48
|
+
if (size > 1200) {
|
|
48
49
|
value = ScreenSize.XL;
|
|
49
|
-
} else if (
|
|
50
|
+
} else if (size > 993) {
|
|
50
51
|
value = ScreenSize.LG;
|
|
51
|
-
} else if (
|
|
52
|
+
} else if (size > 769) {
|
|
52
53
|
value = ScreenSize.MD;
|
|
53
|
-
} else if (
|
|
54
|
+
} else if (size > 556) {
|
|
54
55
|
value = ScreenSize.SM;
|
|
55
56
|
} else {
|
|
56
57
|
value = ScreenSize.XS;
|
|
@@ -5,12 +5,14 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
|
|
|
5
5
|
// @ts-nocheck
|
|
6
6
|
|
|
7
7
|
import throttle from 'lodash.throttle';
|
|
8
|
+
import DialogHandler from '../handler/DialogHandler';
|
|
8
9
|
import { Environment, Font, Gender, IconType, RuntimeEnviroment, TappEvent } from '../types/IChaynsReact';
|
|
9
10
|
import invokeAppCall from '../util/appCall';
|
|
10
11
|
import getDeviceInfo, { getScreenSize } from '../util/deviceHelper';
|
|
11
12
|
import getUserInfo from '../calls/getUserInfo';
|
|
12
13
|
import { sendMessageToGroup, sendMessageToPage, sendMessageToUser } from '../calls/sendMessage';
|
|
13
14
|
import { addApiListener, dispatchApiEvent, removeApiListener } from '../helper/apiListenerHelper';
|
|
15
|
+
let appWrapperDialogId = 0;
|
|
14
16
|
export class AppWrapper {
|
|
15
17
|
mapOldApiToNew(retVal) {
|
|
16
18
|
var _window, _window2, _AppInfo$TappSelected;
|
|
@@ -104,13 +106,12 @@ export class AppWrapper {
|
|
|
104
106
|
permanent: true
|
|
105
107
|
}, {
|
|
106
108
|
callback: v => {
|
|
107
|
-
var _v$accuracy, _v$
|
|
109
|
+
var _v$accuracy, _v$code;
|
|
108
110
|
dispatchApiEvent('geoLocationListener', {
|
|
109
111
|
latitude: v.latitude,
|
|
110
112
|
longitude: v.longitude,
|
|
111
113
|
accuracy: (_v$accuracy = v.accuracy) !== null && _v$accuracy !== void 0 ? _v$accuracy : null,
|
|
112
114
|
speed: v.speed,
|
|
113
|
-
isAccurate: (_v$isAccurate = v.isAccurate) !== null && _v$isAccurate !== void 0 ? _v$isAccurate : null,
|
|
114
115
|
code: (_v$code = v.code) !== null && _v$code !== void 0 ? _v$code : null
|
|
115
116
|
});
|
|
116
117
|
}
|
|
@@ -181,15 +182,13 @@ export class AppWrapper {
|
|
|
181
182
|
};
|
|
182
183
|
},
|
|
183
184
|
getGeoLocation: async () => {
|
|
184
|
-
var _res$accuracy, _res$isAccurate, _res$code;
|
|
185
185
|
const res = await this.appCall(14);
|
|
186
186
|
return {
|
|
187
187
|
latitude: res.latitude,
|
|
188
188
|
longitude: res.longitude,
|
|
189
189
|
speed: res.speed,
|
|
190
|
-
|
|
191
|
-
isAccurate:
|
|
192
|
-
code: (_res$code = res.code) !== null && _res$code !== void 0 ? _res$code : null
|
|
190
|
+
code: res.code,
|
|
191
|
+
isAccurate: res.isAccurate
|
|
193
192
|
};
|
|
194
193
|
},
|
|
195
194
|
getUserInfo: async query => {
|
|
@@ -430,12 +429,46 @@ export class AppWrapper {
|
|
|
430
429
|
void this.appCall(19, value, {
|
|
431
430
|
awaitResult: false
|
|
432
431
|
});
|
|
432
|
+
},
|
|
433
|
+
createDialog: config => {
|
|
434
|
+
return new DialogHandler(config, this.functions.openDialog, this.functions.closeDialog);
|
|
435
|
+
},
|
|
436
|
+
openDialog: async (config, callback) => {
|
|
437
|
+
const currentDialogId = appWrapperDialogId++;
|
|
438
|
+
const eventTarget = new EventTarget();
|
|
439
|
+
const resolve = result => {
|
|
440
|
+
callback(result);
|
|
441
|
+
this.dispatchDialogChange(this.dialogs.filter(x => x.dialogId !== currentDialogId));
|
|
442
|
+
};
|
|
443
|
+
this.dispatchDialogChange([...this.dialogs, {
|
|
444
|
+
config,
|
|
445
|
+
resolve,
|
|
446
|
+
dialogId: currentDialogId,
|
|
447
|
+
eventTarget
|
|
448
|
+
}]);
|
|
449
|
+
return currentDialogId;
|
|
450
|
+
},
|
|
451
|
+
closeDialog: dialogId => {
|
|
452
|
+
const dialog = this.dialogs.find(x => x.dialogId === dialogId);
|
|
453
|
+
if (dialog) {
|
|
454
|
+
dialog.resolve({
|
|
455
|
+
buttonType: -1
|
|
456
|
+
});
|
|
457
|
+
}
|
|
433
458
|
}
|
|
434
459
|
});
|
|
460
|
+
_defineProperty(this, "dialogs", []);
|
|
461
|
+
_defineProperty(this, "dialogEventTarget", new EventTarget());
|
|
435
462
|
}
|
|
436
463
|
notImplemented(call) {
|
|
437
464
|
console.warn(`call ${call} not implement in app`);
|
|
438
465
|
}
|
|
466
|
+
dispatchDialogChange(detail) {
|
|
467
|
+
this.dialogs = detail;
|
|
468
|
+
this.dialogEventTarget.dispatchEvent(new CustomEvent('change', {
|
|
469
|
+
detail
|
|
470
|
+
}));
|
|
471
|
+
}
|
|
439
472
|
appCall(action) {
|
|
440
473
|
let value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
441
474
|
let {
|
|
@@ -468,6 +501,9 @@ export class AppWrapper {
|
|
|
468
501
|
});
|
|
469
502
|
});
|
|
470
503
|
}
|
|
504
|
+
getDialogEventTarget() {
|
|
505
|
+
return this.dialogEventTarget;
|
|
506
|
+
}
|
|
471
507
|
async init() {
|
|
472
508
|
this.values = this.mapOldApiToNew(await this.appCall(18));
|
|
473
509
|
return undefined;
|
|
@@ -3,6 +3,7 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typ
|
|
|
3
3
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
4
4
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
5
5
|
import * as comlink from 'comlink';
|
|
6
|
+
import DialogHandler from '../handler/DialogHandler';
|
|
6
7
|
import { addVisibilityChangeListener, removeVisibilityChangeListener } from '../calls/visibilityChangeListener';
|
|
7
8
|
import { addApiListener, dispatchApiEvent, removeApiListener } from '../helper/apiListenerHelper';
|
|
8
9
|
import getUserInfo from '../calls/getUserInfo';
|
|
@@ -227,7 +228,57 @@ export class FrameWrapper {
|
|
|
227
228
|
scrollByY: async (value, duration) => {
|
|
228
229
|
if (!this.initialized) await this.ready;
|
|
229
230
|
return this.exposedFunctions.scrollByY(value, duration);
|
|
230
|
-
}
|
|
231
|
+
},
|
|
232
|
+
createDialog: config => {
|
|
233
|
+
return new DialogHandler(config, this.functions.openDialog, this.exposedFunctions.closeDialog, this.functions.dispatchEventToDialogClient, this.functions.addDialogClientEventListener);
|
|
234
|
+
},
|
|
235
|
+
closeDialog: async dialogId => {
|
|
236
|
+
if (!this.initialized) await this.ready;
|
|
237
|
+
return this.exposedFunctions.closeDialog(dialogId);
|
|
238
|
+
},
|
|
239
|
+
openDialog: async (config, callback) => {
|
|
240
|
+
if (!this.initialized) await this.ready;
|
|
241
|
+
return this.exposedFunctions.openDialog(config, comlink.proxy(callback));
|
|
242
|
+
},
|
|
243
|
+
setDialogResult: async result => {
|
|
244
|
+
if (!this.initialized) await this.ready;
|
|
245
|
+
return this.exposedFunctions.setDialogResult(result);
|
|
246
|
+
},
|
|
247
|
+
dispatchEventToDialogClient: async (dialogId, data) => {
|
|
248
|
+
if (!this.initialized) await this.ready;
|
|
249
|
+
return this.exposedFunctions.dispatchEventToDialogClient(dialogId, data);
|
|
250
|
+
},
|
|
251
|
+
addDialogClientEventListener: async (dialogId, callback) => {
|
|
252
|
+
if (!this.initialized) await this.ready;
|
|
253
|
+
return this.exposedFunctions.addDialogClientEventListener(dialogId, comlink.proxy(callback));
|
|
254
|
+
},
|
|
255
|
+
dispatchEventToDialogHost: async data => {
|
|
256
|
+
if (!this.initialized) await this.ready;
|
|
257
|
+
return this.exposedFunctions.dispatchEventToDialogHost(data);
|
|
258
|
+
},
|
|
259
|
+
addDialogHostEventListener: async callback => {
|
|
260
|
+
if (!this.initialized) await this.ready;
|
|
261
|
+
const listenerKey = `dialogHostEventListener`;
|
|
262
|
+
const {
|
|
263
|
+
id,
|
|
264
|
+
shouldInitialize
|
|
265
|
+
} = addApiListener(listenerKey, callback);
|
|
266
|
+
if (shouldInitialize) {
|
|
267
|
+
this.exposedFunctions.addDialogHostEventListener(comlink.proxy(data => {
|
|
268
|
+
dispatchApiEvent(listenerKey, data);
|
|
269
|
+
}));
|
|
270
|
+
}
|
|
271
|
+
return id;
|
|
272
|
+
},
|
|
273
|
+
removeDialogHostEventListener: async id => {
|
|
274
|
+
if (!this.initialized) await this.ready;
|
|
275
|
+
const listenerKey = `dialogHostEventListener`;
|
|
276
|
+
const shouldRemove = removeApiListener(listenerKey, id);
|
|
277
|
+
if (shouldRemove) {
|
|
278
|
+
// this.exposedFunctions.removeDialogHostEventListener(0);
|
|
279
|
+
}
|
|
280
|
+
},
|
|
281
|
+
removeDialogClientEventListener: async () => {}
|
|
231
282
|
});
|
|
232
283
|
_defineProperty(this, "initialized", false);
|
|
233
284
|
const initialDataTag = document.querySelector('#__CHAYNS_DATA__');
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import DialogHandler from '../handler/DialogHandler';
|
|
1
2
|
import { addVisibilityChangeListener, removeVisibilityChangeListener } from '../calls/visibilityChangeListener';
|
|
2
3
|
import { addApiListener, dispatchApiEvent, removeApiListener } from '../helper/apiListenerHelper';
|
|
3
4
|
import getUserInfo from '../calls/getUserInfo';
|
|
@@ -20,6 +21,9 @@ export class ModuleFederationWrapper {
|
|
|
20
21
|
return fn(...arguments);
|
|
21
22
|
};
|
|
22
23
|
});
|
|
24
|
+
this.functions.createDialog = config => {
|
|
25
|
+
return new DialogHandler(config, functions.openDialog, functions.closeDialog, functions.dispatchEventToDialogClient, functions.addDialogClientEventListener);
|
|
26
|
+
};
|
|
23
27
|
this.functions.addWindowMetricsListener = async callback => {
|
|
24
28
|
const {
|
|
25
29
|
id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function alert(title?: string, message?: string): Promise<any> | "unsupported";
|
|
1
|
+
export declare function alert(title?: string, message?: string): Promise<any> | "unsupported";
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
export declare const buttonText: {
|
|
2
|
-
YES: string;
|
|
3
|
-
NO: string;
|
|
4
|
-
OK: string;
|
|
5
|
-
CANCEL: string;
|
|
6
|
-
};
|
|
7
|
-
export declare const buttonType: {
|
|
8
|
-
CANCEL: number;
|
|
9
|
-
NEGATIVE: number;
|
|
10
|
-
POSITIVE: number;
|
|
11
|
-
};
|
|
12
|
-
export declare const dialogAction: {
|
|
13
|
-
ALERT_CONFIRM: number;
|
|
14
|
-
INPUT: number;
|
|
15
|
-
SELECT: number;
|
|
16
|
-
DATE: number;
|
|
17
|
-
ADVANCED_DATE: number;
|
|
18
|
-
DROP_UP_ALERT: number;
|
|
19
|
-
MEDIA_SELECT: number;
|
|
20
|
-
FILE_SELECT: number;
|
|
21
|
-
SIGNATURE: number;
|
|
22
|
-
IFRAME: number;
|
|
23
|
-
};
|
|
24
|
-
export declare function chaynsDialog(config: any): Promise<any> | "unsupported";
|
|
1
|
+
export declare const buttonText: {
|
|
2
|
+
YES: string;
|
|
3
|
+
NO: string;
|
|
4
|
+
OK: string;
|
|
5
|
+
CANCEL: string;
|
|
6
|
+
};
|
|
7
|
+
export declare const buttonType: {
|
|
8
|
+
CANCEL: number;
|
|
9
|
+
NEGATIVE: number;
|
|
10
|
+
POSITIVE: number;
|
|
11
|
+
};
|
|
12
|
+
export declare const dialogAction: {
|
|
13
|
+
ALERT_CONFIRM: number;
|
|
14
|
+
INPUT: number;
|
|
15
|
+
SELECT: number;
|
|
16
|
+
DATE: number;
|
|
17
|
+
ADVANCED_DATE: number;
|
|
18
|
+
DROP_UP_ALERT: number;
|
|
19
|
+
MEDIA_SELECT: number;
|
|
20
|
+
FILE_SELECT: number;
|
|
21
|
+
SIGNATURE: number;
|
|
22
|
+
IFRAME: number;
|
|
23
|
+
};
|
|
24
|
+
export declare function chaynsDialog(config: any): Promise<any> | "unsupported";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function close(): Promise<any>;
|
|
1
|
+
export declare function close(): Promise<any>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare function sendData(data: any, isApiEvent: any): Promise<any>;
|
|
2
|
-
export declare function addDialogDataListener(callback: any, getApiEvents?: boolean): boolean;
|
|
3
|
-
export declare function removeDialogDataListener(callback: any, getApiEvents?: boolean): boolean;
|
|
1
|
+
export declare function sendData(data: any, isApiEvent: any): Promise<any>;
|
|
2
|
+
export declare function addDialogDataListener(callback: any, getApiEvents?: boolean): boolean;
|
|
3
|
+
export declare function removeDialogDataListener(callback: any, getApiEvents?: boolean): boolean;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type Confirm = {
|
|
3
|
-
headline?: string;
|
|
4
|
-
text?: string;
|
|
5
|
-
buttons?:
|
|
6
|
-
buttons?:
|
|
7
|
-
links?:
|
|
8
|
-
};
|
|
9
|
-
links?: unknown;
|
|
10
|
-
select?: unknown;
|
|
11
|
-
};
|
|
12
|
-
export declare function confirm(title?: string, message?: string, config?: Confirm): Promise<any> | "unsupported";
|
|
13
|
-
export {};
|
|
1
|
+
import { DialogButtonOld } from "../../types/dialog";
|
|
2
|
+
type Confirm = {
|
|
3
|
+
headline?: string;
|
|
4
|
+
text?: string;
|
|
5
|
+
buttons?: DialogButtonOld[] | {
|
|
6
|
+
buttons?: DialogButtonOld[];
|
|
7
|
+
links?: DialogButtonOld[];
|
|
8
|
+
};
|
|
9
|
+
links?: unknown;
|
|
10
|
+
select?: unknown;
|
|
11
|
+
};
|
|
12
|
+
export declare function confirm(title?: string, message?: string, config?: Confirm): Promise<any> | "unsupported";
|
|
13
|
+
export {};
|