chayns-api 1.1.0-31 → 1.1.0-33

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.
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.vibrate = exports.user = exports.storageSetItem = exports.storageRemoveItem = exports.storageGetItem = exports.site = exports.setWaitCursor = exports.setTempDesignSettings = exports.setScanQrCode = exports.setRefreshScrollEnabled = exports.setOverlay = exports.setHeight = exports.setFloatingButton = exports.setDisplayTimeout = exports.setAdminMode = exports.sendMessageToUser = exports.sendMessageToPage = exports.sendMessageToGroup = exports.selectPage = exports.scrollToY = exports.scrollByY = exports.removeWindowMetricsListener = exports.removeVisibilityChangeListener = exports.removeToolbarChangeListener = exports.removeScrollListener = exports.removeGeoLocationListener = exports.refreshData = exports.refreshAccessToken = exports.parameters = exports.pages = exports.openVideo = exports.openUrl = exports.openMedia = exports.openImage = exports.navigateBack = exports.logout = exports.login = exports.language = exports.invokeDialogCall = exports.invokeCall = exports.getWindowMetrics = exports.getUserInfo = exports.getUser = exports.getSite = exports.getScrollPosition = exports.getParameters = exports.getPages = exports.getLanguage = exports.getGeoLocation = exports.getEnvironment = exports.getDevice = exports.getCurrentPage = exports.getAvailableSharingServices = exports.getAccessToken = exports.environment = exports.device = exports.customCallbackFunction = exports.createDialog = exports.addWindowMetricsListener = exports.addVisibilityChangeListener = exports.addToolbarChangeListener = exports.addScrollListener = exports.addGeoLocationListener = void 0;
6
+ exports.vibrate = exports.user = exports.storageSetItem = exports.storageRemoveItem = exports.storageGetItem = exports.site = exports.setWaitCursor = exports.setTempDesignSettings = exports.setScanQrCode = exports.setRefreshScrollEnabled = exports.setOverlay = exports.setHeight = exports.setFloatingButton = exports.setDisplayTimeout = exports.setAdminMode = exports.sendMessageToUser = exports.sendMessageToPage = exports.sendMessageToGroup = exports.selectPage = exports.scrollToY = exports.scrollByY = exports.removeWindowMetricsListener = exports.removeVisibilityChangeListener = exports.removeToolbarChangeListener = exports.removeScrollListener = exports.removeGeoLocationListener = exports.refreshData = exports.refreshAccessToken = exports.parameters = exports.pages = exports.openVideo = exports.openUrl = exports.openMedia = exports.openImage = exports.navigateBack = exports.logout = exports.login = exports.language = exports.invokeDialogCall = exports.invokeCall = exports.getWindowMetrics = exports.getUserInfo = exports.getUser = exports.getSite = exports.getScrollPosition = exports.getParameters = exports.getPages = exports.getLanguage = exports.getGeoLocation = exports.getEnvironment = exports.getDevice = exports.getCurrentPage = exports.getAvailableSharingServices = exports.getAccessToken = exports.environment = exports.device = exports.customCallbackFunction = exports.createDialog = exports.addWindowMetricsListener = exports.addVisibilityChangeListener = exports.addToolbarChangeListener = exports.addScrollListener = exports.addGeoLocationListener = exports.addAnonymousAccount = void 0;
7
7
  var _moduleWrapper = require("../components/moduleWrapper");
8
8
  /**
9
9
  * This adds a listener to determine your location.
@@ -241,21 +241,29 @@ const storageSetItem = (...args) => _moduleWrapper.moduleWrapper.current.functio
241
241
  */
242
242
  exports.storageSetItem = storageSetItem;
243
243
  const vibrate = (...args) => _moduleWrapper.moduleWrapper.current.functions.vibrate(...args);
244
+
244
245
  /**
245
246
  * This method creates a dialog
246
247
  */
248
+ // @ts-ignore
247
249
  exports.vibrate = vibrate;
248
- const createDialog = (...args) => _moduleWrapper.moduleWrapper.current.functions.createDialog(...args);
250
+ const createDialog = config => _moduleWrapper.moduleWrapper.current.functions.createDialog(config);
249
251
  /**
250
252
  * Displays an overlay
251
253
  */
252
254
  exports.createDialog = createDialog;
253
255
  const setOverlay = (...args) => _moduleWrapper.moduleWrapper.current.functions.setOverlay(...args);
256
+
257
+ /**
258
+ * Generates a temp accesstoken, only valid for short period of time (~3 days), works only when no user is logged in
259
+ */
260
+ exports.setOverlay = setOverlay;
261
+ const addAnonymousAccount = () => _moduleWrapper.moduleWrapper.current.functions.addAnonymousAccount();
254
262
  /**
255
263
  * Returns user information, only when user is logged in
256
264
  * @category User functions
257
265
  */
258
- exports.setOverlay = setOverlay;
266
+ exports.addAnonymousAccount = addAnonymousAccount;
259
267
  const getUser = () => _moduleWrapper.moduleWrapper.current.values.user;
260
268
  exports.getUser = getUser;
261
269
  const getSite = () => _moduleWrapper.moduleWrapper.current.values.site;
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  class DialogHandler {
8
8
  isOpen = false;
9
- result = undefined;
10
9
  listeners = [];
11
10
  constructor(config, open, close, dispatchEvent, addDataListener) {
12
11
  this._open = open;
@@ -41,7 +40,7 @@ class DialogHandler {
41
40
  return;
42
41
  }
43
42
  this.isOpen = false;
44
- this._close(this.dialogId, data);
43
+ this._close(this.dialogId, data, buttonType);
45
44
  }
46
45
  dispatchEvent(data) {
47
46
  if (!this.isOpen) {
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.semaphore = exports.default = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _semaphoreAsyncAwait = _interopRequireDefault(require("semaphore-async-await"));
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
11
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
12
+ const semaphore = exports.semaphore = {};
13
+ const useDynamicScript = args => {
14
+ const [ready, setReady] = _react.default.useState(false);
15
+ const [failed, setFailed] = _react.default.useState(false);
16
+ (0, _react.useEffect)(() => {
17
+ if (!args.url) {
18
+ return undefined;
19
+ }
20
+ const element = document.createElement('script');
21
+ element.src = args.url;
22
+ element.type = 'text/javascript';
23
+ element.async = true;
24
+ setReady(false);
25
+ setFailed(false);
26
+ if (!(args.scope in semaphore)) {
27
+ semaphore[args.scope] = new _semaphoreAsyncAwait.default(1);
28
+ }
29
+ (async () => {
30
+ await semaphore[args.scope].acquire();
31
+ element.onload = () => {
32
+ setReady(true);
33
+ const listKey = args.scope + "_list";
34
+ if (!window[listKey]) window[listKey] = [];
35
+ window[listKey].push({
36
+ url: args.url,
37
+ container: window[args.scope]
38
+ });
39
+ window[args.scope] = null;
40
+ };
41
+ element.onerror = () => {
42
+ setReady(false);
43
+ setFailed(true);
44
+ };
45
+ document.head.appendChild(element);
46
+ })();
47
+ return () => {
48
+ semaphore[args.scope].release();
49
+ if (document.head.contains(element)) {
50
+ document.head.removeChild(element);
51
+ }
52
+ };
53
+ }, [args.url]);
54
+ return {
55
+ ready,
56
+ failed
57
+ };
58
+ };
59
+ var _default = exports.default = useDynamicScript;
@@ -35,6 +35,7 @@ class AppWrapper {
35
35
  const urlParamsLowerCase = new URLSearchParams(location.search.toLowerCase());
36
36
  let tappId = urlParamsLowerCase.get('tappid');
37
37
  let colorMode = urlParamsLowerCase.get('colormode');
38
+ let color = AppInfo.color;
38
39
  if (colorMode) {
39
40
  try {
40
41
  colorMode = Number.parseInt(colorMode, 10);
@@ -51,6 +52,20 @@ class AppWrapper {
51
52
  if (!language) {
52
53
  language = _languages.DeviceLanguage[Number.parseInt(Device === null || Device === void 0 ? void 0 : Device.LanguageID, 10)] || 'de';
53
54
  }
55
+ if (!color && urlParamsLowerCase.has('color')) {
56
+ color = urlParamsLowerCase.get('color');
57
+ if (!color.startsWith('#')) {
58
+ color = `#${color}`;
59
+ }
60
+ }
61
+ let userId = AppUser.TobitUserID;
62
+ if (typeof userId === 'string') {
63
+ try {
64
+ userId = Number.parseInt(userId, 10);
65
+ } catch {
66
+ // ignore
67
+ }
68
+ }
54
69
  return {
55
70
  device: (0, _deviceHelper.default)(navigator.userAgent, 'image/webp'),
56
71
  environment: {
@@ -78,7 +93,7 @@ class AppWrapper {
78
93
  },
79
94
  title: AppInfo.Title,
80
95
  colorMode: (_colorMode = colorMode) !== null && _colorMode !== void 0 ? _colorMode : AppInfo.colorMode,
81
- color: AppInfo.color,
96
+ color,
82
97
  domain: AppInfo.domain,
83
98
  font: {
84
99
  id: _IChaynsReact.Font.Roboto,
@@ -94,14 +109,14 @@ class AppWrapper {
94
109
  firstName: AppUser.FirstName,
95
110
  lastName: AppUser.LastName,
96
111
  gender: _IChaynsReact.Gender.Unknown,
97
- userId: AppUser.TobitUserID,
112
+ userId: userId,
98
113
  personId: AppUser.PersonID,
99
114
  uacGroups: []
100
115
  },
101
116
  customData: null,
102
117
  isAdminModeActive: AppUser.AdminMode,
103
118
  currentPage: {
104
- id: ((_AppInfo$TappSelected = AppInfo.TappSelected) === null || _AppInfo$TappSelected === void 0 ? void 0 : _AppInfo$TappSelected.TappID) || tappId,
119
+ id: tappId || ((_AppInfo$TappSelected = AppInfo.TappSelected) === null || _AppInfo$TappSelected === void 0 ? void 0 : _AppInfo$TappSelected.TappID),
105
120
  siteId: AppInfo.SiteID
106
121
  },
107
122
  pages: AppInfo.Tapps.map(x => ({
@@ -318,7 +333,7 @@ class AppWrapper {
318
333
  (0, _appCall.default)(callObj);
319
334
  },
320
335
  login: async (value, callback, closeCallback) => {
321
- const res = await this.appCall({}, callback);
336
+ const res = await this.appCall(54, value);
322
337
  return {
323
338
  loginState: res === null || res === void 0 ? void 0 : res.loginState
324
339
  };
@@ -549,6 +564,9 @@ class AppWrapper {
549
564
  buttonType: -1
550
565
  });
551
566
  }
567
+ },
568
+ addAnonymousAccount: async () => {
569
+ return this.appCall(302);
552
570
  }
553
571
  };
554
572
  dialogs = [];
@@ -558,18 +576,17 @@ class AppWrapper {
558
576
  }
559
577
  async init() {
560
578
  this.values = this.mapOldApiToNew(await this.appCall(18));
561
- const callbackName = `chaynsApiV5Callback_${this.counter++}`;
562
- window.disablev4AccessTokenChangeListener = true;
563
- window[callbackName] = ({
564
- retVal: value
565
- }) => {
566
- this.mapOldApiToNew(value);
567
- };
568
579
  this.appCall(66, {
569
580
  enabled: true,
570
- callback: callbackName
571
- }, {
572
- awaitResult: false
581
+ callback: async () => {
582
+ this.values = this.mapOldApiToNew(await this.appCall(18));
583
+ document.dispatchEvent(new CustomEvent('chayns_api_data', {
584
+ detail: {
585
+ type: 'user',
586
+ value: this.values.user
587
+ }
588
+ }));
589
+ }
573
590
  });
574
591
  return undefined;
575
592
  }
@@ -296,7 +296,11 @@ class FrameWrapper {
296
296
  // this.exposedFunctions.removeDialogHostEventListener(0);
297
297
  }
298
298
  },
299
- removeDialogClientEventListener: async () => {}
299
+ removeDialogClientEventListener: async () => {},
300
+ addAnonymousAccount: async () => {
301
+ if (!this.initialized) await this.ready;
302
+ return this.exposedFunctions.addAnonymousAccount();
303
+ }
300
304
  };
301
305
  initialized = false;
302
306
  constructor() {
@@ -17,6 +17,13 @@ class StaticChaynsApi {
17
17
  this[k] = v;
18
18
  });
19
19
  }
20
+ getUser = () => this._wrapper.values.user;
20
21
  getSite = () => this._wrapper.values.site;
22
+ getCurrentPage = () => this._wrapper.values.currentPage;
23
+ getDevice = () => this._wrapper.values.device;
24
+ getLanguage = () => this._wrapper.values.language;
25
+ getParameters = () => this._wrapper.values.parameters;
26
+ getPages = () => this._wrapper.values.pages;
27
+ getEnvironment = () => this._wrapper.values.environment;
21
28
  }
22
29
  var _default = exports.default = StaticChaynsApi;
@@ -282,18 +282,23 @@ export const storageSetItem = function () {
282
282
  export const vibrate = function () {
283
283
  return moduleWrapper.current.functions.vibrate(...arguments);
284
284
  };
285
+
285
286
  /**
286
287
  * This method creates a dialog
287
288
  */
288
- export const createDialog = function () {
289
- return moduleWrapper.current.functions.createDialog(...arguments);
290
- };
289
+ // @ts-ignore
290
+ export const createDialog = config => moduleWrapper.current.functions.createDialog(config);
291
291
  /**
292
292
  * Displays an overlay
293
293
  */
294
294
  export const setOverlay = function () {
295
295
  return moduleWrapper.current.functions.setOverlay(...arguments);
296
296
  };
297
+
298
+ /**
299
+ * Generates a temp accesstoken, only valid for short period of time (~3 days), works only when no user is logged in
300
+ */
301
+ export const addAnonymousAccount = () => moduleWrapper.current.functions.addAnonymousAccount();
297
302
  /**
298
303
  * Returns user information, only when user is logged in
299
304
  * @category User functions
@@ -4,7 +4,6 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
4
4
  export default class DialogHandler {
5
5
  constructor(config, open, close, dispatchEvent, addDataListener) {
6
6
  _defineProperty(this, "isOpen", false);
7
- _defineProperty(this, "result", undefined);
8
7
  _defineProperty(this, "listeners", []);
9
8
  this._open = open;
10
9
  this._close = close;
@@ -38,7 +37,7 @@ export default class DialogHandler {
38
37
  return;
39
38
  }
40
39
  this.isOpen = false;
41
- this._close(this.dialogId, data);
40
+ this._close(this.dialogId, data, buttonType);
42
41
  }
43
42
  dispatchEvent(data) {
44
43
  if (!this.isOpen) {
@@ -0,0 +1,50 @@
1
+ import React, { useEffect } from 'react';
2
+ import Semaphore from 'semaphore-async-await';
3
+ export const semaphore = {};
4
+ const useDynamicScript = args => {
5
+ const [ready, setReady] = React.useState(false);
6
+ const [failed, setFailed] = React.useState(false);
7
+ useEffect(() => {
8
+ if (!args.url) {
9
+ return undefined;
10
+ }
11
+ const element = document.createElement('script');
12
+ element.src = args.url;
13
+ element.type = 'text/javascript';
14
+ element.async = true;
15
+ setReady(false);
16
+ setFailed(false);
17
+ if (!(args.scope in semaphore)) {
18
+ semaphore[args.scope] = new Semaphore(1);
19
+ }
20
+ (async () => {
21
+ await semaphore[args.scope].acquire();
22
+ element.onload = () => {
23
+ setReady(true);
24
+ const listKey = args.scope + "_list";
25
+ if (!window[listKey]) window[listKey] = [];
26
+ window[listKey].push({
27
+ url: args.url,
28
+ container: window[args.scope]
29
+ });
30
+ window[args.scope] = null;
31
+ };
32
+ element.onerror = () => {
33
+ setReady(false);
34
+ setFailed(true);
35
+ };
36
+ document.head.appendChild(element);
37
+ })();
38
+ return () => {
39
+ semaphore[args.scope].release();
40
+ if (document.head.contains(element)) {
41
+ document.head.removeChild(element);
42
+ }
43
+ };
44
+ }, [args.url]);
45
+ return {
46
+ ready,
47
+ failed
48
+ };
49
+ };
50
+ export default useDynamicScript;
@@ -27,6 +27,7 @@ export class AppWrapper {
27
27
  const urlParamsLowerCase = new URLSearchParams(location.search.toLowerCase());
28
28
  let tappId = urlParamsLowerCase.get('tappid');
29
29
  let colorMode = urlParamsLowerCase.get('colormode');
30
+ let color = AppInfo.color;
30
31
  if (colorMode) {
31
32
  try {
32
33
  colorMode = Number.parseInt(colorMode, 10);
@@ -43,6 +44,20 @@ export class AppWrapper {
43
44
  if (!language) {
44
45
  language = DeviceLanguage[Number.parseInt(Device === null || Device === void 0 ? void 0 : Device.LanguageID, 10)] || 'de';
45
46
  }
47
+ if (!color && urlParamsLowerCase.has('color')) {
48
+ color = urlParamsLowerCase.get('color');
49
+ if (!color.startsWith('#')) {
50
+ color = `#${color}`;
51
+ }
52
+ }
53
+ let userId = AppUser.TobitUserID;
54
+ if (typeof userId === 'string') {
55
+ try {
56
+ userId = Number.parseInt(userId, 10);
57
+ } catch {
58
+ // ignore
59
+ }
60
+ }
46
61
  return {
47
62
  device: getDeviceInfo(navigator.userAgent, 'image/webp'),
48
63
  environment: {
@@ -70,7 +85,7 @@ export class AppWrapper {
70
85
  },
71
86
  title: AppInfo.Title,
72
87
  colorMode: (_colorMode = colorMode) !== null && _colorMode !== void 0 ? _colorMode : AppInfo.colorMode,
73
- color: AppInfo.color,
88
+ color,
74
89
  domain: AppInfo.domain,
75
90
  font: {
76
91
  id: Font.Roboto,
@@ -86,14 +101,14 @@ export class AppWrapper {
86
101
  firstName: AppUser.FirstName,
87
102
  lastName: AppUser.LastName,
88
103
  gender: Gender.Unknown,
89
- userId: AppUser.TobitUserID,
104
+ userId: userId,
90
105
  personId: AppUser.PersonID,
91
106
  uacGroups: []
92
107
  },
93
108
  customData: null,
94
109
  isAdminModeActive: AppUser.AdminMode,
95
110
  currentPage: {
96
- id: ((_AppInfo$TappSelected = AppInfo.TappSelected) === null || _AppInfo$TappSelected === void 0 ? void 0 : _AppInfo$TappSelected.TappID) || tappId,
111
+ id: tappId || ((_AppInfo$TappSelected = AppInfo.TappSelected) === null || _AppInfo$TappSelected === void 0 ? void 0 : _AppInfo$TappSelected.TappID),
97
112
  siteId: AppInfo.SiteID
98
113
  },
99
114
  pages: AppInfo.Tapps.map(x => ({
@@ -274,7 +289,7 @@ export class AppWrapper {
274
289
  invokeAppCall(callObj);
275
290
  },
276
291
  login: async (value, callback, closeCallback) => {
277
- const res = await this.appCall({}, callback);
292
+ const res = await this.appCall(54, value);
278
293
  return {
279
294
  loginState: res === null || res === void 0 ? void 0 : res.loginState
280
295
  };
@@ -505,6 +520,9 @@ export class AppWrapper {
505
520
  buttonType: -1
506
521
  });
507
522
  }
523
+ },
524
+ addAnonymousAccount: async () => {
525
+ return this.appCall(302);
508
526
  }
509
527
  });
510
528
  _defineProperty(this, "dialogs", []);
@@ -556,19 +574,17 @@ export class AppWrapper {
556
574
  }
557
575
  async init() {
558
576
  this.values = this.mapOldApiToNew(await this.appCall(18));
559
- const callbackName = `chaynsApiV5Callback_${this.counter++}`;
560
- window.disablev4AccessTokenChangeListener = true;
561
- window[callbackName] = _ref2 => {
562
- let {
563
- retVal: value
564
- } = _ref2;
565
- this.mapOldApiToNew(value);
566
- };
567
577
  this.appCall(66, {
568
578
  enabled: true,
569
- callback: callbackName
570
- }, {
571
- awaitResult: false
579
+ callback: async () => {
580
+ this.values = this.mapOldApiToNew(await this.appCall(18));
581
+ document.dispatchEvent(new CustomEvent('chayns_api_data', {
582
+ detail: {
583
+ type: 'user',
584
+ value: this.values.user
585
+ }
586
+ }));
587
+ }
572
588
  });
573
589
  return undefined;
574
590
  }
@@ -290,7 +290,11 @@ export class FrameWrapper {
290
290
  // this.exposedFunctions.removeDialogHostEventListener(0);
291
291
  }
292
292
  },
293
- removeDialogClientEventListener: async () => {}
293
+ removeDialogClientEventListener: async () => {},
294
+ addAnonymousAccount: async () => {
295
+ if (!this.initialized) await this.ready;
296
+ return this.exposedFunctions.addAnonymousAccount();
297
+ }
294
298
  });
295
299
  _defineProperty(this, "initialized", false);
296
300
  const initialDataTag = document.querySelector('#__CHAYNS_DATA__');
@@ -5,7 +5,14 @@ import { moduleWrapper } from '../components/moduleWrapper';
5
5
  import { FrameWrapper } from './FrameWrapper';
6
6
  class StaticChaynsApi {
7
7
  constructor() {
8
+ _defineProperty(this, "getUser", () => this._wrapper.values.user);
8
9
  _defineProperty(this, "getSite", () => this._wrapper.values.site);
10
+ _defineProperty(this, "getCurrentPage", () => this._wrapper.values.currentPage);
11
+ _defineProperty(this, "getDevice", () => this._wrapper.values.device);
12
+ _defineProperty(this, "getLanguage", () => this._wrapper.values.language);
13
+ _defineProperty(this, "getParameters", () => this._wrapper.values.parameters);
14
+ _defineProperty(this, "getPages", () => this._wrapper.values.pages);
15
+ _defineProperty(this, "getEnvironment", () => this._wrapper.values.environment);
9
16
  const wrapper = new FrameWrapper();
10
17
  moduleWrapper.current = wrapper;
11
18
  this._wrapper = wrapper;
@@ -200,11 +200,15 @@ export declare const vibrate: (value: import("../types/IChaynsReact").Vibrate) =
200
200
  /**
201
201
  * This method creates a dialog
202
202
  */
203
- export declare const createDialog: (config: import("../types/IChaynsReact").Dialog) => import("..").DialogHandler;
203
+ export declare const createDialog: ChaynsReactFunctions["createDialog"];
204
204
  /**
205
205
  * Displays an overlay
206
206
  */
207
207
  export declare const setOverlay: (value: import("../types/IChaynsReact").ShowOverlay, callback: () => void) => Promise<void>;
208
+ /**
209
+ * Generates a temp accesstoken, only valid for short period of time (~3 days), works only when no user is logged in
210
+ */
211
+ export declare const addAnonymousAccount: () => Promise<import("../types/IChaynsReact").AnonymousAccountResult>;
208
212
  /**
209
213
  * Returns user information, only when user is logged in
210
214
  * @category User functions
@@ -1,4 +1,4 @@
1
- export default class DialogHandler {
1
+ export default class DialogHandler<S = void, T extends any = void> {
2
2
  private dialogId;
3
3
  private isOpen;
4
4
  private result;
@@ -9,10 +9,16 @@ export default class DialogHandler {
9
9
  private readonly _addDataListener;
10
10
  private readonly listeners;
11
11
  constructor(config: any, open: any, close: any, dispatchEvent: any, addDataListener: any);
12
- open(): Promise<unknown>;
12
+ open(): Promise<{
13
+ buttonType: number;
14
+ result: T extends undefined ? S : T;
15
+ }>;
13
16
  close(buttonType: any, data: any): void;
14
17
  dispatchEvent(data: object): void;
15
18
  addDataListener(listener: (data: any) => void): void;
16
19
  removeDataListener(listener: (data: any) => void): void;
17
- getResult(): any;
20
+ getResult(): {
21
+ buttonType: number;
22
+ result: T extends undefined ? S : T;
23
+ } | undefined;
18
24
  }
@@ -0,0 +1,9 @@
1
+ export declare const semaphore: {};
2
+ declare const useDynamicScript: (args: {
3
+ url: string | undefined;
4
+ scope: string | undefined;
5
+ }) => {
6
+ ready: boolean;
7
+ failed: boolean;
8
+ };
9
+ export default useDynamicScript;
@@ -61,23 +61,25 @@ export interface BaseDialog {
61
61
  config?: any;
62
62
  };
63
63
  }
64
- export type Dialog = BaseDialog & (DialogAlert | DialogConfirm | DialogInput | DialogModule | DialogIFrame | DialogSelect | DialogDate | DialogToast | DialogFileSelect | DialogSignature);
64
+ export type Dialog<T extends any = object> = BaseDialog & (DialogAlert | DialogConfirm | DialogInput | DialogModule<T> | DialogIFrame<T> | DialogSelect | DialogDate | DialogToast | DialogSignature | DialogFileSelect);
65
65
  export interface DialogSignature {
66
66
  type: DialogType.SIGNATURE;
67
67
  }
68
- export interface DialogModule {
68
+ export interface DialogModule<T extends any = object> {
69
69
  type: DialogType.MODULE;
70
70
  system: {
71
71
  url: string;
72
72
  module: string;
73
73
  scope: string;
74
74
  };
75
- dialogInput: object;
75
+ dialogInput?: T;
76
+ backgroundColor?: string;
76
77
  }
77
- export interface DialogIFrame {
78
+ export interface DialogIFrame<T extends any = object> {
78
79
  type: DialogType.IFRAME;
79
80
  url: string;
80
- dialogInput: object;
81
+ dialogInput?: T;
82
+ backgroundColor?: string;
81
83
  }
82
84
  export declare enum DialogInputType {
83
85
  NUMBER = "number",
@@ -88,8 +90,8 @@ export declare enum DialogInputType {
88
90
  }
89
91
  export interface DialogInput {
90
92
  type: DialogType.INPUT;
91
- placeholder: string;
92
- inputType: DialogInputType;
93
+ placeholder?: string;
94
+ inputType?: DialogInputType;
93
95
  defaultValue?: string;
94
96
  formatter?: (input: string) => string;
95
97
  }
@@ -104,7 +106,11 @@ export type DialogSelectListItemType = {
104
106
  disabled?: boolean;
105
107
  isSelected?: boolean;
106
108
  url?: string;
109
+ /**
110
+ * @deprecated Use {@link icon} instead
111
+ */
107
112
  className?: string;
113
+ icon?: string;
108
114
  };
109
115
  export interface DialogSelect {
110
116
  type: DialogType.SELECT;
@@ -216,6 +222,30 @@ export interface ChaynsReactValues {
216
222
  isClosingRequested: boolean;
217
223
  };
218
224
  }
225
+ export interface DialogResultFile {
226
+ blockDownload?: boolean;
227
+ contentType: string;
228
+ filename: string;
229
+ id: number;
230
+ key: string;
231
+ modifyTime: string;
232
+ personId: string;
233
+ protected?: boolean;
234
+ size: number;
235
+ url: string;
236
+ }
237
+ type DialogResultValue<T> = {
238
+ [DialogType.INPUT]: string;
239
+ [DialogType.SELECT]: number[];
240
+ [DialogType.CONFIRM]: void;
241
+ [DialogType.ALERT]: void;
242
+ [DialogType.DATE]: Date;
243
+ [DialogType.FILE_SELECT]: DialogResultFile[];
244
+ [DialogType.IFRAME]: T;
245
+ [DialogType.MODULE]: T;
246
+ [DialogType.SIGNATURE]: string;
247
+ [DialogType.TOAST]: void;
248
+ };
219
249
  /**
220
250
  * @ignore
221
251
  */
@@ -275,7 +305,7 @@ export interface ChaynsReactFunctions {
275
305
  vibrate: (value: Vibrate) => Promise<void>;
276
306
  scrollByY: (position: number, duration?: number) => Promise<void>;
277
307
  setOverlay: (value: ShowOverlay, callback: () => void) => Promise<void>;
278
- createDialog: (config: Dialog) => DialogHandler;
308
+ createDialog: <I extends any = undefined, T extends any = undefined, Z extends Dialog<I> = Dialog<I>>(config: Z) => DialogHandler<DialogResultValue<T>[Z["type"]], T>;
279
309
  openDialog: (value: any, callback: (data: any) => any) => Promise<any>;
280
310
  closeDialog: (dialogId: number) => Promise<void>;
281
311
  setDialogResult: (buttonType: DialogButtonType, result: any) => Promise<void>;
@@ -285,6 +315,7 @@ export interface ChaynsReactFunctions {
285
315
  dispatchEventToDialogHost: (data: object) => Promise<void>;
286
316
  addDialogHostEventListener: (callback: (data: object) => void) => Promise<number>;
287
317
  removeDialogHostEventListener: (id: number) => Promise<void>;
318
+ addAnonymousAccount: () => Promise<AnonymousAccountResult>;
288
319
  }
289
320
  export type DialogResult = {
290
321
  open: () => Promise<any>;
@@ -813,4 +844,7 @@ export declare enum DialogIconType {
813
844
  WarningIcon = "%%DialogWarningIcon%%",
814
845
  ErrorIcon = "%%DialogErrorIcon%%"
815
846
  }
847
+ export type AnonymousAccountResult = {
848
+ token: string;
849
+ };
816
850
  export {};
@@ -4,6 +4,13 @@ declare class StaticChaynsApi {
4
4
  addDataListener: (cb: DataChangeCallback) => () => void;
5
5
  private _wrapper;
6
6
  constructor();
7
+ getUser: () => any;
7
8
  getSite: () => any;
9
+ getCurrentPage: () => any;
10
+ getDevice: () => any;
11
+ getLanguage: () => any;
12
+ getParameters: () => any;
13
+ getPages: () => any;
14
+ getEnvironment: () => any;
8
15
  }
9
16
  export default StaticChaynsApi;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chayns-api",
3
- "version": "1.1.0-31",
3
+ "version": "1.1.0-33",
4
4
  "description": "new chayns api",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",