chayns-api 1.0.11 → 1.1.0-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/.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/bootstrap.js +11 -0
- package/dist/cjs/calls/abstractApiListener.js +40 -0
- package/dist/cjs/calls/apiEventListener.js +40 -0
- 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/setVisibilityChangeListener.js +1 -0
- package/dist/cjs/calls/visibilityChangeListener.js +4 -4
- package/dist/cjs/calls/windowMetricsListener.js +18 -0
- package/dist/cjs/client.js +93 -0
- package/dist/cjs/components/App.js +32 -0
- package/dist/cjs/components/App.spec.js +16 -0
- package/dist/cjs/components/AppDialogWrapper.js +42 -0
- package/dist/cjs/components/Button.js +32 -0
- package/dist/cjs/components/ChaynsModuleProvider.js +457 -0
- package/dist/cjs/components/ChaynsProvider.js +5 -2
- package/dist/cjs/components/ChaynsProviderExposed.js +16 -0
- package/dist/cjs/components/Dialog.js +1 -0
- package/dist/cjs/components/TestProvider.js +236 -0
- package/dist/cjs/components/Title.js +162 -0
- package/dist/cjs/components/withCompatMode.js +1 -1
- package/dist/cjs/functions/addApiListener.js +37 -0
- package/dist/cjs/functions/addGeoLocationListener.js +26 -0
- package/dist/cjs/functions/addScrollListener.js +26 -0
- package/dist/cjs/functions/addWindowMetricsListener.js +37 -0
- package/dist/cjs/handler/DialogHandler.js +40 -0
- package/dist/cjs/helper/cssLoader.js +28 -0
- package/dist/cjs/hooks/addGeoLocationListener.js +26 -0
- package/dist/cjs/hooks/addScrollListener.js +26 -0
- package/dist/cjs/hooks/addWindowMetricsListener.js +37 -0
- package/dist/cjs/hooks/geoLocation.js +48 -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/useAddGeoLocationListener.js +26 -0
- package/dist/cjs/hooks/useAddScrollListener.js +48 -0
- package/dist/cjs/hooks/useAddWindowMetricsListener.js +45 -0
- package/dist/cjs/hooks/useAdddScrollListener.js +26 -0
- 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 +35 -0
- package/dist/cjs/hooks/useEnvironment.js +2 -2
- package/dist/cjs/hooks/useFunction.js +13 -0
- 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/windowMetrics.js +45 -0
- package/dist/cjs/hooks/windowMetricsListener.js +4 -4
- package/dist/cjs/host/ChaynsHost.js +10 -5
- package/dist/cjs/host/HostIframe.js +157 -0
- package/dist/cjs/host/ModuleHost.js +11 -0
- package/dist/cjs/host/iframe/HostIframe.js +5 -2
- package/dist/cjs/host/module/ModuleHost.js +4 -0
- package/dist/cjs/host/module/utils.js +25 -0
- package/dist/cjs/index.example.js +7 -0
- package/dist/cjs/index2.js +64 -0
- package/dist/cjs/types/DynamicApiImport.d.js +5 -0
- package/dist/cjs/types/DynamicImport.d.js +5 -0
- package/dist/cjs/types/IChaynsReact.js +22 -2
- package/dist/cjs/types/chayns-components.d.js +1 -0
- package/dist/cjs/types/chayns-logger.d.js +1 -0
- package/dist/cjs/types/chayns.d.js +1 -0
- package/dist/cjs/types/tobit-websocket-service-client.d.js +1 -0
- package/dist/cjs/types/toolkit-types.d.js +1 -0
- package/dist/cjs/util/deviceHelper.js +7 -6
- package/dist/cjs/util/useFunctionsContext.js +16 -0
- package/dist/cjs/util/useIsAdminMode.js +18 -0
- package/dist/cjs/util/useUser.js +16 -0
- package/dist/cjs/wrapper/AppWrapper.js +39 -0
- package/dist/cjs/wrapper/Dialog.js +35 -0
- package/dist/cjs/wrapper/DialogHandler.js +35 -0
- package/dist/cjs/wrapper/FrameWrapper.js +17 -0
- package/dist/cjs/wrapper/ModuleFederationWrapper.js +4 -0
- package/dist/esm/bootstrap.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/client.js +8 -0
- package/dist/esm/components/App.js +35 -0
- package/dist/esm/components/App.spec.js +9 -0
- package/dist/esm/components/AppDialogWrapper.js +33 -0
- package/dist/esm/components/Button.js +34 -0
- package/dist/esm/components/ChaynsModuleProvider.js +517 -0
- package/dist/esm/components/ChaynsProvider.js +5 -2
- package/dist/esm/components/ChaynsProviderExposed.js +3 -0
- package/dist/esm/components/Dialog.js +0 -0
- package/dist/esm/components/TestProvider.js +308 -0
- package/dist/esm/components/Title.js +210 -0
- package/dist/esm/components/withCompatMode.js +1 -1
- package/dist/esm/handler/DialogHandler.js +36 -0
- package/dist/esm/helper/cssLoader.js +21 -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/useAddGeoLocationListener.js +18 -0
- package/dist/esm/hooks/useAddScrollListener.js +18 -0
- package/dist/esm/hooks/useAddWindowMetricsListener.js +18 -0
- 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 +28 -0
- package/dist/esm/hooks/useEnvironment.js +2 -2
- package/dist/esm/hooks/useFunction.js +6 -0
- 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/HostIframe.js +153 -0
- package/dist/esm/host/iframe/HostIframe.js +5 -2
- package/dist/esm/host/module/ModuleHost.js +4 -0
- package/dist/esm/index.example.js +1 -0
- package/dist/esm/index2.js +5 -0
- package/dist/esm/types/DynamicApiImport.d.js +1 -0
- package/dist/esm/types/DynamicImport.d.js +1 -0
- package/dist/esm/types/IChaynsReact.js +19 -1
- package/dist/esm/types/chayns-components.d.js +0 -0
- package/dist/esm/types/chayns-logger.d.js +0 -0
- package/dist/esm/types/chayns.d.js +0 -0
- package/dist/esm/types/tobit-websocket-service-client.d.js +0 -0
- package/dist/esm/types/toolkit-types.d.js +0 -0
- package/dist/esm/util/deviceHelper.js +7 -6
- package/dist/esm/util/useIsAdminMode.js +9 -0
- package/dist/esm/util/useUser.js +7 -0
- package/dist/esm/wrapper/AppWrapper.js +39 -0
- package/dist/esm/wrapper/Dialog.js +31 -0
- package/dist/esm/wrapper/DialogHandler.js +31 -0
- package/dist/esm/wrapper/FrameWrapper.js +17 -0
- package/dist/esm/wrapper/ModuleFederationWrapper.js +4 -0
- package/dist/types/bootstrap.d.ts +1 -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/client.d.ts +7 -0
- package/dist/types/components/App.d.ts +5 -0
- package/dist/types/components/AppDialogWrapper.d.ts +5 -0
- package/dist/types/components/Button.d.ts +8 -0
- package/dist/types/components/ChaynsContext.d.ts +3 -3
- package/dist/types/components/ChaynsModuleProvider.d.ts +170 -0
- package/dist/types/components/ChaynsProvider.d.ts +14 -14
- package/dist/types/components/ChaynsProviderExposed.d.ts +13 -0
- package/dist/types/components/Dialog.d.ts +0 -0
- package/dist/types/components/Title.d.ts +3 -0
- package/dist/types/components/WaitUntil.d.ts +8 -8
- package/dist/types/components/withCompatMode.d.ts +13 -13
- package/dist/types/handler/DialogHandler.d.ts +12 -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/useFunction.d.ts +2 -0
- 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/HostIframe.d.ts +20 -0
- 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/index.example.d.ts +0 -0
- package/dist/types/types/IChaynsReact.d.ts +702 -623
- 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/Dialog.d.ts +10 -0
- package/dist/types/wrapper/DialogHandler.d.ts +10 -0
- 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,18 @@
|
|
|
1
|
+
import { useContextSelector } from 'use-context-selector';
|
|
2
|
+
import { ChaynsFunctionsContext } from '../components/ChaynsContext';
|
|
3
|
+
import { useCallback } from 'react';
|
|
4
|
+
export var useAddGeoLocationListener = function useAddGeoLocationListener() {
|
|
5
|
+
var addGeoLocationListener = useContextSelector(ChaynsFunctionsContext, function (v) {
|
|
6
|
+
return v === null || v === void 0 ? void 0 : v.addGeoLocationListener;
|
|
7
|
+
});
|
|
8
|
+
var removeGeoLocationListener = useContextSelector(ChaynsFunctionsContext, function (v) {
|
|
9
|
+
return v === null || v === void 0 ? void 0 : v.removeGeoLocationListener;
|
|
10
|
+
});
|
|
11
|
+
var promise;
|
|
12
|
+
return useCallback(function (value, callback) {
|
|
13
|
+
promise = addGeoLocationListener(value, callback);
|
|
14
|
+
return function () {
|
|
15
|
+
promise.then(removeGeoLocationListener);
|
|
16
|
+
};
|
|
17
|
+
}, []);
|
|
18
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useContextSelector } from 'use-context-selector';
|
|
2
|
+
import { ChaynsFunctionsContext } from '../components/ChaynsContext';
|
|
3
|
+
import { useCallback } from 'react';
|
|
4
|
+
export var useAddScrollListener = function useAddScrollListener() {
|
|
5
|
+
var addScrollListener = useContextSelector(ChaynsFunctionsContext, function (v) {
|
|
6
|
+
return v === null || v === void 0 ? void 0 : v.addScrollListener;
|
|
7
|
+
});
|
|
8
|
+
var removeScrollListener = useContextSelector(ChaynsFunctionsContext, function (v) {
|
|
9
|
+
return v === null || v === void 0 ? void 0 : v.removeScrollListener;
|
|
10
|
+
});
|
|
11
|
+
var promise;
|
|
12
|
+
return useCallback(function (value, callback) {
|
|
13
|
+
promise = addScrollListener(value, callback);
|
|
14
|
+
return function () {
|
|
15
|
+
promise.then(removeScrollListener);
|
|
16
|
+
};
|
|
17
|
+
}, []);
|
|
18
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useContextSelector } from 'use-context-selector';
|
|
2
|
+
import { ChaynsFunctionsContext } from '../components/ChaynsContext';
|
|
3
|
+
import { useCallback } from 'react';
|
|
4
|
+
export var useAddWindowMetricsListener = function useAddWindowMetricsListener() {
|
|
5
|
+
var addListener = useContextSelector(ChaynsFunctionsContext, function (v) {
|
|
6
|
+
return v === null || v === void 0 ? void 0 : v.addWindowMetricsListener;
|
|
7
|
+
});
|
|
8
|
+
var removeListener = useContextSelector(ChaynsFunctionsContext, function (v) {
|
|
9
|
+
return v === null || v === void 0 ? void 0 : v.removeWindowMetricsListener;
|
|
10
|
+
});
|
|
11
|
+
var promise;
|
|
12
|
+
return useCallback(function (callback) {
|
|
13
|
+
promise = addListener(callback);
|
|
14
|
+
return function () {
|
|
15
|
+
promise.then(removeListener);
|
|
16
|
+
};
|
|
17
|
+
}, []);
|
|
18
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useContextSelector } from 'use-context-selector';
|
|
2
2
|
import { ChaynsContext } from '../components/ChaynsContext';
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* @category Hooks
|
|
4
|
+
/**
|
|
5
|
+
* @category Hooks
|
|
6
6
|
*/
|
|
7
7
|
export const useCurrentPage = () => useContextSelector(ChaynsContext, v => v === null || v === void 0 ? void 0 : v.currentPage);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useContextSelector } from 'use-context-selector';
|
|
2
2
|
import { ChaynsContext } from '../components/ChaynsContext';
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* @category Hooks
|
|
4
|
+
/**
|
|
5
|
+
* @category Hooks
|
|
6
6
|
*/
|
|
7
7
|
export const useCustomData = () => useContextSelector(ChaynsContext, v => v === null || v === void 0 ? void 0 : v.customData);
|
|
@@ -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 useDevice = () => useContextSelector(ChaynsContext, v => v === null || v === void 0 ? void 0 : v.device);
|
|
@@ -0,0 +1,28 @@
|
|
|
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 closeDialog = useContextSelector(ChaynsFunctionsContext, v => v === null || v === void 0 ? void 0 : v.closeDialog);
|
|
9
|
+
const isClosingRequested = useContextSelector(ChaynsContext, v => {
|
|
10
|
+
var _v$dialog;
|
|
11
|
+
return v === null || v === void 0 ? void 0 : (_v$dialog = v.dialog) === null || _v$dialog === void 0 ? void 0 : _v$dialog.isClosingRequested;
|
|
12
|
+
});
|
|
13
|
+
return {
|
|
14
|
+
closeDialog,
|
|
15
|
+
isClosingRequested
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @category Hooks
|
|
21
|
+
*/
|
|
22
|
+
export const useDialogData = () => {
|
|
23
|
+
const inputData = useContextSelector(ChaynsContext, v => {
|
|
24
|
+
var _v$dialog2;
|
|
25
|
+
return v === null || v === void 0 ? void 0 : (_v$dialog2 = v.dialog) === null || _v$dialog2 === void 0 ? void 0 : _v$dialog2.dialogInput;
|
|
26
|
+
});
|
|
27
|
+
return inputData;
|
|
28
|
+
};
|
|
@@ -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;
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
|
|
3
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
+
|
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
6
|
+
|
|
7
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
|
+
|
|
9
|
+
import React, { useEffect, useRef } from 'react';
|
|
10
|
+
import * as comlink from 'comlink';
|
|
11
|
+
import postIframeForm from '../util/postIframeForm';
|
|
12
|
+
|
|
13
|
+
var HostIframe = function HostIframe(_ref) {
|
|
14
|
+
var iFrameProps = _ref.iFrameProps,
|
|
15
|
+
src = _ref.src,
|
|
16
|
+
_ref$postForm = _ref.postForm,
|
|
17
|
+
postForm = _ref$postForm === void 0 ? false : _ref$postForm,
|
|
18
|
+
iFrameRef = _ref.iFrameRef,
|
|
19
|
+
pages = _ref.pages,
|
|
20
|
+
isAdminModeActive = _ref.isAdminModeActive,
|
|
21
|
+
site = _ref.site,
|
|
22
|
+
user = _ref.user,
|
|
23
|
+
currentPage = _ref.currentPage,
|
|
24
|
+
functions = _ref.functions,
|
|
25
|
+
device = _ref.device;
|
|
26
|
+
var eventTarget = useRef();
|
|
27
|
+
|
|
28
|
+
var _ref2 = useRef();
|
|
29
|
+
|
|
30
|
+
var currentDataRef = useRef();
|
|
31
|
+
|
|
32
|
+
if (!eventTarget.current) {
|
|
33
|
+
eventTarget.current = global.EventTarget ? new EventTarget() : undefined;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
var setHeight = function setHeight(value) {
|
|
37
|
+
if (_ref2.current) {
|
|
38
|
+
_ref2.current.height = "".concat(value, "px");
|
|
39
|
+
}
|
|
40
|
+
}; // region initialData
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
var initialData = {
|
|
44
|
+
site: site,
|
|
45
|
+
isAdminModeActive: isAdminModeActive,
|
|
46
|
+
pages: pages,
|
|
47
|
+
currentPage: currentPage,
|
|
48
|
+
device: device,
|
|
49
|
+
user: user
|
|
50
|
+
}; // endregion
|
|
51
|
+
|
|
52
|
+
currentDataRef.current = initialData; // region postIframeForm
|
|
53
|
+
|
|
54
|
+
useEffect(function () {
|
|
55
|
+
if (postForm) {
|
|
56
|
+
void postIframeForm(src, JSON.stringify(_objectSpread(_objectSpread({}, initialData), {}, {
|
|
57
|
+
pages: undefined
|
|
58
|
+
})), 'chayns', iFrameProps.name);
|
|
59
|
+
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
60
|
+
|
|
61
|
+
}, []); // endregion
|
|
62
|
+
|
|
63
|
+
console.debug('functions', functions); // region expose data and functions to iframe
|
|
64
|
+
|
|
65
|
+
useEffect(function () {
|
|
66
|
+
var _ref$current;
|
|
67
|
+
|
|
68
|
+
if ((_ref$current = _ref2.current) !== null && _ref$current !== void 0 && _ref$current.contentWindow) {
|
|
69
|
+
var obj = _defineProperty({}, iFrameProps.name, {
|
|
70
|
+
functions: _objectSpread(_objectSpread({}, functions), {}, {
|
|
71
|
+
setHeight: setHeight
|
|
72
|
+
}),
|
|
73
|
+
addDataListener: function addDataListener(cb) {
|
|
74
|
+
if (eventTarget.current) eventTarget.current.addEventListener('data_update', function (e) {
|
|
75
|
+
return e.detail && cb(e.detail);
|
|
76
|
+
});
|
|
77
|
+
},
|
|
78
|
+
getInitialData: function getInitialData() {
|
|
79
|
+
return currentDataRef.current;
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
comlink.expose(obj, comlink.windowEndpoint(_ref2.current.contentWindow));
|
|
84
|
+
|
|
85
|
+
_ref2.current.contentWindow.postMessage('chayns-api-host-ready', '*'); // https://github.com/GoogleChromeLabs/comlink/pull/469 might be better approach once released
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
return function () {
|
|
89
|
+
delete obj[iFrameProps.name];
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return undefined; // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
94
|
+
}, []); // endregion
|
|
95
|
+
// region dispatch data update
|
|
96
|
+
|
|
97
|
+
useEffect(function () {
|
|
98
|
+
if (eventTarget.current) {
|
|
99
|
+
eventTarget.current.dispatchEvent(new CustomEvent('data_update', {
|
|
100
|
+
detail: {
|
|
101
|
+
type: 'isAdminModeActive',
|
|
102
|
+
value: isAdminModeActive
|
|
103
|
+
}
|
|
104
|
+
}));
|
|
105
|
+
}
|
|
106
|
+
}, [isAdminModeActive]);
|
|
107
|
+
useEffect(function () {
|
|
108
|
+
if (eventTarget.current) {
|
|
109
|
+
eventTarget.current.dispatchEvent(new CustomEvent('data_update', {
|
|
110
|
+
detail: {
|
|
111
|
+
type: 'user',
|
|
112
|
+
value: user
|
|
113
|
+
}
|
|
114
|
+
}));
|
|
115
|
+
}
|
|
116
|
+
}, [user]);
|
|
117
|
+
useEffect(function () {
|
|
118
|
+
if (eventTarget.current) {
|
|
119
|
+
eventTarget.current.dispatchEvent(new CustomEvent('data_update', {
|
|
120
|
+
detail: {
|
|
121
|
+
type: 'site',
|
|
122
|
+
value: site
|
|
123
|
+
}
|
|
124
|
+
}));
|
|
125
|
+
}
|
|
126
|
+
}, [site]);
|
|
127
|
+
useEffect(function () {
|
|
128
|
+
if (eventTarget.current) {
|
|
129
|
+
eventTarget.current.dispatchEvent(new CustomEvent('data_update', {
|
|
130
|
+
detail: {
|
|
131
|
+
type: 'pages',
|
|
132
|
+
value: pages
|
|
133
|
+
}
|
|
134
|
+
}));
|
|
135
|
+
}
|
|
136
|
+
}, [pages]); // endregion
|
|
137
|
+
|
|
138
|
+
return /*#__PURE__*/React.createElement("iframe", _extends({
|
|
139
|
+
ref: function ref(r) {
|
|
140
|
+
_ref2.current = r;
|
|
141
|
+
|
|
142
|
+
if (iFrameRef) {
|
|
143
|
+
// eslint-disable-next-line no-param-reassign
|
|
144
|
+
iFrameRef.current = r;
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
title: " "
|
|
148
|
+
}, iFrameProps, {
|
|
149
|
+
src: postForm ? undefined : src
|
|
150
|
+
}));
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
export default HostIframe;
|
|
@@ -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", {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import('./bootstrap');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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 = {}));
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -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;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { useContextSelector } from 'use-context-selector';
|
|
2
|
+
import { ChaynsContext } from '../components/ChaynsContext';
|
|
3
|
+
export var useIsAdminMode = function useIsAdminMode() {
|
|
4
|
+
var _useContextSelector;
|
|
5
|
+
|
|
6
|
+
return (_useContextSelector = useContextSelector(ChaynsContext, function (v) {
|
|
7
|
+
return v === null || v === void 0 ? void 0 : v.isAdminModeActive;
|
|
8
|
+
})) !== null && _useContextSelector !== void 0 ? _useContextSelector : false;
|
|
9
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { useContextSelector } from 'use-context-selector';
|
|
2
|
+
import { ChaynsContext } from '../components/ChaynsContext';
|
|
3
|
+
export var useUser = function useUser() {
|
|
4
|
+
return useContextSelector(ChaynsContext, function (v) {
|
|
5
|
+
return v === null || v === void 0 ? void 0 : v.user;
|
|
6
|
+
});
|
|
7
|
+
};
|