chayns-api 1.0.9 → 1.0.10-beta.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/.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 +47 -47
- 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 +40 -0
- package/dist/cjs/components/ChaynsProvider.js +5 -2
- package/dist/cjs/components/withCompatMode.js +3 -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 +31 -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 +6 -3
- package/dist/cjs/host/iframe/HostIframe.js +6 -3
- package/dist/cjs/types/IChaynsReact.js +22 -2
- package/dist/cjs/util/deviceHelper.js +7 -6
- package/dist/cjs/wrapper/AppWrapper.js +59 -0
- package/dist/cjs/wrapper/FrameWrapper.js +16 -1
- package/dist/cjs/wrapper/ModuleFederationWrapper.js +11 -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 +31 -0
- package/dist/esm/components/ChaynsProvider.js +5 -2
- package/dist/esm/components/withCompatMode.js +3 -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 +24 -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 +6 -3
- package/dist/esm/host/iframe/HostIframe.js +6 -3
- package/dist/esm/types/IChaynsReact.js +19 -1
- package/dist/esm/util/deviceHelper.js +7 -6
- package/dist/esm/wrapper/AppWrapper.js +63 -1
- package/dist/esm/wrapper/FrameWrapper.js +19 -2
- package/dist/esm/wrapper/ModuleFederationWrapper.js +11 -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 -13
- package/dist/types/components/WaitUntil.d.ts +8 -7
- package/dist/types/components/withCompatMode.d.ts +13 -13
- 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 +25 -24
- 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 +700 -622
- 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 +27 -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 -76
- package/tsconfig.json +56 -56
- package/toolkit.config.js +0 -52
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.useEnvironment = void 0;
|
|
7
7
|
var _useContextSelector = require("use-context-selector");
|
|
8
8
|
var _ChaynsContext = require("../components/ChaynsContext");
|
|
9
|
-
/**
|
|
10
|
-
* @category Hooks
|
|
9
|
+
/**
|
|
10
|
+
* @category Hooks
|
|
11
11
|
*/
|
|
12
12
|
const useEnvironment = () => (0, _useContextSelector.useContextSelector)(_ChaynsContext.ChaynsContext, v => v === null || v === void 0 ? void 0 : v.environment);
|
|
13
13
|
exports.useEnvironment = useEnvironment;
|
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.useFunctions = void 0;
|
|
7
7
|
var _useContextSelector = require("use-context-selector");
|
|
8
8
|
var _ChaynsContext = require("../components/ChaynsContext");
|
|
9
|
-
/**
|
|
10
|
-
* @category Hooks
|
|
9
|
+
/**
|
|
10
|
+
* @category Hooks
|
|
11
11
|
*/
|
|
12
12
|
const useFunctions = () => {
|
|
13
13
|
const t = (0, _useContextSelector.useContextSelector)(_ChaynsContext.ChaynsFunctionsContext, f => f || {});
|
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.useIsAdminMode = void 0;
|
|
7
7
|
var _useContextSelector2 = require("use-context-selector");
|
|
8
8
|
var _ChaynsContext = require("../components/ChaynsContext");
|
|
9
|
-
/**
|
|
10
|
-
* @category Hooks
|
|
9
|
+
/**
|
|
10
|
+
* @category Hooks
|
|
11
11
|
*/
|
|
12
12
|
const useIsAdminMode = () => {
|
|
13
13
|
var _useContextSelector;
|
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.useLanguage = void 0;
|
|
7
7
|
var _useContextSelector = require("use-context-selector");
|
|
8
8
|
var _ChaynsContext = require("../components/ChaynsContext");
|
|
9
|
-
/**
|
|
10
|
-
* @category Hooks
|
|
9
|
+
/**
|
|
10
|
+
* @category Hooks
|
|
11
11
|
*/
|
|
12
12
|
const useLanguage = () => (0, _useContextSelector.useContextSelector)(_ChaynsContext.ChaynsContext, v => v === null || v === void 0 ? void 0 : v.language);
|
|
13
13
|
exports.useLanguage = useLanguage;
|
|
@@ -7,8 +7,8 @@ exports.usePages = exports.usePage = exports.getPage = void 0;
|
|
|
7
7
|
var _useContextSelector = require("use-context-selector");
|
|
8
8
|
var _ChaynsContext = require("../components/ChaynsContext");
|
|
9
9
|
var _ChaynsProvider = require("../components/ChaynsProvider");
|
|
10
|
-
/**
|
|
11
|
-
* @category Hooks
|
|
10
|
+
/**
|
|
11
|
+
* @category Hooks
|
|
12
12
|
*/
|
|
13
13
|
const usePages = ({
|
|
14
14
|
siteId
|
|
@@ -21,8 +21,8 @@ const usePages = ({
|
|
|
21
21
|
}
|
|
22
22
|
return pages;
|
|
23
23
|
};
|
|
24
|
-
/**
|
|
25
|
-
* @category Hooks
|
|
24
|
+
/**
|
|
25
|
+
* @category Hooks
|
|
26
26
|
*/
|
|
27
27
|
exports.usePages = usePages;
|
|
28
28
|
const usePage = ({
|
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.useParameters = void 0;
|
|
7
7
|
var _useContextSelector = require("use-context-selector");
|
|
8
8
|
var _ChaynsContext = require("../components/ChaynsContext");
|
|
9
|
-
/**
|
|
10
|
-
* @category Hooks
|
|
9
|
+
/**
|
|
10
|
+
* @category Hooks
|
|
11
11
|
*/
|
|
12
12
|
const useParameters = () => (0, _useContextSelector.useContextSelector)(_ChaynsContext.ChaynsContext, v => (v === null || v === void 0 ? void 0 : v.parameters) || []);
|
|
13
13
|
exports.useParameters = useParameters;
|
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.useSite = void 0;
|
|
7
7
|
var _useContextSelector = require("use-context-selector");
|
|
8
8
|
var _ChaynsContext = require("../components/ChaynsContext");
|
|
9
|
-
/**
|
|
10
|
-
* @category Hooks
|
|
9
|
+
/**
|
|
10
|
+
* @category Hooks
|
|
11
11
|
*/
|
|
12
12
|
const useSite = () => (0, _useContextSelector.useContextSelector)(_ChaynsContext.ChaynsContext, v => v === null || v === void 0 ? void 0 : v.site);
|
|
13
13
|
exports.useSite = useSite;
|
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.useUser = void 0;
|
|
7
7
|
var _useContextSelector = require("use-context-selector");
|
|
8
8
|
var _ChaynsContext = require("../components/ChaynsContext");
|
|
9
|
-
/**
|
|
10
|
-
* @category Hooks
|
|
9
|
+
/**
|
|
10
|
+
* @category Hooks
|
|
11
11
|
*/
|
|
12
12
|
const useUser = () => (0, _useContextSelector.useContextSelector)(_ChaynsContext.ChaynsContext, v => (v === null || v === void 0 ? void 0 : v.user) || {});
|
|
13
13
|
exports.useUser = useUser;
|
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.useValues = void 0;
|
|
7
7
|
var _useContextSelector = require("use-context-selector");
|
|
8
8
|
var _ChaynsContext = require("../components/ChaynsContext");
|
|
9
|
-
/**
|
|
10
|
-
* @category Hooks
|
|
9
|
+
/**
|
|
10
|
+
* @category Hooks
|
|
11
11
|
*/
|
|
12
12
|
const useValues = () => {
|
|
13
13
|
const t = (0, _useContextSelector.useContextSelector)(_ChaynsContext.ChaynsContext, v => v || {});
|
|
@@ -8,8 +8,8 @@ var _useContextSelector = require("use-context-selector");
|
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
var _ChaynsContext = require("../components/ChaynsContext");
|
|
10
10
|
var _IChaynsReact = require("../types/IChaynsReact");
|
|
11
|
-
/**
|
|
12
|
-
* @category Hooks
|
|
11
|
+
/**
|
|
12
|
+
* @category Hooks
|
|
13
13
|
*/
|
|
14
14
|
const useWindowMetricsListener = () => {
|
|
15
15
|
const addListener = (0, _useContextSelector.useContextSelector)(_ChaynsContext.ChaynsFunctionsContext, v => v.addWindowMetricsListener);
|
|
@@ -24,8 +24,8 @@ const useWindowMetricsListener = () => {
|
|
|
24
24
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
25
25
|
}, []);
|
|
26
26
|
};
|
|
27
|
-
/**
|
|
28
|
-
* @category Hooks
|
|
27
|
+
/**
|
|
28
|
+
* @category Hooks
|
|
29
29
|
*/
|
|
30
30
|
exports.useWindowMetricsListener = useWindowMetricsListener;
|
|
31
31
|
const useWindowMetrics = ({
|
|
@@ -28,7 +28,8 @@ const ChaynsHost = ({
|
|
|
28
28
|
parameters,
|
|
29
29
|
customData,
|
|
30
30
|
environment,
|
|
31
|
-
preventStagingReplacement
|
|
31
|
+
preventStagingReplacement,
|
|
32
|
+
dialog
|
|
32
33
|
}) => {
|
|
33
34
|
switch (type) {
|
|
34
35
|
case 'client-iframe':
|
|
@@ -47,7 +48,8 @@ const ChaynsHost = ({
|
|
|
47
48
|
parameters: parameters,
|
|
48
49
|
environment: environment,
|
|
49
50
|
customData: customData,
|
|
50
|
-
preventStagingReplacement: preventStagingReplacement
|
|
51
|
+
preventStagingReplacement: preventStagingReplacement,
|
|
52
|
+
dialog: dialog
|
|
51
53
|
});
|
|
52
54
|
case 'client-module':
|
|
53
55
|
return /*#__PURE__*/_react.default.createElement(_ModuleHost.default, {
|
|
@@ -83,7 +85,8 @@ const ChaynsHost = ({
|
|
|
83
85
|
parameters: parameters,
|
|
84
86
|
environment: environment,
|
|
85
87
|
customData: customData,
|
|
86
|
-
preventStagingReplacement: preventStagingReplacement
|
|
88
|
+
preventStagingReplacement: preventStagingReplacement,
|
|
89
|
+
dialog: dialog
|
|
87
90
|
});
|
|
88
91
|
case 'server-module':
|
|
89
92
|
return /*#__PURE__*/_react.default.createElement(_ModuleHost.default, {
|
|
@@ -30,7 +30,8 @@ const HostIframe = ({
|
|
|
30
30
|
parameters,
|
|
31
31
|
environment,
|
|
32
32
|
customData,
|
|
33
|
-
preventStagingReplacement
|
|
33
|
+
preventStagingReplacement,
|
|
34
|
+
dialog
|
|
34
35
|
}) => {
|
|
35
36
|
const eventTarget = (0, _react.useRef)();
|
|
36
37
|
const ref = (0, _react.useRef)();
|
|
@@ -56,7 +57,8 @@ const HostIframe = ({
|
|
|
56
57
|
language,
|
|
57
58
|
parameters,
|
|
58
59
|
environment,
|
|
59
|
-
customData
|
|
60
|
+
customData,
|
|
61
|
+
dialog
|
|
60
62
|
};
|
|
61
63
|
// endregion
|
|
62
64
|
|
|
@@ -68,7 +70,7 @@ const HostIframe = ({
|
|
|
68
70
|
if (postForm) {
|
|
69
71
|
var _await$functions$getA;
|
|
70
72
|
const accessToken = (_await$functions$getA = await functions.getAccessToken()) !== null && _await$functions$getA !== void 0 ? _await$functions$getA : {};
|
|
71
|
-
void (0, _postIframeForm.default)((0, _url.replaceStagingUrl)(preventStagingReplacement, src, environment.
|
|
73
|
+
void (0, _postIframeForm.default)((0, _url.replaceStagingUrl)(preventStagingReplacement, src, environment.buildEnvironment), JSON.stringify({
|
|
72
74
|
...initialData,
|
|
73
75
|
pages: undefined,
|
|
74
76
|
...accessToken
|
|
@@ -116,6 +118,7 @@ const HostIframe = ({
|
|
|
116
118
|
(0, _useUpdateData.default)(eventTarget.current, 'parameters', parameters);
|
|
117
119
|
(0, _useUpdateData.default)(eventTarget.current, 'environment', environment);
|
|
118
120
|
(0, _useUpdateData.default)(eventTarget.current, 'customData', customData);
|
|
121
|
+
(0, _useUpdateData.default)(eventTarget.current, 'dialog', dialog);
|
|
119
122
|
// endregion
|
|
120
123
|
|
|
121
124
|
return /*#__PURE__*/_react.default.createElement("iframe", _extends({
|
|
@@ -3,7 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.TappEvent = exports.SharingApp = exports.ScreenSize = exports.ScanQrCodeCodeType = exports.ScanQrCodeCameraTypes = exports.RuntimeEnviroment = exports.Language = exports.IconType = exports.Gender = exports.Font = exports.FloatingButtonPosition = exports.Environment = exports.DeviceOs = exports.ColorMode = exports.BrowserName = exports.AppName = exports.AccessMode = void 0;
|
|
6
|
+
exports.TappEvent = exports.SharingApp = exports.ScreenSize = exports.ScanQrCodeCodeType = exports.ScanQrCodeCameraTypes = exports.RuntimeEnviroment = exports.Language = exports.IconType = exports.Gender = exports.Font = exports.FloatingButtonPosition = exports.Environment = exports.DialogType = exports.DialogButtonType = exports.DeviceOs = exports.ColorMode = exports.BrowserName = exports.AppName = exports.AccessMode = void 0;
|
|
7
|
+
let DialogButtonType;
|
|
8
|
+
exports.DialogButtonType = DialogButtonType;
|
|
9
|
+
(function (DialogButtonType) {
|
|
10
|
+
DialogButtonType[DialogButtonType["OK"] = 1] = "OK";
|
|
11
|
+
DialogButtonType[DialogButtonType["CANCEL"] = -1] = "CANCEL";
|
|
12
|
+
DialogButtonType[DialogButtonType["NEGATIVE"] = 0] = "NEGATIVE";
|
|
13
|
+
})(DialogButtonType || (exports.DialogButtonType = DialogButtonType = {}));
|
|
7
14
|
let ScreenSize;
|
|
8
15
|
exports.ScreenSize = ScreenSize;
|
|
9
16
|
(function (ScreenSize) {
|
|
@@ -258,4 +265,17 @@ var selectType;
|
|
|
258
265
|
(function (selectType) {
|
|
259
266
|
selectType[selectType["DEFAULT"] = 0] = "DEFAULT";
|
|
260
267
|
selectType[selectType["ICON"] = 1] = "ICON";
|
|
261
|
-
})(selectType || (selectType = {}));
|
|
268
|
+
})(selectType || (selectType = {}));
|
|
269
|
+
let DialogType;
|
|
270
|
+
exports.DialogType = DialogType;
|
|
271
|
+
(function (DialogType) {
|
|
272
|
+
DialogType["ALERT"] = "alert";
|
|
273
|
+
DialogType["CONFIRM"] = "confirm";
|
|
274
|
+
DialogType["DATE"] = "date";
|
|
275
|
+
DialogType["FILE_SELECT"] = "fileSelect";
|
|
276
|
+
DialogType["IFRAME"] = "iframe";
|
|
277
|
+
DialogType["MODULE"] = "module";
|
|
278
|
+
DialogType["INPUT"] = "input";
|
|
279
|
+
DialogType["SELECT"] = "select";
|
|
280
|
+
DialogType["TOAST"] = "toast";
|
|
281
|
+
})(DialogType || (exports.DialogType = DialogType = {}));
|
|
@@ -35,7 +35,7 @@ const getDeviceInfo = (userAgent, acceptHeader) => {
|
|
|
35
35
|
result.accessToken = undefined; // TODO
|
|
36
36
|
result.os = parsedUA === null || parsedUA === void 0 ? void 0 : parsedUA.os;
|
|
37
37
|
if (typeof window !== 'undefined') {
|
|
38
|
-
result.screenSize = getScreenSize(window.innerWidth);
|
|
38
|
+
result.screenSize = getScreenSize(window.innerWidth, window.innerHeight);
|
|
39
39
|
} else {
|
|
40
40
|
// estimate size over user agent, very inaccurate, could be improved by setting a cookie with the screensize
|
|
41
41
|
const screenSizeByUA = /mobi/i.test(userAgent) ? _IChaynsReact.ScreenSize.SM : _IChaynsReact.ScreenSize.XL;
|
|
@@ -49,15 +49,16 @@ const getClientDeviceInfo = () => ({
|
|
|
49
49
|
isTouch: navigator.maxTouchPoints > 0 && window.matchMedia('(pointer: coarse)')
|
|
50
50
|
});
|
|
51
51
|
exports.getClientDeviceInfo = getClientDeviceInfo;
|
|
52
|
-
const getScreenSize = width => {
|
|
52
|
+
const getScreenSize = (width, height) => {
|
|
53
|
+
const size = Math.max(width, height);
|
|
53
54
|
let value;
|
|
54
|
-
if (
|
|
55
|
+
if (size > 1200) {
|
|
55
56
|
value = _IChaynsReact.ScreenSize.XL;
|
|
56
|
-
} else if (
|
|
57
|
+
} else if (size > 993) {
|
|
57
58
|
value = _IChaynsReact.ScreenSize.LG;
|
|
58
|
-
} else if (
|
|
59
|
+
} else if (size > 769) {
|
|
59
60
|
value = _IChaynsReact.ScreenSize.MD;
|
|
60
|
-
} else if (
|
|
61
|
+
} else if (size > 556) {
|
|
61
62
|
value = _IChaynsReact.ScreenSize.SM;
|
|
62
63
|
} else {
|
|
63
64
|
value = _IChaynsReact.ScreenSize.XS;
|
|
@@ -17,6 +17,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
17
17
|
/* eslint-disable */
|
|
18
18
|
// @ts-nocheck
|
|
19
19
|
|
|
20
|
+
let appWrapperDialogId = 0;
|
|
20
21
|
class AppWrapper {
|
|
21
22
|
values = null;
|
|
22
23
|
accessToken = '';
|
|
@@ -98,6 +99,12 @@ class AppWrapper {
|
|
|
98
99
|
notImplemented(call) {
|
|
99
100
|
console.warn(`call ${call} not implement in app`);
|
|
100
101
|
}
|
|
102
|
+
dispatchDialogChange(detail) {
|
|
103
|
+
this.dialogs = detail;
|
|
104
|
+
this.dialogEventTarget.dispatchEvent(new CustomEvent('change', {
|
|
105
|
+
detail
|
|
106
|
+
}));
|
|
107
|
+
}
|
|
101
108
|
counter = 0;
|
|
102
109
|
appCall(action, value = {}, {
|
|
103
110
|
callback,
|
|
@@ -465,8 +472,51 @@ class AppWrapper {
|
|
|
465
472
|
void this.appCall(19, value, {
|
|
466
473
|
awaitResult: false
|
|
467
474
|
});
|
|
475
|
+
},
|
|
476
|
+
openDialog: async (...args) => {
|
|
477
|
+
return this.openDialog(...args);
|
|
478
|
+
},
|
|
479
|
+
createDialog: config => {
|
|
480
|
+
return {
|
|
481
|
+
close: async value => {
|
|
482
|
+
this.dialogs.find(x => x.dialogId === dialogId).eventTarget.dispatchEvent(new CustomEvent('close', {
|
|
483
|
+
detail: data
|
|
484
|
+
}));
|
|
485
|
+
},
|
|
486
|
+
open: async () => {
|
|
487
|
+
return await this.openDialog(config);
|
|
488
|
+
}
|
|
489
|
+
};
|
|
490
|
+
},
|
|
491
|
+
closeDialog: (dialogId, data) => {
|
|
492
|
+
try {
|
|
493
|
+
this.dialogs.find(x => x.dialogId === dialogId).eventTarget.dispatchEvent(new CustomEvent('requestClose', {
|
|
494
|
+
detail: data
|
|
495
|
+
}));
|
|
496
|
+
} catch (e) {
|
|
497
|
+
console.error(e);
|
|
498
|
+
}
|
|
468
499
|
}
|
|
469
500
|
};
|
|
501
|
+
async openDialog(config) {
|
|
502
|
+
const currentDialogId = appWrapperDialogId;
|
|
503
|
+
const res = await new Promise(resolve => {
|
|
504
|
+
const eventTarget = new EventTarget();
|
|
505
|
+
this.dispatchDialogChange([...(this.dialogs || []), {
|
|
506
|
+
config,
|
|
507
|
+
resolve,
|
|
508
|
+
dialogId: appWrapperDialogId++,
|
|
509
|
+
eventTarget
|
|
510
|
+
}]);
|
|
511
|
+
});
|
|
512
|
+
this.dispatchDialogChange(this.dialogs.filter(x => x.dialogId !== currentDialogId));
|
|
513
|
+
return res;
|
|
514
|
+
}
|
|
515
|
+
dialogs = [];
|
|
516
|
+
dialogEventTarget = new EventTarget();
|
|
517
|
+
getDialogEventTarget() {
|
|
518
|
+
return this.dialogEventTarget;
|
|
519
|
+
}
|
|
470
520
|
async init() {
|
|
471
521
|
this.values = this.mapOldApiToNew(await this.appCall(18));
|
|
472
522
|
return undefined;
|
|
@@ -484,5 +534,14 @@ class AppWrapper {
|
|
|
484
534
|
getInitialData() {
|
|
485
535
|
return this.values;
|
|
486
536
|
}
|
|
537
|
+
createDialog(config) {
|
|
538
|
+
return {
|
|
539
|
+
close: () => {},
|
|
540
|
+
open: async () => {
|
|
541
|
+
const dialog = await functions.openDialog(config);
|
|
542
|
+
return dialog;
|
|
543
|
+
}
|
|
544
|
+
};
|
|
545
|
+
}
|
|
487
546
|
}
|
|
488
547
|
exports.AppWrapper = AppWrapper;
|
|
@@ -233,7 +233,22 @@ class FrameWrapper {
|
|
|
233
233
|
scrollByY: async (value, duration) => {
|
|
234
234
|
if (!this.initialized) await this.ready;
|
|
235
235
|
return this.exposedFunctions.scrollByY(value, duration);
|
|
236
|
-
}
|
|
236
|
+
},
|
|
237
|
+
createDialog: config => {
|
|
238
|
+
return {
|
|
239
|
+
close: async (buttonType, data) => {
|
|
240
|
+
await this.exposedFunctions.closeDialog(buttonType, data);
|
|
241
|
+
},
|
|
242
|
+
open: async () => {
|
|
243
|
+
return await this.exposedFunctions.openDialog(config);
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
},
|
|
247
|
+
closeDialog: async (buttonType, value) => {
|
|
248
|
+
if (!this.initialized) await this.ready;
|
|
249
|
+
return this.exposedFunctions.closeDialog(buttonType, value);
|
|
250
|
+
},
|
|
251
|
+
openDialog: async value => {}
|
|
237
252
|
};
|
|
238
253
|
initialized = false;
|
|
239
254
|
constructor() {
|
|
@@ -24,6 +24,17 @@ class ModuleFederationWrapper {
|
|
|
24
24
|
// eslint-disable-next-line
|
|
25
25
|
this.functions[k] = async (...args) => fn(...args);
|
|
26
26
|
});
|
|
27
|
+
this.functions.createDialog = config => {
|
|
28
|
+
return {
|
|
29
|
+
close: (buttonType, data) => {
|
|
30
|
+
return functions.closeDialog(buttonType, data);
|
|
31
|
+
},
|
|
32
|
+
open: async () => {
|
|
33
|
+
const dialog = await functions.openDialog(config);
|
|
34
|
+
return dialog;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
};
|
|
27
38
|
this.functions.addWindowMetricsListener = async callback => {
|
|
28
39
|
const {
|
|
29
40
|
id,
|
|
@@ -3,32 +3,32 @@ import { isDate, isNumber, isObject } from './utils/is';
|
|
|
3
3
|
import { open } from './open';
|
|
4
4
|
import { getDevice } from "../index";
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* The config object for date dialog
|
|
8
|
-
* @typedef {Object} dateConfig
|
|
9
|
-
* @property {Date} preSelect - The date object which should be preselected.
|
|
10
|
-
* @property {Date} minDate - The min date which you could select.
|
|
11
|
-
* @property {Date} maxDate - The max date which you could select.
|
|
12
|
-
* @property {dateDialogType} dateType - The type of dialog you want to display.
|
|
13
|
-
* @property {number} minuteIntervall - The interval for special minutes, possible are 2, 3, 4, 5, 6, 12, 15, 20, 30. Default is 1.
|
|
14
|
-
* @property {string} message - The message that is displayed above the date dialog, only in apps supported
|
|
15
|
-
* @property {string} title - The title that is displayed above the message, only in apps supported
|
|
6
|
+
/**
|
|
7
|
+
* The config object for date dialog
|
|
8
|
+
* @typedef {Object} dateConfig
|
|
9
|
+
* @property {Date} preSelect - The date object which should be preselected.
|
|
10
|
+
* @property {Date} minDate - The min date which you could select.
|
|
11
|
+
* @property {Date} maxDate - The max date which you could select.
|
|
12
|
+
* @property {dateDialogType} dateType - The type of dialog you want to display.
|
|
13
|
+
* @property {number} minuteIntervall - The interval for special minutes, possible are 2, 3, 4, 5, 6, 12, 15, 20, 30. Default is 1.
|
|
14
|
+
* @property {string} message - The message that is displayed above the date dialog, only in apps supported
|
|
15
|
+
* @property {string} title - The title that is displayed above the message, only in apps supported
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
/**
|
|
19
|
-
* This call will open a date select dialog.
|
|
20
|
-
* <div>Call: 30</div>
|
|
21
|
-
* @param {dateConfig} config - Define the configuration of this call
|
|
22
|
-
* @return {Promise} contains a timestamp as result
|
|
23
|
-
* @example chayns.dialog.date({
|
|
24
|
-
* 'dateType': chayns.dialog.dateType.DATE_TIME,
|
|
25
|
-
* 'preSelect': new Date(2018, 6, 14, 0, 0, 0),
|
|
26
|
-
* 'minDate': new Date(2018, 6, 1, 15, 0, 0),
|
|
27
|
-
* 'maxDate': new Date(2019, 6, 1, 0, 23, 0),
|
|
28
|
-
* 'minuteInterval': 15
|
|
29
|
-
* ).then(function (data) {
|
|
30
|
-
* console.log(data);
|
|
31
|
-
* });
|
|
18
|
+
/**
|
|
19
|
+
* This call will open a date select dialog.
|
|
20
|
+
* <div>Call: 30</div>
|
|
21
|
+
* @param {dateConfig} config - Define the configuration of this call
|
|
22
|
+
* @return {Promise} contains a timestamp as result
|
|
23
|
+
* @example chayns.dialog.date({
|
|
24
|
+
* 'dateType': chayns.dialog.dateType.DATE_TIME,
|
|
25
|
+
* 'preSelect': new Date(2018, 6, 14, 0, 0, 0),
|
|
26
|
+
* 'minDate': new Date(2018, 6, 1, 15, 0, 0),
|
|
27
|
+
* 'maxDate': new Date(2019, 6, 1, 0, 23, 0),
|
|
28
|
+
* 'minuteInterval': 15
|
|
29
|
+
* ).then(function (data) {
|
|
30
|
+
* console.log(data);
|
|
31
|
+
* });
|
|
32
32
|
*/
|
|
33
33
|
|
|
34
34
|
export function date() {
|
|
@@ -165,18 +165,18 @@ export function advancedDate() {
|
|
|
165
165
|
});
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
-
/**
|
|
169
|
-
* @typedef {number} dateDialogType
|
|
168
|
+
/**
|
|
169
|
+
* @typedef {number} dateDialogType
|
|
170
170
|
*/
|
|
171
171
|
|
|
172
|
-
/**
|
|
173
|
-
* Enum for date dialog
|
|
174
|
-
* <div>DATE will open a dialog where you can select a special day</div>
|
|
175
|
-
* <div>TIME will open a dialog where you can only select a special time</div>
|
|
176
|
-
* <div>DATE_TIME will open a dialog where you can select a special time on a special day</div>
|
|
177
|
-
* @readonly
|
|
178
|
-
* @enum {dateDialogType}
|
|
179
|
-
* @type {{DATE: number, TIME: number, DATE_TIME: number}}
|
|
172
|
+
/**
|
|
173
|
+
* Enum for date dialog
|
|
174
|
+
* <div>DATE will open a dialog where you can select a special day</div>
|
|
175
|
+
* <div>TIME will open a dialog where you can only select a special time</div>
|
|
176
|
+
* <div>DATE_TIME will open a dialog where you can select a special time on a special day</div>
|
|
177
|
+
* @readonly
|
|
178
|
+
* @enum {dateDialogType}
|
|
179
|
+
* @type {{DATE: number, TIME: number, DATE_TIME: number}}
|
|
180
180
|
*/
|
|
181
181
|
export const dateType = {
|
|
182
182
|
'DATE': 1,
|