@pisell/utils 3.0.6 → 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 +23 -26
- package/es/arrayUtils.js +157 -97
- package/es/common/index.d.ts +5 -0
- package/es/common/index.js +5 -0
- package/es/common/stateHelper.d.ts +2 -6
- package/es/common/stateHelper.js +24 -22
- package/es/common/types.d.ts +10 -13
- package/es/common/types.js +1 -0
- package/es/componentStorage.d.ts +25 -27
- package/es/componentStorage.js +130 -94
- package/es/constants/index.js +9 -7
- package/es/date.js +53 -36
- package/es/document.js +67 -43
- package/es/escPosPrinter/EscPosPrinter.js +490 -353
- package/es/escPosPrinter/index.d.ts +9 -9
- package/es/escPosPrinter/index.js +52 -37
- package/es/firebase/config/index.js +54 -0
- package/es/firebase/index.js +232 -0
- package/es/format.d.ts +15 -12
- package/es/format.js +156 -89
- package/es/image.js +60 -48
- package/es/index.d.ts +24 -39
- package/es/index.js +35 -40
- package/es/jsBridge/index.d.ts +4 -8
- package/es/jsBridge/index.js +55 -56
- package/es/jsBridge/regDeviceApi.js +126 -87
- package/es/jsBridge/types.d.ts +115 -95
- package/es/jsBridge/types.js +1 -0
- package/es/locales.d.ts +8 -11
- package/es/locales.js +96 -77
- package/es/log.d.ts +6 -11
- package/es/log.js +59 -37
- package/es/miniRedux.d.ts +13 -20
- package/es/miniRedux.js +76 -42
- 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 +2 -6
- package/es/number-input/hooks/useNumberInputState.js +128 -71
- package/es/number-input/index.d.ts +14 -0
- package/es/number-input/index.js +21 -0
- package/es/number-input/types.d.ts +88 -88
- package/es/number-input/types.js +1 -0
- package/es/number-input/utils/formatter.d.ts +10 -13
- package/es/number-input/utils/formatter.js +77 -51
- 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 +2 -7
- package/es/number-input/utils/validation.js +66 -51
- package/es/otherUtils.d.ts +9 -12
- package/es/otherUtils.js +129 -71
- package/es/platform.d.ts +9 -12
- package/es/platform.js +85 -61
- package/es/select/hooks/index.d.ts +5 -0
- package/es/select/hooks/index.js +6 -0
- package/es/select/hooks/useDebouncedSearch.d.ts +1 -4
- package/es/select/hooks/useDebouncedSearch.js +53 -39
- package/es/select/hooks/useSelectState.d.ts +7 -7
- package/es/select/hooks/useSelectState.js +113 -56
- package/es/select/index.d.ts +8 -7
- package/es/select/index.js +13 -0
- package/es/select/types.d.ts +211 -211
- package/es/select/types.js +1 -0
- package/es/select/utils/filterOptions.d.ts +6 -7
- package/es/select/utils/filterOptions.js +31 -26
- package/es/select/utils/helpers.d.ts +9 -10
- package/es/select/utils/helpers.js +52 -42
- package/es/select/utils/index.d.ts +7 -4
- package/es/select/utils/index.js +8 -0
- package/es/select/utils/sortOptions.d.ts +5 -6
- package/es/select/utils/sortOptions.js +31 -19
- package/es/select/utils/tagAggregation.d.ts +6 -6
- package/es/select/utils/tagAggregation.js +47 -34
- 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 +2 -6
- package/es/text-input/hooks/useTextInputState.js +126 -69
- package/es/text-input/index.d.ts +14 -0
- package/es/text-input/index.js +20 -0
- package/es/text-input/types.d.ts +48 -48
- 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 +2 -7
- package/es/text-input/utils/validation.js +70 -50
- package/es/typeUtils.js +84 -61
- package/es/walletValidity.d.ts +42 -44
- package/es/walletValidity.js +557 -396
- package/es/weighing.d.ts +45 -48
- package/es/weighing.js +106 -83
- package/lib/arrayUtils.d.ts +23 -26
- package/lib/arrayUtils.js +111 -101
- package/lib/common/index.d.ts +5 -0
- package/lib/common/index.js +29 -0
- package/lib/common/stateHelper.d.ts +2 -6
- package/lib/common/stateHelper.js +32 -21
- package/lib/common/types.d.ts +10 -13
- package/lib/common/types.js +17 -0
- package/lib/componentStorage.d.ts +25 -27
- package/lib/componentStorage.js +126 -96
- package/lib/constants/index.js +36 -7
- package/lib/date.js +65 -43
- package/lib/document.js +62 -46
- package/lib/escPosPrinter/EscPosPrinter.js +403 -327
- package/lib/escPosPrinter/index.d.ts +9 -9
- package/lib/escPosPrinter/index.js +84 -38
- package/lib/firebase/config/index.js +79 -0
- package/lib/firebase/index.js +180 -0
- package/lib/format.d.ts +15 -12
- package/lib/format.js +133 -91
- package/lib/image.js +74 -48
- package/lib/index.d.ts +24 -39
- package/lib/index.js +80 -137
- package/lib/jsBridge/index.d.ts +4 -8
- package/lib/jsBridge/index.js +76 -57
- package/lib/jsBridge/regDeviceApi.js +133 -86
- package/lib/jsBridge/types.d.ts +115 -95
- package/lib/jsBridge/types.js +17 -0
- package/lib/locales.d.ts +8 -11
- package/lib/locales.js +90 -79
- package/lib/log.d.ts +6 -11
- package/lib/log.js +61 -37
- package/lib/miniRedux.d.ts +13 -20
- package/lib/miniRedux.js +89 -43
- 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 +2 -6
- package/lib/number-input/hooks/useNumberInputState.js +81 -71
- package/lib/number-input/index.d.ts +14 -0
- package/lib/number-input/index.js +41 -0
- package/lib/number-input/types.d.ts +88 -88
- package/lib/number-input/types.js +17 -0
- package/lib/number-input/utils/formatter.d.ts +10 -13
- package/lib/number-input/utils/formatter.js +49 -52
- 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 +2 -7
- package/lib/number-input/utils/validation.js +52 -50
- package/lib/otherUtils.d.ts +9 -12
- package/lib/otherUtils.js +98 -86
- package/lib/platform.d.ts +9 -12
- package/lib/platform.js +123 -68
- package/lib/select/hooks/index.d.ts +5 -0
- package/lib/select/hooks/index.js +34 -0
- package/lib/select/hooks/useDebouncedSearch.d.ts +1 -4
- package/lib/select/hooks/useDebouncedSearch.js +41 -40
- package/lib/select/hooks/useSelectState.d.ts +7 -7
- package/lib/select/hooks/useSelectState.js +93 -58
- package/lib/select/index.d.ts +8 -7
- package/lib/select/index.js +53 -0
- package/lib/select/types.d.ts +211 -211
- package/lib/select/types.js +17 -0
- package/lib/select/utils/filterOptions.d.ts +6 -7
- package/lib/select/utils/filterOptions.js +37 -26
- package/lib/select/utils/helpers.d.ts +9 -10
- package/lib/select/utils/helpers.js +41 -45
- package/lib/select/utils/index.d.ts +7 -4
- package/lib/select/utils/index.js +48 -0
- package/lib/select/utils/sortOptions.d.ts +5 -6
- package/lib/select/utils/sortOptions.js +39 -18
- package/lib/select/utils/tagAggregation.d.ts +6 -6
- package/lib/select/utils/tagAggregation.js +41 -33
- 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 +2 -6
- package/lib/text-input/hooks/useTextInputState.js +79 -69
- package/lib/text-input/index.d.ts +14 -0
- package/lib/text-input/index.js +35 -0
- package/lib/text-input/types.d.ts +48 -48
- 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 +2 -7
- package/lib/text-input/utils/validation.js +58 -49
- package/lib/typeUtils.js +73 -68
- package/lib/walletValidity.d.ts +42 -44
- package/lib/walletValidity.js +393 -410
- package/lib/weighing.d.ts +45 -48
- package/lib/weighing.js +149 -104
- package/package.json +1 -1
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js +0 -27
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.js +0 -12
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js +0 -25
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.js +0 -14
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.js +0 -9
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.js +0 -11
- package/es/date.d.ts +0 -31
- package/es/document.d.ts +0 -16
- package/es/image.d.ts +0 -14
- package/es/typeUtils.d.ts +0 -45
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js +0 -27
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.js +0 -12
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js +0 -25
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.js +0 -14
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.js +0 -9
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.js +0 -16
- package/lib/_virtual/_rolldown/runtime.js +0 -23
- package/lib/date.d.ts +0 -31
- package/lib/document.d.ts +0 -16
- package/lib/image.d.ts +0 -14
- package/lib/typeUtils.d.ts +0 -45
package/lib/platform.js
CHANGED
|
@@ -1,77 +1,132 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
if (!/iphone|ios|ipad|android|mobile/i.test(navigator.userAgent.toLowerCase()) && !isIPad) return false;
|
|
9
|
-
return true;
|
|
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 });
|
|
10
8
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
let bIsAndroid = sUserAgent.match(/android/i) == "android";
|
|
19
|
-
let bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
|
|
20
|
-
let bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
|
|
21
|
-
if (bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM || isIpad()) return true;
|
|
22
|
-
else return false;
|
|
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;
|
|
23
16
|
};
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/platform.ts
|
|
20
|
+
var platform_exports = {};
|
|
21
|
+
__export(platform_exports, {
|
|
22
|
+
checkEnv: () => checkEnv,
|
|
23
|
+
isAndroid: () => isAndroid,
|
|
24
|
+
isIOS: () => isIOS,
|
|
25
|
+
isIos: () => isIos,
|
|
26
|
+
isIpad: () => isIpad,
|
|
27
|
+
isMobile: () => isMobile,
|
|
28
|
+
isSafari: () => isSafari,
|
|
29
|
+
isWx: () => isWx,
|
|
30
|
+
isWxApp: () => isWxApp
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(platform_exports);
|
|
33
|
+
var isBrowser = typeof window != "undefined" && window.document;
|
|
34
|
+
var isIpad = () => {
|
|
35
|
+
var ua = navigator.userAgent;
|
|
36
|
+
var isSafari2 = ua.indexOf("Safari") != -1 && ua.indexOf("Version") != -1;
|
|
37
|
+
var isIphone = ua.indexOf("iPhone") != -1 && ua.indexOf("Version") != -1;
|
|
38
|
+
var isIPad = isSafari2 && !isIphone && "ontouchend" in document;
|
|
39
|
+
if (!/iphone|ios|ipad|android|mobile/i.test(
|
|
40
|
+
navigator.userAgent.toLowerCase()
|
|
41
|
+
) && !isIPad) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
return true;
|
|
26
45
|
};
|
|
27
|
-
|
|
28
|
-
|
|
46
|
+
var isMobile = () => {
|
|
47
|
+
let sUserAgent = window.navigator.userAgent.toLowerCase();
|
|
48
|
+
let bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
|
|
49
|
+
let bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
|
|
50
|
+
let bIsMidp = sUserAgent.match(/midp/i) == "midp";
|
|
51
|
+
let bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
|
|
52
|
+
let bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
|
|
53
|
+
let bIsAndroid = sUserAgent.match(/android/i) == "android";
|
|
54
|
+
let bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
|
|
55
|
+
let bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
|
|
56
|
+
if (bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM || isIpad()) {
|
|
57
|
+
return true;
|
|
58
|
+
} else {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
29
61
|
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
let userAgent = window.navigator.userAgent;
|
|
33
|
-
let isOpera = userAgent.indexOf("Opera") > -1 || userAgent.indexOf("OPR") > -1;
|
|
34
|
-
let isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1;
|
|
35
|
-
let isIE11 = userAgent.indexOf("compatible") === -1 && userAgent.indexOf("Trident") > -1;
|
|
36
|
-
let isEdge = userAgent.indexOf("Edge") > -1;
|
|
37
|
-
let isFF = userAgent.indexOf("Firefox") > -1;
|
|
38
|
-
let isSafari = userAgent.indexOf("Safari") > -1 && userAgent.indexOf("Chrome") === -1;
|
|
39
|
-
let isChrome = userAgent.indexOf("Chrome") > -1 && userAgent.indexOf("; Win") > -1 && userAgent.indexOf("Safari") > -1;
|
|
40
|
-
if (isOpera || isIE || isIE11 || isEdge || isFF || isSafari || isChrome) env = 0;
|
|
41
|
-
else env = 1;
|
|
42
|
-
return env;
|
|
62
|
+
var isAndroid = () => {
|
|
63
|
+
return navigator.userAgent.toLowerCase().indexOf("android") !== -1;
|
|
43
64
|
};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
let ua = "";
|
|
47
|
-
if (isBrowser) ua = window.navigator.userAgent.toLowerCase();
|
|
48
|
-
if (ua.match(/MicroMessenger/i) == "micromessenger") return true;
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
return false;
|
|
65
|
+
var isIos = () => {
|
|
66
|
+
return /iphone|ipad|ipod/.test(navigator.userAgent.toLowerCase());
|
|
52
67
|
};
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
68
|
+
var checkEnv = () => {
|
|
69
|
+
let env = 0;
|
|
70
|
+
let userAgent = window.navigator.userAgent;
|
|
71
|
+
let isOpera = userAgent.indexOf("Opera") > -1 || userAgent.indexOf("OPR") > -1;
|
|
72
|
+
let isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1;
|
|
73
|
+
let isIE11 = userAgent.indexOf("compatible") === -1 && userAgent.indexOf("Trident") > -1;
|
|
74
|
+
let isEdge = userAgent.indexOf("Edge") > -1;
|
|
75
|
+
let isFF = userAgent.indexOf("Firefox") > -1;
|
|
76
|
+
let isSafari2 = userAgent.indexOf("Safari") > -1 && userAgent.indexOf("Chrome") === -1;
|
|
77
|
+
let isChrome = userAgent.indexOf("Chrome") > -1 && userAgent.indexOf("; Win") > -1 && userAgent.indexOf("Safari") > -1;
|
|
78
|
+
if (isOpera || isIE || isIE11 || isEdge || isFF || isSafari2 || isChrome) {
|
|
79
|
+
env = 0;
|
|
80
|
+
} else {
|
|
81
|
+
env = 1;
|
|
82
|
+
}
|
|
83
|
+
return env;
|
|
56
84
|
};
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
85
|
+
var isWx = () => {
|
|
86
|
+
if (isBrowser) {
|
|
87
|
+
let ua = "";
|
|
88
|
+
if (isBrowser) {
|
|
89
|
+
ua = window.navigator.userAgent.toLowerCase();
|
|
90
|
+
}
|
|
91
|
+
if (ua.match(/MicroMessenger/i) == "micromessenger") {
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
return false;
|
|
60
97
|
};
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
98
|
+
var isIOS = () => {
|
|
99
|
+
if (isBrowser) {
|
|
100
|
+
let u = navigator.userAgent;
|
|
101
|
+
let isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
|
|
102
|
+
return isiOS;
|
|
103
|
+
}
|
|
104
|
+
return false;
|
|
67
105
|
};
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
106
|
+
var isWxApp = () => {
|
|
107
|
+
if (isBrowser) {
|
|
108
|
+
let u = navigator.userAgent;
|
|
109
|
+
let isWxapp = u.indexOf("miniProgram") !== -1;
|
|
110
|
+
return isWxapp;
|
|
111
|
+
}
|
|
112
|
+
return false;
|
|
113
|
+
};
|
|
114
|
+
var isSafari = () => {
|
|
115
|
+
if (isBrowser) {
|
|
116
|
+
let userAgent = window.navigator.userAgent;
|
|
117
|
+
return userAgent.indexOf("Safari") > -1 && userAgent.indexOf("Chrome") === -1 && userAgent.indexOf("CriOS") === -1 && userAgent.indexOf("ChannelName/Feishu") === -1;
|
|
118
|
+
}
|
|
119
|
+
return false;
|
|
120
|
+
};
|
|
121
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
122
|
+
0 && (module.exports = {
|
|
123
|
+
checkEnv,
|
|
124
|
+
isAndroid,
|
|
125
|
+
isIOS,
|
|
126
|
+
isIos,
|
|
127
|
+
isIpad,
|
|
128
|
+
isMobile,
|
|
129
|
+
isSafari,
|
|
130
|
+
isWx,
|
|
131
|
+
isWxApp
|
|
132
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
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/select/hooks/index.ts
|
|
20
|
+
var hooks_exports = {};
|
|
21
|
+
__export(hooks_exports, {
|
|
22
|
+
useDebouncedSearch: () => import_useDebouncedSearch.useDebouncedSearch,
|
|
23
|
+
useMultipleSelectState: () => import_useSelectState.useMultipleSelectState,
|
|
24
|
+
useSelectState: () => import_useSelectState.useSelectState
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(hooks_exports);
|
|
27
|
+
var import_useSelectState = require("./useSelectState");
|
|
28
|
+
var import_useDebouncedSearch = require("./useDebouncedSearch");
|
|
29
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
+
0 && (module.exports = {
|
|
31
|
+
useDebouncedSearch,
|
|
32
|
+
useMultipleSelectState,
|
|
33
|
+
useSelectState
|
|
34
|
+
});
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/select/hooks/useDebouncedSearch.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* 防抖搜索 Hook
|
|
4
3
|
* 对用户输入进行防抖处理,避免频繁触发搜索
|
|
@@ -18,6 +17,4 @@
|
|
|
18
17
|
* });
|
|
19
18
|
* ```
|
|
20
19
|
*/
|
|
21
|
-
declare function useDebouncedSearch<T = string>(initialValue: T, delay: number, callback?: (value: T) => void): [T, (value: T) => void];
|
|
22
|
-
//#endregion
|
|
23
|
-
export { useDebouncedSearch };
|
|
20
|
+
export declare function useDebouncedSearch<T = string>(initialValue: T, delay: number, callback?: (value: T) => void): [T, (value: T) => void];
|
|
@@ -1,42 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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/select/hooks/useDebouncedSearch.ts
|
|
20
|
+
var useDebouncedSearch_exports = {};
|
|
21
|
+
__export(useDebouncedSearch_exports, {
|
|
22
|
+
useDebouncedSearch: () => useDebouncedSearch
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(useDebouncedSearch_exports);
|
|
25
|
+
var import_react = require("react");
|
|
23
26
|
function useDebouncedSearch(initialValue, delay, callback) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
delay,
|
|
37
|
-
callback
|
|
38
|
-
]);
|
|
39
|
-
return [debouncedValue, setValue];
|
|
27
|
+
const [value, setValue] = (0, import_react.useState)(initialValue);
|
|
28
|
+
const [debouncedValue, setDebouncedValue] = (0, import_react.useState)(initialValue);
|
|
29
|
+
(0, import_react.useEffect)(() => {
|
|
30
|
+
const timer = setTimeout(() => {
|
|
31
|
+
setDebouncedValue(value);
|
|
32
|
+
callback == null ? void 0 : callback(value);
|
|
33
|
+
}, delay);
|
|
34
|
+
return () => {
|
|
35
|
+
clearTimeout(timer);
|
|
36
|
+
};
|
|
37
|
+
}, [value, delay, callback]);
|
|
38
|
+
return [debouncedValue, setValue];
|
|
40
39
|
}
|
|
41
|
-
|
|
42
|
-
exports
|
|
40
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
41
|
+
0 && (module.exports = {
|
|
42
|
+
useDebouncedSearch
|
|
43
|
+
});
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Select 状态管理 Hook
|
|
3
|
+
* 处理受控/非受控模式,适用于单选和多选
|
|
4
|
+
*/
|
|
5
|
+
import type { UseSelectStateOptions, UseMultipleSelectStateOptions, SelectState, MultipleSelectState } from '../types';
|
|
4
6
|
/**
|
|
5
7
|
* 单选状态管理 Hook
|
|
6
8
|
* @template T 值的类型
|
|
7
9
|
* @param options Hook 配置选项
|
|
8
10
|
* @returns 状态管理对象
|
|
9
11
|
*/
|
|
10
|
-
declare function useSelectState<T = string | number>(options: UseSelectStateOptions<T>): SelectState<T>;
|
|
12
|
+
export declare function useSelectState<T = string | number>(options: UseSelectStateOptions<T>): SelectState<T>;
|
|
11
13
|
/**
|
|
12
14
|
* 多选状态管理 Hook
|
|
13
15
|
* @template T 值的类型
|
|
14
16
|
* @param options Hook 配置选项
|
|
15
17
|
* @returns 状态管理对象
|
|
16
18
|
*/
|
|
17
|
-
declare function useMultipleSelectState<T = string | number>(options: UseMultipleSelectStateOptions<T>): MultipleSelectState<T>;
|
|
18
|
-
//#endregion
|
|
19
|
-
export { useMultipleSelectState, useSelectState };
|
|
19
|
+
export declare function useMultipleSelectState<T = string | number>(options: UseMultipleSelectStateOptions<T>): MultipleSelectState<T>;
|
|
@@ -1,62 +1,97 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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/select/hooks/useSelectState.ts
|
|
20
|
+
var useSelectState_exports = {};
|
|
21
|
+
__export(useSelectState_exports, {
|
|
22
|
+
useMultipleSelectState: () => useMultipleSelectState,
|
|
23
|
+
useSelectState: () => useSelectState
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(useSelectState_exports);
|
|
26
|
+
var import_react = require("react");
|
|
14
27
|
function useSelectState(options) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
const { value: controlledValue, defaultValue, onChange } = options;
|
|
29
|
+
const isControlled = controlledValue !== void 0;
|
|
30
|
+
const [internalValue, setInternalValue] = (0, import_react.useState)(
|
|
31
|
+
defaultValue ?? null
|
|
32
|
+
);
|
|
33
|
+
const value = isControlled ? controlledValue : internalValue;
|
|
34
|
+
const setValue = (0, import_react.useCallback)(
|
|
35
|
+
(newValue) => {
|
|
36
|
+
if (!isControlled) {
|
|
37
|
+
setInternalValue(newValue);
|
|
38
|
+
}
|
|
39
|
+
onChange == null ? void 0 : onChange(newValue, null);
|
|
40
|
+
},
|
|
41
|
+
[isControlled, onChange]
|
|
42
|
+
);
|
|
43
|
+
const clearValue = (0, import_react.useCallback)(() => {
|
|
44
|
+
setValue(null);
|
|
45
|
+
}, [setValue]);
|
|
46
|
+
return {
|
|
47
|
+
value,
|
|
48
|
+
setValue,
|
|
49
|
+
clearValue
|
|
50
|
+
};
|
|
30
51
|
}
|
|
31
|
-
/**
|
|
32
|
-
* 多选状态管理 Hook
|
|
33
|
-
* @template T 值的类型
|
|
34
|
-
* @param options Hook 配置选项
|
|
35
|
-
* @returns 状态管理对象
|
|
36
|
-
*/
|
|
37
52
|
function useMultipleSelectState(options) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
53
|
+
const { value: controlledValue, defaultValue, onChange } = options;
|
|
54
|
+
const isControlled = controlledValue !== void 0;
|
|
55
|
+
const [internalValue, setInternalValue] = (0, import_react.useState)(
|
|
56
|
+
defaultValue ?? []
|
|
57
|
+
);
|
|
58
|
+
const value = isControlled ? controlledValue ?? [] : internalValue;
|
|
59
|
+
const setValue = (0, import_react.useCallback)(
|
|
60
|
+
(newValue) => {
|
|
61
|
+
if (!isControlled) {
|
|
62
|
+
setInternalValue(newValue);
|
|
63
|
+
}
|
|
64
|
+
onChange == null ? void 0 : onChange(newValue, []);
|
|
65
|
+
},
|
|
66
|
+
[isControlled, onChange]
|
|
67
|
+
);
|
|
68
|
+
const addValue = (0, import_react.useCallback)(
|
|
69
|
+
(val) => {
|
|
70
|
+
const newValue = [...value, val];
|
|
71
|
+
setValue(newValue);
|
|
72
|
+
},
|
|
73
|
+
[value, setValue]
|
|
74
|
+
);
|
|
75
|
+
const removeValue = (0, import_react.useCallback)(
|
|
76
|
+
(val) => {
|
|
77
|
+
const newValue = value.filter((v) => v !== val);
|
|
78
|
+
setValue(newValue);
|
|
79
|
+
},
|
|
80
|
+
[value, setValue]
|
|
81
|
+
);
|
|
82
|
+
const clearValue = (0, import_react.useCallback)(() => {
|
|
83
|
+
setValue([]);
|
|
84
|
+
}, [setValue]);
|
|
85
|
+
return {
|
|
86
|
+
value,
|
|
87
|
+
setValue,
|
|
88
|
+
addValue,
|
|
89
|
+
removeValue,
|
|
90
|
+
clearValue
|
|
91
|
+
};
|
|
59
92
|
}
|
|
60
|
-
|
|
61
|
-
exports
|
|
62
|
-
|
|
93
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
94
|
+
0 && (module.exports = {
|
|
95
|
+
useMultipleSelectState,
|
|
96
|
+
useSelectState
|
|
97
|
+
});
|
package/lib/select/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Select 组件相关工具和类型导出
|
|
3
|
+
* 供 PisellSingleSelect、PisellMultipleSelect 等组件使用
|
|
4
|
+
*/
|
|
5
|
+
export type { SelectOption, FilterOptionFunc, SortDirection, SelectState, MultipleSelectState, TagDisplayInfo, UseSelectStateOptions, UseMultipleSelectStateOptions, BaseSelectProps, } from './types';
|
|
6
|
+
export { useSelectState, useMultipleSelectState } from './hooks/useSelectState';
|
|
7
|
+
export { useDebouncedSearch } from './hooks/useDebouncedSearch';
|
|
8
|
+
export { filterOptions, defaultFilterOption, sortOptions, calculateTagDisplay, findOptionByValue, findOptionsByValues, isOptionSelected, isOptionSelectedInMultiple, generateId, } from './utils';
|
|
@@ -0,0 +1,53 @@
|
|
|
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/select/index.ts
|
|
20
|
+
var select_exports = {};
|
|
21
|
+
__export(select_exports, {
|
|
22
|
+
calculateTagDisplay: () => import_utils.calculateTagDisplay,
|
|
23
|
+
defaultFilterOption: () => import_utils.defaultFilterOption,
|
|
24
|
+
filterOptions: () => import_utils.filterOptions,
|
|
25
|
+
findOptionByValue: () => import_utils.findOptionByValue,
|
|
26
|
+
findOptionsByValues: () => import_utils.findOptionsByValues,
|
|
27
|
+
generateId: () => import_utils.generateId,
|
|
28
|
+
isOptionSelected: () => import_utils.isOptionSelected,
|
|
29
|
+
isOptionSelectedInMultiple: () => import_utils.isOptionSelectedInMultiple,
|
|
30
|
+
sortOptions: () => import_utils.sortOptions,
|
|
31
|
+
useDebouncedSearch: () => import_useDebouncedSearch.useDebouncedSearch,
|
|
32
|
+
useMultipleSelectState: () => import_useSelectState.useMultipleSelectState,
|
|
33
|
+
useSelectState: () => import_useSelectState.useSelectState
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(select_exports);
|
|
36
|
+
var import_useSelectState = require("./hooks/useSelectState");
|
|
37
|
+
var import_useDebouncedSearch = require("./hooks/useDebouncedSearch");
|
|
38
|
+
var import_utils = require("./utils");
|
|
39
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
+
0 && (module.exports = {
|
|
41
|
+
calculateTagDisplay,
|
|
42
|
+
defaultFilterOption,
|
|
43
|
+
filterOptions,
|
|
44
|
+
findOptionByValue,
|
|
45
|
+
findOptionsByValues,
|
|
46
|
+
generateId,
|
|
47
|
+
isOptionSelected,
|
|
48
|
+
isOptionSelectedInMultiple,
|
|
49
|
+
sortOptions,
|
|
50
|
+
useDebouncedSearch,
|
|
51
|
+
useMultipleSelectState,
|
|
52
|
+
useSelectState
|
|
53
|
+
});
|