@alipay/ams-checkout 0.0.1720509876-dev.3 → 0.0.1720509876-dev.4
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 +2 -1
- package/esm/constant/index.js +1 -0
- package/esm/plugin/component/cashierApp.js +2 -1
- package/esm/plugin/component/component.inline.style.d.ts +1 -0
- package/esm/plugin/component/component.inline.style.js +7 -2
- package/esm/plugin/component/index.js +16 -5
- package/esm/plugin/component/popupWindow.style.d.ts +5 -2
- package/esm/plugin/component/popupWindow.style.js +53 -5
- package/package.json +1 -1
package/esm/constant/index.d.ts
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
* 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
|
5
5
|
* 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.
|
6
6
|
*/
|
7
|
-
import { eventCodeEnum } from
|
7
|
+
import { eventCodeEnum } from '../types';
|
8
8
|
export declare const ERRORMESSAGE: {
|
9
9
|
DOMAIN_NOT_IN_WHITE_LIST: {
|
10
10
|
code: eventCodeEnum;
|
@@ -175,6 +175,7 @@ export declare const COMPONENT_CLOSE_BLOCK_ID = "asm-component-close-block";
|
|
175
175
|
export declare const COMPONENT_RETENTION_ID = "ams-component-retention";
|
176
176
|
export declare const MOCKUP_ID = "ams-component-mockup";
|
177
177
|
export declare const LOADING_ID = "ams-component-loading";
|
178
|
+
export declare const POPUPLOADING_ID = "ams-component-popup-loading";
|
178
179
|
export declare const LISTENER_PREFIX = "_ams_sdk_component_listener";
|
179
180
|
export declare const INLINE_BASE_STYLE_ID = "ams-inline-component-style";
|
180
181
|
export declare const INLINE_IMG_CLASSNAME = "inline-loading";
|
package/esm/constant/index.js
CHANGED
@@ -175,6 +175,7 @@ export var COMPONENT_CLOSE_BLOCK_ID = 'asm-component-close-block';
|
|
175
175
|
export var COMPONENT_RETENTION_ID = 'ams-component-retention';
|
176
176
|
export var MOCKUP_ID = 'ams-component-mockup';
|
177
177
|
export var LOADING_ID = 'ams-component-loading';
|
178
|
+
export var POPUPLOADING_ID = 'ams-component-popup-loading'; // popup弹窗loading
|
178
179
|
export var LISTENER_PREFIX = '_ams_sdk_component_listener';
|
179
180
|
export var INLINE_BASE_STYLE_ID = 'ams-inline-component-style';
|
180
181
|
export var INLINE_IMG_CLASSNAME = 'inline-loading';
|
@@ -101,7 +101,8 @@ export var getAppPath = function getAppPath() {
|
|
101
101
|
// element又分为express_checkout模式和普通模式, express_checkout 模式在扩展参数是返回expressCheckout=true
|
102
102
|
var isExpressCheckout = false;
|
103
103
|
try {
|
104
|
-
|
104
|
+
// expressCheckout可能出现string(false) JSON.parse再转一次
|
105
|
+
isExpressCheckout = JSON.parse(JSON.parse(extendInfo).expressCheckout);
|
105
106
|
} catch (error) {
|
106
107
|
// 遇到JSON解析错误,默认false
|
107
108
|
}
|
@@ -2,6 +2,7 @@ import { componentSignEnum, platformEnum } from '../../types';
|
|
2
2
|
interface Options {
|
3
3
|
componentSign?: componentSignEnum;
|
4
4
|
type: 'tabs' | 'Accordion';
|
5
|
+
isExpressCheckout?: boolean;
|
5
6
|
}
|
6
7
|
export declare const inlineComponentAddCss: () => void;
|
7
8
|
export declare const addInlineLoading: (_selector: HTMLDivElement, platform: platformEnum, options: Options) => void;
|
@@ -8,7 +8,8 @@
|
|
8
8
|
import { COMPONENT_CONTAINER_ID, COMPONENT_IFRAME_TAG_ID, INLINE_BASE_STYLE_ID, INLINE_IMG_CLASSNAME, LOADING_ID } from "../../constant";
|
9
9
|
import { componentSignEnum, platformEnum } from "../../types";
|
10
10
|
import { amsSetSize } from "../../util";
|
11
|
-
|
11
|
+
// border-radius: 8px;
|
12
|
+
var inlineComponentCss = "#".concat(COMPONENT_IFRAME_TAG_ID, "-desktop{\n position: absolute;\n top: 0;\n left: 0;\n}\n#").concat(COMPONENT_IFRAME_TAG_ID, "-mobile{\n position: absolute;\n top: 0;\n left: 0;\n}\n.").concat(COMPONENT_CONTAINER_ID, "-inline{\n width: 100%;\n height: auto;\n position: relative;\n line-height: 0;\n display: flex;\n}\n#").concat(LOADING_ID, "{\n width: 100%;\n flex: 1;\n}\n.").concat(INLINE_IMG_CLASSNAME, "{\n width: 100%;\n height: auto;\n object-fit: contain;\n box-sizing: border-box;\n}\n.").concat(INLINE_IMG_CLASSNAME, "-mobile{\n padding: 0 0.16em;\n}\n.").concat(INLINE_IMG_CLASSNAME, "-desktop{}\n");
|
12
13
|
export var inlineComponentAddCss = function inlineComponentAddCss() {
|
13
14
|
var style = document.createElement('style');
|
14
15
|
style.id = 'ams-inline-component-style';
|
@@ -95,7 +96,11 @@ export var addInlineLoading = function addInlineLoading(_selector, platform, opt
|
|
95
96
|
var loading = document.createElement('div');
|
96
97
|
loading.id = LOADING_ID;
|
97
98
|
if (options.componentSign === componentSignEnum.ELEMENT_PAYMENT) {
|
98
|
-
|
99
|
+
if (options.isExpressCheckout) {
|
100
|
+
loading.innerHTML = '';
|
101
|
+
} else {
|
102
|
+
loading.innerHTML = renderElementPayment(options === null || options === void 0 ? void 0 : options.type);
|
103
|
+
}
|
99
104
|
} else if (platform === platformEnum.desktop) loading.innerHTML = "<svg class=\"".concat(INLINE_IMG_CLASSNAME, " ").concat(INLINE_IMG_CLASSNAME, "-").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>");else if (platform === platformEnum.mobile) loading.innerHTML = "<svg class=\"".concat(INLINE_IMG_CLASSNAME, " ").concat(INLINE_IMG_CLASSNAME, "-").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 ");
|
100
105
|
if (_selector) _selector.appendChild(loading);
|
101
106
|
var loadingDom = document.getElementById(LOADING_ID);
|
@@ -24,12 +24,12 @@ import { componentSignEnum, eventCodeEnum, messageName, platformEnum, productSce
|
|
24
24
|
import { getType, isJsonString, isPC } from "../../util";
|
25
25
|
import { isLocalMock } from "../../util/mock";
|
26
26
|
import { matchVersion } from "../../util/versionCompare";
|
27
|
+
import { handlePaymentSessionConfig } from "../payment-element/utils";
|
27
28
|
import { createIframe, createPreloadIframe, getAppDomain, getIframeUrl } from "./cashierApp";
|
28
29
|
import { getChannelBehavior } from "./channel";
|
29
30
|
import { addInlineLoading, createInlineBaseElement } from "./component.inline.style";
|
30
31
|
import { addPopupLoading, createBaseElement, createMockup, createRetentionPopup, handleDeclareInfo as _handleDeclareInfo, hideRetentionPopup, removeRetentionPopup as _removeRetentionPopup, slideInAndOutKeyframes } from "./component.popup.style";
|
31
|
-
import {
|
32
|
-
import { createModal, destroyModal, insertStyleSheet } from "./popupWindow.style";
|
32
|
+
import { createModal, destroyModal, insertStyleSheet, removePopupLoading } from "./popupWindow.style";
|
33
33
|
window.changingPageHeight = window.innerHeight;
|
34
34
|
var ComponentApp = /*#__PURE__*/function () {
|
35
35
|
function ComponentApp() {
|
@@ -378,9 +378,18 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
378
378
|
var _renderParams$appeara, _this$_renderParams11;
|
379
379
|
var showLoading = renderParams === null || renderParams === void 0 || (_renderParams$appeara = renderParams.appearance) === null || _renderParams$appeara === void 0 ? void 0 : _renderParams$appeara.showLoading;
|
380
380
|
showLoading = typeof showLoading === 'boolean' ? showLoading : true;
|
381
|
+
var extendInfo = renderParams.paymentSessionMetaData.extendInfo;
|
382
|
+
var isExpressCheckout = false;
|
383
|
+
try {
|
384
|
+
// expressCheckout可能出现string(false) JSON.parse再转一次
|
385
|
+
isExpressCheckout = JSON.parse(JSON.parse(extendInfo).expressCheckout);
|
386
|
+
} catch (error) {
|
387
|
+
// 遇到JSON解析错误,默认false
|
388
|
+
}
|
381
389
|
if (showLoading) addInlineLoading(selector, this.platform, {
|
382
390
|
componentSign: this._componentSign,
|
383
|
-
type: (_this$_renderParams11 = this._renderParams) === null || _this$_renderParams11 === void 0 || (_this$_renderParams11 = _this$_renderParams11.appearance) === null || _this$_renderParams11 === void 0 || (_this$_renderParams11 = _this$_renderParams11.layout) === null || _this$_renderParams11 === void 0 ? void 0 : _this$_renderParams11.type
|
391
|
+
type: (_this$_renderParams11 = this._renderParams) === null || _this$_renderParams11 === void 0 || (_this$_renderParams11 = _this$_renderParams11.appearance) === null || _this$_renderParams11 === void 0 || (_this$_renderParams11 = _this$_renderParams11.layout) === null || _this$_renderParams11 === void 0 ? void 0 : _this$_renderParams11.type,
|
392
|
+
isExpressCheckout: isExpressCheckout
|
384
393
|
});
|
385
394
|
}
|
386
395
|
}, {
|
@@ -793,13 +802,14 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
793
802
|
value: function createPreloadApp(componentSign) {
|
794
803
|
var productSceneVersion = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '1.0';
|
795
804
|
var preloadIframe = createPreloadIframe(componentSign, productSceneVersion);
|
805
|
+
var productScene = componentSign.split(/_(?=[^_]*$)/)[0];
|
796
806
|
var _getIframeUrl = getIframeUrl({
|
797
807
|
renderDisplayType: renderDisplayTypeEnum.popup,
|
798
808
|
componentSign: componentSign,
|
799
809
|
analytics: {
|
800
810
|
enabled: false
|
801
811
|
},
|
802
|
-
productScene:
|
812
|
+
productScene: productScene,
|
803
813
|
productSceneVersion: productSceneVersion,
|
804
814
|
environment: this.AMSSDK.options.env.environment,
|
805
815
|
appVersion: this._appVersion,
|
@@ -935,8 +945,8 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
935
945
|
_context4.next = 5;
|
936
946
|
return createModal({
|
937
947
|
widthPadding: data === null || data === void 0 ? void 0 : data.widthPadding,
|
938
|
-
heightPadding: data === null || data === void 0 ? void 0 : data.heightPadding,
|
939
948
|
device: (_data$device = data === null || data === void 0 ? void 0 : data.device) !== null && _data$device !== void 0 ? _data$device : this.platform,
|
949
|
+
loadingConfig: data === null || data === void 0 ? void 0 : data.loadingConfig,
|
940
950
|
url: pageUrl
|
941
951
|
});
|
942
952
|
case 5:
|
@@ -955,6 +965,7 @@ var ComponentApp = /*#__PURE__*/function () {
|
|
955
965
|
}, POPUP_LOADTIME_LOG_LIMIT);
|
956
966
|
this.popupApp.onload = function () {
|
957
967
|
isLoad = true;
|
968
|
+
removePopupLoading();
|
958
969
|
clearTimeout(timeout);
|
959
970
|
clearTimeout(logTimeout);
|
960
971
|
};
|
@@ -1,8 +1,11 @@
|
|
1
|
+
export declare const createCustomSheet: (curTheme?: 'dark' | 'light') => void;
|
2
|
+
export declare const renderPopupLoading: (container: HTMLDivElement, curTheme: 'dark' | 'light') => void;
|
3
|
+
export declare const removePopupLoading: (isShowMockup?: boolean) => void;
|
1
4
|
export declare const insertStyleSheet: () => void;
|
2
|
-
export declare const createModal: ({ device, url, widthPadding,
|
5
|
+
export declare const createModal: ({ device, url, widthPadding, loadingConfig }: {
|
3
6
|
device: any;
|
4
7
|
url: any;
|
5
8
|
widthPadding: any;
|
6
|
-
|
9
|
+
loadingConfig: any;
|
7
10
|
}) => Promise<HTMLIFrameElement>;
|
8
11
|
export declare const destroyModal: () => void;
|
@@ -1,8 +1,46 @@
|
|
1
|
-
import { AMSPOPUP_PREFIX, ANIMATION_TIME } from "../../constant";
|
1
|
+
import { AMSPOPUP_PREFIX, ANIMATION_TIME, MOCKUP_ID, POPUPLOADING_ID } from "../../constant";
|
2
|
+
import { getDesignFontSize } from "../../util";
|
2
3
|
|
3
4
|
// CSS样式字符串
|
4
|
-
var modalStyles = "\n .".concat(AMSPOPUP_PREFIX, "modal {\n /* \u6DFB\u52A0\u5F39\u7A97\u6837\u5F0F */\n background-color: #fff;\n box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n z-index: 9999; /* \u8BBE\u7F6E\u5F39\u7A97\u7684\u5C42\u7EA7\u4E3A 9999 */\n overflow: hidden;\n }\n\n .").concat(AMSPOPUP_PREFIX, "overlay {\n /* \u6DFB\u52A0\u8499\u5C42\u6837\u5F0F */\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: rgba(0, 0, 0, 0.4);\n z-index: 999;\n }\n\n .").concat(AMSPOPUP_PREFIX, "fadeIn {\n /* \u6DFB\u52A0\u6DE1\u5165\u52A8\u753B */\n animation: fadeIn ").concat(ANIMATION_TIME, "ms;\n animation-fill-mode: forwards;\n }\n\n .").concat(AMSPOPUP_PREFIX, "fadeOut {\n /* \u6DFB\u52A0\u6DE1\u51FA\u52A8\u753B */\n animation: fadeOut ").concat(ANIMATION_TIME, "ms;\n animation-fill-mode: forwards;\n }\n\n /* \u5B9A\u4E49\u6DE1\u5165\u52A8\u753B */\n @keyframes fadeIn {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n }\n\n @-webkit-keyframes fadeIn {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n }\n\n @-moz-keyframes fadeIn {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n }\n\n /* \u5B9A\u4E49\u6DE1\u51FA\u52A8\u753B */\n @keyframes fadeOut {\n 0% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n }\n }\n\n @-webkit-keyframes fadeOut {\n 0% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n }\n }\n\n @-moz-keyframes fadeOut {\n 0% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n }\n }\n");
|
5
|
-
|
5
|
+
var modalStyles = "\n .".concat(AMSPOPUP_PREFIX, "modal {\n /* \u6DFB\u52A0\u5F39\u7A97\u6837\u5F0F */\n background-color: #fff;\n box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n z-index: 9999; /* \u8BBE\u7F6E\u5F39\u7A97\u7684\u5C42\u7EA7\u4E3A 9999 */\n overflow: hidden;\n }\n\n .").concat(AMSPOPUP_PREFIX, "overlay {\n /* \u6DFB\u52A0\u8499\u5C42\u6837\u5F0F */\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: rgba(0, 0, 0, 0.4);\n z-index: 999;\n }\n\n .").concat(AMSPOPUP_PREFIX, "fadeIn {\n /* \u6DFB\u52A0\u6DE1\u5165\u52A8\u753B */\n animation: fadeIn ").concat(ANIMATION_TIME, "ms;\n animation-fill-mode: forwards;\n }\n\n .").concat(AMSPOPUP_PREFIX, "fadeOut {\n /* \u6DFB\u52A0\u6DE1\u51FA\u52A8\u753B */\n animation: fadeOut ").concat(ANIMATION_TIME, "ms;\n animation-fill-mode: forwards;\n }\n\n /* \u5B9A\u4E49\u6DE1\u5165\u52A8\u753B */\n @keyframes fadeIn {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n }\n\n @-webkit-keyframes fadeIn {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n }\n\n @-moz-keyframes fadeIn {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n }\n\n /* \u5B9A\u4E49\u6DE1\u51FA\u52A8\u753B */\n @keyframes fadeOut {\n 0% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n }\n }\n\n @-webkit-keyframes fadeOut {\n 0% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n }\n }\n\n @-moz-keyframes fadeOut {\n 0% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n }\n }\n\n\n.ams-component-popup-loading {\n width: 0.8em;\n height:0.8em;\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-popup-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-popup-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-popup-loading .line div:before,\n.ams-component-popup-loading .line div:after {\n content: '';\n display: block;\n height: 13.33px;\n background: black;\n border-radius: 5.3px;\n}\n.ams-component-popup-loading .line div:after {\n margin-top: 13.33px;\n}\n\n.ams-component-popup-loading .line div:nth-child(2) {\n -webkit-transform: rotate(45deg);\n}\n\n.ams-component-popup-loading .line div:nth-child(3) {\n -webkit-transform: rotate(90deg);\n}\n\n.ams-component-popup-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.ams-component-popup-loading .line div:nth-child(1):before {\n -webkit-animation: load 1s linear 0s infinite;\n}\n\n.ams-component-popup-loading .line div:nth-child(2):before {\n -webkit-animation: load 1s linear 0.125s infinite;\n}\n\n.ams-component-popup-loading .line div:nth-child(3):before {\n -webkit-animation: load 1s linear 0.25s infinite;\n}\n\n.ams-component-popup-loading .line div:nth-child(4):before {\n -webkit-animation: load 1s linear 0.375s infinite;\n}\n\n.ams-component-popup-loading .line div:nth-child(1):after {\n -webkit-animation: load 1s linear 0.5s infinite;\n}\n\n.ams-component-popup-loading .line div:nth-child(2):after {\n -webkit-animation: load 1s linear 0.675s infinite;\n}\n\n.ams-component-popup-loading .line div:nth-child(3):after {\n -webkit-animation: load 1s linear 0.75s infinite;\n}\n\n.ams-component-popup-loading .line div:nth-child(4):after {\n -webkit-animation: load 1s linear 0.875s infinite;\n}\n\n.ams-component-popup-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");
|
6
|
+
var getCurrentTheme = function getCurrentTheme() {
|
7
|
+
var curTheme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'default';
|
8
|
+
var theme = {
|
9
|
+
night: 'dark',
|
10
|
+
gamingPurple: 'dark',
|
11
|
+
agateGreen: 'dark',
|
12
|
+
default: 'light',
|
13
|
+
nostalgicGray: 'light',
|
14
|
+
cherryBlossomPink: 'light'
|
15
|
+
};
|
16
|
+
return theme[curTheme];
|
17
|
+
};
|
18
|
+
export var createCustomSheet = function createCustomSheet() {
|
19
|
+
var curTheme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'light';
|
20
|
+
var sheet = "\n .ams-component-popup-loading .line div:before,\n .ams-component-popup-loading .line div:after {\n background: ".concat(curTheme === 'light' ? '#000000' : '#ffffff', " !important;\n }");
|
21
|
+
var style = document.createElement('style');
|
22
|
+
style.innerHTML = sheet;
|
23
|
+
document.head.appendChild(style);
|
24
|
+
};
|
25
|
+
export var renderPopupLoading = function renderPopupLoading(container, curTheme) {
|
26
|
+
createCustomSheet(curTheme);
|
27
|
+
var loading = document.createElement('div');
|
28
|
+
loading === null || loading === void 0 || loading.classList.add(POPUPLOADING_ID);
|
29
|
+
loading.id = POPUPLOADING_ID;
|
30
|
+
loading.innerHTML = '<div class="line"><div></div><div></div><div></div><div></div></div>';
|
31
|
+
loading.style.fontSize = "".concat(getDesignFontSize(), "px");
|
32
|
+
container.appendChild(loading);
|
33
|
+
};
|
34
|
+
export var removePopupLoading = function removePopupLoading() {
|
35
|
+
var _document$getElementB;
|
36
|
+
var isShowMockup = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
37
|
+
var mockup = document.getElementById(MOCKUP_ID);
|
38
|
+
if (mockup) {
|
39
|
+
mockup.style.background = 'rgb(0, 0, 0, 0.6)';
|
40
|
+
mockup.style.display = isShowMockup ? 'block' : 'none';
|
41
|
+
}
|
42
|
+
(_document$getElementB = document.getElementById(POPUPLOADING_ID)) === null || _document$getElementB === void 0 || _document$getElementB.remove();
|
43
|
+
};
|
6
44
|
// 创建和插入样式表
|
7
45
|
export var insertStyleSheet = function insertStyleSheet() {
|
8
46
|
var style = document.createElement('style');
|
@@ -15,7 +53,7 @@ export var createModal = function createModal(_ref) {
|
|
15
53
|
var device = _ref.device,
|
16
54
|
url = _ref.url,
|
17
55
|
widthPadding = _ref.widthPadding,
|
18
|
-
|
56
|
+
loadingConfig = _ref.loadingConfig;
|
19
57
|
return new Promise(function (resolve, reject) {
|
20
58
|
try {
|
21
59
|
var overlay = document.createElement('div');
|
@@ -28,7 +66,7 @@ export var createModal = function createModal(_ref) {
|
|
28
66
|
modal.style.borderRadius = '12px';
|
29
67
|
} else {
|
30
68
|
modal.style.width = "calc(100% - ".concat(2 * widthPadding, "px)");
|
31
|
-
modal.style.height = "
|
69
|
+
modal.style.height = "80vh";
|
32
70
|
modal.style.borderRadius = '8px';
|
33
71
|
}
|
34
72
|
var iframe = document.createElement('iframe');
|
@@ -36,6 +74,16 @@ export var createModal = function createModal(_ref) {
|
|
36
74
|
iframe.style.border = 'none';
|
37
75
|
iframe.style.width = '100%';
|
38
76
|
iframe.style.height = '100%';
|
77
|
+
if (loadingConfig && Object.keys(loadingConfig).length) {
|
78
|
+
var _loadingConfig$theme = loadingConfig.theme,
|
79
|
+
theme = _loadingConfig$theme === void 0 ? 'default' : _loadingConfig$theme,
|
80
|
+
_loadingConfig$backgr = loadingConfig.backgroundPrimary,
|
81
|
+
backgroundPrimary = _loadingConfig$backgr === void 0 ? '#ffffff' : _loadingConfig$backgr;
|
82
|
+
var mode = getCurrentTheme(theme);
|
83
|
+
renderPopupLoading(modal, mode);
|
84
|
+
modal.style.backgroundColor = backgroundPrimary;
|
85
|
+
iframe.style.backgroundColor = backgroundPrimary;
|
86
|
+
}
|
39
87
|
modal.appendChild(iframe);
|
40
88
|
var body = document.getElementsByTagName('body')[0];
|
41
89
|
body.appendChild(overlay);
|