@hairy/vue-lib 1.47.0 → 1.49.0
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/LICENSE.md +21 -21
- package/README.md +36 -36
- package/dist/index.cjs +388 -383
- package/dist/index.d.cts +184 -0
- package/dist/index.d.mts +184 -0
- package/dist/index.mjs +387 -0
- package/package.json +17 -18
- package/dist/index.d.ts +0 -175
- package/dist/index.global.js +0 -1258
- package/dist/index.js +0 -376
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import * as vue from "vue";
|
|
2
|
+
import { ComputedRef, Ref, UnwrapRef, WatchOptions } from "vue";
|
|
3
|
+
import { Component, DefineComponent, FunctionalComponent, PropType, VNode } from "vue-demi";
|
|
4
|
+
import { MaybeElementRef, MaybeRef, UseOffsetPaginationOptions, UseOffsetPaginationReturn } from "@vueuse/core";
|
|
5
|
+
import { Noop } from "@hairy/utils";
|
|
6
|
+
import { DebouncedFunc } from "lodash";
|
|
7
|
+
|
|
8
|
+
//#region src/components/c-field.d.ts
|
|
9
|
+
declare const Field: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
10
|
+
is: {
|
|
11
|
+
type: PropType<string | number | VNode | Component>;
|
|
12
|
+
default: string;
|
|
13
|
+
};
|
|
14
|
+
}>, () => string | number | VNode<vue.RendererNode, vue.RendererElement, {
|
|
15
|
+
[key: string]: any;
|
|
16
|
+
}> | null, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
17
|
+
is: {
|
|
18
|
+
type: PropType<string | number | VNode | Component>;
|
|
19
|
+
default: string;
|
|
20
|
+
};
|
|
21
|
+
}>> & Readonly<{}>, {
|
|
22
|
+
is: string | number | VNode<vue.RendererNode, vue.RendererElement, {
|
|
23
|
+
[key: string]: any;
|
|
24
|
+
}> | Component;
|
|
25
|
+
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region src/components/collapse-transition.d.ts
|
|
28
|
+
declare const CollapseTransition: DefineComponent;
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/hooks/syncElementScroll/index.d.ts
|
|
31
|
+
interface SyncElementSyncScrollOptions {
|
|
32
|
+
left?: boolean;
|
|
33
|
+
top?: boolean;
|
|
34
|
+
wait?: number;
|
|
35
|
+
immediate?: boolean;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Synchronize scrolling between two DOM with the same scrollbar
|
|
39
|
+
* @param fromTarget DOM-A
|
|
40
|
+
* @param toTarget DOM-B
|
|
41
|
+
* @param options
|
|
42
|
+
* @todo optimizes the reuse of useEventListener
|
|
43
|
+
* @todo may have bugs when using wait
|
|
44
|
+
*/
|
|
45
|
+
declare function syncElementSyncScroll(fromTarget: MaybeRef<EventTarget | null | undefined>, toTarget: MaybeRef<EventTarget | null | undefined>, options?: SyncElementSyncScrollOptions): {
|
|
46
|
+
stop: () => void;
|
|
47
|
+
start: () => void;
|
|
48
|
+
syncFromTo: () => void;
|
|
49
|
+
syncToFrom: () => void;
|
|
50
|
+
};
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/hooks/syncElementSize/index.d.ts
|
|
53
|
+
interface SyncElementSizeOptions extends WatchOptions {
|
|
54
|
+
/** Is the width enabled @default true */
|
|
55
|
+
width?: boolean;
|
|
56
|
+
/** Is the height enabled @default true */
|
|
57
|
+
height?: boolean;
|
|
58
|
+
}
|
|
59
|
+
interface SyncElementSizeReturn {
|
|
60
|
+
start?: Noop;
|
|
61
|
+
stop?: Noop;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Synchronize the width or height of from DOM to the specified to DOM
|
|
65
|
+
* @param fromTarget width and height source element
|
|
66
|
+
* @param toTarget width and height setting elements
|
|
67
|
+
* @param options
|
|
68
|
+
*/
|
|
69
|
+
declare function syncElementSize(fromTarget: MaybeElementRef, toTarget: MaybeElementRef, options?: SyncElementSizeOptions): SyncElementSizeReturn;
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/hooks/useChecked/index.d.ts
|
|
72
|
+
type CheckedState = string | boolean | number | symbol;
|
|
73
|
+
/**
|
|
74
|
+
* Get the status of checked and customize the value of checked | unchecked
|
|
75
|
+
* @param target
|
|
76
|
+
* @param checked
|
|
77
|
+
* @param unchecked
|
|
78
|
+
*/
|
|
79
|
+
declare function useChecked(target: Ref<any>, checked?: MaybeRef<CheckedState>, unchecked?: MaybeRef<CheckedState>): vue.WritableComputedRef<boolean, boolean>;
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region src/hooks/usePaginationServer/index.d.ts
|
|
82
|
+
type UseServerPaginationResolve = UnwrapRef<Pick<UseOffsetPaginationReturn, 'currentPage' | 'currentPageSize'> & {
|
|
83
|
+
total: number;
|
|
84
|
+
}>;
|
|
85
|
+
type UseServerPagination = UnwrapRef<Omit<UseOffsetPaginationReturn, 'next' | 'prev'> & {
|
|
86
|
+
total: Ref<number>;
|
|
87
|
+
}>;
|
|
88
|
+
interface UseServerPaginationOptions<T> extends UseOffsetPaginationOptions, WatchOptions {
|
|
89
|
+
resolve: (pagination: UseServerPaginationResolve) => T | Promise<T>;
|
|
90
|
+
/** Monitor the source, trigger reset when the source data changes, default to monitoring page generation */
|
|
91
|
+
sources?: any[];
|
|
92
|
+
}
|
|
93
|
+
interface UseServerPaginationReturn<T> {
|
|
94
|
+
state: Ref<T>;
|
|
95
|
+
loading: Ref<boolean>;
|
|
96
|
+
error: Ref<any>;
|
|
97
|
+
pagination: UseServerPagination;
|
|
98
|
+
next: () => void;
|
|
99
|
+
prev: () => void;
|
|
100
|
+
execute: DebouncedFunc<() => Promise<void>>;
|
|
101
|
+
}
|
|
102
|
+
declare function useServerPagination<T extends any[]>(options: UseServerPaginationOptions<T>): UseServerPaginationReturn<T>;
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region src/hooks/useSelectedMultiple/index.d.ts
|
|
105
|
+
type SelectedMultipleArray = MaybeRef<{
|
|
106
|
+
[key: string]: any;
|
|
107
|
+
}[]>;
|
|
108
|
+
interface SelectedMultipleOptions<T extends SelectedMultipleArray> {
|
|
109
|
+
/**
|
|
110
|
+
* Select Field
|
|
111
|
+
*
|
|
112
|
+
* @default 'select'
|
|
113
|
+
*/
|
|
114
|
+
fieldName?: string;
|
|
115
|
+
/**
|
|
116
|
+
* Processing disabled, takes effect when isSelectAll is changed
|
|
117
|
+
*/
|
|
118
|
+
disabled?: (item: UnwrapRef<T>[number], index: number) => boolean | void;
|
|
119
|
+
}
|
|
120
|
+
interface SelectedMultipleResult<T extends SelectedMultipleArray> {
|
|
121
|
+
/**
|
|
122
|
+
* All currently selected items
|
|
123
|
+
*/
|
|
124
|
+
selected: ComputedRef<UnwrapRef<T>>;
|
|
125
|
+
/**
|
|
126
|
+
* Is it currently all selected, Changing it will affect the selection of the list
|
|
127
|
+
*/
|
|
128
|
+
isSelectedAll: Ref<boolean>;
|
|
129
|
+
/**
|
|
130
|
+
* Whether to choose
|
|
131
|
+
*/
|
|
132
|
+
isSelected: ComputedRef<boolean>;
|
|
133
|
+
/**
|
|
134
|
+
* Selected, but not fully selected (usually used for checkbox components)
|
|
135
|
+
*/
|
|
136
|
+
isIndeterminate: ComputedRef<boolean>;
|
|
137
|
+
}
|
|
138
|
+
declare function useSelectedMultiple<T extends SelectedMultipleArray>(array: T, options?: SelectedMultipleOptions<T>): SelectedMultipleResult<T>;
|
|
139
|
+
//#endregion
|
|
140
|
+
//#region src/hooks/useSelectedSingle/index.d.ts
|
|
141
|
+
type SelectedSingleArray = MaybeRef<{
|
|
142
|
+
[key: string]: any;
|
|
143
|
+
}[]>;
|
|
144
|
+
interface SelectedSingleOptions {
|
|
145
|
+
/**
|
|
146
|
+
* Select Field
|
|
147
|
+
*
|
|
148
|
+
* @default 'select'
|
|
149
|
+
*/
|
|
150
|
+
fieldName?: string;
|
|
151
|
+
/**
|
|
152
|
+
* Is it mandatory, What is the mandatory option
|
|
153
|
+
* @default false
|
|
154
|
+
*
|
|
155
|
+
*/
|
|
156
|
+
required?: true | number;
|
|
157
|
+
}
|
|
158
|
+
interface SelectedSingleResult<T extends SelectedSingleArray> {
|
|
159
|
+
/**
|
|
160
|
+
* 当前选中项
|
|
161
|
+
*/
|
|
162
|
+
selected: ComputedRef<UnwrapRef<T>[number] | undefined>;
|
|
163
|
+
/**
|
|
164
|
+
* 是否已经选择
|
|
165
|
+
*/
|
|
166
|
+
isSelected: ComputedRef<boolean>;
|
|
167
|
+
}
|
|
168
|
+
declare function useSelectedSingle<T extends SelectedSingleArray>(array: T, options?: SelectedSingleOptions): SelectedSingleResult<T>;
|
|
169
|
+
//#endregion
|
|
170
|
+
//#region src/utils/index.d.ts
|
|
171
|
+
/**
|
|
172
|
+
* Directly render the incoming function components
|
|
173
|
+
* @param component
|
|
174
|
+
* @param tag Rendering container (default div)
|
|
175
|
+
*/
|
|
176
|
+
declare function ehr<K extends keyof HTMLElementTagNameMap = 'div'>(component: FunctionalComponent, tag?: K): HTMLElementTagNameMap[K];
|
|
177
|
+
/**
|
|
178
|
+
* Convert the properties of an object to ref
|
|
179
|
+
* @param data
|
|
180
|
+
* @param prop
|
|
181
|
+
*/
|
|
182
|
+
declare function propertyToRef<T>(data: T, prop: keyof T): vue.WritableComputedRef<T[keyof T], T[keyof T]>;
|
|
183
|
+
//#endregion
|
|
184
|
+
export { CheckedState, CollapseTransition, Field, SelectedMultipleArray, SelectedMultipleOptions, SelectedMultipleResult, SelectedSingleArray, SelectedSingleOptions, SelectedSingleResult, SyncElementSizeOptions, SyncElementSizeReturn, UseServerPagination, UseServerPaginationOptions, UseServerPaginationResolve, UseServerPaginationReturn, ehr, propertyToRef, syncElementSize, syncElementSyncScroll, useChecked, useSelectedMultiple, useSelectedSingle, useServerPagination };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { Component, DefineComponent, FunctionalComponent, PropType, VNode } from "vue-demi";
|
|
2
|
+
import { MaybeElementRef, MaybeRef, UseOffsetPaginationOptions, UseOffsetPaginationReturn } from "@vueuse/core";
|
|
3
|
+
import * as vue from "vue";
|
|
4
|
+
import { ComputedRef, Ref, UnwrapRef, WatchOptions } from "vue";
|
|
5
|
+
import { Noop } from "@hairy/utils";
|
|
6
|
+
import { DebouncedFunc } from "lodash";
|
|
7
|
+
|
|
8
|
+
//#region src/components/c-field.d.ts
|
|
9
|
+
declare const Field: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
10
|
+
is: {
|
|
11
|
+
type: PropType<string | number | VNode | Component>;
|
|
12
|
+
default: string;
|
|
13
|
+
};
|
|
14
|
+
}>, () => string | number | VNode<vue.RendererNode, vue.RendererElement, {
|
|
15
|
+
[key: string]: any;
|
|
16
|
+
}> | null, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
17
|
+
is: {
|
|
18
|
+
type: PropType<string | number | VNode | Component>;
|
|
19
|
+
default: string;
|
|
20
|
+
};
|
|
21
|
+
}>> & Readonly<{}>, {
|
|
22
|
+
is: string | number | VNode<vue.RendererNode, vue.RendererElement, {
|
|
23
|
+
[key: string]: any;
|
|
24
|
+
}> | Component;
|
|
25
|
+
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region src/components/collapse-transition.d.ts
|
|
28
|
+
declare const CollapseTransition: DefineComponent;
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/hooks/syncElementScroll/index.d.ts
|
|
31
|
+
interface SyncElementSyncScrollOptions {
|
|
32
|
+
left?: boolean;
|
|
33
|
+
top?: boolean;
|
|
34
|
+
wait?: number;
|
|
35
|
+
immediate?: boolean;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Synchronize scrolling between two DOM with the same scrollbar
|
|
39
|
+
* @param fromTarget DOM-A
|
|
40
|
+
* @param toTarget DOM-B
|
|
41
|
+
* @param options
|
|
42
|
+
* @todo optimizes the reuse of useEventListener
|
|
43
|
+
* @todo may have bugs when using wait
|
|
44
|
+
*/
|
|
45
|
+
declare function syncElementSyncScroll(fromTarget: MaybeRef<EventTarget | null | undefined>, toTarget: MaybeRef<EventTarget | null | undefined>, options?: SyncElementSyncScrollOptions): {
|
|
46
|
+
stop: () => void;
|
|
47
|
+
start: () => void;
|
|
48
|
+
syncFromTo: () => void;
|
|
49
|
+
syncToFrom: () => void;
|
|
50
|
+
};
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/hooks/syncElementSize/index.d.ts
|
|
53
|
+
interface SyncElementSizeOptions extends WatchOptions {
|
|
54
|
+
/** Is the width enabled @default true */
|
|
55
|
+
width?: boolean;
|
|
56
|
+
/** Is the height enabled @default true */
|
|
57
|
+
height?: boolean;
|
|
58
|
+
}
|
|
59
|
+
interface SyncElementSizeReturn {
|
|
60
|
+
start?: Noop;
|
|
61
|
+
stop?: Noop;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Synchronize the width or height of from DOM to the specified to DOM
|
|
65
|
+
* @param fromTarget width and height source element
|
|
66
|
+
* @param toTarget width and height setting elements
|
|
67
|
+
* @param options
|
|
68
|
+
*/
|
|
69
|
+
declare function syncElementSize(fromTarget: MaybeElementRef, toTarget: MaybeElementRef, options?: SyncElementSizeOptions): SyncElementSizeReturn;
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/hooks/useChecked/index.d.ts
|
|
72
|
+
type CheckedState = string | boolean | number | symbol;
|
|
73
|
+
/**
|
|
74
|
+
* Get the status of checked and customize the value of checked | unchecked
|
|
75
|
+
* @param target
|
|
76
|
+
* @param checked
|
|
77
|
+
* @param unchecked
|
|
78
|
+
*/
|
|
79
|
+
declare function useChecked(target: Ref<any>, checked?: MaybeRef<CheckedState>, unchecked?: MaybeRef<CheckedState>): vue.WritableComputedRef<boolean, boolean>;
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region src/hooks/usePaginationServer/index.d.ts
|
|
82
|
+
type UseServerPaginationResolve = UnwrapRef<Pick<UseOffsetPaginationReturn, 'currentPage' | 'currentPageSize'> & {
|
|
83
|
+
total: number;
|
|
84
|
+
}>;
|
|
85
|
+
type UseServerPagination = UnwrapRef<Omit<UseOffsetPaginationReturn, 'next' | 'prev'> & {
|
|
86
|
+
total: Ref<number>;
|
|
87
|
+
}>;
|
|
88
|
+
interface UseServerPaginationOptions<T> extends UseOffsetPaginationOptions, WatchOptions {
|
|
89
|
+
resolve: (pagination: UseServerPaginationResolve) => T | Promise<T>;
|
|
90
|
+
/** Monitor the source, trigger reset when the source data changes, default to monitoring page generation */
|
|
91
|
+
sources?: any[];
|
|
92
|
+
}
|
|
93
|
+
interface UseServerPaginationReturn<T> {
|
|
94
|
+
state: Ref<T>;
|
|
95
|
+
loading: Ref<boolean>;
|
|
96
|
+
error: Ref<any>;
|
|
97
|
+
pagination: UseServerPagination;
|
|
98
|
+
next: () => void;
|
|
99
|
+
prev: () => void;
|
|
100
|
+
execute: DebouncedFunc<() => Promise<void>>;
|
|
101
|
+
}
|
|
102
|
+
declare function useServerPagination<T extends any[]>(options: UseServerPaginationOptions<T>): UseServerPaginationReturn<T>;
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region src/hooks/useSelectedMultiple/index.d.ts
|
|
105
|
+
type SelectedMultipleArray = MaybeRef<{
|
|
106
|
+
[key: string]: any;
|
|
107
|
+
}[]>;
|
|
108
|
+
interface SelectedMultipleOptions<T extends SelectedMultipleArray> {
|
|
109
|
+
/**
|
|
110
|
+
* Select Field
|
|
111
|
+
*
|
|
112
|
+
* @default 'select'
|
|
113
|
+
*/
|
|
114
|
+
fieldName?: string;
|
|
115
|
+
/**
|
|
116
|
+
* Processing disabled, takes effect when isSelectAll is changed
|
|
117
|
+
*/
|
|
118
|
+
disabled?: (item: UnwrapRef<T>[number], index: number) => boolean | void;
|
|
119
|
+
}
|
|
120
|
+
interface SelectedMultipleResult<T extends SelectedMultipleArray> {
|
|
121
|
+
/**
|
|
122
|
+
* All currently selected items
|
|
123
|
+
*/
|
|
124
|
+
selected: ComputedRef<UnwrapRef<T>>;
|
|
125
|
+
/**
|
|
126
|
+
* Is it currently all selected, Changing it will affect the selection of the list
|
|
127
|
+
*/
|
|
128
|
+
isSelectedAll: Ref<boolean>;
|
|
129
|
+
/**
|
|
130
|
+
* Whether to choose
|
|
131
|
+
*/
|
|
132
|
+
isSelected: ComputedRef<boolean>;
|
|
133
|
+
/**
|
|
134
|
+
* Selected, but not fully selected (usually used for checkbox components)
|
|
135
|
+
*/
|
|
136
|
+
isIndeterminate: ComputedRef<boolean>;
|
|
137
|
+
}
|
|
138
|
+
declare function useSelectedMultiple<T extends SelectedMultipleArray>(array: T, options?: SelectedMultipleOptions<T>): SelectedMultipleResult<T>;
|
|
139
|
+
//#endregion
|
|
140
|
+
//#region src/hooks/useSelectedSingle/index.d.ts
|
|
141
|
+
type SelectedSingleArray = MaybeRef<{
|
|
142
|
+
[key: string]: any;
|
|
143
|
+
}[]>;
|
|
144
|
+
interface SelectedSingleOptions {
|
|
145
|
+
/**
|
|
146
|
+
* Select Field
|
|
147
|
+
*
|
|
148
|
+
* @default 'select'
|
|
149
|
+
*/
|
|
150
|
+
fieldName?: string;
|
|
151
|
+
/**
|
|
152
|
+
* Is it mandatory, What is the mandatory option
|
|
153
|
+
* @default false
|
|
154
|
+
*
|
|
155
|
+
*/
|
|
156
|
+
required?: true | number;
|
|
157
|
+
}
|
|
158
|
+
interface SelectedSingleResult<T extends SelectedSingleArray> {
|
|
159
|
+
/**
|
|
160
|
+
* 当前选中项
|
|
161
|
+
*/
|
|
162
|
+
selected: ComputedRef<UnwrapRef<T>[number] | undefined>;
|
|
163
|
+
/**
|
|
164
|
+
* 是否已经选择
|
|
165
|
+
*/
|
|
166
|
+
isSelected: ComputedRef<boolean>;
|
|
167
|
+
}
|
|
168
|
+
declare function useSelectedSingle<T extends SelectedSingleArray>(array: T, options?: SelectedSingleOptions): SelectedSingleResult<T>;
|
|
169
|
+
//#endregion
|
|
170
|
+
//#region src/utils/index.d.ts
|
|
171
|
+
/**
|
|
172
|
+
* Directly render the incoming function components
|
|
173
|
+
* @param component
|
|
174
|
+
* @param tag Rendering container (default div)
|
|
175
|
+
*/
|
|
176
|
+
declare function ehr<K extends keyof HTMLElementTagNameMap = 'div'>(component: FunctionalComponent, tag?: K): HTMLElementTagNameMap[K];
|
|
177
|
+
/**
|
|
178
|
+
* Convert the properties of an object to ref
|
|
179
|
+
* @param data
|
|
180
|
+
* @param prop
|
|
181
|
+
*/
|
|
182
|
+
declare function propertyToRef<T>(data: T, prop: keyof T): vue.WritableComputedRef<T[keyof T], T[keyof T]>;
|
|
183
|
+
//#endregion
|
|
184
|
+
export { CheckedState, CollapseTransition, Field, SelectedMultipleArray, SelectedMultipleOptions, SelectedMultipleResult, SelectedSingleArray, SelectedSingleOptions, SelectedSingleResult, SyncElementSizeOptions, SyncElementSizeReturn, UseServerPagination, UseServerPaginationOptions, UseServerPaginationResolve, UseServerPaginationReturn, ehr, propertyToRef, syncElementSize, syncElementSyncScroll, useChecked, useSelectedMultiple, useSelectedSingle, useServerPagination };
|