@pisell/utils 1.0.68 → 1.0.71

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 (130) hide show
  1. package/README.md +2 -2
  2. package/es/arrayUtils.d.ts +1 -1
  3. package/es/common/index.d.ts +5 -5
  4. package/es/common/index.js +2 -2
  5. package/es/common/stateHelper.d.ts +18 -18
  6. package/es/common/stateHelper.js +15 -15
  7. package/es/common/types.d.ts +28 -28
  8. package/es/componentStorage.d.ts +36 -36
  9. package/es/componentStorage.js +7 -7
  10. package/es/constants/index.d.ts +7 -7
  11. package/es/date.d.ts +28 -28
  12. package/es/date.js +22 -22
  13. package/es/document.d.ts +13 -13
  14. package/es/document.js +7 -7
  15. package/es/escPosPrinter/index.d.ts +9 -9
  16. package/es/firebase/config/index.d.ts +13 -13
  17. package/es/firebase/index.d.ts +28 -28
  18. package/es/format.d.ts +28 -28
  19. package/es/format.js +14 -14
  20. package/es/image.d.ts +11 -11
  21. package/es/image.js +5 -5
  22. package/es/index.d.ts +25 -25
  23. package/es/jsBridge/index.d.ts +22 -22
  24. package/es/jsBridge/index.js +15 -15
  25. package/es/jsBridge/regDeviceApi.d.ts +15 -15
  26. package/es/jsBridge/regDeviceApi.js +3 -3
  27. package/es/jsBridge/types.d.ts +149 -149
  28. package/es/locales.d.ts +9 -9
  29. package/es/locales.js +40 -21
  30. package/es/log.d.ts +10 -10
  31. package/es/miniRedux.d.ts +16 -16
  32. package/es/number-input/hooks/index.d.ts +4 -4
  33. package/es/number-input/hooks/index.js +2 -2
  34. package/es/number-input/hooks/useNumberInputState.d.ts +25 -25
  35. package/es/number-input/hooks/useNumberInputState.js +39 -39
  36. package/es/number-input/index.d.ts +14 -14
  37. package/es/number-input/index.js +8 -8
  38. package/es/number-input/types.d.ts +96 -96
  39. package/es/number-input/utils/formatter.d.ts +53 -53
  40. package/es/number-input/utils/formatter.js +37 -37
  41. package/es/number-input/utils/index.d.ts +7 -7
  42. package/es/number-input/utils/index.js +2 -2
  43. package/es/number-input/utils/validation.d.ts +27 -27
  44. package/es/number-input/utils/validation.js +24 -24
  45. package/es/otherUtils.d.ts +48 -48
  46. package/es/otherUtils.js +32 -32
  47. package/es/platform.d.ts +9 -9
  48. package/es/select/hooks/index.d.ts +5 -5
  49. package/es/select/hooks/index.js +2 -2
  50. package/es/select/hooks/useDebouncedSearch.d.ts +20 -20
  51. package/es/select/hooks/useDebouncedSearch.js +17 -17
  52. package/es/select/hooks/useSelectState.d.ts +19 -19
  53. package/es/select/hooks/useSelectState.js +13 -13
  54. package/es/select/index.d.ts +8 -8
  55. package/es/select/index.js +3 -3
  56. package/es/select/types.d.ts +256 -256
  57. package/es/select/utils/filterOptions.d.ts +22 -22
  58. package/es/select/utils/filterOptions.js +16 -16
  59. package/es/select/utils/helpers.d.ts +42 -42
  60. package/es/select/utils/helpers.js +30 -30
  61. package/es/select/utils/index.d.ts +7 -7
  62. package/es/select/utils/index.js +2 -2
  63. package/es/select/utils/sortOptions.d.ts +12 -12
  64. package/es/select/utils/sortOptions.js +8 -8
  65. package/es/select/utils/tagAggregation.d.ts +25 -25
  66. package/es/select/utils/tagAggregation.js +21 -21
  67. package/es/text-input/hooks/index.d.ts +4 -4
  68. package/es/text-input/hooks/index.js +2 -2
  69. package/es/text-input/hooks/useTextInputState.d.ts +24 -24
  70. package/es/text-input/hooks/useTextInputState.js +38 -38
  71. package/es/text-input/index.d.ts +14 -14
  72. package/es/text-input/index.js +9 -9
  73. package/es/text-input/types.d.ts +56 -56
  74. package/es/text-input/utils/index.d.ts +5 -5
  75. package/es/text-input/utils/index.js +2 -2
  76. package/es/text-input/utils/validation.d.ts +23 -23
  77. package/es/text-input/utils/validation.js +20 -20
  78. package/es/typeUtils.d.ts +42 -42
  79. package/es/typeUtils.js +26 -26
  80. package/es/walletValidity.d.ts +44 -44
  81. package/es/walletValidity.js +85 -85
  82. package/lib/arrayUtils.d.ts +1 -1
  83. package/lib/common/index.d.ts +5 -5
  84. package/lib/common/stateHelper.d.ts +18 -18
  85. package/lib/common/types.d.ts +28 -28
  86. package/lib/componentStorage.d.ts +36 -36
  87. package/lib/constants/index.d.ts +7 -7
  88. package/lib/date.d.ts +28 -28
  89. package/lib/document.d.ts +13 -13
  90. package/lib/escPosPrinter/index.d.ts +9 -9
  91. package/lib/firebase/config/index.d.ts +13 -13
  92. package/lib/firebase/index.d.ts +28 -28
  93. package/lib/format.d.ts +28 -28
  94. package/lib/image.d.ts +11 -11
  95. package/lib/index.d.ts +25 -25
  96. package/lib/jsBridge/index.d.ts +22 -22
  97. package/lib/jsBridge/regDeviceApi.d.ts +15 -15
  98. package/lib/jsBridge/types.d.ts +149 -149
  99. package/lib/locales.d.ts +9 -9
  100. package/lib/locales.js +25 -6
  101. package/lib/log.d.ts +10 -10
  102. package/lib/miniRedux.d.ts +16 -16
  103. package/lib/number-input/hooks/index.d.ts +4 -4
  104. package/lib/number-input/hooks/useNumberInputState.d.ts +25 -25
  105. package/lib/number-input/index.d.ts +14 -14
  106. package/lib/number-input/types.d.ts +96 -96
  107. package/lib/number-input/utils/formatter.d.ts +53 -53
  108. package/lib/number-input/utils/index.d.ts +7 -7
  109. package/lib/number-input/utils/validation.d.ts +27 -27
  110. package/lib/otherUtils.d.ts +48 -48
  111. package/lib/platform.d.ts +9 -9
  112. package/lib/select/hooks/index.d.ts +5 -5
  113. package/lib/select/hooks/useDebouncedSearch.d.ts +20 -20
  114. package/lib/select/hooks/useSelectState.d.ts +19 -19
  115. package/lib/select/index.d.ts +8 -8
  116. package/lib/select/types.d.ts +256 -256
  117. package/lib/select/utils/filterOptions.d.ts +22 -22
  118. package/lib/select/utils/helpers.d.ts +42 -42
  119. package/lib/select/utils/index.d.ts +7 -7
  120. package/lib/select/utils/sortOptions.d.ts +12 -12
  121. package/lib/select/utils/tagAggregation.d.ts +25 -25
  122. package/lib/text-input/hooks/index.d.ts +4 -4
  123. package/lib/text-input/hooks/useTextInputState.d.ts +24 -24
  124. package/lib/text-input/index.d.ts +14 -14
  125. package/lib/text-input/types.d.ts +56 -56
  126. package/lib/text-input/utils/index.d.ts +5 -5
  127. package/lib/text-input/utils/validation.d.ts +23 -23
  128. package/lib/typeUtils.d.ts +42 -42
  129. package/lib/walletValidity.d.ts +44 -44
  130. package/package.json +1 -1
package/es/format.js CHANGED
@@ -1,14 +1,14 @@
1
1
  import { isString, isNumber } from "./typeUtils";
2
2
 
3
- /**
4
- * @title: 格式化金额
5
- * @description:
6
- * @param {number} amount 原金额
7
- * @param {number} precision 小数位数
8
- * @param {string} symbol 货币符号
9
- * @return {*}
10
- * @Author: zhiwei.Wang
11
- * @Date: 2023-11-06 16:51
3
+ /**
4
+ * @title: 格式化金额
5
+ * @description:
6
+ * @param {number} amount 原金额
7
+ * @param {number} precision 小数位数
8
+ * @param {string} symbol 货币符号
9
+ * @return {*}
10
+ * @Author: zhiwei.Wang
11
+ * @Date: 2023-11-06 16:51
12
12
  */
13
13
  export var formatAmount = function formatAmount() {
14
14
  var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
@@ -55,11 +55,11 @@ export var formatAmount = function formatAmount() {
55
55
  return amount;
56
56
  }
57
57
  };
58
- /**
59
- * 根据配置格式化金额
60
- * @param amount
61
- * @param symbol
62
- * @param options
58
+ /**
59
+ * 根据配置格式化金额
60
+ * @param amount
61
+ * @param symbol
62
+ * @param options
63
63
  */
64
64
  export var formatAmountWithOptions = function formatAmountWithOptions() {
65
65
  var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
package/es/image.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- export declare const image: {
2
- ali: (url: string, w: number) => string;
3
- getImageSize: (url: string) => {
4
- width: number;
5
- height: number;
6
- ratio: number;
7
- success: boolean;
8
- widthRatio: number;
9
- originRatio: number;
10
- };
11
- };
1
+ export declare const image: {
2
+ ali: (url: string, w: number) => string;
3
+ getImageSize: (url: string) => {
4
+ width: number;
5
+ height: number;
6
+ ratio: number;
7
+ success: boolean;
8
+ widthRatio: number;
9
+ originRatio: number;
10
+ };
11
+ };
package/es/image.js CHANGED
@@ -17,11 +17,11 @@ var ali = function ali(url, w) {
17
17
  return url;
18
18
  };
19
19
 
20
- /**
21
- * @Title: 获取图片尺寸
22
- * @Describe: 通过 __ 进行分割
23
- * @Author: Wzw
24
- * @param {string} url
20
+ /**
21
+ * @Title: 获取图片尺寸
22
+ * @Describe: 通过 __ 进行分割
23
+ * @Author: Wzw
24
+ * @param {string} url
25
25
  */
26
26
 
27
27
  var getImageSize = function getImageSize(url) {
package/es/index.d.ts CHANGED
@@ -1,25 +1,25 @@
1
- export * from './otherUtils';
2
- export * from './typeUtils';
3
- export * from './componentStorage';
4
- export * from './document';
5
- export * from './date';
6
- export * from './platform';
7
- export * from './log';
8
- export * from './format';
9
- export * from './escPosPrinter';
10
- export * from './miniRedux';
11
- export * from './jsBridge';
12
- export * from './image';
13
- export * from './locales';
14
- export * from './arrayUtils';
15
- export * from './walletValidity';
16
- export * from './common';
17
- export * from './text-input';
18
- export * from './number-input';
19
- export * from './select';
20
- export declare const setPisellUtilsConfig: (config: {
21
- [key: string]: any;
22
- }) => void;
23
- export declare const getPisellUtilsConfig: () => {
24
- [key: string]: any;
25
- };
1
+ export * from './otherUtils';
2
+ export * from './typeUtils';
3
+ export * from './componentStorage';
4
+ export * from './document';
5
+ export * from './date';
6
+ export * from './platform';
7
+ export * from './log';
8
+ export * from './format';
9
+ export * from './escPosPrinter';
10
+ export * from './miniRedux';
11
+ export * from './jsBridge';
12
+ export * from './image';
13
+ export * from './locales';
14
+ export * from './arrayUtils';
15
+ export * from './walletValidity';
16
+ export * from './common';
17
+ export * from './text-input';
18
+ export * from './number-input';
19
+ export * from './select';
20
+ export declare const setPisellUtilsConfig: (config: {
21
+ [key: string]: any;
22
+ }) => void;
23
+ export declare const getPisellUtilsConfig: () => {
24
+ [key: string]: any;
25
+ };
@@ -1,22 +1,22 @@
1
- import { WebPrintParams, DataManagerParams, WebPaymentParams } from './types';
2
- /**
3
- * webView页面中调用打印机打印
4
- * 此api暂时只支持native app平台下ios手机
5
- * @param params
6
- * @param callback
7
- */
8
- export declare function webPrint(params: WebPrintParams, callback: (...arg: any) => void, onError?: (error: any) => void): void;
9
- /**
10
- * webView页面中调用APP内的数据
11
- * 此api暂时只支持native app平台下ios手机
12
- * @param params
13
- * @param callback
14
- */
15
- export declare function dataManager(params: DataManagerParams, callback: (...arg: any) => void, onError: () => void): void;
16
- /**
17
- * webView页面中调用APP内的支付
18
- * 此api暂时只支持native app平台下ios
19
- * @param params
20
- * @param callback
21
- */
22
- export declare function webPayment(params: WebPaymentParams, callback: (...arg: any) => void, onError?: (error: any) => void): void;
1
+ import { WebPrintParams, DataManagerParams, WebPaymentParams } from './types';
2
+ /**
3
+ * webView页面中调用打印机打印
4
+ * 此api暂时只支持native app平台下ios手机
5
+ * @param params
6
+ * @param callback
7
+ */
8
+ export declare function webPrint(params: WebPrintParams, callback: (...arg: any) => void, onError?: (error: any) => void): void;
9
+ /**
10
+ * webView页面中调用APP内的数据
11
+ * 此api暂时只支持native app平台下ios手机
12
+ * @param params
13
+ * @param callback
14
+ */
15
+ export declare function dataManager(params: DataManagerParams, callback: (...arg: any) => void, onError: () => void): void;
16
+ /**
17
+ * webView页面中调用APP内的支付
18
+ * 此api暂时只支持native app平台下ios
19
+ * @param params
20
+ * @param callback
21
+ */
22
+ export declare function webPayment(params: WebPaymentParams, callback: (...arg: any) => void, onError?: (error: any) => void): void;
@@ -1,9 +1,9 @@
1
1
  import regDeviceApi from "./regDeviceApi";
2
- /**
3
- * webView页面中调用打印机打印
4
- * 此api暂时只支持native app平台下ios手机
5
- * @param params
6
- * @param callback
2
+ /**
3
+ * webView页面中调用打印机打印
4
+ * 此api暂时只支持native app平台下ios手机
5
+ * @param params
6
+ * @param callback
7
7
  */
8
8
  export function webPrint(params, _callback, onError) {
9
9
  regDeviceApi().then(function (jsBridge) {
@@ -20,11 +20,11 @@ export function webPrint(params, _callback, onError) {
20
20
  });
21
21
  }
22
22
 
23
- /**
24
- * webView页面中调用APP内的数据
25
- * 此api暂时只支持native app平台下ios手机
26
- * @param params
27
- * @param callback
23
+ /**
24
+ * webView页面中调用APP内的数据
25
+ * 此api暂时只支持native app平台下ios手机
26
+ * @param params
27
+ * @param callback
28
28
  */
29
29
  export function dataManager(params, _callback2, onError) {
30
30
  regDeviceApi().then(function (jsBridge) {
@@ -39,11 +39,11 @@ export function dataManager(params, _callback2, onError) {
39
39
  }).catch(onError);
40
40
  }
41
41
 
42
- /**
43
- * webView页面中调用APP内的支付
44
- * 此api暂时只支持native app平台下ios
45
- * @param params
46
- * @param callback
42
+ /**
43
+ * webView页面中调用APP内的支付
44
+ * 此api暂时只支持native app平台下ios
45
+ * @param params
46
+ * @param callback
47
47
  */
48
48
  export function webPayment(params, _callback3, onError) {
49
49
  regDeviceApi().then(function (jsBridge) {
@@ -1,15 +1,15 @@
1
- type ComposedJSBridge = {
2
- // eslint-disable-next-line camelcase
3
- callDeviceApi: (a: {
4
- apiName: string;
5
- callback: Functon;
6
- onError?: (e: any) => void;
7
- params?: any;
8
- key_events?: string[];
9
- }) => void;
10
- calledByDevice: (a: { apiName: string; callback: Functon }) => void;
11
- };
12
-
13
- const regDeviceApi: (isWebPrint?: boolean) => Promise<ComposedJSBridge>;
14
-
15
- export default regDeviceApi;
1
+ type ComposedJSBridge = {
2
+ // eslint-disable-next-line camelcase
3
+ callDeviceApi: (a: {
4
+ apiName: string;
5
+ callback: Functon;
6
+ onError?: (e: any) => void;
7
+ params?: any;
8
+ key_events?: string[];
9
+ }) => void;
10
+ calledByDevice: (a: { apiName: string; callback: Functon }) => void;
11
+ };
12
+
13
+ const regDeviceApi: (isWebPrint?: boolean) => Promise<ComposedJSBridge>;
14
+
15
+ export default regDeviceApi;
@@ -51,9 +51,9 @@ function checkApiName(apiNames, apiName) {
51
51
  return _apiNames.includes(apiName);
52
52
  }
53
53
 
54
- /**
55
- * 通用jsBridge
56
- * @param deviceType
54
+ /**
55
+ * 通用jsBridge
56
+ * @param deviceType
57
57
  */
58
58
  function getComposedBridge(deviceType) {
59
59
  if (composedBridge) {
@@ -1,149 +1,149 @@
1
- declare type LanguageNumber = {
2
- en: number;
3
- zh_CN: number;
4
- zh_HK: number;
5
- };
6
- declare type LanguageString = {
7
- en: string;
8
- zh_CN: string;
9
- zh_HK: string;
10
- } | string;
11
- /**
12
- * 打印小票
13
- */
14
- export declare type WebPrint0 = {
15
- /**
16
- * 打印类型
17
- * 0: 小票
18
- * 1:ITS备货单/划菜单
19
- * 2:手环
20
- */
21
- type: '0';
22
- data: {
23
- /** 订单ID */
24
- order_id: string;
25
- };
26
- /** 打印语言对应的数量 */
27
- language: LanguageNumber;
28
- };
29
- /**
30
- * 打印ITS备货单/划菜单
31
- */
32
- export declare type WebPrint1 = {
33
- /**
34
- * 打印类型
35
- * 0: 小票
36
- * 1:ITS备货单/划菜单
37
- * 2:手环
38
- */
39
- type: '1';
40
- data: {
41
- /** 0:备货 1:划单 */
42
- mode: '0' | '1';
43
- resource: LanguageString;
44
- /** 订单备注 */
45
- order_note: string;
46
- /** 订单时间或商品下单时间 */
47
- time: string;
48
- /** 订单编号 */
49
- order_number?: string;
50
- /** 商品 */
51
- products: {
52
- /** 商品名称 */
53
- product_title: LanguageString;
54
- /** 商品规格 */
55
- product_option_string: LanguageString;
56
- /** 商品备注 */
57
- product_note: string;
58
- /** 商品数量 */
59
- product_quantity: number;
60
- /** 加菜标识 待定 */
61
- is_append?: boolean;
62
- /** 退菜标识 待定 */
63
- is_removed?: boolean;
64
- }[];
65
- };
66
- /** 打印语言对应的数量 */
67
- language: LanguageNumber;
68
- };
69
- /**
70
- * 打印手环
71
- */
72
- export declare type WebPrint2 = {
73
- /**
74
- * 打印类型
75
- * 0: 小票
76
- * 1:ITS备货单/划菜单
77
- * 2:手环
78
- */
79
- type: '2';
80
- data: {
81
- /** 0: 普通票 1:成人票 2:免费成人票 */
82
- type: '0' | '1' | '2';
83
- /** 发行编码 */
84
- encoded: string;
85
- /** 编码 */
86
- code: string;
87
- /** 到期时间 */
88
- expire_date: string;
89
- areas: {
90
- /** 区域名字 */
91
- area_name: string;
92
- /** 区域代码 */
93
- area_code: string;
94
- /** 可用次数 */
95
- limit_num: number;
96
- /** 已用次数 */
97
- used_num: number;
98
- }[];
99
- };
100
- };
101
- /**
102
- * 打印充值卡
103
- */
104
- export declare type WebPrint4 = {
105
- type: '4';
106
- data: {
107
- order_id: string;
108
- };
109
- };
110
- /**
111
- * 打印订单中所有
112
- */
113
- export declare type WebPrint99 = {
114
- type: '99';
115
- data: {
116
- order_id: string;
117
- machine_code_print_info: {
118
- [key: string]: any;
119
- }[];
120
- small_ticket_data: {
121
- [key: string]: any;
122
- };
123
- };
124
- };
125
- /**
126
- * 打印
127
- */
128
- export declare type WebPrintParams = WebPrint0 | WebPrint1 | WebPrint2 | WebPrint4 | WebPrint99;
129
- /**
130
- * 数据管理
131
- */
132
- export declare type DataManagerParams = {
133
- module: 'set' | 'get';
134
- key: string;
135
- data?: any;
136
- };
137
- /**
138
- * 支付
139
- */
140
- export declare type WebPaymentParams = {
141
- module: 'payment' | 'refund' | string;
142
- key: 'mx51' | string;
143
- data?: {
144
- order_id: string | number;
145
- amount: string | number;
146
- surcharge?: string | number;
147
- };
148
- };
149
- export {};
1
+ declare type LanguageNumber = {
2
+ en: number;
3
+ zh_CN: number;
4
+ zh_HK: number;
5
+ };
6
+ declare type LanguageString = {
7
+ en: string;
8
+ zh_CN: string;
9
+ zh_HK: string;
10
+ } | string;
11
+ /**
12
+ * 打印小票
13
+ */
14
+ export declare type WebPrint0 = {
15
+ /**
16
+ * 打印类型
17
+ * 0: 小票
18
+ * 1:ITS备货单/划菜单
19
+ * 2:手环
20
+ */
21
+ type: '0';
22
+ data: {
23
+ /** 订单ID */
24
+ order_id: string;
25
+ };
26
+ /** 打印语言对应的数量 */
27
+ language: LanguageNumber;
28
+ };
29
+ /**
30
+ * 打印ITS备货单/划菜单
31
+ */
32
+ export declare type WebPrint1 = {
33
+ /**
34
+ * 打印类型
35
+ * 0: 小票
36
+ * 1:ITS备货单/划菜单
37
+ * 2:手环
38
+ */
39
+ type: '1';
40
+ data: {
41
+ /** 0:备货 1:划单 */
42
+ mode: '0' | '1';
43
+ resource: LanguageString;
44
+ /** 订单备注 */
45
+ order_note: string;
46
+ /** 订单时间或商品下单时间 */
47
+ time: string;
48
+ /** 订单编号 */
49
+ order_number?: string;
50
+ /** 商品 */
51
+ products: {
52
+ /** 商品名称 */
53
+ product_title: LanguageString;
54
+ /** 商品规格 */
55
+ product_option_string: LanguageString;
56
+ /** 商品备注 */
57
+ product_note: string;
58
+ /** 商品数量 */
59
+ product_quantity: number;
60
+ /** 加菜标识 待定 */
61
+ is_append?: boolean;
62
+ /** 退菜标识 待定 */
63
+ is_removed?: boolean;
64
+ }[];
65
+ };
66
+ /** 打印语言对应的数量 */
67
+ language: LanguageNumber;
68
+ };
69
+ /**
70
+ * 打印手环
71
+ */
72
+ export declare type WebPrint2 = {
73
+ /**
74
+ * 打印类型
75
+ * 0: 小票
76
+ * 1:ITS备货单/划菜单
77
+ * 2:手环
78
+ */
79
+ type: '2';
80
+ data: {
81
+ /** 0: 普通票 1:成人票 2:免费成人票 */
82
+ type: '0' | '1' | '2';
83
+ /** 发行编码 */
84
+ encoded: string;
85
+ /** 编码 */
86
+ code: string;
87
+ /** 到期时间 */
88
+ expire_date: string;
89
+ areas: {
90
+ /** 区域名字 */
91
+ area_name: string;
92
+ /** 区域代码 */
93
+ area_code: string;
94
+ /** 可用次数 */
95
+ limit_num: number;
96
+ /** 已用次数 */
97
+ used_num: number;
98
+ }[];
99
+ };
100
+ };
101
+ /**
102
+ * 打印充值卡
103
+ */
104
+ export declare type WebPrint4 = {
105
+ type: '4';
106
+ data: {
107
+ order_id: string;
108
+ };
109
+ };
110
+ /**
111
+ * 打印订单中所有
112
+ */
113
+ export declare type WebPrint99 = {
114
+ type: '99';
115
+ data: {
116
+ order_id: string;
117
+ machine_code_print_info: {
118
+ [key: string]: any;
119
+ }[];
120
+ small_ticket_data: {
121
+ [key: string]: any;
122
+ };
123
+ };
124
+ };
125
+ /**
126
+ * 打印
127
+ */
128
+ export declare type WebPrintParams = WebPrint0 | WebPrint1 | WebPrint2 | WebPrint4 | WebPrint99;
129
+ /**
130
+ * 数据管理
131
+ */
132
+ export declare type DataManagerParams = {
133
+ module: 'set' | 'get';
134
+ key: string;
135
+ data?: any;
136
+ };
137
+ /**
138
+ * 支付
139
+ */
140
+ export declare type WebPaymentParams = {
141
+ module: 'payment' | 'refund' | string;
142
+ key: 'mx51' | string;
143
+ data?: {
144
+ order_id: string | number;
145
+ amount: string | number;
146
+ surcharge?: string | number;
147
+ };
148
+ };
149
+ export {};
package/es/locales.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- export declare const locales: {
2
- init: (_localeMaps: any, _locale: string) => void;
3
- getText: (id: string) => any;
4
- getLocale: () => string;
5
- locale: string;
6
- localeMap: any;
7
- localeMaps: any;
8
- formatLocale: (_locale: string) => string;
9
- };
1
+ export declare const locales: {
2
+ init: (_localeMaps: any, _locale: string) => void;
3
+ getText: (id: string) => any;
4
+ getLocale: () => string;
5
+ locale: string;
6
+ localeMap: any;
7
+ localeMaps: any;
8
+ formatLocale: (_locale: string) => string;
9
+ };
package/es/locales.js CHANGED
@@ -19,28 +19,47 @@ var locale = 'en';
19
19
  // 当前语言对应的多语言
20
20
  var localeMap = {};
21
21
 
22
- // 语言格式化
22
+ // 语言格式化(兼容 BCP 47,如 ja-JP、pt-BR)
23
23
  var formatLocale = function formatLocale(_locale) {
24
24
  var obj = {
25
- 'en': 'en',
25
+ en: 'en',
26
+ 'en-US': 'en',
27
+ 'en-us': 'en',
26
28
  'zh-CN': 'zh-CN',
29
+ 'zh-cn': 'zh-CN',
27
30
  'zh-HK': 'zh-HK',
31
+ 'zh-hk': 'zh-HK',
28
32
  'zh-TW': 'zh-HK',
29
- 'en-US': 'en',
30
- 'ja': 'ja',
31
- 'pt': 'pt'
33
+ 'zh-tw': 'zh-HK',
34
+ ja: 'ja',
35
+ 'ja-JP': 'ja',
36
+ 'ja-jp': 'ja',
37
+ pt: 'pt',
38
+ 'pt-BR': 'pt',
39
+ 'pt-br': 'pt',
40
+ 'pt-PT': 'pt',
41
+ 'pt-pt': 'pt'
32
42
  };
33
- return obj[_locale] || 'en';
43
+ var direct = obj[_locale];
44
+ if (direct) return direct;
45
+ var norm = String(_locale || '').trim().replace(/_/g, '-').toLowerCase();
46
+ if (obj[norm]) return obj[norm];
47
+ if (norm.startsWith('ja')) return 'ja';
48
+ if (norm.startsWith('pt')) return 'pt';
49
+ if (norm.startsWith('zh-hk') || norm.startsWith('zh-tw')) return 'zh-HK';
50
+ if (norm.startsWith('zh-cn')) return 'zh-CN';
51
+ if (norm.startsWith('en')) return 'en';
52
+ return 'en';
34
53
  };
35
54
 
36
- /**
37
- * @title: 初始化多语言
38
- * @description:
39
- * @param {any} _localeMaps
40
- * @param {string} _locale
41
- * @return {*}
42
- * @Author: zhiwei.Wang
43
- * @Date: 2024-01-17 21:38
55
+ /**
56
+ * @title: 初始化多语言
57
+ * @description:
58
+ * @param {any} _localeMaps
59
+ * @param {string} _locale
60
+ * @return {*}
61
+ * @Author: zhiwei.Wang
62
+ * @Date: 2024-01-17 21:38
44
63
  */
45
64
  var init = function init(_localeMaps, _locale) {
46
65
  // 设置语言
@@ -57,13 +76,13 @@ var init = function init(_localeMaps, _locale) {
57
76
  localeMap = localeMaps[locale];
58
77
  };
59
78
 
60
- /**
61
- * @title: 获取语言
62
- * @description:
63
- * @param {string} id
64
- * @return {*}
65
- * @Author: zhiwei.Wang
66
- * @Date: 2024-01-17 21:39
79
+ /**
80
+ * @title: 获取语言
81
+ * @description:
82
+ * @param {string} id
83
+ * @return {*}
84
+ * @Author: zhiwei.Wang
85
+ * @Date: 2024-01-17 21:39
67
86
  */
68
87
  var getText = function getText(id) {
69
88
  var _localeMaps2;