chayns-api 1.0.1 → 1.0.3

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 (263) 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 -0
  5. package/LICENSE +21 -21
  6. package/README.md +47 -47
  7. package/dist/cjs/calls/dialogs/alert.js +0 -2
  8. package/dist/cjs/calls/dialogs/chaynsDialog.js +2 -8
  9. package/dist/cjs/calls/dialogs/close.js +0 -2
  10. package/dist/cjs/calls/dialogs/communication.js +1 -16
  11. package/dist/cjs/calls/dialogs/confirm.js +0 -4
  12. package/dist/cjs/calls/dialogs/date.js +46 -63
  13. package/dist/cjs/calls/dialogs/dropUpAlert.js +0 -3
  14. package/dist/cjs/calls/dialogs/fileSelect.js +0 -10
  15. package/dist/cjs/calls/dialogs/iFrame.js +0 -8
  16. package/dist/cjs/calls/dialogs/index.js +0 -27
  17. package/dist/cjs/calls/dialogs/input.js +0 -6
  18. package/dist/cjs/calls/dialogs/mediaSelect.js +0 -7
  19. package/dist/cjs/calls/dialogs/open.js +0 -2
  20. package/dist/cjs/calls/dialogs/select.js +0 -9
  21. package/dist/cjs/calls/dialogs/signature.js +0 -5
  22. package/dist/cjs/calls/dialogs/toast.js +0 -3
  23. package/dist/cjs/calls/dialogs/utils/callback.js +0 -2
  24. package/dist/cjs/calls/dialogs/utils/is.js +0 -4
  25. package/dist/cjs/calls/getUserInfo.js +0 -11
  26. package/dist/cjs/calls/index.js +95 -247
  27. package/dist/cjs/calls/sendMessage.js +8 -34
  28. package/dist/cjs/calls/visibilityChangeListener.js +5 -16
  29. package/dist/cjs/components/ChaynsContext.js +2 -4
  30. package/dist/cjs/components/ChaynsProvider.js +6 -28
  31. package/dist/cjs/components/WaitUntil.js +0 -5
  32. package/dist/cjs/components/withCompatMode.js +1 -16
  33. package/dist/cjs/helper/apiListenerHelper.js +0 -9
  34. package/dist/cjs/hooks/geoLocationListener.js +6 -15
  35. package/dist/cjs/hooks/index.js +6 -16
  36. package/dist/cjs/hooks/scrollListener.js +12 -31
  37. package/dist/cjs/hooks/useAccessToken.js +2 -7
  38. package/dist/cjs/hooks/useCurrentPage.js +2 -6
  39. package/dist/cjs/hooks/useCustomData.js +2 -6
  40. package/dist/cjs/hooks/useDevice.js +2 -6
  41. package/dist/cjs/hooks/useEnvironment.js +2 -6
  42. package/dist/cjs/hooks/useFunctions.js +2 -6
  43. package/dist/cjs/hooks/useIsAdminMode.js +2 -7
  44. package/dist/cjs/hooks/useLanguage.js +2 -6
  45. package/dist/cjs/hooks/usePages.js +26 -18
  46. package/dist/cjs/hooks/useParameters.js +2 -6
  47. package/dist/cjs/hooks/useSite.js +2 -6
  48. package/dist/cjs/hooks/useUser.js +2 -7
  49. package/dist/cjs/hooks/useValues.js +2 -6
  50. package/dist/cjs/hooks/windowMetricsListener.js +6 -16
  51. package/dist/cjs/host/ChaynsHost.js +0 -10
  52. package/dist/cjs/host/iframe/HostIframe.js +23 -30
  53. package/dist/cjs/host/iframe/utils/useUpdateData.js +0 -3
  54. package/dist/cjs/host/module/ModuleHost.js +3 -13
  55. package/dist/cjs/host/module/utils/loadComponent.js +1 -18
  56. package/dist/cjs/host/module/utils/useDynamicScript.js +0 -18
  57. package/dist/cjs/index.js +0 -19
  58. package/dist/cjs/types/IChaynsReact.js +27 -48
  59. package/dist/cjs/util/appCall.js +1 -4
  60. package/dist/cjs/util/deviceHelper.js +5 -22
  61. package/dist/cjs/util/heightHelper.js +0 -9
  62. package/dist/cjs/util/postIframeForm.js +0 -5
  63. package/dist/cjs/wrapper/AppWrapper.js +323 -159
  64. package/dist/cjs/wrapper/FrameWrapper.js +219 -248
  65. package/dist/cjs/wrapper/ModuleFederationWrapper.js +2 -27
  66. package/dist/cjs/wrapper/SsrWrapper.js +0 -8
  67. package/dist/esm/calls/dialogs/alert.js +4 -4
  68. package/dist/esm/calls/dialogs/chaynsDialog.js +7 -11
  69. package/dist/esm/calls/dialogs/communication.js +15 -26
  70. package/dist/esm/calls/dialogs/confirm.js +5 -8
  71. package/dist/esm/calls/dialogs/date.js +119 -128
  72. package/dist/esm/calls/dialogs/dropUpAlert.js +1 -1
  73. package/dist/esm/calls/dialogs/fileSelect.js +23 -62
  74. package/dist/esm/calls/dialogs/iFrame.js +7 -10
  75. package/dist/esm/calls/dialogs/input.js +2 -5
  76. package/dist/esm/calls/dialogs/mediaSelect.js +18 -55
  77. package/dist/esm/calls/dialogs/open.js +2 -2
  78. package/dist/esm/calls/dialogs/select.js +5 -9
  79. package/dist/esm/calls/dialogs/signature.js +0 -2
  80. package/dist/esm/calls/dialogs/toast.js +6 -11
  81. package/dist/esm/calls/dialogs/utils/callback.js +3 -5
  82. package/dist/esm/calls/dialogs/utils/is.js +1 -3
  83. package/dist/esm/calls/getUserInfo.js +32 -92
  84. package/dist/esm/calls/index.js +297 -449
  85. package/dist/esm/calls/sendMessage.js +99 -229
  86. package/dist/esm/calls/visibilityChangeListener.js +14 -19
  87. package/dist/esm/components/ChaynsContext.js +3 -3
  88. package/dist/esm/components/ChaynsProvider.js +45 -86
  89. package/dist/esm/components/WaitUntil.js +21 -86
  90. package/dist/esm/components/withCompatMode.js +35 -77
  91. package/dist/esm/helper/apiListenerHelper.js +10 -15
  92. package/dist/esm/hooks/geoLocationListener.js +24 -50
  93. package/dist/esm/hooks/index.js +1 -1
  94. package/dist/esm/hooks/scrollListener.js +58 -94
  95. package/dist/esm/hooks/useAccessToken.js +8 -30
  96. package/dist/esm/hooks/useCurrentPage.js +4 -8
  97. package/dist/esm/hooks/useCustomData.js +4 -8
  98. package/dist/esm/hooks/useDevice.js +3 -8
  99. package/dist/esm/hooks/useEnvironment.js +3 -8
  100. package/dist/esm/hooks/useFunctions.js +4 -7
  101. package/dist/esm/hooks/useIsAdminMode.js +4 -8
  102. package/dist/esm/hooks/useLanguage.js +3 -8
  103. package/dist/esm/hooks/usePages.js +38 -31
  104. package/dist/esm/hooks/useParameters.js +3 -8
  105. package/dist/esm/hooks/useSite.js +3 -8
  106. package/dist/esm/hooks/useUser.js +3 -9
  107. package/dist/esm/hooks/useValues.js +4 -7
  108. package/dist/esm/hooks/windowMetricsListener.js +22 -48
  109. package/dist/esm/host/ChaynsHost.js +22 -29
  110. package/dist/esm/host/iframe/HostIframe.js +86 -142
  111. package/dist/esm/host/iframe/utils/useUpdateData.js +4 -6
  112. package/dist/esm/host/module/ModuleHost.js +42 -49
  113. package/dist/esm/host/module/utils/loadComponent.js +47 -85
  114. package/dist/esm/host/module/utils/useDynamicScript.js +27 -74
  115. package/dist/esm/types/IChaynsReact.js +37 -61
  116. package/dist/esm/util/appCall.js +2 -4
  117. package/dist/esm/util/deviceHelper.js +13 -37
  118. package/dist/esm/util/heightHelper.js +10 -13
  119. package/dist/esm/util/postIframeForm.js +25 -57
  120. package/dist/esm/wrapper/AppWrapper.js +385 -781
  121. package/dist/esm/wrapper/FrameWrapper.js +262 -1509
  122. package/dist/esm/wrapper/ModuleFederationWrapper.js +47 -284
  123. package/dist/esm/wrapper/SsrWrapper.js +19 -65
  124. package/dist/types/calls/dialogs/alert.d.ts +1 -1
  125. package/dist/types/calls/dialogs/chaynsDialog.d.ts +24 -24
  126. package/dist/types/calls/dialogs/close.d.ts +1 -1
  127. package/dist/types/calls/dialogs/communication.d.ts +3 -3
  128. package/dist/types/calls/dialogs/confirm.d.ts +13 -13
  129. package/dist/types/calls/dialogs/date.d.ts +96 -96
  130. package/dist/types/calls/dialogs/dropUpAlert.d.ts +5 -5
  131. package/dist/types/calls/dialogs/fileSelect.d.ts +16 -16
  132. package/dist/types/calls/dialogs/iFrame.d.ts +10 -10
  133. package/dist/types/calls/dialogs/index.d.ts +14 -14
  134. package/dist/types/calls/dialogs/input.d.ts +15 -15
  135. package/dist/types/calls/dialogs/mediaSelect.d.ts +8 -8
  136. package/dist/types/calls/dialogs/open.d.ts +1 -1
  137. package/dist/types/calls/dialogs/select.d.ts +6 -6
  138. package/dist/types/calls/dialogs/signature.d.ts +7 -7
  139. package/dist/types/calls/dialogs/toast.d.ts +1 -1
  140. package/dist/types/calls/dialogs/utils/callback.d.ts +1 -1
  141. package/dist/types/calls/dialogs/utils/is.d.ts +4 -4
  142. package/dist/types/calls/getUserInfo.d.ts +9 -9
  143. package/dist/types/calls/index.d.ts +225 -231
  144. package/dist/types/calls/sendMessage.d.ts +13 -13
  145. package/dist/types/calls/visibilityChangeListener.d.ts +9 -9
  146. package/dist/types/components/ChaynsContext.d.ts +3 -3
  147. package/dist/types/components/ChaynsProvider.d.ts +13 -13
  148. package/dist/types/components/WaitUntil.d.ts +7 -7
  149. package/dist/types/components/withCompatMode.d.ts +13 -13
  150. package/dist/types/helper/apiListenerHelper.d.ts +6 -6
  151. package/dist/types/hooks/geoLocationListener.d.ts +18 -18
  152. package/dist/types/hooks/index.d.ts +16 -16
  153. package/dist/types/hooks/scrollListener.d.ts +28 -28
  154. package/dist/types/hooks/useAccessToken.d.ts +5 -5
  155. package/dist/types/hooks/useCurrentPage.d.ts +4 -4
  156. package/dist/types/hooks/useCustomData.d.ts +4 -4
  157. package/dist/types/hooks/useDevice.d.ts +5 -5
  158. package/dist/types/hooks/useEnvironment.d.ts +5 -5
  159. package/dist/types/hooks/useFunctions.d.ts +5 -5
  160. package/dist/types/hooks/useIsAdminMode.d.ts +4 -4
  161. package/dist/types/hooks/useLanguage.d.ts +5 -5
  162. package/dist/types/hooks/usePages.d.ts +18 -14
  163. package/dist/types/hooks/useParameters.d.ts +5 -5
  164. package/dist/types/hooks/useSite.d.ts +5 -5
  165. package/dist/types/hooks/useUser.d.ts +5 -5
  166. package/dist/types/hooks/useValues.d.ts +5 -5
  167. package/dist/types/hooks/windowMetricsListener.d.ts +11 -11
  168. package/dist/types/host/ChaynsHost.d.ts +28 -28
  169. package/dist/types/host/iframe/HostIframe.d.ts +24 -24
  170. package/dist/types/host/iframe/utils/useUpdateData.d.ts +3 -3
  171. package/dist/types/host/module/ModuleHost.d.ts +23 -23
  172. package/dist/types/host/module/utils/loadComponent.d.ts +1 -1
  173. package/dist/types/host/module/utils/useDynamicScript.d.ts +9 -9
  174. package/dist/types/index.d.ts +16 -16
  175. package/dist/types/types/IChaynsReact.d.ts +622 -590
  176. package/dist/types/types/dialog.d.ts +41 -41
  177. package/dist/types/util/appCall.d.ts +2 -2
  178. package/dist/types/util/deviceHelper.d.ts +7 -7
  179. package/dist/types/util/heightHelper.d.ts +1 -1
  180. package/dist/types/util/postIframeForm.d.ts +1 -1
  181. package/dist/types/wrapper/AppWrapper.d.ts +18 -16
  182. package/dist/types/wrapper/FrameWrapper.d.ts +15 -15
  183. package/dist/types/wrapper/ModuleFederationWrapper.d.ts +10 -10
  184. package/dist/types/wrapper/SsrWrapper.d.ts +11 -11
  185. package/package.json +76 -76
  186. package/toolkit.config.js +52 -52
  187. package/tsconfig.json +56 -56
  188. package/dist/cjs/bootstrap.js +0 -11
  189. package/dist/cjs/calls/abstractApiListener.js +0 -40
  190. package/dist/cjs/calls/apiEventListener.js +0 -40
  191. package/dist/cjs/calls/setVisibilityChangeListener.js +0 -1
  192. package/dist/cjs/calls/windowMetricsListener.js +0 -18
  193. package/dist/cjs/client.js +0 -93
  194. package/dist/cjs/components/App.js +0 -32
  195. package/dist/cjs/components/App.spec.js +0 -16
  196. package/dist/cjs/components/Button.js +0 -32
  197. package/dist/cjs/components/ChaynsModuleProvider.js +0 -457
  198. package/dist/cjs/components/ChaynsProviderExposed.js +0 -16
  199. package/dist/cjs/components/TestProvider.js +0 -236
  200. package/dist/cjs/components/Title.js +0 -162
  201. package/dist/cjs/functions/addApiListener.js +0 -37
  202. package/dist/cjs/functions/addGeoLocationListener.js +0 -26
  203. package/dist/cjs/functions/addScrollListener.js +0 -26
  204. package/dist/cjs/functions/addWindowMetricsListener.js +0 -37
  205. package/dist/cjs/helper/cssLoader.js +0 -28
  206. package/dist/cjs/hooks/addGeoLocationListener.js +0 -26
  207. package/dist/cjs/hooks/addScrollListener.js +0 -26
  208. package/dist/cjs/hooks/addWindowMetricsListener.js +0 -37
  209. package/dist/cjs/hooks/geoLocation.js +0 -48
  210. package/dist/cjs/hooks/useAddGeoLocationListener.js +0 -26
  211. package/dist/cjs/hooks/useAddScrollListener.js +0 -48
  212. package/dist/cjs/hooks/useAddWindowMetricsListener.js +0 -45
  213. package/dist/cjs/hooks/useAdddScrollListener.js +0 -26
  214. package/dist/cjs/hooks/windowMetrics.js +0 -45
  215. package/dist/cjs/host/HostIframe.js +0 -157
  216. package/dist/cjs/host/ModuleHost.js +0 -11
  217. package/dist/cjs/host/module/utils.js +0 -25
  218. package/dist/cjs/index.example.js +0 -7
  219. package/dist/cjs/index2.js +0 -64
  220. package/dist/cjs/types/DynamicApiImport.d.js +0 -5
  221. package/dist/cjs/types/DynamicImport.d.js +0 -5
  222. package/dist/cjs/types/chayns-components.d.js +0 -1
  223. package/dist/cjs/types/chayns-logger.d.js +0 -1
  224. package/dist/cjs/types/chayns.d.js +0 -1
  225. package/dist/cjs/types/tobit-websocket-service-client.d.js +0 -1
  226. package/dist/cjs/types/toolkit-types.d.js +0 -1
  227. package/dist/cjs/util/useFunctionsContext.js +0 -16
  228. package/dist/cjs/util/useIsAdminMode.js +0 -18
  229. package/dist/cjs/util/useUser.js +0 -16
  230. package/dist/esm/bootstrap.js +0 -4
  231. package/dist/esm/client.js +0 -8
  232. package/dist/esm/components/App.js +0 -35
  233. package/dist/esm/components/App.spec.js +0 -9
  234. package/dist/esm/components/Button.js +0 -34
  235. package/dist/esm/components/ChaynsModuleProvider.js +0 -517
  236. package/dist/esm/components/ChaynsProviderExposed.js +0 -3
  237. package/dist/esm/components/TestProvider.js +0 -308
  238. package/dist/esm/components/Title.js +0 -210
  239. package/dist/esm/helper/cssLoader.js +0 -21
  240. package/dist/esm/hooks/useAddGeoLocationListener.js +0 -18
  241. package/dist/esm/hooks/useAddScrollListener.js +0 -18
  242. package/dist/esm/hooks/useAddWindowMetricsListener.js +0 -18
  243. package/dist/esm/host/HostIframe.js +0 -153
  244. package/dist/esm/index.example.js +0 -1
  245. package/dist/esm/index2.js +0 -5
  246. package/dist/esm/types/DynamicApiImport.d.js +0 -1
  247. package/dist/esm/types/DynamicImport.d.js +0 -1
  248. package/dist/esm/types/chayns-components.d.js +0 -0
  249. package/dist/esm/types/chayns-logger.d.js +0 -0
  250. package/dist/esm/types/chayns.d.js +0 -0
  251. package/dist/esm/types/tobit-websocket-service-client.d.js +0 -0
  252. package/dist/esm/types/toolkit-types.d.js +0 -0
  253. package/dist/esm/util/useIsAdminMode.js +0 -9
  254. package/dist/esm/util/useUser.js +0 -7
  255. package/dist/types/bootstrap.d.ts +0 -1
  256. package/dist/types/client.d.ts +0 -7
  257. package/dist/types/components/App.d.ts +0 -5
  258. package/dist/types/components/Button.d.ts +0 -8
  259. package/dist/types/components/ChaynsModuleProvider.d.ts +0 -170
  260. package/dist/types/components/ChaynsProviderExposed.d.ts +0 -13
  261. package/dist/types/components/Title.d.ts +0 -3
  262. package/dist/types/host/HostIframe.d.ts +0 -20
  263. package/dist/types/index.example.d.ts +0 -0
@@ -1,6 +1,6 @@
1
1
  import { open } from './open';
2
2
  import { getCallbackName } from './utils/callback';
3
- export var buttonText = {
3
+ export const buttonText = {
4
4
  'YES': {
5
5
  'de': 'Ja',
6
6
  'en': 'Yes',
@@ -19,12 +19,12 @@ export var buttonText = {
19
19
  'nl': 'Annuleren'
20
20
  }['de'] || 'Cancel'
21
21
  };
22
- export var buttonType = {
22
+ export const buttonType = {
23
23
  'CANCEL': -1,
24
24
  'NEGATIVE': 0,
25
25
  'POSITIVE': 1
26
26
  };
27
- export var dialogAction = {
27
+ export const dialogAction = {
28
28
  'ALERT_CONFIRM': 178,
29
29
  'INPUT': 173,
30
30
  'SELECT': 174,
@@ -37,16 +37,12 @@ export var dialogAction = {
37
37
  'IFRAME': 191
38
38
  };
39
39
  export function chaynsDialog(config) {
40
- var callbackName = 'chaynsDialog';
40
+ const callbackName = 'chaynsDialog';
41
41
  config.callback = getCallbackName(callbackName);
42
-
43
42
  if (config.dialog) {
44
- config.dialog.callType = dialogAction.ALERT_CONFIRM; // @ts-ignore
45
-
46
- return open(config.dialog).then(function (data) {
47
- return Promise.resolve(data.selection ? data : data.buttonType);
48
- });
43
+ config.dialog.callType = dialogAction.ALERT_CONFIRM;
44
+ // @ts-ignore
45
+ return open(config.dialog).then(data => Promise.resolve(data.selection ? data : data.buttonType));
49
46
  }
50
-
51
47
  return "unsupported";
52
48
  }
@@ -1,77 +1,66 @@
1
1
  // @ts-nocheck
2
+
2
3
  import { invokeDialogCall } from "../index";
3
4
  export function sendData(data, isApiEvent) {
4
5
  return invokeDialogCall({
5
6
  action: 218,
6
7
  value: {
7
- data: data,
8
- isApiEvent: isApiEvent
8
+ data,
9
+ isApiEvent
9
10
  }
10
11
  });
11
12
  }
12
- var listeners = [];
13
- var apiListeners = [];
14
-
13
+ const listeners = [];
14
+ const apiListeners = [];
15
15
  function _dialogDataListener() {
16
- var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
17
-
16
+ let e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
18
17
  if (!e.data || !e.data.action && typeof e.data !== 'string') {
19
18
  return;
20
19
  }
21
-
22
- var messageObj = e.data.action ? e.data : JSON.parse(e.data.match(/(\{(?:.*)\})/)[0]);
23
-
20
+ const messageObj = e.data.action ? e.data : JSON.parse(e.data.match(/(\{(?:.*)\})/)[0]);
24
21
  if (messageObj.action === 218) {
25
- var data = messageObj.value.data;
26
-
22
+ const {
23
+ data
24
+ } = messageObj.value;
27
25
  if (messageObj.value.isApiEvent) {
28
- apiListeners.forEach(function (listener) {
26
+ apiListeners.forEach(listener => {
29
27
  listener(data);
30
28
  });
31
29
  } else {
32
- listeners.forEach(function (listener) {
30
+ listeners.forEach(listener => {
33
31
  listener(data);
34
32
  });
35
33
  }
36
34
  }
37
35
  }
38
-
39
36
  export function addDialogDataListener(callback) {
40
- var getApiEvents = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
41
-
37
+ let getApiEvents = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
42
38
  if (listeners.length === 0 || apiListeners.length === 0) {
43
39
  window.addEventListener('message', _dialogDataListener);
44
40
  }
45
-
46
41
  if (getApiEvents) {
47
42
  apiListeners.push(callback);
48
43
  } else {
49
44
  listeners.push(callback);
50
45
  }
51
-
52
46
  return true;
53
47
  }
54
48
  export function removeDialogDataListener(callback) {
55
- var getApiEvents = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
56
- var index;
57
-
49
+ let getApiEvents = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
50
+ let index;
58
51
  if (getApiEvents) {
59
52
  index = apiListeners.indexOf(callback);
60
-
61
53
  if (index !== -1) {
62
54
  apiListeners.splice(index, 1);
63
55
  }
64
56
  } else {
65
57
  index = listeners.indexOf(callback);
66
-
67
58
  if (index !== -1) {
68
59
  listeners.splice(index, 1);
69
60
  }
70
61
  }
71
-
72
62
  if (listeners.length === 0 && apiListeners.length === 0) {
73
63
  window.removeEventListener('message', _dialogDataListener);
74
64
  }
75
-
76
65
  return index !== -1;
77
66
  }
@@ -1,16 +1,14 @@
1
1
  import { buttonText, buttonType, chaynsDialog } from './chaynsDialog';
2
2
  export function confirm() {
3
- var title = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
4
- var message = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
5
- var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
6
-
3
+ let title = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
4
+ let message = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
5
+ let config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
7
6
  // backward compatibility
8
7
  if (Array.isArray(config)) {
9
8
  config = {
10
9
  'buttons': config
11
10
  };
12
11
  }
13
-
14
12
  if (!config.buttons || !Array.isArray(config.buttons)) {
15
13
  config.buttons = [{
16
14
  'text': buttonText.YES,
@@ -20,11 +18,10 @@ export function confirm() {
20
18
  'buttonType': buttonType.NEGATIVE
21
19
  }];
22
20
  }
23
-
24
21
  return chaynsDialog({
25
22
  'dialog': {
26
- title: title,
27
- message: message,
23
+ title,
24
+ message,
28
25
  'buttons': config.buttons,
29
26
  'links': config.links,
30
27
  'select': config.select
@@ -2,113 +2,115 @@ import { buttonText, buttonType, dialogAction } from './chaynsDialog';
2
2
  import { isDate, isNumber, isObject } from './utils/is';
3
3
  import { open } from './open';
4
4
  import { getDevice } from "../index";
5
- /**
6
- * The config object for date dialog
7
- * @typedef {Object} dateConfig
8
- * @property {Date} preSelect - The date object which should be preselected.
9
- * @property {Date} minDate - The min date which you could select.
10
- * @property {Date} maxDate - The max date which you could select.
11
- * @property {dateDialogType} dateType - The type of dialog you want to display.
12
- * @property {number} minuteIntervall - The interval for special minutes, possible are 2, 3, 4, 5, 6, 12, 15, 20, 30. Default is 1.
13
- * @property {string} message - The message that is displayed above the date dialog, only in apps supported
14
- * @property {string} title - The title that is displayed above the message, only in apps supported
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
15
16
  */
16
17
 
17
- /**
18
- * This call will open a date select dialog.
19
- * <div>Call: 30</div>
20
- * @param {dateConfig} config - Define the configuration of this call
21
- * @return {Promise} contains a timestamp as result
22
- * @example chayns.dialog.date({
23
- * 'dateType': chayns.dialog.dateType.DATE_TIME,
24
- * 'preSelect': new Date(2018, 6, 14, 0, 0, 0),
25
- * 'minDate': new Date(2018, 6, 1, 15, 0, 0),
26
- * 'maxDate': new Date(2019, 6, 1, 0, 23, 0),
27
- * 'minuteInterval': 15
28
- * ).then(function (data) {
29
- * console.log(data);
30
- * });
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
+ * });
31
32
  */
32
33
 
33
34
  export function date() {
34
- var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
35
- var preSelect = config.preSelect,
36
- minDate = config.minDate,
37
- maxDate = config.maxDate,
38
- title = config.title,
39
- message = config.message,
40
- minuteInterval = config.minuteInterval,
41
- autoSelectDate = config.autoSelectDate,
42
- type = config.dateType || dateType.DATE; // This will fix the iOS problem with not preselectedDate without user interaction. That it return the wrog time.
43
-
44
- var _getDevice = getDevice(),
45
- os = _getDevice.os,
46
- app = _getDevice.app;
47
-
35
+ let config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
36
+ let {
37
+ preSelect,
38
+ minDate,
39
+ maxDate,
40
+ title,
41
+ message,
42
+ minuteInterval,
43
+ autoSelectDate
44
+ } = config,
45
+ type = config.dateType || dateType.DATE;
46
+
47
+ // This will fix the iOS problem with not preselectedDate without user interaction. That it return the wrog time.
48
+ const {
49
+ os,
50
+ app
51
+ } = getDevice();
48
52
  if (minuteInterval && minuteInterval > 1 && os === 'iOS' && app) {
49
53
  preSelect = roundInterval(preSelect, minuteInterval);
50
54
  } else {
51
55
  preSelect = validateValue(preSelect);
52
56
  }
53
-
54
57
  minDate = validateValue(minDate);
55
58
  maxDate = validateValue(maxDate);
56
- var buttons = [];
59
+ let buttons = [];
57
60
  buttons = [{
58
61
  'text': buttonText.OK,
59
62
  'buttonType': buttonType.POSITIVE
60
63
  }];
61
64
  return open({
62
65
  'callType': dialogAction.DATE,
63
- type: type,
66
+ type,
64
67
  'selectedDate': preSelect,
65
- minDate: minDate,
66
- maxDate: maxDate,
67
- title: title,
68
- message: message,
69
- buttons: buttons,
70
- minuteInterval: minuteInterval,
71
- autoSelectDate: autoSelectDate
72
- }).then(function (data) {
68
+ minDate,
69
+ maxDate,
70
+ title,
71
+ message,
72
+ buttons,
73
+ minuteInterval,
74
+ autoSelectDate
75
+ }).then(data => {
73
76
  // @ts-ignore
74
77
  return Promise.resolve(data.selectedDate);
75
78
  });
76
79
  }
77
80
  export function advancedDate() {
78
- var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
79
- var preSelect = config.preSelect,
80
- minDate = config.minDate,
81
- maxDate = config.maxDate,
82
- title = config.title,
83
- message = config.message,
84
- minuteInterval = config.minuteInterval,
85
- buttons = config.buttons,
86
- multiselect = config.multiselect,
87
- disabledDates = config.disabledDates,
88
- textBlocks = config.textBlocks,
89
- monthSelect = config.monthSelect,
90
- yearSelect = config.yearSelect,
91
- interval = config.interval,
92
- maxInterval = config.maxInterval,
93
- minInterval = config.minInterval,
94
- disabledIntervals = config.disabledIntervals,
95
- disabledWeekDayIntervals = config.disabledWeekDayIntervals,
96
- getLocalTime = config.getLocalTime,
97
- autoSelectDate = config.autoSelectDate,
98
- type = config.dateType || dateType.DATE;
81
+ let config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
82
+ let {
83
+ preSelect,
84
+ minDate,
85
+ maxDate,
86
+ title,
87
+ message,
88
+ minuteInterval,
89
+ buttons,
90
+ multiselect,
91
+ disabledDates,
92
+ textBlocks,
93
+ monthSelect,
94
+ yearSelect,
95
+ interval,
96
+ maxInterval,
97
+ minInterval,
98
+ disabledIntervals,
99
+ disabledWeekDayIntervals,
100
+ getLocalTime,
101
+ autoSelectDate
102
+ } = config,
103
+ // minInterval and maxInterval in minutes
104
+ type = config.dateType || dateType.DATE;
99
105
  minDate = validateValue(minDate);
100
106
  maxDate = validateValue(maxDate);
101
-
102
- var _getDevice2 = getDevice(),
103
- os = _getDevice2.os,
104
- app = _getDevice2.app;
105
-
107
+ const {
108
+ os,
109
+ app
110
+ } = getDevice();
106
111
  if (!preSelect) preSelect = {};
107
-
108
112
  if (Array.isArray(preSelect)) {
109
- preSelect = preSelect.map(function (p) {
110
- return validateValue(p);
111
- });
113
+ preSelect = preSelect.map(p => validateValue(p));
112
114
  } else if (isObject(preSelect)) {
113
115
  if (preSelect.start && preSelect.end) {
114
116
  if (minuteInterval && minuteInterval > 1 && os === 'iOS' && app) {
@@ -126,84 +128,74 @@ export function advancedDate() {
126
128
  preSelect = validateValue(preSelect);
127
129
  }
128
130
  }
129
-
130
131
  if (Array.isArray(disabledDates)) {
131
- disabledDates = disabledDates.map(function (d) {
132
- return validateValue(d);
133
- });
132
+ disabledDates = disabledDates.map(d => validateValue(d));
134
133
  }
135
-
136
134
  if (!buttons || !Array.isArray(buttons)) {
137
135
  buttons = [{
138
136
  'text': buttonText.OK,
139
137
  'buttonType': buttonType.POSITIVE
140
138
  }];
141
139
  }
142
-
143
140
  return open({
144
141
  'callType': dialogAction.ADVANCED_DATE,
145
- type: type,
142
+ type,
146
143
  'selectedDate': Array.isArray(preSelect) ? undefined : preSelect,
147
- minDate: minDate,
148
- maxDate: maxDate,
149
- title: title,
150
- message: message,
151
- minuteInterval: minuteInterval,
152
- buttons: buttons,
153
- multiselect: multiselect,
144
+ minDate,
145
+ maxDate,
146
+ title,
147
+ message,
148
+ minuteInterval,
149
+ buttons,
150
+ multiselect,
154
151
  'selectedDates': Array.isArray(preSelect) ? preSelect : undefined,
155
- disabledDates: disabledDates,
156
- textBlocks: textBlocks,
157
- monthSelect: monthSelect,
158
- yearSelect: yearSelect,
159
- interval: interval,
160
- minInterval: minInterval,
161
- maxInterval: maxInterval,
162
- disabledIntervals: disabledIntervals,
163
- disabledWeekDayIntervals: disabledWeekDayIntervals,
164
- getLocalTime: getLocalTime,
165
- autoSelectDate: autoSelectDate
166
- }).then(function (data) {
152
+ disabledDates,
153
+ textBlocks,
154
+ monthSelect,
155
+ yearSelect,
156
+ interval,
157
+ minInterval,
158
+ maxInterval,
159
+ disabledIntervals,
160
+ disabledWeekDayIntervals,
161
+ getLocalTime,
162
+ autoSelectDate
163
+ }).then(data => {
167
164
  return Promise.resolve(data);
168
165
  });
169
166
  }
170
- /**
171
- * @typedef {number} dateDialogType
172
- */
173
167
 
174
- /**
175
- * Enum for date dialog
176
- * <div>DATE will open a dialog where you can select a special day</div>
177
- * <div>TIME will open a dialog where you can only select a special time</div>
178
- * <div>DATE_TIME will open a dialog where you can select a special time on a special day</div>
179
- * @readonly
180
- * @enum {dateDialogType}
181
- * @type {{DATE: number, TIME: number, DATE_TIME: number}}
168
+ /**
169
+ * @typedef {number} dateDialogType
182
170
  */
183
171
 
184
- export var dateType = {
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
+ */
181
+ export const dateType = {
185
182
  'DATE': 1,
186
183
  'TIME': 2,
187
184
  'DATE_TIME': 3
188
185
  };
189
-
190
186
  function validateValue(value) {
191
187
  if (!isNumber(value)) {
192
188
  if (isDate(value)) {
193
189
  // TODO: Find out whats the purpose of parsing to int
194
190
  return parseInt(value.getTime() / 1000 + "", 10);
195
191
  }
196
-
197
192
  return undefined;
198
193
  }
199
-
200
194
  return value;
201
195
  }
202
-
203
196
  function roundInterval() {
204
- var preDate = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Date();
205
- var interval = arguments.length > 1 ? arguments[1] : undefined;
206
-
197
+ let preDate = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Date();
198
+ let interval = arguments.length > 1 ? arguments[1] : undefined;
207
199
  if (!isDate(preDate)) {
208
200
  if (isNumber(preDate)) {
209
201
  preDate = new Date(preDate);
@@ -211,10 +203,9 @@ function roundInterval() {
211
203
  return -1;
212
204
  }
213
205
  }
214
-
215
- var minutes = preDate.getMinutes();
206
+ let minutes = preDate.getMinutes();
216
207
  preDate.setMinutes(minutes - minutes % interval);
217
- preDate.setSeconds(0); // TODO: Why?
218
-
208
+ preDate.setSeconds(0);
209
+ // TODO: Why?
219
210
  return parseInt(preDate.getTime() / 1000 + "", 10);
220
211
  }
@@ -1,7 +1,7 @@
1
1
  import { open } from './open';
2
2
  import { dialogAction } from './chaynsDialog';
3
3
  export function dropUpAlert() {
4
- var dialog = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4
+ let dialog = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
5
5
  dialog.callType = dialogAction.DROP_UP_ALERT;
6
6
  return open(dialog);
7
7
  }
@@ -1,71 +1,32 @@
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
1
  import { buttonText, buttonType, dialogAction } from './chaynsDialog';
6
2
  import { open } from './open';
7
3
  import { getAccessToken, getUser, login } from "../index";
8
- export var fileType = {
4
+ export const fileType = {
9
5
  'IMAGE': 'image',
10
6
  'VIDEO': 'video',
11
7
  'AUDIO': 'audio',
12
8
  'DOCUMENT': ['application/x-latex', 'application/x-tex', 'text/', 'application/json', 'application/pdf', 'application/msword', 'application/msexcel', 'application/mspowerpoint', 'application/vnd.ms-word', 'application/vnd.ms-excel', 'application/vnd.ms-powerpoint', 'application/vnd.openxmlformats-officedocument', 'application/vnd.oasis.opendocument']
13
9
  };
14
- export function fileSelect() {
15
- return _fileSelect.apply(this, arguments);
16
- }
17
-
18
- function _fileSelect() {
19
- _fileSelect = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
20
- var dialog,
21
- user,
22
- _args = arguments;
23
- return regeneratorRuntime.wrap(function _callee$(_context) {
24
- while (1) {
25
- switch (_context.prev = _context.next) {
26
- case 0:
27
- dialog = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
28
-
29
- if (!dialog.buttons || !Array.isArray(dialog.buttons)) {
30
- dialog.buttons = [];
31
-
32
- if (dialog.multiselect || dialog.directory) {
33
- dialog.buttons.push({
34
- 'text': buttonText.OK,
35
- 'buttonType': buttonType.POSITIVE
36
- });
37
- }
38
-
39
- dialog.buttons.push({
40
- 'text': buttonText.CANCEL,
41
- 'buttonType': buttonType.NEGATIVE
42
- });
43
- }
44
-
45
- dialog.callType = dialogAction.FILE_SELECT;
46
- user = getUser();
47
-
48
- if (user) {
49
- _context.next = 6;
50
- break;
51
- }
52
-
53
- return _context.abrupt("return", login());
54
-
55
- case 6:
56
- _context.next = 8;
57
- return getAccessToken();
58
-
59
- case 8:
60
- dialog.chaynsToken = _context.sent.accessToken;
61
- return _context.abrupt("return", open(dialog));
62
-
63
- case 10:
64
- case "end":
65
- return _context.stop();
66
- }
67
- }
68
- }, _callee);
69
- }));
70
- return _fileSelect.apply(this, arguments);
10
+ export async function fileSelect() {
11
+ let dialog = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
12
+ if (!dialog.buttons || !Array.isArray(dialog.buttons)) {
13
+ dialog.buttons = [];
14
+ if (dialog.multiselect || dialog.directory) {
15
+ dialog.buttons.push({
16
+ 'text': buttonText.OK,
17
+ 'buttonType': buttonType.POSITIVE
18
+ });
19
+ }
20
+ dialog.buttons.push({
21
+ 'text': buttonText.CANCEL,
22
+ 'buttonType': buttonType.NEGATIVE
23
+ });
24
+ }
25
+ dialog.callType = dialogAction.FILE_SELECT;
26
+ const user = getUser();
27
+ if (!user) {
28
+ return login();
29
+ }
30
+ dialog.chaynsToken = (await getAccessToken()).accessToken;
31
+ return open(dialog);
71
32
  }
@@ -3,10 +3,9 @@ import { open } from './open';
3
3
  import { addDialogDataListener, sendData } from './communication';
4
4
  import { getSite, invokeDialogCall } from "../index";
5
5
  export function iFrame() {
6
- var dialog = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
6
+ let dialog = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
7
7
  url: ""
8
8
  };
9
-
10
9
  if (!dialog.buttons || !Array.isArray(dialog.buttons)) {
11
10
  dialog.buttons = [{
12
11
  'text': buttonText.YES,
@@ -16,22 +15,20 @@ export function iFrame() {
16
15
  'buttonType': buttonType.NEGATIVE
17
16
  }];
18
17
  }
19
-
20
18
  dialog.tappIframeName = window.name;
21
19
  dialog.callType = dialogAction.IFRAME;
22
- var site = getSite();
23
- dialog.url = "".concat(dialog.url).concat(dialog.url.indexOf('?') >= 0 ? '&' : '?', "siteId=").concat(site.id);
20
+ const site = getSite();
21
+ dialog.url = `${dialog.url}${dialog.url.indexOf('?') >= 0 ? '&' : '?'}siteId=${site.id}`;
24
22
  addDialogDataListener(_chaynsCallResponder, true);
25
23
  return open(dialog);
26
24
  }
27
25
  export function _chaynsCallResponder(obj) {
28
26
  if (obj.call.value.callback) {
29
- var call = JSON.parse(JSON.stringify(obj)); // deep copy
30
-
31
- invokeDialogCall(obj).then(function (result) {
27
+ const call = JSON.parse(JSON.stringify(obj)); // deep copy
28
+ invokeDialogCall(obj).then(result => {
32
29
  sendData({
33
- result: result,
34
- call: call
30
+ result,
31
+ call
35
32
  }, true);
36
33
  });
37
34
  } else {
@@ -1,8 +1,7 @@
1
1
  import { buttonText, buttonType, dialogAction } from './chaynsDialog';
2
2
  import { open } from './open';
3
3
  export function input() {
4
- var dialog = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
5
-
4
+ let dialog = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
6
5
  if (!dialog.buttons || !Array.isArray(dialog.buttons)) {
7
6
  dialog.buttons = [{
8
7
  'text': buttonText.YES,
@@ -12,15 +11,13 @@ export function input() {
12
11
  'buttonType': buttonType.NEGATIVE
13
12
  }];
14
13
  }
15
-
16
14
  if (dialog.formatter) {
17
15
  dialog.formatter = dialog.formatter.toString();
18
16
  }
19
-
20
17
  dialog.callType = dialogAction.INPUT;
21
18
  return open(dialog);
22
19
  }
23
- export var inputType = {
20
+ export const inputType = {
24
21
  'DEFAULT': 0,
25
22
  'PASSWORD': 1,
26
23
  'TEXTAREA': 2,