chayns-api 2.4.11 → 2.4.13
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/constants/DefaultLoginDialogOptions.js +2 -1
- package/dist/cjs/wrapper/AppWrapper.js +22 -4
- package/dist/esm/constants/DefaultLoginDialogOptions.js +2 -1
- package/dist/esm/wrapper/AppWrapper.js +26 -5
- package/dist/types/constants/DefaultLoginDialogOptions.d.ts +1 -0
- package/dist/types/types/IChaynsReact.d.ts +1 -0
- package/package.json +1 -1
|
@@ -15,6 +15,7 @@ var _appCall = _interopRequireDefault(require("../util/appCall"));
|
|
|
15
15
|
var _appStorage = require("../util/appStorage");
|
|
16
16
|
var _deviceHelper = _interopRequireWildcard(require("../util/deviceHelper"));
|
|
17
17
|
var _is = require("../util/is");
|
|
18
|
+
var _constants = require("../constants");
|
|
18
19
|
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); }
|
|
19
20
|
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; }
|
|
20
21
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -351,11 +352,28 @@ class AppWrapper {
|
|
|
351
352
|
};
|
|
352
353
|
(0, _appCall.default)(callObj);
|
|
353
354
|
},
|
|
354
|
-
login: async (value, callback, closeCallback) => {
|
|
355
|
-
const
|
|
356
|
-
|
|
357
|
-
|
|
355
|
+
login: async (value = {}, callback, closeCallback) => {
|
|
356
|
+
const {
|
|
357
|
+
result,
|
|
358
|
+
buttonType
|
|
359
|
+
} = await this.createDialog({
|
|
360
|
+
..._constants.DefaultLoginDialogOptions,
|
|
361
|
+
...value
|
|
362
|
+
}).open();
|
|
363
|
+
if (buttonType === _IChaynsReact.DialogButtonType.OK && result.token) {
|
|
364
|
+
const response = {
|
|
365
|
+
loginState: _IChaynsReact.LoginState.SUCCESS,
|
|
366
|
+
...result
|
|
367
|
+
};
|
|
368
|
+
callback(response);
|
|
369
|
+
return response;
|
|
370
|
+
}
|
|
371
|
+
const response = {
|
|
372
|
+
loginState: _IChaynsReact.LoginState.LoginFailed,
|
|
373
|
+
...result
|
|
358
374
|
};
|
|
375
|
+
closeCallback(response);
|
|
376
|
+
return response;
|
|
359
377
|
},
|
|
360
378
|
logout: async () => {
|
|
361
379
|
this.appCall(56, undefined, {
|
|
@@ -7,11 +7,12 @@ import { sendMessageToGroup, sendMessageToPage, sendMessageToUser } from '../cal
|
|
|
7
7
|
import { DeviceLanguage } from '../constants/languages';
|
|
8
8
|
import DialogHandler from '../handler/DialogHandler';
|
|
9
9
|
import { addApiListener, dispatchApiEvent, removeApiListener } from '../helper/apiListenerHelper';
|
|
10
|
-
import { AppName, Environment, Font, Gender, IconType, RuntimeEnviroment, TappEvent } from '../types/IChaynsReact';
|
|
10
|
+
import { AppName, DialogButtonType, Environment, Font, Gender, IconType, LoginState, RuntimeEnviroment, TappEvent } from '../types/IChaynsReact';
|
|
11
11
|
import invokeAppCall from '../util/appCall';
|
|
12
12
|
import { addAppStorageListener, clearAppStorage, isAppStorageAvailable, setAppStorageItem } from '../util/appStorage';
|
|
13
13
|
import getDeviceInfo, { getScreenSize } from '../util/deviceHelper';
|
|
14
14
|
import { isAppCallSupported } from '../util/is';
|
|
15
|
+
import { DefaultLoginDialogOptions } from '../constants';
|
|
15
16
|
export class AppWrapper {
|
|
16
17
|
async loadStyleSettings(siteId) {
|
|
17
18
|
try {
|
|
@@ -314,11 +315,31 @@ export class AppWrapper {
|
|
|
314
315
|
};
|
|
315
316
|
invokeAppCall(callObj);
|
|
316
317
|
},
|
|
317
|
-
login: async (
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
318
|
+
login: async function () {
|
|
319
|
+
let value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
320
|
+
let callback = arguments.length > 1 ? arguments[1] : undefined;
|
|
321
|
+
let closeCallback = arguments.length > 2 ? arguments[2] : undefined;
|
|
322
|
+
const {
|
|
323
|
+
result,
|
|
324
|
+
buttonType
|
|
325
|
+
} = await _this.createDialog({
|
|
326
|
+
...DefaultLoginDialogOptions,
|
|
327
|
+
...value
|
|
328
|
+
}).open();
|
|
329
|
+
if (buttonType === DialogButtonType.OK && result.token) {
|
|
330
|
+
const response = {
|
|
331
|
+
loginState: LoginState.SUCCESS,
|
|
332
|
+
...result
|
|
333
|
+
};
|
|
334
|
+
callback(response);
|
|
335
|
+
return response;
|
|
336
|
+
}
|
|
337
|
+
const response = {
|
|
338
|
+
loginState: LoginState.LoginFailed,
|
|
339
|
+
...result
|
|
321
340
|
};
|
|
341
|
+
closeCallback(response);
|
|
342
|
+
return response;
|
|
322
343
|
},
|
|
323
344
|
logout: async () => {
|
|
324
345
|
this.appCall(56, undefined, {
|
|
@@ -82,6 +82,7 @@ export interface BaseDialog {
|
|
|
82
82
|
type: DialogAnimation;
|
|
83
83
|
config?: any;
|
|
84
84
|
};
|
|
85
|
+
hideDragHandle?: boolean;
|
|
85
86
|
}
|
|
86
87
|
export type Dialog<T = object> = BaseDialog & (DialogAlert | DialogConfirm | DialogInput | DialogModule<T> | DialogIFrame<T> | DialogSelect | DialogDate | DialogToast | DialogSignature | DialogFileSelect);
|
|
87
88
|
export interface DialogSignature {
|