@movk/nuxt 1.3.1 → 1.4.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/README.md +2 -2
- package/dist/module.json +1 -1
- package/dist/module.mjs +12 -2
- package/dist/runtime/components/ColorChooser.d.vue.ts +2 -2
- package/dist/runtime/components/ColorChooser.vue.d.ts +2 -2
- package/dist/runtime/components/DataTable.d.vue.ts +2 -2
- package/dist/runtime/components/DataTable.vue +38 -10
- package/dist/runtime/components/DataTable.vue.d.ts +2 -2
- package/dist/runtime/components/DatePicker.d.vue.ts +3 -3
- package/dist/runtime/components/DatePicker.vue +1 -1
- package/dist/runtime/components/DatePicker.vue.d.ts +3 -3
- package/dist/runtime/components/PillGroup.d.vue.ts +1 -1
- package/dist/runtime/components/PillGroup.vue.d.ts +1 -1
- package/dist/runtime/components/SearchForm.d.vue.ts +3 -3
- package/dist/runtime/components/SearchForm.vue +14 -5
- package/dist/runtime/components/SearchForm.vue.d.ts +3 -3
- package/dist/runtime/components/StarRating.d.vue.ts +2 -2
- package/dist/runtime/components/StarRating.vue.d.ts +2 -2
- package/dist/runtime/components/Tree.d.vue.ts +44 -0
- package/dist/runtime/components/Tree.vue +332 -0
- package/dist/runtime/components/Tree.vue.d.ts +44 -0
- package/dist/runtime/composables/useDownloadWithProgress.d.ts +6 -5
- package/dist/runtime/composables/useDownloadWithProgress.js +4 -16
- package/dist/runtime/composables/useUploadWithProgress.d.ts +6 -5
- package/dist/runtime/composables/useUploadWithProgress.js +4 -16
- package/dist/runtime/domains/auto-form/controls.d.ts +16 -16
- package/dist/runtime/domains/data-table/components/Pagination.d.vue.ts +1 -1
- package/dist/runtime/domains/data-table/components/Pagination.vue.d.ts +1 -1
- package/dist/runtime/domains/tree/components/TreeToolbar.d.vue.ts +43 -0
- package/dist/runtime/domains/tree/components/TreeToolbar.vue +76 -0
- package/dist/runtime/domains/tree/components/TreeToolbar.vue.d.ts +43 -0
- package/dist/runtime/domains/tree/resolve-tree.d.ts +14 -0
- package/dist/runtime/domains/tree/resolve-tree.js +16 -0
- package/dist/runtime/domains/tree/tree-lazy.d.ts +20 -0
- package/dist/runtime/domains/tree/tree-lazy.js +19 -0
- package/dist/runtime/domains/tree/tree-search.d.ts +6 -0
- package/dist/runtime/domains/tree/tree-search.js +5 -0
- package/dist/runtime/types/auto-form/search-form.d.ts +3 -3
- package/dist/runtime/types/components/index.d.ts +1 -0
- package/dist/runtime/types/components/message-box.d.ts +3 -3
- package/dist/runtime/types/components/tree.d.ts +134 -0
- package/dist/runtime/types/components/tree.js +0 -0
- package/dist/runtime/types/data-table/columns.d.ts +1 -17
- package/dist/runtime/types/data-table/component.d.ts +5 -0
- package/dist/runtime/types/shared.d.ts +13 -0
- package/dist/runtime/utils/extend-theme.d.ts +2 -2
- package/dist/runtime/utils/tree-expand.d.ts +22 -0
- package/dist/runtime/utils/tree-expand.js +18 -0
- package/dist/runtime/utils/tree-selection.d.ts +37 -0
- package/dist/runtime/utils/tree-selection.js +59 -0
- package/dist/shared/{nuxt.DfBEyjld.mjs → nuxt.CXM2nhP4.mjs} +76 -4
- package/dist/unplugin.d.mts +4 -2
- package/dist/unplugin.mjs +1 -35
- package/dist/vite.mjs +1 -1
- package/package.json +9 -8
- package/dist/runtime/domains/data-table/tree-selection.d.ts +0 -9
- package/dist/runtime/domains/data-table/tree-selection.js +0 -76
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed, ref, useSlots, watch } from "vue";
|
|
3
|
+
import { reactiveOmit } from "@vueuse/core";
|
|
4
|
+
import { Tree, omitUndefined, splitHighlight } from "@movk/core";
|
|
5
|
+
import { UCheckbox, UIcon, UTree } from "#components";
|
|
6
|
+
import { useAppConfig } from "#imports";
|
|
7
|
+
import { useExtendedTv } from "../utils/extend-theme";
|
|
8
|
+
import treeTheme from "#build/ui/tree";
|
|
9
|
+
import theme from "#build/movk-ui/tree";
|
|
10
|
+
import { createGetKey, normalizeChildren } from "../domains/tree/resolve-tree";
|
|
11
|
+
import { matchLabel } from "../domains/tree/tree-search";
|
|
12
|
+
import { isPlaceholder, LAZY_KEY_FIELD, markLazyPlaceholders } from "../domains/tree/tree-lazy";
|
|
13
|
+
import { computeTreeSelection, selectionSummary } from "../utils/tree-selection";
|
|
14
|
+
import { resolveDefaultExpandedKeys } from "../utils/tree-expand";
|
|
15
|
+
import TreeToolbar from "../domains/tree/components/TreeToolbar.vue";
|
|
16
|
+
const props = defineProps({
|
|
17
|
+
items: { type: null, required: false },
|
|
18
|
+
childrenKey: { type: String, required: false, default: "children" },
|
|
19
|
+
labelKey: { type: null, required: false },
|
|
20
|
+
getKey: { type: Function, required: false },
|
|
21
|
+
defaultExpanded: { type: [Boolean, Number, Function], required: false },
|
|
22
|
+
selectedKeys: { type: Array, required: false },
|
|
23
|
+
multiple: { type: Boolean, required: false },
|
|
24
|
+
strategy: { type: String, required: false },
|
|
25
|
+
propagateSelect: { type: Boolean, required: false },
|
|
26
|
+
bubbleSelect: { type: Boolean, required: false },
|
|
27
|
+
size: { type: null, required: false },
|
|
28
|
+
color: { type: null, required: false },
|
|
29
|
+
searchable: { type: Boolean, required: false },
|
|
30
|
+
filter: { type: Function, required: false },
|
|
31
|
+
highlight: { type: Boolean, required: false, default: true },
|
|
32
|
+
lazy: { type: Boolean, required: false },
|
|
33
|
+
loadChildren: { type: Function, required: false },
|
|
34
|
+
toolbar: { type: Boolean, required: false },
|
|
35
|
+
checkable: { type: Boolean, required: false },
|
|
36
|
+
ui: { type: Object, required: false }
|
|
37
|
+
});
|
|
38
|
+
const emit = defineEmits(["update:modelValue", "update:expanded", "update:search", "change"]);
|
|
39
|
+
defineSlots();
|
|
40
|
+
defineOptions({ inheritAttrs: false });
|
|
41
|
+
const modelValue = defineModel();
|
|
42
|
+
const selectedKeysState = defineModel("selectedKeys", { type: Array });
|
|
43
|
+
const search = defineModel("search", { type: String, ...{ default: "" } });
|
|
44
|
+
const expanded = defineModel("expanded", { type: Array, ...{ default: () => [] } });
|
|
45
|
+
const slots = useSlots();
|
|
46
|
+
const appConfig = useAppConfig();
|
|
47
|
+
const labelKey = computed(() => props.labelKey ?? "label");
|
|
48
|
+
const getKey = computed(() => createGetKey(props.getKey, labelKey.value));
|
|
49
|
+
const { baseUi, extraUi } = useExtendedTv(
|
|
50
|
+
treeTheme,
|
|
51
|
+
theme,
|
|
52
|
+
() => appConfig.movk?.tree,
|
|
53
|
+
() => ({
|
|
54
|
+
ui: {
|
|
55
|
+
...props.ui,
|
|
56
|
+
container: [props.ui?.container, props.class]
|
|
57
|
+
}
|
|
58
|
+
})
|
|
59
|
+
);
|
|
60
|
+
function buildBase(items) {
|
|
61
|
+
const normalized = normalizeChildren(items ?? [], props.childrenKey);
|
|
62
|
+
return props.lazy ? markLazyPlaceholders(normalized, getKey.value, labelKey.value) : normalized;
|
|
63
|
+
}
|
|
64
|
+
const baseItems = ref([]);
|
|
65
|
+
let initialized = false;
|
|
66
|
+
watch(() => props.items, (items) => {
|
|
67
|
+
baseItems.value = buildBase(items ?? []);
|
|
68
|
+
if (!initialized && baseItems.value.length > 0) {
|
|
69
|
+
initialized = true;
|
|
70
|
+
if (expanded.value.length === 0) {
|
|
71
|
+
const de = props.defaultExpanded;
|
|
72
|
+
expanded.value = de === true || typeof de === "number" || typeof de === "function" ? resolveDefaultExpandedKeys(baseItems.value, de, { getKey: getKey.value }) : Tree.findAll(baseItems.value, ({ node }) => !!node.defaultExpanded).map((n) => getKey.value(n));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}, { immediate: true });
|
|
76
|
+
const searching = computed(() => !!(props.searchable && search.value.trim()));
|
|
77
|
+
const displayItems = computed(() => {
|
|
78
|
+
if (!searching.value) return baseItems.value;
|
|
79
|
+
const term = search.value;
|
|
80
|
+
return Tree.filter(
|
|
81
|
+
baseItems.value,
|
|
82
|
+
({ node }) => props.filter ? props.filter(node, term) : matchLabel(node[labelKey.value], term)
|
|
83
|
+
);
|
|
84
|
+
});
|
|
85
|
+
const isEmpty = computed(() => searching.value && displayItems.value.length === 0);
|
|
86
|
+
watch([searching, displayItems], () => {
|
|
87
|
+
if (searching.value) {
|
|
88
|
+
expanded.value = Tree.findAll(displayItems.value, ({ node }) => !!node.children?.length).map((n) => getKey.value(n));
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
const loadingKeys = ref(/* @__PURE__ */ new Set());
|
|
92
|
+
async function onExpandedUpdate(keys) {
|
|
93
|
+
const previous = expanded.value;
|
|
94
|
+
expanded.value = keys;
|
|
95
|
+
if (!props.lazy || !props.loadChildren) return;
|
|
96
|
+
for (const key of keys.filter((k) => !previous.includes(k))) {
|
|
97
|
+
if (loadingKeys.value.has(key)) continue;
|
|
98
|
+
const node = Tree.find(baseItems.value, ({ node: node2 }) => getKey.value(node2) === key);
|
|
99
|
+
const child = node?.children?.[0];
|
|
100
|
+
if (!node || !child || !isPlaceholder(child)) continue;
|
|
101
|
+
loadingKeys.value = new Set(loadingKeys.value).add(key);
|
|
102
|
+
try {
|
|
103
|
+
const loaded = buildBase(await props.loadChildren(node));
|
|
104
|
+
baseItems.value = Tree.updateNode(
|
|
105
|
+
baseItems.value,
|
|
106
|
+
key,
|
|
107
|
+
({ node: node2 }) => ({ ...node2, children: loaded.length ? loaded : void 0, isLeaf: loaded.length === 0 }),
|
|
108
|
+
{ id: LAZY_KEY_FIELD }
|
|
109
|
+
);
|
|
110
|
+
} finally {
|
|
111
|
+
const set = new Set(loadingKeys.value);
|
|
112
|
+
set.delete(key);
|
|
113
|
+
loadingKeys.value = set;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
const FORWARD_OMIT = /* @__PURE__ */ new Set([
|
|
118
|
+
"items",
|
|
119
|
+
"modelValue",
|
|
120
|
+
"selectedKeys",
|
|
121
|
+
"expanded",
|
|
122
|
+
"defaultExpanded",
|
|
123
|
+
"ui",
|
|
124
|
+
"class",
|
|
125
|
+
"childrenKey",
|
|
126
|
+
"searchable",
|
|
127
|
+
"search",
|
|
128
|
+
"filter",
|
|
129
|
+
"highlight",
|
|
130
|
+
"lazy",
|
|
131
|
+
"loadChildren",
|
|
132
|
+
"toolbar",
|
|
133
|
+
"checkable",
|
|
134
|
+
"multiple",
|
|
135
|
+
"strategy",
|
|
136
|
+
"propagateSelect",
|
|
137
|
+
"bubbleSelect"
|
|
138
|
+
]);
|
|
139
|
+
const forwardProps = reactiveOmit(props, (_value, key) => FORWARD_OMIT.has(key));
|
|
140
|
+
const utreeProps = computed(() => {
|
|
141
|
+
const multiple = props.checkable ? true : props.multiple;
|
|
142
|
+
const cascade = (props.strategy ?? "cascade") === "cascade";
|
|
143
|
+
const selectOptions = multiple ? {
|
|
144
|
+
multiple: true,
|
|
145
|
+
propagateSelect: props.propagateSelect || cascade,
|
|
146
|
+
bubbleSelect: props.bubbleSelect || cascade
|
|
147
|
+
} : { multiple };
|
|
148
|
+
return omitUndefined({ ...forwardProps, ...selectOptions });
|
|
149
|
+
});
|
|
150
|
+
const RESERVED_SLOTS = ["toolbar", "toolbar-leading", "toolbar-trailing", "empty", "loading"];
|
|
151
|
+
const forwardSlots = computed(() => Object.keys(slots).filter((name) => !RESERVED_SLOTS.includes(name)));
|
|
152
|
+
function nodeLabel(node) {
|
|
153
|
+
const value = node[labelKey.value];
|
|
154
|
+
return value == null ? "" : String(value);
|
|
155
|
+
}
|
|
156
|
+
const isMultiple = computed(() => !!(props.checkable || props.multiple));
|
|
157
|
+
const selectableNodes = computed(
|
|
158
|
+
() => Tree.findAll(baseItems.value, ({ node }) => !isPlaceholder(node) && !node.disabled)
|
|
159
|
+
);
|
|
160
|
+
const nodesByKey = computed(() => {
|
|
161
|
+
const map = /* @__PURE__ */ new Map();
|
|
162
|
+
Tree.forEach(baseItems.value, ({ node }) => {
|
|
163
|
+
map.set(getKey.value(node), node);
|
|
164
|
+
});
|
|
165
|
+
return map;
|
|
166
|
+
});
|
|
167
|
+
function modelToKeys(value) {
|
|
168
|
+
return Array.isArray(value) ? value.map((node) => getKey.value(node)) : value ? [getKey.value(value)] : [];
|
|
169
|
+
}
|
|
170
|
+
function keysToModel(keys) {
|
|
171
|
+
const nodes = keys.map((k) => nodesByKey.value.get(k)).filter((n) => !!n);
|
|
172
|
+
return isMultiple.value ? nodes : nodes[0];
|
|
173
|
+
}
|
|
174
|
+
const selectedKeys = computed(
|
|
175
|
+
() => selectedKeysState.value !== void 0 ? selectedKeysState.value : modelToKeys(modelValue.value)
|
|
176
|
+
);
|
|
177
|
+
const effectiveModel = computed(
|
|
178
|
+
() => selectedKeysState.value !== void 0 ? keysToModel(selectedKeysState.value) : modelValue.value
|
|
179
|
+
);
|
|
180
|
+
const treeSelection = computed(
|
|
181
|
+
() => computeTreeSelection(baseItems.value, new Set(selectedKeys.value), {
|
|
182
|
+
getKey: getKey.value,
|
|
183
|
+
strategy: props.strategy ?? "cascade"
|
|
184
|
+
})
|
|
185
|
+
);
|
|
186
|
+
const selectableLeafCount = computed(
|
|
187
|
+
() => Tree.findAll(baseItems.value, ({ node }) => !isPlaceholder(node) && !node.disabled && !(Array.isArray(node.children) && node.children.length > 0)).length
|
|
188
|
+
);
|
|
189
|
+
const selectionSummaryValue = computed(
|
|
190
|
+
() => selectionSummary(treeSelection.value.leaves.length, selectableLeafCount.value)
|
|
191
|
+
);
|
|
192
|
+
function setModel(value) {
|
|
193
|
+
modelValue.value = value;
|
|
194
|
+
const keys = modelToKeys(value);
|
|
195
|
+
if (selectedKeysState.value !== void 0) selectedKeysState.value = keys;
|
|
196
|
+
const selection = computeTreeSelection(baseItems.value, keys, {
|
|
197
|
+
getKey: getKey.value,
|
|
198
|
+
strategy: props.strategy ?? "cascade"
|
|
199
|
+
});
|
|
200
|
+
emit("change", { value, keys, selection });
|
|
201
|
+
}
|
|
202
|
+
const expandableKeys = computed(
|
|
203
|
+
() => Tree.findAll(baseItems.value, ({ node }) => !!node.children?.length).map((n) => getKey.value(n))
|
|
204
|
+
);
|
|
205
|
+
const allExpanded = computed(
|
|
206
|
+
() => expandableKeys.value.length > 0 && expandableKeys.value.every((k) => expanded.value.includes(k))
|
|
207
|
+
);
|
|
208
|
+
function onItemSelect(e) {
|
|
209
|
+
if (e.detail.originalEvent.type === "click") e.preventDefault();
|
|
210
|
+
}
|
|
211
|
+
function expandAll() {
|
|
212
|
+
expanded.value = expandableKeys.value;
|
|
213
|
+
}
|
|
214
|
+
function collapseAll() {
|
|
215
|
+
expanded.value = [];
|
|
216
|
+
}
|
|
217
|
+
function toggleExpand() {
|
|
218
|
+
if (allExpanded.value) collapseAll();
|
|
219
|
+
else expandAll();
|
|
220
|
+
}
|
|
221
|
+
function expandToDepth(depth) {
|
|
222
|
+
expanded.value = resolveDefaultExpandedKeys(baseItems.value, depth, { getKey: getKey.value });
|
|
223
|
+
}
|
|
224
|
+
function selectAll() {
|
|
225
|
+
setModel(selectableNodes.value);
|
|
226
|
+
}
|
|
227
|
+
function clearSelection() {
|
|
228
|
+
setModel(isMultiple.value ? [] : void 0);
|
|
229
|
+
}
|
|
230
|
+
defineExpose({
|
|
231
|
+
expandAll,
|
|
232
|
+
collapseAll,
|
|
233
|
+
expandToDepth,
|
|
234
|
+
selectAll,
|
|
235
|
+
clearSelection,
|
|
236
|
+
get treeSelection() {
|
|
237
|
+
return treeSelection.value;
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
</script>
|
|
241
|
+
|
|
242
|
+
<template>
|
|
243
|
+
<div :class="extraUi.container">
|
|
244
|
+
<slot
|
|
245
|
+
v-if="props.toolbar || props.searchable || slots.toolbar"
|
|
246
|
+
name="toolbar"
|
|
247
|
+
:expand-all="expandAll"
|
|
248
|
+
:collapse-all="collapseAll"
|
|
249
|
+
:toggle-expand="toggleExpand"
|
|
250
|
+
:all-expanded="allExpanded"
|
|
251
|
+
:select-all="selectAll"
|
|
252
|
+
:clear="clearSelection"
|
|
253
|
+
:search="search"
|
|
254
|
+
:selection-summary="selectionSummaryValue"
|
|
255
|
+
>
|
|
256
|
+
<TreeToolbar
|
|
257
|
+
:toolbar="props.toolbar"
|
|
258
|
+
:searchable="props.searchable"
|
|
259
|
+
:checkable="props.checkable"
|
|
260
|
+
:search="search"
|
|
261
|
+
:size="props.size"
|
|
262
|
+
:color="props.color"
|
|
263
|
+
:expanded="allExpanded"
|
|
264
|
+
:selection-summary="selectionSummaryValue"
|
|
265
|
+
:ui="{ toolbar: extraUi.toolbar, toolbarButton: extraUi.toolbarButton, search: extraUi.search }"
|
|
266
|
+
@update:search="search = $event"
|
|
267
|
+
@toggle-expand="toggleExpand"
|
|
268
|
+
@select-all="selectAll"
|
|
269
|
+
@clear="clearSelection"
|
|
270
|
+
>
|
|
271
|
+
<template v-if="slots['toolbar-leading']" #leading>
|
|
272
|
+
<slot name="toolbar-leading" />
|
|
273
|
+
</template>
|
|
274
|
+
<template v-if="slots['toolbar-trailing']" #trailing>
|
|
275
|
+
<slot name="toolbar-trailing" />
|
|
276
|
+
</template>
|
|
277
|
+
</TreeToolbar>
|
|
278
|
+
</slot>
|
|
279
|
+
|
|
280
|
+
<div v-if="isEmpty" :class="extraUi.empty">
|
|
281
|
+
<slot name="empty">
|
|
282
|
+
无匹配结果
|
|
283
|
+
</slot>
|
|
284
|
+
</div>
|
|
285
|
+
|
|
286
|
+
<UTree
|
|
287
|
+
v-else
|
|
288
|
+
v-bind="{ ...utreeProps, ...$attrs, ...props.checkable ? { as: { link: 'div' }, onSelect: onItemSelect } : {} }"
|
|
289
|
+
:items="displayItems"
|
|
290
|
+
:model-value="effectiveModel"
|
|
291
|
+
:expanded="expanded"
|
|
292
|
+
:ui="baseUi"
|
|
293
|
+
@update:model-value="setModel($event)"
|
|
294
|
+
@update:expanded="onExpandedUpdate"
|
|
295
|
+
>
|
|
296
|
+
<template v-for="name in forwardSlots" #[name]="slotProps" :key="name">
|
|
297
|
+
<slot :name="name" v-bind="slotProps ?? {}" />
|
|
298
|
+
</template>
|
|
299
|
+
|
|
300
|
+
<template v-if="props.checkable && !slots['item-leading']" #item-leading="{ item, selected, indeterminate, handleSelect }">
|
|
301
|
+
<UCheckbox
|
|
302
|
+
v-if="!isPlaceholder(item)"
|
|
303
|
+
:model-value="indeterminate ? 'indeterminate' : selected"
|
|
304
|
+
:size="props.size"
|
|
305
|
+
:color="props.color"
|
|
306
|
+
:class="extraUi.checkbox"
|
|
307
|
+
tabindex="-1"
|
|
308
|
+
@change="handleSelect"
|
|
309
|
+
@click.stop
|
|
310
|
+
/>
|
|
311
|
+
</template>
|
|
312
|
+
|
|
313
|
+
<template v-if="!slots['item-label']" #item-label="{ item }">
|
|
314
|
+
<slot v-if="isPlaceholder(item)" name="loading" :node="item">
|
|
315
|
+
<span :class="extraUi.loading">
|
|
316
|
+
<UIcon name="i-lucide-loader-circle" :class="extraUi.loadingIcon" />加载中
|
|
317
|
+
</span>
|
|
318
|
+
</slot>
|
|
319
|
+
<template v-else-if="searching && props.highlight">
|
|
320
|
+
<span
|
|
321
|
+
v-for="(segment, index) in splitHighlight(nodeLabel(item), search)"
|
|
322
|
+
:key="index"
|
|
323
|
+
:class="segment.match ? extraUi.highlight : void 0"
|
|
324
|
+
>{{ segment.text }}</span>
|
|
325
|
+
</template>
|
|
326
|
+
<template v-else>
|
|
327
|
+
{{ nodeLabel(item) }}
|
|
328
|
+
</template>
|
|
329
|
+
</template>
|
|
330
|
+
</UTree>
|
|
331
|
+
</div>
|
|
332
|
+
</template>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { AppConfig } from 'nuxt/schema';
|
|
2
|
+
import type { ComponentConfig, TreeItem } from '@nuxt/ui';
|
|
3
|
+
import treeTheme from '#build/ui/tree';
|
|
4
|
+
import theme from '#build/movk-ui/tree';
|
|
5
|
+
import type { TreeExposed, TreeProps, TreeSlots } from '../types/components/tree';
|
|
6
|
+
declare const __VLS_export: <T extends TreeItem[] = TreeItem[], M extends boolean = false>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
7
|
+
props: import("vue").PublicProps & __VLS_PrettifyLocal<(TreeProps<T, M> & {
|
|
8
|
+
ui?: ComponentConfig<typeof treeTheme & typeof theme, AppConfig, "tree">["slots"];
|
|
9
|
+
} & {
|
|
10
|
+
modelValue?: (M extends true ? T[number][] : T[number]) | undefined;
|
|
11
|
+
selectedKeys?: string[];
|
|
12
|
+
search?: string;
|
|
13
|
+
expanded?: string[];
|
|
14
|
+
}) & {
|
|
15
|
+
onChange?: ((payload: {
|
|
16
|
+
value: (M extends true ? T[number][] : T[number]) | undefined;
|
|
17
|
+
keys: string[];
|
|
18
|
+
selection: import("../types").TreeSelectionResult<T[number]>;
|
|
19
|
+
}) => any) | undefined;
|
|
20
|
+
"onUpdate:modelValue"?: ((value: (M extends true ? T[number][] : T[number]) | undefined) => any) | undefined;
|
|
21
|
+
"onUpdate:expanded"?: ((val: string[]) => any) | undefined;
|
|
22
|
+
"onUpdate:search"?: ((value: string) => any) | undefined;
|
|
23
|
+
"onUpdate:selectedKeys"?: ((value: string[] | undefined) => any) | undefined;
|
|
24
|
+
}> & (typeof globalThis extends {
|
|
25
|
+
__VLS_PROPS_FALLBACK: infer P;
|
|
26
|
+
} ? P : {});
|
|
27
|
+
expose: (exposed: import("vue").ShallowUnwrapRef<TreeExposed<T>>) => void;
|
|
28
|
+
attrs: any;
|
|
29
|
+
slots: TreeSlots<T>;
|
|
30
|
+
emit: (((evt: "change", payload: {
|
|
31
|
+
value: (M extends true ? T[number][] : T[number]) | undefined;
|
|
32
|
+
keys: string[];
|
|
33
|
+
selection: import("../types").TreeSelectionResult<T[number]>;
|
|
34
|
+
}) => void) & ((evt: "update:modelValue", val: M extends true ? T[number][] : T[number]) => void) & ((evt: "update:expanded", val: string[]) => void) & ((evt: "update:search", value: string) => void)) & (((event: "update:modelValue", value: (M extends true ? T[number][] : T[number]) | undefined) => void) & ((event: "update:expanded", value: string[]) => void) & ((event: "update:search", value: string) => void) & ((event: "update:selectedKeys", value: string[] | undefined) => void));
|
|
35
|
+
}>) => import("vue").VNode & {
|
|
36
|
+
__ctx?: Awaited<typeof __VLS_setup>;
|
|
37
|
+
};
|
|
38
|
+
declare const _default: typeof __VLS_export;
|
|
39
|
+
export default _default;
|
|
40
|
+
type __VLS_PrettifyLocal<T> = (T extends any ? {
|
|
41
|
+
[K in keyof T]: T[K];
|
|
42
|
+
} : {
|
|
43
|
+
[K in keyof T as K]: T[K];
|
|
44
|
+
}) & {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { Ref } from 'vue';
|
|
1
2
|
import type { NitroFetchRequest } from 'nitropack/types';
|
|
2
|
-
import type { ApiError, TransferRequestOptions, TransferResult } from '../types/api';
|
|
3
|
+
import type { ApiError, TransferRequestOptions, TransferResult, TransferStatus } from '../types/api';
|
|
3
4
|
/**
|
|
4
5
|
* 下载选项(带进度监控)
|
|
5
6
|
*/
|
|
@@ -33,13 +34,13 @@ export interface DownloadWithProgressOptions extends TransferRequestOptions {
|
|
|
33
34
|
*/
|
|
34
35
|
export declare function useDownloadWithProgress<T = Blob>(): {
|
|
35
36
|
/** 下载进度 0-100;后端未返回 content-length 时为 null(不确定) */
|
|
36
|
-
progress:
|
|
37
|
+
progress: Ref<number | null>;
|
|
37
38
|
/** 传输状态 */
|
|
38
|
-
status:
|
|
39
|
+
status: Ref<TransferStatus>;
|
|
39
40
|
/** 业务数据(默认 Blob;JSON 响应时为解包后的业务数据) */
|
|
40
|
-
data:
|
|
41
|
+
data: Ref<T | null>;
|
|
41
42
|
/** 错误信息 */
|
|
42
|
-
error:
|
|
43
|
+
error: Ref<ApiError | Error | null>;
|
|
43
44
|
/** 执行下载 */
|
|
44
45
|
download: (url: NitroFetchRequest, options?: DownloadWithProgressOptions) => Promise<TransferResult<T>>;
|
|
45
46
|
/** 中止下载 */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ref,
|
|
1
|
+
import { ref, shallowRef } from "vue";
|
|
2
|
+
import { useNuxtApp, useRuntimeConfig } from "#imports";
|
|
2
3
|
import { triggerDownload } from "@movk/core";
|
|
3
4
|
import {
|
|
4
5
|
buildFetchContext,
|
|
@@ -12,7 +13,7 @@ export function useDownloadWithProgress() {
|
|
|
12
13
|
const nuxtApp = useNuxtApp();
|
|
13
14
|
const progress = ref(0);
|
|
14
15
|
const status = ref("idle");
|
|
15
|
-
const data =
|
|
16
|
+
const data = shallowRef(null);
|
|
16
17
|
const error = ref(null);
|
|
17
18
|
let controller = null;
|
|
18
19
|
const abort = () => {
|
|
@@ -169,18 +170,5 @@ export function useDownloadWithProgress() {
|
|
|
169
170
|
return { data: null, error: downloadError, aborted: false };
|
|
170
171
|
}
|
|
171
172
|
};
|
|
172
|
-
return {
|
|
173
|
-
/** 下载进度 0-100;后端未返回 content-length 时为 null(不确定) */
|
|
174
|
-
progress,
|
|
175
|
-
/** 传输状态 */
|
|
176
|
-
status,
|
|
177
|
-
/** 业务数据(默认 Blob;JSON 响应时为解包后的业务数据) */
|
|
178
|
-
data,
|
|
179
|
-
/** 错误信息 */
|
|
180
|
-
error,
|
|
181
|
-
/** 执行下载 */
|
|
182
|
-
download,
|
|
183
|
-
/** 中止下载 */
|
|
184
|
-
abort
|
|
185
|
-
};
|
|
173
|
+
return { progress, status, data, error, download, abort };
|
|
186
174
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { Ref } from 'vue';
|
|
1
2
|
import type { NitroFetchRequest } from 'nitropack/types';
|
|
2
|
-
import type { ApiError, TransferRequestOptions, TransferResult } from '../types/api';
|
|
3
|
+
import type { ApiError, TransferRequestOptions, TransferResult, TransferStatus } from '../types/api';
|
|
3
4
|
/**
|
|
4
5
|
* 上传选项(带进度监控)
|
|
5
6
|
*/
|
|
@@ -32,13 +33,13 @@ export interface UploadWithProgressOptions<T = unknown> extends TransferRequestO
|
|
|
32
33
|
*/
|
|
33
34
|
export declare function useUploadWithProgress<T = unknown>(): {
|
|
34
35
|
/** 上传进度 0-100 */
|
|
35
|
-
progress:
|
|
36
|
+
progress: Ref<number | null>;
|
|
36
37
|
/** 传输状态 */
|
|
37
|
-
status:
|
|
38
|
+
status: Ref<TransferStatus>;
|
|
38
39
|
/** 解包后的业务数据 */
|
|
39
|
-
data:
|
|
40
|
+
data: Ref<T | null>;
|
|
40
41
|
/** 错误信息 */
|
|
41
|
-
error:
|
|
42
|
+
error: Ref<ApiError | Error | null>;
|
|
42
43
|
/** 执行上传 */
|
|
43
44
|
upload: (url: NitroFetchRequest, files: File | File[], options?: UploadWithProgressOptions<T>) => Promise<TransferResult<T>>;
|
|
44
45
|
/** 中止上传 */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ref,
|
|
1
|
+
import { ref, shallowRef } from "vue";
|
|
2
|
+
import { useNuxtApp, useRuntimeConfig } from "#imports";
|
|
2
3
|
import {
|
|
3
4
|
buildFetchContext,
|
|
4
5
|
finalizeTransfer,
|
|
@@ -11,7 +12,7 @@ export function useUploadWithProgress() {
|
|
|
11
12
|
const nuxtApp = useNuxtApp();
|
|
12
13
|
const progress = ref(0);
|
|
13
14
|
const status = ref("idle");
|
|
14
|
-
const data =
|
|
15
|
+
const data = shallowRef(null);
|
|
15
16
|
const error = ref(null);
|
|
16
17
|
let currentXhr = null;
|
|
17
18
|
const abort = () => {
|
|
@@ -111,18 +112,5 @@ export function useUploadWithProgress() {
|
|
|
111
112
|
xhr.send(formData);
|
|
112
113
|
});
|
|
113
114
|
};
|
|
114
|
-
return {
|
|
115
|
-
/** 上传进度 0-100 */
|
|
116
|
-
progress,
|
|
117
|
-
/** 传输状态 */
|
|
118
|
-
status,
|
|
119
|
-
/** 解包后的业务数据 */
|
|
120
|
-
data,
|
|
121
|
-
/** 错误信息 */
|
|
122
|
-
error,
|
|
123
|
-
/** 执行上传 */
|
|
124
|
-
upload,
|
|
125
|
-
/** 中止上传 */
|
|
126
|
-
abort
|
|
127
|
-
};
|
|
115
|
+
return { progress, status, data, error, upload, abort };
|
|
128
116
|
}
|
|
@@ -20,7 +20,7 @@ declare const DEFAULT_CONTROL_COMPONENTS: {
|
|
|
20
20
|
props: import("vue").PublicProps & {
|
|
21
21
|
buttonProps?: import("@nuxt/ui").ButtonProps | undefined;
|
|
22
22
|
ui?: (Record<string, import("tailwind-variants").ClassValue> & {
|
|
23
|
-
[x: string]: import("
|
|
23
|
+
[x: string]: import("@nuxt/ui").SlotClass;
|
|
24
24
|
}) | undefined;
|
|
25
25
|
as?: any;
|
|
26
26
|
id?: string | undefined;
|
|
@@ -86,7 +86,7 @@ declare const DEFAULT_CONTROL_COMPONENTS: {
|
|
|
86
86
|
props: import("vue").PublicProps & {
|
|
87
87
|
buttonProps?: import("@nuxt/ui").ButtonProps | undefined;
|
|
88
88
|
ui?: (Record<string, import("tailwind-variants").ClassValue> & {
|
|
89
|
-
[x: string]: import("
|
|
89
|
+
[x: string]: import("@nuxt/ui").SlotClass;
|
|
90
90
|
}) | undefined;
|
|
91
91
|
as?: any;
|
|
92
92
|
id?: string | undefined;
|
|
@@ -151,7 +151,7 @@ declare const DEFAULT_CONTROL_COMPONENTS: {
|
|
|
151
151
|
buttonProps?: import("@nuxt/ui").ButtonProps | undefined;
|
|
152
152
|
tooltipProps?: import("@nuxt/ui").TooltipProps | undefined;
|
|
153
153
|
ui?: (Record<string, import("tailwind-variants").ClassValue> & {
|
|
154
|
-
[x: string]: import("
|
|
154
|
+
[x: string]: import("@nuxt/ui").SlotClass;
|
|
155
155
|
}) | undefined;
|
|
156
156
|
as?: any;
|
|
157
157
|
id?: string | undefined;
|
|
@@ -217,7 +217,7 @@ declare const DEFAULT_CONTROL_COMPONENTS: {
|
|
|
217
217
|
props: import("vue").PublicProps & {
|
|
218
218
|
maxLength?: number | undefined;
|
|
219
219
|
ui?: (Record<string, import("tailwind-variants").ClassValue> & {
|
|
220
|
-
[x: string]: import("
|
|
220
|
+
[x: string]: import("@nuxt/ui").SlotClass;
|
|
221
221
|
}) | undefined;
|
|
222
222
|
as?: any;
|
|
223
223
|
id?: string | undefined;
|
|
@@ -284,7 +284,7 @@ declare const DEFAULT_CONTROL_COMPONENTS: {
|
|
|
284
284
|
size?: string | number | symbol | undefined;
|
|
285
285
|
clearButtonProps?: import("@nuxt/ui").ButtonProps | undefined;
|
|
286
286
|
ui?: (Record<string, import("tailwind-variants").ClassValue> & {
|
|
287
|
-
[x: string]: import("
|
|
287
|
+
[x: string]: import("@nuxt/ui").SlotClass;
|
|
288
288
|
}) | undefined;
|
|
289
289
|
as?: any;
|
|
290
290
|
id?: string | undefined;
|
|
@@ -350,7 +350,7 @@ declare const DEFAULT_CONTROL_COMPONENTS: {
|
|
|
350
350
|
mask?: string | undefined;
|
|
351
351
|
dialCode?: string | undefined;
|
|
352
352
|
ui?: (Record<string, import("tailwind-variants").ClassValue> & {
|
|
353
|
-
[x: string]: import("
|
|
353
|
+
[x: string]: import("@nuxt/ui").SlotClass;
|
|
354
354
|
}) | undefined;
|
|
355
355
|
as?: any;
|
|
356
356
|
id?: string | undefined;
|
|
@@ -423,12 +423,12 @@ declare const DEFAULT_CONTROL_COMPONENTS: {
|
|
|
423
423
|
modelValue?: number;
|
|
424
424
|
}> & Readonly<{
|
|
425
425
|
onChange?: ((value: number) => any) | undefined;
|
|
426
|
-
onHover?: ((value: number | null) => any) | undefined;
|
|
427
426
|
"onUpdate:modelValue"?: ((value: number) => any) | undefined;
|
|
427
|
+
onHover?: ((value: number | null) => any) | undefined;
|
|
428
428
|
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
429
429
|
change: (value: number) => any;
|
|
430
|
-
hover: (value: number | null) => any;
|
|
431
430
|
"update:modelValue": (value: number) => any;
|
|
431
|
+
hover: (value: number | null) => any;
|
|
432
432
|
}, import("vue").PublicProps, {
|
|
433
433
|
max: number;
|
|
434
434
|
showBadge: boolean;
|
|
@@ -448,8 +448,8 @@ declare const DEFAULT_CONTROL_COMPONENTS: {
|
|
|
448
448
|
modelValue?: number;
|
|
449
449
|
}> & Readonly<{
|
|
450
450
|
onChange?: ((value: number) => any) | undefined;
|
|
451
|
-
onHover?: ((value: number | null) => any) | undefined;
|
|
452
451
|
"onUpdate:modelValue"?: ((value: number) => any) | undefined;
|
|
452
|
+
onHover?: ((value: number | null) => any) | undefined;
|
|
453
453
|
}>, {}, {}, {}, {}, {
|
|
454
454
|
max: number;
|
|
455
455
|
showBadge: boolean;
|
|
@@ -466,12 +466,12 @@ declare const DEFAULT_CONTROL_COMPONENTS: {
|
|
|
466
466
|
modelValue?: number;
|
|
467
467
|
}> & Readonly<{
|
|
468
468
|
onChange?: ((value: number) => any) | undefined;
|
|
469
|
-
onHover?: ((value: number | null) => any) | undefined;
|
|
470
469
|
"onUpdate:modelValue"?: ((value: number) => any) | undefined;
|
|
470
|
+
onHover?: ((value: number | null) => any) | undefined;
|
|
471
471
|
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
472
472
|
change: (value: number) => any;
|
|
473
|
-
hover: (value: number | null) => any;
|
|
474
473
|
"update:modelValue": (value: number) => any;
|
|
474
|
+
hover: (value: number | null) => any;
|
|
475
475
|
}, string, {
|
|
476
476
|
max: number;
|
|
477
477
|
showBadge: boolean;
|
|
@@ -500,7 +500,7 @@ declare const DEFAULT_CONTROL_COMPONENTS: {
|
|
|
500
500
|
readonly colorChooser: <M extends "click" | "hover">(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: {
|
|
501
501
|
slots: import("../../types").ColorChooserSlots;
|
|
502
502
|
attrs: any;
|
|
503
|
-
emit: (((evt: "clear") => void) & ((evt: "change", value: string | undefined) => void) & ((evt: "copy", value: string) => void) & ((evt: "update:
|
|
503
|
+
emit: (((evt: "clear") => void) & ((evt: "change", value: string | undefined) => void) & ((evt: "copy", value: string) => void) & ((evt: "update:modelValue", value: string | undefined) => void) & ((evt: "update:open", open: boolean) => void) & ((evt: "format-change", format: import("../../types").ColorFormat) => void)) & ((event: "update:modelValue", value: string | undefined) => void);
|
|
504
504
|
}, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
505
505
|
props: import("vue").PublicProps & {
|
|
506
506
|
id?: string | undefined;
|
|
@@ -522,7 +522,7 @@ declare const DEFAULT_CONTROL_COMPONENTS: {
|
|
|
522
522
|
icon?: import("@nuxt/ui").IconProps["name"];
|
|
523
523
|
colorPickerProps?: Omit<import("@nuxt/ui").ColorPickerProps, "modelValue" | "format" | "disabled"> | undefined;
|
|
524
524
|
ui?: (Record<string, import("tailwind-variants").ClassValue> & {
|
|
525
|
-
[x: string]: import("
|
|
525
|
+
[x: string]: import("@nuxt/ui").SlotClass;
|
|
526
526
|
}) | undefined;
|
|
527
527
|
mode?: M | undefined;
|
|
528
528
|
content?: (Omit<import("reka-ui").PopoverContentProps, "as" | "asChild" | "forceMount"> & Partial<import("@nuxt/ui").EmitsToProps<import("reka-ui").PopoverContentEmits>>) | undefined;
|
|
@@ -538,8 +538,8 @@ declare const DEFAULT_CONTROL_COMPONENTS: {
|
|
|
538
538
|
onClear?: (() => any) | undefined;
|
|
539
539
|
onChange?: ((value: string | undefined) => any) | undefined;
|
|
540
540
|
onCopy?: ((value: string) => any) | undefined;
|
|
541
|
-
"onUpdate:open"?: ((open: boolean) => any) | undefined;
|
|
542
541
|
"onUpdate:modelValue"?: ((value: string | undefined) => any) | undefined;
|
|
542
|
+
"onUpdate:open"?: ((open: boolean) => any) | undefined;
|
|
543
543
|
"onFormat-change"?: ((format: import("../../types").ColorFormat) => any) | undefined;
|
|
544
544
|
} & (typeof globalThis extends {
|
|
545
545
|
__VLS_PROPS_FALLBACK: infer P;
|
|
@@ -547,7 +547,7 @@ declare const DEFAULT_CONTROL_COMPONENTS: {
|
|
|
547
547
|
expose: (exposed: {}) => void;
|
|
548
548
|
attrs: any;
|
|
549
549
|
slots: import("../../types").ColorChooserSlots;
|
|
550
|
-
emit: (((evt: "clear") => void) & ((evt: "change", value: string | undefined) => void) & ((evt: "copy", value: string) => void) & ((evt: "update:
|
|
550
|
+
emit: (((evt: "clear") => void) & ((evt: "change", value: string | undefined) => void) & ((evt: "copy", value: string) => void) & ((evt: "update:modelValue", value: string | undefined) => void) & ((evt: "update:open", open: boolean) => void) & ((evt: "format-change", format: import("../../types").ColorFormat) => void)) & ((event: "update:modelValue", value: string | undefined) => void);
|
|
551
551
|
}>) => import("vue").VNode & {
|
|
552
552
|
__ctx?: Awaited<typeof __VLS_setup>;
|
|
553
553
|
};
|
|
@@ -655,7 +655,7 @@ declare const DEFAULT_CONTROL_COMPONENTS: {
|
|
|
655
655
|
modelValue?: (import("@nuxt/ui").GetModelValue<T, VK, M, undefined> & import("@nuxt/ui").GetModelValue<T, VK, M>) | undefined;
|
|
656
656
|
class?: import("tailwind-variants").ClassValue;
|
|
657
657
|
ui?: (Record<string, import("tailwind-variants").ClassValue> & {
|
|
658
|
-
[x: string]: import("
|
|
658
|
+
[x: string]: import("@nuxt/ui").SlotClass;
|
|
659
659
|
}) | undefined;
|
|
660
660
|
onBlur?: ((event: FocusEvent) => any) | undefined;
|
|
661
661
|
onChange?: ((value: import("@nuxt/ui").GetModelValue<T, VK, M, undefined>) => any) | undefined;
|
|
@@ -4,7 +4,7 @@ declare const __VLS_export: <T extends TableData>(__VLS_props: NonNullable<Await
|
|
|
4
4
|
props: import("vue").PublicProps & __VLS_PrettifyLocal<DataTablePaginationProps<T> & {
|
|
5
5
|
uiConfig?: DataTablePaginationUi & {
|
|
6
6
|
ui?: {
|
|
7
|
-
[x: string]: import("
|
|
7
|
+
[x: string]: import("@nuxt/ui").SlotClass;
|
|
8
8
|
};
|
|
9
9
|
};
|
|
10
10
|
}> & (typeof globalThis extends {
|
|
@@ -4,7 +4,7 @@ declare const __VLS_export: <T extends TableData>(__VLS_props: NonNullable<Await
|
|
|
4
4
|
props: import("vue").PublicProps & __VLS_PrettifyLocal<DataTablePaginationProps<T> & {
|
|
5
5
|
uiConfig?: DataTablePaginationUi & {
|
|
6
6
|
ui?: {
|
|
7
|
-
[x: string]: import("
|
|
7
|
+
[x: string]: import("@nuxt/ui").SlotClass;
|
|
8
8
|
};
|
|
9
9
|
};
|
|
10
10
|
}> & (typeof globalThis extends {
|