@txgw/payout-components 0.2.0 → 0.2.2

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/index.d.ts CHANGED
@@ -4,12 +4,14 @@ import { Emitter } from 'mitt';
4
4
  import { EventType } from 'mitt';
5
5
  import { Handler } from 'mitt';
6
6
  import { JSX as JSX_2 } from 'react/jsx-runtime';
7
+ import { Mi18nInstance } from '@mi18n/react';
7
8
  import { WildcardHandler } from 'mitt';
8
9
 
9
10
  declare const BANK_DETAILS_FORM_KEY = "bankDetails";
10
11
 
11
12
  declare interface BaseProps<T extends keyof typeof ElementsMap> extends InitOptions {
12
13
  emitter: Emitter<Events<T>>;
14
+ mi18n: Mi18nInstance;
13
15
  }
14
16
 
15
17
  declare function BeneficiaryForm(props: Props): JSX_2.Element;
@@ -85,7 +87,7 @@ declare interface LayoutSection {
85
87
  hidden?: boolean;
86
88
  }
87
89
 
88
- declare type Locale = "en" | "zh-Hant" | "ar" | "ja" | "th" | "tr" | "zh";
90
+ declare type Locale = "en";
89
91
 
90
92
  declare type PayoutType = "B2P";
91
93
 
@@ -100,7 +102,8 @@ declare class SDKComponent<T extends keyof typeof ElementsMap> {
100
102
  private mounted;
101
103
  private root;
102
104
  private emitter;
103
- constructor(loader: (typeof ElementsMap)[T], options: InitOptions);
105
+ private mi18n;
106
+ constructor(loader: (typeof ElementsMap)[T], options: InitOptions, mi18n: Mi18nInstance);
104
107
  mount(container: Element): Promise<void>;
105
108
  unmount(): void;
106
109
  on(type: keyof Events<T>, handler: Handler<EventsData<T>>): void;
package/dist/index.js CHANGED
@@ -1,66 +1,89 @@
1
- import { c4 as a } from "./vendor-fKhExfo_.js";
2
- class c {
1
+ import { b_ as m, b$ as u, c0 as c, c1 as h, c2 as l, c3 as f, c4 as p } from "./vendor-D9Vb1NW1.js";
2
+ class d {
3
3
  loader;
4
4
  options;
5
5
  mounted = !1;
6
6
  root;
7
7
  emitter;
8
- constructor(t, o) {
9
- this.loader = t, this.options = o, this.emitter = a(), this.root = null;
8
+ mi18n;
9
+ constructor(t, n, e) {
10
+ this.loader = t, this.options = n, this.emitter = m(), this.mi18n = e, this.root = null;
10
11
  }
11
12
  async mount(t) {
12
13
  if (this.mounted) return;
13
- const o = await this.loader(), e = o.default ?? o, m = await import("./vendor-fKhExfo_.js").then((i) => i.R), s = (await import("./vendor-fKhExfo_.js").then((i) => i.c)).createRoot(t);
14
- s.render(
15
- m.createElement(e, {
14
+ const n = await this.loader(), e = n.default ?? n, a = await import("./vendor-D9Vb1NW1.js").then((i) => i.R), r = (await import("./vendor-D9Vb1NW1.js").then((i) => i.c)).createRoot(t);
15
+ r.render(
16
+ a.createElement(e, {
16
17
  ...this.options,
17
- emitter: this.emitter
18
+ emitter: this.emitter,
19
+ mi18n: this.mi18n
18
20
  })
19
- ), this.root = s, this.mounted = !0;
21
+ ), this.root = r, this.mounted = !0;
20
22
  }
21
23
  unmount() {
22
24
  this.root && (this.root.unmount(), this.root = null), this.mounted = !1;
23
25
  }
24
- on(t, o) {
25
- return t === "*" ? this.emitter.on(t, o) : this.emitter.on(t, o);
26
+ on(t, n) {
27
+ return t === "*" ? this.emitter.on(t, n) : this.emitter.on(t, n);
26
28
  }
27
- off(t, o) {
28
- return t === "*" ? this.emitter.off(t, o) : this.emitter.off(t, o);
29
+ off(t, n) {
30
+ return t === "*" ? this.emitter.off(t, n) : this.emitter.off(t, n);
29
31
  }
30
32
  isMounted() {
31
33
  return this.mounted;
32
34
  }
33
35
  }
34
- const u = {
35
- beneficiaryForm: () => import("./component-beneficiary-form-ZOQLPYQM.js")
36
+ const g = {
37
+ beneficiaryForm: () => import("./component-beneficiary-form-CvWbQOoI.js")
38
+ }, w = {
39
+ staticData: {
40
+ en: () => import("./en-Cb5xUNU4.js")
41
+ }
36
42
  };
37
- class h {
43
+ function D(o) {
44
+ return u().use(c()).use(h()).use(l()).use(f()).init({
45
+ language: p() || o,
46
+ defaultLanguage: o,
47
+ fallbackLanguage: "en",
48
+ // availableLanguages: ["en", "zh-Hant", "ar", "ja", "th", "tr", "zh"],
49
+ availableLanguages: ["en"],
50
+ // 一期只支持英文
51
+ ...w,
52
+ projectId: 181
53
+ });
54
+ }
55
+ class E {
38
56
  options;
57
+ mi18n;
39
58
  components = {};
40
59
  constructor(t) {
41
- this.options = t;
60
+ this.options = t, this.mi18n = D(this.options?.locale || "en");
42
61
  }
43
- createElement(t, o) {
62
+ createElement(t, n) {
44
63
  if (!this.options)
45
64
  throw new Error("[payout-sdk] options are not initialized");
46
- const e = u[t];
65
+ const e = g[t];
47
66
  if (!e)
48
67
  throw new Error(`[payout-sdk] component ${t} not found`);
49
- return this.components[t] ? this.components[t] : (this.components[t] = new c(e, {
50
- ...this.options,
51
- ...o
52
- }), this.components[t]);
68
+ return this.components[t] ? this.components[t] : (this.components[t] = new d(
69
+ e,
70
+ {
71
+ ...this.options,
72
+ ...n
73
+ },
74
+ this.mi18n
75
+ ), this.components[t]);
53
76
  }
54
77
  }
55
- let r = null;
56
- function d(n) {
57
- r = new h(n);
78
+ let s = null;
79
+ function S(o) {
80
+ s = new E(o);
58
81
  }
59
- function p(n, t) {
60
- if (!r) throw new Error("[payout-sdk] SDK is not initialized");
61
- return r.createElement(n, t);
82
+ function L(o, t) {
83
+ if (!s) throw new Error("[payout-sdk] SDK is not initialized");
84
+ return s.createElement(o, t);
62
85
  }
63
86
  export {
64
- p as createElement,
65
- d as init
87
+ L as createElement,
88
+ S as init
66
89
  };