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
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ var _react = _interopRequireDefault(require("react"));
4
+
5
+ var _reactDom = _interopRequireDefault(require("react-dom"));
6
+
7
+ var _App = _interopRequireDefault(require("./components/App"));
8
+
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+
11
+ _reactDom.default.render( /*#__PURE__*/_react.default.createElement(_App.default, null), document.querySelector('#root'));
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
9
+
10
+ class ApiEventListener {
11
+ constructor() {
12
+ _defineProperty(this, "counter", 0);
13
+
14
+ _defineProperty(this, "listenerMapping", {});
15
+
16
+ _defineProperty(this, "addEventListener", callback => {
17
+ if (Object.keys(this.listenerMapping).length === 0) {
18
+ this.initializeListener();
19
+ }
20
+
21
+ const id = ++this.counter;
22
+ this.listenerMapping[id] = callback;
23
+ return Promise.resolve(id);
24
+ });
25
+
26
+ _defineProperty(this, "removeEventListener", id => {
27
+ delete this.listenerMapping[id];
28
+
29
+ if (Object.keys(this.listenerMapping).length === 0) {
30
+ this.cleanupListener();
31
+ }
32
+
33
+ return Promise.resolve();
34
+ });
35
+ }
36
+
37
+ }
38
+
39
+ var _default = ApiEventListener;
40
+ exports.default = _default;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
9
+
10
+ class ApiEventListener {
11
+ constructor() {
12
+ _defineProperty(this, "counter", 0);
13
+
14
+ _defineProperty(this, "listenerMapping", {});
15
+
16
+ _defineProperty(this, "addEventListener", callback => {
17
+ if (Object.keys(this.listenerMapping).length === 0) {
18
+ this.initializeListener();
19
+ }
20
+
21
+ const id = ++this.counter;
22
+ this.listenerMapping[id] = callback;
23
+ return Promise.resolve(id);
24
+ });
25
+
26
+ _defineProperty(this, "removeEventListener", id => {
27
+ delete this.listenerMapping[id];
28
+
29
+ if (Object.keys(this.listenerMapping).length === 0) {
30
+ this.cleanupListener();
31
+ }
32
+
33
+ return Promise.resolve();
34
+ });
35
+ }
36
+
37
+ }
38
+
39
+ var _default = ApiEventListener;
40
+ exports.default = _default;
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.alert = alert;
7
+
7
8
  var _chaynsDialog = require("./chaynsDialog");
9
+
8
10
  function alert(title = '', message = '') {
9
11
  return (0, _chaynsDialog.chaynsDialog)({
10
12
  'dialog': {
@@ -6,8 +6,11 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.buttonType = exports.buttonText = void 0;
7
7
  exports.chaynsDialog = chaynsDialog;
8
8
  exports.dialogAction = void 0;
9
+
9
10
  var _open = require("./open");
11
+
10
12
  var _callback = require("./utils/callback");
13
+
11
14
  const buttonText = {
12
15
  'YES': {
13
16
  'de': 'Ja',
@@ -47,13 +50,16 @@ const dialogAction = {
47
50
  'IFRAME': 191
48
51
  };
49
52
  exports.dialogAction = dialogAction;
53
+
50
54
  function chaynsDialog(config) {
51
55
  const callbackName = 'chaynsDialog';
52
56
  config.callback = (0, _callback.getCallbackName)(callbackName);
57
+
53
58
  if (config.dialog) {
54
- config.dialog.callType = dialogAction.ALERT_CONFIRM;
55
- // @ts-ignore
59
+ config.dialog.callType = dialogAction.ALERT_CONFIRM; // @ts-ignore
60
+
56
61
  return (0, _open.open)(config.dialog).then(data => Promise.resolve(data.selection ? data : data.buttonType));
57
62
  }
63
+
58
64
  return "unsupported";
59
65
  }
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.close = close;
7
+
7
8
  var _index = require("../index");
9
+
8
10
  function close() {
9
11
  return (0, _index.invokeDialogCall)({
10
12
  action: 113,
@@ -6,9 +6,10 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.addDialogDataListener = addDialogDataListener;
7
7
  exports.removeDialogDataListener = removeDialogDataListener;
8
8
  exports.sendData = sendData;
9
+
9
10
  var _index = require("../index");
10
- // @ts-nocheck
11
11
 
12
+ // @ts-nocheck
12
13
  function sendData(data, isApiEvent) {
13
14
  return (0, _index.invokeDialogCall)({
14
15
  action: 218,
@@ -18,17 +19,22 @@ function sendData(data, isApiEvent) {
18
19
  }
19
20
  });
20
21
  }
22
+
21
23
  const listeners = [];
22
24
  const apiListeners = [];
25
+
23
26
  function _dialogDataListener(e = {}) {
24
27
  if (!e.data || !e.data.action && typeof e.data !== 'string') {
25
28
  return;
26
29
  }
30
+
27
31
  const messageObj = e.data.action ? e.data : JSON.parse(e.data.match(/(\{(?:.*)\})/)[0]);
32
+
28
33
  if (messageObj.action === 218) {
29
34
  const {
30
35
  data
31
36
  } = messageObj.value;
37
+
32
38
  if (messageObj.value.isApiEvent) {
33
39
  apiListeners.forEach(listener => {
34
40
  listener(data);
@@ -40,32 +46,41 @@ function _dialogDataListener(e = {}) {
40
46
  }
41
47
  }
42
48
  }
49
+
43
50
  function addDialogDataListener(callback, getApiEvents = false) {
44
51
  if (listeners.length === 0 || apiListeners.length === 0) {
45
52
  window.addEventListener('message', _dialogDataListener);
46
53
  }
54
+
47
55
  if (getApiEvents) {
48
56
  apiListeners.push(callback);
49
57
  } else {
50
58
  listeners.push(callback);
51
59
  }
60
+
52
61
  return true;
53
62
  }
63
+
54
64
  function removeDialogDataListener(callback, getApiEvents = false) {
55
65
  let index;
66
+
56
67
  if (getApiEvents) {
57
68
  index = apiListeners.indexOf(callback);
69
+
58
70
  if (index !== -1) {
59
71
  apiListeners.splice(index, 1);
60
72
  }
61
73
  } else {
62
74
  index = listeners.indexOf(callback);
75
+
63
76
  if (index !== -1) {
64
77
  listeners.splice(index, 1);
65
78
  }
66
79
  }
80
+
67
81
  if (listeners.length === 0 && apiListeners.length === 0) {
68
82
  window.removeEventListener('message', _dialogDataListener);
69
83
  }
84
+
70
85
  return index !== -1;
71
86
  }
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.confirm = confirm;
7
+
7
8
  var _chaynsDialog = require("./chaynsDialog");
9
+
8
10
  function confirm(title = '', message = '', config = {}) {
9
11
  // backward compatibility
10
12
  if (Array.isArray(config)) {
@@ -12,6 +14,7 @@ function confirm(title = '', message = '', config = {}) {
12
14
  'buttons': config
13
15
  };
14
16
  }
17
+
15
18
  if (!config.buttons || !Array.isArray(config.buttons)) {
16
19
  config.buttons = [{
17
20
  'text': _chaynsDialog.buttonText.YES,
@@ -21,6 +24,7 @@ function confirm(title = '', message = '', config = {}) {
21
24
  'buttonType': _chaynsDialog.buttonType.NEGATIVE
22
25
  }];
23
26
  }
27
+
24
28
  return (0, _chaynsDialog.chaynsDialog)({
25
29
  'dialog': {
26
30
  title,
@@ -6,32 +6,38 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.advancedDate = advancedDate;
7
7
  exports.date = date;
8
8
  exports.dateType = void 0;
9
+
9
10
  var _chaynsDialog = require("./chaynsDialog");
11
+
10
12
  var _is = require("./utils/is");
13
+
11
14
  var _open = require("./open");
15
+
12
16
  var _index = require("../index");
17
+
13
18
  function date(config = {}) {
14
19
  let {
15
- preSelect,
16
- minDate,
17
- maxDate,
18
- title,
19
- message,
20
- minuteInterval,
21
- autoSelectDate
22
- } = config,
23
- type = config.dateType || dateType.DATE;
24
-
25
- // This will fix the iOS problem with not preselectedDate without user interaction. That it return the wrog time.
20
+ preSelect,
21
+ minDate,
22
+ maxDate,
23
+ title,
24
+ message,
25
+ minuteInterval,
26
+ autoSelectDate
27
+ } = config,
28
+ type = config.dateType || dateType.DATE; // This will fix the iOS problem with not preselectedDate without user interaction. That it return the wrog time.
29
+
26
30
  const {
27
31
  os,
28
32
  app
29
33
  } = (0, _index.getDevice)();
34
+
30
35
  if (minuteInterval && minuteInterval > 1 && os === 'iOS' && app) {
31
36
  preSelect = roundInterval(preSelect, minuteInterval);
32
37
  } else {
33
38
  preSelect = validateValue(preSelect);
34
39
  }
40
+
35
41
  minDate = validateValue(minDate);
36
42
  maxDate = validateValue(maxDate);
37
43
  let buttons = [];
@@ -55,30 +61,31 @@ function date(config = {}) {
55
61
  return Promise.resolve(data.selectedDate);
56
62
  });
57
63
  }
64
+
58
65
  function advancedDate(config = {}) {
59
66
  let {
60
- preSelect,
61
- minDate,
62
- maxDate,
63
- title,
64
- message,
65
- minuteInterval,
66
- buttons,
67
- multiselect,
68
- disabledDates,
69
- textBlocks,
70
- monthSelect,
71
- yearSelect,
72
- interval,
73
- maxInterval,
74
- minInterval,
75
- disabledIntervals,
76
- disabledWeekDayIntervals,
77
- getLocalTime,
78
- autoSelectDate
79
- } = config,
80
- // minInterval and maxInterval in minutes
81
- type = config.dateType || dateType.DATE;
67
+ preSelect,
68
+ minDate,
69
+ maxDate,
70
+ title,
71
+ message,
72
+ minuteInterval,
73
+ buttons,
74
+ multiselect,
75
+ disabledDates,
76
+ textBlocks,
77
+ monthSelect,
78
+ yearSelect,
79
+ interval,
80
+ maxInterval,
81
+ minInterval,
82
+ disabledIntervals,
83
+ disabledWeekDayIntervals,
84
+ getLocalTime,
85
+ autoSelectDate
86
+ } = config,
87
+ // minInterval and maxInterval in minutes
88
+ type = config.dateType || dateType.DATE;
82
89
  minDate = validateValue(minDate);
83
90
  maxDate = validateValue(maxDate);
84
91
  const {
@@ -86,6 +93,7 @@ function advancedDate(config = {}) {
86
93
  app
87
94
  } = (0, _index.getDevice)();
88
95
  if (!preSelect) preSelect = {};
96
+
89
97
  if (Array.isArray(preSelect)) {
90
98
  preSelect = preSelect.map(p => validateValue(p));
91
99
  } else if ((0, _is.isObject)(preSelect)) {
@@ -105,15 +113,18 @@ function advancedDate(config = {}) {
105
113
  preSelect = validateValue(preSelect);
106
114
  }
107
115
  }
116
+
108
117
  if (Array.isArray(disabledDates)) {
109
118
  disabledDates = disabledDates.map(d => validateValue(d));
110
119
  }
120
+
111
121
  if (!buttons || !Array.isArray(buttons)) {
112
122
  buttons = [{
113
123
  'text': _chaynsDialog.buttonText.OK,
114
124
  'buttonType': _chaynsDialog.buttonType.POSITIVE
115
125
  }];
116
126
  }
127
+
117
128
  return (0, _open.open)({
118
129
  'callType': _chaynsDialog.dialogAction.ADVANCED_DATE,
119
130
  type,
@@ -141,7 +152,6 @@ function advancedDate(config = {}) {
141
152
  return Promise.resolve(data);
142
153
  });
143
154
  }
144
-
145
155
  /**
146
156
  * @typedef {number} dateDialogType
147
157
  */
@@ -155,22 +165,28 @@ function advancedDate(config = {}) {
155
165
  * @enum {dateDialogType}
156
166
  * @type {{DATE: number, TIME: number, DATE_TIME: number}}
157
167
  */
168
+
169
+
158
170
  const dateType = {
159
171
  'DATE': 1,
160
172
  'TIME': 2,
161
173
  'DATE_TIME': 3
162
174
  };
163
175
  exports.dateType = dateType;
176
+
164
177
  function validateValue(value) {
165
178
  if (!(0, _is.isNumber)(value)) {
166
179
  if ((0, _is.isDate)(value)) {
167
180
  // TODO: Find out whats the purpose of parsing to int
168
181
  return parseInt(value.getTime() / 1000 + "", 10);
169
182
  }
183
+
170
184
  return undefined;
171
185
  }
186
+
172
187
  return value;
173
188
  }
189
+
174
190
  function roundInterval(preDate = new Date(), interval) {
175
191
  if (!(0, _is.isDate)(preDate)) {
176
192
  if ((0, _is.isNumber)(preDate)) {
@@ -179,9 +195,10 @@ function roundInterval(preDate = new Date(), interval) {
179
195
  return -1;
180
196
  }
181
197
  }
198
+
182
199
  let minutes = preDate.getMinutes();
183
200
  preDate.setMinutes(minutes - minutes % interval);
184
- preDate.setSeconds(0);
185
- // TODO: Why?
201
+ preDate.setSeconds(0); // TODO: Why?
202
+
186
203
  return parseInt(preDate.getTime() / 1000 + "", 10);
187
204
  }
@@ -4,8 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.dropUpAlert = dropUpAlert;
7
+
7
8
  var _open = require("./open");
9
+
8
10
  var _chaynsDialog = require("./chaynsDialog");
11
+
9
12
  function dropUpAlert(dialog = {}) {
10
13
  dialog.callType = _chaynsDialog.dialogAction.DROP_UP_ALERT;
11
14
  return (0, _open.open)(dialog);
@@ -5,9 +5,13 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.fileSelect = fileSelect;
7
7
  exports.fileType = void 0;
8
+
8
9
  var _chaynsDialog = require("./chaynsDialog");
10
+
9
11
  var _open = require("./open");
12
+
10
13
  var _index = require("../index");
14
+
11
15
  const fileType = {
12
16
  'IMAGE': 'image',
13
17
  'VIDEO': 'video',
@@ -15,25 +19,31 @@ const fileType = {
15
19
  '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']
16
20
  };
17
21
  exports.fileType = fileType;
22
+
18
23
  async function fileSelect(dialog = {}) {
19
24
  if (!dialog.buttons || !Array.isArray(dialog.buttons)) {
20
25
  dialog.buttons = [];
26
+
21
27
  if (dialog.multiselect || dialog.directory) {
22
28
  dialog.buttons.push({
23
29
  'text': _chaynsDialog.buttonText.OK,
24
30
  'buttonType': _chaynsDialog.buttonType.POSITIVE
25
31
  });
26
32
  }
33
+
27
34
  dialog.buttons.push({
28
35
  'text': _chaynsDialog.buttonText.CANCEL,
29
36
  'buttonType': _chaynsDialog.buttonType.NEGATIVE
30
37
  });
31
38
  }
39
+
32
40
  dialog.callType = _chaynsDialog.dialogAction.FILE_SELECT;
33
41
  const user = (0, _index.getUser)();
42
+
34
43
  if (!user) {
35
44
  return (0, _index.login)();
36
45
  }
46
+
37
47
  dialog.chaynsToken = (await (0, _index.getAccessToken)()).accessToken;
38
48
  return (0, _open.open)(dialog);
39
49
  }
@@ -5,10 +5,15 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports._chaynsCallResponder = _chaynsCallResponder;
7
7
  exports.iFrame = iFrame;
8
+
8
9
  var _chaynsDialog = require("./chaynsDialog");
10
+
9
11
  var _open = require("./open");
12
+
10
13
  var _communication = require("./communication");
14
+
11
15
  var _index = require("../index");
16
+
12
17
  function iFrame(dialog = {
13
18
  url: ""
14
19
  }) {
@@ -21,6 +26,7 @@ function iFrame(dialog = {
21
26
  'buttonType': _chaynsDialog.buttonType.NEGATIVE
22
27
  }];
23
28
  }
29
+
24
30
  dialog.tappIframeName = window.name;
25
31
  dialog.callType = _chaynsDialog.dialogAction.IFRAME;
26
32
  const site = (0, _index.getSite)();
@@ -28,9 +34,11 @@ function iFrame(dialog = {
28
34
  (0, _communication.addDialogDataListener)(_chaynsCallResponder, true);
29
35
  return (0, _open.open)(dialog);
30
36
  }
37
+
31
38
  function _chaynsCallResponder(obj) {
32
39
  if (obj.call.value.callback) {
33
40
  const call = JSON.parse(JSON.stringify(obj)); // deep copy
41
+
34
42
  (0, _index.invokeDialogCall)(obj).then(result => {
35
43
  (0, _communication.sendData)({
36
44
  result,
@@ -19,8 +19,11 @@ Object.defineProperty(exports, "buttonType", {
19
19
  return _chaynsDialog.buttonType;
20
20
  }
21
21
  });
22
+
22
23
  var _chaynsDialog = require("./chaynsDialog");
24
+
23
25
  var _alert = require("./alert");
26
+
24
27
  Object.keys(_alert).forEach(function (key) {
25
28
  if (key === "default" || key === "__esModule") return;
26
29
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -32,7 +35,9 @@ Object.keys(_alert).forEach(function (key) {
32
35
  }
33
36
  });
34
37
  });
38
+
35
39
  var _confirm = require("./confirm");
40
+
36
41
  Object.keys(_confirm).forEach(function (key) {
37
42
  if (key === "default" || key === "__esModule") return;
38
43
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -44,7 +49,9 @@ Object.keys(_confirm).forEach(function (key) {
44
49
  }
45
50
  });
46
51
  });
52
+
47
53
  var _select = require("./select");
54
+
48
55
  Object.keys(_select).forEach(function (key) {
49
56
  if (key === "default" || key === "__esModule") return;
50
57
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -56,7 +63,9 @@ Object.keys(_select).forEach(function (key) {
56
63
  }
57
64
  });
58
65
  });
66
+
59
67
  var _date = require("./date");
68
+
60
69
  Object.keys(_date).forEach(function (key) {
61
70
  if (key === "default" || key === "__esModule") return;
62
71
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -68,7 +77,9 @@ Object.keys(_date).forEach(function (key) {
68
77
  }
69
78
  });
70
79
  });
80
+
71
81
  var _input = require("./input");
82
+
72
83
  Object.keys(_input).forEach(function (key) {
73
84
  if (key === "default" || key === "__esModule") return;
74
85
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -80,7 +91,9 @@ Object.keys(_input).forEach(function (key) {
80
91
  }
81
92
  });
82
93
  });
94
+
83
95
  var _close = require("./close");
96
+
84
97
  Object.keys(_close).forEach(function (key) {
85
98
  if (key === "default" || key === "__esModule") return;
86
99
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -92,7 +105,9 @@ Object.keys(_close).forEach(function (key) {
92
105
  }
93
106
  });
94
107
  });
108
+
95
109
  var _dropUpAlert = require("./dropUpAlert");
110
+
96
111
  Object.keys(_dropUpAlert).forEach(function (key) {
97
112
  if (key === "default" || key === "__esModule") return;
98
113
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -104,7 +119,9 @@ Object.keys(_dropUpAlert).forEach(function (key) {
104
119
  }
105
120
  });
106
121
  });
122
+
107
123
  var _iFrame = require("./iFrame");
124
+
108
125
  Object.keys(_iFrame).forEach(function (key) {
109
126
  if (key === "default" || key === "__esModule") return;
110
127
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -116,7 +133,9 @@ Object.keys(_iFrame).forEach(function (key) {
116
133
  }
117
134
  });
118
135
  });
136
+
119
137
  var _mediaSelect = require("./mediaSelect");
138
+
120
139
  Object.keys(_mediaSelect).forEach(function (key) {
121
140
  if (key === "default" || key === "__esModule") return;
122
141
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -128,7 +147,9 @@ Object.keys(_mediaSelect).forEach(function (key) {
128
147
  }
129
148
  });
130
149
  });
150
+
131
151
  var _fileSelect = require("./fileSelect");
152
+
132
153
  Object.keys(_fileSelect).forEach(function (key) {
133
154
  if (key === "default" || key === "__esModule") return;
134
155
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -140,7 +161,9 @@ Object.keys(_fileSelect).forEach(function (key) {
140
161
  }
141
162
  });
142
163
  });
164
+
143
165
  var _communication = require("./communication");
166
+
144
167
  Object.keys(_communication).forEach(function (key) {
145
168
  if (key === "default" || key === "__esModule") return;
146
169
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -152,7 +175,9 @@ Object.keys(_communication).forEach(function (key) {
152
175
  }
153
176
  });
154
177
  });
178
+
155
179
  var _toast = require("./toast");
180
+
156
181
  Object.keys(_toast).forEach(function (key) {
157
182
  if (key === "default" || key === "__esModule") return;
158
183
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -164,7 +189,9 @@ Object.keys(_toast).forEach(function (key) {
164
189
  }
165
190
  });
166
191
  });
192
+
167
193
  var _signature = require("./signature");
194
+
168
195
  Object.keys(_signature).forEach(function (key) {
169
196
  if (key === "default" || key === "__esModule") return;
170
197
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -5,8 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.input = input;
7
7
  exports.inputType = void 0;
8
+
8
9
  var _chaynsDialog = require("./chaynsDialog");
10
+
9
11
  var _open = require("./open");
12
+
10
13
  function input(dialog = {}) {
11
14
  if (!dialog.buttons || !Array.isArray(dialog.buttons)) {
12
15
  dialog.buttons = [{
@@ -17,12 +20,15 @@ function input(dialog = {}) {
17
20
  'buttonType': _chaynsDialog.buttonType.NEGATIVE
18
21
  }];
19
22
  }
23
+
20
24
  if (dialog.formatter) {
21
25
  dialog.formatter = dialog.formatter.toString();
22
26
  }
27
+
23
28
  dialog.callType = _chaynsDialog.dialogAction.INPUT;
24
29
  return (0, _open.open)(dialog);
25
30
  }
31
+
26
32
  const inputType = {
27
33
  'DEFAULT': 0,
28
34
  'PASSWORD': 1,