@pisell/utils 3.0.5 → 3.0.7
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/es/arrayUtils.d.ts +72 -0
- package/es/arrayUtils.js +142 -3
- package/es/common/index.d.ts +5 -0
- package/es/common/index.js +5 -0
- package/es/common/stateHelper.d.ts +18 -0
- package/es/common/stateHelper.js +25 -0
- package/es/common/types.d.ts +28 -0
- package/es/common/types.js +1 -0
- package/es/componentStorage.d.ts +36 -0
- package/es/componentStorage.js +142 -0
- package/es/format.d.ts +5 -1
- package/es/format.js +53 -8
- package/es/index.d.ts +6 -0
- package/es/index.js +6 -0
- package/es/jsBridge/index.d.ts +9 -105
- package/es/jsBridge/index.js +28 -12
- package/es/jsBridge/types.d.ts +149 -0
- package/es/jsBridge/types.js +1 -0
- package/es/locales.d.ts +2 -5
- package/es/locales.js +36 -7
- package/es/miniRedux.js +7 -2
- package/es/number-input/hooks/index.d.ts +4 -0
- package/es/number-input/hooks/index.js +5 -0
- package/es/number-input/hooks/useNumberInputState.d.ts +25 -0
- package/es/number-input/hooks/useNumberInputState.js +129 -0
- package/es/number-input/index.d.ts +14 -0
- package/es/number-input/index.js +21 -0
- package/es/number-input/types.d.ts +96 -0
- package/es/number-input/types.js +1 -0
- package/es/number-input/utils/formatter.d.ts +53 -0
- package/es/number-input/utils/formatter.js +82 -0
- package/es/number-input/utils/index.d.ts +7 -0
- package/es/number-input/utils/index.js +8 -0
- package/es/number-input/utils/validation.d.ts +27 -0
- package/es/number-input/utils/validation.js +67 -0
- package/es/otherUtils.d.ts +48 -0
- package/es/select/hooks/index.d.ts +5 -0
- package/es/select/hooks/index.js +6 -0
- package/es/select/hooks/useDebouncedSearch.d.ts +20 -0
- package/es/select/hooks/useDebouncedSearch.js +55 -0
- package/es/select/hooks/useSelectState.d.ts +19 -0
- package/es/select/hooks/useSelectState.js +117 -0
- package/es/select/index.d.ts +8 -0
- package/es/select/index.js +13 -0
- package/es/select/types.d.ts +256 -0
- package/es/select/types.js +1 -0
- package/es/select/utils/filterOptions.d.ts +22 -0
- package/es/select/utils/filterOptions.js +34 -0
- package/es/select/utils/helpers.d.ts +42 -0
- package/es/select/utils/helpers.js +61 -0
- package/es/select/utils/index.d.ts +7 -0
- package/es/select/utils/index.js +8 -0
- package/es/select/utils/sortOptions.d.ts +12 -0
- package/es/select/utils/sortOptions.js +32 -0
- package/es/select/utils/tagAggregation.d.ts +25 -0
- package/es/select/utils/tagAggregation.js +48 -0
- package/es/text-input/hooks/index.d.ts +4 -0
- package/es/text-input/hooks/index.js +5 -0
- package/es/text-input/hooks/useTextInputState.d.ts +24 -0
- package/es/text-input/hooks/useTextInputState.js +127 -0
- package/es/text-input/index.d.ts +14 -0
- package/es/text-input/index.js +20 -0
- package/es/text-input/types.d.ts +56 -0
- package/es/text-input/types.js +1 -0
- package/es/text-input/utils/index.d.ts +5 -0
- package/es/text-input/utils/index.js +7 -0
- package/es/text-input/utils/validation.d.ts +23 -0
- package/es/text-input/utils/validation.js +71 -0
- package/es/walletValidity.d.ts +55 -0
- package/es/walletValidity.js +143 -38
- package/es/weighing.d.ts +62 -0
- package/es/weighing.js +119 -0
- package/lib/arrayUtils.d.ts +72 -0
- package/lib/arrayUtils.js +75 -0
- package/lib/common/index.d.ts +5 -0
- package/lib/common/index.js +29 -0
- package/lib/common/stateHelper.d.ts +18 -0
- package/lib/common/stateHelper.js +34 -0
- package/lib/common/types.d.ts +28 -0
- package/lib/common/types.js +17 -0
- package/lib/componentStorage.d.ts +36 -0
- package/lib/componentStorage.js +144 -0
- package/lib/format.d.ts +5 -1
- package/lib/format.js +45 -5
- package/lib/index.d.ts +6 -0
- package/lib/index.js +13 -1
- package/lib/jsBridge/index.d.ts +9 -105
- package/lib/jsBridge/index.js +20 -1
- package/lib/jsBridge/types.d.ts +149 -0
- package/lib/jsBridge/types.js +17 -0
- package/lib/locales.d.ts +2 -5
- package/lib/locales.js +34 -7
- package/lib/miniRedux.js +5 -7
- package/lib/number-input/hooks/index.d.ts +4 -0
- package/lib/number-input/hooks/index.js +29 -0
- package/lib/number-input/hooks/useNumberInputState.d.ts +25 -0
- package/lib/number-input/hooks/useNumberInputState.js +83 -0
- package/lib/number-input/index.d.ts +14 -0
- package/lib/number-input/index.js +41 -0
- package/lib/number-input/types.d.ts +96 -0
- package/lib/number-input/types.js +17 -0
- package/lib/number-input/utils/formatter.d.ts +53 -0
- package/lib/number-input/utils/formatter.js +55 -0
- package/lib/number-input/utils/index.d.ts +7 -0
- package/lib/number-input/utils/index.js +39 -0
- package/lib/number-input/utils/validation.d.ts +27 -0
- package/lib/number-input/utils/validation.js +54 -0
- package/lib/otherUtils.d.ts +48 -0
- package/lib/select/hooks/index.d.ts +5 -0
- package/lib/select/hooks/index.js +34 -0
- package/lib/select/hooks/useDebouncedSearch.d.ts +20 -0
- package/lib/select/hooks/useDebouncedSearch.js +43 -0
- package/lib/select/hooks/useSelectState.d.ts +19 -0
- package/lib/select/hooks/useSelectState.js +97 -0
- package/lib/select/index.d.ts +8 -0
- package/lib/select/index.js +53 -0
- package/lib/select/types.d.ts +256 -0
- package/lib/select/types.js +17 -0
- package/lib/select/utils/filterOptions.d.ts +22 -0
- package/lib/select/utils/filterOptions.js +41 -0
- package/lib/select/utils/helpers.d.ts +42 -0
- package/lib/select/utils/helpers.js +51 -0
- package/lib/select/utils/index.d.ts +7 -0
- package/lib/select/utils/index.js +48 -0
- package/lib/select/utils/sortOptions.d.ts +12 -0
- package/lib/select/utils/sortOptions.js +41 -0
- package/lib/select/utils/tagAggregation.d.ts +25 -0
- package/lib/select/utils/tagAggregation.js +43 -0
- package/lib/text-input/hooks/index.d.ts +4 -0
- package/lib/text-input/hooks/index.js +29 -0
- package/lib/text-input/hooks/useTextInputState.d.ts +24 -0
- package/lib/text-input/hooks/useTextInputState.js +81 -0
- package/lib/text-input/index.d.ts +14 -0
- package/lib/text-input/index.js +35 -0
- package/lib/text-input/types.d.ts +56 -0
- package/lib/text-input/types.js +17 -0
- package/lib/text-input/utils/index.d.ts +5 -0
- package/lib/text-input/utils/index.js +32 -0
- package/lib/text-input/utils/validation.d.ts +23 -0
- package/lib/text-input/utils/validation.js +60 -0
- package/lib/walletValidity.d.ts +55 -0
- package/lib/walletValidity.js +120 -40
- package/lib/weighing.d.ts +62 -0
- package/lib/weighing.js +159 -0
- package/package.json +1 -1
- package/es/date.d.ts +0 -28
- package/es/document.d.ts +0 -13
- package/es/firebase/config/index.d.ts +0 -13
- package/es/firebase/index.d.ts +0 -28
- package/es/image.d.ts +0 -11
- package/es/typeUtils.d.ts +0 -42
- package/lib/date.d.ts +0 -28
- package/lib/document.d.ts +0 -13
- package/lib/firebase/config/index.d.ts +0 -13
- package/lib/firebase/index.d.ts +0 -28
- package/lib/image.d.ts +0 -11
- package/lib/typeUtils.d.ts +0 -42
package/lib/jsBridge/index.d.ts
CHANGED
|
@@ -1,113 +1,11 @@
|
|
|
1
|
-
|
|
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
|
-
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
|
-
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
|
-
declare type WebPrint2 = {
|
|
70
|
-
/**
|
|
71
|
-
* 打印类型
|
|
72
|
-
* 0: 小票
|
|
73
|
-
* 1:ITS备货单/划菜单
|
|
74
|
-
* 2:手环
|
|
75
|
-
*/
|
|
76
|
-
type: "2";
|
|
77
|
-
data: {
|
|
78
|
-
/** 0: 普通票 1:成人票 2:免费成人票 */
|
|
79
|
-
type: "0" | "1" | "2";
|
|
80
|
-
/** 发行编码 */
|
|
81
|
-
encoded: string;
|
|
82
|
-
/** 编码 */
|
|
83
|
-
code: string;
|
|
84
|
-
/** 到期时间 */
|
|
85
|
-
expire_date: string;
|
|
86
|
-
areas: {
|
|
87
|
-
/** 区域名字 */
|
|
88
|
-
area_name: string;
|
|
89
|
-
/** 区域代码 */
|
|
90
|
-
area_code: string;
|
|
91
|
-
/** 可用次数 */
|
|
92
|
-
limit_num: number;
|
|
93
|
-
/** 已用次数 */
|
|
94
|
-
used_num: number;
|
|
95
|
-
}[];
|
|
96
|
-
};
|
|
97
|
-
};
|
|
98
|
-
declare type WebPrintParams = WebPrint0 | WebPrint1 | WebPrint2;
|
|
1
|
+
import { WebPrintParams, DataManagerParams, WebPaymentParams } from './types';
|
|
99
2
|
/**
|
|
100
3
|
* webView页面中调用打印机打印
|
|
101
4
|
* 此api暂时只支持native app平台下ios手机
|
|
102
5
|
* @param params
|
|
103
6
|
* @param callback
|
|
104
7
|
*/
|
|
105
|
-
export declare function webPrint(params: WebPrintParams, callback: (...arg: any) => void): void;
|
|
106
|
-
declare type DataManagerParams = {
|
|
107
|
-
module: "set" | "get";
|
|
108
|
-
key: string;
|
|
109
|
-
data?: any;
|
|
110
|
-
};
|
|
8
|
+
export declare function webPrint(params: WebPrintParams, callback: (...arg: any) => void, onError?: (error: any) => void): void;
|
|
111
9
|
/**
|
|
112
10
|
* webView页面中调用APP内的数据
|
|
113
11
|
* 此api暂时只支持native app平台下ios手机
|
|
@@ -115,4 +13,10 @@ declare type DataManagerParams = {
|
|
|
115
13
|
* @param callback
|
|
116
14
|
*/
|
|
117
15
|
export declare function dataManager(params: DataManagerParams, callback: (...arg: any) => void, onError: () => void): void;
|
|
118
|
-
|
|
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;
|
package/lib/jsBridge/index.js
CHANGED
|
@@ -30,11 +30,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
var jsBridge_exports = {};
|
|
31
31
|
__export(jsBridge_exports, {
|
|
32
32
|
dataManager: () => dataManager,
|
|
33
|
+
webPayment: () => webPayment,
|
|
33
34
|
webPrint: () => webPrint
|
|
34
35
|
});
|
|
35
36
|
module.exports = __toCommonJS(jsBridge_exports);
|
|
36
37
|
var import_regDeviceApi = __toESM(require("./regDeviceApi"));
|
|
37
|
-
function webPrint(params, callback) {
|
|
38
|
+
function webPrint(params, callback, onError) {
|
|
38
39
|
(0, import_regDeviceApi.default)().then((jsBridge) => {
|
|
39
40
|
jsBridge.callDeviceApi({
|
|
40
41
|
apiName: "webPrint",
|
|
@@ -43,6 +44,9 @@ function webPrint(params, callback) {
|
|
|
43
44
|
callback && callback(...arg);
|
|
44
45
|
}
|
|
45
46
|
});
|
|
47
|
+
}).catch((err) => {
|
|
48
|
+
onError == null ? void 0 : onError(err);
|
|
49
|
+
console.error("webPrint", err);
|
|
46
50
|
});
|
|
47
51
|
}
|
|
48
52
|
function dataManager(params, callback, onError) {
|
|
@@ -56,8 +60,23 @@ function dataManager(params, callback, onError) {
|
|
|
56
60
|
});
|
|
57
61
|
}).catch(onError);
|
|
58
62
|
}
|
|
63
|
+
function webPayment(params, callback, onError) {
|
|
64
|
+
(0, import_regDeviceApi.default)().then((jsBridge) => {
|
|
65
|
+
jsBridge.callDeviceApi({
|
|
66
|
+
apiName: "webPayment",
|
|
67
|
+
params,
|
|
68
|
+
callback: (...arg) => {
|
|
69
|
+
callback && callback(...arg);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}).catch((err) => {
|
|
73
|
+
onError == null ? void 0 : onError(err);
|
|
74
|
+
console.error("webPayment", err);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
59
77
|
// Annotate the CommonJS export names for ESM import in node:
|
|
60
78
|
0 && (module.exports = {
|
|
61
79
|
dataManager,
|
|
80
|
+
webPayment,
|
|
62
81
|
webPrint
|
|
63
82
|
});
|
|
@@ -0,0 +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 {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
|
|
15
|
+
// src/jsBridge/types.ts
|
|
16
|
+
var types_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(types_exports);
|
package/lib/locales.d.ts
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
export declare const locales: {
|
|
2
2
|
init: (_localeMaps: any, _locale: string) => void;
|
|
3
3
|
getText: (id: string) => any;
|
|
4
|
+
getLocale: () => string;
|
|
4
5
|
locale: string;
|
|
5
6
|
localeMap: any;
|
|
6
|
-
localeMaps:
|
|
7
|
-
en: {};
|
|
8
|
-
'zh-CN': {};
|
|
9
|
-
'zh-HK': {};
|
|
10
|
-
};
|
|
7
|
+
localeMaps: any;
|
|
11
8
|
formatLocale: (_locale: string) => string;
|
|
12
9
|
};
|
package/lib/locales.js
CHANGED
|
@@ -25,19 +25,42 @@ module.exports = __toCommonJS(locales_exports);
|
|
|
25
25
|
var localeMaps = {
|
|
26
26
|
en: {},
|
|
27
27
|
"zh-CN": {},
|
|
28
|
-
"zh-HK": {}
|
|
28
|
+
"zh-HK": {},
|
|
29
|
+
"ja": {},
|
|
30
|
+
"pt": {}
|
|
29
31
|
};
|
|
30
32
|
var locale = "en";
|
|
31
33
|
var localeMap = {};
|
|
32
34
|
var formatLocale = (_locale) => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
const obj = {
|
|
36
|
+
en: "en",
|
|
37
|
+
"en-US": "en",
|
|
38
|
+
"en-us": "en",
|
|
35
39
|
"zh-CN": "zh-CN",
|
|
40
|
+
"zh-cn": "zh-CN",
|
|
36
41
|
"zh-HK": "zh-HK",
|
|
42
|
+
"zh-hk": "zh-HK",
|
|
37
43
|
"zh-TW": "zh-HK",
|
|
38
|
-
"
|
|
44
|
+
"zh-tw": "zh-HK",
|
|
45
|
+
ja: "ja",
|
|
46
|
+
"ja-JP": "ja",
|
|
47
|
+
"ja-jp": "ja",
|
|
48
|
+
pt: "pt",
|
|
49
|
+
"pt-BR": "pt",
|
|
50
|
+
"pt-br": "pt",
|
|
51
|
+
"pt-PT": "pt",
|
|
52
|
+
"pt-pt": "pt"
|
|
39
53
|
};
|
|
40
|
-
|
|
54
|
+
const direct = obj[_locale];
|
|
55
|
+
if (direct) return direct;
|
|
56
|
+
const norm = String(_locale || "").trim().replace(/_/g, "-").toLowerCase();
|
|
57
|
+
if (obj[norm]) return obj[norm];
|
|
58
|
+
if (norm.startsWith("ja")) return "ja";
|
|
59
|
+
if (norm.startsWith("pt")) return "pt";
|
|
60
|
+
if (norm.startsWith("zh-hk") || norm.startsWith("zh-tw")) return "zh-HK";
|
|
61
|
+
if (norm.startsWith("zh-cn")) return "zh-CN";
|
|
62
|
+
if (norm.startsWith("en")) return "en";
|
|
63
|
+
return "en";
|
|
41
64
|
};
|
|
42
65
|
var init = (_localeMaps, _locale) => {
|
|
43
66
|
locale = formatLocale(_locale);
|
|
@@ -50,14 +73,18 @@ var init = (_localeMaps, _locale) => {
|
|
|
50
73
|
}
|
|
51
74
|
localeMaps = allLocales;
|
|
52
75
|
localeMap = localeMaps[locale];
|
|
53
|
-
console.log("多语言注入成功, 当前语言为:" + locale);
|
|
54
76
|
};
|
|
55
77
|
var getText = (id) => {
|
|
56
|
-
|
|
78
|
+
var _a;
|
|
79
|
+
return localeMap[id] || ((_a = localeMaps == null ? void 0 : localeMaps["en"]) == null ? void 0 : _a[id]) || id;
|
|
80
|
+
};
|
|
81
|
+
var getLocale = () => {
|
|
82
|
+
return locale;
|
|
57
83
|
};
|
|
58
84
|
var locales = {
|
|
59
85
|
init,
|
|
60
86
|
getText,
|
|
87
|
+
getLocale,
|
|
61
88
|
locale,
|
|
62
89
|
localeMap,
|
|
63
90
|
localeMaps,
|
package/lib/miniRedux.js
CHANGED
|
@@ -61,6 +61,10 @@ var miniRedux = ({
|
|
|
61
61
|
dispatch({ type, payload });
|
|
62
62
|
}
|
|
63
63
|
}, []);
|
|
64
|
+
const contextValue = (0, import_react.useMemo)(() => ({
|
|
65
|
+
[namespace]: providerState,
|
|
66
|
+
dispatch: _dispatch
|
|
67
|
+
}), [providerState, _dispatch]);
|
|
64
68
|
let _props = {
|
|
65
69
|
...props,
|
|
66
70
|
[namespace]: providerState,
|
|
@@ -71,13 +75,7 @@ var miniRedux = ({
|
|
|
71
75
|
_ref = _props.forwardedRef;
|
|
72
76
|
delete _props.forwardedRef;
|
|
73
77
|
}
|
|
74
|
-
return /* @__PURE__ */ import_react.default.createElement(
|
|
75
|
-
Context.Provider,
|
|
76
|
-
{
|
|
77
|
-
value: { [namespace]: providerState, dispatch: _dispatch }
|
|
78
|
-
},
|
|
79
|
-
/* @__PURE__ */ import_react.default.createElement(ComponentUi, { ..._props, ref })
|
|
80
|
-
);
|
|
78
|
+
return /* @__PURE__ */ import_react.default.createElement(Context.Provider, { value: contextValue }, /* @__PURE__ */ import_react.default.createElement(ComponentUi, { ..._props, ref }));
|
|
81
79
|
});
|
|
82
80
|
return Components;
|
|
83
81
|
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/number-input/hooks/index.ts
|
|
20
|
+
var hooks_exports = {};
|
|
21
|
+
__export(hooks_exports, {
|
|
22
|
+
useNumberInputState: () => import_useNumberInputState.useNumberInputState
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(hooks_exports);
|
|
25
|
+
var import_useNumberInputState = require("./useNumberInputState");
|
|
26
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
27
|
+
0 && (module.exports = {
|
|
28
|
+
useNumberInputState
|
|
29
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { BaseNumberInputProps, NumberInputState } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* 数值输入状态管理 Hook
|
|
4
|
+
*
|
|
5
|
+
* 管理组件的内部状态,包括:
|
|
6
|
+
* - 值管理(受控/非受控模式)
|
|
7
|
+
* - 校验状态管理
|
|
8
|
+
* - 事件处理函数封装
|
|
9
|
+
*
|
|
10
|
+
* 支持受控和非受控两种模式:
|
|
11
|
+
* - 受控模式:value 由外部传入,组件不维护内部状态
|
|
12
|
+
* - 非受控模式:使用 defaultValue,组件维护内部状态
|
|
13
|
+
*
|
|
14
|
+
* @param props 组件 Props(包含校验配置)
|
|
15
|
+
* @returns 数值输入状态对象
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* // 受控模式
|
|
19
|
+
* const state = useNumberInputState({ value: 10, onChange: (v) => console.log(v) });
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* // 非受控模式
|
|
23
|
+
* const state = useNumberInputState({ defaultValue: 10, min: 0, max: 100 });
|
|
24
|
+
*/
|
|
25
|
+
export declare function useNumberInputState(props: BaseNumberInputProps): NumberInputState;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/number-input/hooks/useNumberInputState.ts
|
|
20
|
+
var useNumberInputState_exports = {};
|
|
21
|
+
__export(useNumberInputState_exports, {
|
|
22
|
+
useNumberInputState: () => useNumberInputState
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(useNumberInputState_exports);
|
|
25
|
+
var import_react = require("react");
|
|
26
|
+
var import_validation = require("../utils/validation");
|
|
27
|
+
function useNumberInputState(props) {
|
|
28
|
+
const isControlled = props.value !== void 0;
|
|
29
|
+
const [innerValue, setInnerValue] = (0, import_react.useState)(
|
|
30
|
+
props.defaultValue ?? null
|
|
31
|
+
);
|
|
32
|
+
const [isTouched, setIsTouched] = (0, import_react.useState)(false);
|
|
33
|
+
const [isValid, setIsValid] = (0, import_react.useState)(true);
|
|
34
|
+
const [errors, setErrors] = (0, import_react.useState)([]);
|
|
35
|
+
const currentValue = isControlled ? props.value : innerValue;
|
|
36
|
+
const handleChange = (0, import_react.useCallback)(
|
|
37
|
+
(newValue) => {
|
|
38
|
+
var _a, _b;
|
|
39
|
+
if (!isControlled) {
|
|
40
|
+
setInnerValue(newValue);
|
|
41
|
+
}
|
|
42
|
+
const shouldValidate = props.validateTrigger === "onChange" || props.validateTrigger === "both";
|
|
43
|
+
if (shouldValidate) {
|
|
44
|
+
const validation = (0, import_validation.validateValue)(newValue, props);
|
|
45
|
+
setIsValid(validation.isValid);
|
|
46
|
+
setErrors(validation.errors);
|
|
47
|
+
(_a = props.onValidate) == null ? void 0 : _a.call(props, validation.isValid, validation.errors);
|
|
48
|
+
}
|
|
49
|
+
(_b = props.onChange) == null ? void 0 : _b.call(props, newValue);
|
|
50
|
+
},
|
|
51
|
+
[isControlled, props]
|
|
52
|
+
);
|
|
53
|
+
const handleBlur = (0, import_react.useCallback)(() => {
|
|
54
|
+
var _a, _b;
|
|
55
|
+
setIsTouched(true);
|
|
56
|
+
const shouldValidate = props.validateTrigger !== "onChange";
|
|
57
|
+
if (shouldValidate) {
|
|
58
|
+
const validation = (0, import_validation.validateValue)(currentValue, props);
|
|
59
|
+
setIsValid(validation.isValid);
|
|
60
|
+
setErrors(validation.errors);
|
|
61
|
+
(_a = props.onValidate) == null ? void 0 : _a.call(props, validation.isValid, validation.errors);
|
|
62
|
+
}
|
|
63
|
+
(_b = props.onBlur) == null ? void 0 : _b.call(props, currentValue ?? null);
|
|
64
|
+
}, [currentValue, props]);
|
|
65
|
+
const handleFocus = (0, import_react.useCallback)(() => {
|
|
66
|
+
var _a;
|
|
67
|
+
setIsTouched(true);
|
|
68
|
+
(_a = props.onFocus) == null ? void 0 : _a.call(props);
|
|
69
|
+
}, [props]);
|
|
70
|
+
return {
|
|
71
|
+
value: currentValue,
|
|
72
|
+
isTouched,
|
|
73
|
+
isValid,
|
|
74
|
+
errors,
|
|
75
|
+
handleChange,
|
|
76
|
+
handleBlur,
|
|
77
|
+
handleFocus
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
81
|
+
0 && (module.exports = {
|
|
82
|
+
useNumberInputState
|
|
83
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 数值输入组件公共逻辑导出
|
|
3
|
+
*
|
|
4
|
+
* 供以下组件使用:
|
|
5
|
+
* - PisellNumber
|
|
6
|
+
* - PisellCurrency
|
|
7
|
+
* - PisellPercent
|
|
8
|
+
* - 其他数值输入组件
|
|
9
|
+
*/
|
|
10
|
+
export type { DisplayState, ValidationResult, NumberInputState, BaseNumberInputProps, } from './types';
|
|
11
|
+
export { useNumberInputState } from './hooks';
|
|
12
|
+
export { getDisplayState, formatNumber, addThousandsSeparator, formatPrecision, } from './utils';
|
|
13
|
+
export { validateValue as validateNumberValue } from './utils';
|
|
14
|
+
export type { NumberFormatOptions } from './utils';
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/number-input/index.ts
|
|
20
|
+
var number_input_exports = {};
|
|
21
|
+
__export(number_input_exports, {
|
|
22
|
+
addThousandsSeparator: () => import_utils.addThousandsSeparator,
|
|
23
|
+
formatNumber: () => import_utils.formatNumber,
|
|
24
|
+
formatPrecision: () => import_utils.formatPrecision,
|
|
25
|
+
getDisplayState: () => import_utils.getDisplayState,
|
|
26
|
+
useNumberInputState: () => import_hooks.useNumberInputState,
|
|
27
|
+
validateNumberValue: () => import_utils2.validateValue
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(number_input_exports);
|
|
30
|
+
var import_hooks = require("./hooks");
|
|
31
|
+
var import_utils = require("./utils");
|
|
32
|
+
var import_utils2 = require("./utils");
|
|
33
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
34
|
+
0 && (module.exports = {
|
|
35
|
+
addThousandsSeparator,
|
|
36
|
+
formatNumber,
|
|
37
|
+
formatPrecision,
|
|
38
|
+
getDisplayState,
|
|
39
|
+
useNumberInputState,
|
|
40
|
+
validateNumberValue
|
|
41
|
+
});
|