@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.mjs
ADDED
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
import { Transition, computed, defineComponent, h, render } from "vue-demi";
|
|
2
|
+
import CssRender from "css-render";
|
|
3
|
+
import { extendRef, unrefElement, useAsyncState, useElementSize, useEventListener, useOffsetPagination } from "@vueuse/core";
|
|
4
|
+
import debounce from "lodash/debounce";
|
|
5
|
+
import throttle from "lodash/throttle";
|
|
6
|
+
import { computed as computed$1, nextTick, reactive, ref, unref, watch } from "vue";
|
|
7
|
+
import { unit } from "@hairy/utils";
|
|
8
|
+
|
|
9
|
+
//#region src/components/c-field.ts
|
|
10
|
+
const Field = defineComponent({
|
|
11
|
+
name: "Field",
|
|
12
|
+
props: { is: {
|
|
13
|
+
type: [
|
|
14
|
+
String,
|
|
15
|
+
Number,
|
|
16
|
+
Object
|
|
17
|
+
],
|
|
18
|
+
default: ""
|
|
19
|
+
} },
|
|
20
|
+
setup(props) {
|
|
21
|
+
return () => {
|
|
22
|
+
if (typeof props.is === "string" || typeof props.is === "number") return props.is;
|
|
23
|
+
return props.is ? h(props.is) : null;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/components/collapse-transition.ts
|
|
30
|
+
const { c } = CssRender();
|
|
31
|
+
const CollapseTransition = defineComponent({
|
|
32
|
+
name: "CollapseTransition",
|
|
33
|
+
setup(_, { slots }) {
|
|
34
|
+
const on = {
|
|
35
|
+
onBeforeEnter(el) {
|
|
36
|
+
el.classList.add("collapse-transition");
|
|
37
|
+
if (!el.dataset) el.dataset = {};
|
|
38
|
+
el.dataset.oldPaddingTop = el.style.paddingTop;
|
|
39
|
+
el.dataset.oldPaddingBottom = el.style.paddingBottom;
|
|
40
|
+
el.style.height = "0";
|
|
41
|
+
el.style.paddingTop = "0";
|
|
42
|
+
el.style.paddingBottom = "0";
|
|
43
|
+
},
|
|
44
|
+
onEnter(el) {
|
|
45
|
+
el.dataset.oldOverflow = el.style.overflow;
|
|
46
|
+
if (el.scrollHeight !== 0) {
|
|
47
|
+
el.style.height = `${el.scrollHeight}px`;
|
|
48
|
+
el.style.paddingTop = el.dataset.oldPaddingTop || "0";
|
|
49
|
+
el.style.paddingBottom = el.dataset.oldPaddingBottom || "0";
|
|
50
|
+
} else {
|
|
51
|
+
el.style.height = "";
|
|
52
|
+
el.style.paddingTop = el.dataset.oldPaddingTop || "0";
|
|
53
|
+
el.style.paddingBottom = el.dataset.oldPaddingBottom || "0";
|
|
54
|
+
}
|
|
55
|
+
el.style.overflow = "hidden";
|
|
56
|
+
},
|
|
57
|
+
onAfterEnter(el) {
|
|
58
|
+
el.classList.remove("collapse-transition");
|
|
59
|
+
el.style.height = "";
|
|
60
|
+
el.style.overflow = el.dataset.oldOverflow || "0";
|
|
61
|
+
},
|
|
62
|
+
onBeforeLeave(el) {
|
|
63
|
+
if (!el.dataset) el.dataset = {};
|
|
64
|
+
el.dataset.oldPaddingTop = el.style.paddingTop;
|
|
65
|
+
el.dataset.oldPaddingBottom = el.style.paddingBottom;
|
|
66
|
+
el.dataset.oldOverflow = el.style.overflow;
|
|
67
|
+
el.style.height = `${el.scrollHeight}px`;
|
|
68
|
+
el.style.overflow = "hidden";
|
|
69
|
+
},
|
|
70
|
+
onLeave(el) {
|
|
71
|
+
if (el.scrollHeight !== 0) {
|
|
72
|
+
el.classList.add("collapse-transition");
|
|
73
|
+
el.style.transitionProperty = "height";
|
|
74
|
+
el.style.height = "0";
|
|
75
|
+
el.style.paddingTop = "0";
|
|
76
|
+
el.style.paddingBottom = "0";
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
onAfterLeave(el) {
|
|
80
|
+
el.classList.remove("collapse-transition");
|
|
81
|
+
el.style.height = "";
|
|
82
|
+
el.style.overflow = el.dataset.oldOverflow || "0";
|
|
83
|
+
el.style.paddingTop = el.dataset.oldPaddingTop || "0";
|
|
84
|
+
el.style.paddingBottom = el.dataset.oldPaddingBottom || "0";
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
style.mount();
|
|
88
|
+
return () => h(Transition, on, slots);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
const style = c(".collapse-transition", { transition: "0.2s height ease-in-out, 0.2s padding-top ease-in-out,0.2s padding-bottom ease-in-out" });
|
|
92
|
+
|
|
93
|
+
//#endregion
|
|
94
|
+
//#region src/hooks/syncElementScroll/index.ts
|
|
95
|
+
/**
|
|
96
|
+
* Synchronize scrolling between two DOM with the same scrollbar
|
|
97
|
+
* @param fromTarget DOM-A
|
|
98
|
+
* @param toTarget DOM-B
|
|
99
|
+
* @param options
|
|
100
|
+
* @todo optimizes the reuse of useEventListener
|
|
101
|
+
* @todo may have bugs when using wait
|
|
102
|
+
*/
|
|
103
|
+
function syncElementSyncScroll(fromTarget, toTarget, options = {}) {
|
|
104
|
+
const { left = true, top = true, wait, immediate = true } = options;
|
|
105
|
+
const debounceScrollLocks = reactive({
|
|
106
|
+
from: false,
|
|
107
|
+
to: false
|
|
108
|
+
});
|
|
109
|
+
const onChangeLockScrollListener = debounce((type) => {
|
|
110
|
+
debounceScrollLocks[type] = true;
|
|
111
|
+
}, 20, {
|
|
112
|
+
leading: true,
|
|
113
|
+
trailing: false
|
|
114
|
+
});
|
|
115
|
+
const offChangeLockScrollListener = debounce((type) => {
|
|
116
|
+
debounceScrollLocks[type] = false;
|
|
117
|
+
}, 20, {
|
|
118
|
+
leading: false,
|
|
119
|
+
trailing: true
|
|
120
|
+
});
|
|
121
|
+
const syncScroll = (type) => {
|
|
122
|
+
const positive = type;
|
|
123
|
+
const opposite = type === "from" ? "to" : "from";
|
|
124
|
+
const elements = reactive({
|
|
125
|
+
from: fromTarget,
|
|
126
|
+
to: toTarget
|
|
127
|
+
});
|
|
128
|
+
if (debounceScrollLocks[type]) return;
|
|
129
|
+
onChangeLockScrollListener(opposite);
|
|
130
|
+
const aElement = elements[positive];
|
|
131
|
+
const bElement = elements[opposite];
|
|
132
|
+
const options = {};
|
|
133
|
+
if (left) options.left = aElement.scrollLeft;
|
|
134
|
+
if (top) options.top = aElement.scrollTop;
|
|
135
|
+
if (!aElement || !bElement) return;
|
|
136
|
+
bElement?.scroll(options);
|
|
137
|
+
offChangeLockScrollListener(opposite);
|
|
138
|
+
};
|
|
139
|
+
const syncFromTo = () => syncScroll("from");
|
|
140
|
+
const syncToFrom = () => syncScroll("to");
|
|
141
|
+
let toStopHandle;
|
|
142
|
+
let formStopHandle;
|
|
143
|
+
const stop = () => {
|
|
144
|
+
toStopHandle?.();
|
|
145
|
+
formStopHandle?.();
|
|
146
|
+
};
|
|
147
|
+
const start = () => {
|
|
148
|
+
toStopHandle = useEventListener(fromTarget, "scroll", throttle(syncFromTo, wait));
|
|
149
|
+
formStopHandle = useEventListener(toTarget, "scroll", throttle(syncToFrom, wait));
|
|
150
|
+
};
|
|
151
|
+
if (immediate) start();
|
|
152
|
+
return {
|
|
153
|
+
stop,
|
|
154
|
+
start,
|
|
155
|
+
syncFromTo,
|
|
156
|
+
syncToFrom
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
//#endregion
|
|
161
|
+
//#region src/hooks/syncElementSize/index.ts
|
|
162
|
+
/**
|
|
163
|
+
* Synchronize the width or height of from DOM to the specified to DOM
|
|
164
|
+
* @param fromTarget width and height source element
|
|
165
|
+
* @param toTarget width and height setting elements
|
|
166
|
+
* @param options
|
|
167
|
+
*/
|
|
168
|
+
function syncElementSize(fromTarget, toTarget, options = {}) {
|
|
169
|
+
const { width: isOnWidth = true, height: isOnHeight = false } = options;
|
|
170
|
+
const defaultSize = {
|
|
171
|
+
width: "",
|
|
172
|
+
height: ""
|
|
173
|
+
};
|
|
174
|
+
const fromSize = useElementSize(fromTarget);
|
|
175
|
+
let widthStopHandle;
|
|
176
|
+
let heightStopHandle;
|
|
177
|
+
const sync = (type) => {
|
|
178
|
+
const sources = [fromSize[type], toTarget];
|
|
179
|
+
const callback = () => {
|
|
180
|
+
const element = unrefElement(toTarget);
|
|
181
|
+
if (!element) return void 0;
|
|
182
|
+
element.style[type] = unit(fromSize[type].value);
|
|
183
|
+
};
|
|
184
|
+
return watch(sources, callback, {
|
|
185
|
+
immediate: true,
|
|
186
|
+
...options
|
|
187
|
+
});
|
|
188
|
+
};
|
|
189
|
+
const stop = () => {
|
|
190
|
+
widthStopHandle?.();
|
|
191
|
+
heightStopHandle?.();
|
|
192
|
+
const element = unrefElement(toTarget);
|
|
193
|
+
element.style.width = defaultSize.width;
|
|
194
|
+
element.style.height = defaultSize.height;
|
|
195
|
+
};
|
|
196
|
+
const start = () => {
|
|
197
|
+
if (isOnWidth) widthStopHandle = sync("width");
|
|
198
|
+
if (isOnHeight) heightStopHandle = sync("height");
|
|
199
|
+
};
|
|
200
|
+
watch(() => unref(toTarget), () => {
|
|
201
|
+
const element = unrefElement(toTarget);
|
|
202
|
+
defaultSize.width = element.style.width;
|
|
203
|
+
defaultSize.height = element.style.height;
|
|
204
|
+
});
|
|
205
|
+
start();
|
|
206
|
+
return {
|
|
207
|
+
start,
|
|
208
|
+
stop
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
//#endregion
|
|
213
|
+
//#region src/hooks/useChecked/index.ts
|
|
214
|
+
/**
|
|
215
|
+
* Get the status of checked and customize the value of checked | unchecked
|
|
216
|
+
* @param target
|
|
217
|
+
* @param checked
|
|
218
|
+
* @param unchecked
|
|
219
|
+
*/
|
|
220
|
+
function useChecked(target, checked = true, unchecked = false) {
|
|
221
|
+
return computed$1({
|
|
222
|
+
get: () => target.value === unref(checked),
|
|
223
|
+
set: (_value) => {
|
|
224
|
+
target.value = _value ? unref(checked) : unref(unchecked);
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
//#endregion
|
|
230
|
+
//#region src/hooks/usePaginationServer/index.ts
|
|
231
|
+
function useServerPagination(options) {
|
|
232
|
+
const total = ref(Infinity);
|
|
233
|
+
const pagination = useOffsetPagination({
|
|
234
|
+
total,
|
|
235
|
+
...options
|
|
236
|
+
});
|
|
237
|
+
const resolveOptions = reactive({
|
|
238
|
+
currentPage: pagination.currentPage,
|
|
239
|
+
currentPageSize: pagination.currentPageSize,
|
|
240
|
+
total
|
|
241
|
+
});
|
|
242
|
+
const paginationRef = reactive({
|
|
243
|
+
currentPage: pagination.currentPage,
|
|
244
|
+
currentPageSize: pagination.currentPageSize,
|
|
245
|
+
pageCount: pagination.pageCount,
|
|
246
|
+
isFirstPage: pagination.isFirstPage,
|
|
247
|
+
isLastPage: pagination.isLastPage,
|
|
248
|
+
total
|
|
249
|
+
});
|
|
250
|
+
const state = ref([]);
|
|
251
|
+
const { execute: _execute, isLoading: loading, error } = useAsyncState(async () => {
|
|
252
|
+
return await options.resolve(resolveOptions);
|
|
253
|
+
}, []);
|
|
254
|
+
const execute = debounce(async () => {
|
|
255
|
+
state.value = await _execute();
|
|
256
|
+
}, 100);
|
|
257
|
+
nextTick(() => {
|
|
258
|
+
watch([pagination.currentPageSize, ...options.sources || []], execute, {
|
|
259
|
+
immediate: true,
|
|
260
|
+
...options
|
|
261
|
+
});
|
|
262
|
+
watch(pagination.currentPage, (newValue, oldValue) => newValue !== oldValue && execute());
|
|
263
|
+
});
|
|
264
|
+
return {
|
|
265
|
+
state,
|
|
266
|
+
loading,
|
|
267
|
+
error,
|
|
268
|
+
execute,
|
|
269
|
+
pagination: paginationRef,
|
|
270
|
+
next: pagination.next,
|
|
271
|
+
prev: pagination.prev
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
//#endregion
|
|
276
|
+
//#region src/hooks/utils/extendSelected.ts
|
|
277
|
+
function extendSelected(array, fieldName) {
|
|
278
|
+
watch(array, (items) => {
|
|
279
|
+
for (const item of items) if (typeof item[fieldName] === "undefined") extendRef(item, { [fieldName]: ref(false) });
|
|
280
|
+
}, {
|
|
281
|
+
immediate: true,
|
|
282
|
+
flush: "sync"
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
//#endregion
|
|
287
|
+
//#region src/hooks/useSelectedMultiple/index.ts
|
|
288
|
+
function useSelectedMultiple(array, options = {}) {
|
|
289
|
+
const { fieldName = "select", disabled } = options;
|
|
290
|
+
extendSelected(array, fieldName);
|
|
291
|
+
/** 当前选中的项列表 */
|
|
292
|
+
const selected = computed$1(() => unref(array).filter((item) => item[fieldName]));
|
|
293
|
+
return {
|
|
294
|
+
selected,
|
|
295
|
+
isSelectedAll: computed$1({
|
|
296
|
+
get: () => !selected.value?.length && !unref(array).some((item) => !item[fieldName]),
|
|
297
|
+
set: (value) => unref(array).forEach((item, index) => {
|
|
298
|
+
if (!disabled?.(item, index)) item[fieldName] = value;
|
|
299
|
+
})
|
|
300
|
+
}),
|
|
301
|
+
isSelected: computed$1(() => !!unref(array).some((item) => item[fieldName])),
|
|
302
|
+
isIndeterminate: computed$1(() => {
|
|
303
|
+
const selectCount = selected.value.length;
|
|
304
|
+
return selectCount > 0 && selectCount < unref(array).length;
|
|
305
|
+
})
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
//#endregion
|
|
310
|
+
//#region src/hooks/useSelectedSingle/index.ts
|
|
311
|
+
function useSelectedSingle(array, options = {}) {
|
|
312
|
+
const fieldName = options.fieldName ?? "select";
|
|
313
|
+
const required = options.required ?? false;
|
|
314
|
+
extendSelected(array, fieldName);
|
|
315
|
+
const SELECTED_SINGLE_KEY = "selected_single_key";
|
|
316
|
+
const isLocked = ref(false);
|
|
317
|
+
/** 当前是否已经选择 */
|
|
318
|
+
const isSelected = computed$1(() => !!unref(array).some((item) => item.select));
|
|
319
|
+
if (required) {
|
|
320
|
+
const recover = (bool) => {
|
|
321
|
+
const index = required === true ? 0 : required;
|
|
322
|
+
if (!bool && unref(array).length > 0) unref(array)[index][fieldName] = true;
|
|
323
|
+
};
|
|
324
|
+
watch(isSelected, recover, {
|
|
325
|
+
flush: "sync",
|
|
326
|
+
immediate: true
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
const itemChange = (neglect) => {
|
|
330
|
+
if (isLocked.value) return;
|
|
331
|
+
isLocked.value = true;
|
|
332
|
+
const _array = unref(array);
|
|
333
|
+
const _value = !_array[neglect][fieldName];
|
|
334
|
+
if (required && !_value) _array[neglect][fieldName] = true;
|
|
335
|
+
_array.forEach((target, index) => {
|
|
336
|
+
if (neglect === index) return void 0;
|
|
337
|
+
if (!target[fieldName]) return void 0;
|
|
338
|
+
target[fieldName] = false;
|
|
339
|
+
});
|
|
340
|
+
isLocked.value = false;
|
|
341
|
+
};
|
|
342
|
+
const targetEffect = (target, index) => {
|
|
343
|
+
if (!target[SELECTED_SINGLE_KEY]) return watch(() => target[fieldName], () => itemChange(index), { flush: "sync" });
|
|
344
|
+
Object.defineProperty(target, SELECTED_SINGLE_KEY, { value: true });
|
|
345
|
+
};
|
|
346
|
+
watch(array, () => {
|
|
347
|
+
unref(array).forEach(targetEffect);
|
|
348
|
+
}, {
|
|
349
|
+
immediate: true,
|
|
350
|
+
flush: "sync"
|
|
351
|
+
});
|
|
352
|
+
return {
|
|
353
|
+
selected: computed$1(() => unref(array).find((v) => v[fieldName])),
|
|
354
|
+
isSelected
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
//#endregion
|
|
359
|
+
//#region src/utils/index.ts
|
|
360
|
+
/**
|
|
361
|
+
* Directly render the incoming function components
|
|
362
|
+
* @param component
|
|
363
|
+
* @param tag Rendering container (default div)
|
|
364
|
+
*/
|
|
365
|
+
function ehr(component, tag) {
|
|
366
|
+
const container = document.createElement(tag || "dev");
|
|
367
|
+
render(h(component), container);
|
|
368
|
+
return container;
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Convert the properties of an object to ref
|
|
372
|
+
* @param data
|
|
373
|
+
* @param prop
|
|
374
|
+
*/
|
|
375
|
+
function propertyToRef(data, prop) {
|
|
376
|
+
return computed({
|
|
377
|
+
get() {
|
|
378
|
+
return data[prop];
|
|
379
|
+
},
|
|
380
|
+
set(v) {
|
|
381
|
+
data[prop] = v;
|
|
382
|
+
}
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
//#endregion
|
|
387
|
+
export { CollapseTransition, Field, ehr, propertyToRef, syncElementSize, syncElementSyncScroll, useChecked, useSelectedMultiple, useSelectedSingle, useServerPagination };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hairy/vue-lib",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.49.0",
|
|
5
5
|
"description": "Library for vue",
|
|
6
6
|
"author": "Hairyf <wwu710632@gmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -14,13 +14,22 @@
|
|
|
14
14
|
"bugs": "https://github.com/hairyf/hairylib/issues",
|
|
15
15
|
"keywords": [],
|
|
16
16
|
"sideEffects": false,
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"import": "./dist/index.mjs",
|
|
20
|
+
"require": "./dist/index.cjs"
|
|
21
|
+
},
|
|
22
|
+
"./package.json": "./package.json"
|
|
20
23
|
},
|
|
24
|
+
"main": "./dist/index.mjs",
|
|
25
|
+
"module": "./dist/index.mjs",
|
|
26
|
+
"types": "./dist/index.d.mts",
|
|
21
27
|
"files": [
|
|
22
28
|
"dist"
|
|
23
29
|
],
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"jsdelivr": "./dist/index.iife.js"
|
|
32
|
+
},
|
|
24
33
|
"peerDependencies": {
|
|
25
34
|
"@vue/composition-api": "^1.0.0-rc.1",
|
|
26
35
|
"vue": "^2.0.0 || >=3.0.0"
|
|
@@ -35,26 +44,16 @@
|
|
|
35
44
|
"css-render": "^0.15.14",
|
|
36
45
|
"lodash": "^4.17.21",
|
|
37
46
|
"vue-demi": "latest",
|
|
38
|
-
"@hairy/utils": "1.
|
|
47
|
+
"@hairy/utils": "1.49.0"
|
|
39
48
|
},
|
|
40
49
|
"devDependencies": {
|
|
41
50
|
"@types/lodash": "^4.17.16",
|
|
42
51
|
"vue": "^3.2.29"
|
|
43
52
|
},
|
|
44
53
|
"scripts": {
|
|
45
|
-
"build": "
|
|
46
|
-
"dev": "
|
|
54
|
+
"build": "tsdown",
|
|
55
|
+
"dev": "tsdown --watch",
|
|
47
56
|
"start": "tsx src/index.ts"
|
|
48
57
|
},
|
|
49
|
-
"
|
|
50
|
-
"types": "./dist/index.d.ts",
|
|
51
|
-
"unpkg": "./dist/index.global.js",
|
|
52
|
-
"exports": {
|
|
53
|
-
".": {
|
|
54
|
-
"import": "./dist/index.js",
|
|
55
|
-
"require": "./dist/index.cjs",
|
|
56
|
-
"types": "./dist/index.d.ts"
|
|
57
|
-
},
|
|
58
|
-
"./*": "./*"
|
|
59
|
-
}
|
|
58
|
+
"unpkg": "./dist/index.iife.js"
|
|
60
59
|
}
|
package/dist/index.d.ts
DELETED
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
import * as vue from 'vue';
|
|
2
|
-
import { WatchOptions, Ref, UnwrapRef, ComputedRef } from 'vue';
|
|
3
|
-
import { PropType, VNode, Component, DefineComponent, FunctionalComponent } from 'vue-demi';
|
|
4
|
-
import { MaybeRef, MaybeElementRef, UseOffsetPaginationReturn, UseOffsetPaginationOptions } from '@vueuse/core';
|
|
5
|
-
import { Noop } from '@hairy/utils';
|
|
6
|
-
import { DebouncedFunc } from 'lodash';
|
|
7
|
-
|
|
8
|
-
declare const Field: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
9
|
-
is: {
|
|
10
|
-
type: PropType<string | number | VNode | Component>;
|
|
11
|
-
default: string;
|
|
12
|
-
};
|
|
13
|
-
}>, () => string | number | VNode<vue.RendererNode, vue.RendererElement, {
|
|
14
|
-
[key: string]: any;
|
|
15
|
-
}> | null, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
16
|
-
is: {
|
|
17
|
-
type: PropType<string | number | VNode | Component>;
|
|
18
|
-
default: string;
|
|
19
|
-
};
|
|
20
|
-
}>> & Readonly<{}>, {
|
|
21
|
-
is: string | number | VNode<vue.RendererNode, vue.RendererElement, {
|
|
22
|
-
[key: string]: any;
|
|
23
|
-
}> | Component;
|
|
24
|
-
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
25
|
-
|
|
26
|
-
declare const CollapseTransition: DefineComponent;
|
|
27
|
-
|
|
28
|
-
interface SyncElementSyncScrollOptions {
|
|
29
|
-
left?: boolean;
|
|
30
|
-
top?: boolean;
|
|
31
|
-
wait?: number;
|
|
32
|
-
immediate?: boolean;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Synchronize scrolling between two DOM with the same scrollbar
|
|
36
|
-
* @param fromTarget DOM-A
|
|
37
|
-
* @param toTarget DOM-B
|
|
38
|
-
* @param options
|
|
39
|
-
* @todo optimizes the reuse of useEventListener
|
|
40
|
-
* @todo may have bugs when using wait
|
|
41
|
-
*/
|
|
42
|
-
declare function syncElementSyncScroll(fromTarget: MaybeRef<EventTarget | null | undefined>, toTarget: MaybeRef<EventTarget | null | undefined>, options?: SyncElementSyncScrollOptions): {
|
|
43
|
-
stop: () => void;
|
|
44
|
-
start: () => void;
|
|
45
|
-
syncFromTo: () => void;
|
|
46
|
-
syncToFrom: () => void;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
interface SyncElementSizeOptions extends WatchOptions {
|
|
50
|
-
/** Is the width enabled @default true */
|
|
51
|
-
width?: boolean;
|
|
52
|
-
/** Is the height enabled @default true */
|
|
53
|
-
height?: boolean;
|
|
54
|
-
}
|
|
55
|
-
interface SyncElementSizeReturn {
|
|
56
|
-
start?: Noop;
|
|
57
|
-
stop?: Noop;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Synchronize the width or height of from DOM to the specified to DOM
|
|
61
|
-
* @param fromTarget width and height source element
|
|
62
|
-
* @param toTarget width and height setting elements
|
|
63
|
-
* @param options
|
|
64
|
-
*/
|
|
65
|
-
declare function syncElementSize(fromTarget: MaybeElementRef, toTarget: MaybeElementRef, options?: SyncElementSizeOptions): SyncElementSizeReturn;
|
|
66
|
-
|
|
67
|
-
type CheckedState = string | boolean | number | symbol;
|
|
68
|
-
/**
|
|
69
|
-
* Get the status of checked and customize the value of checked | unchecked
|
|
70
|
-
* @param target
|
|
71
|
-
* @param checked
|
|
72
|
-
* @param unchecked
|
|
73
|
-
*/
|
|
74
|
-
declare function useChecked(target: Ref<any>, checked?: MaybeRef<CheckedState>, unchecked?: MaybeRef<CheckedState>): vue.WritableComputedRef<boolean, boolean>;
|
|
75
|
-
|
|
76
|
-
type UseServerPaginationResolve = UnwrapRef<Pick<UseOffsetPaginationReturn, 'currentPage' | 'currentPageSize'> & {
|
|
77
|
-
total: number;
|
|
78
|
-
}>;
|
|
79
|
-
type UseServerPagination = UnwrapRef<Omit<UseOffsetPaginationReturn, 'next' | 'prev'> & {
|
|
80
|
-
total: Ref<number>;
|
|
81
|
-
}>;
|
|
82
|
-
interface UseServerPaginationOptions<T> extends UseOffsetPaginationOptions, WatchOptions {
|
|
83
|
-
resolve: (pagination: UseServerPaginationResolve) => T | Promise<T>;
|
|
84
|
-
/** Monitor the source, trigger reset when the source data changes, default to monitoring page generation */
|
|
85
|
-
sources?: any[];
|
|
86
|
-
}
|
|
87
|
-
interface UseServerPaginationReturn<T> {
|
|
88
|
-
state: Ref<T>;
|
|
89
|
-
loading: Ref<boolean>;
|
|
90
|
-
error: Ref<any>;
|
|
91
|
-
pagination: UseServerPagination;
|
|
92
|
-
next: () => void;
|
|
93
|
-
prev: () => void;
|
|
94
|
-
execute: DebouncedFunc<() => Promise<void>>;
|
|
95
|
-
}
|
|
96
|
-
declare function useServerPagination<T extends any[]>(options: UseServerPaginationOptions<T>): UseServerPaginationReturn<T>;
|
|
97
|
-
|
|
98
|
-
type SelectedMultipleArray = MaybeRef<{
|
|
99
|
-
[key: string]: any;
|
|
100
|
-
}[]>;
|
|
101
|
-
interface SelectedMultipleOptions<T extends SelectedMultipleArray> {
|
|
102
|
-
/**
|
|
103
|
-
* Select Field
|
|
104
|
-
*
|
|
105
|
-
* @default 'select'
|
|
106
|
-
*/
|
|
107
|
-
fieldName?: string;
|
|
108
|
-
/**
|
|
109
|
-
* Processing disabled, takes effect when isSelectAll is changed
|
|
110
|
-
*/
|
|
111
|
-
disabled?: (item: UnwrapRef<T>[number], index: number) => boolean | void;
|
|
112
|
-
}
|
|
113
|
-
interface SelectedMultipleResult<T extends SelectedMultipleArray> {
|
|
114
|
-
/**
|
|
115
|
-
* All currently selected items
|
|
116
|
-
*/
|
|
117
|
-
selected: ComputedRef<UnwrapRef<T>>;
|
|
118
|
-
/**
|
|
119
|
-
* Is it currently all selected, Changing it will affect the selection of the list
|
|
120
|
-
*/
|
|
121
|
-
isSelectedAll: Ref<boolean>;
|
|
122
|
-
/**
|
|
123
|
-
* Whether to choose
|
|
124
|
-
*/
|
|
125
|
-
isSelected: ComputedRef<boolean>;
|
|
126
|
-
/**
|
|
127
|
-
* Selected, but not fully selected (usually used for checkbox components)
|
|
128
|
-
*/
|
|
129
|
-
isIndeterminate: ComputedRef<boolean>;
|
|
130
|
-
}
|
|
131
|
-
declare function useSelectedMultiple<T extends SelectedMultipleArray>(array: T, options?: SelectedMultipleOptions<T>): SelectedMultipleResult<T>;
|
|
132
|
-
|
|
133
|
-
type SelectedSingleArray = MaybeRef<{
|
|
134
|
-
[key: string]: any;
|
|
135
|
-
}[]>;
|
|
136
|
-
interface SelectedSingleOptions {
|
|
137
|
-
/**
|
|
138
|
-
* Select Field
|
|
139
|
-
*
|
|
140
|
-
* @default 'select'
|
|
141
|
-
*/
|
|
142
|
-
fieldName?: string;
|
|
143
|
-
/**
|
|
144
|
-
* Is it mandatory, What is the mandatory option
|
|
145
|
-
* @default false
|
|
146
|
-
*
|
|
147
|
-
*/
|
|
148
|
-
required?: true | number;
|
|
149
|
-
}
|
|
150
|
-
interface SelectedSingleResult<T extends SelectedSingleArray> {
|
|
151
|
-
/**
|
|
152
|
-
* 当前选中项
|
|
153
|
-
*/
|
|
154
|
-
selected: ComputedRef<UnwrapRef<T>[number] | undefined>;
|
|
155
|
-
/**
|
|
156
|
-
* 是否已经选择
|
|
157
|
-
*/
|
|
158
|
-
isSelected: ComputedRef<boolean>;
|
|
159
|
-
}
|
|
160
|
-
declare function useSelectedSingle<T extends SelectedSingleArray>(array: T, options?: SelectedSingleOptions): SelectedSingleResult<T>;
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Directly render the incoming function components
|
|
164
|
-
* @param component
|
|
165
|
-
* @param tag Rendering container (default div)
|
|
166
|
-
*/
|
|
167
|
-
declare function ehr<K extends keyof HTMLElementTagNameMap = 'div'>(component: FunctionalComponent, tag?: K): HTMLElementTagNameMap[K];
|
|
168
|
-
/**
|
|
169
|
-
* Convert the properties of an object to ref
|
|
170
|
-
* @param data
|
|
171
|
-
* @param prop
|
|
172
|
-
*/
|
|
173
|
-
declare function propertyToRef<T>(data: T, prop: keyof T): vue.WritableComputedRef<T[keyof T], T[keyof T]>;
|
|
174
|
-
|
|
175
|
-
export { type CheckedState, CollapseTransition, Field, type SelectedMultipleArray, type SelectedMultipleOptions, type SelectedMultipleResult, type SelectedSingleArray, type SelectedSingleOptions, type SelectedSingleResult, type SyncElementSizeOptions, type SyncElementSizeReturn, type UseServerPagination, type UseServerPaginationOptions, type UseServerPaginationResolve, type UseServerPaginationReturn, ehr, propertyToRef, syncElementSize, syncElementSyncScroll, useChecked, useSelectedMultiple, useSelectedSingle, useServerPagination };
|