@movk/nuxt 1.3.0 → 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/.nuxt/movk-ui.css +1 -1
- package/README.md +2 -2
- package/dist/module.json +1 -1
- package/dist/module.mjs +12 -2
- package/dist/runtime/components/AutoForm.vue +7 -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/useDateFormatter.js +7 -5
- package/dist/runtime/composables/useDownloadWithProgress.d.ts +6 -5
- package/dist/runtime/composables/useDownloadWithProgress.js +4 -16
- package/dist/runtime/composables/useTheme.d.ts +14 -12
- 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 +651 -11
- package/dist/runtime/domains/auto-form/controls.js +1 -0
- package/dist/runtime/domains/auto-form/provider.js +3 -2
- package/dist/runtime/domains/auto-form/schema.d.ts +5 -0
- package/dist/runtime/domains/auto-form/schema.js +13 -0
- package/dist/runtime/domains/data-table/columns/resolve-data-column.js +34 -2
- package/dist/runtime/domains/data-table/columns/resolve-special-columns.js +1 -1
- package/dist/runtime/domains/data-table/columns/style.js +4 -3
- 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 +21 -21
- 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
|
+
}) & {};
|
|
@@ -20,10 +20,12 @@ import {
|
|
|
20
20
|
isToday,
|
|
21
21
|
parseDate,
|
|
22
22
|
parseDateTime,
|
|
23
|
-
parseZonedDateTime
|
|
23
|
+
parseZonedDateTime,
|
|
24
|
+
parseAbsolute
|
|
24
25
|
} from "@internationalized/date";
|
|
25
26
|
const DEFAULT_LOCALE = "zh-CN";
|
|
26
27
|
const DEFAULT_FORMAT_OPTIONS = { dateStyle: "medium" };
|
|
28
|
+
const ABSOLUTE_RE = /(?:Z|[+-]\d{2}:?\d{2})$/;
|
|
27
29
|
function safe(fn, fallback) {
|
|
28
30
|
try {
|
|
29
31
|
return fn();
|
|
@@ -138,10 +140,10 @@ export function useDateFormatter(options = {}) {
|
|
|
138
140
|
}
|
|
139
141
|
function parse(value) {
|
|
140
142
|
try {
|
|
141
|
-
if (value.includes("T"))
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
return
|
|
143
|
+
if (!value.includes("T")) return parseDate(value);
|
|
144
|
+
if (value.includes("[")) return parseZonedDateTime(value);
|
|
145
|
+
if (ABSOLUTE_RE.test(value)) return parseAbsolute(value, timeZone);
|
|
146
|
+
return parseDateTime(value);
|
|
145
147
|
} catch {
|
|
146
148
|
return null;
|
|
147
149
|
}
|
|
@@ -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
|
+
type IconSet = 'lucide' | 'phosphor' | 'tabler';
|
|
1
2
|
export declare function useTheme(): {
|
|
2
|
-
color: import("vue").ComputedRef<
|
|
3
|
+
color: import("vue").ComputedRef<string>;
|
|
3
4
|
style: {
|
|
4
5
|
innerHTML: import("vue").ComputedRef<string>;
|
|
5
6
|
id: string;
|
|
@@ -7,30 +8,30 @@ export declare function useTheme(): {
|
|
|
7
8
|
}[];
|
|
8
9
|
link: import("vue").ComputedRef<{
|
|
9
10
|
rel: "stylesheet";
|
|
10
|
-
href:
|
|
11
|
+
href: string;
|
|
11
12
|
id: string;
|
|
12
13
|
}[]>;
|
|
13
|
-
neutralColors:
|
|
14
|
-
neutral: import("vue").WritableComputedRef<
|
|
14
|
+
neutralColors: string[];
|
|
15
|
+
neutral: import("vue").WritableComputedRef<string, string>;
|
|
15
16
|
primaryColors: string[];
|
|
16
|
-
primary: import("vue").WritableComputedRef<
|
|
17
|
+
primary: import("vue").WritableComputedRef<string, string>;
|
|
17
18
|
blackAsPrimary: import("vue").ComputedRef<boolean>;
|
|
18
19
|
setBlackAsPrimary: (value: boolean) => void;
|
|
19
|
-
radiuses:
|
|
20
|
-
radius: import("vue").WritableComputedRef<
|
|
21
|
-
fonts:
|
|
22
|
-
font: import("vue").WritableComputedRef<
|
|
23
|
-
icon: import("vue").WritableComputedRef<
|
|
20
|
+
radiuses: number[];
|
|
21
|
+
radius: import("vue").WritableComputedRef<number, number>;
|
|
22
|
+
fonts: string[];
|
|
23
|
+
font: import("vue").WritableComputedRef<string, string>;
|
|
24
|
+
icon: import("vue").WritableComputedRef<IconSet, IconSet>;
|
|
24
25
|
icons: {
|
|
25
26
|
label: string;
|
|
26
27
|
icon: string;
|
|
27
|
-
value:
|
|
28
|
+
value: IconSet;
|
|
28
29
|
}[];
|
|
29
30
|
modes: import("vue").ComputedRef<{
|
|
30
31
|
label: string;
|
|
31
32
|
icon: any;
|
|
32
33
|
}[]>;
|
|
33
|
-
mode: import("vue").WritableComputedRef<
|
|
34
|
+
mode: import("vue").WritableComputedRef<string, string>;
|
|
34
35
|
hasCSSChanges: import("vue").ComputedRef<boolean>;
|
|
35
36
|
hasConfigChanges: import("vue").ComputedRef<boolean>;
|
|
36
37
|
configLabel: string;
|
|
@@ -38,3 +39,4 @@ export declare function useTheme(): {
|
|
|
38
39
|
exportConfig: () => string;
|
|
39
40
|
resetTheme: () => void;
|
|
40
41
|
};
|
|
42
|
+
export {};
|
|
@@ -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
|
}
|