@w-run/wdesign-ui 0.0.0-stage → 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 +255 -2
- package/dist/index.d.ts +1013 -0
- 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 +746 -0
- package/dist/style/alert.css +636 -0
- package/dist/style/anchor.css +630 -0
- package/dist/style/audio.css +1954 -0
- package/dist/style/avatar.css +651 -0
- package/dist/style/backtop.css +625 -0
- package/dist/style/badge.css +632 -0
- package/dist/style/bento.css +763 -0
- package/dist/style/bottom-sheet.css +776 -0
- package/dist/style/breadcrumb.css +629 -0
- package/dist/style/button.css +829 -0
- package/dist/style/calendar.css +1512 -0
- package/dist/style/card.css +748 -0
- package/dist/style/carousel.css +670 -0
- package/dist/style/cascader.css +862 -0
- package/dist/style/checkbox.css +706 -0
- package/dist/style/chevron.css +575 -0
- package/dist/style/collapse.css +648 -0
- package/dist/style/colorpicker.css +876 -0
- package/dist/style/command.css +760 -0
- package/dist/style/container.css +550 -0
- package/dist/style/countdown.css +722 -0
- package/dist/style/danmaku.css +644 -0
- package/dist/style/datepicker.css +683 -0
- package/dist/style/datetime-picker.css +714 -0
- package/dist/style/descriptions.css +712 -0
- package/dist/style/divider.css +604 -0
- package/dist/style/dot.css +585 -0
- package/dist/style/drawer.css +743 -0
- package/dist/style/dropdown.css +645 -0
- package/dist/style/empty.css +657 -0
- package/dist/style/explorer.css +944 -0
- package/dist/style/file-list.css +664 -0
- package/dist/style/flip.css +600 -0
- package/dist/style/form.css +638 -0
- package/dist/style/grid.css +618 -0
- package/dist/style/group.css +1022 -0
- package/dist/style/icon-btn.css +641 -0
- package/dist/style/image-preview.css +725 -0
- package/dist/style/input-number.css +680 -0
- package/dist/style/input.css +682 -0
- package/dist/style/list.css +630 -0
- package/dist/style/loading.css +667 -0
- package/dist/style/markdown.css +884 -0
- 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 +775 -0
- package/dist/style/nav.css +1046 -0
- package/dist/style/notification.css +601 -0
- package/dist/style/otp.css +699 -0
- package/dist/style/pagination.css +680 -0
- package/dist/style/popconfirm.css +645 -0
- package/dist/style/popover.css +740 -0
- package/dist/style/post-item.css +676 -0
- package/dist/style/progress-ring.css +640 -0
- package/dist/style/progress.css +576 -0
- package/dist/style/pull-refresh.css +637 -0
- package/dist/style/qrcode.css +613 -0
- package/dist/style/radio.css +705 -0
- package/dist/style/rate.css +637 -0
- package/dist/style/result.css +597 -0
- package/dist/style/scroll-reveal.css +613 -0
- package/dist/style/scrollbar.css +644 -0
- package/dist/style/segmented-picker.css +679 -0
- package/dist/style/segmented.css +894 -0
- package/dist/style/select.css +937 -0
- package/dist/style/skeleton.css +590 -0
- package/dist/style/slider.css +642 -0
- package/dist/style/sortable.css +714 -0
- package/dist/style/space.css +568 -0
- package/dist/style/sparkline.css +606 -0
- package/dist/style/spinner.css +586 -0
- package/dist/style/splitter.css +711 -0
- package/dist/style/stat-bar.css +767 -0
- package/dist/style/statistic.css +589 -0
- package/dist/style/steps.css +724 -0
- package/dist/style/switch.css +676 -0
- package/dist/style/tab-bar.css +647 -0
- package/dist/style/table.css +1229 -0
- package/dist/style/tabs.css +756 -0
- package/dist/style/tag-input.css +710 -0
- package/dist/style/tag.css +682 -0
- package/dist/style/time-picker.css +749 -0
- package/dist/style/timeline.css +1082 -0
- package/dist/style/toast.css +598 -0
- package/dist/style/tooltip.css +604 -0
- package/dist/style/tour.css +683 -0
- package/dist/style/transfer.css +858 -0
- package/dist/style/tree.css +786 -0
- package/dist/style/typography.css +947 -0
- package/dist/style/upload.css +758 -0
- package/dist/style/vlist.css +591 -0
- package/dist/style/vplayer.css +1588 -0
- package/dist/style/watermark.css +570 -0
- package/dist/wdesign-ui.css +21093 -0
- package/dist/wdesign-ui.esm.js +20265 -0
- package/package.json +134 -4
- package/tokens.json +385 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FORM_CONTEXT,
|
|
3
|
+
FORM_ITEM_CONTEXT,
|
|
4
|
+
isEmpty,
|
|
5
|
+
runRules
|
|
6
|
+
} from "./chunk-UYUNYHZD.js";
|
|
7
|
+
|
|
8
|
+
// .lib-build/WdFormItem.ts
|
|
9
|
+
import { defineComponent as _defineComponent } from "vue";
|
|
10
|
+
import { unref as _unref, openBlock as _openBlock, createElementBlock as _createElementBlock, createCommentVNode as _createCommentVNode, toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, normalizeStyle as _normalizeStyle, renderSlot as _renderSlot, createElementVNode as _createElementVNode, normalizeClass as _normalizeClass } from "vue";
|
|
11
|
+
import { computed, inject, onBeforeUnmount, provide, ref, watch } from "vue";
|
|
12
|
+
var _hoisted_1 = ["data-form-prop"];
|
|
13
|
+
var _hoisted_2 = {
|
|
14
|
+
key: 0,
|
|
15
|
+
class: "wd-form-item__req",
|
|
16
|
+
"aria-hidden": "true"
|
|
17
|
+
};
|
|
18
|
+
var _hoisted_3 = ["id"];
|
|
19
|
+
var _hoisted_4 = {
|
|
20
|
+
key: 1,
|
|
21
|
+
class: "wd-form-item__hint"
|
|
22
|
+
};
|
|
23
|
+
var WdFormItem_default = /* @__PURE__ */ _defineComponent({
|
|
24
|
+
...{ name: "WdFormItem" },
|
|
25
|
+
__name: "WdFormItem",
|
|
26
|
+
props: {
|
|
27
|
+
prop: { type: String, required: false, default: "" },
|
|
28
|
+
label: { type: String, required: false },
|
|
29
|
+
rules: { type: Array, required: false },
|
|
30
|
+
required: { type: Boolean, required: false, default: false },
|
|
31
|
+
hint: { type: String, required: false },
|
|
32
|
+
validateTrigger: { type: null, required: false, default: "change" }
|
|
33
|
+
},
|
|
34
|
+
setup(__props, { expose: __expose }) {
|
|
35
|
+
const props = __props;
|
|
36
|
+
const form = inject(FORM_CONTEXT, null);
|
|
37
|
+
const error = ref("");
|
|
38
|
+
const touched = ref(false);
|
|
39
|
+
const validating = ref(false);
|
|
40
|
+
let uid = 0;
|
|
41
|
+
const instanceId = `wd-form-item-${++uid}-${props.prop || "field"}`;
|
|
42
|
+
const errorId = computed(() => error.value ? `${instanceId}-error` : void 0);
|
|
43
|
+
provide(FORM_ITEM_CONTEXT, {
|
|
44
|
+
invalid: () => !!error.value,
|
|
45
|
+
errorId: () => errorId.value
|
|
46
|
+
});
|
|
47
|
+
const mergedRules = computed(() => {
|
|
48
|
+
if (props.rules?.length) return props.rules;
|
|
49
|
+
if (!form || !props.prop) return [];
|
|
50
|
+
return form.rules()[props.prop] ?? [];
|
|
51
|
+
});
|
|
52
|
+
const isRequired = computed(
|
|
53
|
+
() => props.required || mergedRules.value.some((r) => r.required)
|
|
54
|
+
);
|
|
55
|
+
function currentValue() {
|
|
56
|
+
return form?.model()?.[props.prop];
|
|
57
|
+
}
|
|
58
|
+
async function validate(trigger) {
|
|
59
|
+
if (!mergedRules.value.length) {
|
|
60
|
+
error.value = "";
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
const rules = trigger ? mergedRules.value.filter((r) => !r.trigger || r.trigger === trigger) : mergedRules.value;
|
|
64
|
+
if (!rules.length) return true;
|
|
65
|
+
validating.value = true;
|
|
66
|
+
try {
|
|
67
|
+
const msg = await runRules(rules, currentValue(), form?.model() ?? {});
|
|
68
|
+
error.value = msg;
|
|
69
|
+
touched.value = true;
|
|
70
|
+
return !msg;
|
|
71
|
+
} finally {
|
|
72
|
+
validating.value = false;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function reset() {
|
|
76
|
+
error.value = "";
|
|
77
|
+
touched.value = false;
|
|
78
|
+
}
|
|
79
|
+
if (form && props.prop) {
|
|
80
|
+
form.register({ prop: props.prop, validate, reset, getError: () => error.value });
|
|
81
|
+
onBeforeUnmount(() => form.unregister({ prop: props.prop, validate, reset, getError: () => error.value }));
|
|
82
|
+
}
|
|
83
|
+
watch(
|
|
84
|
+
() => form && props.prop ? form.model()[props.prop] : void 0,
|
|
85
|
+
(v, old) => {
|
|
86
|
+
if (v === old) return;
|
|
87
|
+
if (props.validateTrigger === "change") validate("change");
|
|
88
|
+
}
|
|
89
|
+
);
|
|
90
|
+
function onFocusOut(e) {
|
|
91
|
+
const next = e.relatedTarget;
|
|
92
|
+
if (next && e.currentTarget.contains(next)) return;
|
|
93
|
+
validate("blur");
|
|
94
|
+
}
|
|
95
|
+
const state = computed(() => {
|
|
96
|
+
if (validating.value) return "validating";
|
|
97
|
+
if (error.value) return "error";
|
|
98
|
+
if (touched.value && !isEmpty(currentValue())) return "success";
|
|
99
|
+
return "";
|
|
100
|
+
});
|
|
101
|
+
const disabled = computed(() => form?.disabled() ?? false);
|
|
102
|
+
__expose({ validate, reset, error });
|
|
103
|
+
return (_ctx, _cache) => {
|
|
104
|
+
return _openBlock(), _createElementBlock("div", {
|
|
105
|
+
class: _normalizeClass(["wd-form-item", [state.value ? `wd-form-item--${state.value}` : "", { "wd-form-item--disabled": disabled.value }]]),
|
|
106
|
+
"data-form-prop": __props.prop || void 0
|
|
107
|
+
}, [
|
|
108
|
+
__props.label ? (_openBlock(), _createElementBlock(
|
|
109
|
+
"label",
|
|
110
|
+
{
|
|
111
|
+
key: 0,
|
|
112
|
+
class: "wd-form-item__label",
|
|
113
|
+
style: _normalizeStyle(_unref(form)?.labelPosition() === "left" ? { width: _unref(form)?.labelWidth() } : void 0)
|
|
114
|
+
},
|
|
115
|
+
[
|
|
116
|
+
isRequired.value ? (_openBlock(), _createElementBlock("span", _hoisted_2, "*")) : _createCommentVNode("v-if", true),
|
|
117
|
+
_createTextVNode(
|
|
118
|
+
" " + _toDisplayString(__props.label),
|
|
119
|
+
1
|
|
120
|
+
/* TEXT */
|
|
121
|
+
)
|
|
122
|
+
],
|
|
123
|
+
4
|
|
124
|
+
/* STYLE */
|
|
125
|
+
)) : _createCommentVNode("v-if", true),
|
|
126
|
+
_createElementVNode(
|
|
127
|
+
"div",
|
|
128
|
+
{
|
|
129
|
+
class: "wd-form-item__control",
|
|
130
|
+
onFocusout: onFocusOut
|
|
131
|
+
},
|
|
132
|
+
[
|
|
133
|
+
_renderSlot(_ctx.$slots, "default"),
|
|
134
|
+
error.value ? (_openBlock(), _createElementBlock("p", {
|
|
135
|
+
key: 0,
|
|
136
|
+
id: errorId.value,
|
|
137
|
+
class: "wd-form-item__error",
|
|
138
|
+
role: "alert"
|
|
139
|
+
}, _toDisplayString(error.value), 9, _hoisted_3)) : __props.hint ? (_openBlock(), _createElementBlock(
|
|
140
|
+
"p",
|
|
141
|
+
_hoisted_4,
|
|
142
|
+
_toDisplayString(__props.hint),
|
|
143
|
+
1
|
|
144
|
+
/* TEXT */
|
|
145
|
+
)) : _createCommentVNode("v-if", true)
|
|
146
|
+
],
|
|
147
|
+
32
|
|
148
|
+
/* NEED_HYDRATION */
|
|
149
|
+
)
|
|
150
|
+
], 10, _hoisted_1);
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
export {
|
|
155
|
+
WdFormItem_default as WdFormItem
|
|
156
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// .lib-build/WdGrid.ts
|
|
2
|
+
import { defineComponent as _defineComponent } from "vue";
|
|
3
|
+
import { renderSlot as _renderSlot, normalizeStyle as _normalizeStyle, openBlock as _openBlock, createElementBlock as _createElementBlock } from "vue";
|
|
4
|
+
import { computed } from "vue";
|
|
5
|
+
var _hoisted_1 = ["data-cols"];
|
|
6
|
+
var WdGrid_default = /* @__PURE__ */ _defineComponent({
|
|
7
|
+
...{ name: "WdGrid" },
|
|
8
|
+
__name: "WdGrid",
|
|
9
|
+
props: {
|
|
10
|
+
columns: { type: [Number, String], required: false, default: 1 },
|
|
11
|
+
gap: { type: String, required: false, default: "md" },
|
|
12
|
+
gutter: { type: Number, required: false }
|
|
13
|
+
},
|
|
14
|
+
setup(__props) {
|
|
15
|
+
const props = __props;
|
|
16
|
+
const isAuto = computed(() => props.columns === "auto");
|
|
17
|
+
const cols = computed(() => {
|
|
18
|
+
if (isAuto.value) return "repeat(auto-fit, minmax(200px, 1fr))";
|
|
19
|
+
return void 0;
|
|
20
|
+
});
|
|
21
|
+
const dataCols = computed(() => isAuto.value ? void 0 : String(props.columns));
|
|
22
|
+
const gapValue = computed(() => {
|
|
23
|
+
if (props.gutter) return `${props.gutter}px`;
|
|
24
|
+
const val = { sm: 8, md: 16, lg: 24 }[props.gap] || 16;
|
|
25
|
+
return `${val}px`;
|
|
26
|
+
});
|
|
27
|
+
return (_ctx, _cache) => {
|
|
28
|
+
return _openBlock(), _createElementBlock("div", {
|
|
29
|
+
class: "wd-grid",
|
|
30
|
+
"data-cols": dataCols.value,
|
|
31
|
+
style: _normalizeStyle({ gridTemplateColumns: cols.value, gap: gapValue.value })
|
|
32
|
+
}, [
|
|
33
|
+
_renderSlot(_ctx.$slots, "default")
|
|
34
|
+
], 12, _hoisted_1);
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
export {
|
|
39
|
+
WdGrid_default as WdGrid
|
|
40
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// .lib-build/WdGroup.ts
|
|
2
|
+
import { defineComponent as _defineComponent } from "vue";
|
|
3
|
+
import { renderSlot as _renderSlot, normalizeClass as _normalizeClass, openBlock as _openBlock, createElementBlock as _createElementBlock } from "vue";
|
|
4
|
+
import { computed, onMounted, ref, watch } from "vue";
|
|
5
|
+
var _hoisted_1 = ["aria-label", "aria-disabled"];
|
|
6
|
+
var WdGroup_default = /* @__PURE__ */ _defineComponent({
|
|
7
|
+
...{ name: "WdGroup" },
|
|
8
|
+
__name: "WdGroup",
|
|
9
|
+
props: {
|
|
10
|
+
variant: { type: String, required: false, default: "capsule" },
|
|
11
|
+
direction: { type: String, required: false, default: "row" },
|
|
12
|
+
size: { type: String, required: false, default: "md" },
|
|
13
|
+
block: { type: Boolean, required: false, default: false },
|
|
14
|
+
disabled: { type: Boolean, required: false, default: false },
|
|
15
|
+
equal: { type: Boolean, required: false, default: false },
|
|
16
|
+
label: { type: String, required: false, default: "" },
|
|
17
|
+
seamless: { type: Boolean, required: false, default: true }
|
|
18
|
+
},
|
|
19
|
+
setup(__props) {
|
|
20
|
+
const props = __props;
|
|
21
|
+
const root = ref(null);
|
|
22
|
+
function markChildren() {
|
|
23
|
+
const el = root.value;
|
|
24
|
+
if (!el) return;
|
|
25
|
+
const kids = Array.from(el.children);
|
|
26
|
+
const n = kids.length;
|
|
27
|
+
kids.forEach((c, i) => {
|
|
28
|
+
c.classList.toggle("wd-group__item", true);
|
|
29
|
+
c.classList.toggle("wd-group__item--first", i === 0);
|
|
30
|
+
c.classList.toggle("wd-group__item--last", i === n - 1);
|
|
31
|
+
c.classList.toggle("wd-group__item--middle", i > 0 && i < n - 1);
|
|
32
|
+
c.classList.toggle("wd-group__item--only", n === 1);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
onMounted(markChildren);
|
|
36
|
+
watch(
|
|
37
|
+
() => root.value ? Array.from(root.value.children).length : 0,
|
|
38
|
+
() => markChildren()
|
|
39
|
+
);
|
|
40
|
+
const classes = computed(() => [
|
|
41
|
+
"wd-group",
|
|
42
|
+
`wd-group--${props.variant}`,
|
|
43
|
+
`wd-group--${props.direction}`,
|
|
44
|
+
`wd-group--${props.size}`,
|
|
45
|
+
{
|
|
46
|
+
"wd-group--block": props.block,
|
|
47
|
+
"wd-group--disabled": props.disabled,
|
|
48
|
+
"wd-group--equal": props.equal,
|
|
49
|
+
"wd-group--seamless": props.seamless
|
|
50
|
+
}
|
|
51
|
+
]);
|
|
52
|
+
return (_ctx, _cache) => {
|
|
53
|
+
return _openBlock(), _createElementBlock("div", {
|
|
54
|
+
ref_key: "root",
|
|
55
|
+
ref: root,
|
|
56
|
+
class: _normalizeClass(classes.value),
|
|
57
|
+
role: "group",
|
|
58
|
+
"aria-label": __props.label || void 0,
|
|
59
|
+
"aria-disabled": __props.disabled || void 0
|
|
60
|
+
}, [
|
|
61
|
+
_renderSlot(_ctx.$slots, "default")
|
|
62
|
+
], 10, _hoisted_1);
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
export {
|
|
67
|
+
WdGroup_default as WdGroup
|
|
68
|
+
};
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import {
|
|
2
|
+
popDuration
|
|
3
|
+
} from "./chunk-HAKYCUAR.js";
|
|
4
|
+
import {
|
|
5
|
+
useFocusTrap
|
|
6
|
+
} from "./chunk-LT3NTWIT.js";
|
|
7
|
+
import "./chunk-5HYOQ52I.js";
|
|
8
|
+
import {
|
|
9
|
+
WdIcon_default
|
|
10
|
+
} from "./chunk-Q34U2HES.js";
|
|
11
|
+
|
|
12
|
+
// .lib-build/WdImagePreview.ts
|
|
13
|
+
import { defineComponent as _defineComponent } from "vue";
|
|
14
|
+
import { renderSlot as _renderSlot, openBlock as _openBlock, createElementBlock as _createElementBlock, createCommentVNode as _createCommentVNode, unref as _unref, createVNode as _createVNode, createElementVNode as _createElementVNode, mergeProps as _mergeProps, normalizeStyle as _normalizeStyle, Fragment as _Fragment, withModifiers as _withModifiers, toDisplayString as _toDisplayString, Transition as _Transition, withCtx as _withCtx, Teleport as _Teleport, createBlock as _createBlock } from "vue";
|
|
15
|
+
import { computed, ref, watch } from "vue";
|
|
16
|
+
var _hoisted_1 = ["src", "alt"];
|
|
17
|
+
var _hoisted_2 = {
|
|
18
|
+
key: 1,
|
|
19
|
+
class: "wd-image-preview__thumb wd-image-preview__thumb--failed"
|
|
20
|
+
};
|
|
21
|
+
var _hoisted_3 = ["aria-label"];
|
|
22
|
+
var _hoisted_4 = ["src", "alt"];
|
|
23
|
+
var _hoisted_5 = {
|
|
24
|
+
class: "wd-preview__failed",
|
|
25
|
+
role: "alert"
|
|
26
|
+
};
|
|
27
|
+
var _hoisted_6 = {
|
|
28
|
+
key: 0,
|
|
29
|
+
class: "wd-preview__count"
|
|
30
|
+
};
|
|
31
|
+
var _hoisted_7 = { class: "wd-preview__toolbar" };
|
|
32
|
+
var WdImagePreview_default = /* @__PURE__ */ _defineComponent({
|
|
33
|
+
...{ name: "WdImagePreview" },
|
|
34
|
+
__name: "WdImagePreview",
|
|
35
|
+
props: {
|
|
36
|
+
src: { type: String, required: false, default: "" },
|
|
37
|
+
list: { type: Array, required: false, default: () => [] },
|
|
38
|
+
alt: { type: String, required: false, default: "" },
|
|
39
|
+
index: { type: Number, required: false, default: 0 }
|
|
40
|
+
},
|
|
41
|
+
setup(__props) {
|
|
42
|
+
const POP_DURATION = popDuration();
|
|
43
|
+
const props = __props;
|
|
44
|
+
const open = ref(false);
|
|
45
|
+
const panel = ref(null);
|
|
46
|
+
const cur = ref(props.index);
|
|
47
|
+
const scale = ref(1);
|
|
48
|
+
const rotate = ref(0);
|
|
49
|
+
const thumbFailed = ref(false);
|
|
50
|
+
const stageFailed = ref(false);
|
|
51
|
+
watch(
|
|
52
|
+
() => [props.src, props.list, cur.value],
|
|
53
|
+
() => {
|
|
54
|
+
thumbFailed.value = false;
|
|
55
|
+
stageFailed.value = false;
|
|
56
|
+
},
|
|
57
|
+
{ deep: true }
|
|
58
|
+
);
|
|
59
|
+
const images = computed(() => props.list.length ? props.list : props.src ? [props.src] : []);
|
|
60
|
+
useFocusTrap(open, panel, () => {
|
|
61
|
+
open.value = false;
|
|
62
|
+
return true;
|
|
63
|
+
});
|
|
64
|
+
watch(
|
|
65
|
+
() => props.index,
|
|
66
|
+
(v) => {
|
|
67
|
+
cur.value = v;
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
function retryStage() {
|
|
71
|
+
stageFailed.value = false;
|
|
72
|
+
}
|
|
73
|
+
function view(i) {
|
|
74
|
+
const n = images.value.length;
|
|
75
|
+
if (!n) return;
|
|
76
|
+
cur.value = (i % n + n) % n;
|
|
77
|
+
scale.value = 1;
|
|
78
|
+
rotate.value = 0;
|
|
79
|
+
}
|
|
80
|
+
function zoom(d) {
|
|
81
|
+
scale.value = Math.min(4, Math.max(0.4, Math.round((scale.value + d) * 100) / 100));
|
|
82
|
+
}
|
|
83
|
+
function resetView() {
|
|
84
|
+
scale.value = 1;
|
|
85
|
+
rotate.value = 0;
|
|
86
|
+
}
|
|
87
|
+
function openPreview() {
|
|
88
|
+
if (!images.value.length) return;
|
|
89
|
+
resetView();
|
|
90
|
+
open.value = true;
|
|
91
|
+
}
|
|
92
|
+
return (_ctx, _cache) => {
|
|
93
|
+
return _openBlock(), _createElementBlock(
|
|
94
|
+
_Fragment,
|
|
95
|
+
null,
|
|
96
|
+
[
|
|
97
|
+
_createElementVNode(
|
|
98
|
+
"span",
|
|
99
|
+
_mergeProps(_ctx.$attrs, {
|
|
100
|
+
class: "wd-image-preview",
|
|
101
|
+
onClick: openPreview
|
|
102
|
+
}),
|
|
103
|
+
[
|
|
104
|
+
_renderSlot(_ctx.$slots, "default", {}, () => [
|
|
105
|
+
(__props.src || __props.list.length) && !thumbFailed.value ? (_openBlock(), _createElementBlock("img", {
|
|
106
|
+
key: 0,
|
|
107
|
+
src: __props.src || images.value[0],
|
|
108
|
+
alt: __props.alt,
|
|
109
|
+
class: "wd-image-preview__thumb",
|
|
110
|
+
onError: _cache[0] || (_cache[0] = ($event) => thumbFailed.value = true)
|
|
111
|
+
}, null, 40, _hoisted_1)) : thumbFailed.value ? (_openBlock(), _createElementBlock("span", _hoisted_2, [
|
|
112
|
+
_createVNode(_unref(WdIcon_default), {
|
|
113
|
+
name: "image",
|
|
114
|
+
size: 18
|
|
115
|
+
}),
|
|
116
|
+
_cache[10] || (_cache[10] = _createElementVNode(
|
|
117
|
+
"span",
|
|
118
|
+
null,
|
|
119
|
+
"\u56FE\u7247\u52A0\u8F7D\u5931\u8D25",
|
|
120
|
+
-1
|
|
121
|
+
/* CACHED */
|
|
122
|
+
))
|
|
123
|
+
])) : _createCommentVNode("v-if", true)
|
|
124
|
+
])
|
|
125
|
+
],
|
|
126
|
+
16
|
|
127
|
+
/* FULL_PROPS */
|
|
128
|
+
),
|
|
129
|
+
(_openBlock(), _createBlock(_Teleport, { to: "body" }, [
|
|
130
|
+
_createVNode(_Transition, {
|
|
131
|
+
name: "wd-preview-fade",
|
|
132
|
+
duration: _unref(POP_DURATION)
|
|
133
|
+
}, {
|
|
134
|
+
default: _withCtx(() => [
|
|
135
|
+
open.value ? (_openBlock(), _createElementBlock("div", {
|
|
136
|
+
key: 0,
|
|
137
|
+
ref_key: "panel",
|
|
138
|
+
ref: panel,
|
|
139
|
+
class: "wd-preview",
|
|
140
|
+
role: "dialog",
|
|
141
|
+
"aria-modal": "true",
|
|
142
|
+
"aria-label": __props.alt || "\u56FE\u7247\u9884\u89C8"
|
|
143
|
+
}, [
|
|
144
|
+
_createElementVNode("div", {
|
|
145
|
+
class: "wd-preview__mask",
|
|
146
|
+
"aria-hidden": "true",
|
|
147
|
+
onClick: _cache[1] || (_cache[1] = ($event) => open.value = false)
|
|
148
|
+
}),
|
|
149
|
+
_createElementVNode(
|
|
150
|
+
"div",
|
|
151
|
+
{
|
|
152
|
+
class: "wd-preview__stage",
|
|
153
|
+
onWheel: _cache[3] || (_cache[3] = _withModifiers(($event) => zoom($event.deltaY > 0 ? -0.15 : 0.15), ["prevent"]))
|
|
154
|
+
},
|
|
155
|
+
[
|
|
156
|
+
!stageFailed.value ? (_openBlock(), _createElementBlock("img", {
|
|
157
|
+
key: 0,
|
|
158
|
+
class: "wd-preview__img",
|
|
159
|
+
src: images.value[cur.value],
|
|
160
|
+
alt: __props.alt,
|
|
161
|
+
style: _normalizeStyle({ transform: `scale(${scale.value}) rotate(${rotate.value}deg)` }),
|
|
162
|
+
onError: _cache[2] || (_cache[2] = ($event) => stageFailed.value = true)
|
|
163
|
+
}, null, 44, _hoisted_4)) : (_openBlock(), _createElementBlock(
|
|
164
|
+
_Fragment,
|
|
165
|
+
{ key: 1 },
|
|
166
|
+
[
|
|
167
|
+
_createCommentVNode("\n \u52A0\u8F7D\u5931\u8D25\u8981**\u5728\u906E\u7F69\u4E0A\u8BF4\u6E05\u695A**\uFF0C\u800C\u4E0D\u662F\u4EA4\u7ED9\u6D4F\u89C8\u5668\u7684\u7834\u56FE\u56FE\u6807\u3002\n \u7ED9\u4E00\u4E2A\u300C\u91CD\u8BD5\u300D\uFF1A\u4E34\u65F6\u7F51\u7EDC\u95EE\u9898\u91CD\u8BD5\u5F80\u5F80\u5C31\u597D\u4E86\uFF0C\u800C\u4E14\u80FD\u8BA9\u7528\u6237\u786E\u8BA4\n \u300C\u662F\u8FD9\u5F20\u56FE\u574F\u4E86\u300D\u800C\u4E0D\u662F\u300C\u9884\u89C8\u5668\u5361\u4F4F\u4E86\u300D\u3002\n "),
|
|
168
|
+
_createElementVNode("div", _hoisted_5, [
|
|
169
|
+
_createVNode(_unref(WdIcon_default), {
|
|
170
|
+
name: "image",
|
|
171
|
+
size: 40
|
|
172
|
+
}),
|
|
173
|
+
_cache[11] || (_cache[11] = _createElementVNode(
|
|
174
|
+
"p",
|
|
175
|
+
{ class: "wd-preview__failed-title" },
|
|
176
|
+
"\u56FE\u7247\u52A0\u8F7D\u5931\u8D25",
|
|
177
|
+
-1
|
|
178
|
+
/* CACHED */
|
|
179
|
+
)),
|
|
180
|
+
_cache[12] || (_cache[12] = _createElementVNode(
|
|
181
|
+
"p",
|
|
182
|
+
{ class: "wd-preview__failed-hint" },
|
|
183
|
+
"\u94FE\u63A5\u53EF\u80FD\u5DF2\u5931\u6548\uFF0C\u6216\u56FE\u7247\u4E0D\u5141\u8BB8\u8DE8\u57DF\u8BBF\u95EE",
|
|
184
|
+
-1
|
|
185
|
+
/* CACHED */
|
|
186
|
+
)),
|
|
187
|
+
_createElementVNode("button", {
|
|
188
|
+
type: "button",
|
|
189
|
+
class: "wd-preview__retry",
|
|
190
|
+
onClick: retryStage
|
|
191
|
+
}, "\u91CD\u8BD5")
|
|
192
|
+
])
|
|
193
|
+
],
|
|
194
|
+
2112
|
|
195
|
+
/* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
|
|
196
|
+
))
|
|
197
|
+
],
|
|
198
|
+
32
|
|
199
|
+
/* NEED_HYDRATION */
|
|
200
|
+
),
|
|
201
|
+
images.value.length > 1 ? (_openBlock(), _createElementBlock(
|
|
202
|
+
"div",
|
|
203
|
+
_hoisted_6,
|
|
204
|
+
_toDisplayString(cur.value + 1) + " / " + _toDisplayString(images.value.length),
|
|
205
|
+
1
|
|
206
|
+
/* TEXT */
|
|
207
|
+
)) : _createCommentVNode("v-if", true),
|
|
208
|
+
_createElementVNode("div", _hoisted_7, [
|
|
209
|
+
images.value.length > 1 ? (_openBlock(), _createElementBlock("button", {
|
|
210
|
+
key: 0,
|
|
211
|
+
type: "button",
|
|
212
|
+
class: "wd-icon-btn wd-icon-btn--ghost wd-preview__btn",
|
|
213
|
+
"aria-label": "\u4E0A\u4E00\u5F20",
|
|
214
|
+
onClick: _cache[4] || (_cache[4] = ($event) => view(cur.value - 1))
|
|
215
|
+
}, "\u2039")) : _createCommentVNode("v-if", true),
|
|
216
|
+
_createElementVNode("button", {
|
|
217
|
+
type: "button",
|
|
218
|
+
class: "wd-icon-btn wd-icon-btn--ghost wd-preview__btn",
|
|
219
|
+
"aria-label": "\u65CB\u8F6C",
|
|
220
|
+
onClick: _cache[5] || (_cache[5] = ($event) => rotate.value = (rotate.value + 90) % 360)
|
|
221
|
+
}, "\u21BB"),
|
|
222
|
+
_createElementVNode("button", {
|
|
223
|
+
type: "button",
|
|
224
|
+
class: "wd-icon-btn wd-icon-btn--ghost wd-preview__btn",
|
|
225
|
+
"aria-label": "\u7F29\u5C0F",
|
|
226
|
+
onClick: _cache[6] || (_cache[6] = ($event) => zoom(-0.25))
|
|
227
|
+
}, "\u2212"),
|
|
228
|
+
_createElementVNode("button", {
|
|
229
|
+
type: "button",
|
|
230
|
+
class: "wd-icon-btn wd-icon-btn--ghost wd-preview__btn",
|
|
231
|
+
"aria-label": "\u653E\u5927",
|
|
232
|
+
onClick: _cache[7] || (_cache[7] = ($event) => zoom(0.25))
|
|
233
|
+
}, "\uFF0B"),
|
|
234
|
+
_createElementVNode("button", {
|
|
235
|
+
type: "button",
|
|
236
|
+
class: "wd-icon-btn wd-icon-btn--ghost wd-preview__btn",
|
|
237
|
+
"aria-label": "\u8FD8\u539F",
|
|
238
|
+
onClick: resetView
|
|
239
|
+
}, "1:1"),
|
|
240
|
+
images.value.length > 1 ? (_openBlock(), _createElementBlock("button", {
|
|
241
|
+
key: 1,
|
|
242
|
+
type: "button",
|
|
243
|
+
class: "wd-icon-btn wd-icon-btn--ghost wd-preview__btn",
|
|
244
|
+
"aria-label": "\u4E0B\u4E00\u5F20",
|
|
245
|
+
onClick: _cache[8] || (_cache[8] = ($event) => view(cur.value + 1))
|
|
246
|
+
}, "\u203A")) : _createCommentVNode("v-if", true),
|
|
247
|
+
_createElementVNode("button", {
|
|
248
|
+
type: "button",
|
|
249
|
+
class: "wd-icon-btn wd-icon-btn--ghost wd-preview__btn",
|
|
250
|
+
"aria-label": "\u5173\u95ED",
|
|
251
|
+
onClick: _cache[9] || (_cache[9] = ($event) => open.value = false)
|
|
252
|
+
}, [
|
|
253
|
+
_createVNode(_unref(WdIcon_default), {
|
|
254
|
+
name: "close",
|
|
255
|
+
size: 13
|
|
256
|
+
})
|
|
257
|
+
])
|
|
258
|
+
])
|
|
259
|
+
], 8, _hoisted_3)) : _createCommentVNode("v-if", true)
|
|
260
|
+
]),
|
|
261
|
+
_: 1
|
|
262
|
+
/* STABLE */
|
|
263
|
+
}, 8, ["duration"])
|
|
264
|
+
]))
|
|
265
|
+
],
|
|
266
|
+
64
|
|
267
|
+
/* STABLE_FRAGMENT */
|
|
268
|
+
);
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
export {
|
|
273
|
+
WdImagePreview_default as WdImagePreview
|
|
274
|
+
};
|