@w-run/wdesign-ui 1.0.0 → 1.1.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 +208 -127
- package/dist/index.d.ts +1010 -80
- package/dist/parts/WdAffix.js +159 -0
- package/dist/parts/WdAiMessage.js +277 -0
- package/dist/parts/WdAlert.js +92 -0
- package/dist/parts/WdAnchor.js +159 -0
- package/dist/parts/WdAudioPlayer.js +1024 -0
- package/dist/parts/WdAvatar.js +6 -0
- package/dist/parts/WdAvatarGroup.js +46 -0
- package/dist/parts/WdBacktop.js +120 -0
- package/dist/parts/WdBadge.js +61 -0
- package/dist/parts/WdBento.js +40 -0
- package/dist/parts/WdBentoItem.js +43 -0
- package/dist/parts/WdBottomSheet.js +263 -0
- package/dist/parts/WdBreadcrumb.js +64 -0
- package/dist/parts/WdButton.js +94 -0
- package/dist/parts/WdCalendar.js +11 -0
- package/dist/parts/WdCard.js +113 -0
- package/dist/parts/WdCarousel.js +365 -0
- package/dist/parts/WdCascader.js +386 -0
- package/dist/parts/WdCheckbox.js +81 -0
- package/dist/parts/WdCollapse.js +135 -0
- package/dist/parts/WdColorPicker.js +592 -0
- package/dist/parts/WdCommand.js +357 -0
- package/dist/parts/WdContainer.js +37 -0
- package/dist/parts/WdCountdown.js +163 -0
- package/dist/parts/WdDanmaku.js +6 -0
- package/dist/parts/WdDatePicker.js +169 -0
- package/dist/parts/WdDateTimePicker.js +162 -0
- package/dist/parts/WdDescriptions.js +146 -0
- package/dist/parts/WdDivider.js +64 -0
- package/dist/parts/WdDrawer.js +176 -0
- package/dist/parts/WdDropdown.js +140 -0
- package/dist/parts/WdEmpty.js +79 -0
- package/dist/parts/WdExplorer.js +336 -0
- package/dist/parts/WdFileList.js +177 -0
- package/dist/parts/WdForm.js +111 -0
- package/dist/parts/WdFormItem.js +156 -0
- package/dist/parts/WdGrid.js +40 -0
- package/dist/parts/WdGroup.js +68 -0
- package/dist/parts/WdImagePreview.js +274 -0
- package/dist/parts/WdInput.js +10 -0
- package/dist/parts/WdInputNumber.js +253 -0
- package/dist/parts/WdListItem.js +60 -0
- package/dist/parts/WdLoading.js +128 -0
- package/dist/parts/WdMarkdown.js +172 -0
- package/dist/parts/WdMarquee.js +80 -0
- package/dist/parts/WdMasonry.js +40 -0
- package/dist/parts/WdMediaCard.js +302 -0
- package/dist/parts/WdMentions.js +277 -0
- package/dist/parts/WdModal.js +149 -0
- package/dist/parts/WdNav.js +311 -0
- package/dist/parts/WdNotification.js +112 -0
- package/dist/parts/WdOtp.js +107 -0
- package/dist/parts/WdPagination.js +252 -0
- package/dist/parts/WdPopconfirm.js +214 -0
- package/dist/parts/WdPopover.js +203 -0
- package/dist/parts/WdPostItem.js +84 -0
- package/dist/parts/WdProgress.js +48 -0
- package/dist/parts/WdProgressRing.js +101 -0
- package/dist/parts/WdPullRefresh.js +167 -0
- package/dist/parts/WdQRCode.js +1909 -0
- package/dist/parts/WdRadioGroup.js +95 -0
- package/dist/parts/WdRate.js +128 -0
- package/dist/parts/WdResult.js +86 -0
- package/dist/parts/WdScrollbar.js +186 -0
- package/dist/parts/WdSegmented.js +11 -0
- package/dist/parts/WdSelect.js +465 -0
- package/dist/parts/WdSkeleton.js +69 -0
- package/dist/parts/WdSlider.js +100 -0
- package/dist/parts/WdSortableList.js +291 -0
- package/dist/parts/WdSpace.js +46 -0
- package/dist/parts/WdSparkline.js +148 -0
- package/dist/parts/WdSpinner.js +6 -0
- package/dist/parts/WdSplitter.js +183 -0
- package/dist/parts/WdStatBar.js +202 -0
- package/dist/parts/WdStatistic.js +131 -0
- package/dist/parts/WdSteps.js +110 -0
- package/dist/parts/WdSwitch.js +63 -0
- package/dist/parts/WdTabBar.js +84 -0
- package/dist/parts/WdTable.js +589 -0
- package/dist/parts/WdTabs.js +219 -0
- package/dist/parts/WdTag.js +6 -0
- package/dist/parts/WdTagInput.js +181 -0
- package/dist/parts/WdTimePicker.js +12 -0
- package/dist/parts/WdTimeline.js +145 -0
- package/dist/parts/WdTooltip.js +108 -0
- package/dist/parts/WdTour.js +264 -0
- package/dist/parts/WdTransfer.js +446 -0
- package/dist/parts/WdTree.js +322 -0
- package/dist/parts/WdUpload.js +309 -0
- package/dist/parts/WdVideoPlayer.js +1006 -0
- package/dist/parts/WdVirtualList.js +169 -0
- package/dist/parts/WdWatermark.js +150 -0
- package/dist/parts/chunk-3LVE72ZK.js +361 -0
- package/dist/parts/chunk-5HYOQ52I.js +101 -0
- package/dist/parts/chunk-7M3MUL3B.js +275 -0
- package/dist/parts/chunk-AOTJ63HN.js +15 -0
- package/dist/parts/chunk-AXEF2U2A.js +41 -0
- package/dist/parts/chunk-CY3QOSFP.js +645 -0
- package/dist/parts/chunk-G7NN4A6J.js +40 -0
- package/dist/parts/chunk-HAKYCUAR.js +9 -0
- package/dist/parts/chunk-JDE4AHBR.js +160 -0
- package/dist/parts/chunk-LT3NTWIT.js +117 -0
- package/dist/parts/chunk-OGHYFT7B.js +387 -0
- package/dist/parts/chunk-Q34U2HES.js +261 -0
- package/dist/parts/chunk-RLSVPJHM.js +10 -0
- package/dist/parts/chunk-U2CDKD2T.js +30 -0
- package/dist/parts/chunk-UYUNYHZD.js +40 -0
- package/dist/parts/chunk-VUJL2HGD.js +23 -0
- package/dist/parts/chunk-WCFG5KNT.js +51 -0
- package/dist/parts/chunk-WDDAALPI.js +42 -0
- package/dist/parts/chunk-WFXLDBP2.js +149 -0
- package/dist/style/affix.css +566 -0
- package/dist/style/ai-msg.css +572 -13
- package/dist/style/alert.css +577 -5
- package/dist/style/anchor.css +630 -0
- package/dist/style/audio.css +658 -67
- package/dist/style/avatar.css +575 -12
- package/dist/style/backtop.css +625 -0
- package/dist/style/badge.css +595 -11
- package/dist/style/bento.css +763 -0
- package/dist/style/bottom-sheet.css +776 -0
- package/dist/style/breadcrumb.css +579 -4
- package/dist/style/button.css +631 -36
- package/dist/style/calendar.css +1512 -0
- package/dist/style/card.css +683 -6
- package/dist/style/carousel.css +573 -4
- package/dist/style/cascader.css +862 -0
- package/dist/style/checkbox.css +584 -7
- package/dist/style/chevron.css +543 -1
- package/dist/style/collapse.css +586 -7
- package/dist/style/colorpicker.css +876 -0
- package/dist/style/command.css +572 -13
- package/dist/style/container.css +543 -0
- package/dist/style/countdown.css +722 -0
- package/dist/style/danmaku.css +644 -0
- package/dist/style/datepicker.css +606 -128
- package/dist/style/datetime-picker.css +714 -0
- package/dist/style/descriptions.css +604 -11
- package/dist/style/divider.css +544 -2
- package/dist/style/dot.css +556 -1
- package/dist/style/drawer.css +609 -11
- package/dist/style/dropdown.css +565 -3
- package/dist/style/empty.css +624 -3
- package/dist/style/explorer.css +632 -24
- package/dist/style/file-list.css +577 -5
- package/dist/style/flip.css +600 -0
- package/dist/style/form.css +550 -8
- package/dist/style/grid.css +614 -0
- package/dist/style/group.css +560 -16
- package/dist/style/icon-btn.css +570 -4
- package/dist/style/image-preview.css +652 -8
- package/dist/style/input-number.css +680 -0
- package/dist/style/input.css +571 -8
- package/dist/style/list.css +553 -4
- package/dist/style/loading.css +667 -0
- package/dist/style/markdown.css +592 -20
- package/dist/style/marquee.css +678 -0
- package/dist/style/masonry.css +614 -0
- package/dist/style/media-card.css +1229 -0
- package/dist/style/mentions.css +690 -0
- package/dist/style/modal.css +626 -15
- package/dist/style/nav.css +1046 -0
- package/dist/style/notification.css +556 -7
- package/dist/style/otp.css +567 -7
- package/dist/style/pagination.css +571 -11
- package/dist/style/popconfirm.css +568 -10
- package/dist/style/popover.css +645 -15
- package/dist/style/post-item.css +548 -6
- package/dist/style/progress-ring.css +640 -0
- package/dist/style/progress.css +543 -1
- package/dist/style/pull-refresh.css +637 -0
- package/dist/style/qrcode.css +613 -0
- package/dist/style/radio.css +584 -5
- package/dist/style/rate.css +594 -1
- package/dist/style/result.css +546 -3
- package/dist/style/scroll-reveal.css +613 -0
- package/dist/style/scrollbar.css +644 -0
- package/dist/style/segmented-picker.css +573 -14
- package/dist/style/segmented.css +711 -7
- package/dist/style/select.css +682 -26
- package/dist/style/skeleton.css +559 -0
- package/dist/style/slider.css +565 -4
- package/dist/style/sortable.css +593 -7
- package/dist/style/space.css +543 -0
- package/dist/style/sparkline.css +606 -0
- package/dist/style/spinner.css +559 -0
- package/dist/style/splitter.css +711 -0
- package/dist/style/stat-bar.css +767 -0
- package/dist/style/statistic.css +552 -7
- package/dist/style/steps.css +633 -9
- package/dist/style/switch.css +585 -4
- package/dist/style/tab-bar.css +647 -0
- package/dist/style/table.css +886 -36
- package/dist/style/tabs.css +599 -10
- package/dist/style/tag-input.css +710 -0
- package/dist/style/tag.css +603 -18
- package/dist/style/time-picker.css +749 -0
- package/dist/style/timeline.css +575 -14
- package/dist/style/toast.css +567 -6
- package/dist/style/tooltip.css +564 -5
- package/dist/style/tour.css +683 -0
- package/dist/style/transfer.css +858 -0
- package/dist/style/tree.css +613 -16
- package/dist/style/typography.css +884 -3
- package/dist/style/upload.css +602 -13
- package/dist/style/vlist.css +543 -1
- package/dist/style/vplayer.css +799 -57
- package/dist/style/watermark.css +570 -0
- package/dist/wdesign-ui.css +18055 -7262
- package/dist/wdesign-ui.esm.js +8976 -5044
- package/package.json +99 -13
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useControllable
|
|
3
|
+
} from "./chunk-G7NN4A6J.js";
|
|
4
|
+
import {
|
|
5
|
+
WdSpinner_default
|
|
6
|
+
} from "./chunk-WDDAALPI.js";
|
|
7
|
+
import {
|
|
8
|
+
WdIcon_default
|
|
9
|
+
} from "./chunk-Q34U2HES.js";
|
|
10
|
+
|
|
11
|
+
// .lib-build/WdTree.ts
|
|
12
|
+
import { defineComponent as _defineComponent } from "vue";
|
|
13
|
+
import { renderList as _renderList, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock, unref as _unref, createBlock as _createBlock, createCommentVNode as _createCommentVNode, withModifiers as _withModifiers, normalizeClass as _normalizeClass, createElementVNode as _createElementVNode, renderSlot as _renderSlot, toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, normalizeStyle as _normalizeStyle, createVNode as _createVNode } from "vue";
|
|
14
|
+
import { computed, ref } from "vue";
|
|
15
|
+
var _hoisted_1 = ["data-k", "tabindex", "aria-expanded", "aria-selected", "aria-disabled", "onClick", "onKeydown"];
|
|
16
|
+
var _hoisted_2 = ["onClick"];
|
|
17
|
+
var _hoisted_3 = ["checked", ".indeterminate", "disabled", "onChange"];
|
|
18
|
+
var _hoisted_4 = {
|
|
19
|
+
key: 1,
|
|
20
|
+
class: "wd-tree__icon"
|
|
21
|
+
};
|
|
22
|
+
var _hoisted_5 = { class: "wd-tree__label" };
|
|
23
|
+
var _hoisted_6 = {
|
|
24
|
+
key: 0,
|
|
25
|
+
class: "wd-tree__loading",
|
|
26
|
+
role: "status",
|
|
27
|
+
"aria-live": "polite"
|
|
28
|
+
};
|
|
29
|
+
var _hoisted_7 = {
|
|
30
|
+
key: 1,
|
|
31
|
+
class: "wd-tree__empty"
|
|
32
|
+
};
|
|
33
|
+
var WdTree_default = /* @__PURE__ */ _defineComponent({
|
|
34
|
+
...{ name: "WdTree" },
|
|
35
|
+
__name: "WdTree",
|
|
36
|
+
props: {
|
|
37
|
+
nodes: { type: Array, required: false, default: () => [] },
|
|
38
|
+
expandedKeys: { type: Array, required: false },
|
|
39
|
+
selectedKey: { type: [String, Number, null], required: false },
|
|
40
|
+
checkable: { type: Boolean, required: false, default: false },
|
|
41
|
+
checkedKeys: { type: Array, required: false },
|
|
42
|
+
cascade: { type: Boolean, required: false, default: true },
|
|
43
|
+
showLine: { type: Boolean, required: false, default: false },
|
|
44
|
+
emptyText: { type: String, required: false, default: "\u6682\u65E0\u6570\u636E" },
|
|
45
|
+
indent: { type: Number, required: false, default: 18 },
|
|
46
|
+
defaultExpandedKeys: { type: Array, required: false, default: () => [] },
|
|
47
|
+
defaultSelectedKey: { type: [String, Number, null], required: false, default: null },
|
|
48
|
+
defaultCheckedKeys: { type: Array, required: false, default: () => [] },
|
|
49
|
+
loading: { type: Boolean, required: false, default: false }
|
|
50
|
+
},
|
|
51
|
+
emits: ["update:expandedKeys", "update:selectedKey", "update:checkedKeys", "select", "check", "expand"],
|
|
52
|
+
setup(__props, { emit: __emit }) {
|
|
53
|
+
const props = __props;
|
|
54
|
+
const emit = __emit;
|
|
55
|
+
const keyOf = (n) => n.key ?? n.label;
|
|
56
|
+
const { value: expanded, set: setExpanded } = useControllable({
|
|
57
|
+
modelValue: computed(() => props.expandedKeys),
|
|
58
|
+
defaultValue: computed(() => props.defaultExpandedKeys),
|
|
59
|
+
fallback: [],
|
|
60
|
+
onChange: (v) => emit("update:expandedKeys", v)
|
|
61
|
+
});
|
|
62
|
+
const { value: selected, set: setSelected } = useControllable({
|
|
63
|
+
modelValue: computed(() => props.selectedKey),
|
|
64
|
+
defaultValue: computed(() => props.defaultSelectedKey),
|
|
65
|
+
fallback: null,
|
|
66
|
+
onChange: (v) => {
|
|
67
|
+
if (v !== null) emit("update:selectedKey", v);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
const { value: checked, set: setChecked } = useControllable({
|
|
71
|
+
modelValue: computed(() => props.checkedKeys),
|
|
72
|
+
defaultValue: computed(() => props.defaultCheckedKeys),
|
|
73
|
+
fallback: [],
|
|
74
|
+
onChange: (v) => emit("update:checkedKeys", v)
|
|
75
|
+
});
|
|
76
|
+
function isExpanded(k) {
|
|
77
|
+
return expanded.value.includes(k);
|
|
78
|
+
}
|
|
79
|
+
const isChecked = (k) => checked.value.includes(k);
|
|
80
|
+
function collectKeys(n, out = []) {
|
|
81
|
+
out.push(keyOf(n));
|
|
82
|
+
n.children?.forEach((c) => collectKeys(c, out));
|
|
83
|
+
return out;
|
|
84
|
+
}
|
|
85
|
+
function ancestry(target, list = props.nodes, trail = []) {
|
|
86
|
+
for (const n of list) {
|
|
87
|
+
if (keyOf(n) === target) return trail;
|
|
88
|
+
if (n.children) {
|
|
89
|
+
const r = ancestry(target, n.children, [...trail, n]);
|
|
90
|
+
if (r.length || keyOf(n) === target) return r;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return [];
|
|
94
|
+
}
|
|
95
|
+
function toggleExpand(n) {
|
|
96
|
+
const k = keyOf(n);
|
|
97
|
+
const wasOpen = isExpanded(k);
|
|
98
|
+
const next = wasOpen ? expanded.value.filter((x) => x !== k) : [...expanded.value, k];
|
|
99
|
+
setExpanded(next);
|
|
100
|
+
emit("expand", n, !wasOpen);
|
|
101
|
+
}
|
|
102
|
+
function select(n) {
|
|
103
|
+
if (n.disabled || props.loading) return;
|
|
104
|
+
setSelected(keyOf(n));
|
|
105
|
+
emit("select", n);
|
|
106
|
+
}
|
|
107
|
+
function toggleCheck(n) {
|
|
108
|
+
if (n.disabled) return;
|
|
109
|
+
const k = keyOf(n);
|
|
110
|
+
const on = !isChecked(k);
|
|
111
|
+
let next = new Set(checked.value);
|
|
112
|
+
const setDeep = (node, v) => {
|
|
113
|
+
const kk = keyOf(node);
|
|
114
|
+
if (v) next.add(kk);
|
|
115
|
+
else next.delete(kk);
|
|
116
|
+
node.children?.forEach((c) => setDeep(c, v));
|
|
117
|
+
};
|
|
118
|
+
if (props.cascade) setDeep(n, on);
|
|
119
|
+
else on ? next.add(k) : next.delete(k);
|
|
120
|
+
if (props.cascade) {
|
|
121
|
+
let chain = ancestry(k);
|
|
122
|
+
for (let i = chain.length - 1; i >= 0; i--) {
|
|
123
|
+
const p = chain[i];
|
|
124
|
+
const kids = p.children || [];
|
|
125
|
+
const all = kids.length > 0 && kids.every((c) => next.has(keyOf(c)));
|
|
126
|
+
all ? next.add(keyOf(p)) : next.delete(keyOf(p));
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
const arr = [...next];
|
|
130
|
+
setChecked(arr);
|
|
131
|
+
emit("check", n, on);
|
|
132
|
+
}
|
|
133
|
+
function isIndeterminate(n) {
|
|
134
|
+
if (!props.checkable || !props.cascade) return false;
|
|
135
|
+
const kids = n.children || [];
|
|
136
|
+
if (!kids.length) return false;
|
|
137
|
+
const on = kids.filter((c) => isChecked(keyOf(c))).length;
|
|
138
|
+
return on > 0 && on < kids.length;
|
|
139
|
+
}
|
|
140
|
+
const flat = computed(() => {
|
|
141
|
+
if (props.loading) return [];
|
|
142
|
+
const out = [];
|
|
143
|
+
const walk = (list, depth, parent) => {
|
|
144
|
+
for (const n of list) {
|
|
145
|
+
out.push({ node: n, depth, parent });
|
|
146
|
+
if (n.children?.length && isExpanded(keyOf(n))) walk(n.children, depth + 1, n);
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
walk(props.nodes, 0, null);
|
|
150
|
+
return out;
|
|
151
|
+
});
|
|
152
|
+
const focusKey = ref(null);
|
|
153
|
+
const treeEl = ref(null);
|
|
154
|
+
function focusNode(k) {
|
|
155
|
+
focusKey.value = k;
|
|
156
|
+
treeEl.value?.querySelector(`[data-k="${CSS.escape(String(k))}"]`)?.focus();
|
|
157
|
+
}
|
|
158
|
+
function moveFocus(dir) {
|
|
159
|
+
const list = flat.value.filter((x) => !x.node.disabled);
|
|
160
|
+
if (!list.length) return;
|
|
161
|
+
const curKey = document.activeElement?.getAttribute?.("data-k") ?? (focusKey.value !== null ? String(focusKey.value) : null) ?? (selected.value !== null && selected.value !== void 0 ? String(selected.value) : null);
|
|
162
|
+
const i = list.findIndex((x) => String(keyOf(x.node)) === curKey);
|
|
163
|
+
const next = i < 0 ? 0 : Math.min(list.length - 1, Math.max(0, i + dir));
|
|
164
|
+
focusNode(keyOf(list[next].node));
|
|
165
|
+
}
|
|
166
|
+
function onKeydown(e, entry) {
|
|
167
|
+
const n = entry.node;
|
|
168
|
+
const k = keyOf(n);
|
|
169
|
+
switch (e.key) {
|
|
170
|
+
case "ArrowDown":
|
|
171
|
+
e.preventDefault();
|
|
172
|
+
moveFocus(1);
|
|
173
|
+
break;
|
|
174
|
+
case "ArrowUp":
|
|
175
|
+
e.preventDefault();
|
|
176
|
+
moveFocus(-1);
|
|
177
|
+
break;
|
|
178
|
+
case "ArrowRight":
|
|
179
|
+
e.preventDefault();
|
|
180
|
+
if (n.children?.length && !isExpanded(k)) toggleExpand(n);
|
|
181
|
+
else moveFocus(1);
|
|
182
|
+
break;
|
|
183
|
+
case "ArrowLeft": {
|
|
184
|
+
e.preventDefault();
|
|
185
|
+
const parent = flat.value.find((x) => keyOf(x.node) === k)?.parent;
|
|
186
|
+
if (n.children?.length && isExpanded(k)) toggleExpand(n);
|
|
187
|
+
else if (parent) focusNode(keyOf(parent));
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
case "Enter":
|
|
191
|
+
case " ":
|
|
192
|
+
e.preventDefault();
|
|
193
|
+
select(n);
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
const depthPad = (d) => `${d * props.indent + 8}px`;
|
|
198
|
+
function lineX(depth) {
|
|
199
|
+
if (!depth) return "0px";
|
|
200
|
+
return `${(depth - 1) * props.indent + 8 + 8}px`;
|
|
201
|
+
}
|
|
202
|
+
return (_ctx, _cache) => {
|
|
203
|
+
return _openBlock(), _createElementBlock(
|
|
204
|
+
"div",
|
|
205
|
+
{
|
|
206
|
+
ref_key: "treeEl",
|
|
207
|
+
ref: treeEl,
|
|
208
|
+
class: _normalizeClass(["wd-tree", { "wd-tree--line": __props.showLine }]),
|
|
209
|
+
role: "tree",
|
|
210
|
+
onKeydown: _cache[2] || (_cache[2] = _withModifiers(() => {
|
|
211
|
+
}, ["self", "prevent"]))
|
|
212
|
+
},
|
|
213
|
+
[
|
|
214
|
+
(_openBlock(true), _createElementBlock(
|
|
215
|
+
_Fragment,
|
|
216
|
+
null,
|
|
217
|
+
_renderList(flat.value, (entry) => {
|
|
218
|
+
return _openBlock(), _createElementBlock("div", {
|
|
219
|
+
key: keyOf(entry.node),
|
|
220
|
+
class: _normalizeClass(["wd-tree__node", {
|
|
221
|
+
"wd-tree__node--selected": _unref(selected) === keyOf(entry.node),
|
|
222
|
+
"wd-tree__node--disabled": entry.node.disabled
|
|
223
|
+
}]),
|
|
224
|
+
role: "treeitem",
|
|
225
|
+
"data-k": keyOf(entry.node),
|
|
226
|
+
tabindex: entry.node.disabled ? -1 : 0,
|
|
227
|
+
"aria-expanded": entry.node.children?.length ? isExpanded(keyOf(entry.node)) : void 0,
|
|
228
|
+
"aria-selected": _unref(selected) === keyOf(entry.node),
|
|
229
|
+
"aria-disabled": entry.node.disabled || void 0,
|
|
230
|
+
style: _normalizeStyle({ paddingLeft: depthPad(entry.depth), "--wd-tree-line-x": lineX(entry.depth) }),
|
|
231
|
+
onClick: ($event) => select(entry.node),
|
|
232
|
+
onKeydown: ($event) => onKeydown($event, entry)
|
|
233
|
+
}, [
|
|
234
|
+
_createElementVNode("span", {
|
|
235
|
+
class: _normalizeClass(["wd-tree__arrow", { "wd-tree__arrow--open": isExpanded(keyOf(entry.node)), "wd-tree__arrow--leaf": !entry.node.children?.length }]),
|
|
236
|
+
onClick: _withModifiers(($event) => entry.node.children?.length && toggleExpand(entry.node), ["stop"])
|
|
237
|
+
}, [
|
|
238
|
+
entry.node.children?.length ? (_openBlock(), _createBlock(_unref(WdIcon_default), {
|
|
239
|
+
key: 0,
|
|
240
|
+
name: "chevron-right",
|
|
241
|
+
size: 10
|
|
242
|
+
})) : _createCommentVNode("v-if", true)
|
|
243
|
+
], 10, _hoisted_2),
|
|
244
|
+
__props.checkable ? (_openBlock(), _createElementBlock("label", {
|
|
245
|
+
key: 0,
|
|
246
|
+
class: "wd-tree__check",
|
|
247
|
+
onClick: _cache[0] || (_cache[0] = _withModifiers(() => {
|
|
248
|
+
}, ["stop"]))
|
|
249
|
+
}, [
|
|
250
|
+
_createElementVNode("input", {
|
|
251
|
+
type: "checkbox",
|
|
252
|
+
checked: isChecked(keyOf(entry.node)),
|
|
253
|
+
".indeterminate": isIndeterminate(entry.node),
|
|
254
|
+
disabled: entry.node.disabled,
|
|
255
|
+
onChange: ($event) => toggleCheck(entry.node)
|
|
256
|
+
}, null, 40, _hoisted_3)
|
|
257
|
+
])) : _createCommentVNode("v-if", true),
|
|
258
|
+
entry.node.icon || _ctx.$slots.icon ? (_openBlock(), _createElementBlock("span", _hoisted_4, [
|
|
259
|
+
_renderSlot(_ctx.$slots, "icon", {
|
|
260
|
+
node: entry.node
|
|
261
|
+
}, () => [
|
|
262
|
+
_createTextVNode(
|
|
263
|
+
_toDisplayString(entry.node.icon),
|
|
264
|
+
1
|
|
265
|
+
/* TEXT */
|
|
266
|
+
)
|
|
267
|
+
])
|
|
268
|
+
])) : _createCommentVNode("v-if", true),
|
|
269
|
+
_createElementVNode("span", _hoisted_5, [
|
|
270
|
+
_renderSlot(_ctx.$slots, "label", {
|
|
271
|
+
node: entry.node
|
|
272
|
+
}, () => [
|
|
273
|
+
_createTextVNode(
|
|
274
|
+
_toDisplayString(entry.node.label),
|
|
275
|
+
1
|
|
276
|
+
/* TEXT */
|
|
277
|
+
)
|
|
278
|
+
])
|
|
279
|
+
]),
|
|
280
|
+
_ctx.$slots.extra ? (_openBlock(), _createElementBlock("span", {
|
|
281
|
+
key: 2,
|
|
282
|
+
class: "wd-tree__extra",
|
|
283
|
+
onClick: _cache[1] || (_cache[1] = _withModifiers(() => {
|
|
284
|
+
}, ["stop"]))
|
|
285
|
+
}, [
|
|
286
|
+
_renderSlot(_ctx.$slots, "extra", {
|
|
287
|
+
node: entry.node
|
|
288
|
+
})
|
|
289
|
+
])) : _createCommentVNode("v-if", true)
|
|
290
|
+
], 46, _hoisted_1);
|
|
291
|
+
}),
|
|
292
|
+
128
|
|
293
|
+
/* KEYED_FRAGMENT */
|
|
294
|
+
)),
|
|
295
|
+
__props.loading ? (_openBlock(), _createElementBlock("div", _hoisted_6, [
|
|
296
|
+
_createVNode(WdSpinner_default, { size: "sm" }),
|
|
297
|
+
_cache[3] || (_cache[3] = _createElementVNode(
|
|
298
|
+
"span",
|
|
299
|
+
null,
|
|
300
|
+
"\u52A0\u8F7D\u4E2D\u2026",
|
|
301
|
+
-1
|
|
302
|
+
/* CACHED */
|
|
303
|
+
))
|
|
304
|
+
])) : !flat.value.length ? (_openBlock(), _createElementBlock("div", _hoisted_7, [
|
|
305
|
+
_renderSlot(_ctx.$slots, "empty", {}, () => [
|
|
306
|
+
_createTextVNode(
|
|
307
|
+
_toDisplayString(__props.emptyText),
|
|
308
|
+
1
|
|
309
|
+
/* TEXT */
|
|
310
|
+
)
|
|
311
|
+
])
|
|
312
|
+
])) : _createCommentVNode("v-if", true)
|
|
313
|
+
],
|
|
314
|
+
34
|
|
315
|
+
/* CLASS, NEED_HYDRATION */
|
|
316
|
+
);
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
export {
|
|
321
|
+
WdTree_default as WdTree
|
|
322
|
+
};
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useControllable
|
|
3
|
+
} from "./chunk-G7NN4A6J.js";
|
|
4
|
+
import {
|
|
5
|
+
useFormItemA11y
|
|
6
|
+
} from "./chunk-VUJL2HGD.js";
|
|
7
|
+
import "./chunk-UYUNYHZD.js";
|
|
8
|
+
import {
|
|
9
|
+
WdIcon_default
|
|
10
|
+
} from "./chunk-Q34U2HES.js";
|
|
11
|
+
|
|
12
|
+
// .lib-build/WdUpload.ts
|
|
13
|
+
import { defineComponent as _defineComponent } from "vue";
|
|
14
|
+
import { unref as _unref, createVNode as _createVNode, createElementVNode as _createElementVNode, createTextVNode as _createTextVNode, toDisplayString as _toDisplayString, openBlock as _openBlock, createElementBlock as _createElementBlock, createCommentVNode as _createCommentVNode, withModifiers as _withModifiers, normalizeClass as _normalizeClass, renderList as _renderList, Fragment as _Fragment, normalizeStyle as _normalizeStyle, mergeProps as _mergeProps } from "vue";
|
|
15
|
+
import { computed, ref } from "vue";
|
|
16
|
+
var _hoisted_1 = ["aria-disabled"];
|
|
17
|
+
var _hoisted_2 = { class: "wd-upload__icon" };
|
|
18
|
+
var _hoisted_3 = {
|
|
19
|
+
key: 0,
|
|
20
|
+
class: "wd-upload__hint"
|
|
21
|
+
};
|
|
22
|
+
var _hoisted_4 = ["accept", "multiple", "disabled"];
|
|
23
|
+
var _hoisted_5 = {
|
|
24
|
+
key: 1,
|
|
25
|
+
class: "wd-upload__error"
|
|
26
|
+
};
|
|
27
|
+
var _hoisted_6 = {
|
|
28
|
+
key: 0,
|
|
29
|
+
class: "wd-upload__list"
|
|
30
|
+
};
|
|
31
|
+
var _hoisted_7 = { class: "wd-upload__file-icon" };
|
|
32
|
+
var _hoisted_8 = { class: "wd-upload__info" };
|
|
33
|
+
var _hoisted_9 = { class: "wd-upload__name" };
|
|
34
|
+
var _hoisted_10 = {
|
|
35
|
+
key: 0,
|
|
36
|
+
class: "wd-upload__progress"
|
|
37
|
+
};
|
|
38
|
+
var _hoisted_11 = ["disabled", "onClick"];
|
|
39
|
+
var _hoisted_12 = ["disabled", "onClick"];
|
|
40
|
+
var WdUpload_default = /* @__PURE__ */ _defineComponent({
|
|
41
|
+
...{ name: "WdUpload" },
|
|
42
|
+
__name: "WdUpload",
|
|
43
|
+
props: {
|
|
44
|
+
modelValue: { type: Array, required: false },
|
|
45
|
+
defaultValue: { type: Array, required: false, default: () => [] },
|
|
46
|
+
accept: { type: String, required: false, default: "*" },
|
|
47
|
+
multiple: { type: Boolean, required: false, default: false },
|
|
48
|
+
hint: { type: String, required: false, default: "" },
|
|
49
|
+
maxCount: { type: Number, required: false, default: 0 },
|
|
50
|
+
maxSize: { type: Number, required: false, default: 0 },
|
|
51
|
+
showList: { type: Boolean, required: false, default: true },
|
|
52
|
+
disabled: { type: Boolean, required: false, default: false },
|
|
53
|
+
request: { type: Function, required: false }
|
|
54
|
+
},
|
|
55
|
+
emits: ["change", "exceed", "success", "error", "update:modelValue"],
|
|
56
|
+
setup(__props, { emit: __emit }) {
|
|
57
|
+
const formA11y = useFormItemA11y();
|
|
58
|
+
const props = __props;
|
|
59
|
+
const emit = __emit;
|
|
60
|
+
const { value: files, set: setFiles } = useControllable({
|
|
61
|
+
modelValue: computed(() => props.modelValue),
|
|
62
|
+
defaultValue: computed(() => props.defaultValue),
|
|
63
|
+
fallback: [],
|
|
64
|
+
onChange: (v) => emit("update:modelValue", v)
|
|
65
|
+
});
|
|
66
|
+
const error = ref("");
|
|
67
|
+
const dragging = ref(false);
|
|
68
|
+
const input = ref();
|
|
69
|
+
const raws = /* @__PURE__ */ new Map();
|
|
70
|
+
let seq = 0;
|
|
71
|
+
function fmtSize(n) {
|
|
72
|
+
if (n < 1024) return n + " B";
|
|
73
|
+
if (n < 1048576) return (n / 1024).toFixed(1) + " KB";
|
|
74
|
+
return (n / 1048576).toFixed(1) + " MB";
|
|
75
|
+
}
|
|
76
|
+
function mutate(fn) {
|
|
77
|
+
const next = fn(files.value);
|
|
78
|
+
setFiles(next);
|
|
79
|
+
emit("change", next);
|
|
80
|
+
}
|
|
81
|
+
function patch(uid, p) {
|
|
82
|
+
mutate((list) => list.map((f) => f.uid === uid ? { ...f, ...p } : f));
|
|
83
|
+
}
|
|
84
|
+
async function start(uid) {
|
|
85
|
+
const raw = raws.get(uid);
|
|
86
|
+
if (!raw) return;
|
|
87
|
+
if (!props.request) {
|
|
88
|
+
patch(uid, { status: "ready", percent: 0, error: void 0 });
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
patch(uid, { status: "uploading", percent: 0, error: void 0 });
|
|
92
|
+
let last = 0;
|
|
93
|
+
try {
|
|
94
|
+
await props.request(raw, (p) => {
|
|
95
|
+
const v = Math.max(0, Math.min(100, Math.round(p)));
|
|
96
|
+
if (v === last) return;
|
|
97
|
+
last = v;
|
|
98
|
+
patch(uid, { percent: v });
|
|
99
|
+
});
|
|
100
|
+
patch(uid, { status: "success", percent: 100 });
|
|
101
|
+
emit("success", files.value.find((f) => f.uid === uid));
|
|
102
|
+
} catch (e) {
|
|
103
|
+
patch(uid, { status: "error", error: e?.message || "\u4E0A\u4F20\u5931\u8D25" });
|
|
104
|
+
emit("error", files.value.find((f) => f.uid === uid));
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function addFiles(list) {
|
|
108
|
+
if (props.disabled) return;
|
|
109
|
+
error.value = "";
|
|
110
|
+
const incoming = [];
|
|
111
|
+
for (const f of Array.from(list)) {
|
|
112
|
+
if (props.maxCount > 0 && files.value.length + incoming.length >= props.maxCount) {
|
|
113
|
+
error.value = "\u6700\u591A\u4E0A\u4F20 " + props.maxCount + " \u4E2A\u6587\u4EF6";
|
|
114
|
+
emit("exceed", "count", f);
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
if (props.maxSize > 0 && f.size > props.maxSize) {
|
|
118
|
+
error.value = f.name + " \u8D85\u8FC7 " + fmtSize(props.maxSize) + " \u4E0A\u9650";
|
|
119
|
+
emit("exceed", "size", f);
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
if (!props.multiple && files.value.length + incoming.length >= 1) incoming.length = 0;
|
|
123
|
+
const uid = "f" + ++seq;
|
|
124
|
+
raws.set(uid, f);
|
|
125
|
+
incoming.push({ uid, name: f.name, size: f.size, percent: 0, status: "ready" });
|
|
126
|
+
}
|
|
127
|
+
if (!incoming.length) return;
|
|
128
|
+
mutate((cur) => [...cur, ...incoming]);
|
|
129
|
+
for (const item of incoming) void start(item.uid);
|
|
130
|
+
}
|
|
131
|
+
function remove(i) {
|
|
132
|
+
if (props.disabled) return;
|
|
133
|
+
const target = files.value[i];
|
|
134
|
+
if (target) raws.delete(target.uid);
|
|
135
|
+
mutate((list) => list.filter((_, idx) => idx !== i));
|
|
136
|
+
}
|
|
137
|
+
function retry(uid) {
|
|
138
|
+
void start(uid);
|
|
139
|
+
}
|
|
140
|
+
function openPicker() {
|
|
141
|
+
if (props.disabled) return;
|
|
142
|
+
input.value?.click();
|
|
143
|
+
}
|
|
144
|
+
function onPick(e) {
|
|
145
|
+
const target = e.target;
|
|
146
|
+
addFiles(target.files || []);
|
|
147
|
+
target.value = "";
|
|
148
|
+
}
|
|
149
|
+
function onDrop(e) {
|
|
150
|
+
e.preventDefault();
|
|
151
|
+
dragging.value = false;
|
|
152
|
+
if (e.dataTransfer) addFiles(e.dataTransfer.files);
|
|
153
|
+
}
|
|
154
|
+
function metaOf(f) {
|
|
155
|
+
const size = fmtSize(f.size);
|
|
156
|
+
if (f.status === "success") return size + " \xB7 \u5DF2\u5B8C\u6210";
|
|
157
|
+
if (f.status === "error") return size + " \xB7 " + (f.error || "\u4E0A\u4F20\u5931\u8D25");
|
|
158
|
+
if (f.status === "uploading") return size + " \xB7 \u4E0A\u4F20\u4E2D " + f.percent + "%";
|
|
159
|
+
return size + " \xB7 \u5F85\u4E0A\u4F20";
|
|
160
|
+
}
|
|
161
|
+
return (_ctx, _cache) => {
|
|
162
|
+
return _openBlock(), _createElementBlock(
|
|
163
|
+
"div",
|
|
164
|
+
_mergeProps({
|
|
165
|
+
class: ["wd-upload", { "is-disabled": __props.disabled }]
|
|
166
|
+
}, _unref(formA11y).attrs.value),
|
|
167
|
+
[
|
|
168
|
+
_createElementVNode("div", {
|
|
169
|
+
class: _normalizeClass(["wd-upload__zone", { "wd-upload__zone--over": dragging.value }]),
|
|
170
|
+
"aria-disabled": __props.disabled,
|
|
171
|
+
onClick: openPicker,
|
|
172
|
+
onDragover: _cache[0] || (_cache[0] = _withModifiers(($event) => !__props.disabled && (dragging.value = true), ["prevent"])),
|
|
173
|
+
onDragleave: _cache[1] || (_cache[1] = ($event) => dragging.value = false),
|
|
174
|
+
onDrop
|
|
175
|
+
}, [
|
|
176
|
+
_createElementVNode("span", _hoisted_2, [
|
|
177
|
+
_createVNode(_unref(WdIcon_default), {
|
|
178
|
+
name: "upload",
|
|
179
|
+
size: 30
|
|
180
|
+
})
|
|
181
|
+
]),
|
|
182
|
+
_cache[2] || (_cache[2] = _createElementVNode(
|
|
183
|
+
"span",
|
|
184
|
+
{ class: "wd-upload__hint" },
|
|
185
|
+
[
|
|
186
|
+
_createElementVNode("strong", null, "\u70B9\u51FB\u9009\u62E9"),
|
|
187
|
+
_createTextVNode(" \u6216\u62D6\u62FD\u6587\u4EF6\u5230\u8FD9\u91CC")
|
|
188
|
+
],
|
|
189
|
+
-1
|
|
190
|
+
/* CACHED */
|
|
191
|
+
)),
|
|
192
|
+
__props.hint ? (_openBlock(), _createElementBlock(
|
|
193
|
+
"span",
|
|
194
|
+
_hoisted_3,
|
|
195
|
+
_toDisplayString(__props.hint),
|
|
196
|
+
1
|
|
197
|
+
/* TEXT */
|
|
198
|
+
)) : _createCommentVNode("v-if", true),
|
|
199
|
+
_cache[3] || (_cache[3] = _createElementVNode(
|
|
200
|
+
"span",
|
|
201
|
+
{ class: "wd-upload__browse" },
|
|
202
|
+
"\u6D4F\u89C8\u6587\u4EF6",
|
|
203
|
+
-1
|
|
204
|
+
/* CACHED */
|
|
205
|
+
)),
|
|
206
|
+
_createElementVNode("input", {
|
|
207
|
+
ref_key: "input",
|
|
208
|
+
ref: input,
|
|
209
|
+
class: "wd-upload__input",
|
|
210
|
+
type: "file",
|
|
211
|
+
accept: __props.accept,
|
|
212
|
+
multiple: __props.multiple,
|
|
213
|
+
disabled: __props.disabled,
|
|
214
|
+
onChange: onPick
|
|
215
|
+
}, null, 40, _hoisted_4),
|
|
216
|
+
error.value ? (_openBlock(), _createElementBlock(
|
|
217
|
+
"span",
|
|
218
|
+
_hoisted_5,
|
|
219
|
+
_toDisplayString(error.value),
|
|
220
|
+
1
|
|
221
|
+
/* TEXT */
|
|
222
|
+
)) : _createCommentVNode("v-if", true)
|
|
223
|
+
], 42, _hoisted_1),
|
|
224
|
+
__props.showList && _unref(files).length ? (_openBlock(), _createElementBlock("div", _hoisted_6, [
|
|
225
|
+
(_openBlock(true), _createElementBlock(
|
|
226
|
+
_Fragment,
|
|
227
|
+
null,
|
|
228
|
+
_renderList(_unref(files), (f, i) => {
|
|
229
|
+
return _openBlock(), _createElementBlock(
|
|
230
|
+
"div",
|
|
231
|
+
{
|
|
232
|
+
key: f.uid,
|
|
233
|
+
class: _normalizeClass(["wd-upload__item", { "wd-upload__item--error": f.status === "error" }])
|
|
234
|
+
},
|
|
235
|
+
[
|
|
236
|
+
_createElementVNode("span", _hoisted_7, [
|
|
237
|
+
_createVNode(_unref(WdIcon_default), {
|
|
238
|
+
name: "file",
|
|
239
|
+
size: 16
|
|
240
|
+
})
|
|
241
|
+
]),
|
|
242
|
+
_createElementVNode("div", _hoisted_8, [
|
|
243
|
+
_createElementVNode(
|
|
244
|
+
"div",
|
|
245
|
+
_hoisted_9,
|
|
246
|
+
_toDisplayString(f.name),
|
|
247
|
+
1
|
|
248
|
+
/* TEXT */
|
|
249
|
+
),
|
|
250
|
+
_createElementVNode(
|
|
251
|
+
"div",
|
|
252
|
+
{
|
|
253
|
+
class: _normalizeClass(["wd-upload__meta", { "wd-upload__meta--error": f.status === "error" }])
|
|
254
|
+
},
|
|
255
|
+
_toDisplayString(metaOf(f)),
|
|
256
|
+
3
|
|
257
|
+
/* TEXT, CLASS */
|
|
258
|
+
),
|
|
259
|
+
f.status === "uploading" ? (_openBlock(), _createElementBlock("div", _hoisted_10, [
|
|
260
|
+
_createElementVNode(
|
|
261
|
+
"span",
|
|
262
|
+
{
|
|
263
|
+
class: "wd-upload__progress-bar",
|
|
264
|
+
style: _normalizeStyle({ width: f.percent + "%" })
|
|
265
|
+
},
|
|
266
|
+
null,
|
|
267
|
+
4
|
|
268
|
+
/* STYLE */
|
|
269
|
+
)
|
|
270
|
+
])) : _createCommentVNode("v-if", true)
|
|
271
|
+
]),
|
|
272
|
+
f.status === "error" ? (_openBlock(), _createElementBlock("button", {
|
|
273
|
+
key: 0,
|
|
274
|
+
type: "button",
|
|
275
|
+
class: "wd-upload__retry",
|
|
276
|
+
disabled: __props.disabled,
|
|
277
|
+
onClick: _withModifiers(($event) => retry(f.uid), ["stop"])
|
|
278
|
+
}, " \u91CD\u8BD5 ", 8, _hoisted_11)) : _createCommentVNode("v-if", true),
|
|
279
|
+
_createElementVNode("button", {
|
|
280
|
+
type: "button",
|
|
281
|
+
class: "wd-upload__remove",
|
|
282
|
+
"aria-label": "\u79FB\u9664",
|
|
283
|
+
disabled: __props.disabled,
|
|
284
|
+
onClick: _withModifiers(($event) => remove(i), ["stop"])
|
|
285
|
+
}, [
|
|
286
|
+
_createVNode(_unref(WdIcon_default), {
|
|
287
|
+
name: "close",
|
|
288
|
+
size: 13
|
|
289
|
+
})
|
|
290
|
+
], 8, _hoisted_12)
|
|
291
|
+
],
|
|
292
|
+
2
|
|
293
|
+
/* CLASS */
|
|
294
|
+
);
|
|
295
|
+
}),
|
|
296
|
+
128
|
|
297
|
+
/* KEYED_FRAGMENT */
|
|
298
|
+
))
|
|
299
|
+
])) : _createCommentVNode("v-if", true)
|
|
300
|
+
],
|
|
301
|
+
16
|
|
302
|
+
/* FULL_PROPS */
|
|
303
|
+
);
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
export {
|
|
308
|
+
WdUpload_default as WdUpload
|
|
309
|
+
};
|