Skip to content

Commit bc32156

Browse files
committed
feat: update jsdoc
1 parent 4bf2fe4 commit bc32156

File tree

9 files changed

+185
-235
lines changed

9 files changed

+185
-235
lines changed

packages/plugin/src/plugins/searchItems.ts

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,15 @@ import type {
1010

1111
export interface PluginOptions {
1212
/**
13-
* **EN:** The name of the field used for list item labels, used to search list items. Default is
14-
* `label`.
15-
*
16-
* **CN:** 列表项标签(名称)的字段名,用于搜索列表项,默认是`label`。
13+
* - **EN:** The name of the field used for list item labels, used to search list items. Default is
14+
* `label`.
15+
* - **CN:** 列表项标签(名称)的字段名,用于搜索列表项,默认是`label`。
1716
*/
1817
labelField?: string;
1918

2019
/**
21-
* **EN:** Whether to ignore case when searching for list items. Default is `true`.
22-
*
23-
* **CN:** 搜索列表项时是否忽略大小写,默认是`true`。
20+
* - **EN:** Whether to ignore case when searching for list items. Default is `true`.
21+
* - **CN:** 搜索列表项时是否忽略大小写,默认是`true`。
2422
*/
2523
ignoreCase?: boolean;
2624
}
@@ -90,16 +88,15 @@ declare module 'enum-plus-extend' {
9088
V extends EnumValue = ValueTypeFromSingleInit<T[K], K>,
9189
> {
9290
/**
93-
* **EN:** Search for list items, returns true if the item matches the search criteria, false
94-
* otherwise. The function supports searching by specific field that is specified in options. If
95-
* the search string is empty, it returns all items.
91+
* - **EN:** Search for list items, returns true if the item matches the search criteria, false
92+
* otherwise. The function supports searching by specific field that is specified in options.
93+
* If the search string is empty, it returns all items.
9694
*
97-
* This function is compatible with the `Ant Design` specification, and can be as `filterOption`
98-
* property of components like `Select`, `AutoComplete`, `Transfer`, `Mentions`, etc.
95+
* This function is compatible with the `Ant Design` specification, and can be as `filterOption`
96+
* property of components like `Select`, `AutoComplete`, `Transfer`, `Mentions`, etc.
97+
* - **CN:** 搜索列表项,如果项匹配搜索条件,则返回true,否则返回false。还可以在选项中设置搜索字段,支持按指定的字段进行搜索。如果搜索字符串为空,则返回所有项。
9998
*
100-
* **CN:** 搜索列表项,如果项匹配搜索条件,则返回true,否则返回false。还可以在选项中设置搜索字段,支持按指定的字段进行搜索。如果搜索字符串为空,则返回所有项。
101-
*
102-
* 该函数兼容`Ant Design`规范,可以作为`Select`、`AutoComplete`、`Transfer`、`Mentions`等组件的`filterOption`属性。
99+
* 该函数兼容`Ant Design`规范,可以作为`Select`、`AutoComplete`、`Transfer`、`Mentions`等组件的`filterOption`属性。
103100
*
104101
* @param search The search string | 搜索字符串
105102
* @param item The item to search for | 要搜索的项
@@ -109,15 +106,13 @@ declare module 'enum-plus-extend' {
109106
*/
110107
searchItems: (
111108
/**
112-
* **EN:** The search string, if empty, return all items
113-
*
114-
* **CN:** 搜索字符串,如果为空,则返回所有项
109+
* - **EN:** The search string, if empty, return all items
110+
* - **CN:** 搜索字符串,如果为空,则返回所有项
115111
*/
116112
search?: string,
117113
/**
118-
* **EN:** The item to search for
119-
*
120-
* **CN:** 待搜索的列表项
114+
* - **EN:** The item to search for
115+
* - **CN:** 待搜索的列表项
121116
*/
122117
item?: V | Record<string, unknown> | EnumItemClass<EnumItemInit<V>, K, V>
123118
) => boolean;

packages/plugin/src/plugins/toSelect.ts

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -149,31 +149,26 @@ export interface ToSelectConfig<
149149
V extends EnumValue = ValueTypeFromSingleInit<T[K], K>,
150150
> {
151151
/**
152-
* **EN:** The name of the value field in the output object, or a function to get the field name,
153-
* default is `value`
154-
*
155-
* **CN:** 输出对象的value字段名,或者获取字段名的函数,默认为 `value`
152+
* - **EN:** The name of the value field in the output object, or a function to get the field name,
153+
* default is `value`
154+
* - **CN:** 输出对象的value字段名,或者获取字段名的函数,默认为 `value`
156155
*/
157156
valueField?: FOV;
158157
/**
159-
* **EN:** The name of the label field in the output object, or a function to get the field name,
160-
* default is `label`
161-
*
162-
* **CN:** 输出对象的label字段名,或者获取字段名的函数,默认为 `label`
158+
* - **EN:** The name of the label field in the output object, or a function to get the field name,
159+
* default is `label`
160+
* - **CN:** 输出对象的label字段名,或者获取字段名的函数,默认为 `label`
163161
*/
164162
labelField?: FOL;
165163
}
166164

167165
export interface FirstOptionConfig<V = EnumValue, FOV extends string = string, FOL extends string = string> {
168166
/**
169-
* **EN:** Add a default option at the top
170-
*
167+
* - **EN:** Add a default option at the top
171168
* - `true`: the option uses the default value, `value` is `''`, `label` is `'All'`;
172169
* - `false`: the default option is not added;
173170
* - `object`: custom default option, must be an object with `key`, `value`, and `label` properties
174-
*
175-
* **CN:** 在头部添加一个默认选项
176-
*
171+
* - **CN:** 在头部添加一个默认选项
177172
* - `true`: 选项使用默认值,`value`为`''`,`label`为`'全部'`
178173
* - `false`: 不添加默认选项
179174
* - `object`: 自定义默认选项

src/enum-collection.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ import type {
2121
import { ENUM_COLLECTION, ITEMS, KEYS } from './utils';
2222

2323
/**
24-
* **EN:** Enum collection extension base class, used to extend the Enums
25-
*
26-
* **CN:** 枚举集合扩展基类,用于扩展枚举
24+
* - **EN:** Enum collection extension base class, used to extend the Enums
25+
* - **CN:** 枚举集合扩展基类,用于扩展枚举
2726
*/
2827
// @ts-expect-error: because don't know which methods are added
2928
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
@@ -33,9 +32,8 @@ export class EnumExtensionClass<
3332
V extends EnumValue = ValueTypeFromSingleInit<T[K], K>,
3433
> implements EnumExtension<T, K, V> {}
3534
/**
36-
* **EN:** Enum collection
37-
*
38-
* **CN:** 枚举项集合
35+
* - **EN:** Enum collection
36+
* - **CN:** 枚举项集合
3937
*/
4038
export class EnumCollectionClass<
4139
T extends EnumInit<K, V>,
@@ -49,9 +47,8 @@ export class EnumCollectionClass<
4947
readonly items!: EnumItemsArray<T, K, V>;
5048
readonly keys!: K[];
5149
/**
52-
* **EN:** A boolean value indicates that this is an enum collection instance.
53-
*
54-
* **CN:** 布尔值,表示这是一个枚举集合实例
50+
* - **EN:** A boolean value indicates that this is an enum collection instance.
51+
* - **CN:** 布尔值,表示这是一个枚举集合实例
5552
*/
5653
readonly [ENUM_COLLECTION] = true;
5754
[Symbol.hasInstance](this: EnumCollectionClass<T, K, V>, instance: unknown): boolean {
@@ -66,7 +63,7 @@ export class EnumCollectionClass<
6663
* a custom `localize` function is set, the return value may vary depending on the implementation
6764
* of the method.
6865
*
69-
* **CN:** 枚举集合显示名称,支持本地化。注意,通常情况下返回的是字符串,但如果设置了自定义的 `localize` 函数,则返回值可能有所不同,取决于方法的实现
66+
* - **CN:** 枚举集合显示名称,支持本地化。注意,通常情况下返回的是字符串,但如果设置了自定义的 `localize` 函数,则返回值可能有所不同,取决于方法的实现
7067
*
7168
* @returns {string | undefined} The localized name of the enum collection, or undefined if not
7269
* set.

src/enum-item.ts

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,38 +16,33 @@ export class EnumItemClass<
1616
V extends EnumValue = ValueTypeFromSingleInit<T, K>,
1717
> {
1818
/**
19-
* **EN:** The value of the enum item
20-
*
21-
* **CN:** 枚举项的值
19+
* - **EN:** The value of the enum item
20+
* - **CN:** 枚举项的值
2221
*/
2322
readonly value: V;
2423

2524
/**
26-
* **EN:** The label of the enum item (also known as display name)
27-
*
28-
* **CN:** 枚举项的标签(亦称显示名称)
25+
* - **EN:** The label of the enum item (also known as display name)
26+
* - **CN:** 枚举项的标签(亦称显示名称)
2927
*/
3028
readonly label: string;
3129

3230
/**
33-
* **EN:** The key of the enum item, which is the key in the initialization object when creating
34-
* the enum collection.
35-
*
36-
* **CN:** 枚举项的键,即创建枚举集合时初始化对象中的键
31+
* - **EN:** The key of the enum item, which is the key in the initialization object when creating
32+
* the enum collection.
33+
* - **CN:** 枚举项的键,即创建枚举集合时初始化对象中的键
3734
*/
3835
readonly key: K;
3936

4037
/**
41-
* **EN:** The original initialization object of the enum item, which is the sub-object of a
42-
* single enum item when creating the enum collection.
43-
*
44-
* **CN:** 枚举项的原始初始化对象,即创建枚举集合时单个枚举项的子对象
38+
* - **EN:** The original initialization object of the enum item, which is the sub-object of a
39+
* single enum item when creating the enum collection.
40+
* - **CN:** 枚举项的原始初始化对象,即创建枚举集合时单个枚举项的子对象
4541
*/
4642
readonly raw: T;
4743
/**
48-
* **EN:** A boolean value indicates that this is an enum item instance.
49-
*
50-
* **CN:** 布尔值,表示这是一个枚举项实例
44+
* - **EN:** A boolean value indicates that this is an enum item instance.
45+
* - **CN:** 布尔值,表示这是一个枚举项实例
5146
*/
5247
readonly [ENUM_ITEM] = true;
5348
/**

src/enum-values.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,8 @@ export class EnumItemsArray<
3838
{
3939
private _raw: T;
4040
/**
41-
* **EN:** A boolean value indicates that this is an enum items array.
42-
*
43-
* **CN:** 布尔值,表示这是一个枚举项数组
41+
* - **EN:** A boolean value indicates that this is an enum items array.
42+
* - **CN:** 布尔值,表示这是一个枚举项数组
4443
*/
4544
readonly [ENUM_ITEMS] = true;
4645

src/enum.ts

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@ import { defaultLocalize } from './utils';
1515
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1616
// let enumExtensions: any;
1717
/**
18-
* **EN:** Generate an enum collection, the enum value supports `number` and `string` types, and the
19-
* enum name supports localization solutions
20-
*
21-
* **CN:** 生成一个枚举集合,枚举值支持`number`和`string`类型,枚举名称支持本地化方案
18+
* - **EN:** Generate an enum collection, the enum value supports `number` and `string` types, and the
19+
* enum name supports localization solutions
20+
* - **CN:** 生成一个枚举集合,枚举值支持`number`和`string`类型,枚举名称支持本地化方案
2221
*
2322
* @example
2423
* const Week = Enum({
@@ -36,9 +35,8 @@ export function Enum<
3635
V extends EnumValue = ValueTypeFromSingleInit<T[K], K>,
3736
>(init: T, options?: EnumInitOptions<T, K, V>): IEnum<T, K, V> & EnumExtension<T, K, V>;
3837
/**
39-
* **EN:** Generate an enum based on an object array
40-
*
41-
* **CN:** 基于对象数组生成枚举
38+
* - **EN:** Generate an enum based on an object array
39+
* - **CN:** 基于对象数组生成枚举
4240
*
4341
* @example
4442
* const Week = Enum([
@@ -72,27 +70,25 @@ export function Enum<
7270
}
7371

7472
/**
75-
* **EN:** Global localization function, used to convert enum item text to localized text. Only need
76-
* to be set once, effective globally. This method need to be set at the project entry, before
77-
* running any Enum instance
73+
* - **EN:** Global localization function, used to convert enum item text to localized text. Only need
74+
* to be set once, effective globally. This method need to be set at the project entry, before
75+
* running any Enum instance
7876
*
7977
* If you want to provide a custom localization function, be sure to resolve and localize the
8078
* following built-in resources:
8179
*
8280
* - `enum-plus.options.all` => `All`
83-
*
84-
* **CN:** 全局本地化函数,用于把枚举项文本转换为本地化文本。只需要设置一次,全局生效。需要在项目入口处设置,且在运行任何Enum实例之前
81+
* - **CN:** 全局本地化函数,用于把枚举项文本转换为本地化文本。只需要设置一次,全局生效。需要在项目入口处设置,且在运行任何Enum实例之前
8582
*
8683
* 如果要提供自定义的本地化函数,请务必解析并本地化以下内置资源:
8784
*
8885
* - `enum-plus.options.all` => `All`
8986
*/
9087
Enum.localize = defaultLocalize;
9188
/**
92-
* **EN:** Add global extension methods to the enum, and all enum instances will have these new
93-
* extension methods
94-
*
95-
* **CN:** 为枚举增加全局扩展方法,所有枚举实例都会具有这些新扩展方法
89+
* - **EN:** Add global extension methods to the enum, and all enum instances will have these new
90+
* extension methods
91+
* - **CN:** 为枚举增加全局扩展方法,所有枚举实例都会具有这些新扩展方法
9692
*
9793
* @param obj Extension content, must be an object | 扩展内容,必须是一个对象
9894
*/
@@ -103,10 +99,9 @@ Enum.extends = function (obj: Record<string, unknown> | undefined) {
10399
Object.assign(EnumExtensionClass.prototype, obj);
104100
};
105101
/**
106-
* **EN:** Install a plugin that enhances the functionality of the Enum class by adding new methods
107-
* or properties.
108-
*
109-
* **CN:** 安装一个插件,通过添加新的方法或属性来增强Enum类的功能
102+
* - **EN:** Install a plugin that enhances the functionality of the Enum class by adding new methods
103+
* or properties.
104+
* - **CN:** 安装一个插件,通过添加新的方法或属性来增强Enum类的功能
110105
*
111106
* @param plugin The plugin to install | 要安装的插件
112107
* @param options The options for the plugin | 插件的选项
@@ -139,10 +134,9 @@ function getInitMapFromArray<
139134
}
140135

141136
/**
142-
* **EN:** Represent the Enum plugin that enhances the functionality of the global Enum by adding
143-
* new methods or properties.
144-
*
145-
* **CN:** 表示增强Enum类功能的插件,通过添加新方法或属性
137+
* - **EN:** Represent the Enum plugin that enhances the functionality of the global Enum by adding
138+
* new methods or properties.
139+
* - **CN:** 表示增强Enum类功能的插件,通过添加新方法或属性
146140
*
147141
* @param options The options for the plugin | 插件的选项
148142
* @param Enum The Enum global method | Enum全局方法

src/extension.d.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
11
declare module 'enum-plus-extend' {
22
/**
3-
* **EN:** Global extension of the enumeration, which can be used to add global extension methods
4-
*
5-
* **CN:** 枚举的全局扩展,可以用来添加全局扩展方法
3+
* - **EN:** Global extension of the enumeration, which can be used to add global extension methods
4+
* - **CN:** 枚举的全局扩展,可以用来添加全局扩展方法
65
*/
76
// eslint-disable-next-line @typescript-eslint/no-empty-interface, @typescript-eslint/no-unused-vars
87
interface EnumExtension<T, K, V> {}
98
/**
10-
* **EN:** Enum global localization extension
11-
*
12-
* **CN:** 枚举本地化的全局扩展
9+
* - **EN:** Enum global localization extension
10+
* - **CN:** 枚举本地化的全局扩展
1311
*/
1412
interface EnumLocaleExtends {
1513
/**
16-
* **EN:** Key values of the localized text of the enumeration, which can be used to enhance the
17-
* intelligent prompt of the editor
18-
*
19-
* **CN:** 枚举本地化文本的Key值,可以用来增强编辑器的智能提示
14+
* - **EN:** Key values of the localized text of the enumeration, which can be used to enhance the
15+
* intelligent prompt of the editor
16+
* - **CN:** 枚举本地化文本的Key值,可以用来增强编辑器的智能提示
2017
*/
2118
LocaleKeys: BuiltInLocaleKeys;
2219
}

0 commit comments

Comments
 (0)