@pisell/utils 1.0.71 → 1.0.73

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js +27 -0
  2. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.js +12 -0
  3. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js +25 -0
  4. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.js +14 -0
  5. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.js +9 -0
  6. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.js +11 -0
  7. package/es/arrayUtils.d.ts +4 -1
  8. package/es/arrayUtils.js +15 -24
  9. package/es/common/stateHelper.d.ts +6 -2
  10. package/es/common/stateHelper.js +22 -24
  11. package/es/common/types.d.ts +13 -10
  12. package/es/componentStorage.d.ts +27 -25
  13. package/es/componentStorage.js +94 -130
  14. package/es/constants/index.js +7 -9
  15. package/es/date.d.ts +6 -3
  16. package/es/date.js +36 -53
  17. package/es/document.d.ts +6 -3
  18. package/es/document.js +43 -67
  19. package/es/escPosPrinter/EscPosPrinter.js +353 -490
  20. package/es/escPosPrinter/index.d.ts +9 -9
  21. package/es/escPosPrinter/index.js +37 -52
  22. package/es/format.d.ts +12 -11
  23. package/es/format.js +90 -116
  24. package/es/image.d.ts +13 -10
  25. package/es/image.js +48 -60
  26. package/es/index.d.ts +38 -23
  27. package/es/index.js +39 -34
  28. package/es/jsBridge/index.d.ts +8 -4
  29. package/es/jsBridge/index.js +57 -56
  30. package/es/jsBridge/regDeviceApi.js +107 -149
  31. package/es/jsBridge/types.d.ts +95 -115
  32. package/es/locales.d.ts +11 -8
  33. package/es/locales.js +77 -96
  34. package/es/log.d.ts +11 -6
  35. package/es/log.js +37 -59
  36. package/es/miniRedux.d.ts +20 -13
  37. package/es/miniRedux.js +42 -78
  38. package/es/number-input/hooks/useNumberInputState.d.ts +6 -2
  39. package/es/number-input/hooks/useNumberInputState.js +71 -128
  40. package/es/number-input/types.d.ts +88 -88
  41. package/es/number-input/utils/formatter.d.ts +13 -10
  42. package/es/number-input/utils/formatter.js +51 -77
  43. package/es/number-input/utils/validation.d.ts +7 -2
  44. package/es/number-input/utils/validation.js +51 -66
  45. package/es/otherUtils.d.ts +12 -9
  46. package/es/otherUtils.js +71 -129
  47. package/es/platform.d.ts +17 -9
  48. package/es/platform.js +78 -85
  49. package/es/select/hooks/useDebouncedSearch.d.ts +4 -1
  50. package/es/select/hooks/useDebouncedSearch.js +39 -53
  51. package/es/select/hooks/useSelectState.d.ts +7 -7
  52. package/es/select/hooks/useSelectState.js +56 -113
  53. package/es/select/index.d.ts +7 -8
  54. package/es/select/types.d.ts +211 -211
  55. package/es/select/utils/filterOptions.d.ts +7 -6
  56. package/es/select/utils/filterOptions.js +26 -31
  57. package/es/select/utils/helpers.d.ts +10 -9
  58. package/es/select/utils/helpers.js +42 -52
  59. package/es/select/utils/index.d.ts +4 -7
  60. package/es/select/utils/sortOptions.d.ts +6 -5
  61. package/es/select/utils/sortOptions.js +19 -31
  62. package/es/select/utils/tagAggregation.d.ts +6 -6
  63. package/es/select/utils/tagAggregation.js +34 -47
  64. package/es/text-input/hooks/useTextInputState.d.ts +6 -2
  65. package/es/text-input/hooks/useTextInputState.js +69 -126
  66. package/es/text-input/types.d.ts +48 -48
  67. package/es/text-input/utils/validation.d.ts +7 -2
  68. package/es/text-input/utils/validation.js +50 -70
  69. package/es/typeUtils.d.ts +11 -8
  70. package/es/typeUtils.js +61 -84
  71. package/es/walletValidity.d.ts +36 -34
  72. package/es/walletValidity.js +332 -456
  73. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js +27 -0
  74. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.js +12 -0
  75. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js +25 -0
  76. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.js +14 -0
  77. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.js +9 -0
  78. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.js +16 -0
  79. package/lib/_virtual/_rolldown/runtime.js +23 -0
  80. package/lib/arrayUtils.d.ts +4 -1
  81. package/lib/arrayUtils.js +14 -39
  82. package/lib/common/stateHelper.d.ts +6 -2
  83. package/lib/common/stateHelper.js +21 -32
  84. package/lib/common/types.d.ts +13 -10
  85. package/lib/componentStorage.d.ts +27 -25
  86. package/lib/componentStorage.js +96 -126
  87. package/lib/constants/index.js +7 -36
  88. package/lib/date.d.ts +6 -3
  89. package/lib/date.js +43 -65
  90. package/lib/document.d.ts +6 -3
  91. package/lib/document.js +46 -62
  92. package/lib/escPosPrinter/EscPosPrinter.js +327 -403
  93. package/lib/escPosPrinter/index.d.ts +9 -9
  94. package/lib/escPosPrinter/index.js +38 -84
  95. package/lib/format.d.ts +12 -11
  96. package/lib/format.js +91 -99
  97. package/lib/image.d.ts +13 -10
  98. package/lib/image.js +48 -74
  99. package/lib/index.d.ts +38 -23
  100. package/lib/index.js +115 -78
  101. package/lib/jsBridge/index.d.ts +8 -4
  102. package/lib/jsBridge/index.js +58 -77
  103. package/lib/jsBridge/regDeviceApi.js +106 -153
  104. package/lib/jsBridge/types.d.ts +95 -115
  105. package/lib/locales.d.ts +11 -8
  106. package/lib/locales.js +79 -90
  107. package/lib/log.d.ts +11 -6
  108. package/lib/log.js +37 -61
  109. package/lib/miniRedux.d.ts +20 -13
  110. package/lib/miniRedux.js +43 -92
  111. package/lib/number-input/hooks/useNumberInputState.d.ts +6 -2
  112. package/lib/number-input/hooks/useNumberInputState.js +71 -81
  113. package/lib/number-input/types.d.ts +88 -88
  114. package/lib/number-input/utils/formatter.d.ts +13 -10
  115. package/lib/number-input/utils/formatter.js +52 -49
  116. package/lib/number-input/utils/validation.d.ts +7 -2
  117. package/lib/number-input/utils/validation.js +50 -52
  118. package/lib/otherUtils.d.ts +12 -9
  119. package/lib/otherUtils.js +86 -98
  120. package/lib/platform.d.ts +17 -9
  121. package/lib/platform.js +85 -122
  122. package/lib/select/hooks/useDebouncedSearch.d.ts +4 -1
  123. package/lib/select/hooks/useDebouncedSearch.js +40 -41
  124. package/lib/select/hooks/useSelectState.d.ts +7 -7
  125. package/lib/select/hooks/useSelectState.js +58 -93
  126. package/lib/select/index.d.ts +7 -8
  127. package/lib/select/types.d.ts +211 -211
  128. package/lib/select/utils/filterOptions.d.ts +7 -6
  129. package/lib/select/utils/filterOptions.js +26 -37
  130. package/lib/select/utils/helpers.d.ts +10 -9
  131. package/lib/select/utils/helpers.js +45 -41
  132. package/lib/select/utils/index.d.ts +4 -7
  133. package/lib/select/utils/sortOptions.d.ts +6 -5
  134. package/lib/select/utils/sortOptions.js +18 -39
  135. package/lib/select/utils/tagAggregation.d.ts +6 -6
  136. package/lib/select/utils/tagAggregation.js +33 -41
  137. package/lib/text-input/hooks/useTextInputState.d.ts +6 -2
  138. package/lib/text-input/hooks/useTextInputState.js +69 -79
  139. package/lib/text-input/types.d.ts +48 -48
  140. package/lib/text-input/utils/validation.d.ts +7 -2
  141. package/lib/text-input/utils/validation.js +49 -58
  142. package/lib/typeUtils.d.ts +11 -8
  143. package/lib/typeUtils.js +68 -73
  144. package/lib/walletValidity.d.ts +36 -34
  145. package/lib/walletValidity.js +345 -317
  146. package/package.json +1 -2
  147. package/es/common/index.d.ts +0 -5
  148. package/es/common/index.js +0 -5
  149. package/es/common/types.js +0 -1
  150. package/es/constants/index.d.ts +0 -7
  151. package/es/firebase/config/index.d.ts +0 -13
  152. package/es/firebase/config/index.js +0 -54
  153. package/es/firebase/index.d.ts +0 -28
  154. package/es/firebase/index.js +0 -232
  155. package/es/jsBridge/types.js +0 -1
  156. package/es/number-input/hooks/index.d.ts +0 -4
  157. package/es/number-input/hooks/index.js +0 -5
  158. package/es/number-input/index.d.ts +0 -14
  159. package/es/number-input/index.js +0 -21
  160. package/es/number-input/types.js +0 -1
  161. package/es/number-input/utils/index.d.ts +0 -7
  162. package/es/number-input/utils/index.js +0 -8
  163. package/es/select/hooks/index.d.ts +0 -5
  164. package/es/select/hooks/index.js +0 -6
  165. package/es/select/index.js +0 -13
  166. package/es/select/types.js +0 -1
  167. package/es/select/utils/index.js +0 -8
  168. package/es/text-input/hooks/index.d.ts +0 -4
  169. package/es/text-input/hooks/index.js +0 -5
  170. package/es/text-input/index.d.ts +0 -14
  171. package/es/text-input/index.js +0 -20
  172. package/es/text-input/types.js +0 -1
  173. package/es/text-input/utils/index.d.ts +0 -5
  174. package/es/text-input/utils/index.js +0 -7
  175. package/lib/common/index.d.ts +0 -5
  176. package/lib/common/index.js +0 -29
  177. package/lib/common/types.js +0 -17
  178. package/lib/constants/index.d.ts +0 -7
  179. package/lib/firebase/config/index.d.ts +0 -13
  180. package/lib/firebase/config/index.js +0 -79
  181. package/lib/firebase/index.d.ts +0 -28
  182. package/lib/firebase/index.js +0 -180
  183. package/lib/jsBridge/types.js +0 -17
  184. package/lib/number-input/hooks/index.d.ts +0 -4
  185. package/lib/number-input/hooks/index.js +0 -29
  186. package/lib/number-input/index.d.ts +0 -14
  187. package/lib/number-input/index.js +0 -41
  188. package/lib/number-input/types.js +0 -17
  189. package/lib/number-input/utils/index.d.ts +0 -7
  190. package/lib/number-input/utils/index.js +0 -39
  191. package/lib/select/hooks/index.d.ts +0 -5
  192. package/lib/select/hooks/index.js +0 -34
  193. package/lib/select/index.js +0 -53
  194. package/lib/select/types.js +0 -17
  195. package/lib/select/utils/index.js +0 -48
  196. package/lib/text-input/hooks/index.d.ts +0 -4
  197. package/lib/text-input/hooks/index.js +0 -29
  198. package/lib/text-input/index.d.ts +0 -14
  199. package/lib/text-input/index.js +0 -35
  200. package/lib/text-input/types.js +0 -17
  201. package/lib/text-input/utils/index.d.ts +0 -5
  202. package/lib/text-input/utils/index.js +0 -32
@@ -1,51 +1,55 @@
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);
1
+ //#region src/select/utils/helpers.ts
2
+ /**
3
+ * 根据值查找选项对象
4
+ * @template T 选项值的类型
5
+ * @param value 选项值
6
+ * @param options 选项列表
7
+ * @returns 找到的选项对象,如果没找到返回 undefined
8
+ */
29
9
  function findOptionByValue(value, options) {
30
- return options.find((opt) => opt.value === value);
10
+ return options.find((opt) => opt.value === value);
31
11
  }
12
+ /**
13
+ * 根据值数组查找选项对象数组
14
+ * @template T 选项值的类型
15
+ * @param values 选项值数组
16
+ * @param options 选项列表
17
+ * @returns 找到的选项对象数组
18
+ */
32
19
  function findOptionsByValues(values, options) {
33
- return values.map((val) => findOptionByValue(val, options)).filter(Boolean);
20
+ return values.map((val) => findOptionByValue(val, options)).filter(Boolean);
34
21
  }
22
+ /**
23
+ * 判断选项是否被选中(单选)
24
+ * @template T 选项值的类型
25
+ * @param optionValue 选项值
26
+ * @param selectedValue 当前选中值
27
+ * @returns 是否选中
28
+ */
35
29
  function isOptionSelected(optionValue, selectedValue) {
36
- return selectedValue !== null && selectedValue !== void 0 && optionValue === selectedValue;
30
+ return selectedValue !== null && selectedValue !== void 0 && optionValue === selectedValue;
37
31
  }
32
+ /**
33
+ * 判断选项是否被选中(多选)
34
+ * @template T 选项值的类型
35
+ * @param optionValue 选项值
36
+ * @param selectedValues 当前选中值数组
37
+ * @returns 是否选中
38
+ */
38
39
  function isOptionSelectedInMultiple(optionValue, selectedValues) {
39
- return selectedValues.includes(optionValue);
40
+ return selectedValues.includes(optionValue);
40
41
  }
42
+ /**
43
+ * 生成唯一 ID
44
+ * @param prefix ID 前缀
45
+ * @returns 唯一 ID
46
+ */
41
47
  function generateId(prefix = "select") {
42
- return `${prefix}-${Math.random().toString(36).substr(2, 9)}`;
48
+ return `${prefix}-${Math.random().toString(36).substr(2, 9)}`;
43
49
  }
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
- });
50
+ //#endregion
51
+ exports.findOptionByValue = findOptionByValue;
52
+ exports.findOptionsByValues = findOptionsByValues;
53
+ exports.generateId = generateId;
54
+ exports.isOptionSelected = isOptionSelected;
55
+ exports.isOptionSelectedInMultiple = isOptionSelectedInMultiple;
@@ -1,7 +1,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';
1
+ import { calculateTagDisplay } from "./tagAggregation.js";
2
+ import { defaultFilterOption, filterOptions } from "./filterOptions.js";
3
+ import { sortOptions } from "./sortOptions.js";
4
+ import { findOptionByValue, findOptionsByValues, generateId, isOptionSelected, isOptionSelectedInMultiple } from "./helpers.js";
@@ -1,7 +1,6 @@
1
- /**
2
- * 选项排序工具函数
3
- */
4
- import type { SelectOption, SortDirection } from '../types';
1
+ import { SelectOption, SortDirection } from "../types.js";
2
+
3
+ //#region src/select/utils/sortOptions.d.ts
5
4
  /**
6
5
  * 排序选项列表
7
6
  * @template T 选项值的类型
@@ -9,4 +8,6 @@ import type { SelectOption, SortDirection } from '../types';
9
8
  * @param direction 排序方向('asc' 升序 | 'desc' 降序)
10
9
  * @returns 排序后的选项列表(新数组)
11
10
  */
12
- export declare function sortOptions<T = string | number>(options: SelectOption<T>[], direction?: SortDirection): SelectOption<T>[];
11
+ declare function sortOptions<T = string | number>(options: SelectOption<T>[], direction?: SortDirection): SelectOption<T>[];
12
+ //#endregion
13
+ export { sortOptions };
@@ -1,41 +1,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/sortOptions.ts
20
- var sortOptions_exports = {};
21
- __export(sortOptions_exports, {
22
- sortOptions: () => sortOptions
23
- });
24
- module.exports = __toCommonJS(sortOptions_exports);
1
+ //#region src/select/utils/sortOptions.ts
2
+ /**
3
+ * 排序选项列表
4
+ * @template T 选项值的类型
5
+ * @param options 原始选项列表
6
+ * @param direction 排序方向('asc' 升序 | 'desc' 降序)
7
+ * @returns 排序后的选项列表(新数组)
8
+ */
25
9
  function sortOptions(options, direction = "asc") {
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;
10
+ const sortedOptions = [...options];
11
+ sortedOptions.sort((a, b) => {
12
+ const labelA = a.label.toLowerCase();
13
+ const labelB = b.label.toLowerCase();
14
+ if (direction === "asc") return labelA.localeCompare(labelB);
15
+ else return labelB.localeCompare(labelA);
16
+ });
17
+ return sortedOptions;
37
18
  }
38
- // Annotate the CommonJS export names for ESM import in node:
39
- 0 && (module.exports = {
40
- sortOptions
41
- });
19
+ //#endregion
20
+ exports.sortOptions = sortOptions;
@@ -1,8 +1,6 @@
1
- /**
2
- * 标签聚合工具函数
3
- * 用于多选下拉组件的标签显示逻辑
4
- */
5
- import type { SelectOption, TagDisplayInfo } from '../types';
1
+ import { SelectOption, TagDisplayInfo } from "../types.js";
2
+
3
+ //#region src/select/utils/tagAggregation.d.ts
6
4
  /**
7
5
  * 计算需要显示的标签和聚合信息
8
6
  * @template T 选项值的类型
@@ -22,4 +20,6 @@ import type { SelectOption, TagDisplayInfo } from '../types';
22
20
  * // }
23
21
  * ```
24
22
  */
25
- export declare function calculateTagDisplay<T = string | number>(selectedValues: T[], options: SelectOption<T>[], maxTagCount: number): TagDisplayInfo<T>;
23
+ declare function calculateTagDisplay<T = string | number>(selectedValues: T[], options: SelectOption<T>[], maxTagCount: number): TagDisplayInfo<T>;
24
+ //#endregion
25
+ export { calculateTagDisplay };
@@ -1,43 +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/select/utils/tagAggregation.ts
20
- var tagAggregation_exports = {};
21
- __export(tagAggregation_exports, {
22
- calculateTagDisplay: () => calculateTagDisplay
23
- });
24
- module.exports = __toCommonJS(tagAggregation_exports);
1
+ //#region src/select/utils/tagAggregation.ts
2
+ /**
3
+ * 计算需要显示的标签和聚合信息
4
+ * @template T 选项值的类型
5
+ * @param selectedValues 当前选中的值数组
6
+ * @param options 所有选项列表
7
+ * @param maxTagCount 最多显示的标签数量
8
+ * @returns 标签显示信息
9
+ *
10
+ * @example
11
+ * ```tsx
12
+ * const tagInfo = calculateTagDisplay(['a', 'b', 'c', 'd'], options, 2);
13
+ * // 返回:
14
+ * // {
15
+ * // visibleTags: [option_a, option_b],
16
+ * // hiddenTags: [option_c, option_d],
17
+ * // hiddenCount: 2
18
+ * // }
19
+ * ```
20
+ */
25
21
  function calculateTagDisplay(selectedValues, options, maxTagCount) {
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
- };
22
+ const selectedOptions = selectedValues.map((v) => options.find((opt) => opt.value === v)).filter(Boolean);
23
+ if (selectedOptions.length <= maxTagCount) return {
24
+ visibleTags: selectedOptions,
25
+ hiddenTags: [],
26
+ hiddenCount: 0
27
+ };
28
+ return {
29
+ visibleTags: selectedOptions.slice(0, maxTagCount),
30
+ hiddenTags: selectedOptions.slice(maxTagCount),
31
+ hiddenCount: selectedOptions.length - maxTagCount
32
+ };
39
33
  }
40
- // Annotate the CommonJS export names for ESM import in node:
41
- 0 && (module.exports = {
42
- calculateTagDisplay
43
- });
34
+ //#endregion
35
+ exports.calculateTagDisplay = calculateTagDisplay;
@@ -1,4 +1,6 @@
1
- import type { BaseTextInputProps, TextInputState } from '../types';
1
+ import { BaseTextInputProps, TextInputState } from "../types.js";
2
+
3
+ //#region src/text-input/hooks/useTextInputState.d.ts
2
4
  /**
3
5
  * 文本输入状态管理 Hook
4
6
  *
@@ -21,4 +23,6 @@ import type { BaseTextInputProps, TextInputState } from '../types';
21
23
  * // 非受控模式
22
24
  * const state = useTextInputState({ defaultValue: 'hello' });
23
25
  */
24
- export declare function useTextInputState(props: BaseTextInputProps): TextInputState;
26
+ declare function useTextInputState(props: BaseTextInputProps): TextInputState;
27
+ //#endregion
28
+ export { useTextInputState };
@@ -1,81 +1,71 @@
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");
1
+ require("../../_virtual/_rolldown/runtime.js");
2
+ const require_validation = require("../utils/validation.js");
3
+ let react = require("react");
4
+ //#region src/text-input/hooks/useTextInputState.ts
5
+ /**
6
+ * 文本输入状态管理 Hook
7
+ *
8
+ * 管理组件的内部状态,包括:
9
+ * - 值管理(受控/非受控模式)
10
+ * - 校验状态管理
11
+ * - 事件处理函数封装
12
+ *
13
+ * 支持受控和非受控两种模式:
14
+ * - 受控模式:value 由外部传入,组件不维护内部状态
15
+ * - 非受控模式:使用 defaultValue,组件维护内部状态
16
+ *
17
+ * @param props 组件 Props(包含校验配置)
18
+ * @returns 文本输入状态对象
19
+ *
20
+ * @example
21
+ * // 受控模式
22
+ * const state = useTextInputState({ value: 'hello', onChange: (v) => console.log(v) });
23
+ *
24
+ * // 非受控模式
25
+ * const state = useTextInputState({ defaultValue: 'hello' });
26
+ */
27
27
  function useTextInputState(props) {
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
- };
28
+ const isControlled = props.value !== void 0;
29
+ const [innerValue, setInnerValue] = (0, react.useState)(props.defaultValue || "");
30
+ const [isTouched, setIsTouched] = (0, react.useState)(false);
31
+ const [isValid, setIsValid] = (0, react.useState)(true);
32
+ const [errors, setErrors] = (0, react.useState)([]);
33
+ const currentValue = isControlled ? props.value : innerValue;
34
+ return {
35
+ value: currentValue,
36
+ isTouched,
37
+ isValid,
38
+ errors,
39
+ handleChange: (0, react.useCallback)((newValue) => {
40
+ var _props$onChange;
41
+ if (!isControlled) setInnerValue(newValue);
42
+ if (props.validateTrigger === "onChange" || props.validateTrigger === "both") {
43
+ var _props$onValidate;
44
+ const validation = require_validation.validateValue(newValue, props);
45
+ setIsValid(validation.isValid);
46
+ setErrors(validation.errors);
47
+ (_props$onValidate = props.onValidate) === null || _props$onValidate === void 0 || _props$onValidate.call(props, validation.isValid, validation.errors);
48
+ }
49
+ (_props$onChange = props.onChange) === null || _props$onChange === void 0 || _props$onChange.call(props, newValue);
50
+ }, [isControlled, props]),
51
+ handleBlur: (0, react.useCallback)(() => {
52
+ var _props$onBlur;
53
+ setIsTouched(true);
54
+ if (props.validateTrigger !== "onChange") {
55
+ var _props$onValidate2;
56
+ const validation = require_validation.validateValue(currentValue || "", props);
57
+ setIsValid(validation.isValid);
58
+ setErrors(validation.errors);
59
+ (_props$onValidate2 = props.onValidate) === null || _props$onValidate2 === void 0 || _props$onValidate2.call(props, validation.isValid, validation.errors);
60
+ }
61
+ (_props$onBlur = props.onBlur) === null || _props$onBlur === void 0 || _props$onBlur.call(props, currentValue || "");
62
+ }, [currentValue, props]),
63
+ handleFocus: (0, react.useCallback)(() => {
64
+ var _props$onFocus;
65
+ setIsTouched(true);
66
+ (_props$onFocus = props.onFocus) === null || _props$onFocus === void 0 || _props$onFocus.call(props);
67
+ }, [props])
68
+ };
77
69
  }
78
- // Annotate the CommonJS export names for ESM import in node:
79
- 0 && (module.exports = {
80
- useTextInputState
81
- });
70
+ //#endregion
71
+ exports.useTextInputState = useTextInputState;
@@ -1,56 +1,56 @@
1
- /**
2
- * 文本输入组件公共类型定义
3
- * 供 PisellSingleLineText、PisellLongText、PisellPhone、PisellEmail、PisellUrl 等组件使用
4
- */
5
- export type { DisplayState, ValidationResult } from '../common';
1
+ import { DisplayState, ValidationResult } from "../common/types.js";
2
+
3
+ //#region src/text-input/types.d.ts
6
4
  /**
7
5
  * 文本输入状态 Hook 返回值
8
6
  */
9
- export interface TextInputState {
10
- /**
11
- * 当前值
12
- */
13
- value: string | undefined;
14
- /**
15
- * 是否已被触摸(交互过)
16
- */
17
- isTouched: boolean;
18
- /**
19
- * 是否校验通过
20
- */
21
- isValid: boolean;
22
- /**
23
- * 错误信息数组
24
- */
25
- errors: string[];
26
- /**
27
- * 值变更处理函数
28
- */
29
- handleChange: (value: string) => void;
30
- /**
31
- * 失焦处理函数
32
- */
33
- handleBlur: () => void;
34
- /**
35
- * 聚焦处理函数
36
- */
37
- handleFocus: () => void;
7
+ interface TextInputState {
8
+ /**
9
+ * 当前值
10
+ */
11
+ value: string | undefined;
12
+ /**
13
+ * 是否已被触摸(交互过)
14
+ */
15
+ isTouched: boolean;
16
+ /**
17
+ * 是否校验通过
18
+ */
19
+ isValid: boolean;
20
+ /**
21
+ * 错误信息数组
22
+ */
23
+ errors: string[];
24
+ /**
25
+ * 值变更处理函数
26
+ */
27
+ handleChange: (value: string) => void;
28
+ /**
29
+ * 失焦处理函数
30
+ */
31
+ handleBlur: () => void;
32
+ /**
33
+ * 聚焦处理函数
34
+ */
35
+ handleFocus: () => void;
38
36
  }
39
37
  /**
40
38
  * 基础文本输入 Props(供校验和状态管理使用)
41
39
  */
42
- export interface BaseTextInputProps {
43
- value?: string;
44
- defaultValue?: string;
45
- required?: boolean;
46
- minLength?: number;
47
- maxLength?: number;
48
- pattern?: string | RegExp;
49
- validator?: (value: string) => boolean | string;
50
- validateTrigger?: 'onChange' | 'onBlur' | 'both';
51
- errorMessage?: string;
52
- onChange?: (value: string) => void;
53
- onBlur?: (value: string) => void;
54
- onFocus?: () => void;
55
- onValidate?: (isValid: boolean, errors: string[]) => void;
40
+ interface BaseTextInputProps {
41
+ value?: string;
42
+ defaultValue?: string;
43
+ required?: boolean;
44
+ minLength?: number;
45
+ maxLength?: number;
46
+ pattern?: string | RegExp;
47
+ validator?: (value: string) => boolean | string;
48
+ validateTrigger?: 'onChange' | 'onBlur' | 'both';
49
+ errorMessage?: string;
50
+ onChange?: (value: string) => void;
51
+ onBlur?: (value: string) => void;
52
+ onFocus?: () => void;
53
+ onValidate?: (isValid: boolean, errors: string[]) => void;
56
54
  }
55
+ //#endregion
56
+ export { BaseTextInputProps, TextInputState };
@@ -1,4 +1,7 @@
1
- import type { BaseTextInputProps, ValidationResult } from '../types';
1
+ import { ValidationResult } from "../../common/types.js";
2
+ import { BaseTextInputProps } from "../types.js";
3
+
4
+ //#region src/text-input/utils/validation.d.ts
2
5
  /**
3
6
  * 校验文本输入值
4
7
  *
@@ -20,4 +23,6 @@ import type { BaseTextInputProps, ValidationResult } from '../types';
20
23
  * validateValue('', { required: true })
21
24
  * // { isValid: false, errors: ['此字段为必填项'] }
22
25
  */
23
- export declare function validateValue(value: string, props: BaseTextInputProps): ValidationResult;
26
+ declare function validateValue(value: string, props: BaseTextInputProps): ValidationResult;
27
+ //#endregion
28
+ export { validateValue };