@alipay/ams-checkout 1.4.0 → 1.5.0
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 +53 -32
- package/esm/constant/index.js +53 -32
- package/esm/core/component/index.d.ts +23 -9
- package/esm/core/component/index.js +145 -43
- package/esm/core/drop-in/index.d.ts +4 -4
- package/esm/core/drop-in/index.js +3 -3
- package/esm/core/instance/index.d.ts +6 -15
- package/esm/core/instance/index.js +31 -53
- package/esm/image/skeleton.svg +18 -0
- package/esm/index.d.ts +4 -10
- package/esm/index.js +8 -30
- package/esm/plugin/component/cashierApp.d.ts +1 -1
- package/esm/plugin/component/cashierApp.js +16 -15
- package/esm/plugin/component/{component.style.d.ts → component.inline.style.d.ts} +4 -1
- package/esm/plugin/component/component.inline.style.js +38 -0
- package/esm/plugin/component/component.popup.style.d.ts +12 -0
- package/esm/plugin/component/component.popup.style.js +163 -0
- package/esm/plugin/component/index.d.ts +29 -32
- package/esm/plugin/component/index.js +225 -333
- package/esm/plugin/drop-in/index.d.ts +3 -5
- package/esm/plugin/drop-in/index.js +3 -3
- package/esm/request/index.d.ts +2 -2
- package/esm/request/index.js +3 -3
- package/esm/request/utils.d.ts +3 -3
- package/esm/request/utils.js +4 -4
- package/esm/service/index.d.ts +2 -2
- package/esm/types/index.d.ts +71 -34
- package/esm/types/index.js +84 -47
- package/esm/util/createIframeNode.d.ts +3 -3
- package/esm/util/createIframeNode.js +8 -8
- package/esm/util/index.d.ts +6 -4
- package/esm/util/index.js +22 -5
- package/esm/util/mock.js +1 -2
- package/package.json +1 -1
- package/esm/plugin/component/component.style.js +0 -15
@@ -17,7 +17,7 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
17
17
|
*/
|
18
18
|
import { v4 as uuid } from 'uuid';
|
19
19
|
import { ERRORMESSAGE, EVENT } from "../../constant";
|
20
|
-
import {
|
20
|
+
import { environmentEnum, modeEnum, networkModeEnum, osTypeEnum, terminalTypeEnum } from "../../types/index";
|
21
21
|
import { device, EventCenter, getType, queryParse } from "../../util/index";
|
22
22
|
import CallApp from "../../util/intl-callapp/es/main";
|
23
23
|
var AMSSDK = /*#__PURE__*/function () {
|
@@ -25,16 +25,13 @@ var AMSSDK = /*#__PURE__*/function () {
|
|
25
25
|
_classCallCheck(this, AMSSDK);
|
26
26
|
_defineProperty(this, "options", void 0);
|
27
27
|
_defineProperty(this, "checkoutState", void 0);
|
28
|
-
_defineProperty(this, "
|
28
|
+
_defineProperty(this, "_eventCenter", void 0);
|
29
29
|
_defineProperty(this, "plugins", void 0);
|
30
30
|
_defineProperty(this, "_instanceId", void 0);
|
31
31
|
this._instanceId = uuid();
|
32
32
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
33
33
|
this.options = {};
|
34
|
-
this.
|
35
|
-
this.checkoutState = {
|
36
|
-
paymentMethodType: ''
|
37
|
-
};
|
34
|
+
this._eventCenter = new EventCenter();
|
38
35
|
this._initEvent(options);
|
39
36
|
this._setOptions(options);
|
40
37
|
this.plugins = new Map();
|
@@ -43,8 +40,8 @@ var AMSSDK = /*#__PURE__*/function () {
|
|
43
40
|
* @description Destroy and process some contents of the plug-in
|
44
41
|
*/
|
45
42
|
_createClass(AMSSDK, [{
|
46
|
-
key: "
|
47
|
-
value: function
|
43
|
+
key: "unmount",
|
44
|
+
value: function unmount() {
|
48
45
|
var _iterator = _createForOfIteratorHelper(this.plugins.values()),
|
49
46
|
_step;
|
50
47
|
try {
|
@@ -53,7 +50,9 @@ var AMSSDK = /*#__PURE__*/function () {
|
|
53
50
|
try {
|
54
51
|
plugin.logoutPlugin();
|
55
52
|
// eslint-disable-next-line no-empty
|
56
|
-
} catch (error) {
|
53
|
+
} catch (error) {
|
54
|
+
console.error(error);
|
55
|
+
}
|
57
56
|
}
|
58
57
|
} catch (err) {
|
59
58
|
_iterator.e(err);
|
@@ -79,17 +78,17 @@ var AMSSDK = /*#__PURE__*/function () {
|
|
79
78
|
value: function _setEnv(options) {
|
80
79
|
var _queryParse = queryParse(),
|
81
80
|
_moreEnv = _queryParse._moreEnv;
|
82
|
-
if (options !== null && options !== void 0 && options.environment && !((options === null || options === void 0 ? void 0 : options.environment) in
|
83
|
-
console.warn(ERRORMESSAGE.INIT_PARAMETER_ERROR.ENVIRONMENT_ERROR.
|
81
|
+
if (options !== null && options !== void 0 && options.environment && !((options === null || options === void 0 ? void 0 : options.environment) in environmentEnum) && _moreEnv !== 'true') {
|
82
|
+
console.warn(ERRORMESSAGE.INIT_PARAMETER_ERROR.ENVIRONMENT_ERROR.message);
|
84
83
|
options.environment = 'prod';
|
85
84
|
}
|
86
85
|
this.options.env = {
|
87
|
-
terminalType: device.isMobile ?
|
86
|
+
terminalType: device.isMobile ? terminalTypeEnum.WAP : terminalTypeEnum.WEB,
|
88
87
|
environment: (options === null || options === void 0 ? void 0 : options.environment) || 'prod'
|
89
88
|
};
|
90
|
-
if (this.options.env.terminalType ===
|
89
|
+
if (this.options.env.terminalType === terminalTypeEnum.WAP) {
|
91
90
|
// eslint-disable-next-line no-nested-ternary
|
92
|
-
this.options.env.osType = device.iOS ?
|
91
|
+
this.options.env.osType = device.iOS ? osTypeEnum.IOS : device.Android ? osTypeEnum.ANDROID : osTypeEnum.ELSE;
|
93
92
|
}
|
94
93
|
}
|
95
94
|
/**
|
@@ -98,15 +97,15 @@ var AMSSDK = /*#__PURE__*/function () {
|
|
98
97
|
}, {
|
99
98
|
key: "_setMode",
|
100
99
|
value: function _setMode(options) {
|
101
|
-
this.options.mode = (options === null || options === void 0 ? void 0 : options.mode) ||
|
102
|
-
if (options !== null && options !== void 0 && options.mode && !((options === null || options === void 0 ? void 0 : options.mode) in
|
103
|
-
console.warn(ERRORMESSAGE.INIT_PARAMETER_ERROR.MODE_ERROR.
|
104
|
-
this.options.mode =
|
100
|
+
this.options.mode = (options === null || options === void 0 ? void 0 : options.mode) || modeEnum.component;
|
101
|
+
if (options !== null && options !== void 0 && options.mode && !((options === null || options === void 0 ? void 0 : options.mode) in modeEnum)) {
|
102
|
+
console.warn(ERRORMESSAGE.INIT_PARAMETER_ERROR.MODE_ERROR.message);
|
103
|
+
this.options.mode = modeEnum.component;
|
105
104
|
}
|
106
|
-
this.options.networkMode = (options === null || options === void 0 ? void 0 : options.networkMode) ||
|
107
|
-
if (options !== null && options !== void 0 && options.networkMode && !((options === null || options === void 0 ? void 0 : options.networkMode) in
|
108
|
-
console.warn(ERRORMESSAGE.INIT_PARAMETER_ERROR.NET_MODE_NOT_SUPPORT.
|
109
|
-
this.options.networkMode =
|
105
|
+
this.options.networkMode = (options === null || options === void 0 ? void 0 : options.networkMode) || networkModeEnum.session;
|
106
|
+
if (options !== null && options !== void 0 && options.networkMode && !((options === null || options === void 0 ? void 0 : options.networkMode) in networkModeEnum)) {
|
107
|
+
console.warn(ERRORMESSAGE.INIT_PARAMETER_ERROR.NET_MODE_NOT_SUPPORT.message);
|
108
|
+
this.options.networkMode = networkModeEnum.proxy;
|
110
109
|
}
|
111
110
|
}
|
112
111
|
/**
|
@@ -116,28 +115,28 @@ var AMSSDK = /*#__PURE__*/function () {
|
|
116
115
|
key: "_initEvent",
|
117
116
|
value: function _initEvent(options) {
|
118
117
|
if (options !== null && options !== void 0 && options.onError) {
|
119
|
-
if (getType(options.onError) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.
|
118
|
+
if (getType(options.onError) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.message);
|
120
119
|
this._overrideSubscription(EVENT.error.name, options.onError, EVENT.error.uniqueKey);
|
121
120
|
}
|
122
121
|
if (options !== null && options !== void 0 && options.onPaymentMethodSelected) {
|
123
|
-
if (getType(options.onPaymentMethodSelected) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.
|
122
|
+
if (getType(options.onPaymentMethodSelected) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.message);
|
124
123
|
this._overrideSubscription(EVENT.paymentMethodSelected.name, options.onPaymentMethodSelected, EVENT.paymentMethodSelected.uniqueKey);
|
125
124
|
}
|
126
125
|
if (options !== null && options !== void 0 && options.onSizeChanged) {
|
127
|
-
if (getType(options.onSizeChanged) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.
|
126
|
+
if (getType(options.onSizeChanged) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.message);
|
128
127
|
this._overrideSubscription(EVENT.sizeChanged.name, options.onSizeChanged, EVENT.sizeChanged.uniqueKey);
|
129
128
|
}
|
130
129
|
if (options !== null && options !== void 0 && options.onLog) {
|
131
|
-
if (getType(options.onLog) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.
|
130
|
+
if (getType(options.onLog) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.message);
|
132
131
|
this._overrideSubscription(EVENT.log.name, options.onLog, EVENT.log.uniqueKey);
|
133
132
|
}
|
134
133
|
if (options !== null && options !== void 0 && options.onEventCallback) {
|
135
|
-
if (getType(options.onEventCallback) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.
|
134
|
+
if (getType(options.onEventCallback) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.message);
|
136
135
|
this._overrideSubscription(EVENT.eventCallback.name, options.onEventCallback, EVENT.eventCallback.uniqueKey);
|
137
136
|
}
|
138
137
|
if (options !== null && options !== void 0 && options.onClose) {
|
139
|
-
if (getType(options.onClose) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.
|
140
|
-
this._overrideSubscription(EVENT.
|
138
|
+
if (getType(options.onClose) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.message);
|
139
|
+
this._overrideSubscription(EVENT.close.name, options.onClose, EVENT.close.uniqueKey);
|
141
140
|
}
|
142
141
|
}
|
143
142
|
/**
|
@@ -175,7 +174,7 @@ var AMSSDK = /*#__PURE__*/function () {
|
|
175
174
|
value: function _redirect(data) {
|
176
175
|
var _this = this;
|
177
176
|
return new Promise(function (resolve, reject) {
|
178
|
-
var isWeb = _this.options.env.terminalType ===
|
177
|
+
var isWeb = _this.options.env.terminalType === terminalTypeEnum.WEB;
|
179
178
|
var normalUrl = (data === null || data === void 0 ? void 0 : data.normalUrl) || '';
|
180
179
|
var schemeUrl = (data === null || data === void 0 ? void 0 : data.schemeUrl) || '';
|
181
180
|
var applinkUrl = (data === null || data === void 0 ? void 0 : data.applinkUrl) || '';
|
@@ -224,29 +223,8 @@ var AMSSDK = /*#__PURE__*/function () {
|
|
224
223
|
}, {
|
225
224
|
key: "_overrideSubscription",
|
226
225
|
value: function _overrideSubscription(name, func, funcKey) {
|
227
|
-
this.
|
228
|
-
this.
|
229
|
-
}
|
230
|
-
/**
|
231
|
-
* @description Create an event handler, called when an error occurs in AMSCheckout.
|
232
|
-
*/
|
233
|
-
}, {
|
234
|
-
key: "onError",
|
235
|
-
value: function onError(event) {
|
236
|
-
this._overrideSubscription(EVENT.error.name, event, EVENT.error.uniqueKey);
|
237
|
-
}
|
238
|
-
/**
|
239
|
-
* @description Create an event handler
|
240
|
-
*/
|
241
|
-
}, {
|
242
|
-
key: "onSizeChanged",
|
243
|
-
value: function onSizeChanged(event) {
|
244
|
-
this._overrideSubscription(EVENT.sizeChanged.name, event, EVENT.sizeChanged.uniqueKey);
|
245
|
-
}
|
246
|
-
}, {
|
247
|
-
key: "onLog",
|
248
|
-
value: function onLog(event) {
|
249
|
-
this._overrideSubscription(EVENT.log.name, event, EVENT.log.uniqueKey);
|
226
|
+
this._eventCenter.off(name, func, funcKey);
|
227
|
+
this._eventCenter.on(name, func, funcKey);
|
250
228
|
}
|
251
229
|
}]);
|
252
230
|
return AMSSDK;
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<svg width="740" height="360" viewBox="0 0 740 360" fill="none" xmlns="">
|
2
|
+
<rect width="740" height="360" rx="12" fill="#F6F6F6"/>
|
3
|
+
<rect opacity="0.7" x="44" y="44" width="32" height="32" rx="4" fill="#E1E6ED"/>
|
4
|
+
<rect opacity="0.7" x="94" y="44" width="32" height="32" rx="4" fill="#E1E6ED"/>
|
5
|
+
<rect opacity="0.7" x="144" y="44" width="32" height="32" rx="4" fill="#E1E6ED"/>
|
6
|
+
<g style="mix-blend-mode:multiply" opacity="0.336007">
|
7
|
+
<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"/>
|
8
|
+
</g>
|
9
|
+
<g style="mix-blend-mode:multiply" opacity="0.336007">
|
10
|
+
<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"/>
|
11
|
+
</g>
|
12
|
+
<g style="mix-blend-mode:multiply" opacity="0.336007">
|
13
|
+
<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"/>
|
14
|
+
</g>
|
15
|
+
<g style="mix-blend-mode:multiply" opacity="0.336007">
|
16
|
+
<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"/>
|
17
|
+
</g>
|
18
|
+
</svg>
|
package/esm/index.d.ts
CHANGED
@@ -5,18 +5,12 @@
|
|
5
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
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
7
|
*/
|
8
|
-
import {
|
9
|
-
import {
|
10
|
-
import AMSSDK from './core/instance';
|
11
|
-
import { optionsParams } from './types';
|
8
|
+
import { AMSComponent } from './core/component/index';
|
9
|
+
import { IoptionsParams } from './types';
|
12
10
|
export * from './types';
|
13
|
-
export declare class AMSCheckout extends
|
14
|
-
createComponent: IcreateComponentFunc;
|
15
|
-
createPayment: IcreatePaymentFunc;
|
16
|
-
confirmPayment: IconfirmPaymentFunc;
|
17
|
-
constructor(options: optionsParams);
|
11
|
+
export declare class AMSCheckout extends AMSComponent {
|
18
12
|
}
|
19
13
|
export declare class AMSAutoDebit extends AMSCheckout {
|
20
|
-
constructor(options:
|
14
|
+
constructor(options: IoptionsParams);
|
21
15
|
}
|
22
16
|
export default AMSCheckout;
|
package/esm/index.js
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
2
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
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 _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
5
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
4
6
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
5
7
|
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
8
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
@@ -9,9 +11,6 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
|
|
9
11
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
10
12
|
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
13
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
12
|
-
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; }
|
13
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
14
|
-
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
15
14
|
/**
|
16
15
|
* Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
|
17
16
|
*
|
@@ -19,38 +18,17 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
19
18
|
* 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
|
20
19
|
* 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.
|
21
20
|
*/
|
22
|
-
import {
|
23
|
-
import { confirmPayment, createPayment, mixinDropInConstructor, _subscribeFromCheckoutPlugin } from "./core/drop-in/index";
|
24
|
-
import AMSSDK from "./core/instance";
|
21
|
+
import { AMSComponent } from "./core/component/index";
|
25
22
|
export * from "./types";
|
26
|
-
export var AMSCheckout = /*#__PURE__*/function (
|
27
|
-
_inherits(AMSCheckout,
|
23
|
+
export var AMSCheckout = /*#__PURE__*/function (_AMSComponent) {
|
24
|
+
_inherits(AMSCheckout, _AMSComponent);
|
28
25
|
var _super = _createSuper(AMSCheckout);
|
29
|
-
function AMSCheckout(
|
30
|
-
var _this;
|
26
|
+
function AMSCheckout() {
|
31
27
|
_classCallCheck(this, AMSCheckout);
|
32
|
-
|
33
|
-
_defineProperty(_assertThisInitialized(_this), "createComponent", void 0);
|
34
|
-
_defineProperty(_assertThisInitialized(_this), "createPayment", void 0);
|
35
|
-
_defineProperty(_assertThisInitialized(_this), "confirmPayment", void 0);
|
36
|
-
Object.defineProperty(_assertThisInitialized(_this), 'createComponent', {
|
37
|
-
value: createComponent
|
38
|
-
});
|
39
|
-
Object.defineProperty(_assertThisInitialized(_this), 'createPayment', {
|
40
|
-
value: createPayment
|
41
|
-
});
|
42
|
-
Object.defineProperty(_assertThisInitialized(_this), 'confirmPayment', {
|
43
|
-
value: confirmPayment
|
44
|
-
});
|
45
|
-
Object.defineProperty(_assertThisInitialized(_this), '_subscribeFromCheckoutPlugin', {
|
46
|
-
value: _subscribeFromCheckoutPlugin
|
47
|
-
});
|
48
|
-
mixinComponentConstructor(options, _assertThisInitialized(_this));
|
49
|
-
mixinDropInConstructor(options, _assertThisInitialized(_this));
|
50
|
-
return _this;
|
28
|
+
return _super.apply(this, arguments);
|
51
29
|
}
|
52
30
|
return _createClass(AMSCheckout);
|
53
|
-
}(
|
31
|
+
}(AMSComponent);
|
54
32
|
export var AMSAutoDebit = /*#__PURE__*/function (_AMSCheckout) {
|
55
33
|
_inherits(AMSAutoDebit, _AMSCheckout);
|
56
34
|
var _super2 = _createSuper(AMSAutoDebit);
|
@@ -20,4 +20,4 @@ export declare const getIframeUrl: (iframeParams: {
|
|
20
20
|
/**
|
21
21
|
* @description Create iframe
|
22
22
|
*/
|
23
|
-
export declare const createIframe: (mode: string) => HTMLIFrameElement;
|
23
|
+
export declare const createIframe: (mode: string, platform: 'mobile' | 'desktop') => HTMLIFrameElement;
|
@@ -85,38 +85,39 @@ export var getIframeUrl = function getIframeUrl(iframeParams) {
|
|
85
85
|
locale: locale,
|
86
86
|
scale: scale,
|
87
87
|
instanceId: instanceId,
|
88
|
-
sandbox: environment === 'light_sandbox' || _light_sandbox === 'true' ? 'true' : 'false',
|
89
88
|
analyticsEnabled: (analytics === null || analytics === void 0 ? void 0 : analytics.enabled) === false ? 'false' : 'true',
|
90
89
|
sdkVersion: sdkVersion,
|
91
|
-
refUrl: window.location.href
|
92
|
-
shadow: environment === 'sandbox' || _sandbox === 'true' ? 'true' : 'false',
|
93
|
-
requestHost: requestHost,
|
94
|
-
groupId: groupId,
|
95
|
-
LOCAL_MOCK: LOCAL_MOCK
|
90
|
+
refUrl: window.location.href
|
96
91
|
});
|
92
|
+
if (LOCAL_MOCK) urlParams.LOCAL_MOCK = LOCAL_MOCK;
|
93
|
+
if (requestHost) urlParams.requestHost = requestHost;
|
94
|
+
if (groupId) urlParams.groupId = groupId;
|
95
|
+
if (environment === 'light_sandbox' || _light_sandbox === 'true') urlParams.sandbox = 'true';
|
96
|
+
if (environment === 'sandbox' || _sandbox === 'true') urlParams.shadow = 'true';
|
97
97
|
var locationSearch = serialize(urlParams);
|
98
98
|
return "".concat(path, "?").concat(locationSearch);
|
99
99
|
};
|
100
|
-
var getIframeId = function getIframeId(UIMode) {
|
101
|
-
var IdMap = {
|
102
|
-
dropin: 'checkout-dropin',
|
103
|
-
component: 'checkout-component'
|
104
|
-
};
|
105
|
-
return IdMap[UIMode] || 'checkout-component';
|
106
|
-
};
|
107
100
|
|
108
101
|
/**
|
109
102
|
* @description Create iframe
|
110
103
|
*/
|
111
|
-
export var createIframe = function createIframe(mode) {
|
104
|
+
export var createIframe = function createIframe(mode, platform) {
|
105
|
+
var getIframeId = function getIframeId() {
|
106
|
+
var IdMap = {
|
107
|
+
dropin: "ams-checkout-dropin-".concat(platform),
|
108
|
+
component: "ams-checkout-component-".concat(platform)
|
109
|
+
};
|
110
|
+
return IdMap[mode] || 'ams-checkout-component';
|
111
|
+
};
|
112
112
|
var iframe = document.createElement('iframe');
|
113
|
-
var iframeId = getIframeId(
|
113
|
+
var iframeId = getIframeId();
|
114
114
|
var none = '0';
|
115
115
|
var width = '100%';
|
116
116
|
iframe.id = iframeId;
|
117
117
|
iframe.style.height = none;
|
118
118
|
iframe.style.width = width;
|
119
119
|
iframe.style.border = none;
|
120
|
+
iframe.style.opacity = none;
|
120
121
|
iframe.style.overflow = 'hidden';
|
121
122
|
return iframe;
|
122
123
|
};
|
@@ -5,4 +5,7 @@
|
|
5
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
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
7
|
*/
|
8
|
-
|
8
|
+
import { platformEnum } from '../../types';
|
9
|
+
export declare const inlineComponentAddCss: () => void;
|
10
|
+
export declare const addInlineLoading: (_selector: HTMLDivElement, platform: platformEnum) => void;
|
11
|
+
export declare const createInlineBaseElement: (selector: string) => HTMLDivElement | undefined;
|
@@ -0,0 +1,38 @@
|
|
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 { INLINE_BASE_STYLE_ID, LOADING_ID, INLINE_IMG_CLASSNAME, COMPONENT_CONTAINER_ID, COMPONENT_IFRAME_TAG_ID } from "../../constant";
|
10
|
+
import { amsSetSize } from "../../util";
|
11
|
+
var inlineComponentCss = "#".concat(COMPONENT_IFRAME_TAG_ID, "-desktop{\n border-radius: 8px;\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
|
+
export var inlineComponentAddCss = function inlineComponentAddCss() {
|
13
|
+
var style = document.createElement('style');
|
14
|
+
style.id = 'ams-inline-component-style';
|
15
|
+
style.type = 'text/css';
|
16
|
+
style.innerHTML = inlineComponentCss;
|
17
|
+
document.head.appendChild(style);
|
18
|
+
};
|
19
|
+
export var addInlineLoading = function addInlineLoading(_selector, platform) {
|
20
|
+
var loading = document.createElement('div');
|
21
|
+
loading.id = LOADING_ID;
|
22
|
+
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>");
|
23
|
+
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 ");
|
24
|
+
if (_selector) _selector.appendChild(loading);
|
25
|
+
var loadingDom = document.getElementById(LOADING_ID);
|
26
|
+
amsSetSize(null, loadingDom);
|
27
|
+
};
|
28
|
+
export var createInlineBaseElement = function createInlineBaseElement(selector) {
|
29
|
+
var inlineBaseStyle = document.getElementById(INLINE_BASE_STYLE_ID);
|
30
|
+
if (!inlineBaseStyle) inlineComponentAddCss();
|
31
|
+
if (document.getElementById(COMPONENT_CONTAINER_ID)) return;
|
32
|
+
var amsComponentContainer = document.createElement('div');
|
33
|
+
amsComponentContainer.className = "".concat(COMPONENT_CONTAINER_ID, "-inline");
|
34
|
+
amsComponentContainer.id = COMPONENT_CONTAINER_ID;
|
35
|
+
var selectorDom = document.querySelector(selector);
|
36
|
+
if (selectorDom) selectorDom.appendChild(amsComponentContainer);
|
37
|
+
return amsComponentContainer;
|
38
|
+
};
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { platformEnum } from '../../types';
|
2
|
+
export declare const componentAddCSS: () => void;
|
3
|
+
export declare const createBaseElement: (platform: platformEnum, closeBtnFunc: () => void) => HTMLDivElement | undefined;
|
4
|
+
export declare const createCloseBtn: (platform: platformEnum, closeBtnFunc: () => void) => void;
|
5
|
+
export declare const createRetentionPopup: (platform: platformEnum, remainBtnFunc: () => void, leaveBtnFunc: () => void) => void;
|
6
|
+
export declare const hideRetentionPopup: () => void;
|
7
|
+
export declare const removeRetentionPopup: (platform: platformEnum, remainBtnFunc: () => void, leaveBtnFunc: () => void) => void;
|
8
|
+
export declare const createMockup: () => void;
|
9
|
+
export declare const addPopupLoading: () => void;
|
10
|
+
export declare const handleDeclareInfo: ({ closeDialogData }: {
|
11
|
+
closeDialogData: any;
|
12
|
+
}) => void;
|
@@ -0,0 +1,163 @@
|
|
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 { ANIMATION_TIME, closeImg, COMPONENT_CLOSE_BLOCK_ID, COMPONENT_CONTAINER_ID, COMPONENT_RETENTION_ID, COMPONENT_SECTION_ID, LOADING_ID, MOCKUP_ID } from "../../constant";
|
9
|
+
import { platformEnum } from "../../types";
|
10
|
+
import { addSetFontSizeEvent, amsSetSize, getDesignFontSize } from "../../util";
|
11
|
+
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 -webkit-transform: translate(-50%, -50%) scale(1);\n opacity: 1\n }\n \n 100% {\n opacity: 0;\n transform: translate(-50%, -50%) scale(0.4);\n -webkit-transform: translate(-50%, -50%) scale(0.4);\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: ams-component-container-zoom-out 0.3s ease-in-out;\n animation-fill-mode: forwards;\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.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 -webkit-animation: ams-component-container-zoom-out 0.3s ease-in-out;\n animation-fill-mode: forwards;\n -webkit-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 overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.ams-component-retention-remain-mobile {\n width: 100%;\n height: 44px;\n font-size: 16px;\n line-height: 44px;\n padding: 0 6px;\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 padding: 0 8px;\n max-width: 225px;\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 overflow: hidden;\n text-overflow: ellipsis;\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 padding: 0 6px;\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 padding: 0 8px;\n max-width: 225px;\n}\n.".concat(MOCKUP_ID, "-hidden{\nanimation: ").concat(MOCKUP_ID, "-opacity 0.3s ease-in-out;\n animation-fill-mode: forwards\n}\n/** \u52A0\u8F7D\u52A8\u753B **/\n@-webkit-keyframes ").concat(MOCKUP_ID, "-opacity {\n 0% {\n opacity: 1;\n }\n\n 100% {\n opacity: 0;\n }\n}\n");
|
12
|
+
export var componentAddCSS = function componentAddCSS() {
|
13
|
+
var style = document.createElement('style');
|
14
|
+
style.type = 'text/css';
|
15
|
+
style.innerHTML = componentCss;
|
16
|
+
document.head.appendChild(style);
|
17
|
+
};
|
18
|
+
export var createBaseElement = function createBaseElement(platform, closeBtnFunc) {
|
19
|
+
if (document.getElementById(COMPONENT_CONTAINER_ID)) return;
|
20
|
+
componentAddCSS();
|
21
|
+
addSetFontSizeEvent();
|
22
|
+
var amsComponentContainer = document.createElement('div');
|
23
|
+
amsComponentContainer.className = "".concat(COMPONENT_CONTAINER_ID, "-hidden-").concat(platform);
|
24
|
+
amsComponentContainer.id = COMPONENT_CONTAINER_ID;
|
25
|
+
amsSetSize(null, amsComponentContainer);
|
26
|
+
document.body.appendChild(amsComponentContainer);
|
27
|
+
var amsComponentSection = document.createElement('div');
|
28
|
+
amsComponentSection.className = "ams-component-section-".concat(platform);
|
29
|
+
amsComponentSection.id = COMPONENT_SECTION_ID;
|
30
|
+
amsComponentContainer.appendChild(amsComponentSection);
|
31
|
+
amsComponentContainer.classList.remove("".concat(COMPONENT_CONTAINER_ID, "-hidden-").concat(platform));
|
32
|
+
amsComponentContainer.classList.add("".concat(COMPONENT_CONTAINER_ID, "-").concat(platform));
|
33
|
+
createCloseBtn(platform, closeBtnFunc);
|
34
|
+
return amsComponentContainer;
|
35
|
+
};
|
36
|
+
export var createCloseBtn = function createCloseBtn(platform, closeBtnFunc) {
|
37
|
+
var clickEventName = platform === platformEnum.mobile ? 'touchend' : 'click';
|
38
|
+
var container = document.getElementById(COMPONENT_CONTAINER_ID);
|
39
|
+
// close btn
|
40
|
+
var closeBtnHTML = "<img class='".concat(COMPONENT_CLOSE_BLOCK_ID, "-btn-").concat(platform, "' src=\"").concat(closeImg, "\"/>");
|
41
|
+
var closeBlock = document.createElement('div');
|
42
|
+
closeBlock.classList.add("".concat(COMPONENT_CLOSE_BLOCK_ID, "-").concat(platform), "".concat(COMPONENT_CLOSE_BLOCK_ID, "-hidden"));
|
43
|
+
closeBlock.id = COMPONENT_CLOSE_BLOCK_ID;
|
44
|
+
closeBlock.innerHTML = closeBtnHTML;
|
45
|
+
closeBlock.addEventListener(clickEventName, function () {
|
46
|
+
closeBtnFunc();
|
47
|
+
});
|
48
|
+
if (container) container.appendChild(closeBlock);
|
49
|
+
};
|
50
|
+
export var createRetentionPopup = function createRetentionPopup(platform, remainBtnFunc, leaveBtnFunc) {
|
51
|
+
var clickEventName = platform === platformEnum.mobile ? 'touchend' : 'click';
|
52
|
+
// retention popup
|
53
|
+
var retentionPopup = document.createElement('div');
|
54
|
+
retentionPopup.id = COMPONENT_RETENTION_ID;
|
55
|
+
retentionPopup.classList.add("".concat(COMPONENT_RETENTION_ID, "-").concat(platform));
|
56
|
+
retentionPopup.innerHTML = "\n <span id=\"".concat(COMPONENT_RETENTION_ID, "-title\" class=\"").concat(COMPONENT_RETENTION_ID, "-title-").concat(platform, "\">\n Are you sure you want to leave?\n </span>\n <span\n id=\"").concat(COMPONENT_RETENTION_ID, "-sub-title\"\n class=\"").concat(COMPONENT_RETENTION_ID, "-sub-title-").concat(platform, "\"\n >\n If you leave this page, you'll have to start over again.\n </span>\n <div class=\"").concat(COMPONENT_RETENTION_ID, "-btn-block-").concat(platform, "\">\n <div id=\"").concat(COMPONENT_RETENTION_ID, "-remain\" class=\"").concat(COMPONENT_RETENTION_ID, "-remain-").concat(platform, "\">\n Continue Payment\n </div>\n <div id=\"").concat(COMPONENT_RETENTION_ID, "-leave\" class=\"").concat(COMPONENT_RETENTION_ID, "-leave-").concat(platform, "\">\n Leave\n </div>\n </div>");
|
57
|
+
document.body.appendChild(retentionPopup);
|
58
|
+
var remainBtn = document.getElementById("".concat(COMPONENT_RETENTION_ID, "-remain"));
|
59
|
+
if (remainBtn) {
|
60
|
+
remainBtn.addEventListener(clickEventName, remainBtnFunc);
|
61
|
+
}
|
62
|
+
var leaveBtn = document.getElementById("".concat(COMPONENT_RETENTION_ID, "-leave"));
|
63
|
+
if (leaveBtn) {
|
64
|
+
leaveBtn.addEventListener(clickEventName, leaveBtnFunc);
|
65
|
+
}
|
66
|
+
};
|
67
|
+
export var hideRetentionPopup = function hideRetentionPopup() {
|
68
|
+
var retentionPopup = document.getElementById(COMPONENT_RETENTION_ID);
|
69
|
+
var container = document.getElementById(COMPONENT_CONTAINER_ID);
|
70
|
+
if (retentionPopup) {
|
71
|
+
retentionPopup.classList.remove("".concat(COMPONENT_RETENTION_ID, "-show"));
|
72
|
+
retentionPopup.classList.add("".concat(COMPONENT_RETENTION_ID, "-hidden"));
|
73
|
+
setTimeout(function () {
|
74
|
+
retentionPopup.classList.remove("".concat(COMPONENT_RETENTION_ID, "-hidden"));
|
75
|
+
container === null || container === void 0 ? void 0 : container.classList.remove("".concat(COMPONENT_CONTAINER_ID, "-opacity"));
|
76
|
+
}, ANIMATION_TIME);
|
77
|
+
}
|
78
|
+
};
|
79
|
+
export var removeRetentionPopup = function removeRetentionPopup(platform, remainBtnFunc, leaveBtnFunc) {
|
80
|
+
var _document$getElementB;
|
81
|
+
var clickEventName = platform === platformEnum.mobile ? 'touchend' : 'click';
|
82
|
+
var remainBtn = document.getElementById("".concat(COMPONENT_RETENTION_ID, "-remain"));
|
83
|
+
if (remainBtn) {
|
84
|
+
remainBtn.removeEventListener(clickEventName, remainBtnFunc);
|
85
|
+
}
|
86
|
+
var leaveBtn = document.getElementById("".concat(COMPONENT_RETENTION_ID, "-leave"));
|
87
|
+
if (leaveBtn) {
|
88
|
+
leaveBtn.removeEventListener(clickEventName, leaveBtnFunc);
|
89
|
+
}
|
90
|
+
(_document$getElementB = document.getElementById(COMPONENT_RETENTION_ID)) === null || _document$getElementB === void 0 ? void 0 : _document$getElementB.remove();
|
91
|
+
};
|
92
|
+
export var createMockup = function createMockup() {
|
93
|
+
var body = document.getElementsByTagName('body')[0];
|
94
|
+
body.style.overflow = 'hidden';
|
95
|
+
var mockup = document.createElement('div');
|
96
|
+
mockup.style.width = '100vw';
|
97
|
+
mockup.style.height = '100vh';
|
98
|
+
mockup.style.position = 'fixed';
|
99
|
+
mockup.style.top = '0';
|
100
|
+
mockup.style.left = '0';
|
101
|
+
mockup.style.zIndex = '1000';
|
102
|
+
mockup.style.background = 'rgba(0,0,0,0.5)';
|
103
|
+
mockup.style.display = 'none';
|
104
|
+
mockup.id = MOCKUP_ID;
|
105
|
+
body.appendChild(mockup);
|
106
|
+
};
|
107
|
+
export var addPopupLoading = function addPopupLoading() {
|
108
|
+
var loading = document.createElement('div');
|
109
|
+
loading === null || loading === void 0 ? void 0 : loading.classList.add(LOADING_ID);
|
110
|
+
loading.id = LOADING_ID;
|
111
|
+
loading.innerHTML = '<div class="line"><div></div><div></div><div></div><div></div></div>';
|
112
|
+
loading.style.fontSize = "".concat(getDesignFontSize(), "px");
|
113
|
+
var body = document.getElementsByTagName('body')[0];
|
114
|
+
body === null || body === void 0 ? void 0 : body.appendChild(loading);
|
115
|
+
};
|
116
|
+
export var handleDeclareInfo = function handleDeclareInfo(_ref) {
|
117
|
+
var _ref$closeDialogData = _ref.closeDialogData,
|
118
|
+
closeDialogData = _ref$closeDialogData === void 0 ? {} : _ref$closeDialogData;
|
119
|
+
try {
|
120
|
+
if (closeDialogData) {
|
121
|
+
var retentionTitle = document.getElementById("".concat(COMPONENT_RETENTION_ID, "-title"));
|
122
|
+
if (retentionTitle) {
|
123
|
+
var _closeDialogData$titl, _closeDialogData$titl2, _closeDialogData$titl3;
|
124
|
+
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");
|
125
|
+
retentionTitle.style.color = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$titl2 = closeDialogData.title) === null || _closeDialogData$titl2 === void 0 ? void 0 : _closeDialogData$titl2.fontColor;
|
126
|
+
retentionTitle.innerHTML = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$titl3 = closeDialogData.title) === null || _closeDialogData$titl3 === void 0 ? void 0 : _closeDialogData$titl3.text;
|
127
|
+
}
|
128
|
+
var retentionMessage = document.getElementById("".concat(COMPONENT_RETENTION_ID, "-sub-title"));
|
129
|
+
if (retentionMessage) {
|
130
|
+
var _closeDialogData$mess, _closeDialogData$mess2, _closeDialogData$mess3;
|
131
|
+
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");
|
132
|
+
retentionMessage.style.color = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$mess2 = closeDialogData.message) === null || _closeDialogData$mess2 === void 0 ? void 0 : _closeDialogData$mess2.fontColor;
|
133
|
+
retentionMessage.innerHTML = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$mess3 = closeDialogData.message) === null || _closeDialogData$mess3 === void 0 ? void 0 : _closeDialogData$mess3.text;
|
134
|
+
}
|
135
|
+
var remainBtn = document.getElementById("".concat(COMPONENT_RETENTION_ID, "-remain"));
|
136
|
+
if (remainBtn) {
|
137
|
+
var _closeDialogData$btnO, _closeDialogData$btnO2, _closeDialogData$btnO3, _closeDialogData$btnO4, _closeDialogData$btnO5, _closeDialogData$btnO7;
|
138
|
+
remainBtn.innerHTML = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnO = closeDialogData.btnOK) === null || _closeDialogData$btnO === void 0 ? void 0 : _closeDialogData$btnO.text;
|
139
|
+
remainBtn.style.fontSize = "".concat(closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnO2 = closeDialogData.btnOK) === null || _closeDialogData$btnO2 === void 0 ? void 0 : _closeDialogData$btnO2.fontSize, "px");
|
140
|
+
remainBtn.style.color = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnO3 = closeDialogData.btnOK) === null || _closeDialogData$btnO3 === void 0 ? void 0 : _closeDialogData$btnO3.fontColor;
|
141
|
+
remainBtn.style.borderRadius = "".concat(closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnO4 = closeDialogData.btnOK) === null || _closeDialogData$btnO4 === void 0 ? void 0 : _closeDialogData$btnO4.corner, "px");
|
142
|
+
if ((closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnO5 = closeDialogData.btnOK) === null || _closeDialogData$btnO5 === void 0 ? void 0 : _closeDialogData$btnO5.type) === 'stroke') {
|
143
|
+
var _closeDialogData$btnO6;
|
144
|
+
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);
|
145
|
+
} 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;
|
146
|
+
}
|
147
|
+
var leaveBrn = document.getElementById("".concat(COMPONENT_RETENTION_ID, "-leave"));
|
148
|
+
if (leaveBrn) {
|
149
|
+
var _closeDialogData$btnC, _closeDialogData$btnC2, _closeDialogData$btnC3, _closeDialogData$btnC4, _closeDialogData$btnC5, _closeDialogData$btnC7;
|
150
|
+
leaveBrn.innerHTML = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnC = closeDialogData.btnCancel) === null || _closeDialogData$btnC === void 0 ? void 0 : _closeDialogData$btnC.text;
|
151
|
+
leaveBrn.style.fontSize = "".concat(closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnC2 = closeDialogData.btnCancel) === null || _closeDialogData$btnC2 === void 0 ? void 0 : _closeDialogData$btnC2.fontSize, "px");
|
152
|
+
leaveBrn.style.color = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnC3 = closeDialogData.btnCancel) === null || _closeDialogData$btnC3 === void 0 ? void 0 : _closeDialogData$btnC3.fontColor;
|
153
|
+
leaveBrn.style.borderRadius = "".concat(closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnC4 = closeDialogData.btnCancel) === null || _closeDialogData$btnC4 === void 0 ? void 0 : _closeDialogData$btnC4.corner, "px");
|
154
|
+
if ((closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnC5 = closeDialogData.btnCancel) === null || _closeDialogData$btnC5 === void 0 ? void 0 : _closeDialogData$btnC5.type) === 'stroke') {
|
155
|
+
var _closeDialogData$btnC6;
|
156
|
+
leaveBrn.style.border = "1px solid ".concat(closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnC6 = closeDialogData.btnCancel) === null || _closeDialogData$btnC6 === void 0 ? void 0 : _closeDialogData$btnC6.bg);
|
157
|
+
} else leaveBrn.style.backgroundColor = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnC7 = closeDialogData.btnCancel) === null || _closeDialogData$btnC7 === void 0 ? void 0 : _closeDialogData$btnC7.bg;
|
158
|
+
}
|
159
|
+
}
|
160
|
+
} catch (error) {
|
161
|
+
console.error(error);
|
162
|
+
}
|
163
|
+
};
|