chayns-api 1.0.12 → 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.
Files changed (227) 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/bootstrap.js +11 -0
  8. package/dist/cjs/calls/abstractApiListener.js +40 -0
  9. package/dist/cjs/calls/apiEventListener.js +40 -0
  10. package/dist/cjs/calls/dialogs/date.js +10 -10
  11. package/dist/cjs/calls/index.js +102 -97
  12. package/dist/cjs/calls/sendMessage.js +8 -8
  13. package/dist/cjs/calls/setVisibilityChangeListener.js +1 -0
  14. package/dist/cjs/calls/visibilityChangeListener.js +4 -4
  15. package/dist/cjs/calls/windowMetricsListener.js +18 -0
  16. package/dist/cjs/client.js +93 -0
  17. package/dist/cjs/components/App.js +32 -0
  18. package/dist/cjs/components/App.spec.js +16 -0
  19. package/dist/cjs/components/AppDialogWrapper.js +42 -0
  20. package/dist/cjs/components/Button.js +32 -0
  21. package/dist/cjs/components/ChaynsModuleProvider.js +457 -0
  22. package/dist/cjs/components/ChaynsProvider.js +5 -2
  23. package/dist/cjs/components/ChaynsProviderExposed.js +16 -0
  24. package/dist/cjs/components/Dialog.js +1 -0
  25. package/dist/cjs/components/TestProvider.js +236 -0
  26. package/dist/cjs/components/Title.js +162 -0
  27. package/dist/cjs/functions/addApiListener.js +37 -0
  28. package/dist/cjs/functions/addGeoLocationListener.js +26 -0
  29. package/dist/cjs/functions/addScrollListener.js +26 -0
  30. package/dist/cjs/functions/addWindowMetricsListener.js +37 -0
  31. package/dist/cjs/handler/DialogHandler.js +40 -0
  32. package/dist/cjs/helper/cssLoader.js +28 -0
  33. package/dist/cjs/hooks/addGeoLocationListener.js +26 -0
  34. package/dist/cjs/hooks/addScrollListener.js +26 -0
  35. package/dist/cjs/hooks/addWindowMetricsListener.js +37 -0
  36. package/dist/cjs/hooks/geoLocation.js +48 -0
  37. package/dist/cjs/hooks/geoLocationListener.js +4 -4
  38. package/dist/cjs/hooks/index.js +14 -1
  39. package/dist/cjs/hooks/scrollListener.js +8 -8
  40. package/dist/cjs/hooks/useAccessToken.js +2 -2
  41. package/dist/cjs/hooks/useAddGeoLocationListener.js +26 -0
  42. package/dist/cjs/hooks/useAddScrollListener.js +48 -0
  43. package/dist/cjs/hooks/useAddWindowMetricsListener.js +45 -0
  44. package/dist/cjs/hooks/useAdddScrollListener.js +26 -0
  45. package/dist/cjs/hooks/useCurrentPage.js +2 -2
  46. package/dist/cjs/hooks/useCustomData.js +2 -2
  47. package/dist/cjs/hooks/useDevice.js +2 -2
  48. package/dist/cjs/hooks/useDialogState.js +35 -0
  49. package/dist/cjs/hooks/useEnvironment.js +2 -2
  50. package/dist/cjs/hooks/useFunction.js +13 -0
  51. package/dist/cjs/hooks/useFunctions.js +2 -2
  52. package/dist/cjs/hooks/useIsAdminMode.js +2 -2
  53. package/dist/cjs/hooks/useLanguage.js +2 -2
  54. package/dist/cjs/hooks/usePages.js +4 -4
  55. package/dist/cjs/hooks/useParameters.js +2 -2
  56. package/dist/cjs/hooks/useSite.js +2 -2
  57. package/dist/cjs/hooks/useUser.js +2 -2
  58. package/dist/cjs/hooks/useValues.js +2 -2
  59. package/dist/cjs/hooks/windowMetrics.js +45 -0
  60. package/dist/cjs/hooks/windowMetricsListener.js +4 -4
  61. package/dist/cjs/host/ChaynsHost.js +10 -5
  62. package/dist/cjs/host/HostIframe.js +157 -0
  63. package/dist/cjs/host/ModuleHost.js +11 -0
  64. package/dist/cjs/host/iframe/HostIframe.js +5 -2
  65. package/dist/cjs/host/module/ModuleHost.js +4 -0
  66. package/dist/cjs/host/module/utils.js +25 -0
  67. package/dist/cjs/index.example.js +7 -0
  68. package/dist/cjs/index2.js +64 -0
  69. package/dist/cjs/types/DynamicApiImport.d.js +5 -0
  70. package/dist/cjs/types/DynamicImport.d.js +5 -0
  71. package/dist/cjs/types/IChaynsReact.js +22 -2
  72. package/dist/cjs/types/chayns-components.d.js +1 -0
  73. package/dist/cjs/types/chayns-logger.d.js +1 -0
  74. package/dist/cjs/types/chayns.d.js +1 -0
  75. package/dist/cjs/types/tobit-websocket-service-client.d.js +1 -0
  76. package/dist/cjs/types/toolkit-types.d.js +1 -0
  77. package/dist/cjs/util/deviceHelper.js +7 -6
  78. package/dist/cjs/util/useFunctionsContext.js +16 -0
  79. package/dist/cjs/util/useIsAdminMode.js +18 -0
  80. package/dist/cjs/util/useUser.js +16 -0
  81. package/dist/cjs/wrapper/AppWrapper.js +39 -0
  82. package/dist/cjs/wrapper/Dialog.js +35 -0
  83. package/dist/cjs/wrapper/DialogHandler.js +35 -0
  84. package/dist/cjs/wrapper/FrameWrapper.js +17 -0
  85. package/dist/cjs/wrapper/ModuleFederationWrapper.js +4 -0
  86. package/dist/esm/bootstrap.js +4 -0
  87. package/dist/esm/calls/dialogs/date.js +34 -34
  88. package/dist/esm/calls/index.js +102 -96
  89. package/dist/esm/calls/sendMessage.js +8 -8
  90. package/dist/esm/calls/visibilityChangeListener.js +4 -4
  91. package/dist/esm/client.js +8 -0
  92. package/dist/esm/components/App.js +35 -0
  93. package/dist/esm/components/App.spec.js +9 -0
  94. package/dist/esm/components/AppDialogWrapper.js +33 -0
  95. package/dist/esm/components/Button.js +34 -0
  96. package/dist/esm/components/ChaynsModuleProvider.js +517 -0
  97. package/dist/esm/components/ChaynsProvider.js +5 -2
  98. package/dist/esm/components/ChaynsProviderExposed.js +3 -0
  99. package/dist/esm/components/Dialog.js +0 -0
  100. package/dist/esm/components/TestProvider.js +308 -0
  101. package/dist/esm/components/Title.js +210 -0
  102. package/dist/esm/handler/DialogHandler.js +36 -0
  103. package/dist/esm/helper/cssLoader.js +21 -0
  104. package/dist/esm/hooks/geoLocationListener.js +4 -4
  105. package/dist/esm/hooks/index.js +2 -1
  106. package/dist/esm/hooks/scrollListener.js +8 -8
  107. package/dist/esm/hooks/useAccessToken.js +2 -2
  108. package/dist/esm/hooks/useAddGeoLocationListener.js +18 -0
  109. package/dist/esm/hooks/useAddScrollListener.js +18 -0
  110. package/dist/esm/hooks/useAddWindowMetricsListener.js +18 -0
  111. package/dist/esm/hooks/useCurrentPage.js +2 -2
  112. package/dist/esm/hooks/useCustomData.js +2 -2
  113. package/dist/esm/hooks/useDevice.js +2 -2
  114. package/dist/esm/hooks/useDialogState.js +28 -0
  115. package/dist/esm/hooks/useEnvironment.js +2 -2
  116. package/dist/esm/hooks/useFunction.js +6 -0
  117. package/dist/esm/hooks/useFunctions.js +2 -2
  118. package/dist/esm/hooks/useIsAdminMode.js +2 -2
  119. package/dist/esm/hooks/useLanguage.js +2 -2
  120. package/dist/esm/hooks/usePages.js +4 -4
  121. package/dist/esm/hooks/useParameters.js +2 -2
  122. package/dist/esm/hooks/useSite.js +2 -2
  123. package/dist/esm/hooks/useUser.js +2 -2
  124. package/dist/esm/hooks/useValues.js +2 -2
  125. package/dist/esm/hooks/windowMetricsListener.js +4 -4
  126. package/dist/esm/host/ChaynsHost.js +10 -5
  127. package/dist/esm/host/HostIframe.js +153 -0
  128. package/dist/esm/host/iframe/HostIframe.js +5 -2
  129. package/dist/esm/host/module/ModuleHost.js +4 -0
  130. package/dist/esm/index.example.js +1 -0
  131. package/dist/esm/index2.js +5 -0
  132. package/dist/esm/types/DynamicApiImport.d.js +1 -0
  133. package/dist/esm/types/DynamicImport.d.js +1 -0
  134. package/dist/esm/types/IChaynsReact.js +19 -1
  135. package/dist/esm/types/chayns-components.d.js +0 -0
  136. package/dist/esm/types/chayns-logger.d.js +0 -0
  137. package/dist/esm/types/chayns.d.js +0 -0
  138. package/dist/esm/types/tobit-websocket-service-client.d.js +0 -0
  139. package/dist/esm/types/toolkit-types.d.js +0 -0
  140. package/dist/esm/util/deviceHelper.js +7 -6
  141. package/dist/esm/util/useIsAdminMode.js +9 -0
  142. package/dist/esm/util/useUser.js +7 -0
  143. package/dist/esm/wrapper/AppWrapper.js +39 -0
  144. package/dist/esm/wrapper/Dialog.js +31 -0
  145. package/dist/esm/wrapper/DialogHandler.js +31 -0
  146. package/dist/esm/wrapper/FrameWrapper.js +17 -0
  147. package/dist/esm/wrapper/ModuleFederationWrapper.js +4 -0
  148. package/dist/types/bootstrap.d.ts +1 -0
  149. package/dist/types/calls/dialogs/alert.d.ts +1 -1
  150. package/dist/types/calls/dialogs/chaynsDialog.d.ts +24 -24
  151. package/dist/types/calls/dialogs/close.d.ts +1 -1
  152. package/dist/types/calls/dialogs/communication.d.ts +3 -3
  153. package/dist/types/calls/dialogs/confirm.d.ts +13 -13
  154. package/dist/types/calls/dialogs/date.d.ts +96 -96
  155. package/dist/types/calls/dialogs/dropUpAlert.d.ts +5 -5
  156. package/dist/types/calls/dialogs/fileSelect.d.ts +16 -16
  157. package/dist/types/calls/dialogs/iFrame.d.ts +10 -10
  158. package/dist/types/calls/dialogs/index.d.ts +14 -14
  159. package/dist/types/calls/dialogs/input.d.ts +15 -15
  160. package/dist/types/calls/dialogs/mediaSelect.d.ts +8 -8
  161. package/dist/types/calls/dialogs/open.d.ts +1 -1
  162. package/dist/types/calls/dialogs/select.d.ts +6 -6
  163. package/dist/types/calls/dialogs/signature.d.ts +7 -7
  164. package/dist/types/calls/dialogs/toast.d.ts +1 -1
  165. package/dist/types/calls/dialogs/utils/callback.d.ts +1 -1
  166. package/dist/types/calls/dialogs/utils/is.d.ts +4 -4
  167. package/dist/types/calls/getUserInfo.d.ts +9 -9
  168. package/dist/types/calls/index.d.ts +237 -233
  169. package/dist/types/calls/sendMessage.d.ts +13 -13
  170. package/dist/types/calls/visibilityChangeListener.d.ts +9 -9
  171. package/dist/types/client.d.ts +7 -0
  172. package/dist/types/components/App.d.ts +5 -0
  173. package/dist/types/components/AppDialogWrapper.d.ts +5 -0
  174. package/dist/types/components/Button.d.ts +8 -0
  175. package/dist/types/components/ChaynsContext.d.ts +3 -3
  176. package/dist/types/components/ChaynsModuleProvider.d.ts +170 -0
  177. package/dist/types/components/ChaynsProvider.d.ts +14 -14
  178. package/dist/types/components/ChaynsProviderExposed.d.ts +13 -0
  179. package/dist/types/components/Dialog.d.ts +0 -0
  180. package/dist/types/components/Title.d.ts +3 -0
  181. package/dist/types/components/WaitUntil.d.ts +8 -8
  182. package/dist/types/components/withCompatMode.d.ts +13 -13
  183. package/dist/types/handler/DialogHandler.d.ts +12 -0
  184. package/dist/types/helper/apiListenerHelper.d.ts +6 -6
  185. package/dist/types/hooks/geoLocationListener.d.ts +18 -18
  186. package/dist/types/hooks/index.d.ts +17 -16
  187. package/dist/types/hooks/scrollListener.d.ts +28 -28
  188. package/dist/types/hooks/useAccessToken.d.ts +5 -5
  189. package/dist/types/hooks/useCurrentPage.d.ts +4 -4
  190. package/dist/types/hooks/useCustomData.d.ts +4 -4
  191. package/dist/types/hooks/useDevice.d.ts +5 -5
  192. package/dist/types/hooks/useDialogState.d.ts +9 -0
  193. package/dist/types/hooks/useEnvironment.d.ts +5 -5
  194. package/dist/types/hooks/useFunction.d.ts +2 -0
  195. package/dist/types/hooks/useFunctions.d.ts +5 -5
  196. package/dist/types/hooks/useIsAdminMode.d.ts +4 -4
  197. package/dist/types/hooks/useLanguage.d.ts +5 -5
  198. package/dist/types/hooks/usePages.d.ts +18 -18
  199. package/dist/types/hooks/useParameters.d.ts +5 -5
  200. package/dist/types/hooks/useSite.d.ts +5 -5
  201. package/dist/types/hooks/useUser.d.ts +5 -5
  202. package/dist/types/hooks/useValues.d.ts +5 -5
  203. package/dist/types/hooks/windowMetricsListener.d.ts +11 -11
  204. package/dist/types/host/ChaynsHost.d.ts +30 -29
  205. package/dist/types/host/HostIframe.d.ts +20 -0
  206. package/dist/types/host/iframe/HostIframe.d.ts +26 -25
  207. package/dist/types/host/iframe/utils/useUpdateData.d.ts +3 -3
  208. package/dist/types/host/module/ModuleHost.d.ts +26 -25
  209. package/dist/types/host/module/utils/loadComponent.d.ts +1 -1
  210. package/dist/types/host/module/utils/useDynamicScript.d.ts +9 -9
  211. package/dist/types/index.d.ts +16 -16
  212. package/dist/types/index.example.d.ts +0 -0
  213. package/dist/types/types/IChaynsReact.d.ts +702 -623
  214. package/dist/types/types/dialog.d.ts +41 -41
  215. package/dist/types/util/appCall.d.ts +2 -2
  216. package/dist/types/util/deviceHelper.d.ts +7 -7
  217. package/dist/types/util/heightHelper.d.ts +1 -1
  218. package/dist/types/util/postIframeForm.d.ts +1 -1
  219. package/dist/types/util/url.d.ts +1 -1
  220. package/dist/types/wrapper/AppWrapper.d.ts +22 -18
  221. package/dist/types/wrapper/Dialog.d.ts +10 -0
  222. package/dist/types/wrapper/DialogHandler.d.ts +10 -0
  223. package/dist/types/wrapper/FrameWrapper.d.ts +15 -15
  224. package/dist/types/wrapper/ModuleFederationWrapper.d.ts +10 -10
  225. package/dist/types/wrapper/SsrWrapper.d.ts +11 -11
  226. package/package.json +75 -75
  227. package/tsconfig.json +56 -56
@@ -0,0 +1,308 @@
1
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
2
+
3
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
4
+
5
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
6
+
7
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
8
+
9
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
10
+
11
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
12
+
13
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
14
+
15
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
16
+
17
+ import React, { useEffect, useState } from "react";
18
+ var api;
19
+
20
+ var ChaynsProvider = function ChaynsProvider(_ref) {
21
+ var children = _ref.children;
22
+
23
+ var _useState = useState(false),
24
+ _useState2 = _slicedToArray(_useState, 2),
25
+ loaded = _useState2[0],
26
+ setLoaded = _useState2[1];
27
+
28
+ useEffect(function () {
29
+ void _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
30
+ return regeneratorRuntime.wrap(function _callee$(_context) {
31
+ while (1) {
32
+ switch (_context.prev = _context.next) {
33
+ case 0:
34
+ _context.next = 2;
35
+ return import("app2/index2");
36
+
37
+ case 2:
38
+ api = _context.sent;
39
+ setLoaded(true);
40
+
41
+ case 4:
42
+ case "end":
43
+ return _context.stop();
44
+ }
45
+ }
46
+ }, _callee);
47
+ }))();
48
+ }, []);
49
+ if (!loaded) return false;
50
+ return /*#__PURE__*/React.createElement(api.RealChaynsProvider, null, children);
51
+ };
52
+
53
+ export var useGeoLocation = function useGeoLocation() {
54
+ var _api;
55
+
56
+ return (_api = api).useGeoLocation.apply(_api, arguments);
57
+ };
58
+ export var addGeoLocationListener = function addGeoLocationListener() {
59
+ var _api2;
60
+
61
+ return (_api2 = api).addGeoLocationListener.apply(_api2, arguments);
62
+ };
63
+ export var addScrollListener = function addScrollListener() {
64
+ var _api3;
65
+
66
+ return (_api3 = api).addScrollListener.apply(_api3, arguments);
67
+ };
68
+ export var addVisibilityChangeListener = function addVisibilityChangeListener() {
69
+ var _api4;
70
+
71
+ return (_api4 = api).addVisibilityChangeListener.apply(_api4, arguments);
72
+ };
73
+ export var addWindowMetricsListener = function addWindowMetricsListener() {
74
+ var _api5;
75
+
76
+ return (_api5 = api).addWindowMetricsListener.apply(_api5, arguments);
77
+ };
78
+ export var getAccessToken = function getAccessToken() {
79
+ var _api6;
80
+
81
+ return (_api6 = api).getAccessToken.apply(_api6, arguments);
82
+ };
83
+ export var getAvailableSharingServices = function getAvailableSharingServices() {
84
+ var _api7;
85
+
86
+ return (_api7 = api).getAvailableSharingServices.apply(_api7, arguments);
87
+ };
88
+ export var getGeoLocation = function getGeoLocation() {
89
+ var _api8;
90
+
91
+ return (_api8 = api).getGeoLocation.apply(_api8, arguments);
92
+ };
93
+ export var getUserInfo = function getUserInfo() {
94
+ var _api9;
95
+
96
+ return (_api9 = api).getUserInfo.apply(_api9, arguments);
97
+ };
98
+ export var getScrollPosition = function getScrollPosition() {
99
+ var _api10;
100
+
101
+ return (_api10 = api).getScrollPosition.apply(_api10, arguments);
102
+ };
103
+ export var getWindowMetrics = function getWindowMetrics() {
104
+ var _api11;
105
+
106
+ return (_api11 = api).getWindowMetrics.apply(_api11, arguments);
107
+ };
108
+ export var invokeCall = function invokeCall() {
109
+ var _api12;
110
+
111
+ return (_api12 = api).invokeCall.apply(_api12, arguments);
112
+ };
113
+ export var login = function login() {
114
+ var _api13;
115
+
116
+ return (_api13 = api).login.apply(_api13, arguments);
117
+ };
118
+ export var logout = function logout() {
119
+ var _api14;
120
+
121
+ return (_api14 = api).logout.apply(_api14, arguments);
122
+ };
123
+ export var navigateBack = function navigateBack() {
124
+ var _api15;
125
+
126
+ return (_api15 = api).navigateBack.apply(_api15, arguments);
127
+ };
128
+ export var openImage = function openImage() {
129
+ var _api16;
130
+
131
+ return (_api16 = api).openImage.apply(_api16, arguments);
132
+ };
133
+ export var openUrl = function openUrl() {
134
+ var _api17;
135
+
136
+ return (_api17 = api).openUrl.apply(_api17, arguments);
137
+ };
138
+ export var openVideo = function openVideo() {
139
+ var _api18;
140
+
141
+ return (_api18 = api).openVideo.apply(_api18, arguments);
142
+ };
143
+ export var refreshAccessToken = function refreshAccessToken() {
144
+ var _api19;
145
+
146
+ return (_api19 = api).refreshAccessToken.apply(_api19, arguments);
147
+ };
148
+ export var refreshData = function refreshData() {
149
+ var _api20;
150
+
151
+ return (_api20 = api).refreshData.apply(_api20, arguments);
152
+ };
153
+ export var removeGeoLocationListener = function removeGeoLocationListener() {
154
+ var _api21;
155
+
156
+ return (_api21 = api).removeGeoLocationListener.apply(_api21, arguments);
157
+ };
158
+ export var removeScrollListener = function removeScrollListener() {
159
+ var _api22;
160
+
161
+ return (_api22 = api).removeScrollListener.apply(_api22, arguments);
162
+ };
163
+ export var removeVisibilityChangeListener = function removeVisibilityChangeListener() {
164
+ var _api23;
165
+
166
+ return (_api23 = api).removeVisibilityChangeListener.apply(_api23, arguments);
167
+ };
168
+ export var removeWindowMetricsListener = function removeWindowMetricsListener() {
169
+ var _api24;
170
+
171
+ return (_api24 = api).removeWindowMetricsListener.apply(_api24, arguments);
172
+ };
173
+ export var scrollToY = function scrollToY() {
174
+ var _api25;
175
+
176
+ return (_api25 = api).scrollToY.apply(_api25, arguments);
177
+ };
178
+ export var sendMessageToGroup = function sendMessageToGroup() {
179
+ var _api26;
180
+
181
+ return (_api26 = api).sendMessageToGroup.apply(_api26, arguments);
182
+ };
183
+ export var sendMessageToPage = function sendMessageToPage() {
184
+ var _api27;
185
+
186
+ return (_api27 = api).sendMessageToPage.apply(_api27, arguments);
187
+ };
188
+ export var sendMessageToUser = function sendMessageToUser() {
189
+ var _api28;
190
+
191
+ return (_api28 = api).sendMessageToUser.apply(_api28, arguments);
192
+ };
193
+ export var setAdminMode = function setAdminMode() {
194
+ var _api29;
195
+
196
+ return (_api29 = api).setAdminMode.apply(_api29, arguments);
197
+ };
198
+ export var setDisplayTimeout = function setDisplayTimeout() {
199
+ var _api30;
200
+
201
+ return (_api30 = api).setDisplayTimeout.apply(_api30, arguments);
202
+ };
203
+ export var setFloatingButton = function setFloatingButton() {
204
+ var _api31;
205
+
206
+ return (_api31 = api).setFloatingButton.apply(_api31, arguments);
207
+ };
208
+ export var setHeight = function setHeight() {
209
+ var _api32;
210
+
211
+ return (_api32 = api).setHeight.apply(_api32, arguments);
212
+ };
213
+ export var setOverlay = function setOverlay() {
214
+ var _api33;
215
+
216
+ return (_api33 = api).setOverlay.apply(_api33, arguments);
217
+ };
218
+ export var setRefreshScrollEnabled = function setRefreshScrollEnabled() {
219
+ var _api34;
220
+
221
+ return (_api34 = api).setRefreshScrollEnabled.apply(_api34, arguments);
222
+ };
223
+ export var setScanQrCode = function setScanQrCode() {
224
+ var _api35;
225
+
226
+ return (_api35 = api).setScanQrCode.apply(_api35, arguments);
227
+ };
228
+ export var setTempDesignSettings = function setTempDesignSettings() {
229
+ var _api36;
230
+
231
+ return (_api36 = api).setTempDesignSettings.apply(_api36, arguments);
232
+ };
233
+ export var setWaitCursor = function setWaitCursor() {
234
+ var _api37;
235
+
236
+ return (_api37 = api).setWaitCursor.apply(_api37, arguments);
237
+ };
238
+ export var storageGetItem = function storageGetItem() {
239
+ var _api38;
240
+
241
+ return (_api38 = api).storageGetItem.apply(_api38, arguments);
242
+ };
243
+ export var storageRemoveItem = function storageRemoveItem() {
244
+ var _api39;
245
+
246
+ return (_api39 = api).storageRemoveItem.apply(_api39, arguments);
247
+ };
248
+ export var storageSetItem = function storageSetItem() {
249
+ var _api40;
250
+
251
+ return (_api40 = api).storageSetItem.apply(_api40, arguments);
252
+ };
253
+ export var vibrate = function vibrate() {
254
+ var _api41;
255
+
256
+ return (_api41 = api).vibrate.apply(_api41, arguments);
257
+ };
258
+ export var useAccessToken = function useAccessToken() {
259
+ var _api42;
260
+
261
+ return (_api42 = api).useAccessToken.apply(_api42, arguments);
262
+ };
263
+ export var useWindowMetrics = function useWindowMetrics() {
264
+ var _api43;
265
+
266
+ return (_api43 = api).useWindowMetrics.apply(_api43, arguments);
267
+ };
268
+ export var useScrollPosition = function useScrollPosition() {
269
+ var _api44;
270
+
271
+ return (_api44 = api).useScrollPosition.apply(_api44, arguments);
272
+ };
273
+ export var useUser = function useUser() {
274
+ var _api45;
275
+
276
+ return (_api45 = api).useUser.apply(_api45, arguments);
277
+ };
278
+ export var useIsAdminMode = function useIsAdminMode() {
279
+ var _api46;
280
+
281
+ return (_api46 = api).useIsAdminMode.apply(_api46, arguments);
282
+ };
283
+ export var useScrollOffsetTop = function useScrollOffsetTop() {
284
+ var _api47;
285
+
286
+ return (_api47 = api).useScrollOffsetTop.apply(_api47, arguments);
287
+ };
288
+ export var useScrollOffsetBottom = function useScrollOffsetBottom() {
289
+ var _api48;
290
+
291
+ return (_api48 = api).useScrollOffsetBottom.apply(_api48, arguments);
292
+ };
293
+ export var useScrollListener = function useScrollListener() {
294
+ var _api49;
295
+
296
+ return (_api49 = api).useScrollListener.apply(_api49, arguments);
297
+ };
298
+ export var useWindowMetricsListener = function useWindowMetricsListener() {
299
+ var _api50;
300
+
301
+ return (_api50 = api).useWindowMetricsListener.apply(_api50, arguments);
302
+ };
303
+ export var useGeoLocationListener = function useGeoLocationListener() {
304
+ var _api51;
305
+
306
+ return (_api51 = api).useGeoLocationListener.apply(_api51, arguments);
307
+ };
308
+ export default ChaynsProvider;
@@ -0,0 +1,210 @@
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 asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
4
+
5
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
6
+
7
+ 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; }
8
+
9
+ 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; }
10
+
11
+ 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; }
12
+
13
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
14
+
15
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
16
+
17
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
18
+
19
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
20
+
21
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
22
+
23
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
24
+
25
+ import React, { useEffect, useRef, useState } from 'react';
26
+ import { useContextSelector } from 'use-context-selector';
27
+ import { useUser } from '../hooks/useUser';
28
+ import { useIsAdminMode } from '../hooks/useIsAdminMode';
29
+ import { useScrollOffsetBottom, useScrollOffsetTop, useScrollPosition } from '../hooks/scrollListener';
30
+ import { useWindowMetrics } from '../hooks/windowMetricsListener';
31
+ import { ChaynsContext, ChaynsFunctionsContext } from './ChaynsContext';
32
+ import ChaynsHost from '../host/ChaynsHost';
33
+ // import './title.scss';
34
+ import { addScrollListener, removeScrollListener } from '../index';
35
+ var FirstName = /*#__PURE__*/React.memo(function () {
36
+ var user = useUser();
37
+ console.debug('render first name', user);
38
+ return /*#__PURE__*/React.createElement("div", {
39
+ className: "firstname"
40
+ }, "FirstName: ", user === null || user === void 0 ? void 0 : user.firstName);
41
+ });
42
+
43
+ var Title = function Title() {
44
+ var _URLSearchParams$get;
45
+
46
+ var isAdminModeActive = useIsAdminMode();
47
+ var ref = useRef(null); // const addScrollListener = useScrollListener();
48
+ //const { value } = useGeoLocation({ timeout: 1000, enabled: true, silent: true });
49
+
50
+ var _useScrollPosition = useScrollPosition({
51
+ enabled: true,
52
+ throttle: 100
53
+ }),
54
+ scrollY = _useScrollPosition.scrollY; // const addGeoLocationListener = useGeoLocationListener();
55
+ // const addWindowMetricsListener = useWindowMetricsListener();
56
+
57
+
58
+ var offsetTop = useScrollOffsetTop();
59
+ var offsetBottom = useScrollOffsetBottom();
60
+ var values = useContextSelector(ChaynsContext, function (s) {
61
+ return s;
62
+ });
63
+ var functions = useContextSelector(ChaynsFunctionsContext, function (s) {
64
+ return s;
65
+ });
66
+ var login = useContextSelector(ChaynsFunctionsContext, function (s) {
67
+ return s.login;
68
+ });
69
+ var logout = useContextSelector(ChaynsFunctionsContext, function (s) {
70
+ return s.logout;
71
+ }); // const [windowMetrics, setWindowMetrics] = useState(null);
72
+
73
+ var windowMetrics = useWindowMetrics();
74
+ console.log('offsetTop', offsetTop, offsetBottom, windowMetrics);
75
+
76
+ var _useState = useState(10),
77
+ _useState2 = _slicedToArray(_useState, 2),
78
+ testHeight = _useState2[0],
79
+ setTestHeight = _useState2[1];
80
+
81
+ useEffect(function () {
82
+ var promise = addScrollListener({}, function (r) {
83
+ return console.log('add scroll', r);
84
+ });
85
+ return function () {
86
+ void (promise === null || promise === void 0 ? void 0 : promise.then(function (id) {
87
+ console.log('remove scroll', id);
88
+ return removeScrollListener(id);
89
+ }));
90
+ };
91
+ }, []); // useEffect(() => addScrollListener({ throttle: 200 }, (ev) => {
92
+ // console.log('scroll', ev)
93
+ // setWindowMetrics(ev.windowMetrics);
94
+ // }), [addScrollListener]);
95
+ //
96
+ // useEffect(() => addGeoLocationListener({ silent: true }, (ev) => {
97
+ // console.log('geo location', ev);
98
+ // }), [addGeoLocationListener])
99
+ //
100
+ // useEffect(() => addWindowMetricsListener((ev) => {
101
+ // console.log('window metrics', ev);
102
+ // setWindowMetrics(ev);
103
+ // }), [addWindowMetricsListener]);
104
+ // console.debug('render title', scrollPosition);
105
+
106
+ var src = useRef();
107
+ var depth = global.location ? Number.parseInt((_URLSearchParams$get = new URLSearchParams(window.location.search).get('depth')) !== null && _URLSearchParams$get !== void 0 ? _URLSearchParams$get : '1', 10) : 1;
108
+
109
+ if (!src.current) {
110
+ src.current = "https://w-hn-laptop.tobit.ag:8082?depth=".concat(depth + 1); // src.current = 'https://tapp01.tobit.com/Tapps/Chaynsnet/landingpage_2020/v4/index.html?isWidget=true';
111
+ }
112
+
113
+ var maxDepth = 2;
114
+ return /*#__PURE__*/React.createElement("div", {
115
+ className: "chayns-api"
116
+ }, /*#__PURE__*/React.createElement(FirstName, null), /*#__PURE__*/React.createElement("button", {
117
+ id: "login-button",
118
+ type: "button",
119
+ onClick: function onClick() {
120
+ return login({
121
+ ignoreAuthenticated: false
122
+ }, function () {}, function () {});
123
+ }
124
+ }, "Login"), /*#__PURE__*/React.createElement("button", {
125
+ type: "button",
126
+ onClick: logout
127
+ }, "Logout"), /*#__PURE__*/React.createElement("div", null, "AdminMode active: ", isAdminModeActive ? 'true' : 'false'), depth < maxDepth && /*#__PURE__*/React.createElement(ChaynsHost, _extends({}, values, {
128
+ iFrameRef: ref,
129
+ src: src.current,
130
+ iFrameProps: {
131
+ name: "CustomPluginIframe".concat(depth),
132
+ style: {
133
+ border: 0,
134
+ width: '100%'
135
+ },
136
+ height: 1
137
+ },
138
+ functions: _objectSpread(_objectSpread({}, functions), {}, {
139
+ getWindowMetrics: function () {
140
+ var _getWindowMetrics = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
141
+ var v;
142
+ return regeneratorRuntime.wrap(function _callee$(_context) {
143
+ while (1) {
144
+ switch (_context.prev = _context.next) {
145
+ case 0:
146
+ _context.next = 2;
147
+ return functions.getWindowMetrics();
148
+
149
+ case 2:
150
+ v = _context.sent;
151
+ return _context.abrupt("return", _objectSpread(_objectSpread({}, v), {}, {
152
+ offsetTop: v.offsetTop + (ref.current ? ref.current.getBoundingClientRect().top : 0)
153
+ }));
154
+
155
+ case 4:
156
+ case "end":
157
+ return _context.stop();
158
+ }
159
+ }
160
+ }, _callee);
161
+ }));
162
+
163
+ function getWindowMetrics() {
164
+ return _getWindowMetrics.apply(this, arguments);
165
+ }
166
+
167
+ return getWindowMetrics;
168
+ }(),
169
+ addWindowMetricsListener: function addWindowMetricsListener(cb) {
170
+ return functions.addWindowMetricsListener(function (result) {
171
+ return cb(_objectSpread(_objectSpread({}, result), {}, {
172
+ offsetTop: result.offsetTop + (ref.current ? ref.current.getBoundingClientRect().top : 0)
173
+ }));
174
+ });
175
+ }
176
+ }),
177
+ type: "client-iframe"
178
+ })), /*#__PURE__*/React.createElement("div", {
179
+ style: {
180
+ position: 'absolute',
181
+ top: offsetTop,
182
+ color: 'green',
183
+ backgroundColor: 'white'
184
+ }
185
+ }, "456"), /*#__PURE__*/React.createElement("div", {
186
+ style: {
187
+ position: 'absolute',
188
+ top: Math.min(offsetBottom, window.innerHeight) - 25,
189
+ right: 20,
190
+ color: 'red',
191
+ backgroundColor: 'white'
192
+ }
193
+ }, "123"), /*#__PURE__*/React.createElement("button", {
194
+ type: "button",
195
+ onClick: function onClick() {
196
+ return setTestHeight(testHeight + 100);
197
+ }
198
+ }, "Increase height"), /*#__PURE__*/React.createElement("div", {
199
+ className: "nice",
200
+ style: {
201
+ height: testHeight
202
+ }
203
+ }), /*#__PURE__*/React.createElement("button", {
204
+ onClick: function onClick() {
205
+ return setTestHeight(Math.max(0, testHeight - 100));
206
+ }
207
+ }, "Reduce height"));
208
+ };
209
+
210
+ export default /*#__PURE__*/React.memo(Title);
@@ -0,0 +1,36 @@
1
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
3
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
4
+ export default class DialogHandler {
5
+ constructor(config, open, close) {
6
+ _defineProperty(this, "isOpen", false);
7
+ _defineProperty(this, "result", undefined);
8
+ this._open = open;
9
+ this._close = close;
10
+ this._config = config;
11
+ }
12
+ async open() {
13
+ if (this.isOpen) {
14
+ throw new Error('cannot open a dialog which is already open');
15
+ }
16
+ const res = await new Promise(async resolve => {
17
+ const callback = data => {
18
+ this.isOpen = false;
19
+ resolve(data);
20
+ };
21
+ this.isOpen = true;
22
+ this.dialogId = await this._open(this._config, callback);
23
+ });
24
+ return this.result = res;
25
+ }
26
+ close(buttonType, data) {
27
+ if (!this.isOpen) {
28
+ return;
29
+ }
30
+ this.isOpen = false;
31
+ this._close(this.dialogId, data);
32
+ }
33
+ getResult() {
34
+ return this.result;
35
+ }
36
+ }
@@ -0,0 +1,21 @@
1
+ export function loadCss() {
2
+ var apiUrl = 'https://api.chayns.net/css/';
3
+ var parameters = new URLSearchParams(window.location.search.toLowerCase());
4
+ document.documentElement.style.visibility = 'hidden';
5
+ document.documentElement.style.overflow = 'hidden';
6
+ var head = document.getElementsByTagName('HEAD')[0];
7
+ var link = document.createElement('link');
8
+ link.rel = 'stylesheet';
9
+ link.type = 'text/css';
10
+ link.href = apiUrl + (parameters.get('siteid') || "");
11
+
12
+ link.onload = function () {
13
+ document.documentElement.style.visibility = 'visible';
14
+ };
15
+
16
+ link.onerror = function () {
17
+ document.documentElement.style.visibility = 'visible';
18
+ };
19
+
20
+ head.appendChild(link);
21
+ }
@@ -1,8 +1,8 @@
1
1
  import { useContextSelector } from 'use-context-selector';
2
2
  import { useCallback, useEffect, useRef, useState } from 'react';
3
3
  import { ChaynsFunctionsContext } from '../components/ChaynsContext';
4
- /**
5
- * @category Hooks
4
+ /**
5
+ * @category Hooks
6
6
  */
7
7
  export const useGeoLocationListener = () => {
8
8
  const addListener = useContextSelector(ChaynsFunctionsContext, v => v.addGeoLocationListener);
@@ -17,8 +17,8 @@ export const useGeoLocationListener = () => {
17
17
  // eslint-disable-next-line react-hooks/exhaustive-deps
18
18
  }, []);
19
19
  };
20
- /**
21
- * @category Hooks
20
+ /**
21
+ * @category Hooks
22
22
  */
23
23
  export const useGeoLocation = function () {
24
24
  let {
@@ -13,4 +13,5 @@ export { useLanguage } from './useLanguage';
13
13
  export { useValues } from './useValues';
14
14
  export { useFunctions } from './useFunctions';
15
15
  export { useCurrentPage } from './useCurrentPage';
16
- export { useCustomData } from './useCustomData';
16
+ export { useCustomData } from './useCustomData';
17
+ export { useDialogState, useDialogData } from './useDialogState';
@@ -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 { useWindowMetrics } from './windowMetricsListener';
5
- /**
6
- * @category Hooks
5
+ /**
6
+ * @category Hooks
7
7
  */
8
8
  export const useScrollListener = () => {
9
9
  const addListener = useContextSelector(ChaynsFunctionsContext, v => v.addScrollListener);
@@ -18,8 +18,8 @@ export const useScrollListener = () => {
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 useScrollPosition = function () {
25
25
  let {
@@ -46,8 +46,8 @@ export const useScrollPosition = function () {
46
46
  }, [getScrollPosition]);
47
47
  return value;
48
48
  };
49
- /**
50
- * @category Hooks
49
+ /**
50
+ * @category Hooks
51
51
  */
52
52
  export const useScrollOffsetTop = function () {
53
53
  let {
@@ -69,8 +69,8 @@ export const useScrollOffsetTop = function () {
69
69
  }
70
70
  return 0;
71
71
  };
72
- /**
73
- * @category Hooks
72
+ /**
73
+ * @category Hooks
74
74
  */
75
75
  export const useScrollOffsetBottom = function () {
76
76
  let {
@@ -2,8 +2,8 @@ import { useEffect, useState } from "react";
2
2
  import { useContextSelector } from "use-context-selector";
3
3
  import { ChaynsFunctionsContext } from "../components/ChaynsContext";
4
4
 
5
- /**
6
- * @category Hooks
5
+ /**
6
+ * @category Hooks
7
7
  */
8
8
  export const useAccessToken = accessToken => {
9
9
  const [token, setToken] = useState(null);
@@ -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
+ };