@clownlee/cores 1.0.8 → 1.0.10
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.
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { SelectInstance } from 'element-plus';
|
|
2
|
+
import { SelectLoadMoreProps, SelectOption } from './types';
|
|
3
|
+
|
|
4
|
+
declare function __VLS_template(): {
|
|
5
|
+
option?(_: {
|
|
6
|
+
item: SelectOption & {
|
|
7
|
+
[x: string]: any;
|
|
8
|
+
value?: string | number | undefined;
|
|
9
|
+
label?: string | undefined;
|
|
10
|
+
id?: string | number | undefined;
|
|
11
|
+
name?: string | undefined;
|
|
12
|
+
};
|
|
13
|
+
}): any;
|
|
14
|
+
};
|
|
15
|
+
declare const __VLS_component: import('vue').DefineComponent<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<SelectLoadMoreProps>, {
|
|
16
|
+
modelValue: undefined;
|
|
17
|
+
options: () => never[];
|
|
18
|
+
loadMore: undefined;
|
|
19
|
+
pageSize: number;
|
|
20
|
+
threshold: number;
|
|
21
|
+
loadingText: string;
|
|
22
|
+
getOptionKey: (item: SelectOption) => string;
|
|
23
|
+
getOptionLabel: (item: SelectOption) => string;
|
|
24
|
+
getOptionValue: (item: SelectOption) => string | number;
|
|
25
|
+
getOptionProps: () => {};
|
|
26
|
+
popperClass: string;
|
|
27
|
+
autoLoad: boolean;
|
|
28
|
+
}>>, {
|
|
29
|
+
reset: () => void;
|
|
30
|
+
refresh: () => Promise<void>;
|
|
31
|
+
loadMore: () => Promise<void>;
|
|
32
|
+
selectRef: import('vue').Ref<SelectInstance | undefined, SelectInstance | undefined>;
|
|
33
|
+
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
34
|
+
"update:modelValue": (value: string | number | (string | number)[] | undefined) => void;
|
|
35
|
+
change: (value: string | number | (string | number)[] | undefined) => void;
|
|
36
|
+
"visible-change": (visible: boolean) => void;
|
|
37
|
+
"load-error": (error: any) => void;
|
|
38
|
+
}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<SelectLoadMoreProps>, {
|
|
39
|
+
modelValue: undefined;
|
|
40
|
+
options: () => never[];
|
|
41
|
+
loadMore: undefined;
|
|
42
|
+
pageSize: number;
|
|
43
|
+
threshold: number;
|
|
44
|
+
loadingText: string;
|
|
45
|
+
getOptionKey: (item: SelectOption) => string;
|
|
46
|
+
getOptionLabel: (item: SelectOption) => string;
|
|
47
|
+
getOptionValue: (item: SelectOption) => string | number;
|
|
48
|
+
getOptionProps: () => {};
|
|
49
|
+
popperClass: string;
|
|
50
|
+
autoLoad: boolean;
|
|
51
|
+
}>>> & Readonly<{
|
|
52
|
+
"onUpdate:modelValue"?: ((value: string | number | (string | number)[] | undefined) => any) | undefined;
|
|
53
|
+
onChange?: ((value: string | number | (string | number)[] | undefined) => any) | undefined;
|
|
54
|
+
"onVisible-change"?: ((visible: boolean) => any) | undefined;
|
|
55
|
+
"onLoad-error"?: ((error: any) => any) | undefined;
|
|
56
|
+
}>, {
|
|
57
|
+
modelValue: string | number | Array<string | number>;
|
|
58
|
+
popperClass: string;
|
|
59
|
+
pageSize: number;
|
|
60
|
+
loadingText: string;
|
|
61
|
+
options: SelectOption[];
|
|
62
|
+
getOptionProps: (item: SelectOption) => Record<string, any>;
|
|
63
|
+
loadMore: import('./types').LoadMoreFn;
|
|
64
|
+
threshold: number;
|
|
65
|
+
getOptionKey: (item: SelectOption) => string | number;
|
|
66
|
+
getOptionLabel: (item: SelectOption) => string;
|
|
67
|
+
getOptionValue: (item: SelectOption) => string | number;
|
|
68
|
+
autoLoad: boolean;
|
|
69
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
70
|
+
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
|
|
71
|
+
export default _default;
|
|
72
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
73
|
+
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
74
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
75
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
76
|
+
} : {
|
|
77
|
+
type: import('vue').PropType<T[K]>;
|
|
78
|
+
required: true;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
type __VLS_WithDefaults<P, D> = {
|
|
82
|
+
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
|
|
83
|
+
default: D[K];
|
|
84
|
+
}> : P[K];
|
|
85
|
+
};
|
|
86
|
+
type __VLS_Prettify<T> = {
|
|
87
|
+
[K in keyof T]: T[K];
|
|
88
|
+
} & {};
|
|
89
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
90
|
+
new (): {
|
|
91
|
+
$slots: S;
|
|
92
|
+
};
|
|
93
|
+
};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { SelectInstance } from 'element-plus';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 选项数据类型
|
|
5
|
+
*/
|
|
6
|
+
export interface SelectOption {
|
|
7
|
+
/** 选项值 */
|
|
8
|
+
value?: string | number;
|
|
9
|
+
/** 选项标签 */
|
|
10
|
+
label?: string;
|
|
11
|
+
/** 选项 ID(当 value 不存在时使用) */
|
|
12
|
+
id?: string | number;
|
|
13
|
+
/** 选项名称(当 label 不存在时使用) */
|
|
14
|
+
name?: string;
|
|
15
|
+
/** 其他自定义属性 */
|
|
16
|
+
[key: string]: any;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* 加载更多函数的参数
|
|
20
|
+
*/
|
|
21
|
+
export interface LoadMoreParams {
|
|
22
|
+
/** 当前页码 */
|
|
23
|
+
page: number;
|
|
24
|
+
/** 每页数量 */
|
|
25
|
+
pageSize: number;
|
|
26
|
+
/** 搜索关键词(如果有) */
|
|
27
|
+
keyword?: string | number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* 加载更多函数的返回值
|
|
31
|
+
*/
|
|
32
|
+
export interface LoadMoreResult {
|
|
33
|
+
/** 数据列表 */
|
|
34
|
+
data: SelectOption[];
|
|
35
|
+
/** 是否还有更多数据(可选,如果不提供则根据 data.length 判断) */
|
|
36
|
+
hasMore?: boolean;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* 加载更多函数类型
|
|
40
|
+
*/
|
|
41
|
+
export type LoadMoreFn = (params: LoadMoreParams) => Promise<LoadMoreResult> | LoadMoreResult;
|
|
42
|
+
/**
|
|
43
|
+
* SelectLoadMore 组件 Props
|
|
44
|
+
*/
|
|
45
|
+
export interface SelectLoadMoreProps {
|
|
46
|
+
/** 绑定值 */
|
|
47
|
+
modelValue?: string | number | Array<string | number>;
|
|
48
|
+
/** 选项列表(静态数据,如果提供了 loadMore 函数,则作为初始数据) */
|
|
49
|
+
options?: SelectOption[];
|
|
50
|
+
/** 加载更多数据的函数 */
|
|
51
|
+
loadMore?: LoadMoreFn;
|
|
52
|
+
/** 每页加载数量 */
|
|
53
|
+
pageSize?: number;
|
|
54
|
+
/** 距离底部多少像素时触发加载(单位:px) */
|
|
55
|
+
threshold?: number;
|
|
56
|
+
/** 加载中显示的文本 */
|
|
57
|
+
loadingText?: string;
|
|
58
|
+
/** 获取选项的唯一 key */
|
|
59
|
+
getOptionKey?: (item: SelectOption) => string | number;
|
|
60
|
+
/** 获取选项的显示标签 */
|
|
61
|
+
getOptionLabel?: (item: SelectOption) => string;
|
|
62
|
+
/** 获取选项的值 */
|
|
63
|
+
getOptionValue?: (item: SelectOption) => string | number;
|
|
64
|
+
/** 获取选项的其他 props(传递给 el-option) */
|
|
65
|
+
getOptionProps?: (item: SelectOption) => Record<string, any>;
|
|
66
|
+
/** 下拉框的 popper class */
|
|
67
|
+
popperClass?: string;
|
|
68
|
+
/** 是否在下拉框打开时自动加载第一页数据 */
|
|
69
|
+
autoLoad?: boolean;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* SelectLoadMore 组件 Emits
|
|
73
|
+
*/
|
|
74
|
+
export interface SelectLoadMoreEmits {
|
|
75
|
+
/** 值变化事件 */
|
|
76
|
+
'update:modelValue': [value: string | number | Array<string | number> | undefined];
|
|
77
|
+
/** 选择变化事件 */
|
|
78
|
+
change: [value: string | number | Array<string | number> | undefined];
|
|
79
|
+
/** 下拉框显示/隐藏事件 */
|
|
80
|
+
'visible-change': [visible: boolean];
|
|
81
|
+
/** 加载错误事件 */
|
|
82
|
+
'load-error': [error: any];
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* SelectLoadMore 组件实例方法
|
|
86
|
+
*/
|
|
87
|
+
export interface SelectLoadMoreInstance {
|
|
88
|
+
/** 重置状态(清空已加载数据,重置页码) */
|
|
89
|
+
reset: () => void;
|
|
90
|
+
/** 刷新数据(重置并重新加载第一页) */
|
|
91
|
+
refresh: () => Promise<void>;
|
|
92
|
+
/** 手动触发加载更多 */
|
|
93
|
+
loadMore: () => Promise<void>;
|
|
94
|
+
/** el-select 实例引用 */
|
|
95
|
+
selectRef: SelectInstance | undefined;
|
|
96
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clownlee/cores",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"description": "公共核心库,提供统一的 HTTP 请求能力和自动 token 刷新功能",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
],
|
|
19
19
|
"scripts": {
|
|
20
20
|
"build": "vite build",
|
|
21
|
+
"build:test": "vite build",
|
|
21
22
|
"dev": "vite build --watch",
|
|
22
23
|
"type-check": "vue-tsc --noEmit"
|
|
23
24
|
},
|