@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
|
@@ -1,55 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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/utils/helpers.ts
|
|
20
|
+
var helpers_exports = {};
|
|
21
|
+
__export(helpers_exports, {
|
|
22
|
+
findOptionByValue: () => findOptionByValue,
|
|
23
|
+
findOptionsByValues: () => findOptionsByValues,
|
|
24
|
+
generateId: () => generateId,
|
|
25
|
+
isOptionSelected: () => isOptionSelected,
|
|
26
|
+
isOptionSelectedInMultiple: () => isOptionSelectedInMultiple
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(helpers_exports);
|
|
9
29
|
function findOptionByValue(value, options) {
|
|
10
|
-
|
|
30
|
+
return options.find((opt) => opt.value === value);
|
|
11
31
|
}
|
|
12
|
-
/**
|
|
13
|
-
* 根据值数组查找选项对象数组
|
|
14
|
-
* @template T 选项值的类型
|
|
15
|
-
* @param values 选项值数组
|
|
16
|
-
* @param options 选项列表
|
|
17
|
-
* @returns 找到的选项对象数组
|
|
18
|
-
*/
|
|
19
32
|
function findOptionsByValues(values, options) {
|
|
20
|
-
|
|
33
|
+
return values.map((val) => findOptionByValue(val, options)).filter(Boolean);
|
|
21
34
|
}
|
|
22
|
-
/**
|
|
23
|
-
* 判断选项是否被选中(单选)
|
|
24
|
-
* @template T 选项值的类型
|
|
25
|
-
* @param optionValue 选项值
|
|
26
|
-
* @param selectedValue 当前选中值
|
|
27
|
-
* @returns 是否选中
|
|
28
|
-
*/
|
|
29
35
|
function isOptionSelected(optionValue, selectedValue) {
|
|
30
|
-
|
|
36
|
+
return selectedValue !== null && selectedValue !== void 0 && optionValue === selectedValue;
|
|
31
37
|
}
|
|
32
|
-
/**
|
|
33
|
-
* 判断选项是否被选中(多选)
|
|
34
|
-
* @template T 选项值的类型
|
|
35
|
-
* @param optionValue 选项值
|
|
36
|
-
* @param selectedValues 当前选中值数组
|
|
37
|
-
* @returns 是否选中
|
|
38
|
-
*/
|
|
39
38
|
function isOptionSelectedInMultiple(optionValue, selectedValues) {
|
|
40
|
-
|
|
39
|
+
return selectedValues.includes(optionValue);
|
|
41
40
|
}
|
|
42
|
-
/**
|
|
43
|
-
* 生成唯一 ID
|
|
44
|
-
* @param prefix ID 前缀
|
|
45
|
-
* @returns 唯一 ID
|
|
46
|
-
*/
|
|
47
41
|
function generateId(prefix = "select") {
|
|
48
|
-
|
|
42
|
+
return `${prefix}-${Math.random().toString(36).substr(2, 9)}`;
|
|
49
43
|
}
|
|
50
|
-
|
|
51
|
-
exports
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
44
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
45
|
+
0 && (module.exports = {
|
|
46
|
+
findOptionByValue,
|
|
47
|
+
findOptionsByValues,
|
|
48
|
+
generateId,
|
|
49
|
+
isOptionSelected,
|
|
50
|
+
isOptionSelectedInMultiple
|
|
51
|
+
});
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Select 工具函数导出
|
|
3
|
+
*/
|
|
4
|
+
export { calculateTagDisplay } from './tagAggregation';
|
|
5
|
+
export { filterOptions, defaultFilterOption } from './filterOptions';
|
|
6
|
+
export { sortOptions } from './sortOptions';
|
|
7
|
+
export { findOptionByValue, findOptionsByValues, isOptionSelected, isOptionSelectedInMultiple, generateId, } from './helpers';
|
|
@@ -0,0 +1,48 @@
|
|
|
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/utils/index.ts
|
|
20
|
+
var utils_exports = {};
|
|
21
|
+
__export(utils_exports, {
|
|
22
|
+
calculateTagDisplay: () => import_tagAggregation.calculateTagDisplay,
|
|
23
|
+
defaultFilterOption: () => import_filterOptions.defaultFilterOption,
|
|
24
|
+
filterOptions: () => import_filterOptions.filterOptions,
|
|
25
|
+
findOptionByValue: () => import_helpers.findOptionByValue,
|
|
26
|
+
findOptionsByValues: () => import_helpers.findOptionsByValues,
|
|
27
|
+
generateId: () => import_helpers.generateId,
|
|
28
|
+
isOptionSelected: () => import_helpers.isOptionSelected,
|
|
29
|
+
isOptionSelectedInMultiple: () => import_helpers.isOptionSelectedInMultiple,
|
|
30
|
+
sortOptions: () => import_sortOptions.sortOptions
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(utils_exports);
|
|
33
|
+
var import_tagAggregation = require("./tagAggregation");
|
|
34
|
+
var import_filterOptions = require("./filterOptions");
|
|
35
|
+
var import_sortOptions = require("./sortOptions");
|
|
36
|
+
var import_helpers = require("./helpers");
|
|
37
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
38
|
+
0 && (module.exports = {
|
|
39
|
+
calculateTagDisplay,
|
|
40
|
+
defaultFilterOption,
|
|
41
|
+
filterOptions,
|
|
42
|
+
findOptionByValue,
|
|
43
|
+
findOptionsByValues,
|
|
44
|
+
generateId,
|
|
45
|
+
isOptionSelected,
|
|
46
|
+
isOptionSelectedInMultiple,
|
|
47
|
+
sortOptions
|
|
48
|
+
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* 选项排序工具函数
|
|
3
|
+
*/
|
|
4
|
+
import type { SelectOption, SortDirection } from '../types';
|
|
4
5
|
/**
|
|
5
6
|
* 排序选项列表
|
|
6
7
|
* @template T 选项值的类型
|
|
@@ -8,6 +9,4 @@ import { SelectOption, SortDirection } from "../types.js";
|
|
|
8
9
|
* @param direction 排序方向('asc' 升序 | 'desc' 降序)
|
|
9
10
|
* @returns 排序后的选项列表(新数组)
|
|
10
11
|
*/
|
|
11
|
-
declare function sortOptions<T = string | number>(options: SelectOption<T>[], direction?: SortDirection): SelectOption<T>[];
|
|
12
|
-
//#endregion
|
|
13
|
-
export { sortOptions };
|
|
12
|
+
export declare function sortOptions<T = string | number>(options: SelectOption<T>[], direction?: SortDirection): SelectOption<T>[];
|
|
@@ -1,20 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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/utils/sortOptions.ts
|
|
20
|
+
var sortOptions_exports = {};
|
|
21
|
+
__export(sortOptions_exports, {
|
|
22
|
+
sortOptions: () => sortOptions
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(sortOptions_exports);
|
|
9
25
|
function sortOptions(options, direction = "asc") {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
26
|
+
const sortedOptions = [...options];
|
|
27
|
+
sortedOptions.sort((a, b) => {
|
|
28
|
+
const labelA = a.label.toLowerCase();
|
|
29
|
+
const labelB = b.label.toLowerCase();
|
|
30
|
+
if (direction === "asc") {
|
|
31
|
+
return labelA.localeCompare(labelB);
|
|
32
|
+
} else {
|
|
33
|
+
return labelB.localeCompare(labelA);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
return sortedOptions;
|
|
18
37
|
}
|
|
19
|
-
|
|
20
|
-
exports
|
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
+
0 && (module.exports = {
|
|
40
|
+
sortOptions
|
|
41
|
+
});
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* 标签聚合工具函数
|
|
3
|
+
* 用于多选下拉组件的标签显示逻辑
|
|
4
|
+
*/
|
|
5
|
+
import type { SelectOption, TagDisplayInfo } from '../types';
|
|
4
6
|
/**
|
|
5
7
|
* 计算需要显示的标签和聚合信息
|
|
6
8
|
* @template T 选项值的类型
|
|
@@ -20,6 +22,4 @@ import { SelectOption, TagDisplayInfo } from "../types.js";
|
|
|
20
22
|
* // }
|
|
21
23
|
* ```
|
|
22
24
|
*/
|
|
23
|
-
declare function calculateTagDisplay<T = string | number>(selectedValues: T[], options: SelectOption<T>[], maxTagCount: number): TagDisplayInfo<T>;
|
|
24
|
-
//#endregion
|
|
25
|
-
export { calculateTagDisplay };
|
|
25
|
+
export declare function calculateTagDisplay<T = string | number>(selectedValues: T[], options: SelectOption<T>[], maxTagCount: number): TagDisplayInfo<T>;
|
|
@@ -1,35 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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/utils/tagAggregation.ts
|
|
20
|
+
var tagAggregation_exports = {};
|
|
21
|
+
__export(tagAggregation_exports, {
|
|
22
|
+
calculateTagDisplay: () => calculateTagDisplay
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(tagAggregation_exports);
|
|
21
25
|
function calculateTagDisplay(selectedValues, options, maxTagCount) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
const selectedOptions = selectedValues.map((v) => options.find((opt) => opt.value === v)).filter(Boolean);
|
|
27
|
+
if (selectedOptions.length <= maxTagCount) {
|
|
28
|
+
return {
|
|
29
|
+
visibleTags: selectedOptions,
|
|
30
|
+
hiddenTags: [],
|
|
31
|
+
hiddenCount: 0
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
visibleTags: selectedOptions.slice(0, maxTagCount),
|
|
36
|
+
hiddenTags: selectedOptions.slice(maxTagCount),
|
|
37
|
+
hiddenCount: selectedOptions.length - maxTagCount
|
|
38
|
+
};
|
|
33
39
|
}
|
|
34
|
-
|
|
35
|
-
exports
|
|
40
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
41
|
+
0 && (module.exports = {
|
|
42
|
+
calculateTagDisplay
|
|
43
|
+
});
|
|
@@ -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/text-input/hooks/index.ts
|
|
20
|
+
var hooks_exports = {};
|
|
21
|
+
__export(hooks_exports, {
|
|
22
|
+
useTextInputState: () => import_useTextInputState.useTextInputState
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(hooks_exports);
|
|
25
|
+
var import_useTextInputState = require("./useTextInputState");
|
|
26
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
27
|
+
0 && (module.exports = {
|
|
28
|
+
useTextInputState
|
|
29
|
+
});
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { BaseTextInputProps, TextInputState } from
|
|
2
|
-
|
|
3
|
-
//#region src/text-input/hooks/useTextInputState.d.ts
|
|
1
|
+
import type { BaseTextInputProps, TextInputState } from '../types';
|
|
4
2
|
/**
|
|
5
3
|
* 文本输入状态管理 Hook
|
|
6
4
|
*
|
|
@@ -23,6 +21,4 @@ import { BaseTextInputProps, TextInputState } from "../types.js";
|
|
|
23
21
|
* // 非受控模式
|
|
24
22
|
* const state = useTextInputState({ defaultValue: 'hello' });
|
|
25
23
|
*/
|
|
26
|
-
declare function useTextInputState(props: BaseTextInputProps): TextInputState;
|
|
27
|
-
//#endregion
|
|
28
|
-
export { useTextInputState };
|
|
24
|
+
export declare function useTextInputState(props: BaseTextInputProps): TextInputState;
|
|
@@ -1,71 +1,81 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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/text-input/hooks/useTextInputState.ts
|
|
20
|
+
var useTextInputState_exports = {};
|
|
21
|
+
__export(useTextInputState_exports, {
|
|
22
|
+
useTextInputState: () => useTextInputState
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(useTextInputState_exports);
|
|
25
|
+
var import_react = require("react");
|
|
26
|
+
var import_validation = require("../utils/validation");
|
|
27
27
|
function useTextInputState(props) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
28
|
+
const isControlled = props.value !== void 0;
|
|
29
|
+
const [innerValue, setInnerValue] = (0, import_react.useState)(props.defaultValue || "");
|
|
30
|
+
const [isTouched, setIsTouched] = (0, import_react.useState)(false);
|
|
31
|
+
const [isValid, setIsValid] = (0, import_react.useState)(true);
|
|
32
|
+
const [errors, setErrors] = (0, import_react.useState)([]);
|
|
33
|
+
const currentValue = isControlled ? props.value : innerValue;
|
|
34
|
+
const handleChange = (0, import_react.useCallback)(
|
|
35
|
+
(newValue) => {
|
|
36
|
+
var _a, _b;
|
|
37
|
+
if (!isControlled) {
|
|
38
|
+
setInnerValue(newValue);
|
|
39
|
+
}
|
|
40
|
+
const shouldValidate = props.validateTrigger === "onChange" || props.validateTrigger === "both";
|
|
41
|
+
if (shouldValidate) {
|
|
42
|
+
const validation = (0, import_validation.validateValue)(newValue, props);
|
|
43
|
+
setIsValid(validation.isValid);
|
|
44
|
+
setErrors(validation.errors);
|
|
45
|
+
(_a = props.onValidate) == null ? void 0 : _a.call(props, validation.isValid, validation.errors);
|
|
46
|
+
}
|
|
47
|
+
(_b = props.onChange) == null ? void 0 : _b.call(props, newValue);
|
|
48
|
+
},
|
|
49
|
+
[isControlled, props]
|
|
50
|
+
);
|
|
51
|
+
const handleBlur = (0, import_react.useCallback)(() => {
|
|
52
|
+
var _a, _b;
|
|
53
|
+
setIsTouched(true);
|
|
54
|
+
const shouldValidate = props.validateTrigger !== "onChange";
|
|
55
|
+
if (shouldValidate) {
|
|
56
|
+
const validation = (0, import_validation.validateValue)(currentValue || "", props);
|
|
57
|
+
setIsValid(validation.isValid);
|
|
58
|
+
setErrors(validation.errors);
|
|
59
|
+
(_a = props.onValidate) == null ? void 0 : _a.call(props, validation.isValid, validation.errors);
|
|
60
|
+
}
|
|
61
|
+
(_b = props.onBlur) == null ? void 0 : _b.call(props, currentValue || "");
|
|
62
|
+
}, [currentValue, props]);
|
|
63
|
+
const handleFocus = (0, import_react.useCallback)(() => {
|
|
64
|
+
var _a;
|
|
65
|
+
setIsTouched(true);
|
|
66
|
+
(_a = props.onFocus) == null ? void 0 : _a.call(props);
|
|
67
|
+
}, [props]);
|
|
68
|
+
return {
|
|
69
|
+
value: currentValue,
|
|
70
|
+
isTouched,
|
|
71
|
+
isValid,
|
|
72
|
+
errors,
|
|
73
|
+
handleChange,
|
|
74
|
+
handleBlur,
|
|
75
|
+
handleFocus
|
|
76
|
+
};
|
|
69
77
|
}
|
|
70
|
-
|
|
71
|
-
exports
|
|
78
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
79
|
+
0 && (module.exports = {
|
|
80
|
+
useTextInputState
|
|
81
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 文本输入组件公共逻辑导出
|
|
3
|
+
*
|
|
4
|
+
* 供以下组件使用:
|
|
5
|
+
* - PisellSingleLineText
|
|
6
|
+
* - PisellLongText
|
|
7
|
+
* - PisellPhone
|
|
8
|
+
* - PisellEmail
|
|
9
|
+
* - PisellUrl
|
|
10
|
+
*/
|
|
11
|
+
export type { DisplayState, ValidationResult, TextInputState, BaseTextInputProps, } from './types';
|
|
12
|
+
export { useTextInputState } from './hooks';
|
|
13
|
+
export { getDisplayState } from './utils';
|
|
14
|
+
export { validateValue as validateTextValue } from './utils';
|
|
@@ -0,0 +1,35 @@
|
|
|
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/text-input/index.ts
|
|
20
|
+
var text_input_exports = {};
|
|
21
|
+
__export(text_input_exports, {
|
|
22
|
+
getDisplayState: () => import_utils.getDisplayState,
|
|
23
|
+
useTextInputState: () => import_hooks.useTextInputState,
|
|
24
|
+
validateTextValue: () => import_utils2.validateValue
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(text_input_exports);
|
|
27
|
+
var import_hooks = require("./hooks");
|
|
28
|
+
var import_utils = require("./utils");
|
|
29
|
+
var import_utils2 = require("./utils");
|
|
30
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
31
|
+
0 && (module.exports = {
|
|
32
|
+
getDisplayState,
|
|
33
|
+
useTextInputState,
|
|
34
|
+
validateTextValue
|
|
35
|
+
});
|