chayns-api 1.1.0-9 → 1.2.0-0
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.
- package/dist/cjs/calls/index.js +11 -3
- package/dist/cjs/components/ChaynsProvider.js +2 -5
- package/dist/cjs/components/withHydrationBoundary.js +5 -9
- package/dist/cjs/constants/languages.js +19 -0
- package/dist/cjs/handler/DialogHandler.js +1 -2
- package/dist/cjs/host/ChaynsHost.js +20 -39
- package/dist/cjs/host/module/ModuleHost.js +2 -20
- package/dist/cjs/host/module/utils/loadComponent.js +84 -42
- package/dist/cjs/index.js +8 -1
- package/dist/cjs/util/transferNestedFunctions.js +5 -2
- package/dist/cjs/util/url.js +1 -1
- package/dist/cjs/wrapper/AppWrapper.js +81 -43
- package/dist/cjs/wrapper/FrameWrapper.js +5 -1
- package/dist/cjs/wrapper/StaticChaynsApi.js +7 -0
- package/dist/esm/calls/index.js +8 -3
- package/dist/esm/components/ChaynsProvider.js +2 -5
- package/dist/esm/components/withHydrationBoundary.js +5 -9
- package/dist/esm/constants/languages.js +13 -0
- package/dist/esm/handler/DialogHandler.js +1 -2
- package/dist/esm/host/ChaynsHost.js +18 -39
- package/dist/esm/host/module/ModuleHost.js +2 -20
- package/dist/esm/host/module/utils/loadComponent.js +87 -44
- package/dist/esm/index.js +1 -1
- package/dist/esm/util/transferNestedFunctions.js +5 -2
- package/dist/esm/util/url.js +2 -2
- package/dist/esm/wrapper/AppWrapper.js +85 -45
- package/dist/esm/wrapper/FrameWrapper.js +5 -1
- package/dist/esm/wrapper/StaticChaynsApi.js +7 -0
- package/dist/types/calls/index.d.ts +5 -1
- package/dist/types/components/withHydrationBoundary.d.ts +1 -1
- package/dist/types/constants/languages.d.ts +12 -0
- package/dist/types/handler/DialogHandler.d.ts +9 -3
- package/dist/types/hooks/useCurrentPage.d.ts +4 -1
- package/dist/types/hooks/useCustomData.d.ts +1 -1
- package/dist/types/host/ChaynsHost.d.ts +0 -1
- package/dist/types/host/module/ModuleHost.d.ts +1 -0
- package/dist/types/host/module/utils/loadComponent.d.ts +3 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/types/IChaynsReact.d.ts +42 -8
- package/dist/types/wrapper/AppWrapper.d.ts +0 -3
- package/dist/types/wrapper/StaticChaynsApi.d.ts +7 -0
- package/package.json +2 -2
|
@@ -24,8 +24,11 @@ Comlink.transferHandlers.set("FUNCTION", {
|
|
|
24
24
|
},
|
|
25
25
|
deserialize(obj) {
|
|
26
26
|
obj._functionKeys.forEach(x => {
|
|
27
|
-
|
|
28
|
-
obj[x]
|
|
27
|
+
// under certain conditions deserialize can be called more than once on same object
|
|
28
|
+
if (obj[x] instanceof MessagePort) {
|
|
29
|
+
obj[x].start();
|
|
30
|
+
obj[x] = Comlink.wrap(obj[x]);
|
|
31
|
+
}
|
|
29
32
|
});
|
|
30
33
|
return obj;
|
|
31
34
|
}
|
package/dist/esm/util/url.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Environment } from
|
|
1
|
+
import { Environment } from '../types/IChaynsReact';
|
|
2
2
|
export const replaceStagingUrl = (prevent, url, environment) => {
|
|
3
|
-
if (prevent) return url;
|
|
3
|
+
if (prevent || !url) return url;
|
|
4
4
|
let replacedUrl = url;
|
|
5
5
|
if (environment === Environment.Qa || environment === Environment.Development) {
|
|
6
6
|
replacedUrl = replacedUrl.replace('tapp.chayns-static.space', 'tapp-dev.chayns-static.space');
|
|
@@ -12,19 +12,22 @@ import getDeviceInfo, { getScreenSize } from '../util/deviceHelper';
|
|
|
12
12
|
import getUserInfo from '../calls/getUserInfo';
|
|
13
13
|
import { sendMessageToGroup, sendMessageToPage, sendMessageToUser } from '../calls/sendMessage';
|
|
14
14
|
import { addApiListener, dispatchApiEvent, removeApiListener } from '../helper/apiListenerHelper';
|
|
15
|
+
import { DeviceLanguage } from '../constants/languages';
|
|
15
16
|
let appWrapperDialogId = 0;
|
|
16
17
|
export class AppWrapper {
|
|
17
18
|
mapOldApiToNew(retVal) {
|
|
18
19
|
var _window, _colorMode, _window2, _AppInfo$TappSelected;
|
|
19
20
|
const {
|
|
20
21
|
AppInfo,
|
|
21
|
-
AppUser
|
|
22
|
+
AppUser,
|
|
23
|
+
Device
|
|
22
24
|
} = retVal;
|
|
23
25
|
this.accessToken = AppUser.TobitAccessToken;
|
|
24
26
|
const urlParams = new URLSearchParams(location.search);
|
|
25
27
|
const urlParamsLowerCase = new URLSearchParams(location.search.toLowerCase());
|
|
26
28
|
let tappId = urlParamsLowerCase.get('tappid');
|
|
27
29
|
let colorMode = urlParamsLowerCase.get('colormode');
|
|
30
|
+
let color = AppInfo.color;
|
|
28
31
|
if (colorMode) {
|
|
29
32
|
try {
|
|
30
33
|
colorMode = Number.parseInt(colorMode, 10);
|
|
@@ -37,6 +40,24 @@ export class AppWrapper {
|
|
|
37
40
|
// ignore
|
|
38
41
|
}
|
|
39
42
|
}
|
|
43
|
+
let language = AppInfo.Language;
|
|
44
|
+
if (!language) {
|
|
45
|
+
language = DeviceLanguage[Number.parseInt(Device === null || Device === void 0 ? void 0 : Device.LanguageID, 10)] || 'de';
|
|
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
|
+
}
|
|
40
61
|
return {
|
|
41
62
|
device: getDeviceInfo(navigator.userAgent, 'image/webp'),
|
|
42
63
|
environment: {
|
|
@@ -44,12 +65,11 @@ export class AppWrapper {
|
|
|
44
65
|
runtimeEnvironment: RuntimeEnviroment.Unknown
|
|
45
66
|
},
|
|
46
67
|
language: {
|
|
47
|
-
site:
|
|
68
|
+
site: language,
|
|
48
69
|
translation: null,
|
|
49
|
-
device:
|
|
50
|
-
active:
|
|
70
|
+
device: language,
|
|
71
|
+
active: language
|
|
51
72
|
},
|
|
52
|
-
// ToDo: Find better way to detect
|
|
53
73
|
site: {
|
|
54
74
|
id: AppInfo.SiteID,
|
|
55
75
|
locationId: AppInfo.LocationID,
|
|
@@ -65,7 +85,7 @@ export class AppWrapper {
|
|
|
65
85
|
},
|
|
66
86
|
title: AppInfo.Title,
|
|
67
87
|
colorMode: (_colorMode = colorMode) !== null && _colorMode !== void 0 ? _colorMode : AppInfo.colorMode,
|
|
68
|
-
color
|
|
88
|
+
color,
|
|
69
89
|
domain: AppInfo.domain,
|
|
70
90
|
font: {
|
|
71
91
|
id: Font.Roboto,
|
|
@@ -81,14 +101,14 @@ export class AppWrapper {
|
|
|
81
101
|
firstName: AppUser.FirstName,
|
|
82
102
|
lastName: AppUser.LastName,
|
|
83
103
|
gender: Gender.Unknown,
|
|
84
|
-
userId:
|
|
104
|
+
userId: userId,
|
|
85
105
|
personId: AppUser.PersonID,
|
|
86
106
|
uacGroups: []
|
|
87
107
|
},
|
|
88
108
|
customData: null,
|
|
89
109
|
isAdminModeActive: AppUser.AdminMode,
|
|
90
110
|
currentPage: {
|
|
91
|
-
id: ((_AppInfo$TappSelected = AppInfo.TappSelected) === null || _AppInfo$TappSelected === void 0 ? void 0 : _AppInfo$TappSelected.TappID)
|
|
111
|
+
id: tappId || ((_AppInfo$TappSelected = AppInfo.TappSelected) === null || _AppInfo$TappSelected === void 0 ? void 0 : _AppInfo$TappSelected.TappID),
|
|
92
112
|
siteId: AppInfo.SiteID
|
|
93
113
|
},
|
|
94
114
|
pages: AppInfo.Tapps.map(x => ({
|
|
@@ -105,6 +125,7 @@ export class AppWrapper {
|
|
|
105
125
|
};
|
|
106
126
|
}
|
|
107
127
|
constructor() {
|
|
128
|
+
var _this = this;
|
|
108
129
|
_defineProperty(this, "values", null);
|
|
109
130
|
_defineProperty(this, "accessToken", '');
|
|
110
131
|
_defineProperty(this, "counter", 0);
|
|
@@ -269,7 +290,7 @@ export class AppWrapper {
|
|
|
269
290
|
invokeAppCall(callObj);
|
|
270
291
|
},
|
|
271
292
|
login: async (value, callback, closeCallback) => {
|
|
272
|
-
const res = await this.appCall(
|
|
293
|
+
const res = await this.appCall(54, value);
|
|
273
294
|
return {
|
|
274
295
|
loginState: res === null || res === void 0 ? void 0 : res.loginState
|
|
275
296
|
};
|
|
@@ -321,7 +342,8 @@ export class AppWrapper {
|
|
|
321
342
|
shouldRemove
|
|
322
343
|
} = removeApiListener('geoLocationListener', id);
|
|
323
344
|
if (shouldRemove) {
|
|
324
|
-
// App does not support removal of request geo location call with permanent true which makes this a
|
|
345
|
+
// App does not support removal of request geo location call with permanent true which makes this a
|
|
346
|
+
// no-op
|
|
325
347
|
}
|
|
326
348
|
},
|
|
327
349
|
removeScrollListener: async id => {
|
|
@@ -476,44 +498,44 @@ export class AppWrapper {
|
|
|
476
498
|
});
|
|
477
499
|
},
|
|
478
500
|
createDialog: config => {
|
|
479
|
-
return new DialogHandler(config, this.functions.openDialog, this.functions.closeDialog);
|
|
501
|
+
return new DialogHandler(config, this.functions.openDialog, this.functions.closeDialog, this.functions.dispatchEventToDialogClient, this.functions.addDialogClientEventListener);
|
|
480
502
|
},
|
|
481
503
|
openDialog: async (config, callback) => {
|
|
482
504
|
const currentDialogId = appWrapperDialogId++;
|
|
483
|
-
|
|
484
|
-
|
|
505
|
+
this.appCall(184, {
|
|
506
|
+
dialogContent: {
|
|
507
|
+
apiVersion: 5,
|
|
508
|
+
config
|
|
509
|
+
},
|
|
510
|
+
externalDialogUrl: 'https://tapp.chayns-static.space/api/dialog-v2/v1/index.html'
|
|
511
|
+
}, {
|
|
512
|
+
awaitResult: true
|
|
513
|
+
}).then(result => {
|
|
485
514
|
callback(result);
|
|
486
|
-
|
|
487
|
-
};
|
|
488
|
-
this.dispatchDialogChange([...this.dialogs, {
|
|
489
|
-
config,
|
|
490
|
-
resolve,
|
|
491
|
-
dialogId: currentDialogId,
|
|
492
|
-
eventTarget
|
|
493
|
-
}]);
|
|
515
|
+
});
|
|
494
516
|
return currentDialogId;
|
|
495
517
|
},
|
|
496
|
-
closeDialog: dialogId
|
|
497
|
-
|
|
518
|
+
closeDialog: function (dialogId, result) {
|
|
519
|
+
let buttonType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : -1;
|
|
520
|
+
const dialog = _this.dialogs.find(x => x.dialogId === dialogId);
|
|
498
521
|
if (dialog) {
|
|
499
522
|
dialog.resolve({
|
|
500
|
-
buttonType
|
|
523
|
+
buttonType,
|
|
524
|
+
result
|
|
501
525
|
});
|
|
502
526
|
}
|
|
527
|
+
},
|
|
528
|
+
dispatchEventToDialogClient: () => this.notImplemented('dispatchEventToDialogClient'),
|
|
529
|
+
addDialogClientEventListener: () => this.notImplemented('addDialogClientEventListener'),
|
|
530
|
+
addAnonymousAccount: async () => {
|
|
531
|
+
return this.appCall(302);
|
|
503
532
|
}
|
|
504
533
|
});
|
|
505
534
|
_defineProperty(this, "dialogs", []);
|
|
506
|
-
_defineProperty(this, "dialogEventTarget", new EventTarget());
|
|
507
535
|
}
|
|
508
536
|
notImplemented(call) {
|
|
509
537
|
console.warn(`call ${call} not implement in app`);
|
|
510
538
|
}
|
|
511
|
-
dispatchDialogChange(detail) {
|
|
512
|
-
this.dialogs = detail;
|
|
513
|
-
this.dialogEventTarget.dispatchEvent(new CustomEvent('change', {
|
|
514
|
-
detail
|
|
515
|
-
}));
|
|
516
|
-
}
|
|
517
539
|
appCall(action) {
|
|
518
540
|
let value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
519
541
|
let {
|
|
@@ -546,24 +568,42 @@ export class AppWrapper {
|
|
|
546
568
|
});
|
|
547
569
|
});
|
|
548
570
|
}
|
|
549
|
-
getDialogEventTarget() {
|
|
550
|
-
return this.dialogEventTarget;
|
|
551
|
-
}
|
|
552
571
|
async init() {
|
|
553
572
|
this.values = this.mapOldApiToNew(await this.appCall(18));
|
|
554
|
-
const callbackName = `chaynsApiV5Callback_${this.counter++}`;
|
|
555
|
-
window.disablev4AccessTokenChangeListener = true;
|
|
556
|
-
window[callbackName] = _ref2 => {
|
|
557
|
-
let {
|
|
558
|
-
retVal: value
|
|
559
|
-
} = _ref2;
|
|
560
|
-
this.mapOldApiToNew(value);
|
|
561
|
-
};
|
|
562
573
|
this.appCall(66, {
|
|
563
|
-
enabled: true
|
|
564
|
-
callback: callbackName
|
|
574
|
+
enabled: true
|
|
565
575
|
}, {
|
|
566
|
-
|
|
576
|
+
callback: async () => {
|
|
577
|
+
this.values = this.mapOldApiToNew(await this.appCall(18));
|
|
578
|
+
document.dispatchEvent(new CustomEvent('chayns_api_data', {
|
|
579
|
+
detail: {
|
|
580
|
+
type: 'user',
|
|
581
|
+
value: this.values.user
|
|
582
|
+
}
|
|
583
|
+
}));
|
|
584
|
+
},
|
|
585
|
+
awaitResult: true
|
|
586
|
+
});
|
|
587
|
+
window.disablev4DesignSettingsChangeListener = true;
|
|
588
|
+
this.appCall(254, {
|
|
589
|
+
enabled: true
|
|
590
|
+
}, {
|
|
591
|
+
callback: _ref2 => {
|
|
592
|
+
let {
|
|
593
|
+
colorMode
|
|
594
|
+
} = _ref2;
|
|
595
|
+
this.values.site = {
|
|
596
|
+
...this.values.site,
|
|
597
|
+
colorMode
|
|
598
|
+
};
|
|
599
|
+
document.dispatchEvent(new CustomEvent('chayns_api_data', {
|
|
600
|
+
detail: {
|
|
601
|
+
type: 'site',
|
|
602
|
+
value: this.values.site
|
|
603
|
+
}
|
|
604
|
+
}));
|
|
605
|
+
},
|
|
606
|
+
awaitResult: true
|
|
567
607
|
});
|
|
568
608
|
return undefined;
|
|
569
609
|
}
|
|
@@ -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:
|
|
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
|
|
@@ -8,7 +8,7 @@ type HydrationComponent = React.FC<{
|
|
|
8
8
|
value: StoreLikeValue;
|
|
9
9
|
children?: React.ReactNode;
|
|
10
10
|
}>;
|
|
11
|
-
type Initializer = (initialValue: object | undefined) => StoreLikeValue;
|
|
11
|
+
type Initializer = (initialValue: object | undefined, id: string) => StoreLikeValue;
|
|
12
12
|
type HydrationBoundary = React.FC<{
|
|
13
13
|
id?: string;
|
|
14
14
|
children?: React.ReactNode;
|
|
@@ -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<
|
|
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():
|
|
20
|
+
getResult(): {
|
|
21
|
+
buttonType: number;
|
|
22
|
+
result: T extends undefined ? S : T;
|
|
23
|
+
} | undefined;
|
|
18
24
|
}
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare const loadModule: (scope: any, module: any, url: any, preventSingleton?: boolean) => any;
|
|
2
|
+
declare const loadComponent: (scope: any, module: any, url: any, skipCompatMode?: boolean, preventSingleton?: boolean) => any;
|
|
3
|
+
export default loadComponent;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export * from './components/withCompatMode';
|
|
|
11
11
|
export * from './constants';
|
|
12
12
|
export { default as withHydrationBoundary } from './components/withHydrationBoundary';
|
|
13
13
|
export { default as StaticChaynsApi } from './wrapper/StaticChaynsApi';
|
|
14
|
-
export { default as loadComponent } from './host/module/utils/loadComponent';
|
|
14
|
+
export { default as loadComponent, loadModule } from './host/module/utils/loadComponent';
|
|
15
15
|
export { default as DialogHandler } from './handler/DialogHandler';
|
|
16
16
|
export * as dialog from './calls/dialogs/index';
|
|
17
17
|
export * from './types/IChaynsReact';
|
|
@@ -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 |
|
|
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
|
|
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
|
|
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
|
|
92
|
-
inputType
|
|
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:
|
|
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 {};
|
|
@@ -5,7 +5,6 @@ export declare class AppWrapper implements IChaynsReact {
|
|
|
5
5
|
mapOldApiToNew(retVal: any): ChaynsReactValues;
|
|
6
6
|
constructor();
|
|
7
7
|
notImplemented(call: string): void;
|
|
8
|
-
private dispatchDialogChange;
|
|
9
8
|
counter: number;
|
|
10
9
|
appCall(action: any, value?: unknown, { callback, awaitResult }?: {
|
|
11
10
|
callback: any;
|
|
@@ -13,8 +12,6 @@ export declare class AppWrapper implements IChaynsReact {
|
|
|
13
12
|
}): Promise<unknown> | undefined;
|
|
14
13
|
functions: ChaynsReactFunctions;
|
|
15
14
|
private dialogs;
|
|
16
|
-
dialogEventTarget: EventTarget;
|
|
17
|
-
getDialogEventTarget(): EventTarget;
|
|
18
15
|
init(): Promise<undefined>;
|
|
19
16
|
getSSRData(): null;
|
|
20
17
|
addDataListener(cb: DataChangeCallback): CleanupCallback;
|
|
@@ -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.
|
|
3
|
+
"version": "1.2.0-0",
|
|
4
4
|
"description": "new chayns api",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"extends": "@chayns-toolkit"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@module-federation/runtime": "^0.1.
|
|
45
|
+
"@module-federation/runtime": "^0.1.13",
|
|
46
46
|
"@types/semver": "^7.5.8",
|
|
47
47
|
"comlink": "4.3.1",
|
|
48
48
|
"detect-browser": "^5.2.1",
|