chayns-api 1.0.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 (211) hide show
  1. package/dist/cjs/calls/dialogs/alert.js +0 -2
  2. package/dist/cjs/calls/dialogs/chaynsDialog.js +2 -8
  3. package/dist/cjs/calls/dialogs/close.js +0 -2
  4. package/dist/cjs/calls/dialogs/communication.js +1 -16
  5. package/dist/cjs/calls/dialogs/confirm.js +0 -4
  6. package/dist/cjs/calls/dialogs/date.js +36 -53
  7. package/dist/cjs/calls/dialogs/dropUpAlert.js +0 -3
  8. package/dist/cjs/calls/dialogs/fileSelect.js +0 -10
  9. package/dist/cjs/calls/dialogs/iFrame.js +0 -8
  10. package/dist/cjs/calls/dialogs/index.js +0 -27
  11. package/dist/cjs/calls/dialogs/input.js +0 -6
  12. package/dist/cjs/calls/dialogs/mediaSelect.js +0 -7
  13. package/dist/cjs/calls/dialogs/open.js +0 -2
  14. package/dist/cjs/calls/dialogs/select.js +0 -9
  15. package/dist/cjs/calls/dialogs/signature.js +0 -5
  16. package/dist/cjs/calls/dialogs/toast.js +0 -3
  17. package/dist/cjs/calls/dialogs/utils/callback.js +0 -2
  18. package/dist/cjs/calls/dialogs/utils/environment.js +10 -0
  19. package/dist/cjs/calls/dialogs/utils/is.js +0 -4
  20. package/dist/cjs/calls/getUserInfo.js +0 -11
  21. package/dist/cjs/calls/index.js +3 -155
  22. package/dist/cjs/calls/sendMessage.js +0 -26
  23. package/dist/cjs/calls/visibilityChangeListener.js +1 -12
  24. package/dist/cjs/components/ChaynsContext.js +2 -4
  25. package/dist/cjs/components/ChaynsProvider.js +6 -28
  26. package/dist/cjs/components/WaitUntil.js +0 -5
  27. package/dist/cjs/components/withCompatMode.js +1 -16
  28. package/dist/cjs/helper/apiListenerHelper.js +0 -9
  29. package/dist/cjs/hooks/geoLocationListener.js +2 -11
  30. package/dist/cjs/hooks/index.js +6 -16
  31. package/dist/cjs/hooks/scrollListener.js +4 -23
  32. package/dist/cjs/hooks/useAccessToken.js +0 -5
  33. package/dist/cjs/hooks/useCurrentPage.js +0 -4
  34. package/dist/cjs/hooks/useCustomData.js +0 -4
  35. package/dist/cjs/hooks/useDevice.js +0 -4
  36. package/dist/cjs/hooks/useEnvironment.js +0 -4
  37. package/dist/cjs/hooks/useFunctions.js +0 -4
  38. package/dist/cjs/hooks/useIsAdminMode.js +0 -5
  39. package/dist/cjs/hooks/useLanguage.js +0 -4
  40. package/dist/cjs/hooks/usePages.js +22 -14
  41. package/dist/cjs/hooks/useParameters.js +0 -4
  42. package/dist/cjs/hooks/useSite.js +0 -4
  43. package/dist/cjs/hooks/useUser.js +0 -5
  44. package/dist/cjs/hooks/useValues.js +0 -4
  45. package/dist/cjs/hooks/windowMetricsListener.js +2 -12
  46. package/dist/cjs/host/ChaynsHost.js +0 -10
  47. package/dist/cjs/host/iframe/HostIframe.js +23 -30
  48. package/dist/cjs/host/iframe/utils/useUpdateData.js +0 -3
  49. package/dist/cjs/host/module/ModuleHost.js +3 -13
  50. package/dist/cjs/host/{HostIframe.js → module/PagemakerFrame.js} +23 -75
  51. package/dist/cjs/host/module/utils/loadComponent.js +1 -18
  52. package/dist/cjs/host/module/utils/useDynamicScript.js +0 -18
  53. package/dist/cjs/index.js +0 -19
  54. package/dist/cjs/types/IChaynsReact.js +27 -48
  55. package/dist/cjs/util/appCall.js +1 -4
  56. package/dist/cjs/util/deviceHelper.js +4 -21
  57. package/dist/cjs/util/heightHelper.js +0 -9
  58. package/dist/cjs/util/postIframeForm.js +0 -5
  59. package/dist/cjs/wrapper/AppWrapper.js +318 -159
  60. package/dist/cjs/wrapper/FrameWrapper.js +215 -248
  61. package/dist/cjs/wrapper/ModuleFederationWrapper.js +2 -27
  62. package/dist/cjs/wrapper/SsrWrapper.js +0 -8
  63. package/dist/esm/calls/dialogs/alert.js +4 -4
  64. package/dist/esm/calls/dialogs/chaynsDialog.js +7 -11
  65. package/dist/esm/calls/dialogs/communication.js +15 -26
  66. package/dist/esm/calls/dialogs/confirm.js +5 -8
  67. package/dist/esm/calls/dialogs/date.js +85 -94
  68. package/dist/esm/calls/dialogs/dropUpAlert.js +1 -1
  69. package/dist/esm/calls/dialogs/fileSelect.js +23 -62
  70. package/dist/esm/calls/dialogs/iFrame.js +7 -10
  71. package/dist/esm/calls/dialogs/input.js +2 -5
  72. package/dist/esm/calls/dialogs/mediaSelect.js +18 -55
  73. package/dist/esm/calls/dialogs/open.js +2 -2
  74. package/dist/esm/calls/dialogs/select.js +5 -9
  75. package/dist/esm/calls/dialogs/signature.js +0 -2
  76. package/dist/esm/calls/dialogs/toast.js +6 -11
  77. package/dist/esm/calls/dialogs/utils/callback.js +3 -5
  78. package/dist/esm/calls/dialogs/utils/environment.js +3 -0
  79. package/dist/esm/calls/dialogs/utils/is.js +1 -3
  80. package/dist/esm/calls/getUserInfo.js +32 -92
  81. package/dist/esm/calls/index.js +124 -276
  82. package/dist/esm/calls/sendMessage.js +91 -221
  83. package/dist/esm/calls/visibilityChangeListener.js +10 -15
  84. package/dist/esm/components/ChaynsContext.js +3 -3
  85. package/dist/esm/components/ChaynsProvider.js +45 -86
  86. package/dist/esm/components/WaitUntil.js +21 -86
  87. package/dist/esm/components/withCompatMode.js +35 -77
  88. package/dist/esm/helper/apiListenerHelper.js +10 -15
  89. package/dist/esm/hooks/geoLocationListener.js +20 -46
  90. package/dist/esm/hooks/index.js +1 -1
  91. package/dist/esm/hooks/scrollListener.js +50 -86
  92. package/dist/esm/hooks/useAccessToken.js +6 -28
  93. package/dist/esm/hooks/useCurrentPage.js +2 -6
  94. package/dist/esm/hooks/useCustomData.js +2 -6
  95. package/dist/esm/hooks/useDevice.js +1 -6
  96. package/dist/esm/hooks/useEnvironment.js +1 -6
  97. package/dist/esm/hooks/useFunctions.js +2 -5
  98. package/dist/esm/hooks/useIsAdminMode.js +2 -6
  99. package/dist/esm/hooks/useLanguage.js +1 -6
  100. package/dist/esm/hooks/usePages.js +34 -27
  101. package/dist/esm/hooks/useParameters.js +1 -6
  102. package/dist/esm/hooks/useSite.js +1 -6
  103. package/dist/esm/hooks/useUser.js +1 -7
  104. package/dist/esm/hooks/useValues.js +2 -5
  105. package/dist/esm/hooks/windowMetricsListener.js +18 -44
  106. package/dist/esm/host/ChaynsHost.js +22 -29
  107. package/dist/esm/host/iframe/HostIframe.js +86 -142
  108. package/dist/esm/host/iframe/utils/useUpdateData.js +4 -6
  109. package/dist/esm/host/module/ModuleHost.js +42 -49
  110. package/dist/esm/host/module/PagemakerFrame.js +97 -0
  111. package/dist/esm/host/module/utils/loadComponent.js +47 -85
  112. package/dist/esm/host/module/utils/useDynamicScript.js +27 -74
  113. package/dist/esm/types/IChaynsReact.js +37 -61
  114. package/dist/esm/util/appCall.js +2 -4
  115. package/dist/esm/util/deviceHelper.js +12 -36
  116. package/dist/esm/util/heightHelper.js +10 -13
  117. package/dist/esm/util/postIframeForm.js +25 -57
  118. package/dist/esm/wrapper/AppWrapper.js +380 -781
  119. package/dist/esm/wrapper/FrameWrapper.js +258 -1509
  120. package/dist/esm/wrapper/ModuleFederationWrapper.js +47 -284
  121. package/dist/esm/wrapper/SsrWrapper.js +19 -65
  122. package/dist/types/calls/dialogs/confirm.d.ts +1 -1
  123. package/dist/types/calls/dialogs/date.d.ts +4 -4
  124. package/dist/types/calls/dialogs/dropUpAlert.d.ts +1 -1
  125. package/dist/types/calls/dialogs/fileSelect.d.ts +1 -1
  126. package/dist/types/calls/dialogs/iFrame.d.ts +1 -1
  127. package/dist/types/calls/dialogs/input.d.ts +1 -1
  128. package/dist/types/calls/dialogs/mediaSelect.d.ts +1 -1
  129. package/dist/types/calls/dialogs/signature.d.ts +1 -1
  130. package/dist/types/calls/dialogs/utils/environment.d.ts +3 -0
  131. package/dist/types/calls/index.d.ts +0 -6
  132. package/dist/types/components/ChaynsProvider.d.ts +1 -1
  133. package/dist/types/components/WaitUntil.d.ts +1 -1
  134. package/dist/types/components/withCompatMode.d.ts +1 -1
  135. package/dist/types/hooks/index.d.ts +1 -1
  136. package/dist/types/hooks/useAccessToken.d.ts +1 -1
  137. package/dist/types/hooks/usePages.d.ts +4 -0
  138. package/dist/types/host/ChaynsHost.d.ts +1 -1
  139. package/dist/types/host/iframe/HostIframe.d.ts +1 -1
  140. package/dist/types/host/module/ModuleHost.d.ts +2 -2
  141. package/dist/types/host/{HostIframe.d.ts → module/PagemakerFrame.d.ts} +7 -5
  142. package/dist/types/types/IChaynsReact.d.ts +55 -24
  143. package/dist/types/util/deviceHelper.d.ts +2 -2
  144. package/dist/types/wrapper/AppWrapper.d.ts +6 -4
  145. package/package.json +1 -1
  146. package/dist/cjs/bootstrap.js +0 -11
  147. package/dist/cjs/calls/abstractApiListener.js +0 -40
  148. package/dist/cjs/calls/apiEventListener.js +0 -40
  149. package/dist/cjs/calls/setVisibilityChangeListener.js +0 -1
  150. package/dist/cjs/calls/windowMetricsListener.js +0 -18
  151. package/dist/cjs/components/App.js +0 -32
  152. package/dist/cjs/components/App.spec.js +0 -16
  153. package/dist/cjs/components/Button.js +0 -32
  154. package/dist/cjs/components/ChaynsProviderExposed.js +0 -16
  155. package/dist/cjs/components/TestProvider.js +0 -236
  156. package/dist/cjs/components/Title.js +0 -162
  157. package/dist/cjs/functions/addApiListener.js +0 -37
  158. package/dist/cjs/functions/addGeoLocationListener.js +0 -26
  159. package/dist/cjs/functions/addScrollListener.js +0 -26
  160. package/dist/cjs/functions/addWindowMetricsListener.js +0 -37
  161. package/dist/cjs/helper/cssLoader.js +0 -28
  162. package/dist/cjs/hooks/addGeoLocationListener.js +0 -26
  163. package/dist/cjs/hooks/addScrollListener.js +0 -26
  164. package/dist/cjs/hooks/addWindowMetricsListener.js +0 -37
  165. package/dist/cjs/hooks/geoLocation.js +0 -48
  166. package/dist/cjs/hooks/useAddGeoLocationListener.js +0 -26
  167. package/dist/cjs/hooks/useAddScrollListener.js +0 -48
  168. package/dist/cjs/hooks/useAddWindowMetricsListener.js +0 -45
  169. package/dist/cjs/hooks/useAdddScrollListener.js +0 -26
  170. package/dist/cjs/hooks/windowMetrics.js +0 -45
  171. package/dist/cjs/host/ModuleHost.js +0 -11
  172. package/dist/cjs/host/module/utils.js +0 -25
  173. package/dist/cjs/index.example.js +0 -7
  174. package/dist/cjs/index2.js +0 -64
  175. package/dist/cjs/types/DynamicImport.d.js +0 -5
  176. package/dist/cjs/types/chayns-components.d.js +0 -1
  177. package/dist/cjs/types/chayns-logger.d.js +0 -1
  178. package/dist/cjs/types/chayns.d.js +0 -1
  179. package/dist/cjs/types/tobit-websocket-service-client.d.js +0 -1
  180. package/dist/cjs/types/toolkit-types.d.js +0 -1
  181. package/dist/cjs/util/useFunctionsContext.js +0 -16
  182. package/dist/cjs/util/useIsAdminMode.js +0 -18
  183. package/dist/cjs/util/useUser.js +0 -16
  184. package/dist/esm/bootstrap.js +0 -4
  185. package/dist/esm/components/App.js +0 -35
  186. package/dist/esm/components/App.spec.js +0 -9
  187. package/dist/esm/components/Button.js +0 -34
  188. package/dist/esm/components/ChaynsProviderExposed.js +0 -3
  189. package/dist/esm/components/TestProvider.js +0 -308
  190. package/dist/esm/components/Title.js +0 -210
  191. package/dist/esm/helper/cssLoader.js +0 -21
  192. package/dist/esm/hooks/useAddGeoLocationListener.js +0 -18
  193. package/dist/esm/hooks/useAddScrollListener.js +0 -18
  194. package/dist/esm/hooks/useAddWindowMetricsListener.js +0 -18
  195. package/dist/esm/host/HostIframe.js +0 -153
  196. package/dist/esm/index.example.js +0 -1
  197. package/dist/esm/index2.js +0 -5
  198. package/dist/esm/types/DynamicImport.d.js +0 -1
  199. package/dist/esm/types/chayns-components.d.js +0 -0
  200. package/dist/esm/types/chayns-logger.d.js +0 -0
  201. package/dist/esm/types/chayns.d.js +0 -0
  202. package/dist/esm/types/tobit-websocket-service-client.d.js +0 -0
  203. package/dist/esm/types/toolkit-types.d.js +0 -0
  204. package/dist/esm/util/useIsAdminMode.js +0 -9
  205. package/dist/esm/util/useUser.js +0 -7
  206. package/dist/types/bootstrap.d.ts +0 -1
  207. package/dist/types/components/App.d.ts +0 -5
  208. package/dist/types/components/Button.d.ts +0 -8
  209. package/dist/types/components/ChaynsProviderExposed.d.ts +0 -13
  210. package/dist/types/components/Title.d.ts +0 -3
  211. 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,6 +2,7 @@ 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
+
5
6
  /**
6
7
  * The config object for date dialog
7
8
  * @typedef {Object} dateConfig
@@ -31,84 +32,85 @@ import { getDevice } from "../index";
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,47 +128,43 @@ 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
  }
167
+
170
168
  /**
171
169
  * @typedef {number} dateDialogType
172
170
  */
@@ -180,30 +178,24 @@ export function advancedDate() {
180
178
  * @enum {dateDialogType}
181
179
  * @type {{DATE: number, TIME: number, DATE_TIME: number}}
182
180
  */
183
-
184
- export var dateType = {
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,