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.
Files changed (139) hide show
  1. package/.babelrc +30 -30
  2. package/.eslintrc +17 -17
  3. package/.github/workflows/deploy_docs.yml +28 -28
  4. package/.github/workflows/publish.yml +21 -21
  5. package/LICENSE +21 -21
  6. package/README.md +54 -54
  7. package/dist/cjs/calls/dialogs/date.js +10 -10
  8. package/dist/cjs/calls/index.js +102 -97
  9. package/dist/cjs/calls/sendMessage.js +8 -8
  10. package/dist/cjs/calls/visibilityChangeListener.js +4 -4
  11. package/dist/cjs/components/AppDialogWrapper.js +42 -0
  12. package/dist/cjs/components/ChaynsProvider.js +5 -2
  13. package/dist/cjs/handler/DialogHandler.js +63 -0
  14. package/dist/cjs/hooks/geoLocationListener.js +4 -4
  15. package/dist/cjs/hooks/index.js +14 -1
  16. package/dist/cjs/hooks/scrollListener.js +8 -8
  17. package/dist/cjs/hooks/useAccessToken.js +2 -2
  18. package/dist/cjs/hooks/useCurrentPage.js +2 -2
  19. package/dist/cjs/hooks/useCustomData.js +2 -2
  20. package/dist/cjs/hooks/useDevice.js +2 -2
  21. package/dist/cjs/hooks/useDialogState.js +39 -0
  22. package/dist/cjs/hooks/useEnvironment.js +2 -2
  23. package/dist/cjs/hooks/useFunctions.js +2 -2
  24. package/dist/cjs/hooks/useIsAdminMode.js +2 -2
  25. package/dist/cjs/hooks/useLanguage.js +2 -2
  26. package/dist/cjs/hooks/usePages.js +4 -4
  27. package/dist/cjs/hooks/useParameters.js +2 -2
  28. package/dist/cjs/hooks/useSite.js +2 -2
  29. package/dist/cjs/hooks/useUser.js +2 -2
  30. package/dist/cjs/hooks/useValues.js +2 -2
  31. package/dist/cjs/hooks/windowMetricsListener.js +4 -4
  32. package/dist/cjs/host/ChaynsHost.js +10 -5
  33. package/dist/cjs/host/iframe/HostIframe.js +5 -2
  34. package/dist/cjs/host/module/ModuleHost.js +4 -0
  35. package/dist/cjs/types/IChaynsReact.js +22 -2
  36. package/dist/cjs/util/deviceHelper.js +7 -6
  37. package/dist/cjs/wrapper/AppWrapper.js +42 -6
  38. package/dist/cjs/wrapper/FrameWrapper.js +52 -1
  39. package/dist/cjs/wrapper/ModuleFederationWrapper.js +4 -0
  40. package/dist/esm/calls/dialogs/date.js +34 -34
  41. package/dist/esm/calls/index.js +102 -96
  42. package/dist/esm/calls/sendMessage.js +8 -8
  43. package/dist/esm/calls/visibilityChangeListener.js +4 -4
  44. package/dist/esm/components/AppDialogWrapper.js +33 -0
  45. package/dist/esm/components/ChaynsProvider.js +5 -2
  46. package/dist/esm/handler/DialogHandler.js +59 -0
  47. package/dist/esm/hooks/geoLocationListener.js +4 -4
  48. package/dist/esm/hooks/index.js +2 -1
  49. package/dist/esm/hooks/scrollListener.js +8 -8
  50. package/dist/esm/hooks/useAccessToken.js +2 -2
  51. package/dist/esm/hooks/useCurrentPage.js +2 -2
  52. package/dist/esm/hooks/useCustomData.js +2 -2
  53. package/dist/esm/hooks/useDevice.js +2 -2
  54. package/dist/esm/hooks/useDialogState.js +32 -0
  55. package/dist/esm/hooks/useEnvironment.js +2 -2
  56. package/dist/esm/hooks/useFunctions.js +2 -2
  57. package/dist/esm/hooks/useIsAdminMode.js +2 -2
  58. package/dist/esm/hooks/useLanguage.js +2 -2
  59. package/dist/esm/hooks/usePages.js +4 -4
  60. package/dist/esm/hooks/useParameters.js +2 -2
  61. package/dist/esm/hooks/useSite.js +2 -2
  62. package/dist/esm/hooks/useUser.js +2 -2
  63. package/dist/esm/hooks/useValues.js +2 -2
  64. package/dist/esm/hooks/windowMetricsListener.js +4 -4
  65. package/dist/esm/host/ChaynsHost.js +10 -5
  66. package/dist/esm/host/iframe/HostIframe.js +5 -2
  67. package/dist/esm/host/module/ModuleHost.js +4 -0
  68. package/dist/esm/types/IChaynsReact.js +19 -1
  69. package/dist/esm/util/deviceHelper.js +7 -6
  70. package/dist/esm/wrapper/AppWrapper.js +42 -6
  71. package/dist/esm/wrapper/FrameWrapper.js +52 -1
  72. package/dist/esm/wrapper/ModuleFederationWrapper.js +4 -0
  73. package/dist/types/calls/dialogs/alert.d.ts +1 -1
  74. package/dist/types/calls/dialogs/chaynsDialog.d.ts +24 -24
  75. package/dist/types/calls/dialogs/close.d.ts +1 -1
  76. package/dist/types/calls/dialogs/communication.d.ts +3 -3
  77. package/dist/types/calls/dialogs/confirm.d.ts +13 -13
  78. package/dist/types/calls/dialogs/date.d.ts +96 -96
  79. package/dist/types/calls/dialogs/dropUpAlert.d.ts +5 -5
  80. package/dist/types/calls/dialogs/fileSelect.d.ts +16 -16
  81. package/dist/types/calls/dialogs/iFrame.d.ts +10 -10
  82. package/dist/types/calls/dialogs/index.d.ts +14 -14
  83. package/dist/types/calls/dialogs/input.d.ts +15 -15
  84. package/dist/types/calls/dialogs/mediaSelect.d.ts +8 -8
  85. package/dist/types/calls/dialogs/open.d.ts +1 -1
  86. package/dist/types/calls/dialogs/select.d.ts +6 -6
  87. package/dist/types/calls/dialogs/signature.d.ts +7 -7
  88. package/dist/types/calls/dialogs/toast.d.ts +1 -1
  89. package/dist/types/calls/dialogs/utils/callback.d.ts +1 -1
  90. package/dist/types/calls/dialogs/utils/is.d.ts +4 -4
  91. package/dist/types/calls/getUserInfo.d.ts +9 -9
  92. package/dist/types/calls/index.d.ts +237 -233
  93. package/dist/types/calls/sendMessage.d.ts +13 -13
  94. package/dist/types/calls/visibilityChangeListener.d.ts +9 -9
  95. package/dist/types/components/AppDialogWrapper.d.ts +5 -0
  96. package/dist/types/components/ChaynsContext.d.ts +3 -3
  97. package/dist/types/components/ChaynsProvider.d.ts +14 -14
  98. package/dist/types/components/WaitUntil.d.ts +7 -8
  99. package/dist/types/components/withCompatMode.d.ts +13 -13
  100. package/dist/types/handler/DialogHandler.d.ts +19 -0
  101. package/dist/types/helper/apiListenerHelper.d.ts +6 -6
  102. package/dist/types/hooks/geoLocationListener.d.ts +18 -18
  103. package/dist/types/hooks/index.d.ts +17 -16
  104. package/dist/types/hooks/scrollListener.d.ts +28 -28
  105. package/dist/types/hooks/useAccessToken.d.ts +5 -5
  106. package/dist/types/hooks/useCurrentPage.d.ts +4 -4
  107. package/dist/types/hooks/useCustomData.d.ts +4 -4
  108. package/dist/types/hooks/useDevice.d.ts +5 -5
  109. package/dist/types/hooks/useDialogState.d.ts +9 -0
  110. package/dist/types/hooks/useEnvironment.d.ts +5 -5
  111. package/dist/types/hooks/useFunctions.d.ts +5 -5
  112. package/dist/types/hooks/useIsAdminMode.d.ts +4 -4
  113. package/dist/types/hooks/useLanguage.d.ts +5 -5
  114. package/dist/types/hooks/usePages.d.ts +18 -18
  115. package/dist/types/hooks/useParameters.d.ts +5 -5
  116. package/dist/types/hooks/useSite.d.ts +5 -5
  117. package/dist/types/hooks/useUser.d.ts +5 -5
  118. package/dist/types/hooks/useValues.d.ts +5 -5
  119. package/dist/types/hooks/windowMetricsListener.d.ts +11 -11
  120. package/dist/types/host/ChaynsHost.d.ts +30 -29
  121. package/dist/types/host/iframe/HostIframe.d.ts +26 -25
  122. package/dist/types/host/iframe/utils/useUpdateData.d.ts +3 -3
  123. package/dist/types/host/module/ModuleHost.d.ts +26 -25
  124. package/dist/types/host/module/utils/loadComponent.d.ts +1 -1
  125. package/dist/types/host/module/utils/useDynamicScript.d.ts +9 -9
  126. package/dist/types/index.d.ts +16 -16
  127. package/dist/types/types/IChaynsReact.d.ts +708 -624
  128. package/dist/types/types/dialog.d.ts +41 -41
  129. package/dist/types/util/appCall.d.ts +2 -2
  130. package/dist/types/util/deviceHelper.d.ts +7 -7
  131. package/dist/types/util/heightHelper.d.ts +1 -1
  132. package/dist/types/util/postIframeForm.d.ts +1 -1
  133. package/dist/types/util/url.d.ts +1 -1
  134. package/dist/types/wrapper/AppWrapper.d.ts +22 -18
  135. package/dist/types/wrapper/FrameWrapper.d.ts +15 -15
  136. package/dist/types/wrapper/ModuleFederationWrapper.d.ts +10 -10
  137. package/dist/types/wrapper/SsrWrapper.d.ts +11 -11
  138. package/package.json +75 -75
  139. package/tsconfig.json +56 -56
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.useCustomData = 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 useCustomData = () => (0, _useContextSelector.useContextSelector)(_ChaynsContext.ChaynsContext, v => v === null || v === void 0 ? void 0 : v.customData);
13
13
  exports.useCustomData = useCustomData;
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.useDevice = 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 useDevice = () => (0, _useContextSelector.useContextSelector)(_ChaynsContext.ChaynsContext, v => v === null || v === void 0 ? void 0 : v.device);
13
13
  exports.useDevice = useDevice;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useDialogState = exports.useDialogData = void 0;
7
+ var _useContextSelector = require("use-context-selector");
8
+ var _ChaynsContext = require("../components/ChaynsContext");
9
+ /**
10
+ * @category Hooks
11
+ */
12
+ const useDialogState = () => {
13
+ const setResult = (0, _useContextSelector.useContextSelector)(_ChaynsContext.ChaynsFunctionsContext, v => v === null || v === void 0 ? void 0 : v.setDialogResult);
14
+ const sendData = (0, _useContextSelector.useContextSelector)(_ChaynsContext.ChaynsFunctionsContext, v => v === null || v === void 0 ? void 0 : v.dispatchEventToDialogHost);
15
+ const addDataListener = (0, _useContextSelector.useContextSelector)(_ChaynsContext.ChaynsFunctionsContext, v => v === null || v === void 0 ? void 0 : v.addDialogHostEventListener);
16
+ const isClosingRequested = (0, _useContextSelector.useContextSelector)(_ChaynsContext.ChaynsContext, v => {
17
+ var _v$dialog;
18
+ return v === null || v === void 0 ? void 0 : (_v$dialog = v.dialog) === null || _v$dialog === void 0 ? void 0 : _v$dialog.isClosingRequested;
19
+ });
20
+ return {
21
+ setResult,
22
+ sendData,
23
+ addDataListener,
24
+ isClosingRequested
25
+ };
26
+ };
27
+
28
+ /**
29
+ * @category Hooks
30
+ */
31
+ exports.useDialogState = useDialogState;
32
+ const useDialogData = () => {
33
+ const inputData = (0, _useContextSelector.useContextSelector)(_ChaynsContext.ChaynsContext, v => {
34
+ var _v$dialog2;
35
+ return v === null || v === void 0 ? void 0 : (_v$dialog2 = v.dialog) === null || _v$dialog2 === void 0 ? void 0 : _v$dialog2.dialogInput;
36
+ });
37
+ return inputData;
38
+ };
39
+ exports.useDialogData = useDialogData;
@@ -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, {
@@ -64,7 +66,8 @@ const ChaynsHost = ({
64
66
  parameters: parameters,
65
67
  customData: customData,
66
68
  environment: environment,
67
- preventStagingReplacement: preventStagingReplacement
69
+ preventStagingReplacement: preventStagingReplacement,
70
+ dialog: dialog
68
71
  });
69
72
  case 'server-iframe':
70
73
  return /*#__PURE__*/_react.default.createElement(_HostIframe.default, {
@@ -83,7 +86,8 @@ const ChaynsHost = ({
83
86
  parameters: parameters,
84
87
  environment: environment,
85
88
  customData: customData,
86
- preventStagingReplacement: preventStagingReplacement
89
+ preventStagingReplacement: preventStagingReplacement,
90
+ dialog: dialog
87
91
  });
88
92
  case 'server-module':
89
93
  return /*#__PURE__*/_react.default.createElement(_ModuleHost.default, {
@@ -99,7 +103,8 @@ const ChaynsHost = ({
99
103
  parameters: parameters,
100
104
  customData: customData,
101
105
  environment: environment,
102
- preventStagingReplacement: preventStagingReplacement
106
+ preventStagingReplacement: preventStagingReplacement,
107
+ dialog: dialog
103
108
  }, children);
104
109
  default:
105
110
  return null;
@@ -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
 
@@ -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({
@@ -50,6 +50,7 @@ const ModuleHost = ({
50
50
  language,
51
51
  parameters,
52
52
  customData,
53
+ dialog,
53
54
  environment,
54
55
  preventStagingReplacement
55
56
  }) => {
@@ -68,6 +69,9 @@ const ModuleHost = ({
68
69
  if (user) {
69
70
  initialData.user = user;
70
71
  }
72
+ if (dialog) {
73
+ initialData.dialog = dialog;
74
+ }
71
75
  // endregion
72
76
 
73
77
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
@@ -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 (width > 1200) {
55
+ if (size > 1200) {
55
56
  value = _IChaynsReact.ScreenSize.XL;
56
- } else if (width > 993) {
57
+ } else if (size > 993) {
57
58
  value = _IChaynsReact.ScreenSize.LG;
58
- } else if (width > 769) {
59
+ } else if (size > 769) {
59
60
  value = _IChaynsReact.ScreenSize.MD;
60
- } else if (width > 556) {
61
+ } else if (size > 556) {
61
62
  value = _IChaynsReact.ScreenSize.SM;
62
63
  } else {
63
64
  value = _IChaynsReact.ScreenSize.XS;
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.AppWrapper = void 0;
7
7
  var _lodash = _interopRequireDefault(require("lodash.throttle"));
8
+ var _DialogHandler = _interopRequireDefault(require("../handler/DialogHandler"));
8
9
  var _IChaynsReact = require("../types/IChaynsReact");
9
10
  var _appCall = _interopRequireDefault(require("../util/appCall"));
10
11
  var _deviceHelper = _interopRequireWildcard(require("../util/deviceHelper"));
@@ -17,6 +18,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
17
18
  /* eslint-disable */
18
19
  // @ts-nocheck
19
20
 
21
+ let appWrapperDialogId = 0;
20
22
  class AppWrapper {
21
23
  values = null;
22
24
  accessToken = '';
@@ -98,6 +100,12 @@ class AppWrapper {
98
100
  notImplemented(call) {
99
101
  console.warn(`call ${call} not implement in app`);
100
102
  }
103
+ dispatchDialogChange(detail) {
104
+ this.dialogs = detail;
105
+ this.dialogEventTarget.dispatchEvent(new CustomEvent('change', {
106
+ detail
107
+ }));
108
+ }
101
109
  counter = 0;
102
110
  appCall(action, value = {}, {
103
111
  callback,
@@ -143,13 +151,12 @@ class AppWrapper {
143
151
  permanent: true
144
152
  }, {
145
153
  callback: v => {
146
- var _v$accuracy, _v$isAccurate, _v$code;
154
+ var _v$accuracy, _v$code;
147
155
  (0, _apiListenerHelper.dispatchApiEvent)('geoLocationListener', {
148
156
  latitude: v.latitude,
149
157
  longitude: v.longitude,
150
158
  accuracy: (_v$accuracy = v.accuracy) !== null && _v$accuracy !== void 0 ? _v$accuracy : null,
151
159
  speed: v.speed,
152
- isAccurate: (_v$isAccurate = v.isAccurate) !== null && _v$isAccurate !== void 0 ? _v$isAccurate : null,
153
160
  code: (_v$code = v.code) !== null && _v$code !== void 0 ? _v$code : null
154
161
  });
155
162
  }
@@ -220,15 +227,13 @@ class AppWrapper {
220
227
  };
221
228
  },
222
229
  getGeoLocation: async () => {
223
- var _res$accuracy, _res$isAccurate, _res$code;
224
230
  const res = await this.appCall(14);
225
231
  return {
226
232
  latitude: res.latitude,
227
233
  longitude: res.longitude,
228
234
  speed: res.speed,
229
- accuracy: (_res$accuracy = res.accuracy) !== null && _res$accuracy !== void 0 ? _res$accuracy : null,
230
- isAccurate: (_res$isAccurate = res.isAccurate) !== null && _res$isAccurate !== void 0 ? _res$isAccurate : null,
231
- code: (_res$code = res.code) !== null && _res$code !== void 0 ? _res$code : null
235
+ code: res.code,
236
+ isAccurate: res.isAccurate
232
237
  };
233
238
  },
234
239
  getUserInfo: async query => {
@@ -468,8 +473,39 @@ class AppWrapper {
468
473
  void this.appCall(19, value, {
469
474
  awaitResult: false
470
475
  });
476
+ },
477
+ createDialog: config => {
478
+ return new _DialogHandler.default(config, this.functions.openDialog, this.functions.closeDialog);
479
+ },
480
+ openDialog: async (config, callback) => {
481
+ const currentDialogId = appWrapperDialogId++;
482
+ const eventTarget = new EventTarget();
483
+ const resolve = result => {
484
+ callback(result);
485
+ this.dispatchDialogChange(this.dialogs.filter(x => x.dialogId !== currentDialogId));
486
+ };
487
+ this.dispatchDialogChange([...this.dialogs, {
488
+ config,
489
+ resolve,
490
+ dialogId: currentDialogId,
491
+ eventTarget
492
+ }]);
493
+ return currentDialogId;
494
+ },
495
+ closeDialog: dialogId => {
496
+ const dialog = this.dialogs.find(x => x.dialogId === dialogId);
497
+ if (dialog) {
498
+ dialog.resolve({
499
+ buttonType: -1
500
+ });
501
+ }
471
502
  }
472
503
  };
504
+ dialogs = [];
505
+ dialogEventTarget = new EventTarget();
506
+ getDialogEventTarget() {
507
+ return this.dialogEventTarget;
508
+ }
473
509
  async init() {
474
510
  this.values = this.mapOldApiToNew(await this.appCall(18));
475
511
  return undefined;
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.FrameWrapper = void 0;
7
7
  var comlink = _interopRequireWildcard(require("comlink"));
8
+ var _DialogHandler = _interopRequireDefault(require("../handler/DialogHandler"));
8
9
  var _visibilityChangeListener = require("../calls/visibilityChangeListener");
9
10
  var _apiListenerHelper = require("../helper/apiListenerHelper");
10
11
  var _getUserInfo = _interopRequireDefault(require("../calls/getUserInfo"));
@@ -233,7 +234,57 @@ class FrameWrapper {
233
234
  scrollByY: async (value, duration) => {
234
235
  if (!this.initialized) await this.ready;
235
236
  return this.exposedFunctions.scrollByY(value, duration);
236
- }
237
+ },
238
+ createDialog: config => {
239
+ return new _DialogHandler.default(config, this.functions.openDialog, this.exposedFunctions.closeDialog, this.functions.dispatchEventToDialogClient, this.functions.addDialogClientEventListener);
240
+ },
241
+ closeDialog: async dialogId => {
242
+ if (!this.initialized) await this.ready;
243
+ return this.exposedFunctions.closeDialog(dialogId);
244
+ },
245
+ openDialog: async (config, callback) => {
246
+ if (!this.initialized) await this.ready;
247
+ return this.exposedFunctions.openDialog(config, comlink.proxy(callback));
248
+ },
249
+ setDialogResult: async result => {
250
+ if (!this.initialized) await this.ready;
251
+ return this.exposedFunctions.setDialogResult(result);
252
+ },
253
+ dispatchEventToDialogClient: async (dialogId, data) => {
254
+ if (!this.initialized) await this.ready;
255
+ return this.exposedFunctions.dispatchEventToDialogClient(dialogId, data);
256
+ },
257
+ addDialogClientEventListener: async (dialogId, callback) => {
258
+ if (!this.initialized) await this.ready;
259
+ return this.exposedFunctions.addDialogClientEventListener(dialogId, comlink.proxy(callback));
260
+ },
261
+ dispatchEventToDialogHost: async data => {
262
+ if (!this.initialized) await this.ready;
263
+ return this.exposedFunctions.dispatchEventToDialogHost(data);
264
+ },
265
+ addDialogHostEventListener: async callback => {
266
+ if (!this.initialized) await this.ready;
267
+ const listenerKey = `dialogHostEventListener`;
268
+ const {
269
+ id,
270
+ shouldInitialize
271
+ } = (0, _apiListenerHelper.addApiListener)(listenerKey, callback);
272
+ if (shouldInitialize) {
273
+ this.exposedFunctions.addDialogHostEventListener(comlink.proxy(data => {
274
+ (0, _apiListenerHelper.dispatchApiEvent)(listenerKey, data);
275
+ }));
276
+ }
277
+ return id;
278
+ },
279
+ removeDialogHostEventListener: async id => {
280
+ if (!this.initialized) await this.ready;
281
+ const listenerKey = `dialogHostEventListener`;
282
+ const shouldRemove = (0, _apiListenerHelper.removeApiListener)(listenerKey, id);
283
+ if (shouldRemove) {
284
+ // this.exposedFunctions.removeDialogHostEventListener(0);
285
+ }
286
+ },
287
+ removeDialogClientEventListener: async () => {}
237
288
  };
238
289
  initialized = false;
239
290
  constructor() {
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.ModuleFederationWrapper = void 0;
7
+ var _DialogHandler = _interopRequireDefault(require("../handler/DialogHandler"));
7
8
  var _visibilityChangeListener = require("../calls/visibilityChangeListener");
8
9
  var _apiListenerHelper = require("../helper/apiListenerHelper");
9
10
  var _getUserInfo = _interopRequireDefault(require("../calls/getUserInfo"));
@@ -24,6 +25,9 @@ class ModuleFederationWrapper {
24
25
  // eslint-disable-next-line
25
26
  this.functions[k] = async (...args) => fn(...args);
26
27
  });
28
+ this.functions.createDialog = config => {
29
+ return new _DialogHandler.default(config, functions.openDialog, functions.closeDialog, functions.dispatchEventToDialogClient, functions.addDialogClientEventListener);
30
+ };
27
31
  this.functions.addWindowMetricsListener = async callback => {
28
32
  const {
29
33
  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,