@alipay/ams-checkout 0.0.1744283958-dev.0 → 0.0.1744283958-dev.10
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/umd/ams-checkout.min.js +1 -1
- package/esm/config/index.d.ts +7 -7
- package/esm/config/index.js +7 -7
- package/esm/constant/index.d.ts +6 -0
- package/esm/constant/index.js +6 -0
- package/esm/core/component/element/elementContainerService/containerService.d.ts +3 -0
- package/esm/core/component/element/elementContainerService/containerService.js +17 -2
- package/esm/core/component/element/elementContainerService/index.d.ts +1 -0
- package/esm/core/component/element/elementContainerService/index.js +8 -0
- package/esm/core/component/element/elementController/index.d.ts +5 -0
- package/esm/core/component/element/elementController/index.js +188 -95
- package/esm/core/component/element/elementProcessor/addressProcessor.d.ts +4 -1
- package/esm/core/component/element/elementProcessor/addressProcessor.js +28 -6
- package/esm/core/component/element/elementProcessor/authProcessor.d.ts +4 -1
- package/esm/core/component/element/elementProcessor/authProcessor.js +28 -566
- package/esm/core/component/element/elementProcessor/baseElementProcessor.d.ts +2 -0
- package/esm/core/component/element/elementProcessor/baseElementProcessor.js +6 -0
- package/esm/core/component/element/elementProcessor/paymentProcessor.js +53 -18
- package/esm/core/component/element/mock.d.ts +8 -0
- package/esm/core/component/element/mock.js +927 -0
- package/esm/core/component/element/type.d.ts +13 -0
- package/esm/core/component/element/util.d.ts +2 -1
- package/esm/core/component/element/util.js +124 -0
- package/esm/foundation/core/index.js +2 -1
- package/esm/foundation/index.d.ts +7 -0
- package/esm/foundation/index.js +3 -0
- package/esm/foundation/service/container/index.js +9 -2
- package/package.json +1 -1
@@ -375,4 +375,17 @@ export interface IElementProcessors {
|
|
375
375
|
[ElementType.address]: AddressProcessor;
|
376
376
|
[ElementType.payment]: PaymentProcessor;
|
377
377
|
}
|
378
|
+
export interface IToastOptions {
|
379
|
+
position?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'center';
|
380
|
+
backgroundColor?: string;
|
381
|
+
color?: string;
|
382
|
+
padding?: string;
|
383
|
+
borderRadius?: string;
|
384
|
+
fontSize?: string;
|
385
|
+
zIndex?: number;
|
386
|
+
width?: string;
|
387
|
+
duration?: number;
|
388
|
+
icon?: 'SUCCESS' | 'FAIL';
|
389
|
+
spin?: boolean;
|
390
|
+
}
|
378
391
|
export {};
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { IElementStatus } from '../../../foundation';
|
2
2
|
import { Ianalytics, IPaymentSessionMetaData } from '../../../types';
|
3
3
|
import { ContainerController } from './elementContainerService/containerService';
|
4
|
-
import { ELEMENT_ENVIRONMENT_TYPE, IElementOptions } from './type';
|
4
|
+
import { ELEMENT_ENVIRONMENT_TYPE, IElementOptions, IToastOptions } from './type';
|
5
5
|
declare const formatElementOption: (options: IElementOptions) => {
|
6
6
|
environment: ELEMENT_ENVIRONMENT_TYPE;
|
7
7
|
locale?: string;
|
@@ -56,4 +56,5 @@ export declare function redirect(data: {
|
|
56
56
|
applinkUrl?: string;
|
57
57
|
callAppJudgeTime?: number;
|
58
58
|
}): Promise<void>;
|
59
|
+
export declare function showToast(options?: IToastOptions, callback?: Function): void;
|
59
60
|
export { formatElementOption };
|
@@ -324,4 +324,128 @@ export function redirect(data) {
|
|
324
324
|
}
|
325
325
|
});
|
326
326
|
}
|
327
|
+
export function showToast() {
|
328
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
329
|
+
var callback = arguments.length > 1 ? arguments[1] : undefined;
|
330
|
+
var createNode = function createNode() {
|
331
|
+
var tag = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'div';
|
332
|
+
var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
333
|
+
var children = arguments.length > 2 ? arguments[2] : undefined;
|
334
|
+
var node = document.createElement(tag);
|
335
|
+
Object.keys(props).forEach(function (key) {
|
336
|
+
if (key === 'style') {
|
337
|
+
Object.keys(props[key]).forEach(function (styleKey) {
|
338
|
+
node.style[styleKey] = props[key][styleKey];
|
339
|
+
});
|
340
|
+
} else {
|
341
|
+
node.setAttribute(key, props[key]);
|
342
|
+
}
|
343
|
+
});
|
344
|
+
if (typeof children === 'string') node.textContent = children;
|
345
|
+
return node;
|
346
|
+
};
|
347
|
+
var defaultOptions = {
|
348
|
+
position: 'bottom-right',
|
349
|
+
backgroundColor: 'rgba(0, 0, 0, 0.80)',
|
350
|
+
color: '#ffffff',
|
351
|
+
padding: '20px 16px',
|
352
|
+
borderRadius: '8px',
|
353
|
+
fontSize: '14px',
|
354
|
+
zIndex: 9999,
|
355
|
+
width: '148px',
|
356
|
+
duration: 2000
|
357
|
+
};
|
358
|
+
var defaultIcon = {
|
359
|
+
SUCCESS: 'https://cdn.marmot-cloud.com/storage/2024/07/10/10b191d6-0b0a-4bd9-96cc-310b7f2a8530.svg',
|
360
|
+
FAIL: 'https://cdn.marmot-cloud.com/storage/2024/11/08/4ae27343-61d2-4a07-b323-c951c7711b40.svg'
|
361
|
+
};
|
362
|
+
var config = _objectSpread(_objectSpread({}, defaultOptions), options);
|
363
|
+
var container = document.getElementById('antom_toast-container');
|
364
|
+
if (!container) {
|
365
|
+
container = createNode('div', {
|
366
|
+
style: {
|
367
|
+
position: 'fixed',
|
368
|
+
display: 'flex',
|
369
|
+
justifyContent: 'center',
|
370
|
+
alignItems: 'center',
|
371
|
+
pointerEvents: 'none'
|
372
|
+
},
|
373
|
+
id: 'antom_toast-container'
|
374
|
+
});
|
375
|
+
document.body.appendChild(container);
|
376
|
+
} else {
|
377
|
+
container.innerHTML = '';
|
378
|
+
}
|
379
|
+
switch (config.position) {
|
380
|
+
case 'top-left':
|
381
|
+
container.style.top = '20px';
|
382
|
+
container.style.left = '20px';
|
383
|
+
break;
|
384
|
+
case 'top-right':
|
385
|
+
container.style.top = '20px';
|
386
|
+
container.style.right = '20px';
|
387
|
+
break;
|
388
|
+
case 'bottom-left':
|
389
|
+
container.style.bottom = '20px';
|
390
|
+
container.style.left = '20px';
|
391
|
+
break;
|
392
|
+
case 'bottom-right':
|
393
|
+
default:
|
394
|
+
container.style.bottom = '0';
|
395
|
+
container.style.right = '0';
|
396
|
+
container.style.top = '0';
|
397
|
+
container.style.left = '0';
|
398
|
+
break;
|
399
|
+
}
|
400
|
+
var toast = createNode('div', {
|
401
|
+
style: {
|
402
|
+
backgroundColor: config.backgroundColor,
|
403
|
+
color: config.color,
|
404
|
+
padding: config.padding,
|
405
|
+
borderRadius: config.borderRadius,
|
406
|
+
fontSize: config.fontSize,
|
407
|
+
opacity: '0',
|
408
|
+
transition: 'opacity 0.3s ease-in-out',
|
409
|
+
display: 'flex',
|
410
|
+
alignItems: 'center',
|
411
|
+
justifyContent: 'center',
|
412
|
+
flexDirection: 'column',
|
413
|
+
width: config.width,
|
414
|
+
boxSizing: 'border-box'
|
415
|
+
}
|
416
|
+
});
|
417
|
+
if (config.icon) {
|
418
|
+
var icon = createNode('img', {
|
419
|
+
style: {
|
420
|
+
width: '40px',
|
421
|
+
height: '40px'
|
422
|
+
},
|
423
|
+
src: config.icon ? defaultIcon[config.icon] : ''
|
424
|
+
});
|
425
|
+
toast.appendChild(icon);
|
426
|
+
}
|
427
|
+
var text = createNode('span', {
|
428
|
+
style: {
|
429
|
+
textAlign: 'center',
|
430
|
+
marginTop: '12px',
|
431
|
+
lineHeight: '20px',
|
432
|
+
fontFamily: "Noto Sans",
|
433
|
+
fontWeight: 400,
|
434
|
+
fontSize: '14px'
|
435
|
+
}
|
436
|
+
}, config.message);
|
437
|
+
toast.appendChild(text);
|
438
|
+
container.appendChild(toast);
|
439
|
+
setTimeout(function () {
|
440
|
+
toast.style.opacity = '1';
|
441
|
+
}, 10);
|
442
|
+
setTimeout(function () {
|
443
|
+
toast.style.opacity = '0';
|
444
|
+
setTimeout(function () {
|
445
|
+
var _container;
|
446
|
+
(_container = container) === null || _container === void 0 || _container.remove();
|
447
|
+
callback && callback();
|
448
|
+
}, 300);
|
449
|
+
}, config.duration);
|
450
|
+
}
|
327
451
|
export { formatElementOption };
|
@@ -406,7 +406,8 @@ export var AntomSDKCore = /*#__PURE__*/function () {
|
|
406
406
|
var immediately = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
407
407
|
var containerService = ServiceProvider.getInstance(this.instanceId).getService('Container');
|
408
408
|
var cleanElement = function cleanElement() {
|
409
|
-
|
409
|
+
var _this3$paymentContext;
|
410
|
+
containerService.cleanContainer((_this3$paymentContext = _this3.paymentContext) === null || _this3$paymentContext === void 0 ? void 0 : _this3$paymentContext.displayInfo);
|
410
411
|
cleanMockup();
|
411
412
|
removeRetentionPopup();
|
412
413
|
// TODO @/component this.removeEventListener();
|
@@ -28,6 +28,13 @@ export declare class DisplayInfo {
|
|
28
28
|
selector: string;
|
29
29
|
appearance?: Record<string, any>;
|
30
30
|
appendAliasContainerId?: boolean;
|
31
|
+
merchantAppointParam?: {
|
32
|
+
storedCard: {
|
33
|
+
needCVV: boolean;
|
34
|
+
};
|
35
|
+
};
|
36
|
+
iframeStyle?: Partial<CSSStyleDeclaration>;
|
37
|
+
notRedirectAfterComplete?: boolean;
|
31
38
|
constructor();
|
32
39
|
}
|
33
40
|
/**
|
package/esm/foundation/index.js
CHANGED
@@ -26,6 +26,9 @@ export var DisplayInfo = /*#__PURE__*/_createClass(function DisplayInfo() {
|
|
26
26
|
_defineProperty(this, "appearance", void 0);
|
27
27
|
// append selector name to containerId
|
28
28
|
_defineProperty(this, "appendAliasContainerId", void 0);
|
29
|
+
_defineProperty(this, "merchantAppointParam", void 0);
|
30
|
+
_defineProperty(this, "iframeStyle", void 0);
|
31
|
+
_defineProperty(this, "notRedirectAfterComplete", void 0);
|
29
32
|
this.platform = isPC() ? PlatformEnum.desktop : PlatformEnum.mobile;
|
30
33
|
this.isRetention = true;
|
31
34
|
this.type = DisplayTypeEnum.popup;
|
@@ -7,6 +7,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
7
7
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
8
8
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
9
9
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
10
|
+
import { isEmpty } from "../../../util";
|
10
11
|
import { addInlineLoading, createInlineBaseElement } from "../../../component/component.inline.style";
|
11
12
|
import { addPopupLoading, createBaseElement } from "../../../component/component.popup.style";
|
12
13
|
import { insertStyleSheet } from "../../../component/popupWindow.style";
|
@@ -64,6 +65,12 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
64
65
|
type = displayInfo.type,
|
65
66
|
platform = displayInfo.platform;
|
66
67
|
var webApp = createIframe('antom-sdk-web-app' + (displayInfo.appendAliasContainerId ? "-".concat(selector) : ''));
|
68
|
+
if (!isEmpty(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.iframeStyle)) {
|
69
|
+
Object.keys(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.iframeStyle).forEach(function (key) {
|
70
|
+
var _displayInfo$iframeSt;
|
71
|
+
webApp.style[key] = displayInfo === null || displayInfo === void 0 || (_displayInfo$iframeSt = displayInfo.iframeStyle) === null || _displayInfo$iframeSt === void 0 ? void 0 : _displayInfo$iframeSt[key];
|
72
|
+
});
|
73
|
+
}
|
67
74
|
this.webApp = webApp;
|
68
75
|
this.displayInfo = displayInfo;
|
69
76
|
webApp.src = url;
|
@@ -83,7 +90,7 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
83
90
|
value: function cleanContainer(displayInfo) {
|
84
91
|
var _document$getElementB;
|
85
92
|
// selector and container
|
86
|
-
var selector = displayInfo.type === DisplayTypeEnum.inline ? displayInfo.selector : COMPONENT_CONTAINER_ID;
|
93
|
+
var selector = (displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.type) === DisplayTypeEnum.inline ? displayInfo.selector : COMPONENT_CONTAINER_ID;
|
87
94
|
var selectorDom = document.querySelector(selector);
|
88
95
|
if (selectorDom) {
|
89
96
|
selectorDom.innerHTML = '';
|
@@ -94,7 +101,7 @@ export var ContainerService = /*#__PURE__*/function () {
|
|
94
101
|
this.eventCenter.cleanIFrames();
|
95
102
|
|
96
103
|
// animation
|
97
|
-
(_document$getElementB = document.getElementById("".concat(COMPONENT_CONTAINER_ID, "-").concat(displayInfo.platform, "-animation-style"))) === null || _document$getElementB === void 0 || _document$getElementB.remove();
|
104
|
+
(_document$getElementB = document.getElementById("".concat(COMPONENT_CONTAINER_ID, "-").concat(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.platform, "-animation-style"))) === null || _document$getElementB === void 0 || _document$getElementB.remove();
|
98
105
|
}
|
99
106
|
}, {
|
100
107
|
key: "showLoading",
|