@paykka/card-checkout-ui 0.5.15 → 0.5.17
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/card-checkout-ui.iife.js +4 -4
- package/dist/card-checkout-ui.umd.cjs +4 -4
- package/dist/es/api/index.js +3 -0
- package/dist/es/api/modules/index.js +3 -0
- package/dist/es/components/AccountNameField/index.js +2 -0
- package/dist/es/components/AddressField/index.js +2 -0
- package/dist/es/components/CardExpireDateField/index.js +2 -0
- package/dist/es/components/CardHolderNameField/index.js +2 -0
- package/dist/es/components/CardIBANField/index.js +2 -0
- package/dist/es/components/CardNumberField/index.js +2 -0
- package/dist/es/components/CardSecurityCodeField/index.js +2 -0
- package/dist/es/components/CardSelector/index.js +2 -0
- package/dist/es/components/EmailField/EmailField.js +2 -0
- package/dist/es/components/RecurringTip/index.js +1 -1
- package/dist/es/components/SecuredFieldsProvider/SecuredFieldsProvider.js +0 -1
- package/dist/es/components/internal/CheckBox/CheckBox.js +1 -1
- package/dist/es/config.js +11 -0
- package/dist/es/core/Session.js +3 -0
- package/dist/es/core/index.js +2 -0
- package/dist/es/core/query.js +3 -0
- package/dist/es/core.js +34 -34
- package/dist/es/hooks/useI18n.js +1 -1
- package/dist/es/hooks/usePayState.js +4 -8
- package/dist/es/i18n/I18n.js +11 -8
- package/dist/es/index.js +4 -2
- package/dist/types/components/AliPay/type.d.ts +0 -2
- package/dist/types/components/ApplePay/type.d.ts +0 -2
- package/dist/types/components/Card/type.d.ts +0 -2
- package/dist/types/components/GooglePay/type.d.ts +0 -2
- package/dist/types/components/Sepa/type.d.ts +0 -2
- package/dist/types/components/WechatPay/type.d.ts +0 -2
- package/dist/types/config.d.ts +3 -0
- package/dist/types/hooks/useI18n.d.ts +2 -2
- package/dist/types/hooks/usePayState.d.ts +0 -2
- package/dist/types/i18n/I18n.d.ts +6 -5
- package/dist/types/i18n/locales/index.d.ts +1 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/types/utils/format.d.ts +2 -2
- package/package.json +1 -1
package/dist/es/api/index.js
CHANGED
|
@@ -3,6 +3,8 @@ import "../../utils/card-brand/brands.js";
|
|
|
3
3
|
import "../../utils/system-info/get-browser-info.js";
|
|
4
4
|
import { useI18n } from "../../hooks/useI18n.js";
|
|
5
5
|
import "../../core/context.js";
|
|
6
|
+
import "../../i18n/util.js";
|
|
7
|
+
import "../../i18n/locales/index.js";
|
|
6
8
|
import "../internal/Form/context.js";
|
|
7
9
|
import { FormItem } from "../internal/Form/FormItem.js";
|
|
8
10
|
import "../internal/Form/Form.js";
|
|
@@ -8,6 +8,8 @@ import "../../core/context.js";
|
|
|
8
8
|
import { isArray, isNil } from "../../utils/is.js";
|
|
9
9
|
import "../../utils/card-brand/brands.js";
|
|
10
10
|
import "../../utils/system-info/get-browser-info.js";
|
|
11
|
+
import "../../i18n/util.js";
|
|
12
|
+
import "../../i18n/locales/index.js";
|
|
11
13
|
import "../internal/Form/context.js";
|
|
12
14
|
import { FormItem } from "../internal/Form/FormItem.js";
|
|
13
15
|
import "../internal/Form/Form.js";
|
|
@@ -2,6 +2,8 @@ import { w, A, F, h, u } from "../../core.js";
|
|
|
2
2
|
import { isExpired } from "../../utils/index.js";
|
|
3
3
|
import { useI18n } from "../../hooks/useI18n.js";
|
|
4
4
|
import "../../core/context.js";
|
|
5
|
+
import "../../i18n/util.js";
|
|
6
|
+
import "../../i18n/locales/index.js";
|
|
5
7
|
import "../internal/Form/context.js";
|
|
6
8
|
import { FormItem } from "../internal/Form/FormItem.js";
|
|
7
9
|
import "../internal/Form/Form.js";
|
|
@@ -3,6 +3,8 @@ import "../../utils/card-brand/brands.js";
|
|
|
3
3
|
import "../../utils/system-info/get-browser-info.js";
|
|
4
4
|
import { useI18n } from "../../hooks/useI18n.js";
|
|
5
5
|
import "../../core/context.js";
|
|
6
|
+
import "../../i18n/util.js";
|
|
7
|
+
import "../../i18n/locales/index.js";
|
|
6
8
|
import "../internal/Form/context.js";
|
|
7
9
|
import { FormItem } from "../internal/Form/FormItem.js";
|
|
8
10
|
import "../internal/Form/Form.js";
|
|
@@ -2,6 +2,8 @@ import { A, h, u } from "../../core.js";
|
|
|
2
2
|
import { clamp } from "../../utils/index.js";
|
|
3
3
|
import { useI18n } from "../../hooks/useI18n.js";
|
|
4
4
|
import "../../core/context.js";
|
|
5
|
+
import "../../i18n/util.js";
|
|
6
|
+
import "../../i18n/locales/index.js";
|
|
5
7
|
import "../internal/Form/context.js";
|
|
6
8
|
import { FormItem } from "../internal/Form/FormItem.js";
|
|
7
9
|
import "../internal/Form/Form.js";
|
|
@@ -2,6 +2,8 @@ import { w, A, F, h, u } from "../../core.js";
|
|
|
2
2
|
import { clamp } from "../../utils/index.js";
|
|
3
3
|
import { useI18n } from "../../hooks/useI18n.js";
|
|
4
4
|
import "../../core/context.js";
|
|
5
|
+
import "../../i18n/util.js";
|
|
6
|
+
import "../../i18n/locales/index.js";
|
|
5
7
|
import "../internal/Form/context.js";
|
|
6
8
|
import { FormItem } from "../internal/Form/FormItem.js";
|
|
7
9
|
import "../internal/Form/Form.js";
|
|
@@ -5,6 +5,8 @@ import "../../utils/system-info/get-browser-info.js";
|
|
|
5
5
|
import { limitedToNumber } from "../../utils/format.js";
|
|
6
6
|
import { useI18n } from "../../hooks/useI18n.js";
|
|
7
7
|
import "../../core/context.js";
|
|
8
|
+
import "../../i18n/util.js";
|
|
9
|
+
import "../../i18n/locales/index.js";
|
|
8
10
|
import "../internal/Form/context.js";
|
|
9
11
|
import { FormItem } from "../internal/Form/FormItem.js";
|
|
10
12
|
import "../internal/Form/Form.js";
|
|
@@ -4,6 +4,8 @@ import { useI18n } from "../../hooks/useI18n.js";
|
|
|
4
4
|
import "../../core/context.js";
|
|
5
5
|
import { finCardBrandInfoByCode } from "../../utils/card-brand/index.js";
|
|
6
6
|
import "../../utils/system-info/get-browser-info.js";
|
|
7
|
+
import "../../i18n/util.js";
|
|
8
|
+
import "../../i18n/locales/index.js";
|
|
7
9
|
import "../internal/Form/context.js";
|
|
8
10
|
import { FormItem } from "../internal/Form/FormItem.js";
|
|
9
11
|
import "../internal/Form/Form.js";
|
|
@@ -10,6 +10,8 @@ import "../../utils/card-brand/brands.js";
|
|
|
10
10
|
import "../../utils/system-info/get-browser-info.js";
|
|
11
11
|
import { useI18n } from "../../hooks/useI18n.js";
|
|
12
12
|
import "../../core/context.js";
|
|
13
|
+
import "../../i18n/util.js";
|
|
14
|
+
import "../../i18n/locales/index.js";
|
|
13
15
|
import "../internal/Form/context.js";
|
|
14
16
|
import { FormItem } from "../internal/Form/FormItem.js";
|
|
15
17
|
import "../internal/Form/Form.js";
|
|
@@ -2,9 +2,9 @@ import { u } from "../../core.js";
|
|
|
2
2
|
import { CoreContext } from "../../core/context.js";
|
|
3
3
|
import "../../utils/card-brand/brands.js";
|
|
4
4
|
import "../../utils/system-info/get-browser-info.js";
|
|
5
|
-
import { useBEM } from "../../hooks/useBEM.js";
|
|
6
5
|
import "../../i18n/util.js";
|
|
7
6
|
import "../../i18n/locales/index.js";
|
|
7
|
+
import { useBEM } from "../../hooks/useBEM.js";
|
|
8
8
|
import { IconInfo } from "../internal/icons/IconInfo.js";
|
|
9
9
|
const { bem } = useBEM("recurring-tip");
|
|
10
10
|
function RecurringTip() {
|
|
@@ -112,7 +112,6 @@ const SecuredFieldsProvider = w((props, ref) => {
|
|
|
112
112
|
return;
|
|
113
113
|
}
|
|
114
114
|
window.removeEventListener("message", onReceiveMessage);
|
|
115
|
-
console.log(hiddenIframe.current);
|
|
116
115
|
if (hiddenIframe.current) {
|
|
117
116
|
document.body.removeChild(hiddenIframe.current);
|
|
118
117
|
}
|
|
@@ -5,9 +5,9 @@ import "../../../core/context.js";
|
|
|
5
5
|
import "../../../utils/card-brand/brands.js";
|
|
6
6
|
import "../../../utils/system-info/get-browser-info.js";
|
|
7
7
|
import { normalizedClass } from "../../../utils/format.js";
|
|
8
|
-
import { COMMON_CLASS_NAME } from "../../../constant.js";
|
|
9
8
|
import "../../../i18n/util.js";
|
|
10
9
|
import "../../../i18n/locales/index.js";
|
|
10
|
+
import { COMMON_CLASS_NAME } from "../../../constant.js";
|
|
11
11
|
import { IconChecked } from "../icons/iconChecked.js";
|
|
12
12
|
const { bem } = useBEM("check-box");
|
|
13
13
|
const CheckBox = (props) => {
|
package/dist/es/config.js
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
+
import "./utils/card-brand/brands.js";
|
|
2
|
+
import "./utils/system-info/get-browser-info.js";
|
|
3
|
+
import "./i18n/util.js";
|
|
4
|
+
import "./core.js";
|
|
5
|
+
import "./i18n/locales/index.js";
|
|
1
6
|
let apiUrl = "https://checkout.aq.paykka.com";
|
|
2
7
|
let cdnOrigin = "https://checkout.aq.paykka.com";
|
|
3
8
|
let cdnDir = "/cp";
|
|
4
9
|
let cdnUrl = `${cdnOrigin}${cdnDir}`;
|
|
5
10
|
let radarEnv = void 0;
|
|
6
11
|
let customReqHeaders = {};
|
|
12
|
+
let customLocale = void 0;
|
|
7
13
|
function setApiUrl(url) {
|
|
8
14
|
apiUrl = url;
|
|
9
15
|
}
|
|
@@ -19,14 +25,19 @@ function setRadarEnv(env) {
|
|
|
19
25
|
function setCustomReqHeaders(headers) {
|
|
20
26
|
customReqHeaders = headers;
|
|
21
27
|
}
|
|
28
|
+
function setCustomLocale(locale) {
|
|
29
|
+
customLocale = locale;
|
|
30
|
+
}
|
|
22
31
|
export {
|
|
23
32
|
apiUrl,
|
|
24
33
|
cdnOrigin,
|
|
25
34
|
cdnUrl,
|
|
35
|
+
customLocale,
|
|
26
36
|
customReqHeaders,
|
|
27
37
|
radarEnv,
|
|
28
38
|
setApiUrl,
|
|
29
39
|
setCDNUrl,
|
|
40
|
+
setCustomLocale,
|
|
30
41
|
setCustomReqHeaders,
|
|
31
42
|
setRadarEnv
|
|
32
43
|
};
|
package/dist/es/core/Session.js
CHANGED
|
@@ -26,6 +26,9 @@ import "../utils/card-brand/brands.js";
|
|
|
26
26
|
import "../utils/system-info/get-browser-info.js";
|
|
27
27
|
import { generateColors } from "../utils/colors.js";
|
|
28
28
|
import { createPromise } from "../utils/create-promise.js";
|
|
29
|
+
import "../i18n/util.js";
|
|
30
|
+
import "../core.js";
|
|
31
|
+
import "../i18n/locales/index.js";
|
|
29
32
|
import { querySession } from "./query.js";
|
|
30
33
|
class Session {
|
|
31
34
|
constructor(sessionId, clientKey) {
|
package/dist/es/core/index.js
CHANGED
package/dist/es/core/query.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import "../utils/card-brand/brands.js";
|
|
2
2
|
import "../utils/system-info/get-browser-info.js";
|
|
3
|
+
import "../i18n/util.js";
|
|
4
|
+
import "../core.js";
|
|
5
|
+
import "../i18n/locales/index.js";
|
|
3
6
|
import { onceGetCheckoutInfo } from "../api/modules/checkout/index.js";
|
|
4
7
|
async function querySession({ sessionId, clientKey }, options) {
|
|
5
8
|
try {
|
package/dist/es/core.js
CHANGED
|
@@ -3854,36 +3854,6 @@ function isValidCSSUnit(color) {
|
|
|
3854
3854
|
}
|
|
3855
3855
|
return matchers.CSS_UNIT.test(color);
|
|
3856
3856
|
}
|
|
3857
|
-
function e$1(e2, n2) {
|
|
3858
|
-
return n2 = n2 || {}, new Promise(function(t2, r2) {
|
|
3859
|
-
var s2 = new XMLHttpRequest(), o2 = [], u2 = {}, a2 = function e3() {
|
|
3860
|
-
return { ok: 2 == (s2.status / 100 | 0), statusText: s2.statusText, status: s2.status, url: s2.responseURL, text: function() {
|
|
3861
|
-
return Promise.resolve(s2.responseText);
|
|
3862
|
-
}, json: function() {
|
|
3863
|
-
return Promise.resolve(s2.responseText).then(JSON.parse);
|
|
3864
|
-
}, blob: function() {
|
|
3865
|
-
return Promise.resolve(new Blob([s2.response]));
|
|
3866
|
-
}, clone: e3, headers: { keys: function() {
|
|
3867
|
-
return o2;
|
|
3868
|
-
}, entries: function() {
|
|
3869
|
-
return o2.map(function(e4) {
|
|
3870
|
-
return [e4, s2.getResponseHeader(e4)];
|
|
3871
|
-
});
|
|
3872
|
-
}, get: function(e4) {
|
|
3873
|
-
return s2.getResponseHeader(e4);
|
|
3874
|
-
}, has: function(e4) {
|
|
3875
|
-
return null != s2.getResponseHeader(e4);
|
|
3876
|
-
} } };
|
|
3877
|
-
};
|
|
3878
|
-
for (var i2 in s2.open(n2.method || "get", e2, true), s2.onload = function() {
|
|
3879
|
-
s2.getAllResponseHeaders().toLowerCase().replace(/^(.+?):/gm, function(e3, n3) {
|
|
3880
|
-
u2[n3] || o2.push(u2[n3] = n3);
|
|
3881
|
-
}), t2(a2());
|
|
3882
|
-
}, s2.onerror = r2, s2.withCredentials = "include" == n2.credentials, n2.headers)
|
|
3883
|
-
s2.setRequestHeader(i2, n2.headers[i2]);
|
|
3884
|
-
s2.send(n2.body || null);
|
|
3885
|
-
});
|
|
3886
|
-
}
|
|
3887
3857
|
var i = Symbol.for("preact-signals");
|
|
3888
3858
|
function t() {
|
|
3889
3859
|
if (!(s$1 > 1)) {
|
|
@@ -3917,7 +3887,7 @@ function t() {
|
|
|
3917
3887
|
}
|
|
3918
3888
|
var o = void 0;
|
|
3919
3889
|
var h = void 0, s$1 = 0, f = 0, v = 0;
|
|
3920
|
-
function e(i2) {
|
|
3890
|
+
function e$1(i2) {
|
|
3921
3891
|
if (void 0 !== o) {
|
|
3922
3892
|
var t2 = i2.n;
|
|
3923
3893
|
if (void 0 === t2 || t2.t !== o) {
|
|
@@ -4008,7 +3978,7 @@ u.prototype.peek = function() {
|
|
|
4008
3978
|
}
|
|
4009
3979
|
};
|
|
4010
3980
|
Object.defineProperty(u.prototype, "value", { get: function() {
|
|
4011
|
-
var i2 = e(this);
|
|
3981
|
+
var i2 = e$1(this);
|
|
4012
3982
|
if (void 0 !== i2)
|
|
4013
3983
|
i2.i = this.i;
|
|
4014
3984
|
return this.v;
|
|
@@ -4139,7 +4109,7 @@ y.prototype.N = function() {
|
|
|
4139
4109
|
Object.defineProperty(y.prototype, "value", { get: function() {
|
|
4140
4110
|
if (1 & this.f)
|
|
4141
4111
|
throw new Error("Cycle detected");
|
|
4142
|
-
var i2 = e(this);
|
|
4112
|
+
var i2 = e$1(this);
|
|
4143
4113
|
this.h();
|
|
4144
4114
|
if (void 0 !== i2)
|
|
4145
4115
|
i2.i = this.i;
|
|
@@ -4422,6 +4392,36 @@ function useSignal(n2) {
|
|
|
4422
4392
|
return d$1(n2);
|
|
4423
4393
|
}, []);
|
|
4424
4394
|
}
|
|
4395
|
+
function e(e2, n2) {
|
|
4396
|
+
return n2 = n2 || {}, new Promise(function(t2, r2) {
|
|
4397
|
+
var s2 = new XMLHttpRequest(), o2 = [], u2 = {}, a2 = function e3() {
|
|
4398
|
+
return { ok: 2 == (s2.status / 100 | 0), statusText: s2.statusText, status: s2.status, url: s2.responseURL, text: function() {
|
|
4399
|
+
return Promise.resolve(s2.responseText);
|
|
4400
|
+
}, json: function() {
|
|
4401
|
+
return Promise.resolve(s2.responseText).then(JSON.parse);
|
|
4402
|
+
}, blob: function() {
|
|
4403
|
+
return Promise.resolve(new Blob([s2.response]));
|
|
4404
|
+
}, clone: e3, headers: { keys: function() {
|
|
4405
|
+
return o2;
|
|
4406
|
+
}, entries: function() {
|
|
4407
|
+
return o2.map(function(e4) {
|
|
4408
|
+
return [e4, s2.getResponseHeader(e4)];
|
|
4409
|
+
});
|
|
4410
|
+
}, get: function(e4) {
|
|
4411
|
+
return s2.getResponseHeader(e4);
|
|
4412
|
+
}, has: function(e4) {
|
|
4413
|
+
return null != s2.getResponseHeader(e4);
|
|
4414
|
+
} } };
|
|
4415
|
+
};
|
|
4416
|
+
for (var i2 in s2.open(n2.method || "get", e2, true), s2.onload = function() {
|
|
4417
|
+
s2.getAllResponseHeaders().toLowerCase().replace(/^(.+?):/gm, function(e3, n3) {
|
|
4418
|
+
u2[n3] || o2.push(u2[n3] = n3);
|
|
4419
|
+
}), t2(a2());
|
|
4420
|
+
}, s2.onerror = r2, s2.withCredentials = "include" == n2.credentials, n2.headers)
|
|
4421
|
+
s2.setRequestHeader(i2, n2.headers[i2]);
|
|
4422
|
+
s2.send(n2.body || null);
|
|
4423
|
+
});
|
|
4424
|
+
}
|
|
4425
4425
|
export {
|
|
4426
4426
|
A$1 as A,
|
|
4427
4427
|
B$2 as B,
|
|
@@ -4431,7 +4431,7 @@ export {
|
|
|
4431
4431
|
_$3 as _,
|
|
4432
4432
|
b$1 as b,
|
|
4433
4433
|
d$1 as d,
|
|
4434
|
-
e
|
|
4434
|
+
e,
|
|
4435
4435
|
h$1 as h,
|
|
4436
4436
|
index,
|
|
4437
4437
|
inputToRGB,
|
package/dist/es/hooks/useI18n.js
CHANGED
|
@@ -6,7 +6,7 @@ import { I18n } from "../i18n/I18n.js";
|
|
|
6
6
|
import "../i18n/locales/index.js";
|
|
7
7
|
function useI18n(locale) {
|
|
8
8
|
const coreContext = x(CoreContext);
|
|
9
|
-
const [_i18n] = h((coreContext == null ? void 0 : coreContext.i18n) ?? new I18n(
|
|
9
|
+
const [_i18n] = h((coreContext == null ? void 0 : coreContext.i18n) ?? new I18n());
|
|
10
10
|
locale && _i18n.load(locale);
|
|
11
11
|
return { i18n: _i18n };
|
|
12
12
|
}
|
|
@@ -3,7 +3,7 @@ import "../core/context.js";
|
|
|
3
3
|
import "../utils/card-brand/brands.js";
|
|
4
4
|
import "../utils/system-info/get-browser-info.js";
|
|
5
5
|
import { Session } from "../core/Session.js";
|
|
6
|
-
import { radarEnv } from "../config.js";
|
|
6
|
+
import { customLocale, radarEnv } from "../config.js";
|
|
7
7
|
import { getPayKKaRadarInstance } from "../out/radar.js";
|
|
8
8
|
import { useI18n } from "./useI18n.js";
|
|
9
9
|
let _session;
|
|
@@ -22,21 +22,17 @@ function usePayState(props) {
|
|
|
22
22
|
setSession(_session);
|
|
23
23
|
_session.ready().then(() => setSessionReady(true)).catch(() => setSessionReady(false));
|
|
24
24
|
}, [props.sessionId]);
|
|
25
|
-
const { i18n } = useI18n(
|
|
25
|
+
const { i18n } = useI18n(customLocale);
|
|
26
26
|
y(() => {
|
|
27
|
-
if (props.i18n) {
|
|
28
|
-
i18n.load(props.i18n);
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
27
|
if (session) {
|
|
32
28
|
session.ready().then(() => {
|
|
33
|
-
i18n.load(session.checkout.locale);
|
|
29
|
+
i18n.load(session.checkout.locale || customLocale);
|
|
34
30
|
const payKKaRadar2 = getPayKKaRadarInstance(radarEnv);
|
|
35
31
|
setPayKKaRadar(payKKaRadar2);
|
|
36
32
|
payKKaRadar2 == null ? void 0 : payKKaRadar2.createPayKKaRadar();
|
|
37
33
|
});
|
|
38
34
|
}
|
|
39
|
-
}, [
|
|
35
|
+
}, [session]);
|
|
40
36
|
return {
|
|
41
37
|
validated,
|
|
42
38
|
setValidated,
|
package/dist/es/i18n/I18n.js
CHANGED
|
@@ -9,17 +9,16 @@ import { getBrowserInfo } from "../utils/system-info/get-browser-info.js";
|
|
|
9
9
|
import { loadTranslation } from "./util.js";
|
|
10
10
|
import { d } from "../core.js";
|
|
11
11
|
const _I18n = class _I18n {
|
|
12
|
-
constructor(
|
|
12
|
+
constructor() {
|
|
13
13
|
/** 语言 */
|
|
14
14
|
__publicField(this, "locale");
|
|
15
15
|
/** 翻译文案 */
|
|
16
16
|
__publicField(this, "translation");
|
|
17
17
|
/** 加载文案完成标识 */
|
|
18
|
-
__publicField(this, "
|
|
18
|
+
__publicField(this, "isReady", d(false));
|
|
19
19
|
/** 当前正在加载的id标识 */
|
|
20
20
|
__publicField(this, "currentLoadId", 0);
|
|
21
21
|
if (!_I18n.instance) {
|
|
22
|
-
this.load(locale);
|
|
23
22
|
_I18n.instance = this;
|
|
24
23
|
}
|
|
25
24
|
return _I18n.instance;
|
|
@@ -28,6 +27,9 @@ const _I18n = class _I18n {
|
|
|
28
27
|
var _a;
|
|
29
28
|
return ((_a = this.translation) == null ? void 0 : _a[key]) ?? "";
|
|
30
29
|
}
|
|
30
|
+
get ready() {
|
|
31
|
+
return this.isReady;
|
|
32
|
+
}
|
|
31
33
|
/** 加载国际化翻译文案 */
|
|
32
34
|
load(locale = getBrowserInfo().language) {
|
|
33
35
|
if (locale === this.locale) {
|
|
@@ -35,15 +37,16 @@ const _I18n = class _I18n {
|
|
|
35
37
|
}
|
|
36
38
|
this.locale = locale;
|
|
37
39
|
const loadId = ++this.currentLoadId;
|
|
38
|
-
this.
|
|
40
|
+
this.isReady.value = false;
|
|
39
41
|
loadTranslation(this.locale).then((res) => {
|
|
42
|
+
if (loadId !== this.currentLoadId) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
this.isReady.value = true;
|
|
40
46
|
this.locale = res.locale;
|
|
41
47
|
this.translation = res.translation;
|
|
42
|
-
if (loadId === this.currentLoadId) {
|
|
43
|
-
this.ready.value = true;
|
|
44
|
-
}
|
|
45
48
|
}).catch(() => {
|
|
46
|
-
this.
|
|
49
|
+
this.isReady.value = false;
|
|
47
50
|
});
|
|
48
51
|
}
|
|
49
52
|
};
|
package/dist/es/index.js
CHANGED
|
@@ -20,8 +20,8 @@ import { create } from "./core/create.js";
|
|
|
20
20
|
import { Session } from "./core/Session.js";
|
|
21
21
|
import { querySession } from "./core/query.js";
|
|
22
22
|
import { I18n } from "./i18n/I18n.js";
|
|
23
|
-
import "./i18n/locales/index.js";
|
|
24
|
-
import { setApiUrl, setCDNUrl, setCustomReqHeaders, setRadarEnv } from "./config.js";
|
|
23
|
+
import { LocaleKey } from "./i18n/locales/index.js";
|
|
24
|
+
import { setApiUrl, setCDNUrl, setCustomLocale, setCustomReqHeaders, setRadarEnv } from "./config.js";
|
|
25
25
|
import "./utils/card-brand/brands.js";
|
|
26
26
|
import { getFingerprint } from "./utils/system-info/finger-print.js";
|
|
27
27
|
import "./utils/system-info/get-browser-info.js";
|
|
@@ -39,6 +39,7 @@ export {
|
|
|
39
39
|
GooglePay,
|
|
40
40
|
I18n,
|
|
41
41
|
IBANField,
|
|
42
|
+
LocaleKey,
|
|
42
43
|
SecuredIframe,
|
|
43
44
|
Sepa,
|
|
44
45
|
Session,
|
|
@@ -49,6 +50,7 @@ export {
|
|
|
49
50
|
querySession,
|
|
50
51
|
setApiUrl,
|
|
51
52
|
setCDNUrl,
|
|
53
|
+
setCustomLocale,
|
|
52
54
|
setCustomReqHeaders,
|
|
53
55
|
setRadarEnv
|
|
54
56
|
};
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import type { PayRes } from '../../api';
|
|
2
|
-
import type { LocaleKey } from '../../i18n';
|
|
3
2
|
import type { FormValidateError } from '../internal/Form';
|
|
4
3
|
export interface AliPayProps {
|
|
5
4
|
sessionId: string;
|
|
6
5
|
clientKey?: string;
|
|
7
|
-
i18n?: LocaleKey;
|
|
8
6
|
onSubmit?: (formValidateError?: Recordable<FormValidateError[]>) => void;
|
|
9
7
|
onSuccess?: (...args: any[]) => void;
|
|
10
8
|
onError?: (error: any) => void;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import type { PayRes } from '../../api';
|
|
2
|
-
import type { LocaleKey } from '../../i18n';
|
|
3
2
|
export interface ApplePayProps {
|
|
4
3
|
sessionId: string;
|
|
5
4
|
clientKey?: string;
|
|
6
|
-
i18n?: LocaleKey;
|
|
7
5
|
onSubmit?: () => void;
|
|
8
6
|
onSuccess?: (...args: any[]) => void;
|
|
9
7
|
onError?: (error: any) => void;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import type { LocaleKey } from '../../i18n';
|
|
2
1
|
import type { FormValidateError } from '../internal/Form';
|
|
3
2
|
export interface CardProps {
|
|
4
3
|
sessionId: string;
|
|
5
4
|
clientKey?: string;
|
|
6
|
-
i18n?: LocaleKey;
|
|
7
5
|
showCardBrands?: boolean;
|
|
8
6
|
onSubmit?: (formValidateError?: Recordable<FormValidateError[]>) => void;
|
|
9
7
|
onSuccess?: (returnUrl?: string) => void;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import type { PayRes } from '../../api';
|
|
2
|
-
import type { LocaleKey } from '../../i18n';
|
|
3
2
|
export interface GooglePayProps {
|
|
4
3
|
sessionId: string;
|
|
5
4
|
clientKey?: string;
|
|
6
|
-
i18n?: LocaleKey;
|
|
7
5
|
onSubmit?: () => void;
|
|
8
6
|
onSuccess?: (...args: any[]) => void;
|
|
9
7
|
onError?: (error: any) => void;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import type { LocaleKey } from '../../i18n';
|
|
2
1
|
import type { FormValidateError } from '../internal/Form';
|
|
3
2
|
export interface SepaProps {
|
|
4
3
|
sessionId: string;
|
|
5
4
|
clientKey?: string;
|
|
6
|
-
i18n?: LocaleKey;
|
|
7
5
|
onSubmit?: (formValidateError?: Recordable<FormValidateError[]>) => void;
|
|
8
6
|
onSuccess?: (returnUrl?: string) => void;
|
|
9
7
|
onError?: (error: any) => void;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import type { PayRes } from '../../api';
|
|
2
|
-
import type { LocaleKey } from '../../i18n';
|
|
3
2
|
import type { FormValidateError } from '../internal/Form';
|
|
4
3
|
export interface WechatPayProps {
|
|
5
4
|
sessionId: string;
|
|
6
5
|
clientKey?: string;
|
|
7
|
-
i18n?: LocaleKey;
|
|
8
6
|
onSubmit?: (formValidateError?: Recordable<FormValidateError[]>) => void;
|
|
9
7
|
onSuccess?: (...args: any[]) => void;
|
|
10
8
|
onError?: (error: any) => void;
|
package/dist/types/config.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type LocaleKeyType } from "./i18n";
|
|
1
2
|
import { type RadarEnv } from "./types";
|
|
2
3
|
export declare let apiUrl: string;
|
|
3
4
|
export declare let cdnOrigin: any;
|
|
@@ -5,7 +6,9 @@ export declare let cdnDir: any;
|
|
|
5
6
|
export declare let cdnUrl: string;
|
|
6
7
|
export declare let radarEnv: RadarEnv | undefined;
|
|
7
8
|
export declare let customReqHeaders: Recordable;
|
|
9
|
+
export declare let customLocale: LocaleKeyType | undefined;
|
|
8
10
|
export declare function setApiUrl(url: string): void;
|
|
9
11
|
export declare function setCDNUrl(url: string): void;
|
|
10
12
|
export declare function setRadarEnv(env: RadarEnv): void;
|
|
11
13
|
export declare function setCustomReqHeaders(headers: Recordable): void;
|
|
14
|
+
export declare function setCustomLocale(locale: LocaleKeyType): void;
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LocaleKeyType, Translation } from './locales';
|
|
2
2
|
import { Signal } from '@preact/signals';
|
|
3
3
|
export declare class I18n {
|
|
4
4
|
/** 语言 */
|
|
5
|
-
locale:
|
|
5
|
+
locale: LocaleKeyType;
|
|
6
6
|
/** 翻译文案 */
|
|
7
7
|
translation?: Translation;
|
|
8
8
|
/** 加载文案完成标识 */
|
|
9
|
-
|
|
9
|
+
private isReady;
|
|
10
10
|
/** 当前正在加载的id标识 */
|
|
11
11
|
private currentLoadId;
|
|
12
12
|
private static instance;
|
|
13
|
-
constructor(
|
|
13
|
+
constructor();
|
|
14
14
|
get(key: keyof Translation): string;
|
|
15
|
+
get ready(): Signal<boolean>;
|
|
15
16
|
/** 加载国际化翻译文案 */
|
|
16
|
-
load(locale?:
|
|
17
|
+
load(locale?: LocaleKeyType): void;
|
|
17
18
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * from './components';
|
|
2
2
|
export { type ComponentInst, create, querySession, Session } from './core';
|
|
3
|
-
export { I18n } from './i18n';
|
|
4
|
-
export { setApiUrl, setCDNUrl, setRadarEnv, setCustomReqHeaders } from './config';
|
|
3
|
+
export { I18n, LocaleKey } from './i18n';
|
|
4
|
+
export { setApiUrl, setCDNUrl, setRadarEnv, setCustomReqHeaders, setCustomLocale } from './config';
|
|
5
5
|
export { getFingerprint } from './utils';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export declare const normalizedStyle: <T extends string | Recordable<any
|
|
2
|
-
export declare const normalizedClass: <T extends string | Recordable<any
|
|
1
|
+
export declare const normalizedStyle: <T extends string | Nil | Recordable<any>>(...args: MaybeArray<T>[]) => string;
|
|
2
|
+
export declare const normalizedClass: <T extends string | Nil | Recordable<any>>(...args: MaybeArray<T>[]) => string;
|
|
3
3
|
export declare function limitedToNumber(val: string, whitelist?: string[]): string;
|
|
4
4
|
export declare function trimAll(str: string): string;
|
|
5
5
|
export declare function toFixed(num: number, digits?: number): string;
|