@alipay/ams-checkout 0.0.1779094014-dev.2 → 0.0.1779094014-dev.21

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.
Files changed (47) hide show
  1. package/ams-checkout.js +3 -3
  2. package/dist/ams-checkout.min.js +1 -1
  3. package/dist/ams-checkout.min.js.map +1 -1
  4. package/esm/component/popupWindow.style.js +2 -1
  5. package/esm/config/index.d.ts +7 -0
  6. package/esm/config/index.js +2 -2
  7. package/esm/constant/index.d.ts +1 -0
  8. package/esm/constant/index.js +1 -0
  9. package/esm/core/component/element/elementContainerService/containerService.js +3 -2
  10. package/esm/core/component/element/elementProcessor/paymentProcessor.js +42 -4
  11. package/esm/core/component/element/index.d.ts +3 -0
  12. package/esm/core/component/element/index.js +13 -8
  13. package/esm/core/component/element/modernElementController/adapter.d.ts +5 -5
  14. package/esm/core/component/element/modernElementController/adapter.js +23 -19
  15. package/esm/core/component/element/modernElementController/index.d.ts +43 -13
  16. package/esm/core/component/element/modernElementController/index.js +585 -263
  17. package/esm/core/component/element/type.d.ts +6 -18
  18. package/esm/foundation/service/container/utils.js +3 -1
  19. package/esm/modern/global.d.ts +3 -0
  20. package/esm/modern/index.d.ts +5 -1
  21. package/esm/modern/index.js +1 -51
  22. package/esm/modern/tools.js +1 -0
  23. package/esm/plugin/component/channel.d.ts +4 -1
  24. package/esm/plugin/component/channel.js +6 -2
  25. package/esm/plugin/component/index.js +7 -6
  26. package/esm/tsdoc-metadata.json +1 -1
  27. package/esm/types/index.d.ts +1 -0
  28. package/esm/util/logger.js +1 -2
  29. package/package.json +23 -10
  30. package/types.d.ts +896 -71
  31. package/types.untrimmed.d.ts +1203 -113
  32. package/esm/modern/oneapi/iexpfront/PaymentSessionService.d.ts +0 -23
  33. package/esm/modern/oneapi/iexpfront/PaymentSessionService.js +0 -55
  34. package/esm/modern/oneapi/iexpfront/definitions.d.ts +0 -3656
  35. package/esm/modern/oneapi/iexpfront/definitions.js +0 -1
  36. package/esm/modern/tools/AntomSDKError.d.ts +0 -47
  37. package/esm/modern/tools/AntomSDKError.js +0 -47
  38. package/esm/modern/tools/buildPageUrl.d.ts +0 -4
  39. package/esm/modern/tools/buildPageUrl.js +0 -19
  40. package/esm/modern/tools/getDevReqConfig.d.ts +0 -2
  41. package/esm/modern/tools/getDevReqConfig.js +0 -16
  42. package/esm/modern/tools/getLocaleFromRenderData.d.ts +0 -6
  43. package/esm/modern/tools/getLocaleFromRenderData.js +0 -20
  44. package/esm/modern/tools/getMetaData.d.ts +0 -102
  45. package/esm/modern/tools/getMetaData.js +0 -7
  46. package/esm/modern/tools/openModal.d.ts +0 -20
  47. package/esm/modern/tools/openModal.js +0 -221
@@ -1 +0,0 @@
1
- export {};
@@ -1,47 +0,0 @@
1
- import { AntomError } from "@antintl/antom-toolset";
2
- declare const AntomSDKErrorCodes: {
3
- /**
4
- * @description 找不到主元素
5
- */
6
- readonly NOT_FIND_MAINELEMENT: "NOT_FIND_MAINELEMENT";
7
- /**
8
- * @description sessionData无效
9
- */
10
- readonly SESSION_DATA_INVALID: "SESSION_DATA_INVALID";
11
- /**
12
- * @description WebApp 初始化超时
13
- */
14
- readonly SDK_LAUNCH_PAYMENT_APP_ERROR: "SDK_LAUNCH_PAYMENT_APP_ERROR";
15
- readonly GENERATE_ELEMENT_KEY_FAILED: "GENERATE_ELEMENT_KEY_FAILED";
16
- readonly ELEMENT_INIT_FAILED: "ELEMENT_INIT_FAILED";
17
- readonly MOUNT_TIMEOUT: "MOUNT_TIMEOUT";
18
- readonly MOUNT_MISSING_CONTAINER: "MOUNT_MISSING_CONTAINER";
19
- readonly MOUNT_IFRAME_LOAD_ERROR: "MOUNT_IFRAME_LOAD_ERROR";
20
- readonly MOUNT_NOT_MAINELEMENT_WITH_SINGLE_MODE: "MOUNT_NOT_MAINELEMENT_WITH_SINGLE_MODE";
21
- readonly MOUNT_NOT_SUPPORT: "MOUNT_NOT_SUPPORT";
22
- readonly MOUNT_INITIAL_FAILED: "MOUNT_INITIAL_FAILED";
23
- readonly ELEMENT_INSTANCE_DESTROYED: "ELEMENT_INSTANCE_DESTROYED";
24
- readonly ELEMENT_DEFINE_ERROR: "ELEMENT_DEFINE_ERROR";
25
- readonly ELEMENT_ALREADY_REGISTERED: "ELEMENT_ALREADY_REGISTERED";
26
- readonly CANNOT_CREATE_SAME_ELEMENT_TWICE: "CANNOT_CREATE_SAME_ELEMENT_TWICE";
27
- readonly GROUPS_ONLY_ONE_MAIN_ELEMENT: "GROUPS_ONLY_ONE_MAIN_ELEMENT";
28
- readonly GROUPS_NOT_FOUND_MAIN_ELEMENT: "GROUPS_NOT_FOUND_MAIN_ELEMENT";
29
- readonly NOT_SUPPORT_ELEMENT: "NOT_SUPPORT_ELEMENT";
30
- readonly NOT_SUPPORT_SUBMIT: "NOT_SUPPORT_SUBMIT";
31
- readonly INVALID_MODAL_URL: "INVALID_MODAL_URL";
32
- readonly LOAD_DEBUGGER_FAILED: "LOAD_DEBUGGER_FAILED";
33
- readonly API_MISS_PARAMS: "API_MISS_PARAMS";
34
- readonly API_GATEWAY_TIMEOUT: "API_GATEWAY_TIMEOUT";
35
- readonly API_SYSTEM_ERROR: "API_SYSTEM_ERROR";
36
- readonly API_TIMEOUT: "API_TIMEOUT";
37
- readonly API_NOT_LOGIN: "API_NOT_LOGIN";
38
- readonly API_GATEWAY_ERROR: "API_GATEWAY_ERROR";
39
- readonly UNKNOWN_ERROR: "UNKNOWN_ERROR";
40
- readonly NO_PORTS_ERROR: "NO_PORTS_ERROR";
41
- readonly INVALID_REDIRECT_URL: "INVALID_REDIRECT_URL";
42
- };
43
- type AntomSDKErrorCodes = typeof AntomSDKErrorCodes[keyof typeof AntomSDKErrorCodes];
44
- export declare class AntomSDKError extends AntomError<AntomSDKErrorCodes> {
45
- name: string;
46
- }
47
- export {};
@@ -1,47 +0,0 @@
1
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
3
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
4
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
5
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
6
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
7
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
8
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
9
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
10
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
11
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
12
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
13
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
14
- 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; }
15
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
16
- 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); }
17
- import { AntomError, CommonErrorCodes } from "@antintl/antom-toolset";
18
- import { SDKInternalErrorCodes } from "@antintl/opensdk-core";
19
- var AntomSDKErrorCodes = _objectSpread(_objectSpread(_objectSpread({}, CommonErrorCodes), SDKInternalErrorCodes), {}, {
20
- /**
21
- * @description 找不到主元素
22
- */
23
- NOT_FIND_MAINELEMENT: 'NOT_FIND_MAINELEMENT',
24
- /**
25
- * @description sessionData无效
26
- */
27
- SESSION_DATA_INVALID: 'SESSION_DATA_INVALID',
28
- /**
29
- * @description WebApp 初始化超时
30
- */
31
- SDK_LAUNCH_PAYMENT_APP_ERROR: 'SDK_LAUNCH_PAYMENT_APP_ERROR'
32
- });
33
- export var AntomSDKError = /*#__PURE__*/function (_AntomError) {
34
- _inherits(AntomSDKError, _AntomError);
35
- var _super = _createSuper(AntomSDKError);
36
- function AntomSDKError() {
37
- var _this;
38
- _classCallCheck(this, AntomSDKError);
39
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
40
- args[_key] = arguments[_key];
41
- }
42
- _this = _super.call.apply(_super, [this].concat(args));
43
- _defineProperty(_assertThisInitialized(_this), "name", 'AntomSDKError');
44
- return _this;
45
- }
46
- return _createClass(AntomSDKError);
47
- }(AntomError);
@@ -1,4 +0,0 @@
1
- /**
2
- * 根据pathname构建页面地址
3
- */
4
- export declare function buildPageUrl(pathname: string, elements2?: boolean): string;
@@ -1,19 +0,0 @@
1
- function getPagePublicPath(elements2) {
2
- var elementsFix = elements2 ? 'elements2' : 'elements';
3
- if (true) {
4
- var origin = location.origin;
5
- var storageOrigin = localStorage.getItem('antom-checkout-v2_app_document_prefix');
6
- // demo在这里注入后,由sdk来使用
7
- if (storageOrigin) {
8
- origin = storageOrigin;
9
- }
10
- return "".concat(origin, "/").concat(elementsFix, "/").concat(localStorage.getItem('ANTOM_LOCAL') ? 'src/pages' : 'pages');
11
- }
12
- return "https://checkout.antom.com/${elementsFix}/pages";
13
- }
14
- /**
15
- * 根据pathname构建页面地址
16
- */
17
- export function buildPageUrl(pathname, elements2) {
18
- return getPagePublicPath(elements2) + (pathname.startsWith('/') ? pathname : "/".concat(pathname));
19
- }
@@ -1,2 +0,0 @@
1
- import { type RequestOptions } from '@antintl/antom-toolset';
2
- export declare function getDevReqConfig(): Partial<RequestOptions> | undefined;
@@ -1,16 +0,0 @@
1
- export function getDevReqConfig() {
2
- // marmot的非生产环境会注入特定的查询参数,我们通过这些参数来判断是否需要开启开发环境的配置
3
- // 在生产环境他们应该是无效的
4
- if (true || false) {
5
- var env = window.localStorage.getItem('antom-checkout-v2_env') || 'dev';
6
- var baseURL = window.localStorage.getItem('antom-checkout-v2_base_url') || undefined;
7
- var group = window.localStorage.getItem('antom-checkout-v2_group_id') || undefined;
8
- var globalSet = JSON.parse(JSON.stringify({
9
- baseURL: baseURL,
10
- group: group,
11
- env: env
12
- }));
13
- console.log('[getDevReqConfig] dev request config:', globalSet);
14
- return globalSet;
15
- }
16
- }
@@ -1,6 +0,0 @@
1
- export declare function getLocaleFromRenderData(renderData?: {
2
- supportedLanguages?: {
3
- preferred?: boolean;
4
- locale?: string;
5
- }[];
6
- }): string | undefined;
@@ -1,20 +0,0 @@
1
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
2
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
3
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
4
- export function getLocaleFromRenderData(renderData) {
5
- var languages = (renderData === null || renderData === void 0 ? void 0 : renderData.supportedLanguages) || [];
6
- var _iterator = _createForOfIteratorHelper(languages),
7
- _step;
8
- try {
9
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
10
- var l = _step.value;
11
- if (l.preferred && l.locale) {
12
- return l.locale;
13
- }
14
- }
15
- } catch (err) {
16
- _iterator.e(err);
17
- } finally {
18
- _iterator.f();
19
- }
20
- }
@@ -1,102 +0,0 @@
1
- import type { PaymentSessionAction, PaymentSessionConfig, SessionSecurityConfig } from '../oneapi/iexpfront/definitions';
2
- export interface FrontModulesToBeLoadedInterface {
3
- acquirerName: string;
4
- scriptUrl: string;
5
- }
6
- export interface IApplePayContactField {
7
- email: string;
8
- name: string;
9
- phone: string;
10
- postalAddress: string;
11
- phoneticName: string;
12
- }
13
- export interface IPaymentSessionMetaData {
14
- clientId?: string;
15
- renderDisplayType?: string;
16
- paymentSessionConfig?: PaymentSessionConfig;
17
- securityConfig?: SessionSecurityConfig;
18
- moneyView?: any;
19
- extendInfo?: string;
20
- paymentMethodInfoView?: any;
21
- paymentView?: any;
22
- modernWeb?: boolean;
23
- action?: PaymentSessionAction;
24
- authUrlInfo?: {
25
- appIdentifier?: string;
26
- applinkUrl?: string;
27
- normalUrl?: string;
28
- schemeUrl?: string;
29
- authUrl?: string;
30
- };
31
- paymentSessionFactor?: {
32
- externalRiskTimeout?: number;
33
- extendInfo?: {
34
- merchantCapabilities?: string[];
35
- supportedNetworks?: string[];
36
- requiredBillingContactFields: IApplePayContactField[];
37
- requiredShippingContactFields: IApplePayContactField[];
38
- };
39
- merchantInfo?: {
40
- registeredCountry?: string;
41
- partnerId?: string;
42
- merchantName?: string;
43
- };
44
- order?: {
45
- orderDescription: string;
46
- };
47
- paymentAmount?: {
48
- value?: string;
49
- currency?: string;
50
- };
51
- paymentMethodInfo?: {
52
- paymentMethodType?: string;
53
- };
54
- paymentMethodViewMetaData?: any;
55
- paymentRequestId?: string;
56
- supportedLanguages?: any;
57
- /**
58
- * 当前为苹果分期场景的信息
59
- */
60
- recurringInfo?: {
61
- /**
62
- * 代扣协议开始日期 不传为当前系统时间
63
- */
64
- startDate?: number;
65
- /**
66
- * 代扣协议结束日期 不传不限制结束时间
67
- */
68
- endDate?: number;
69
- /**
70
- * 付款时间间隔单位,支持:"year" "month" "day" "hour" "minute" 不传默认month
71
- */
72
- intervalUnit?: string;
73
- /**
74
- * 付款时间间隔。比如每过6个月付款一次,intervalCount就是6, 不传默认为1
75
- */
76
- intervalCount?: number;
77
- /**
78
- * 分期标题信息
79
- */
80
- title?: string;
81
- /**
82
- * 分期管理页面
83
- */
84
- managementURL?: string;
85
- /**
86
- * 苹果通知ipay MAPN信息变更的地址
87
- */
88
- tokenNotificationURL?: string;
89
- /**
90
- * 分期协议描述
91
- */
92
- agreementDescription?: string;
93
- };
94
- frontModulesToBeLoaded?: FrontModulesToBeLoadedInterface[];
95
- };
96
- connectFactor?: {
97
- enableConnect?: boolean;
98
- };
99
- skipRenderPaymentMethod?: boolean;
100
- needAccountConfirmPage?: boolean;
101
- }
102
- export declare const getMetaData: (sessionData: string) => IPaymentSessionMetaData;
@@ -1,7 +0,0 @@
1
- import { parseSessionData } from "@antintl/antom-toolset";
2
-
3
- // https://developer.apple.com/documentation/apple_pay_on_the_web/applepaycontactfield
4
-
5
- // 这是从老项目接过来的类型定义,暂时先保留
6
-
7
- export var getMetaData = parseSessionData;
@@ -1,20 +0,0 @@
1
- import type { BaseOpenModalConfig } from '@antintl/opensdk-core';
2
- export interface OpenModalParams extends BaseOpenModalConfig {
3
- mode: 'desktop' | 'mobile';
4
- loadingConfig?: {
5
- theme?: 'light' | 'dark';
6
- backgroundColor?: string;
7
- };
8
- textDirection?: 'ltr' | 'rtl';
9
- }
10
- export declare const openModal: (params: OpenModalParams) => {
11
- iframe: HTMLIFrameElement;
12
- destroy: () => void;
13
- };
14
- /**
15
- *
16
- * @param designSize 设计的size
17
- * @param maxFontSize 最大fontsize
18
- * @returns 确认后的size
19
- */
20
- export declare function getDesignFontSize(designSize?: number, maxFontSize?: number): number;
@@ -1,221 +0,0 @@
1
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
3
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
4
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
5
- import { device, i18n } from '@antintl/antom-toolset';
6
- var AMSPOPUP_PREFIX = 'ams-popup';
7
- var ANIMATION_TIME = 300;
8
- var POPUPLOADING_ID = 'ams-component-popup-loading';
9
-
10
- // CSS样式字符串
11
- 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 .").concat(AMSPOPUP_PREFIX, "modal-mobile{\n background-color: #fff;\n box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);\n position: fixed;\n bottom: 0;\n left: 0%;\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 .").concat(AMSPOPUP_PREFIX, "-drawer-enter {\n animation: slideIn ").concat(ANIMATION_TIME, "ms forwards;\n }\n\n @keyframes slideIn {\n from {\n transform: translateY(100%); /* \u6ED1\u5165\u65F6\u5728\u89C6\u53E3\u5E95\u90E8\u5916 */\n opacity: 0; /* \u521D\u59CB\u900F\u660E\u5EA6\u4E3A 0 */\n }\n to {\n transform: translateY(0); /* \u6ED1\u5165\u7ED3\u675F\u65F6\u5728\u539F\u4F4D\u7F6E */\n opacity: 1; /* \u7ED3\u675F\u65F6\u900F\u660E\u5EA6\u4E3A 1 */\n }\n }\n\n /* \u62BD\u5C49\u4ECE\u5E95\u90E8\u6ED1\u51FA */\n .").concat(AMSPOPUP_PREFIX, "-drawer-exit {\n animation: slideOut ").concat(ANIMATION_TIME, "ms forwards;\n }\n\n @keyframes slideOut {\n from {\n transform: translateY(0); /* \u6ED1\u51FA\u65F6\u4ECE\u5F53\u524D\u4F4D\u7F6E\u5F00\u59CB */\n opacity: 1; /* \u521D\u59CB\u900F\u660E\u5EA6\u4E3A 1 */\n }\n to {\n transform: translateY(100%); /* \u6ED1\u51FA\u7ED3\u675F\u65F6\u5728\u89C6\u53E3\u5E95\u90E8\u5916 */\n opacity: 0; /* \u7ED3\u675F\u65F6\u900F\u660E\u5EA6\u4E3A 0 */\n }\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[dir=\"rtl\"] .ams-component-popup-loading .line div:nth-child(4):before {\n -webkit-animation: load 1s linear 0s infinite;\n}\n\n[dir=\"rtl\"] .ams-component-popup-loading .line div:nth-child(3):before {\n -webkit-animation: load 1s linear 0.125s infinite;\n}\n\n[dir=\"rtl\"] .ams-component-popup-loading .line div:nth-child(2):before {\n -webkit-animation: load 1s linear 0.25s infinite;\n}\n\n[dir=\"rtl\"] .ams-component-popup-loading .line div:nth-child(1):before {\n -webkit-animation: load 1s linear 0.375s infinite;\n}\n\n[dir=\"rtl\"] .ams-component-popup-loading .line div:nth-child(4):after {\n -webkit-animation: load 1s linear 0.5s infinite;\n}\n\n[dir=\"rtl\"] .ams-component-popup-loading .line div:nth-child(3):after {\n -webkit-animation: load 1s linear 0.675s infinite;\n}\n\n[dir=\"rtl\"] .ams-component-popup-loading .line div:nth-child(2):after {\n -webkit-animation: load 1s linear 0.75s infinite;\n}\n\n[dir=\"rtl\"] .ams-component-popup-loading .line div:nth-child(1):after {\n -webkit-animation: load 1s linear 0.875s infinite;\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");
12
- var createCustomSheet = function createCustomSheet() {
13
- var curTheme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'light';
14
- 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 }");
15
- var style = document.createElement('style');
16
- style.innerHTML = sheet;
17
- document.head.appendChild(style);
18
- };
19
- var createPopupLoading = function createPopupLoading(curTheme, text) {
20
- createCustomSheet(curTheme);
21
- var loading = document.createElement('div');
22
- loading === null || loading === void 0 || loading.classList.add(POPUPLOADING_ID);
23
- loading.id = POPUPLOADING_ID;
24
- loading.innerHTML = "<div class=\"line\"><div></div><div></div><div></div><div></div></div><span id=\"text\" style=\"font-size: 16px;position:absolute;bottom: 0;white-space: nowrap\">".concat(text || '', "</span>");
25
- loading.style.fontSize = "".concat(getDesignFontSize(), "px");
26
- return loading;
27
- };
28
-
29
- // 创建和插入样式表
30
- var insertStyleSheet = function insertStyleSheet() {
31
- var style = document.createElement('style');
32
- style.innerHTML = modalStyles;
33
- document.head.appendChild(style);
34
- return function () {
35
- var _style$parentNode;
36
- (_style$parentNode = style.parentNode) === null || _style$parentNode === void 0 || _style$parentNode.removeChild(style);
37
- };
38
- };
39
- function createCloseIcon(_ref) {
40
- var onClose = _ref.onClose,
41
- textDirection = _ref.textDirection;
42
- var closeIcon = document.createElement('div');
43
- closeIcon.style.position = 'absolute';
44
- if (textDirection === 'rtl') {
45
- closeIcon.style.left = '16px';
46
- } else {
47
- closeIcon.style.right = '16px';
48
- }
49
- closeIcon.style.top = '23px';
50
- closeIcon.style.cursor = 'pointer';
51
- var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
52
- svg.setAttribute('width', '16');
53
- svg.setAttribute('height', '16');
54
- svg.setAttribute('viewBox', '0 0 16 16');
55
- svg.setAttribute('fill', 'none');
56
- var path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
57
- path.setAttribute('fill-rule', 'evenodd');
58
- path.setAttribute('clip-rule', 'evenodd');
59
- path.setAttribute('d', 'M13.0449 2.99894L12.9494 2.91165L12.8685 2.85222L12.7802 2.7996C12.3611 2.57499 11.8556 2.64328 11.5228 2.9763L7.99909 6.50088L4.48854 2.99028L4.44701 2.95034C4.0098 2.57169 3.38048 2.57202 2.99838 2.9525L2.92363 3.03297L2.85175 3.12897L2.79916 3.21735C2.57471 3.63642 2.64292 4.14198 2.9757 4.47491L6.50186 8.00046L2.95226 11.5518C2.57141 11.9917 2.57173 12.6211 2.95197 13.0033L3.0324 13.078L3.12837 13.15L3.21674 13.2026C3.63573 13.4272 4.14123 13.3589 4.47407 13.0259L7.99909 9.49935L11.5474 13.0494C11.9944 13.4368 12.6238 13.4235 13.0212 13.0259L13.0922 12.9471L13.1559 12.8595C13.4298 12.4403 13.3789 11.8852 13.0211 11.5272L9.497 8.00115L13.0052 4.4915L13.07 4.4225C13.4304 4.00477 13.4199 3.37582 13.0449 2.99894Z');
60
- path.setAttribute('fill', '#ABB9CC');
61
- svg.appendChild(path);
62
- closeIcon.appendChild(svg);
63
- closeIcon.onclick = onClose;
64
- return closeIcon;
65
- }
66
- // 插入弹窗
67
- export var openModal = function openModal(params) {
68
- var mode = params.mode,
69
- url = params.url,
70
- loadingConfig = params.loadingConfig,
71
- _params$showClose = params.showClose,
72
- showClose = _params$showClose === void 0 ? true : _params$showClose,
73
- _params$hideCloseWhen = params.hideCloseWhenLoaded,
74
- hideCloseWhenLoaded = _params$hideCloseWhen === void 0 ? true : _params$hideCloseWhen,
75
- onClose = params.onClose,
76
- _params$textDirection = params.textDirection,
77
- textDirection = _params$textDirection === void 0 ? 'ltr' : _params$textDirection,
78
- _params$showLoading = params.showLoading,
79
- showLoading = _params$showLoading === void 0 ? true : _params$showLoading;
80
- var overlay = document.createElement('div');
81
- overlay.classList.add("".concat(AMSPOPUP_PREFIX, "overlay"), "".concat(AMSPOPUP_PREFIX, "fadeIn"));
82
- var modal = document.createElement('div');
83
- if (mode === 'desktop') {
84
- modal.classList.add("".concat(AMSPOPUP_PREFIX, "modal"), "".concat(AMSPOPUP_PREFIX, "fadeIn"));
85
- modal.style.width = '656px';
86
- modal.style.height = '620px';
87
- modal.style.borderRadius = '12px';
88
- } else {
89
- modal.classList.add("".concat(AMSPOPUP_PREFIX, "modal-mobile"), "".concat(AMSPOPUP_PREFIX, "-drawer-enter"));
90
- modal.style.width = '100%';
91
- modal.style.height = '80vh';
92
- modal.style.borderRadius = '12px 12px 0 0';
93
- }
94
- modal.setAttribute('dir', textDirection);
95
- var destroyModal = createDestroyHandle(mode, overlay, modal);
96
- var iframe = document.createElement('iframe');
97
- iframe.src = url; // 替换为实际的 URL 地址
98
- iframe.style.border = 'none';
99
- iframe.style.width = '100%';
100
- iframe.style.height = '100%';
101
- var _ref2 = loadingConfig || {},
102
- _ref2$theme = _ref2.theme,
103
- theme = _ref2$theme === void 0 ? 'light' : _ref2$theme,
104
- _ref2$backgroundColor = _ref2.backgroundColor,
105
- backgroundColor = _ref2$backgroundColor === void 0 ? '#ffffff' : _ref2$backgroundColor;
106
- var loadingEle = createPopupLoading(theme);
107
- var createCloseHandle = function createCloseHandle() {
108
- var closing = false;
109
- return /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
110
- var _loadingEle$parentNod;
111
- var closeLoading;
112
- return _regeneratorRuntime().wrap(function _callee$(_context) {
113
- while (1) switch (_context.prev = _context.next) {
114
- case 0:
115
- if (!closing) {
116
- _context.next = 2;
117
- break;
118
- }
119
- return _context.abrupt("return");
120
- case 2:
121
- (_loadingEle$parentNod = loadingEle.parentNode) === null || _loadingEle$parentNod === void 0 || _loadingEle$parentNod.removeChild(loadingEle);
122
- modal.removeChild(iframe);
123
- closeLoading = createPopupLoading(theme, i18n.get({
124
- defaultMessage: 'closing',
125
- id: 'antom.common.closing'
126
- }));
127
- modal.appendChild(closeLoading);
128
- closing = true;
129
- _context.prev = 7;
130
- _context.next = 10;
131
- return onClose === null || onClose === void 0 ? void 0 : onClose();
132
- case 10:
133
- _context.prev = 10;
134
- closing = false;
135
- return _context.finish(10);
136
- case 13:
137
- destroyModal();
138
- case 14:
139
- case "end":
140
- return _context.stop();
141
- }
142
- }, _callee, null, [[7,, 10, 13]]);
143
- }));
144
- };
145
- var handler = function handler() {
146
- modal.removeChild(loadingEle);
147
- iframe.removeEventListener('load', handler);
148
- };
149
- iframe.addEventListener('load', handler);
150
- if (showClose) {
151
- var closeIcon = createCloseIcon({
152
- onClose: createCloseHandle(),
153
- textDirection: textDirection
154
- });
155
- var _handler = function _handler() {
156
- modal.removeChild(closeIcon);
157
- iframe.removeEventListener('load', _handler);
158
- };
159
- if (hideCloseWhenLoaded) {
160
- iframe.addEventListener('load', _handler);
161
- }
162
- modal.appendChild(closeIcon);
163
- }
164
- if (showLoading) {
165
- modal.style.backgroundColor = backgroundColor;
166
- iframe.style.backgroundColor = backgroundColor;
167
- var _handler2 = function _handler2() {
168
- var _loadingEle$parentNod2;
169
- (_loadingEle$parentNod2 = loadingEle.parentNode) === null || _loadingEle$parentNod2 === void 0 || _loadingEle$parentNod2.removeChild(loadingEle);
170
- iframe.removeEventListener('load', _handler2);
171
- };
172
- iframe.addEventListener('load', _handler2);
173
- modal.appendChild(loadingEle);
174
- }
175
- modal.appendChild(iframe);
176
- var body = document.getElementsByTagName('body')[0];
177
- insertStyleSheet();
178
- body.appendChild(overlay);
179
- body.appendChild(modal);
180
- return {
181
- iframe: iframe,
182
- destroy: destroyModal
183
- };
184
- };
185
-
186
- // 创建动画销毁器
187
- function createDestroyHandle(mode, overlay, modal) {
188
- return function () {
189
- if (!overlay) {
190
- return;
191
- }
192
- overlay.classList.remove("".concat(AMSPOPUP_PREFIX, "fadeIn"));
193
- overlay.classList.add("".concat(AMSPOPUP_PREFIX, "fadeOut"));
194
- if (mode === 'desktop') {
195
- modal.classList.remove("".concat(AMSPOPUP_PREFIX, "fadeIn"));
196
- modal.classList.add("".concat(AMSPOPUP_PREFIX, "fadeOut"));
197
- } else {
198
- modal.classList.remove("".concat(AMSPOPUP_PREFIX, "-drawer-enter"));
199
- modal.classList.add("".concat(AMSPOPUP_PREFIX, "-drawer-exit"));
200
- }
201
- setTimeout(function () {
202
- var _overlay$parentNode, _modal$parentNode;
203
- (_overlay$parentNode = overlay.parentNode) === null || _overlay$parentNode === void 0 || _overlay$parentNode.removeChild(overlay);
204
- (_modal$parentNode = modal.parentNode) === null || _modal$parentNode === void 0 || _modal$parentNode.removeChild(modal);
205
- }, ANIMATION_TIME);
206
- };
207
- }
208
-
209
- /**
210
- *
211
- * @param designSize 设计的size
212
- * @param maxFontSize 最大fontsize
213
- * @returns 确认后的size
214
- */
215
- export function getDesignFontSize() {
216
- var designSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 390;
217
- var maxFontSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 130;
218
- var screenWidth = document.documentElement.clientWidth;
219
- var currentFontSize = device.isPC ? maxFontSize : screenWidth * 100 / designSize;
220
- return Math.min(currentFontSize, maxFontSize);
221
- }