chayns-api 1.0.0 → 1.0.1

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 (205) hide show
  1. package/dist/cjs/bootstrap.js +11 -0
  2. package/dist/cjs/calls/abstractApiListener.js +40 -0
  3. package/dist/cjs/calls/apiEventListener.js +40 -0
  4. package/dist/cjs/calls/dialogs/alert.js +2 -0
  5. package/dist/cjs/calls/dialogs/chaynsDialog.js +8 -2
  6. package/dist/cjs/calls/dialogs/close.js +2 -0
  7. package/dist/cjs/calls/dialogs/communication.js +16 -1
  8. package/dist/cjs/calls/dialogs/confirm.js +4 -0
  9. package/dist/cjs/calls/dialogs/date.js +53 -36
  10. package/dist/cjs/calls/dialogs/dropUpAlert.js +3 -0
  11. package/dist/cjs/calls/dialogs/fileSelect.js +10 -0
  12. package/dist/cjs/calls/dialogs/iFrame.js +8 -0
  13. package/dist/cjs/calls/dialogs/index.js +27 -0
  14. package/dist/cjs/calls/dialogs/input.js +6 -0
  15. package/dist/cjs/calls/dialogs/mediaSelect.js +7 -0
  16. package/dist/cjs/calls/dialogs/open.js +2 -0
  17. package/dist/cjs/calls/dialogs/select.js +9 -0
  18. package/dist/cjs/calls/dialogs/signature.js +5 -0
  19. package/dist/cjs/calls/dialogs/toast.js +3 -0
  20. package/dist/cjs/calls/dialogs/utils/callback.js +2 -0
  21. package/dist/cjs/calls/dialogs/utils/is.js +4 -0
  22. package/dist/cjs/calls/getUserInfo.js +11 -0
  23. package/dist/cjs/calls/index.js +155 -3
  24. package/dist/cjs/calls/sendMessage.js +26 -0
  25. package/dist/cjs/calls/setVisibilityChangeListener.js +1 -0
  26. package/dist/cjs/calls/visibilityChangeListener.js +12 -1
  27. package/dist/cjs/calls/windowMetricsListener.js +18 -0
  28. package/dist/cjs/components/App.js +32 -0
  29. package/dist/cjs/components/App.spec.js +16 -0
  30. package/dist/cjs/components/Button.js +32 -0
  31. package/dist/cjs/components/ChaynsContext.js +4 -2
  32. package/dist/cjs/components/ChaynsProvider.js +28 -6
  33. package/dist/cjs/components/ChaynsProviderExposed.js +16 -0
  34. package/dist/cjs/components/TestProvider.js +236 -0
  35. package/dist/cjs/components/Title.js +162 -0
  36. package/dist/cjs/components/WaitUntil.js +5 -0
  37. package/dist/cjs/components/withCompatMode.js +16 -1
  38. package/dist/cjs/functions/addApiListener.js +37 -0
  39. package/dist/cjs/functions/addGeoLocationListener.js +26 -0
  40. package/dist/cjs/functions/addScrollListener.js +26 -0
  41. package/dist/cjs/functions/addWindowMetricsListener.js +37 -0
  42. package/dist/cjs/helper/apiListenerHelper.js +9 -0
  43. package/dist/cjs/helper/cssLoader.js +28 -0
  44. package/dist/cjs/hooks/addGeoLocationListener.js +26 -0
  45. package/dist/cjs/hooks/addScrollListener.js +26 -0
  46. package/dist/cjs/hooks/addWindowMetricsListener.js +37 -0
  47. package/dist/cjs/hooks/geoLocation.js +48 -0
  48. package/dist/cjs/hooks/geoLocationListener.js +11 -2
  49. package/dist/cjs/hooks/index.js +16 -0
  50. package/dist/cjs/hooks/scrollListener.js +23 -4
  51. package/dist/cjs/hooks/useAccessToken.js +5 -0
  52. package/dist/cjs/hooks/useAddGeoLocationListener.js +26 -0
  53. package/dist/cjs/hooks/useAddScrollListener.js +48 -0
  54. package/dist/cjs/hooks/useAddWindowMetricsListener.js +45 -0
  55. package/dist/cjs/hooks/useAdddScrollListener.js +26 -0
  56. package/dist/cjs/hooks/useCurrentPage.js +4 -0
  57. package/dist/cjs/hooks/useCustomData.js +4 -0
  58. package/dist/cjs/hooks/useDevice.js +4 -0
  59. package/dist/cjs/hooks/useEnvironment.js +4 -0
  60. package/dist/cjs/hooks/useFunctions.js +4 -0
  61. package/dist/cjs/hooks/useIsAdminMode.js +5 -0
  62. package/dist/cjs/hooks/useLanguage.js +4 -0
  63. package/dist/cjs/hooks/usePages.js +12 -0
  64. package/dist/cjs/hooks/useParameters.js +4 -0
  65. package/dist/cjs/hooks/useSite.js +4 -0
  66. package/dist/cjs/hooks/useUser.js +4 -0
  67. package/dist/cjs/hooks/useValues.js +4 -0
  68. package/dist/cjs/hooks/windowMetrics.js +45 -0
  69. package/dist/cjs/hooks/windowMetricsListener.js +12 -2
  70. package/dist/cjs/host/ChaynsHost.js +12 -0
  71. package/dist/cjs/host/{module/PagemakerFrame.js → HostIframe.js} +75 -23
  72. package/dist/cjs/host/ModuleHost.js +11 -0
  73. package/dist/cjs/host/iframe/HostIframe.js +30 -23
  74. package/dist/cjs/host/iframe/utils/useUpdateData.js +3 -0
  75. package/dist/cjs/host/module/ModuleHost.js +13 -3
  76. package/dist/cjs/host/module/utils/loadComponent.js +18 -1
  77. package/dist/cjs/host/module/utils/useDynamicScript.js +18 -0
  78. package/dist/cjs/host/module/utils.js +25 -0
  79. package/dist/cjs/index.example.js +7 -0
  80. package/dist/cjs/index.js +19 -0
  81. package/dist/cjs/index2.js +64 -0
  82. package/dist/cjs/types/DynamicImport.d.js +5 -0
  83. package/dist/cjs/types/IChaynsReact.js +47 -0
  84. package/dist/cjs/types/chayns-components.d.js +1 -0
  85. package/dist/cjs/types/chayns-logger.d.js +1 -0
  86. package/dist/cjs/types/chayns.d.js +1 -0
  87. package/dist/cjs/types/tobit-websocket-service-client.d.js +1 -0
  88. package/dist/cjs/types/toolkit-types.d.js +1 -0
  89. package/dist/cjs/util/appCall.js +4 -1
  90. package/dist/cjs/util/deviceHelper.js +17 -2
  91. package/dist/cjs/util/heightHelper.js +9 -0
  92. package/dist/cjs/util/postIframeForm.js +5 -0
  93. package/dist/cjs/util/useFunctionsContext.js +16 -0
  94. package/dist/cjs/util/useIsAdminMode.js +18 -0
  95. package/dist/cjs/util/useUser.js +16 -0
  96. package/dist/cjs/wrapper/AppWrapper.js +144 -119
  97. package/dist/cjs/wrapper/FrameWrapper.js +248 -215
  98. package/dist/cjs/wrapper/ModuleFederationWrapper.js +27 -2
  99. package/dist/cjs/wrapper/SsrWrapper.js +8 -0
  100. package/dist/esm/bootstrap.js +4 -0
  101. package/dist/esm/calls/dialogs/alert.js +4 -4
  102. package/dist/esm/calls/dialogs/chaynsDialog.js +11 -7
  103. package/dist/esm/calls/dialogs/communication.js +26 -15
  104. package/dist/esm/calls/dialogs/confirm.js +8 -5
  105. package/dist/esm/calls/dialogs/date.js +94 -85
  106. package/dist/esm/calls/dialogs/dropUpAlert.js +1 -1
  107. package/dist/esm/calls/dialogs/fileSelect.js +62 -23
  108. package/dist/esm/calls/dialogs/iFrame.js +10 -7
  109. package/dist/esm/calls/dialogs/input.js +5 -2
  110. package/dist/esm/calls/dialogs/mediaSelect.js +55 -18
  111. package/dist/esm/calls/dialogs/open.js +2 -2
  112. package/dist/esm/calls/dialogs/select.js +9 -5
  113. package/dist/esm/calls/dialogs/signature.js +2 -0
  114. package/dist/esm/calls/dialogs/toast.js +11 -6
  115. package/dist/esm/calls/dialogs/utils/callback.js +5 -3
  116. package/dist/esm/calls/dialogs/utils/is.js +3 -1
  117. package/dist/esm/calls/getUserInfo.js +92 -32
  118. package/dist/esm/calls/index.js +276 -124
  119. package/dist/esm/calls/sendMessage.js +221 -91
  120. package/dist/esm/calls/visibilityChangeListener.js +15 -10
  121. package/dist/esm/components/App.js +35 -0
  122. package/dist/esm/components/App.spec.js +9 -0
  123. package/dist/esm/components/Button.js +34 -0
  124. package/dist/esm/components/ChaynsContext.js +3 -3
  125. package/dist/esm/components/ChaynsProvider.js +86 -45
  126. package/dist/esm/components/ChaynsProviderExposed.js +3 -0
  127. package/dist/esm/components/TestProvider.js +308 -0
  128. package/dist/esm/components/Title.js +210 -0
  129. package/dist/esm/components/WaitUntil.js +86 -21
  130. package/dist/esm/components/withCompatMode.js +77 -35
  131. package/dist/esm/helper/apiListenerHelper.js +15 -10
  132. package/dist/esm/helper/cssLoader.js +21 -0
  133. package/dist/esm/hooks/geoLocationListener.js +46 -20
  134. package/dist/esm/hooks/scrollListener.js +86 -50
  135. package/dist/esm/hooks/useAccessToken.js +28 -6
  136. package/dist/esm/hooks/useAddGeoLocationListener.js +18 -0
  137. package/dist/esm/hooks/useAddScrollListener.js +18 -0
  138. package/dist/esm/hooks/useAddWindowMetricsListener.js +18 -0
  139. package/dist/esm/hooks/useCurrentPage.js +6 -2
  140. package/dist/esm/hooks/useCustomData.js +6 -2
  141. package/dist/esm/hooks/useDevice.js +6 -1
  142. package/dist/esm/hooks/useEnvironment.js +6 -1
  143. package/dist/esm/hooks/useFunctions.js +5 -2
  144. package/dist/esm/hooks/useIsAdminMode.js +6 -2
  145. package/dist/esm/hooks/useLanguage.js +6 -1
  146. package/dist/esm/hooks/usePages.js +27 -14
  147. package/dist/esm/hooks/useParameters.js +6 -1
  148. package/dist/esm/hooks/useSite.js +6 -1
  149. package/dist/esm/hooks/useUser.js +6 -1
  150. package/dist/esm/hooks/useValues.js +5 -2
  151. package/dist/esm/hooks/windowMetricsListener.js +44 -18
  152. package/dist/esm/host/ChaynsHost.js +30 -21
  153. package/dist/esm/host/HostIframe.js +153 -0
  154. package/dist/esm/host/iframe/HostIframe.js +142 -86
  155. package/dist/esm/host/iframe/utils/useUpdateData.js +6 -4
  156. package/dist/esm/host/module/ModuleHost.js +49 -42
  157. package/dist/esm/host/module/utils/loadComponent.js +85 -47
  158. package/dist/esm/host/module/utils/useDynamicScript.js +74 -27
  159. package/dist/esm/index.example.js +1 -0
  160. package/dist/esm/index2.js +5 -0
  161. package/dist/esm/types/DynamicImport.d.js +1 -0
  162. package/dist/esm/types/IChaynsReact.js +61 -14
  163. package/dist/esm/types/chayns-components.d.js +0 -0
  164. package/dist/esm/types/chayns-logger.d.js +0 -0
  165. package/dist/esm/types/chayns.d.js +0 -0
  166. package/dist/esm/types/tobit-websocket-service-client.d.js +0 -0
  167. package/dist/esm/types/toolkit-types.d.js +0 -0
  168. package/dist/esm/util/appCall.js +4 -2
  169. package/dist/esm/util/deviceHelper.js +33 -11
  170. package/dist/esm/util/heightHelper.js +13 -10
  171. package/dist/esm/util/postIframeForm.js +57 -25
  172. package/dist/esm/util/useIsAdminMode.js +9 -0
  173. package/dist/esm/util/useUser.js +7 -0
  174. package/dist/esm/wrapper/AppWrapper.js +762 -179
  175. package/dist/esm/wrapper/FrameWrapper.js +1509 -258
  176. package/dist/esm/wrapper/ModuleFederationWrapper.js +284 -47
  177. package/dist/esm/wrapper/SsrWrapper.js +65 -19
  178. package/dist/types/bootstrap.d.ts +1 -0
  179. package/dist/types/calls/dialogs/confirm.d.ts +1 -1
  180. package/dist/types/calls/dialogs/date.d.ts +4 -4
  181. package/dist/types/calls/dialogs/dropUpAlert.d.ts +1 -1
  182. package/dist/types/calls/dialogs/fileSelect.d.ts +1 -1
  183. package/dist/types/calls/dialogs/iFrame.d.ts +1 -1
  184. package/dist/types/calls/dialogs/input.d.ts +1 -1
  185. package/dist/types/calls/dialogs/mediaSelect.d.ts +1 -1
  186. package/dist/types/calls/dialogs/signature.d.ts +1 -1
  187. package/dist/types/components/App.d.ts +5 -0
  188. package/dist/types/components/Button.d.ts +8 -0
  189. package/dist/types/components/ChaynsProvider.d.ts +1 -1
  190. package/dist/types/components/ChaynsProviderExposed.d.ts +13 -0
  191. package/dist/types/components/Title.d.ts +3 -0
  192. package/dist/types/components/WaitUntil.d.ts +1 -1
  193. package/dist/types/components/withCompatMode.d.ts +1 -1
  194. package/dist/types/hooks/useAccessToken.d.ts +1 -1
  195. package/dist/types/host/ChaynsHost.d.ts +2 -1
  196. package/dist/types/host/{module/PagemakerFrame.d.ts → HostIframe.d.ts} +5 -7
  197. package/dist/types/host/iframe/HostIframe.d.ts +1 -1
  198. package/dist/types/host/module/ModuleHost.d.ts +2 -2
  199. package/dist/types/index.example.d.ts +0 -0
  200. package/dist/types/types/IChaynsReact.d.ts +14 -14
  201. package/package.json +1 -1
  202. package/dist/cjs/calls/dialogs/utils/environment.js +0 -10
  203. package/dist/esm/calls/dialogs/utils/environment.js +0 -3
  204. package/dist/esm/host/module/PagemakerFrame.js +0 -97
  205. package/dist/types/calls/dialogs/utils/environment.d.ts +0 -3
@@ -1,6 +1,6 @@
1
1
  import { open } from './open';
2
2
  import { getCallbackName } from './utils/callback';
3
- export const buttonText = {
3
+ export var buttonText = {
4
4
  'YES': {
5
5
  'de': 'Ja',
6
6
  'en': 'Yes',
@@ -19,12 +19,12 @@ export const buttonText = {
19
19
  'nl': 'Annuleren'
20
20
  }['de'] || 'Cancel'
21
21
  };
22
- export const buttonType = {
22
+ export var buttonType = {
23
23
  'CANCEL': -1,
24
24
  'NEGATIVE': 0,
25
25
  'POSITIVE': 1
26
26
  };
27
- export const dialogAction = {
27
+ export var dialogAction = {
28
28
  'ALERT_CONFIRM': 178,
29
29
  'INPUT': 173,
30
30
  'SELECT': 174,
@@ -37,12 +37,16 @@ export const dialogAction = {
37
37
  'IFRAME': 191
38
38
  };
39
39
  export function chaynsDialog(config) {
40
- const callbackName = 'chaynsDialog';
40
+ var callbackName = 'chaynsDialog';
41
41
  config.callback = getCallbackName(callbackName);
42
+
42
43
  if (config.dialog) {
43
- config.dialog.callType = dialogAction.ALERT_CONFIRM;
44
- // @ts-ignore
45
- return open(config.dialog).then(data => Promise.resolve(data.selection ? data : data.buttonType));
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
+ });
46
49
  }
50
+
47
51
  return "unsupported";
48
52
  }
@@ -1,66 +1,77 @@
1
1
  // @ts-nocheck
2
-
3
2
  import { invokeDialogCall } from "../index";
4
3
  export function sendData(data, isApiEvent) {
5
4
  return invokeDialogCall({
6
5
  action: 218,
7
6
  value: {
8
- data,
9
- isApiEvent
7
+ data: data,
8
+ isApiEvent: isApiEvent
10
9
  }
11
10
  });
12
11
  }
13
- const listeners = [];
14
- const apiListeners = [];
12
+ var listeners = [];
13
+ var apiListeners = [];
14
+
15
15
  function _dialogDataListener() {
16
- let e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
16
+ var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
17
+
17
18
  if (!e.data || !e.data.action && typeof e.data !== 'string') {
18
19
  return;
19
20
  }
20
- const messageObj = e.data.action ? e.data : JSON.parse(e.data.match(/(\{(?:.*)\})/)[0]);
21
+
22
+ var messageObj = e.data.action ? e.data : JSON.parse(e.data.match(/(\{(?:.*)\})/)[0]);
23
+
21
24
  if (messageObj.action === 218) {
22
- const {
23
- data
24
- } = messageObj.value;
25
+ var data = messageObj.value.data;
26
+
25
27
  if (messageObj.value.isApiEvent) {
26
- apiListeners.forEach(listener => {
28
+ apiListeners.forEach(function (listener) {
27
29
  listener(data);
28
30
  });
29
31
  } else {
30
- listeners.forEach(listener => {
32
+ listeners.forEach(function (listener) {
31
33
  listener(data);
32
34
  });
33
35
  }
34
36
  }
35
37
  }
38
+
36
39
  export function addDialogDataListener(callback) {
37
- let getApiEvents = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
40
+ var getApiEvents = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
41
+
38
42
  if (listeners.length === 0 || apiListeners.length === 0) {
39
43
  window.addEventListener('message', _dialogDataListener);
40
44
  }
45
+
41
46
  if (getApiEvents) {
42
47
  apiListeners.push(callback);
43
48
  } else {
44
49
  listeners.push(callback);
45
50
  }
51
+
46
52
  return true;
47
53
  }
48
54
  export function removeDialogDataListener(callback) {
49
- let getApiEvents = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
50
- let index;
55
+ var getApiEvents = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
56
+ var index;
57
+
51
58
  if (getApiEvents) {
52
59
  index = apiListeners.indexOf(callback);
60
+
53
61
  if (index !== -1) {
54
62
  apiListeners.splice(index, 1);
55
63
  }
56
64
  } else {
57
65
  index = listeners.indexOf(callback);
66
+
58
67
  if (index !== -1) {
59
68
  listeners.splice(index, 1);
60
69
  }
61
70
  }
71
+
62
72
  if (listeners.length === 0 && apiListeners.length === 0) {
63
73
  window.removeEventListener('message', _dialogDataListener);
64
74
  }
75
+
65
76
  return index !== -1;
66
77
  }
@@ -1,14 +1,16 @@
1
1
  import { buttonText, buttonType, chaynsDialog } from './chaynsDialog';
2
2
  export function confirm() {
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] : {};
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
+
6
7
  // backward compatibility
7
8
  if (Array.isArray(config)) {
8
9
  config = {
9
10
  'buttons': config
10
11
  };
11
12
  }
13
+
12
14
  if (!config.buttons || !Array.isArray(config.buttons)) {
13
15
  config.buttons = [{
14
16
  'text': buttonText.YES,
@@ -18,10 +20,11 @@ export function confirm() {
18
20
  'buttonType': buttonType.NEGATIVE
19
21
  }];
20
22
  }
23
+
21
24
  return chaynsDialog({
22
25
  'dialog': {
23
- title,
24
- message,
26
+ title: title,
27
+ message: message,
25
28
  'buttons': config.buttons,
26
29
  'links': config.links,
27
30
  'select': config.select
@@ -2,7 +2,6 @@ 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
5
  /**
7
6
  * The config object for date dialog
8
7
  * @typedef {Object} dateConfig
@@ -32,85 +31,84 @@ import { getDevice } from "../index";
32
31
  */
33
32
 
34
33
  export function date() {
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();
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
+
52
48
  if (minuteInterval && minuteInterval > 1 && os === 'iOS' && app) {
53
49
  preSelect = roundInterval(preSelect, minuteInterval);
54
50
  } else {
55
51
  preSelect = validateValue(preSelect);
56
52
  }
53
+
57
54
  minDate = validateValue(minDate);
58
55
  maxDate = validateValue(maxDate);
59
- let buttons = [];
56
+ var buttons = [];
60
57
  buttons = [{
61
58
  'text': buttonText.OK,
62
59
  'buttonType': buttonType.POSITIVE
63
60
  }];
64
61
  return open({
65
62
  'callType': dialogAction.DATE,
66
- type,
63
+ type: type,
67
64
  'selectedDate': preSelect,
68
- minDate,
69
- maxDate,
70
- title,
71
- message,
72
- buttons,
73
- minuteInterval,
74
- autoSelectDate
75
- }).then(data => {
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) {
76
73
  // @ts-ignore
77
74
  return Promise.resolve(data.selectedDate);
78
75
  });
79
76
  }
80
77
  export function advancedDate() {
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;
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;
105
99
  minDate = validateValue(minDate);
106
100
  maxDate = validateValue(maxDate);
107
- const {
108
- os,
109
- app
110
- } = getDevice();
101
+
102
+ var _getDevice2 = getDevice(),
103
+ os = _getDevice2.os,
104
+ app = _getDevice2.app;
105
+
111
106
  if (!preSelect) preSelect = {};
107
+
112
108
  if (Array.isArray(preSelect)) {
113
- preSelect = preSelect.map(p => validateValue(p));
109
+ preSelect = preSelect.map(function (p) {
110
+ return validateValue(p);
111
+ });
114
112
  } else if (isObject(preSelect)) {
115
113
  if (preSelect.start && preSelect.end) {
116
114
  if (minuteInterval && minuteInterval > 1 && os === 'iOS' && app) {
@@ -128,43 +126,47 @@ export function advancedDate() {
128
126
  preSelect = validateValue(preSelect);
129
127
  }
130
128
  }
129
+
131
130
  if (Array.isArray(disabledDates)) {
132
- disabledDates = disabledDates.map(d => validateValue(d));
131
+ disabledDates = disabledDates.map(function (d) {
132
+ return validateValue(d);
133
+ });
133
134
  }
135
+
134
136
  if (!buttons || !Array.isArray(buttons)) {
135
137
  buttons = [{
136
138
  'text': buttonText.OK,
137
139
  'buttonType': buttonType.POSITIVE
138
140
  }];
139
141
  }
142
+
140
143
  return open({
141
144
  'callType': dialogAction.ADVANCED_DATE,
142
- type,
145
+ type: type,
143
146
  'selectedDate': Array.isArray(preSelect) ? undefined : preSelect,
144
- minDate,
145
- maxDate,
146
- title,
147
- message,
148
- minuteInterval,
149
- buttons,
150
- multiselect,
147
+ minDate: minDate,
148
+ maxDate: maxDate,
149
+ title: title,
150
+ message: message,
151
+ minuteInterval: minuteInterval,
152
+ buttons: buttons,
153
+ multiselect: multiselect,
151
154
  'selectedDates': Array.isArray(preSelect) ? preSelect : undefined,
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 => {
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) {
164
167
  return Promise.resolve(data);
165
168
  });
166
169
  }
167
-
168
170
  /**
169
171
  * @typedef {number} dateDialogType
170
172
  */
@@ -178,24 +180,30 @@ export function advancedDate() {
178
180
  * @enum {dateDialogType}
179
181
  * @type {{DATE: number, TIME: number, DATE_TIME: number}}
180
182
  */
181
- export const dateType = {
183
+
184
+ export var dateType = {
182
185
  'DATE': 1,
183
186
  'TIME': 2,
184
187
  'DATE_TIME': 3
185
188
  };
189
+
186
190
  function validateValue(value) {
187
191
  if (!isNumber(value)) {
188
192
  if (isDate(value)) {
189
193
  // TODO: Find out whats the purpose of parsing to int
190
194
  return parseInt(value.getTime() / 1000 + "", 10);
191
195
  }
196
+
192
197
  return undefined;
193
198
  }
199
+
194
200
  return value;
195
201
  }
202
+
196
203
  function roundInterval() {
197
- let preDate = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Date();
198
- let interval = arguments.length > 1 ? arguments[1] : undefined;
204
+ var preDate = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Date();
205
+ var interval = arguments.length > 1 ? arguments[1] : undefined;
206
+
199
207
  if (!isDate(preDate)) {
200
208
  if (isNumber(preDate)) {
201
209
  preDate = new Date(preDate);
@@ -203,9 +211,10 @@ function roundInterval() {
203
211
  return -1;
204
212
  }
205
213
  }
206
- let minutes = preDate.getMinutes();
214
+
215
+ var minutes = preDate.getMinutes();
207
216
  preDate.setMinutes(minutes - minutes % interval);
208
- preDate.setSeconds(0);
209
- // TODO: Why?
217
+ preDate.setSeconds(0); // TODO: Why?
218
+
210
219
  return parseInt(preDate.getTime() / 1000 + "", 10);
211
220
  }
@@ -1,7 +1,7 @@
1
1
  import { open } from './open';
2
2
  import { dialogAction } from './chaynsDialog';
3
3
  export function dropUpAlert() {
4
- let dialog = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4
+ var 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,32 +1,71 @@
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
+
1
5
  import { buttonText, buttonType, dialogAction } from './chaynsDialog';
2
6
  import { open } from './open';
3
7
  import { getAccessToken, getUser, login } from "../index";
4
- export const fileType = {
8
+ export var fileType = {
5
9
  'IMAGE': 'image',
6
10
  'VIDEO': 'video',
7
11
  'AUDIO': 'audio',
8
12
  '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']
9
13
  };
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);
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);
32
71
  }
@@ -3,9 +3,10 @@ import { open } from './open';
3
3
  import { addDialogDataListener, sendData } from './communication';
4
4
  import { getSite, invokeDialogCall } from "../index";
5
5
  export function iFrame() {
6
- let dialog = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
6
+ var dialog = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
7
7
  url: ""
8
8
  };
9
+
9
10
  if (!dialog.buttons || !Array.isArray(dialog.buttons)) {
10
11
  dialog.buttons = [{
11
12
  'text': buttonText.YES,
@@ -15,20 +16,22 @@ export function iFrame() {
15
16
  'buttonType': buttonType.NEGATIVE
16
17
  }];
17
18
  }
19
+
18
20
  dialog.tappIframeName = window.name;
19
21
  dialog.callType = dialogAction.IFRAME;
20
- const site = getSite();
21
- dialog.url = `${dialog.url}${dialog.url.indexOf('?') >= 0 ? '&' : '?'}siteId=${site.id}`;
22
+ var site = getSite();
23
+ dialog.url = "".concat(dialog.url).concat(dialog.url.indexOf('?') >= 0 ? '&' : '?', "siteId=").concat(site.id);
22
24
  addDialogDataListener(_chaynsCallResponder, true);
23
25
  return open(dialog);
24
26
  }
25
27
  export function _chaynsCallResponder(obj) {
26
28
  if (obj.call.value.callback) {
27
- const call = JSON.parse(JSON.stringify(obj)); // deep copy
28
- invokeDialogCall(obj).then(result => {
29
+ var call = JSON.parse(JSON.stringify(obj)); // deep copy
30
+
31
+ invokeDialogCall(obj).then(function (result) {
29
32
  sendData({
30
- result,
31
- call
33
+ result: result,
34
+ call: call
32
35
  }, true);
33
36
  });
34
37
  } else {
@@ -1,7 +1,8 @@
1
1
  import { buttonText, buttonType, dialogAction } from './chaynsDialog';
2
2
  import { open } from './open';
3
3
  export function input() {
4
- let dialog = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4
+ var dialog = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
5
+
5
6
  if (!dialog.buttons || !Array.isArray(dialog.buttons)) {
6
7
  dialog.buttons = [{
7
8
  'text': buttonText.YES,
@@ -11,13 +12,15 @@ export function input() {
11
12
  'buttonType': buttonType.NEGATIVE
12
13
  }];
13
14
  }
15
+
14
16
  if (dialog.formatter) {
15
17
  dialog.formatter = dialog.formatter.toString();
16
18
  }
19
+
17
20
  dialog.callType = dialogAction.INPUT;
18
21
  return open(dialog);
19
22
  }
20
- export const inputType = {
23
+ export var inputType = {
21
24
  'DEFAULT': 0,
22
25
  'PASSWORD': 1,
23
26
  'TEXTAREA': 2,