@alipay/ams-checkout 0.0.1691743027-dev.4 → 0.0.1691743027-dev.5
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/constant/index.d.ts +12 -0
- package/esm/constant/index.js +12 -0
- package/esm/plugin/component/{component.style.d.ts → component.inline.style.d.ts} +2 -2
- package/esm/plugin/component/component.inline.style.js +38 -0
- package/esm/plugin/component/component.popup.style.d.ts +9 -0
- package/esm/plugin/component/component.popup.style.js +115 -0
- package/esm/plugin/component/index.d.ts +5 -20
- package/esm/plugin/component/index.js +102 -231
- package/package.json +1 -1
- package/esm/plugin/component/component.style.js +0 -43
@@ -15,31 +15,23 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
15
15
|
* 2. If applicable, the use of the Software is also subject to the terms and conditions of any non-disclosure agreement signed by you and the relevant Ant Group entity.
|
16
16
|
*/
|
17
17
|
/* eslint-disable no-console */
|
18
|
-
import {
|
18
|
+
import { COMPONENTPLUGINID, COMPONENT_CLOSE_BLOCK_ID, COMPONENT_CONTAINER_ID, COMPONENT_RETENTION_ID, COMPONENT_SECTION_ID, ERRORMESSAGE, EVENT, LISTENER_PREFIX, LOADING_ID, LOADTIME_LIMIT, MOCKUP_ID } from "../../constant";
|
19
19
|
import { queryPaymentInfo } from "../../service";
|
20
|
-
import { componentSignEnum, messageName, platformEnum, productSceneEnum, renderDisplayTypeEnum, targetEnum
|
21
|
-
import {
|
20
|
+
import { componentSignEnum, eventCodeEnum, messageName, platformEnum, productSceneEnum, renderDisplayTypeEnum, targetEnum } from "../../types";
|
21
|
+
import { getType, isJsonString, isPC } from "../../util";
|
22
22
|
import { isLocalMock } from "../../util/mock";
|
23
23
|
import { createIframe, getAppDomain, getIframeUrl } from "./cashierApp";
|
24
|
-
import {
|
24
|
+
import { addInlineLoading, createInlineBaseElement } from "./component.inline.style";
|
25
|
+
import { addPopupLoading, createBaseElement, createMockup, createRetentionPopup, hideRetentionPopup, removeRetentionPopup as _removeRetentionPopup } from "./component.popup.style";
|
25
26
|
var _window = window,
|
26
27
|
innerHeight = _window.innerHeight;
|
27
|
-
var componentContainerId = 'ams-component-container';
|
28
|
-
var componentSectionId = 'ams-component-section';
|
29
|
-
var componentCloseBlockId = 'asm-component-close-block';
|
30
|
-
var componentRetentionId = 'ams-component-retention';
|
31
|
-
var mockupId = 'ams-component-mockup';
|
32
|
-
var loadingId = 'ams-component-loading';
|
33
|
-
var listenerPrefix = '_ams_sdk_component_listener';
|
34
|
-
var inlineBaseStyleId = 'ams-inline-component-style';
|
35
|
-
var loadTimeLimit = 15000;
|
36
28
|
var ComponentApp = /*#__PURE__*/function () {
|
37
29
|
function ComponentApp() {
|
38
30
|
_classCallCheck(this, ComponentApp);
|
39
31
|
_defineProperty(this, "app", void 0);
|
40
|
-
_defineProperty(this, "appDomain", void 0);
|
41
32
|
_defineProperty(this, "AMSSDK", void 0);
|
42
33
|
_defineProperty(this, "platform", void 0);
|
34
|
+
_defineProperty(this, "appDomain", void 0);
|
43
35
|
_defineProperty(this, "createIframeNode", void 0);
|
44
36
|
_defineProperty(this, "_selector", void 0);
|
45
37
|
_defineProperty(this, "_appVersion", void 0);
|
@@ -54,7 +46,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
54
46
|
_defineProperty(this, "_renderDisplayType", renderDisplayTypeEnum.popup);
|
55
47
|
this._appVersion = '1.5.0';
|
56
48
|
this._isInitComponent = false;
|
57
|
-
this._selector = "#".concat(
|
49
|
+
this._selector = "#".concat(COMPONENT_SECTION_ID);
|
58
50
|
this.createIframeNode = function () {
|
59
51
|
return Promise.resolve();
|
60
52
|
};
|
@@ -111,7 +103,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
111
103
|
this._componentSign = componentSign;
|
112
104
|
if (renderParams !== null && renderParams !== void 0 && renderParams.selector) this._selector = renderParams.selector;
|
113
105
|
this._renderDisplayType = renderParams.renderDisplayType;
|
114
|
-
var insertedNode = this._renderDisplayType === renderDisplayTypeEnum.inline ? "#".concat(
|
106
|
+
var insertedNode = this._renderDisplayType === renderDisplayTypeEnum.inline ? "#".concat(COMPONENT_CONTAINER_ID) : this._selector;
|
115
107
|
this._performanceData.push({
|
116
108
|
key: 'sdk_create_component',
|
117
109
|
value: Date.now()
|
@@ -120,13 +112,13 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
120
112
|
code: eventCodeEnum.SDK_START_OF_LOADING
|
121
113
|
});
|
122
114
|
if (this._renderDisplayType === renderDisplayTypeEnum.inline) {
|
123
|
-
this.
|
115
|
+
var container = createInlineBaseElement(this._selector);
|
116
|
+
if (container) this.renderInlineLoading(renderParams, container);
|
124
117
|
}
|
125
118
|
if (this._renderDisplayType === renderDisplayTypeEnum.popup) {
|
126
|
-
this.
|
127
|
-
this.
|
128
|
-
|
129
|
-
this.createMockup();
|
119
|
+
createBaseElement(this.platform, this.closeBtnFunc);
|
120
|
+
createRetentionPopup(this.platform, this.hideRetentionPopupFunc, this.retentionPopupLeaveFunc);
|
121
|
+
createMockup();
|
130
122
|
this.renderPopupLoading(renderParams);
|
131
123
|
}
|
132
124
|
this.createApp(renderParams);
|
@@ -139,17 +131,23 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
139
131
|
});
|
140
132
|
}
|
141
133
|
}, {
|
142
|
-
key: "
|
143
|
-
value: function
|
134
|
+
key: "renderInlineLoading",
|
135
|
+
value: function renderInlineLoading(renderParams, selector) {
|
144
136
|
var _renderParams$appeara;
|
145
137
|
var showLoading = renderParams === null || renderParams === void 0 ? void 0 : (_renderParams$appeara = renderParams.appearance) === null || _renderParams$appeara === void 0 ? void 0 : _renderParams$appeara.showLoading;
|
146
138
|
showLoading = typeof showLoading === 'boolean' ? showLoading : true;
|
139
|
+
if (showLoading) addInlineLoading(selector, this.platform);
|
140
|
+
}
|
141
|
+
}, {
|
142
|
+
key: "renderPopupLoading",
|
143
|
+
value: function renderPopupLoading(renderParams) {
|
144
|
+
var _renderParams$appeara2;
|
145
|
+
var showLoading = renderParams === null || renderParams === void 0 ? void 0 : (_renderParams$appeara2 = renderParams.appearance) === null || _renderParams$appeara2 === void 0 ? void 0 : _renderParams$appeara2.showLoading;
|
146
|
+
showLoading = typeof showLoading === 'boolean' ? showLoading : true;
|
147
147
|
if (!showLoading) return;
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
return this.showPopupLoading();
|
152
|
-
}
|
148
|
+
var mockup = document.getElementById(MOCKUP_ID);
|
149
|
+
if (mockup) mockup.style.display = 'block';
|
150
|
+
addPopupLoading();
|
153
151
|
}
|
154
152
|
}, {
|
155
153
|
key: "createLoadAppPromise",
|
@@ -159,7 +157,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
159
157
|
_this2._loadAppPromiseResolve = resolve;
|
160
158
|
setTimeout(function () {
|
161
159
|
reject(ERRORMESSAGE.CREATECOMPONENT_ERROR.LOAD_APP_TIMEOUT);
|
162
|
-
},
|
160
|
+
}, LOADTIME_LIMIT);
|
163
161
|
}).catch(function (error) {
|
164
162
|
_this2.dispatchToSDK(EVENT.error.name, {
|
165
163
|
code: ERRORMESSAGE.CREATECOMPONENT_ERROR.code,
|
@@ -266,16 +264,32 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
266
264
|
return this._actionQueryPromise;
|
267
265
|
}
|
268
266
|
}, {
|
269
|
-
key: "
|
270
|
-
value: function
|
267
|
+
key: "cleanElement",
|
268
|
+
value: function cleanElement() {
|
271
269
|
try {
|
272
|
-
|
273
|
-
|
270
|
+
var _document$getElementB;
|
271
|
+
// selector and container
|
274
272
|
if (getType(this._selector) === 'string') {
|
275
273
|
var selectorDom = document.querySelector(this._selector);
|
276
274
|
if (selectorDom) selectorDom.innerHTML = '';
|
277
275
|
}
|
278
|
-
|
276
|
+
var container = document.getElementById(COMPONENT_CONTAINER_ID);
|
277
|
+
if (container) container === null || container === void 0 ? void 0 : container.remove();
|
278
|
+
|
279
|
+
// animation
|
280
|
+
(_document$getElementB = document.getElementById("".concat(COMPONENT_CONTAINER_ID, "-").concat(this.platform, "-animation-style"))) === null || _document$getElementB === void 0 ? void 0 : _document$getElementB.remove();
|
281
|
+
|
282
|
+
// mockup
|
283
|
+
var body = document.getElementsByTagName('body')[0];
|
284
|
+
body.style.overflow = 'auto';
|
285
|
+
var mockup = document.getElementById(MOCKUP_ID);
|
286
|
+
mockup === null || mockup === void 0 ? void 0 : mockup.remove();
|
287
|
+
|
288
|
+
// retentionPopup
|
289
|
+
this.removeRetentionPopup(this.platform);
|
290
|
+
|
291
|
+
// listener
|
292
|
+
this._removeEventListener();
|
279
293
|
} catch (error) {
|
280
294
|
console.error(error);
|
281
295
|
}
|
@@ -348,7 +362,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
348
362
|
}, {
|
349
363
|
key: "resizeListener",
|
350
364
|
value: function resizeListener() {
|
351
|
-
var cashier = document.getElementById(
|
365
|
+
var cashier = document.getElementById(COMPONENT_CONTAINER_ID);
|
352
366
|
cashier.style.transition = 'none';
|
353
367
|
this.dispatchToApp({
|
354
368
|
context: {
|
@@ -368,16 +382,16 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
368
382
|
key: "_addEventListener",
|
369
383
|
value: function _addEventListener() {
|
370
384
|
this._removeEventListener();
|
371
|
-
window["".concat(
|
372
|
-
window["".concat(
|
373
|
-
window.addEventListener('message', window["".concat(
|
374
|
-
window.addEventListener('resize', window["".concat(
|
385
|
+
window["".concat(LISTENER_PREFIX, "_").concat(this.AMSSDK._instanceId)] = this.listener.bind(this);
|
386
|
+
window["".concat(LISTENER_PREFIX, "_").concat(this.AMSSDK._instanceId, "_resize")] = this.resizeListener.bind(this);
|
387
|
+
window.addEventListener('message', window["".concat(LISTENER_PREFIX, "_").concat(this.AMSSDK._instanceId)]);
|
388
|
+
window.addEventListener('resize', window["".concat(LISTENER_PREFIX, "_").concat(this.AMSSDK._instanceId, "_resize")]);
|
375
389
|
}
|
376
390
|
}, {
|
377
391
|
key: "_removeEventListener",
|
378
392
|
value: function _removeEventListener() {
|
379
|
-
window.removeEventListener('message', window["".concat(
|
380
|
-
window.removeEventListener('resize', window["".concat(
|
393
|
+
window.removeEventListener('message', window["".concat(LISTENER_PREFIX, "_").concat(this.AMSSDK._instanceId)]);
|
394
|
+
window.removeEventListener('resize', window["".concat(LISTENER_PREFIX, "_").concat(this.AMSSDK._instanceId, "_resize")]);
|
381
395
|
}
|
382
396
|
|
383
397
|
/**
|
@@ -446,29 +460,28 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
446
460
|
value: function handleSizeChanged(data) {
|
447
461
|
var _data$context$data2;
|
448
462
|
if (((_data$context$data2 = data.context.data) === null || _data$context$data2 === void 0 ? void 0 : _data$context$data2.height) <= 1) return;
|
449
|
-
var cashier = document.getElementById(
|
463
|
+
var cashier = document.getElementById(COMPONENT_CONTAINER_ID);
|
450
464
|
cashier.style.height = "".concat(data.context.data.height, "px");
|
451
465
|
if (this._renderDisplayType === renderDisplayTypeEnum.popup) {
|
452
|
-
var _document$
|
453
|
-
var mockup = document.getElementById(
|
466
|
+
var _document$getElementB2;
|
467
|
+
var mockup = document.getElementById(MOCKUP_ID);
|
454
468
|
if (mockup) {
|
455
|
-
mockup.style.background = '
|
456
|
-
mockup.style.opacity = '0.6';
|
469
|
+
mockup.style.background = 'rgb(0, 0, 0, 0.6)';
|
457
470
|
mockup.style.display = 'block';
|
458
471
|
}
|
459
|
-
(_document$
|
472
|
+
(_document$getElementB2 = document.getElementById(LOADING_ID)) === null || _document$getElementB2 === void 0 ? void 0 : _document$getElementB2.remove();
|
460
473
|
if (this.platform === 'desktop') {
|
461
|
-
cashier.classList.add("".concat(
|
474
|
+
cashier.classList.add("".concat(COMPONENT_CONTAINER_ID, "-").concat(this.platform, "-animation"));
|
462
475
|
if (data.context.data.width) cashier.style.width = "".concat(data.context.data.width, "px");
|
463
476
|
}
|
464
477
|
if (this.platform === 'mobile') {
|
465
|
-
cashier.classList.add("".concat(
|
466
|
-
var animationStyleId = "".concat(
|
478
|
+
cashier.classList.add("".concat(COMPONENT_CONTAINER_ID, "-").concat(this.platform, "-animation"));
|
479
|
+
var animationStyleId = "".concat(COMPONENT_CONTAINER_ID, "-").concat(this.platform, "-animation-style");
|
467
480
|
var animationStyle = document.getElementById(animationStyleId);
|
468
481
|
if (animationStyle) animationStyle === null || animationStyle === void 0 ? void 0 : animationStyle.remove();
|
469
482
|
|
470
483
|
// 弹出和弹入动画
|
471
|
-
var runkeyframes = "@keyframes ".concat(
|
484
|
+
var runkeyframes = "@keyframes ".concat(COMPONENT_CONTAINER_ID, "-slide-in {\n 0% {\n height: 1px;\n }\n 100% {\n height: ").concat(data.context.data.height, "px;\n }\n }\n @keyframes ").concat(COMPONENT_CONTAINER_ID, "-slide-out {\n 0% {\n height: ").concat(data.context.data.height, "px;\n opacity: 1;\n }\n 50% {\n opacity: 1;\n }\n 100% {\n height: 1px;\n opacity: 0;\n }\n }");
|
472
485
|
// 创建style标签
|
473
486
|
var style = document.createElement('style');
|
474
487
|
style.id = animationStyleId;
|
@@ -486,8 +499,8 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
486
499
|
}
|
487
500
|
}
|
488
501
|
if (this._renderDisplayType === renderDisplayTypeEnum.inline) {
|
489
|
-
var _document$
|
490
|
-
(_document$
|
502
|
+
var _document$getElementB3;
|
503
|
+
(_document$getElementB3 = document.getElementById(LOADING_ID)) === null || _document$getElementB3 === void 0 ? void 0 : _document$getElementB3.remove();
|
491
504
|
}
|
492
505
|
this.app.style.height = "".concat(data.context.data.height, "px");
|
493
506
|
this.app.style.opacity = '1';
|
@@ -552,21 +565,21 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
552
565
|
closeDialogData = _ref3$closeDialogData === void 0 ? {} : _ref3$closeDialogData;
|
553
566
|
try {
|
554
567
|
if (closeDialogData) {
|
555
|
-
var retentionTitle = document.getElementById("".concat(
|
568
|
+
var retentionTitle = document.getElementById("".concat(COMPONENT_RETENTION_ID, "-title"));
|
556
569
|
if (retentionTitle) {
|
557
570
|
var _closeDialogData$titl, _closeDialogData$titl2, _closeDialogData$titl3;
|
558
571
|
retentionTitle.style.fontSize = "".concat(closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$titl = closeDialogData.title) === null || _closeDialogData$titl === void 0 ? void 0 : _closeDialogData$titl.fontSize, "px");
|
559
572
|
retentionTitle.style.color = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$titl2 = closeDialogData.title) === null || _closeDialogData$titl2 === void 0 ? void 0 : _closeDialogData$titl2.fontColor;
|
560
573
|
retentionTitle.innerHTML = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$titl3 = closeDialogData.title) === null || _closeDialogData$titl3 === void 0 ? void 0 : _closeDialogData$titl3.text;
|
561
574
|
}
|
562
|
-
var retentionMessage = document.getElementById("".concat(
|
575
|
+
var retentionMessage = document.getElementById("".concat(COMPONENT_RETENTION_ID, "-sub-title"));
|
563
576
|
if (retentionMessage) {
|
564
577
|
var _closeDialogData$mess, _closeDialogData$mess2, _closeDialogData$mess3;
|
565
578
|
retentionMessage.style.fontSize = "".concat(closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$mess = closeDialogData.message) === null || _closeDialogData$mess === void 0 ? void 0 : _closeDialogData$mess.fontSize, "px");
|
566
579
|
retentionMessage.style.color = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$mess2 = closeDialogData.message) === null || _closeDialogData$mess2 === void 0 ? void 0 : _closeDialogData$mess2.fontColor;
|
567
580
|
retentionMessage.innerHTML = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$mess3 = closeDialogData.message) === null || _closeDialogData$mess3 === void 0 ? void 0 : _closeDialogData$mess3.text;
|
568
581
|
}
|
569
|
-
var remainBtn = document.getElementById("".concat(
|
582
|
+
var remainBtn = document.getElementById("".concat(COMPONENT_RETENTION_ID, "-remain"));
|
570
583
|
if (remainBtn) {
|
571
584
|
var _closeDialogData$btnO, _closeDialogData$btnO2, _closeDialogData$btnO3, _closeDialogData$btnO4, _closeDialogData$btnO5, _closeDialogData$btnO7;
|
572
585
|
remainBtn.innerHTML = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnO = closeDialogData.btnOK) === null || _closeDialogData$btnO === void 0 ? void 0 : _closeDialogData$btnO.text;
|
@@ -578,7 +591,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
578
591
|
remainBtn.style.border = "1px solid ".concat(closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnO6 = closeDialogData.btnOK) === null || _closeDialogData$btnO6 === void 0 ? void 0 : _closeDialogData$btnO6.bg);
|
579
592
|
} else remainBtn.style.backgroundColor = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnO7 = closeDialogData.btnOK) === null || _closeDialogData$btnO7 === void 0 ? void 0 : _closeDialogData$btnO7.bg;
|
580
593
|
}
|
581
|
-
var leaveBrn = document.getElementById("".concat(
|
594
|
+
var leaveBrn = document.getElementById("".concat(COMPONENT_RETENTION_ID, "-leave"));
|
582
595
|
if (leaveBrn) {
|
583
596
|
var _closeDialogData$btnC, _closeDialogData$btnC2, _closeDialogData$btnC3, _closeDialogData$btnC4, _closeDialogData$btnC5, _closeDialogData$btnC7;
|
584
597
|
leaveBrn.innerHTML = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnC = closeDialogData.btnCancel) === null || _closeDialogData$btnC === void 0 ? void 0 : _closeDialogData$btnC.text;
|
@@ -598,11 +611,11 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
598
611
|
}, {
|
599
612
|
key: "handleCloseBtnShow",
|
600
613
|
value: function handleCloseBtnShow(showClose) {
|
601
|
-
var closeBlock = document.getElementById(
|
614
|
+
var closeBlock = document.getElementById(COMPONENT_CLOSE_BLOCK_ID);
|
602
615
|
if (showClose) {
|
603
|
-
closeBlock === null || closeBlock === void 0 ? void 0 : closeBlock.classList.remove("".concat(
|
616
|
+
closeBlock === null || closeBlock === void 0 ? void 0 : closeBlock.classList.remove("".concat(COMPONENT_CLOSE_BLOCK_ID, "-hidden"));
|
604
617
|
} else if (showClose === false) {
|
605
|
-
closeBlock === null || closeBlock === void 0 ? void 0 : closeBlock.classList.add("".concat(
|
618
|
+
closeBlock === null || closeBlock === void 0 ? void 0 : closeBlock.classList.add("".concat(COMPONENT_CLOSE_BLOCK_ID, "-hidden"));
|
606
619
|
}
|
607
620
|
}
|
608
621
|
|
@@ -716,71 +729,39 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
716
729
|
}
|
717
730
|
return sendRenderEvent;
|
718
731
|
}()
|
719
|
-
}, {
|
720
|
-
key: "showPopupLoading",
|
721
|
-
value: function showPopupLoading() {
|
722
|
-
var loading = document.createElement('div');
|
723
|
-
loading === null || loading === void 0 ? void 0 : loading.classList.add(loadingId);
|
724
|
-
loading.id = loadingId;
|
725
|
-
loading.innerHTML = '<div class="line"><div></div><div></div><div></div><div></div></div>';
|
726
|
-
loading.style.fontSize = "".concat(getDesignFontSize(), "px");
|
727
|
-
var body = document.getElementsByTagName('body')[0];
|
728
|
-
body === null || body === void 0 ? void 0 : body.appendChild(loading);
|
729
|
-
}
|
730
|
-
|
731
|
-
/**
|
732
|
-
* @description show cashier
|
733
|
-
*/
|
734
|
-
}, {
|
735
|
-
key: "setContainerClass",
|
736
|
-
value: function setContainerClass() {
|
737
|
-
var cashier = document.getElementById(componentContainerId);
|
738
|
-
cashier === null || cashier === void 0 ? void 0 : cashier.classList.remove("".concat(componentContainerId, "-hidden-").concat(this.platform));
|
739
|
-
cashier === null || cashier === void 0 ? void 0 : cashier.classList.add("".concat(componentContainerId, "-").concat(this.platform));
|
740
|
-
}
|
741
|
-
|
742
732
|
/**
|
743
733
|
* @description close cashier
|
744
734
|
*/
|
745
735
|
}, {
|
746
736
|
key: "cleanContainer",
|
747
737
|
value: function cleanContainer() {
|
748
|
-
var _document$
|
738
|
+
var _document$getElementB4,
|
739
|
+
_this5 = this;
|
749
740
|
var immediately = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
750
741
|
this._loadAppPromiseResolve && this._loadAppPromiseResolve(true);
|
751
742
|
this._performanceData = [];
|
752
743
|
this._isInitComponent = false;
|
753
|
-
|
754
|
-
|
744
|
+
this.app = null;
|
745
|
+
(_document$getElementB4 = document.getElementById(LOADING_ID)) === null || _document$getElementB4 === void 0 ? void 0 : _document$getElementB4.remove();
|
746
|
+
this.hideComponentAnimation();
|
747
|
+
var mockup = document.getElementById(MOCKUP_ID);
|
748
|
+
mockup === null || mockup === void 0 ? void 0 : mockup.classList.add("".concat(MOCKUP_ID, "-hidden"));
|
749
|
+
if (immediately) this.cleanElement();else {
|
750
|
+
setTimeout(function () {
|
751
|
+
_this5.cleanElement();
|
752
|
+
}, 300);
|
753
|
+
}
|
755
754
|
}
|
756
755
|
}, {
|
757
|
-
key: "
|
758
|
-
value: function
|
759
|
-
var
|
760
|
-
var immediately = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
761
|
-
var container = document.getElementById(componentContainerId);
|
756
|
+
key: "hideComponentAnimation",
|
757
|
+
value: function hideComponentAnimation() {
|
758
|
+
var container = document.getElementById(COMPONENT_CONTAINER_ID);
|
762
759
|
if (container) {
|
763
760
|
// size变化动画取消
|
764
761
|
container.style.transition = '';
|
765
|
-
container === null || container === void 0 ? void 0 : container.classList.remove("".concat(
|
766
|
-
container === null || container === void 0 ? void 0 : container.classList.remove("".concat(
|
767
|
-
container === null || container === void 0 ? void 0 : container.classList.add("".concat(
|
768
|
-
}
|
769
|
-
var removeMockupAndApp = function removeMockupAndApp() {
|
770
|
-
var _document$getElementB4;
|
771
|
-
var body = document.getElementsByTagName('body')[0];
|
772
|
-
body.style.overflow = 'auto';
|
773
|
-
var mockup = document.getElementById(mockupId);
|
774
|
-
mockup === null || mockup === void 0 ? void 0 : mockup.remove();
|
775
|
-
if (container) container.style.height = '';
|
776
|
-
(_document$getElementB4 = document.getElementById("".concat(componentContainerId, "-").concat(_this5.platform, "-animation-style"))) === null || _document$getElementB4 === void 0 ? void 0 : _document$getElementB4.remove();
|
777
|
-
_this5.removeRetentionPopup();
|
778
|
-
_this5.cleanApp();
|
779
|
-
};
|
780
|
-
if (immediately) removeMockupAndApp();else {
|
781
|
-
setTimeout(function () {
|
782
|
-
removeMockupAndApp();
|
783
|
-
}, 300);
|
762
|
+
container === null || container === void 0 ? void 0 : container.classList.remove("".concat(COMPONENT_CONTAINER_ID, "-").concat(this.platform));
|
763
|
+
container === null || container === void 0 ? void 0 : container.classList.remove("".concat(COMPONENT_CONTAINER_ID, "-").concat(this.platform, "-animation"));
|
764
|
+
container === null || container === void 0 ? void 0 : container.classList.add("".concat(COMPONENT_CONTAINER_ID, "-hidden-").concat(this.platform));
|
784
765
|
}
|
785
766
|
}
|
786
767
|
}, {
|
@@ -792,143 +773,33 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
792
773
|
this.dispatchToSDK(EVENT.close.name, {});
|
793
774
|
}
|
794
775
|
}
|
795
|
-
|
796
|
-
/**
|
797
|
-
* @description create mount node
|
798
|
-
*/
|
799
|
-
}, {
|
800
|
-
key: "createBaseElement",
|
801
|
-
value: function createBaseElement() {
|
802
|
-
if (document.getElementById(componentContainerId)) return;
|
803
|
-
componentAddCSS();
|
804
|
-
addSetFontSizeEvent();
|
805
|
-
var amsComponentContainer = document.createElement('div');
|
806
|
-
amsComponentContainer.className = "".concat(componentContainerId, "-hidden-").concat(this.platform);
|
807
|
-
amsComponentContainer.id = componentContainerId;
|
808
|
-
amsSetSize(null, amsComponentContainer);
|
809
|
-
document.body.appendChild(amsComponentContainer);
|
810
|
-
var amsComponentSection = document.createElement('div');
|
811
|
-
amsComponentSection.className = "ams-component-section-".concat(this.platform);
|
812
|
-
amsComponentSection.id = componentSectionId;
|
813
|
-
amsComponentContainer.appendChild(amsComponentSection);
|
814
|
-
this.createCloseBtn();
|
815
|
-
}
|
816
|
-
}, {
|
817
|
-
key: "createInlineBaseElement",
|
818
|
-
value: function createInlineBaseElement(renderParams) {
|
819
|
-
var _renderParams$appeara2;
|
820
|
-
var inlineBaseStyle = document.getElementById(inlineBaseStyleId);
|
821
|
-
if (!inlineBaseStyle) inlineComponentAddCss();
|
822
|
-
if (document.getElementById(componentContainerId)) return;
|
823
|
-
var amsComponentContainer = document.createElement('div');
|
824
|
-
amsComponentContainer.className = "".concat(componentContainerId, "-inline");
|
825
|
-
amsComponentContainer.id = componentContainerId;
|
826
|
-
var selectorDom = document.querySelector(this._selector);
|
827
|
-
if (selectorDom) selectorDom.appendChild(amsComponentContainer);
|
828
|
-
var showLoading = renderParams === null || renderParams === void 0 ? void 0 : (_renderParams$appeara2 = renderParams.appearance) === null || _renderParams$appeara2 === void 0 ? void 0 : _renderParams$appeara2.showLoading;
|
829
|
-
showLoading = typeof showLoading === 'boolean' ? showLoading : true;
|
830
|
-
if (showLoading) showInlineLoading(amsComponentContainer, this.platform);
|
831
|
-
}
|
832
|
-
}, {
|
833
|
-
key: "createCloseBtn",
|
834
|
-
value: function createCloseBtn() {
|
835
|
-
var _this6 = this;
|
836
|
-
var container = document.getElementById(componentContainerId);
|
837
|
-
// close btn
|
838
|
-
var closeBtnHTML = "<img class='".concat(componentCloseBlockId, "-btn-").concat(this.platform, "' src=\"").concat(closeImg, "\"/>");
|
839
|
-
var closeBlock = document.createElement('div');
|
840
|
-
closeBlock.classList.add("".concat(componentCloseBlockId, "-").concat(this.platform), "".concat(componentCloseBlockId, "-hidden"));
|
841
|
-
closeBlock.id = componentCloseBlockId;
|
842
|
-
closeBlock.innerHTML = closeBtnHTML;
|
843
|
-
closeBlock.addEventListener(this._clickEventName, function () {
|
844
|
-
_this6.closeBtnFunc();
|
845
|
-
});
|
846
|
-
if (container) container.appendChild(closeBlock);
|
847
|
-
}
|
848
|
-
}, {
|
849
|
-
key: "createRetentionPopup",
|
850
|
-
value: function createRetentionPopup() {
|
851
|
-
// retention popup
|
852
|
-
var retentionPopup = document.createElement('div');
|
853
|
-
retentionPopup.id = componentRetentionId;
|
854
|
-
retentionPopup.classList.add("".concat(componentRetentionId, "-").concat(this.platform));
|
855
|
-
retentionPopup.innerHTML = "\n <span id=\"".concat(componentRetentionId, "-title\" class=\"").concat(componentRetentionId, "-title-").concat(this.platform, "\">\n Are you sure you want to leave?\n </span>\n <span\n id=\"").concat(componentRetentionId, "-sub-title\"\n class=\"").concat(componentRetentionId, "-sub-title-").concat(this.platform, "\"\n >\n If you leave this page, you'll have to start over again.\n </span>\n <div class=\"").concat(componentRetentionId, "-btn-block-").concat(this.platform, "\">\n <div id=\"").concat(componentRetentionId, "-remain\" class=\"").concat(componentRetentionId, "-remain-").concat(this.platform, "\">\n Continue Payment\n </div>\n <div id=\"").concat(componentRetentionId, "-leave\" class=\"").concat(componentRetentionId, "-leave-").concat(this.platform, "\">\n Leave\n </div>\n </div>");
|
856
|
-
document.body.appendChild(retentionPopup);
|
857
|
-
var remainBtn = document.getElementById("".concat(componentRetentionId, "-remain"));
|
858
|
-
if (remainBtn) {
|
859
|
-
remainBtn.addEventListener(this._clickEventName, this.hideRetentionPopup.bind(this));
|
860
|
-
}
|
861
|
-
var leaveBtn = document.getElementById("".concat(componentRetentionId, "-leave"));
|
862
|
-
if (leaveBtn) {
|
863
|
-
leaveBtn.addEventListener(this._clickEventName, this.retentionPopupLeaveFunc.bind(this));
|
864
|
-
}
|
865
|
-
}
|
866
776
|
}, {
|
867
777
|
key: "retentionPopupLeaveFunc",
|
868
778
|
value: function retentionPopupLeaveFunc() {
|
869
779
|
this.dispatchToSDK(EVENT.close.name, {});
|
870
|
-
this.
|
780
|
+
this.hideRetentionPopupFunc();
|
871
781
|
this.cleanContainer();
|
872
782
|
}
|
873
783
|
}, {
|
874
784
|
key: "removeRetentionPopup",
|
875
|
-
value: function removeRetentionPopup() {
|
876
|
-
|
877
|
-
var remainBtn = document.getElementById("".concat(componentRetentionId, "-remain"));
|
878
|
-
if (remainBtn) {
|
879
|
-
remainBtn.removeEventListener(this._clickEventName, this.hideRetentionPopup);
|
880
|
-
}
|
881
|
-
var leaveBtn = document.getElementById("".concat(componentRetentionId, "-leave"));
|
882
|
-
if (leaveBtn) {
|
883
|
-
leaveBtn.removeEventListener(this._clickEventName, this.retentionPopupLeaveFunc);
|
884
|
-
}
|
885
|
-
(_document$getElementB5 = document.getElementById(componentRetentionId)) === null || _document$getElementB5 === void 0 ? void 0 : _document$getElementB5.remove();
|
785
|
+
value: function removeRetentionPopup(platform) {
|
786
|
+
_removeRetentionPopup(platform, this.hideRetentionPopupFunc, this.retentionPopupLeaveFunc);
|
886
787
|
}
|
887
788
|
}, {
|
888
789
|
key: "showRetentionPopup",
|
889
790
|
value: function showRetentionPopup() {
|
890
|
-
var retentionPopup = document.getElementById(
|
891
|
-
var container = document.getElementById(
|
791
|
+
var retentionPopup = document.getElementById(COMPONENT_RETENTION_ID);
|
792
|
+
var container = document.getElementById(COMPONENT_CONTAINER_ID);
|
892
793
|
if (retentionPopup) {
|
893
|
-
container === null || container === void 0 ? void 0 : container.classList.add("".concat(
|
894
|
-
retentionPopup.classList.remove("".concat(
|
895
|
-
retentionPopup.classList.add("".concat(
|
794
|
+
container === null || container === void 0 ? void 0 : container.classList.add("".concat(COMPONENT_CONTAINER_ID, "-opacity"));
|
795
|
+
retentionPopup.classList.remove("".concat(COMPONENT_RETENTION_ID, "-hidden"));
|
796
|
+
retentionPopup.classList.add("".concat(COMPONENT_RETENTION_ID, "-show"));
|
896
797
|
}
|
897
798
|
}
|
898
799
|
}, {
|
899
|
-
key: "
|
900
|
-
value: function
|
901
|
-
|
902
|
-
var container = document.getElementById(componentContainerId);
|
903
|
-
if (retentionPopup) {
|
904
|
-
retentionPopup.classList.remove("".concat(componentRetentionId, "-show"));
|
905
|
-
retentionPopup.classList.add("".concat(componentRetentionId, "-hidden"));
|
906
|
-
setTimeout(function () {
|
907
|
-
retentionPopup.classList.remove("".concat(componentRetentionId, "-hidden"));
|
908
|
-
container === null || container === void 0 ? void 0 : container.classList.remove("".concat(componentContainerId, "-opacity"));
|
909
|
-
}, 300);
|
910
|
-
}
|
911
|
-
}
|
912
|
-
/**
|
913
|
-
* @description create mockup
|
914
|
-
*/
|
915
|
-
}, {
|
916
|
-
key: "createMockup",
|
917
|
-
value: function createMockup() {
|
918
|
-
var body = document.getElementsByTagName('body')[0];
|
919
|
-
body.style.overflow = 'hidden';
|
920
|
-
var mockup = document.createElement('div');
|
921
|
-
mockup.style.width = '100vw';
|
922
|
-
mockup.style.height = '100vh';
|
923
|
-
mockup.style.position = 'fixed';
|
924
|
-
mockup.style.top = '0';
|
925
|
-
mockup.style.left = '0';
|
926
|
-
mockup.style.zIndex = '1000';
|
927
|
-
mockup.style.background = '#ffffff';
|
928
|
-
mockup.style.opacity = '0.5';
|
929
|
-
mockup.style.display = 'none';
|
930
|
-
mockup.id = mockupId;
|
931
|
-
body.appendChild(mockup);
|
800
|
+
key: "hideRetentionPopupFunc",
|
801
|
+
value: function hideRetentionPopupFunc() {
|
802
|
+
hideRetentionPopup();
|
932
803
|
}
|
933
804
|
}, {
|
934
805
|
key: "submitForm",
|
package/package.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"name":"@alipay/ams-checkout","version":"0.0.1691743027-dev.
|
1
|
+
{"name":"@alipay/ams-checkout","version":"0.0.1691743027-dev.5","description":"","author":"","main":"esm/index.js","module":"esm/index.js","typings":"esm/index.d.ts","files":["dist","esm","LEGAL.md","LICENSE","README.md"],"scripts":{"build":"father build","ci":"npm run lint","cov":"jest --coverage","format":"prettier --write --no-error-on-unmatched-pattern \"**/*.{js,jsx,ts,tsx,md,json,css,less}\"","lint":"eslint ./src","test":"jest"},"dependencies":{"axios":"^1.3.4","uuid":"^9.0.0"},"devDependencies":{"@babel/core":"^7.20.7","@babel/preset-env":"^7.20.2","@testing-library/jest-dom":"^5.1.1","@testing-library/react":"^9.5.0","@types/jest":"^29.2.4","@types/uuid":"^9.0.0","@typescript-eslint/parser":"^5.60.0","babel-jest":"^29.3.1","babel-loader":"^9.1.0","babel-plugin-import":"^1.13.0","eslint":"^8.36.0","father":"^4.2.3","jest":"^29.5.0","jest-environment-jsdom":"^29.3.1","prettier":"^2.8.4","prettier-plugin-organize-imports":"^3.2.3","prettier-plugin-packagejson":"^2.4.5","ts-jest":"^29.0.3","ts-node":"^10.9.1","typescript":"^4.9.5"},"engines":{},"publishConfig":{"access":"public"}}
|
@@ -1,43 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
|
3
|
-
*
|
4
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), the rights to use, copy, modify, merge, and/or distribute the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
5
|
-
* 1. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE; and
|
6
|
-
* 2. If applicable, the use of the Software is also subject to the terms and conditions of any non-disclosure agreement signed by you and the relevant Ant Group entity.
|
7
|
-
*/
|
8
|
-
import { platformEnum } from "../../types";
|
9
|
-
import { amsSetSize } from "../../util";
|
10
|
-
var componentContainerId = 'ams-component-container';
|
11
|
-
var componentSectionId = 'ams-component-section';
|
12
|
-
var componentCloseBlockId = 'asm-component-close-block';
|
13
|
-
var componentRetentionId = 'ams-component-retention';
|
14
|
-
var mockupId = 'ams-component-mockup';
|
15
|
-
var loadingId = 'ams-component-loading';
|
16
|
-
var listenerPrefix = '_ams_sdk_component_listener';
|
17
|
-
var inlineBaseStyleId = 'ams-inline-component-style';
|
18
|
-
var inlineImgClassName = 'inline-loading';
|
19
|
-
var loadTimeLimit = 15000;
|
20
|
-
var componentCss = ".ams-component-container-mobile {\n width: 100%;\n height: 1px;\n position: fixed;\n bottom: -1px;\n left: 0;\n z-index: 1001;\n border-radius: 12px 12px 0 0;\n overflow: hidden;\n}\n.ams-component-container-mobile-animation{\n animation: ams-component-container-slide-in 0.3s ease-in-out;\n}\n\n.ams-component-section-desktop {\n font-size: 0;\n}\n\n.ams-component-container-hidden-mobile {\n width: 100%;\n height: 0px;\n position: fixed;\n bottom: -1px;\n left: 0;\n z-index: 1001;\n background-color: transparent;\n border-radius: 12px 12px 0 0;\n animation: ams-component-container-slide-out 0.26s ease-in forwards;\n overflow: hidden;\n}\n\n.ams-component-section-mobile {\n border-radius: 12px 12px 0 0;\n overflow: hidden;\n font-size: 0;\n}\n\n.ams-component-container-desktop {\n display: block;\n width: 672px;\n position: fixed;\n top: 50%;\n left: 50%;\n z-index: 1001;\n border-radius: 8px;\n overflow: hidden;\n transform-origin: 50% 50%;\n}\n.ams-component-container-desktop-animation{\n animation: ams-component-container-zoom-in 0.3s ease-in-out;\n animation-fill-mode: forwards\n}\n\n@keyframes ams-component-container-zoom-out {\n 0% {\n transform: translate(-50%, -50%) scale(1);\n opacity: 1\n }\n\n 100% {\n transform: translate(-50%, -50%) scale(0.4);\n opacity: 0\n }\n}\n\n@keyframes ams-component-container-zoom-in {\n 0% {\n transform: translate(-50%, -50%) scale(0.4);\n opacity: 0\n }\n\n 80% {\n opacity: 1\n }\n\n 100% {\n opacity: 1;\n transform: translate(-50%, -50%) scale(1);\n }\n}\n\n.ams-component-container-hidden-desktop {\n display: block;\n position: fixed;\n top: 50%;\n left: 50%;\n z-index: 1001;\n border-radius: 8px;\n overflow: hidden;\n animation-fill-mode: forwards;\n animation: ams-component-container-zoom-out 0.3s ease-in-out;\n transform-origin: 50% 50%;\n}\n\n.ams-component-loading {\n width: 0.8em;\n height:0.8em;\n background: rgba(0, 0, 0, 0.5);\n border-radius: 8px;\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n z-index: 1001;\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n}\n\n.ams-component-loading .line {\n width: 40px;\n height: 40px;\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n}\n.ams-component-loading .line div {\n position: absolute;\n left: 17.67px;\n top: 0;\n width: 5.33px;\n height: 40px;\n}\n\n.ams-component-loading .line div:before,\n.ams-component-loading .line div:after {\n content: '';\n display: block;\n height: 13.33px;\n background: #fcfcfc;\n border-radius: 5.3px;\n}\n.ams-component-loading .line div:after {\n margin-top: 13.33px;\n}\n\n.ams-component-loading .line div:nth-child(2) {\n -webkit-transform: rotate(45deg);\n}\n\n.ams-component-loading .line div:nth-child(3) {\n -webkit-transform: rotate(90deg);\n}\n\n.ams-component-loading .line div:nth-child(4) {\n -webkit-transform: rotate(135deg);\n}\n\n/** \u52A0\u8F7D\u52A8\u753B **/\n@-webkit-keyframes load {\n 0% {\n opacity: 0;\n }\n\n 100% {\n opacity: 1;\n }\n\n}\n\n.ams-component-loading .line div:nth-child(1):before {\n -webkit-animation: load 1s linear 0s infinite;\n}\n\n.ams-component-loading .line div:nth-child(2):before {\n -webkit-animation: load 1s linear 0.125s infinite;\n}\n\n.ams-component-loading .line div:nth-child(3):before {\n -webkit-animation: load 1s linear 0.25s infinite;\n}\n\n.ams-component-loading .line div:nth-child(4):before {\n -webkit-animation: load 1s linear 0.375s infinite;\n}\n\n.ams-component-loading .line div:nth-child(1):after {\n -webkit-animation: load 1s linear 0.5s infinite;\n}\n\n.ams-component-loading .line div:nth-child(2):after {\n -webkit-animation: load 1s linear 0.675s infinite;\n}\n\n.ams-component-loading .line div:nth-child(3):after {\n -webkit-animation: load 1s linear 0.75s infinite;\n}\n\n.ams-component-loading .line div:nth-child(4):after {\n -webkit-animation: load 1s linear 0.875s infinite;\n}\n\n.ams-component-loading-logo {\n width: 0.44em;\n height: 0.44em;\n -webkit-transform:rotate(360deg);\n transform:rotate(360deg);\n -webkit-transition:-webkit-transform 1s linear;\n transition:transform 1s linear;\n animation: ams-component-loading-logo 1s linear infinite;\n}\n\n.asm-component-close-block-desktop {\n position: absolute;\n width: 40px;\n height: 40px;\n right: 0;\n top: 0;\n cursor: pointer;\n}\n.asm-component-close-block-btn-desktop {\n width: 11px;\n height: 11px;\n object-fit: fill;\n position: absolute;\n right: 18.7px;\n top: 26.7px;\n}\n.asm-component-close-block-hidden {\n width: 0px !important;\n height: 0px !important;\n visibility: hidden;\n}\n.asm-component-close-block-mobile {\n position: absolute;\n width: 0.4em;\n height: 0.4em;\n right: 0;\n top: 0;\n cursor: pointer;\n z-index: 1009;\n}\n\n.asm-component-close-block-btn-mobile {\n width: 0.11em;\n height: 0.11em;\n object-fit: fill;\n position: absolute;\n right: 0.147em;\n top: 0.167em;\n}\n\n\n.ams-component-container-opacity{\n opacity: 1;\n}\n\n.ams-component-container-opacity:after{\n position: absolute;\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n display: block;\n content: \"\";\n z-index: 1010;\n background-color: rgba(0, 0, 0, 0.35);\n}\n\n#ams-component-retention {\n position: fixed;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%);\n transform-origin: 50%;\n height: auto;\n display: none;\n z-index: 1009;\n}\n\n.ams-component-retention-show {\n display: flex !important;\n animation: ams-component-container-zoom-in 0.3s ease-in-out;\n animation-fill-mode: forwards\n}\n\n.ams-component-retention-hidden {\n display: flex !important;\n animation: ams-component-container-zoom-out 0.3s ease-in-out;\n animation-fill-mode: forwards\n}\n\n.ams-component-retention-mobile {\n width: 294px;\n border-radius: 12px;\n padding: 24px 0;\n background-color: #fff;\n flex-direction: column;\n align-items: flex-start;\n justify-content: center;\n box-sizing: border-box;\n}\n\n.ams-component-retention-desktop {\n width: 544px;\n border-radius: 12px;\n padding: 32px;\n background-color: #fff;\n flex-direction: column;\n align-items: flex-start;\n justify-content: center;\n box-sizing: border-box;\n}\n\n@media screen and (max-width: 300px) {\n .ams-component-retention-mobile {\n transform: translate(-50%, -50%) scale(0.8);\n }\n}\n\n.ams-component-retention-title-mobile {\n width: 100%;\n font-style: normal;\n font-weight: 500;\n font-size: 16px;\n line-height: 24px;\n color: #2A3A52;\n text-align: center;\n padding: 0 16px;\n box-sizing: border-box;\n}\n\n.ams-component-retention-title-desktop {\n text-align: left;\n width: 100%;\n font-style: normal;\n font-weight: 500;\n font-size: 16px;\n line-height: 24px;\n color: #2A3A52;\n}\n\n.ams-component-retention-sub-title-mobile {\n width: 100%;\n font-weight: 400;\n font-size: 14px;\n line-height: 20px;\n color: #7C8CA3;\n margin-top: 8px;\n text-align: center;\n padding: 0 16px;\n box-sizing: border-box;\n}\n\n.ams-component-retention-sub-title-desktop {\n text-align: left;\n font-style: normal;\n font-weight: 400;\n font-size: 14px;\n line-height: 20px;\n color: #7C8CA3;\n margin-top: 10px;\n}\n\n.ams-component-retention-btn-block-mobile {\n width: 100%;\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n justify-content: center;\n margin-top: 24px;\n padding: 0 24px;\n box-sizing: border-box;\n}\n\n.ams-component-retention-btn-block-desktop {\n width: 100%;\n margin-top: 24px;\n}\n\n#ams-component-retention-remain {\n background: #0079FF;\n border-radius: 100px;\n font-style: normal;\n font-weight: 500;\n text-align: center;\n box-sizing: border-box;\n color: #FFFFFF;\n}\n\n.ams-component-retention-remain-mobile {\n width: 100%;\n height: 44px;\n font-size: 16px;\n line-height: 44px;\n}\n\n.ams-component-retention-remain-desktop {\n height: 44px;\n font-size: 16px;\n line-height: 44px;\n display: inline-block;\n padding: 0 24px;\n float: right;\n cursor: pointer;\n}\n\n#ams-component-retention-leave {\n border-radius: 100px;\n border: 1px solid #0079FF;\n font-style: normal;\n font-weight: 500;\n text-align: center;\n box-sizing: border-box;\n}\n\n.ams-component-retention-leave-mobile {\n width: 100%;\n height: 44px;\n font-size: 16px;\n line-height: 44px;\n color: #1677FF;\n margin-top: 12px;\n}\n\n.ams-component-retention-leave-desktop {\n height: 44px;\n font-size: 16px;\n line-height: 44px;\n color: #1677FF;\n display: inline-block;\n padding: 0 24px;\n float: right;\n margin-right: 16px;\n cursor: pointer;\n}\n\n";
|
21
|
-
export var componentAddCSS = function componentAddCSS() {
|
22
|
-
var style = document.createElement('style');
|
23
|
-
style.type = 'text/css';
|
24
|
-
style.innerHTML = componentCss;
|
25
|
-
document.head.appendChild(style);
|
26
|
-
};
|
27
|
-
var inlineComponentCss = "#ams-checkout-component-desktop{\n border-radius: 8px;\n position: absolute;\n top: 0;\n left: 0;\n}\n#ams-checkout-component-mobile{\n position: absolute;\n top: 0;\n left: 0;\n}\n.".concat(componentContainerId, "-inline{\n width: 100%;\n height: auto;\n position: relative;\n line-height: 0;\n display: flex;\n}\n#").concat(loadingId, "{\n width: 100%;\n flex: 1;\n}\n.").concat(inlineImgClassName, "{\n width: 100%;\n height: auto;\n object-fit: contain;\n box-sizing: border-box;\n}\n.").concat(inlineImgClassName, "-mobile{\n padding: 0 0.16em;\n}\n.").concat(inlineImgClassName, "-desktop{}\n");
|
28
|
-
export var inlineComponentAddCss = function inlineComponentAddCss() {
|
29
|
-
var style = document.createElement('style');
|
30
|
-
style.id = 'ams-inline-component-style';
|
31
|
-
style.type = 'text/css';
|
32
|
-
style.innerHTML = inlineComponentCss;
|
33
|
-
document.head.appendChild(style);
|
34
|
-
};
|
35
|
-
export var showInlineLoading = function showInlineLoading(_selector, platform) {
|
36
|
-
var loading = document.createElement('div');
|
37
|
-
loading.id = loadingId;
|
38
|
-
if (platform === platformEnum.desktop) loading.innerHTML = "<svg class=\"".concat(inlineImgClassName, " ").concat(inlineImgClassName, "-").concat(platform, "\" width=\"740\" height=\"360\" viewBox=\"0 0 740 360\" fill=\"none\" xmlns=\"\">\n <rect width=\"740\" height=\"360\" rx=\"12\" fill=\"#F6F6F6\"/>\n <rect opacity=\"0.7\" x=\"44\" y=\"44\" width=\"32\" height=\"32\" rx=\"4\" fill=\"#E1E6ED\"/>\n <rect opacity=\"0.7\" x=\"94\" y=\"44\" width=\"32\" height=\"32\" rx=\"4\" fill=\"#E1E6ED\"/>\n <rect opacity=\"0.7\" x=\"144\" y=\"44\" width=\"32\" height=\"32\" rx=\"4\" fill=\"#E1E6ED\"/>\n <g style=\"mix-blend-mode:multiply\" opacity=\"0.336007\">\n <path d=\"M136 100H48C43.5817 100 40 103.582 40 108C40 112.418 43.5817 116 48 116H136C140.418 116 144 112.418 144 108C144 103.582 140.418 100 136 100Z\" fill=\"#E1E6ED\"/>\n </g>\n <g style=\"mix-blend-mode:multiply\" opacity=\"0.336007\">\n <path d=\"M682 126H58C48.0589 126 40 134.059 40 144C40 153.941 48.0589 162 58 162H682C691.941 162 700 153.941 700 144C700 134.059 691.941 126 682 126Z\" fill=\"#E1E6ED\"/>\n </g>\n <g style=\"mix-blend-mode:multiply\" opacity=\"0.336007\">\n <path d=\"M682 182H58C48.0589 182 40 190.059 40 200C40 209.941 48.0589 218 58 218H682C691.941 218 700 209.941 700 200C700 190.059 691.941 182 682 182Z\" fill=\"#E1E6ED\"/>\n </g>\n <g style=\"mix-blend-mode:multiply\" opacity=\"0.336007\">\n <path d=\"M504 274H64C52.9543 274 44 282.954 44 294C44 305.046 52.9543 314 64 314H504C515.046 314 524 305.046 524 294C524 282.954 515.046 274 504 274Z\" fill=\"#E1E6ED\"/>\n </g>\n </svg>");
|
39
|
-
if (platform === platformEnum.mobile) loading.innerHTML = "<svg class=\"".concat(inlineImgClassName, " ").concat(inlineImgClassName, "-").concat(platform, "\" width=\"358\" height=\"186\" viewBox=\"0 0 358 186\" fill=\"none\" xmlns=\"\">\n <g clip-path=\"url(#clip0_2543_91192)\">\n <rect width=\"358\" height=\"186\" fill=\"white\"/>\n <g clip-path=\"url(#clip1_2543_91192)\">\n <rect width=\"358\" height=\"186\" fill=\"white\"/>\n <rect width=\"358\" height=\"40\" fill=\"white\"/>\n <rect opacity=\"0.7\" x=\"4\" y=\"4\" width=\"32\" height=\"32\" rx=\"4\" fill=\"#E1E6ED\"/>\n <rect opacity=\"0.7\" x=\"54\" y=\"4\" width=\"32\" height=\"32\" rx=\"4\" fill=\"#E1E6ED\"/>\n <rect opacity=\"0.7\" x=\"104\" y=\"4\" width=\"32\" height=\"32\" rx=\"4\" fill=\"#E1E6ED\"/>\n <g clip-path=\"url(#clip2_2543_91192)\">\n <rect width=\"358\" height=\"120\" transform=\"translate(0 66)\" fill=\"white\"/>\n <g style=\"mix-blend-mode:multiply\" opacity=\"0.336007\">\n <path d=\"M95 66H9C4.02944 66 0 70.0294 0 75C0 79.9706 4.02943 84 9 84H95C99.9706 84 104 79.9706 104 75C104 70.0294 99.9706 66 95 66Z\" fill=\"#E1E6ED\"/>\n </g>\n <g clip-path=\"url(#clip3_2543_91192)\">\n <g style=\"mix-blend-mode:multiply\" opacity=\"0.336007\">\n <path d=\"M340 94H18C8.05888 94 0 102.059 0 112C0 121.941 8.05887 130 18 130H340C349.941 130 358 121.941 358 112C358 102.059 349.941 94 340 94Z\" fill=\"#E1E6ED\"/>\n </g>\n <g style=\"mix-blend-mode:multiply\" opacity=\"0.336007\">\n <path d=\"M340 150H18C8.05888 150 0 158.059 0 168C0 177.941 8.05887 186 18 186H340C349.941 186 358 177.941 358 168C358 158.059 349.941 150 340 150Z\" fill=\"#E1E6ED\"/>\n </g>\n </g>\n </g>\n </g>\n </g>\n <defs>\n <clipPath id=\"clip0_2543_91192\">\n <rect width=\"358\" height=\"186\" fill=\"white\"/>\n </clipPath>\n <clipPath id=\"clip1_2543_91192\">\n <rect width=\"358\" height=\"186\" fill=\"white\"/>\n </clipPath>\n <clipPath id=\"clip2_2543_91192\">\n <rect width=\"358\" height=\"120\" fill=\"white\" transform=\"translate(0 66)\"/>\n </clipPath>\n <clipPath id=\"clip3_2543_91192\">\n <rect width=\"358\" height=\"92\" fill=\"white\" transform=\"translate(0 94)\"/>\n </clipPath>\n </defs>\n </svg>\n ");
|
40
|
-
if (_selector) _selector.appendChild(loading);
|
41
|
-
var loadingDom = document.getElementById(loadingId);
|
42
|
-
amsSetSize(null, loadingDom);
|
43
|
-
};
|