@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,261 @@
|
|
|
1
|
+
// .lib-build/WdIcon.ts
|
|
2
|
+
import { defineComponent as _defineComponent } from "vue";
|
|
3
|
+
import { normalizeClass as _normalizeClass, normalizeStyle as _normalizeStyle, openBlock as _openBlock, createElementBlock as _createElementBlock } from "vue";
|
|
4
|
+
import { computed, onBeforeUnmount, onMounted, ref, watchEffect } from "vue";
|
|
5
|
+
|
|
6
|
+
// .lib-build/optical.ts
|
|
7
|
+
var OPTICAL_TALL = /* @__PURE__ */ new Set([
|
|
8
|
+
// 33 个
|
|
9
|
+
"arrow-down",
|
|
10
|
+
"arrow-down-left",
|
|
11
|
+
"arrow-down-right",
|
|
12
|
+
"arrow-left",
|
|
13
|
+
"arrow-right",
|
|
14
|
+
"arrow-up",
|
|
15
|
+
"arrow-up-left",
|
|
16
|
+
"arrow-up-right",
|
|
17
|
+
"check",
|
|
18
|
+
"chevron-down",
|
|
19
|
+
"chevron-left",
|
|
20
|
+
"chevron-left-alt",
|
|
21
|
+
"chevron-left-double-alt",
|
|
22
|
+
"chevron-right",
|
|
23
|
+
"chevron-right-alt",
|
|
24
|
+
"chevron-right-double-alt",
|
|
25
|
+
"chevron-up",
|
|
26
|
+
"chevrons-down",
|
|
27
|
+
"chevrons-left",
|
|
28
|
+
"chevrons-right",
|
|
29
|
+
"chevrons-up",
|
|
30
|
+
"command-line",
|
|
31
|
+
"dots-drag",
|
|
32
|
+
"dots-horizontal",
|
|
33
|
+
"dots-vertical",
|
|
34
|
+
"hr-line",
|
|
35
|
+
"list",
|
|
36
|
+
"menu",
|
|
37
|
+
"minus",
|
|
38
|
+
"pause",
|
|
39
|
+
"play",
|
|
40
|
+
"plus",
|
|
41
|
+
"point"
|
|
42
|
+
]);
|
|
43
|
+
var OPTICAL_LIGHT = /* @__PURE__ */ new Set([
|
|
44
|
+
// 20 个
|
|
45
|
+
"activity",
|
|
46
|
+
"circle-alt",
|
|
47
|
+
"close",
|
|
48
|
+
"corner-down-left",
|
|
49
|
+
"corner-down-right",
|
|
50
|
+
"corner-left-down",
|
|
51
|
+
"corner-left-up",
|
|
52
|
+
"corner-right-down",
|
|
53
|
+
"corner-right-up",
|
|
54
|
+
"corner-up-left",
|
|
55
|
+
"corner-up-right",
|
|
56
|
+
"eye-off",
|
|
57
|
+
"git-commit",
|
|
58
|
+
"italic",
|
|
59
|
+
"maximize",
|
|
60
|
+
"minimize",
|
|
61
|
+
"text",
|
|
62
|
+
"trending-down",
|
|
63
|
+
"trending-up",
|
|
64
|
+
"zoom-in-arrow"
|
|
65
|
+
]);
|
|
66
|
+
var OPTICAL_HEAVY = /* @__PURE__ */ new Set([
|
|
67
|
+
// 49 个
|
|
68
|
+
"ad",
|
|
69
|
+
"apps",
|
|
70
|
+
"arrow-down-circle",
|
|
71
|
+
"arrow-right-circle",
|
|
72
|
+
"arrow-up-circle",
|
|
73
|
+
"board",
|
|
74
|
+
"box-back",
|
|
75
|
+
"box-go",
|
|
76
|
+
"box-ok",
|
|
77
|
+
"box-prize",
|
|
78
|
+
"brackets",
|
|
79
|
+
"calculator",
|
|
80
|
+
"cancel",
|
|
81
|
+
"check-circle",
|
|
82
|
+
"clipboard",
|
|
83
|
+
"clock",
|
|
84
|
+
"close-circle",
|
|
85
|
+
"develop",
|
|
86
|
+
"file",
|
|
87
|
+
"file-minus",
|
|
88
|
+
"file-plus",
|
|
89
|
+
"folder",
|
|
90
|
+
"folder-manage",
|
|
91
|
+
"folder-minus",
|
|
92
|
+
"folder-plus",
|
|
93
|
+
"folders",
|
|
94
|
+
"help-circle",
|
|
95
|
+
"id-card",
|
|
96
|
+
"identity",
|
|
97
|
+
"image",
|
|
98
|
+
"info-circle",
|
|
99
|
+
"language",
|
|
100
|
+
"layout-dashboard",
|
|
101
|
+
"layout-grid",
|
|
102
|
+
"message",
|
|
103
|
+
"message-circle",
|
|
104
|
+
"message-read",
|
|
105
|
+
"minus-circle",
|
|
106
|
+
"minus-square",
|
|
107
|
+
"money-bag",
|
|
108
|
+
"monitor",
|
|
109
|
+
"pause-circle",
|
|
110
|
+
"pip",
|
|
111
|
+
"plus-circle",
|
|
112
|
+
"plus-square",
|
|
113
|
+
"shopping-bag",
|
|
114
|
+
"ticket",
|
|
115
|
+
"video",
|
|
116
|
+
"warning-circle"
|
|
117
|
+
]);
|
|
118
|
+
var DEFAULT_OPTICAL = {
|
|
119
|
+
tall: 1.14,
|
|
120
|
+
light: 1.08,
|
|
121
|
+
heavy: 0.97,
|
|
122
|
+
shrinkHeavy: true
|
|
123
|
+
};
|
|
124
|
+
function opticalFactor(name, opts = DEFAULT_OPTICAL) {
|
|
125
|
+
const o = { ...DEFAULT_OPTICAL, ...opts };
|
|
126
|
+
if (OPTICAL_TALL.has(name)) return o.tall;
|
|
127
|
+
if (OPTICAL_LIGHT.has(name)) return o.light;
|
|
128
|
+
if (o.shrinkHeavy && OPTICAL_HEAVY.has(name)) return o.heavy;
|
|
129
|
+
return 1;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// .lib-build/registry.ts
|
|
133
|
+
var cache = /* @__PURE__ */ new Map();
|
|
134
|
+
var inflight = /* @__PURE__ */ new Map();
|
|
135
|
+
function inlineData() {
|
|
136
|
+
return globalThis.WD_ICONS;
|
|
137
|
+
}
|
|
138
|
+
var loaders = {};
|
|
139
|
+
function styleOrder(style) {
|
|
140
|
+
return style === "filled" ? ["filled", "outlined"] : ["outlined", "filled"];
|
|
141
|
+
}
|
|
142
|
+
function getIconSync(name, style = "outlined") {
|
|
143
|
+
for (const st of styleOrder(style)) {
|
|
144
|
+
const hit = cache.get(`${st}/${name}`);
|
|
145
|
+
if (hit) return hit;
|
|
146
|
+
}
|
|
147
|
+
return void 0;
|
|
148
|
+
}
|
|
149
|
+
function getIcon(name, style = "outlined") {
|
|
150
|
+
const hit = getIconSync(name, style);
|
|
151
|
+
if (hit) return Promise.resolve(hit);
|
|
152
|
+
const key = `${style}/${name}`;
|
|
153
|
+
const pending = inflight.get(key);
|
|
154
|
+
if (pending) return pending;
|
|
155
|
+
const task = (async () => {
|
|
156
|
+
const inline = inlineData();
|
|
157
|
+
for (const st of styleOrder(style)) {
|
|
158
|
+
const path = `../icons/${st}/${name}.svg`;
|
|
159
|
+
if (loaders[path]) {
|
|
160
|
+
try {
|
|
161
|
+
const raw2 = await loaders[path]();
|
|
162
|
+
cache.set(`${st}/${name}`, raw2);
|
|
163
|
+
return raw2;
|
|
164
|
+
} catch {
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
const raw = inline?.[`${st}/${name}`];
|
|
168
|
+
if (raw) {
|
|
169
|
+
cache.set(`${st}/${name}`, raw);
|
|
170
|
+
return raw;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return void 0;
|
|
174
|
+
})();
|
|
175
|
+
inflight.set(key, task);
|
|
176
|
+
task.finally(() => inflight.delete(key));
|
|
177
|
+
return task;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// .lib-build/WdIcon.ts
|
|
181
|
+
var _hoisted_1 = ["innerHTML"];
|
|
182
|
+
var WdIcon_default = /* @__PURE__ */ _defineComponent({
|
|
183
|
+
...{ name: "WdIcon" },
|
|
184
|
+
__name: "WdIcon",
|
|
185
|
+
props: {
|
|
186
|
+
name: { type: String, required: true },
|
|
187
|
+
variant: { type: String, required: false, default: "outlined" },
|
|
188
|
+
size: { type: [Number, String], required: false, default: 24 },
|
|
189
|
+
filled: { type: Boolean, required: false, default: false },
|
|
190
|
+
optical: { type: Boolean, required: false, default: true },
|
|
191
|
+
weight: { type: String, required: false, default: "thin" }
|
|
192
|
+
},
|
|
193
|
+
setup(__props) {
|
|
194
|
+
const props = __props;
|
|
195
|
+
const svg = ref("");
|
|
196
|
+
const resolvedStyle = computed(() => props.filled ? "filled" : props.variant);
|
|
197
|
+
const WEIGHT_STROKE = {
|
|
198
|
+
thin: 0,
|
|
199
|
+
normal: 6,
|
|
200
|
+
medium: 12,
|
|
201
|
+
bold: 20
|
|
202
|
+
};
|
|
203
|
+
const strokeWidth = computed(() => WEIGHT_STROKE[props.weight] ?? 0);
|
|
204
|
+
const factor = computed(() => props.optical ? opticalFactor(props.name) : 1);
|
|
205
|
+
const dpr = ref(typeof window === "undefined" ? 1 : window.devicePixelRatio || 1);
|
|
206
|
+
if (typeof window !== "undefined") {
|
|
207
|
+
let mq = null;
|
|
208
|
+
const watchDpr = () => {
|
|
209
|
+
mq?.removeEventListener("change", onDprChange);
|
|
210
|
+
mq = window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`);
|
|
211
|
+
mq.addEventListener("change", onDprChange);
|
|
212
|
+
dpr.value = window.devicePixelRatio || 1;
|
|
213
|
+
};
|
|
214
|
+
const onDprChange = () => watchDpr();
|
|
215
|
+
onMounted(watchDpr);
|
|
216
|
+
onBeforeUnmount(() => mq?.removeEventListener("change", onDprChange));
|
|
217
|
+
}
|
|
218
|
+
const sizePx = computed(() => {
|
|
219
|
+
const base = typeof props.size === "number" ? props.size : parseFloat(props.size) || 24;
|
|
220
|
+
const raw = base * factor.value;
|
|
221
|
+
const step = 1 / dpr.value;
|
|
222
|
+
const snapped = Math.round(raw / step) * step;
|
|
223
|
+
return `${Math.round(snapped * 1e3) / 1e3}px`;
|
|
224
|
+
});
|
|
225
|
+
watchEffect(() => {
|
|
226
|
+
const name = props.name;
|
|
227
|
+
const style = resolvedStyle.value;
|
|
228
|
+
const hit = getIconSync(name, style);
|
|
229
|
+
if (hit) {
|
|
230
|
+
svg.value = hit;
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
let alive = true;
|
|
234
|
+
getIcon(name, style).then((raw) => {
|
|
235
|
+
if (alive) svg.value = raw ?? "";
|
|
236
|
+
});
|
|
237
|
+
return () => {
|
|
238
|
+
alive = false;
|
|
239
|
+
};
|
|
240
|
+
});
|
|
241
|
+
return (_ctx, _cache) => {
|
|
242
|
+
return _openBlock(), _createElementBlock("span", {
|
|
243
|
+
class: _normalizeClass(["wd-icon", [
|
|
244
|
+
{ "wd-icon--optical": factor.value !== 1 },
|
|
245
|
+
`wd-icon--w-${__props.weight}`
|
|
246
|
+
]]),
|
|
247
|
+
style: _normalizeStyle({
|
|
248
|
+
width: sizePx.value,
|
|
249
|
+
height: sizePx.value,
|
|
250
|
+
// 传给 CSS 变量,由样式表统一应用到 svg 内的所有图形
|
|
251
|
+
"--wd-icon-stroke": String(strokeWidth.value)
|
|
252
|
+
}),
|
|
253
|
+
innerHTML: svg.value
|
|
254
|
+
}, null, 14, _hoisted_1);
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
export {
|
|
260
|
+
WdIcon_default
|
|
261
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// composables/useComposition.ts
|
|
2
|
+
import { ref } from "vue";
|
|
3
|
+
function useComposition() {
|
|
4
|
+
const isComposing = ref(false);
|
|
5
|
+
let justFlushedAt = 0;
|
|
6
|
+
function onCompositionStart() {
|
|
7
|
+
isComposing.value = true;
|
|
8
|
+
}
|
|
9
|
+
function onCompositionEnd(e, flush) {
|
|
10
|
+
isComposing.value = false;
|
|
11
|
+
if (flush) {
|
|
12
|
+
flush();
|
|
13
|
+
justFlushedAt = Date.now();
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function shouldSkip(e) {
|
|
17
|
+
if (isComposing.value) return true;
|
|
18
|
+
if (e && e.isComposing) return true;
|
|
19
|
+
if (justFlushedAt && Date.now() - justFlushedAt < 100) {
|
|
20
|
+
justFlushedAt = 0;
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
return { isComposing, onCompositionStart, onCompositionEnd, shouldSkip };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export {
|
|
29
|
+
useComposition
|
|
30
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// .lib-build/form-context.ts
|
|
2
|
+
var FORM_CONTEXT = /* @__PURE__ */ Symbol("wd-form");
|
|
3
|
+
var FORM_ITEM_CONTEXT = /* @__PURE__ */ Symbol("wd-form-item");
|
|
4
|
+
function isEmpty(v) {
|
|
5
|
+
if (v === void 0 || v === null) return true;
|
|
6
|
+
if (typeof v === "string") return v.trim() === "";
|
|
7
|
+
if (Array.isArray(v)) return v.length === 0;
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
async function runRules(rules, value, model) {
|
|
11
|
+
for (const r of rules) {
|
|
12
|
+
if (r.required && isEmpty(value)) {
|
|
13
|
+
return r.message || "\u6B64\u9879\u4E3A\u5FC5\u586B";
|
|
14
|
+
}
|
|
15
|
+
if (isEmpty(value) && !r.required) continue;
|
|
16
|
+
if (typeof value === "string") {
|
|
17
|
+
if (r.min !== void 0 && value.length < r.min) {
|
|
18
|
+
return r.message || `\u81F3\u5C11 ${r.min} \u4E2A\u5B57\u7B26`;
|
|
19
|
+
}
|
|
20
|
+
if (r.max !== void 0 && value.length > r.max) {
|
|
21
|
+
return r.message || `\u6700\u591A ${r.max} \u4E2A\u5B57\u7B26`;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (r.pattern && typeof value === "string" && !r.pattern.test(value)) {
|
|
25
|
+
return r.message || "\u683C\u5F0F\u4E0D\u6B63\u786E";
|
|
26
|
+
}
|
|
27
|
+
if (r.validator) {
|
|
28
|
+
const out = await r.validator(value, model);
|
|
29
|
+
if (out !== true) return typeof out === "string" ? out : r.message || "\u6821\u9A8C\u672A\u901A\u8FC7";
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return "";
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export {
|
|
36
|
+
FORM_CONTEXT,
|
|
37
|
+
FORM_ITEM_CONTEXT,
|
|
38
|
+
isEmpty,
|
|
39
|
+
runRules
|
|
40
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FORM_ITEM_CONTEXT
|
|
3
|
+
} from "./chunk-UYUNYHZD.js";
|
|
4
|
+
|
|
5
|
+
// .lib-build/useFormItemA11y.ts
|
|
6
|
+
import { computed, inject } from "vue";
|
|
7
|
+
function useFormItemA11y() {
|
|
8
|
+
const formItem = inject(FORM_ITEM_CONTEXT, null);
|
|
9
|
+
const attrs = computed(() => {
|
|
10
|
+
if (!formItem) return {};
|
|
11
|
+
const out = {};
|
|
12
|
+
if (formItem.invalid()) out["aria-invalid"] = "true";
|
|
13
|
+
const described = formItem.errorId();
|
|
14
|
+
if (described) out["aria-describedby"] = described;
|
|
15
|
+
return out;
|
|
16
|
+
});
|
|
17
|
+
const invalid = computed(() => !!formItem && formItem.invalid());
|
|
18
|
+
return { formItem, attrs, invalid };
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export {
|
|
22
|
+
useFormItemA11y
|
|
23
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// .lib-build/WdAvatar.ts
|
|
2
|
+
import { defineComponent as _defineComponent } from "vue";
|
|
3
|
+
import { toDisplayString as _toDisplayString, normalizeClass as _normalizeClass, openBlock as _openBlock, createElementBlock as _createElementBlock } from "vue";
|
|
4
|
+
import { computed } from "vue";
|
|
5
|
+
var WdAvatar_default = /* @__PURE__ */ _defineComponent({
|
|
6
|
+
...{ name: "WdAvatar" },
|
|
7
|
+
__name: "WdAvatar",
|
|
8
|
+
props: {
|
|
9
|
+
name: { type: String, required: false, default: "" },
|
|
10
|
+
tone: { type: Number, required: false, default: 0 },
|
|
11
|
+
dark: { type: Boolean, required: false, default: false },
|
|
12
|
+
size: { type: String, required: false, default: "md" }
|
|
13
|
+
},
|
|
14
|
+
setup(__props) {
|
|
15
|
+
const props = __props;
|
|
16
|
+
const label = computed(() => {
|
|
17
|
+
const n = props.name.trim();
|
|
18
|
+
if (!n) return "?";
|
|
19
|
+
if (n.startsWith("+")) return n;
|
|
20
|
+
return n.charAt(0);
|
|
21
|
+
});
|
|
22
|
+
const resolvedTone = computed(() => {
|
|
23
|
+
if (props.tone) return props.tone;
|
|
24
|
+
if (!props.name) return 0;
|
|
25
|
+
let hash = 0;
|
|
26
|
+
for (const ch of props.name) hash = hash * 31 + ch.charCodeAt(0) | 0;
|
|
27
|
+
return Math.abs(hash) % 6 + 1;
|
|
28
|
+
});
|
|
29
|
+
const classes = computed(() => [
|
|
30
|
+
"wd-avatar",
|
|
31
|
+
resolvedTone.value ? `wd-avatar--tone-${resolvedTone.value}` : "",
|
|
32
|
+
props.dark ? "wd-avatar--dark" : "",
|
|
33
|
+
props.size === "sm" ? "wd-avatar--sm" : ""
|
|
34
|
+
]);
|
|
35
|
+
return (_ctx, _cache) => {
|
|
36
|
+
return _openBlock(), _createElementBlock(
|
|
37
|
+
"span",
|
|
38
|
+
{
|
|
39
|
+
class: _normalizeClass(classes.value)
|
|
40
|
+
},
|
|
41
|
+
_toDisplayString(label.value),
|
|
42
|
+
3
|
|
43
|
+
/* TEXT, CLASS */
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
export {
|
|
50
|
+
WdAvatar_default
|
|
51
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// .lib-build/WdSpinner.ts
|
|
2
|
+
import { defineComponent as _defineComponent } from "vue";
|
|
3
|
+
import { normalizeClass as _normalizeClass, normalizeStyle as _normalizeStyle, openBlock as _openBlock, createElementBlock as _createElementBlock } from "vue";
|
|
4
|
+
import { computed } from "vue";
|
|
5
|
+
var WdSpinner_default = /* @__PURE__ */ _defineComponent({
|
|
6
|
+
...{ name: "WdSpinner" },
|
|
7
|
+
__name: "WdSpinner",
|
|
8
|
+
props: {
|
|
9
|
+
size: { type: [String, Number], required: false, default: "md" }
|
|
10
|
+
},
|
|
11
|
+
setup(__props) {
|
|
12
|
+
const props = __props;
|
|
13
|
+
const PRESET = { sm: "18px", md: "28px", lg: "40px" };
|
|
14
|
+
const style = computed(() => {
|
|
15
|
+
if (typeof props.size === "number") {
|
|
16
|
+
const px = Math.max(8, props.size);
|
|
17
|
+
const bw = Math.max(2, Math.round(px * 0.11 * 10) / 10);
|
|
18
|
+
return { width: `${px}px`, height: `${px}px`, borderWidth: `${bw}px` };
|
|
19
|
+
}
|
|
20
|
+
return {};
|
|
21
|
+
});
|
|
22
|
+
const cls = computed(() => typeof props.size === "string" && props.size !== "md" ? `wd-spinner--${props.size}` : "");
|
|
23
|
+
return (_ctx, _cache) => {
|
|
24
|
+
return _openBlock(), _createElementBlock(
|
|
25
|
+
"span",
|
|
26
|
+
{
|
|
27
|
+
class: _normalizeClass(["wd-spinner", cls.value]),
|
|
28
|
+
style: _normalizeStyle(style.value),
|
|
29
|
+
role: "status",
|
|
30
|
+
"aria-label": "\u52A0\u8F7D\u4E2D"
|
|
31
|
+
},
|
|
32
|
+
null,
|
|
33
|
+
6
|
|
34
|
+
/* CLASS, STYLE */
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
export {
|
|
41
|
+
WdSpinner_default
|
|
42
|
+
};
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
// .lib-build/anchor.ts
|
|
2
|
+
import { nextTick, onBeforeUnmount, onMounted, ref, watch } from "vue";
|
|
3
|
+
function scrollOffset() {
|
|
4
|
+
const x = window.scrollX ?? window.pageXOffset ?? document.documentElement.scrollLeft ?? 0;
|
|
5
|
+
const y = window.scrollY ?? window.pageYOffset ?? document.documentElement.scrollTop ?? 0;
|
|
6
|
+
return { x, y };
|
|
7
|
+
}
|
|
8
|
+
function viewportSize() {
|
|
9
|
+
const vv = window.visualViewport;
|
|
10
|
+
if (vv) return { width: vv.width, height: vv.height };
|
|
11
|
+
return { width: window.innerWidth, height: window.innerHeight };
|
|
12
|
+
}
|
|
13
|
+
function useAnchoredPosition(open, anchor, panel, options = {}) {
|
|
14
|
+
const pos = ref({ top: 0, left: 0 });
|
|
15
|
+
const actual = ref(options.placement || "bottom-start");
|
|
16
|
+
function place() {
|
|
17
|
+
const el = anchor.value;
|
|
18
|
+
if (!el) return;
|
|
19
|
+
const a = el.getBoundingClientRect();
|
|
20
|
+
const pr = panel.value?.getBoundingClientRect();
|
|
21
|
+
const gap = options.gap ?? 6;
|
|
22
|
+
const pw = options.matchWidth ? a.width : options.width ?? pr?.width ?? 0;
|
|
23
|
+
const ph = pr?.height ?? 0;
|
|
24
|
+
const vp = viewportSize();
|
|
25
|
+
const s = scrollOffset();
|
|
26
|
+
const vTop = a.top;
|
|
27
|
+
const vBottom = a.bottom;
|
|
28
|
+
const dTop = a.top + s.y;
|
|
29
|
+
const dBottom = a.bottom + s.y;
|
|
30
|
+
const dLeft = a.left + s.x;
|
|
31
|
+
const dRight = a.right + s.x;
|
|
32
|
+
let placement = options.placement || "bottom-start";
|
|
33
|
+
const wantBottom = placement.startsWith("bottom");
|
|
34
|
+
const fitsBelow = vBottom + gap + ph <= vp.height - 8;
|
|
35
|
+
const fitsAbove = vTop - gap - ph >= 8;
|
|
36
|
+
const goBottom = wantBottom ? fitsBelow || !fitsAbove : !fitsAbove && fitsBelow;
|
|
37
|
+
let top;
|
|
38
|
+
if (goBottom) {
|
|
39
|
+
top = dBottom + gap;
|
|
40
|
+
placement = placement.replace("top", "bottom");
|
|
41
|
+
} else {
|
|
42
|
+
top = dTop - gap - ph;
|
|
43
|
+
placement = placement.replace("bottom", "top");
|
|
44
|
+
}
|
|
45
|
+
let left;
|
|
46
|
+
if (placement.endsWith("start")) left = dLeft;
|
|
47
|
+
else if (placement.endsWith("end")) left = dRight - pw;
|
|
48
|
+
else left = dLeft + a.width / 2 - pw / 2;
|
|
49
|
+
const minLeft = s.x + 8;
|
|
50
|
+
const maxLeft = s.x + vp.width - pw - 8;
|
|
51
|
+
left = Math.max(minLeft, Math.min(left, Math.max(minLeft, maxLeft)));
|
|
52
|
+
const liveH = panel.value?.getBoundingClientRect().height ?? 0;
|
|
53
|
+
const clampH = liveH > 0 ? liveH : ph;
|
|
54
|
+
if (clampH > 0) {
|
|
55
|
+
const minTop = s.y + 8;
|
|
56
|
+
const maxTop = s.y + vp.height - clampH - 8;
|
|
57
|
+
top = Math.max(minTop, Math.min(top, Math.max(minTop, maxTop)));
|
|
58
|
+
}
|
|
59
|
+
pos.value = { top, left };
|
|
60
|
+
actual.value = placement;
|
|
61
|
+
}
|
|
62
|
+
let raf = 0;
|
|
63
|
+
let timer = 0;
|
|
64
|
+
function schedule() {
|
|
65
|
+
if (raf) return;
|
|
66
|
+
raf = requestAnimationFrame(() => {
|
|
67
|
+
raf = 0;
|
|
68
|
+
place();
|
|
69
|
+
});
|
|
70
|
+
clearTimeout(timer);
|
|
71
|
+
timer = window.setTimeout(place, 32);
|
|
72
|
+
}
|
|
73
|
+
function onScroll(e) {
|
|
74
|
+
const t = e.target;
|
|
75
|
+
if (t && panel.value && panel.value.contains(t)) return;
|
|
76
|
+
schedule();
|
|
77
|
+
}
|
|
78
|
+
let vv = null;
|
|
79
|
+
function bind() {
|
|
80
|
+
window.addEventListener("scroll", onScroll, true);
|
|
81
|
+
window.addEventListener("resize", schedule);
|
|
82
|
+
vv = window.visualViewport ?? null;
|
|
83
|
+
if (vv) {
|
|
84
|
+
vv.addEventListener("resize", schedule);
|
|
85
|
+
vv.addEventListener("scroll", schedule);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function unbind() {
|
|
89
|
+
window.removeEventListener("scroll", onScroll, true);
|
|
90
|
+
window.removeEventListener("resize", schedule);
|
|
91
|
+
if (vv) {
|
|
92
|
+
vv.removeEventListener("resize", schedule);
|
|
93
|
+
vv.removeEventListener("scroll", schedule);
|
|
94
|
+
vv = null;
|
|
95
|
+
}
|
|
96
|
+
if (raf) {
|
|
97
|
+
cancelAnimationFrame(raf);
|
|
98
|
+
raf = 0;
|
|
99
|
+
}
|
|
100
|
+
clearTimeout(timer);
|
|
101
|
+
}
|
|
102
|
+
watch(open, async (v) => {
|
|
103
|
+
if (v) {
|
|
104
|
+
await nextTick();
|
|
105
|
+
place();
|
|
106
|
+
bind();
|
|
107
|
+
schedule();
|
|
108
|
+
} else {
|
|
109
|
+
unbind();
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
let ro = null;
|
|
113
|
+
watch(panel, (el) => {
|
|
114
|
+
ro?.disconnect();
|
|
115
|
+
if (el && typeof ResizeObserver !== "undefined") {
|
|
116
|
+
ro = new ResizeObserver(() => schedule());
|
|
117
|
+
ro.observe(el);
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
onBeforeUnmount(() => {
|
|
121
|
+
ro?.disconnect();
|
|
122
|
+
ro = null;
|
|
123
|
+
});
|
|
124
|
+
onMounted(() => {
|
|
125
|
+
if (open.value) {
|
|
126
|
+
place();
|
|
127
|
+
bind();
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
onBeforeUnmount(unbind);
|
|
131
|
+
return { pos, place: schedule, actual };
|
|
132
|
+
}
|
|
133
|
+
function useDismiss(refs, close, enabled, event = "click") {
|
|
134
|
+
function onDoc(e) {
|
|
135
|
+
if (!enabled.value) return;
|
|
136
|
+
const t = e.target;
|
|
137
|
+
if (refs.some((r) => r.value?.contains(t))) return;
|
|
138
|
+
close();
|
|
139
|
+
}
|
|
140
|
+
if (typeof document !== "undefined") document.addEventListener(event, onDoc);
|
|
141
|
+
onBeforeUnmount(() => {
|
|
142
|
+
if (typeof document !== "undefined") document.removeEventListener(event, onDoc);
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export {
|
|
147
|
+
useAnchoredPosition,
|
|
148
|
+
useDismiss
|
|
149
|
+
};
|