@veltra/desktop 1.10.0 → 1.12.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/dist/components/ai-button/ai-button.js +117 -0
- package/dist/components/ai-button/ai-button.js.map +1 -0
- package/dist/components/ai-button/style.d.ts +1 -0
- package/dist/components/ai-button/style.js +3 -0
- package/dist/components/ai-button/style2.css +29 -0
- package/dist/components/code-editor/basic-setup.js +5 -5
- package/dist/components/code-editor/code-editor.js +2 -2
- package/dist/components/code-editor/langs/bash/index.js +2 -2
- package/dist/components/code-editor/langs/powershell/index.js +2 -2
- package/dist/components/code-editor/langs/spel/index.js +1 -1
- package/dist/components/code-editor/langs/spel/language.js +1 -1
- package/dist/components/code-editor/shell-extension.js +2 -2
- package/dist/components/file-viewer/previewers/image-previewer.js +28 -124
- package/dist/components/file-viewer/previewers/image-previewer.js.map +1 -1
- package/dist/components/file-viewer/previewers/pdf-worker-wrapper.js.map +1 -1
- package/dist/components/file-viewer/previewers/sheet-previewer.js +5 -5
- package/dist/components/file-viewer/previewers/sheet-previewer.js.map +1 -1
- package/dist/components/file-viewer/style2.css +42 -203
- package/dist/components/image-previewer/image-previewer.js +286 -0
- package/dist/components/image-previewer/image-previewer.js.map +1 -0
- package/dist/components/image-previewer/style.d.ts +1 -0
- package/dist/components/image-previewer/style.js +2 -0
- package/dist/components/image-previewer/style2.css +174 -0
- package/dist/components/index.d.ts +21 -19
- package/dist/components/index.js +41 -37
- package/dist/components/index.js.map +1 -1
- package/dist/index.d.ts +110 -106
- package/dist/index.js +108 -106
- package/dist/node_modules/.bun/@codemirror_autocomplete@6.20.3/node_modules/@codemirror/autocomplete/dist/index.js +3 -3
- package/dist/node_modules/.bun/@codemirror_autocomplete@6.20.3/node_modules/@codemirror/autocomplete/dist/index.js.map +1 -1
- package/dist/node_modules/.bun/{@codemirror_commands@6.11.0 → @codemirror_commands@6.11.1}/node_modules/@codemirror/commands/dist/index.js +6 -6
- package/dist/node_modules/.bun/@codemirror_commands@6.11.1/node_modules/@codemirror/commands/dist/index.js.map +1 -0
- package/dist/node_modules/.bun/@codemirror_lang-css@6.3.1/node_modules/@codemirror/lang-css/dist/index.js +1 -1
- package/dist/node_modules/.bun/@codemirror_lang-css@6.3.1/node_modules/@codemirror/lang-css/dist/index.js.map +1 -1
- package/dist/node_modules/.bun/@codemirror_lang-html@6.4.12/node_modules/@codemirror/lang-html/dist/index.js +3 -3
- package/dist/node_modules/.bun/@codemirror_lang-html@6.4.12/node_modules/@codemirror/lang-html/dist/index.js.map +1 -1
- package/dist/node_modules/.bun/@codemirror_lang-java@6.0.2/node_modules/@codemirror/lang-java/dist/index.js +1 -1
- package/dist/node_modules/.bun/@codemirror_lang-java@6.0.2/node_modules/@codemirror/lang-java/dist/index.js.map +1 -1
- package/dist/node_modules/.bun/@codemirror_lang-javascript@6.2.5/node_modules/@codemirror/lang-javascript/dist/index.js +3 -3
- package/dist/node_modules/.bun/@codemirror_lang-javascript@6.2.5/node_modules/@codemirror/lang-javascript/dist/index.js.map +1 -1
- package/dist/node_modules/.bun/@codemirror_lang-json@6.0.2/node_modules/@codemirror/lang-json/dist/index.js +1 -1
- package/dist/node_modules/.bun/@codemirror_lang-json@6.0.2/node_modules/@codemirror/lang-json/dist/index.js.map +1 -1
- package/dist/node_modules/.bun/@codemirror_lang-markdown@6.5.2/node_modules/@codemirror/lang-markdown/dist/index.js +3 -3
- package/dist/node_modules/.bun/@codemirror_lang-markdown@6.5.2/node_modules/@codemirror/lang-markdown/dist/index.js.map +1 -1
- package/dist/node_modules/.bun/@codemirror_lang-sql@6.10.0/node_modules/@codemirror/lang-sql/dist/index.js +1 -1
- package/dist/node_modules/.bun/@codemirror_lang-sql@6.10.0/node_modules/@codemirror/lang-sql/dist/index.js.map +1 -1
- package/dist/node_modules/.bun/{@codemirror_language@6.12.4 → @codemirror_language@6.13.1}/node_modules/@codemirror/language/dist/index.js +5 -168
- package/dist/node_modules/.bun/@codemirror_language@6.13.1/node_modules/@codemirror/language/dist/index.js.map +1 -0
- package/dist/node_modules/.bun/{@codemirror_legacy-modes@6.5.4 → @codemirror_legacy-modes@6.5.5}/node_modules/@codemirror/legacy-modes/mode/powershell.js +1 -1
- package/dist/node_modules/.bun/{@codemirror_legacy-modes@6.5.4 → @codemirror_legacy-modes@6.5.5}/node_modules/@codemirror/legacy-modes/mode/powershell.js.map +1 -1
- package/dist/node_modules/.bun/{@codemirror_legacy-modes@6.5.4 → @codemirror_legacy-modes@6.5.5}/node_modules/@codemirror/legacy-modes/mode/shell.js +1 -1
- package/dist/node_modules/.bun/{@codemirror_legacy-modes@6.5.4 → @codemirror_legacy-modes@6.5.5}/node_modules/@codemirror/legacy-modes/mode/shell.js.map +1 -1
- package/dist/node_modules/.bun/@codemirror_lint@6.9.7/node_modules/@codemirror/lint/dist/index.js +2 -2
- package/dist/node_modules/.bun/@codemirror_lint@6.9.7/node_modules/@codemirror/lint/dist/index.js.map +1 -1
- package/dist/node_modules/.bun/{@codemirror_search@6.7.1 → @codemirror_search@6.7.2}/node_modules/@codemirror/search/dist/index.js +10 -3
- package/dist/node_modules/.bun/@codemirror_search@6.7.2/node_modules/@codemirror/search/dist/index.js.map +1 -0
- package/dist/node_modules/.bun/{@codemirror_state@6.7.1 → @codemirror_state@6.7.6}/node_modules/@codemirror/state/dist/index.js +50 -16
- package/dist/node_modules/.bun/@codemirror_state@6.7.6/node_modules/@codemirror/state/dist/index.js.map +1 -0
- package/dist/node_modules/.bun/@codemirror_streamparser@6.0.0/node_modules/@codemirror/streamparser/dist/index.js +169 -0
- package/dist/node_modules/.bun/@codemirror_streamparser@6.0.0/node_modules/@codemirror/streamparser/dist/index.js.map +1 -0
- package/dist/node_modules/.bun/@codemirror_theme-one-dark@6.1.3/node_modules/@codemirror/theme-one-dark/dist/index.js +2 -2
- package/dist/node_modules/.bun/@codemirror_theme-one-dark@6.1.3/node_modules/@codemirror/theme-one-dark/dist/index.js.map +1 -1
- package/dist/node_modules/.bun/{@codemirror_view@6.43.9 → @codemirror_view@6.43.14}/node_modules/@codemirror/view/dist/index.js +159 -93
- package/dist/node_modules/.bun/@codemirror_view@6.43.14/node_modules/@codemirror/view/dist/index.js.map +1 -0
- package/dist/node_modules/.bun/@lezer_common@1.5.3/node_modules/@lezer/common/dist/index.js.map +1 -1
- package/dist/node_modules/.bun/@lezer_css@1.3.9/node_modules/@lezer/css/dist/index.js.map +1 -1
- package/dist/node_modules/.bun/@lezer_highlight@1.2.5/node_modules/@lezer/highlight/dist/index.js.map +1 -1
- package/dist/node_modules/.bun/@lezer_html@1.3.13/node_modules/@lezer/html/dist/index.js.map +1 -1
- package/dist/node_modules/.bun/@lezer_java@1.1.5/node_modules/@lezer/java/dist/index.js.map +1 -1
- package/dist/node_modules/.bun/@lezer_javascript@1.5.6/node_modules/@lezer/javascript/dist/index.js.map +1 -1
- package/dist/node_modules/.bun/@lezer_json@1.0.3/node_modules/@lezer/json/dist/index.js.map +1 -1
- package/dist/node_modules/.bun/@lezer_lr@1.4.11/node_modules/@lezer/lr/dist/index.js.map +1 -1
- package/dist/node_modules/.bun/@lezer_markdown@1.8.0/node_modules/@lezer/markdown/dist/index.js.map +1 -1
- package/dist/node_modules/.bun/@marijn_find-cluster-break@1.0.4/node_modules/@marijn/find-cluster-break/src/index.js.map +1 -1
- package/dist/node_modules/.bun/crelt@1.0.7/node_modules/crelt/index.js.map +1 -1
- package/dist/node_modules/.bun/style-mod@4.1.4/node_modules/style-mod/src/style-mod.js.map +1 -1
- package/dist/node_modules/.bun/w3c-keyname@2.2.8/node_modules/w3c-keyname/index.js.map +1 -1
- package/dist/types/ai-button.d.ts +42 -0
- package/dist/types/image-previewer.d.ts +48 -0
- package/dist/types/index.d.ts +3 -1
- package/package.json +16 -16
- package/src/components/ai-button/__test__/ai-button.test.ts +375 -0
- package/src/components/ai-button/ai-button.vue +87 -0
- package/src/components/ai-button/index.ts +1 -0
- package/src/components/ai-button/style.scss +19 -0
- package/src/components/ai-button/style.ts +3 -0
- package/src/components/file-viewer/__test__/file-viewer.test.ts +58 -0
- package/src/components/file-viewer/previewers/image-previewer.vue +25 -138
- package/src/components/file-viewer/previewers/sheet-previewer.vue +1 -1
- package/src/components/file-viewer/style.scss +54 -266
- package/src/components/image-previewer/__test__/image-previewer.test.ts +292 -0
- package/src/components/image-previewer/image-previewer.vue +314 -0
- package/src/components/image-previewer/index.ts +1 -0
- package/src/components/image-previewer/style.scss +188 -0
- package/src/components/image-previewer/style.ts +2 -0
- package/src/components/index.ts +4 -0
- package/src/types/ai-button.ts +44 -0
- package/src/types/image-previewer.ts +50 -0
- package/src/types/index.ts +3 -0
- package/dist/node_modules/.bun/@codemirror_commands@6.11.0/node_modules/@codemirror/commands/dist/index.js.map +0 -1
- package/dist/node_modules/.bun/@codemirror_language@6.12.4/node_modules/@codemirror/language/dist/index.js.map +0 -1
- package/dist/node_modules/.bun/@codemirror_search@6.7.1/node_modules/@codemirror/search/dist/index.js.map +0 -1
- package/dist/node_modules/.bun/@codemirror_state@6.7.1/node_modules/@codemirror/state/dist/index.js.map +0 -1
- package/dist/node_modules/.bun/@codemirror_view@6.43.9/node_modules/@codemirror/view/dist/index.js.map +0 -1
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import _sfc_main$1 from "../icon/icon.js";
|
|
2
|
+
import { ZOOM_MIN, ZOOM_STEP, clampZoom, toBlobUrl } from "../file-viewer/helper.js";
|
|
3
|
+
import { Fragment, Teleport, Transition, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, mergeModels, mergeProps, normalizeClass, onBeforeUnmount, openBlock, ref, shallowRef, toDisplayString, unref, useAttrs, useModel, useTemplateRef, watch, withCtx, withModifiers } from "vue";
|
|
4
|
+
import { bem } from "@veltra/utils";
|
|
5
|
+
import { Close, Refresh, ZoomIn, ZoomOut } from "@veltra/icons/normal";
|
|
6
|
+
//#region src/components/image-previewer/image-previewer.vue
|
|
7
|
+
const _hoisted_1 = ["src", "alt"];
|
|
8
|
+
const _hoisted_2 = ["disabled"];
|
|
9
|
+
const _hoisted_3 = ["disabled"];
|
|
10
|
+
const _hoisted_4 = ["disabled"];
|
|
11
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
12
|
+
name: "UImagePreviewer",
|
|
13
|
+
inheritAttrs: false,
|
|
14
|
+
__name: "image-previewer",
|
|
15
|
+
props: /*@__PURE__*/ mergeModels({
|
|
16
|
+
src: {},
|
|
17
|
+
alt: {},
|
|
18
|
+
mime: {},
|
|
19
|
+
modal: {
|
|
20
|
+
type: Boolean,
|
|
21
|
+
default: true
|
|
22
|
+
},
|
|
23
|
+
open: { type: Boolean },
|
|
24
|
+
closeOnClickBackdrop: {
|
|
25
|
+
type: Boolean,
|
|
26
|
+
default: true
|
|
27
|
+
},
|
|
28
|
+
closeOnEsc: {
|
|
29
|
+
type: Boolean,
|
|
30
|
+
default: true
|
|
31
|
+
}
|
|
32
|
+
}, {
|
|
33
|
+
"open": {
|
|
34
|
+
type: Boolean,
|
|
35
|
+
default: true
|
|
36
|
+
},
|
|
37
|
+
"openModifiers": {}
|
|
38
|
+
}),
|
|
39
|
+
emits: /*@__PURE__*/ mergeModels([
|
|
40
|
+
"update:open",
|
|
41
|
+
"close",
|
|
42
|
+
"zoom-change",
|
|
43
|
+
"error"
|
|
44
|
+
], ["update:open"]),
|
|
45
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
46
|
+
const emit = __emit;
|
|
47
|
+
const cls = bem("image-previewer");
|
|
48
|
+
const attrs = useAttrs();
|
|
49
|
+
const stage = useTemplateRef("stage");
|
|
50
|
+
const open = useModel(__props, "open");
|
|
51
|
+
const url = shallowRef("");
|
|
52
|
+
const loading = ref(false);
|
|
53
|
+
const failed = ref(false);
|
|
54
|
+
/** 缩放级别;缩放入口统一经 setScale 收敛到 [ZOOM_MIN, ZOOM_MAX] */
|
|
55
|
+
const scale = ref(1);
|
|
56
|
+
/** 拖拽起止各写一次,仅驱动 grabbing 光标 */
|
|
57
|
+
const isDragging = ref(false);
|
|
58
|
+
const zoomPercent = computed(() => `${Math.round(scale.value * 100)}%`);
|
|
59
|
+
let panState;
|
|
60
|
+
let offsetX = 0;
|
|
61
|
+
let offsetY = 0;
|
|
62
|
+
/** transform 唯一写入口:直接写预览面 style,绕开响应式 */
|
|
63
|
+
function applyTransform() {
|
|
64
|
+
const el = stage.value;
|
|
65
|
+
if (!el) return;
|
|
66
|
+
el.style.transform = `translate3d(${offsetX}px, ${offsetY}px, 0) scale(${scale.value})`;
|
|
67
|
+
}
|
|
68
|
+
function setScale(value) {
|
|
69
|
+
scale.value = clampZoom(value);
|
|
70
|
+
if (scale.value <= 1) {
|
|
71
|
+
offsetX = 0;
|
|
72
|
+
offsetY = 0;
|
|
73
|
+
}
|
|
74
|
+
applyTransform();
|
|
75
|
+
emit("zoom-change", scale.value);
|
|
76
|
+
}
|
|
77
|
+
function zoomIn() {
|
|
78
|
+
setScale(scale.value + ZOOM_STEP);
|
|
79
|
+
}
|
|
80
|
+
function zoomOut() {
|
|
81
|
+
setScale(scale.value - ZOOM_STEP);
|
|
82
|
+
}
|
|
83
|
+
function resetZoom() {
|
|
84
|
+
setScale(1);
|
|
85
|
+
}
|
|
86
|
+
__expose({
|
|
87
|
+
zoomIn,
|
|
88
|
+
zoomOut,
|
|
89
|
+
resetZoom
|
|
90
|
+
});
|
|
91
|
+
function onPointerDown(e) {
|
|
92
|
+
if (scale.value <= 1 || e.button !== 0) return;
|
|
93
|
+
panState = {
|
|
94
|
+
pointerId: e.pointerId,
|
|
95
|
+
startX: e.clientX,
|
|
96
|
+
startY: e.clientY,
|
|
97
|
+
originX: offsetX,
|
|
98
|
+
originY: offsetY
|
|
99
|
+
};
|
|
100
|
+
isDragging.value = true;
|
|
101
|
+
stage.value?.setPointerCapture(e.pointerId);
|
|
102
|
+
e.preventDefault();
|
|
103
|
+
}
|
|
104
|
+
function onPointerMove(e) {
|
|
105
|
+
if (!panState || panState.pointerId !== e.pointerId) return;
|
|
106
|
+
offsetX = panState.originX + e.clientX - panState.startX;
|
|
107
|
+
offsetY = panState.originY + e.clientY - panState.startY;
|
|
108
|
+
applyTransform();
|
|
109
|
+
}
|
|
110
|
+
function onPointerEnd(e) {
|
|
111
|
+
if (!panState || panState.pointerId !== e.pointerId) return;
|
|
112
|
+
const el = stage.value;
|
|
113
|
+
if (el?.hasPointerCapture(e.pointerId)) el.releasePointerCapture(e.pointerId);
|
|
114
|
+
panState = void 0;
|
|
115
|
+
isDragging.value = false;
|
|
116
|
+
}
|
|
117
|
+
function onWheel(e) {
|
|
118
|
+
if (!(e.ctrlKey || e.metaKey)) return;
|
|
119
|
+
e.preventDefault();
|
|
120
|
+
setScale(scale.value + (e.deltaY > 0 ? -ZOOM_STEP : ZOOM_STEP));
|
|
121
|
+
}
|
|
122
|
+
function onDblclick() {
|
|
123
|
+
if (scale.value === 1) setScale(2);
|
|
124
|
+
else resetZoom();
|
|
125
|
+
}
|
|
126
|
+
function onBackdropMousedown() {
|
|
127
|
+
if (!__props.modal) return;
|
|
128
|
+
if (__props.closeOnClickBackdrop === false) return;
|
|
129
|
+
if (scale.value > 1) return;
|
|
130
|
+
close();
|
|
131
|
+
}
|
|
132
|
+
function close() {
|
|
133
|
+
if (!__props.modal) return;
|
|
134
|
+
open.value = false;
|
|
135
|
+
emit("close");
|
|
136
|
+
}
|
|
137
|
+
function handleWindowKeydown(e) {
|
|
138
|
+
if (e.key !== "Escape") return;
|
|
139
|
+
if (!__props.modal || !open.value) return;
|
|
140
|
+
if (__props.closeOnEsc === false) return;
|
|
141
|
+
e.stopPropagation();
|
|
142
|
+
close();
|
|
143
|
+
}
|
|
144
|
+
let revoke;
|
|
145
|
+
function load() {
|
|
146
|
+
if (__props.src === void 0 || __props.src === null) {
|
|
147
|
+
revoke?.();
|
|
148
|
+
revoke = void 0;
|
|
149
|
+
url.value = "";
|
|
150
|
+
loading.value = false;
|
|
151
|
+
failed.value = false;
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
loading.value = true;
|
|
155
|
+
failed.value = false;
|
|
156
|
+
revoke?.();
|
|
157
|
+
const r = toBlobUrl(__props.src, __props.mime);
|
|
158
|
+
url.value = r.url;
|
|
159
|
+
revoke = r.revoke;
|
|
160
|
+
setScale(1);
|
|
161
|
+
}
|
|
162
|
+
function onImgError(e) {
|
|
163
|
+
loading.value = false;
|
|
164
|
+
failed.value = true;
|
|
165
|
+
emit("error", e);
|
|
166
|
+
}
|
|
167
|
+
watch(() => __props.src, () => load(), { immediate: true });
|
|
168
|
+
let previousBodyOverflow = "";
|
|
169
|
+
let isBodyLocked = false;
|
|
170
|
+
function lockBody() {
|
|
171
|
+
if (isBodyLocked || typeof document === "undefined") return;
|
|
172
|
+
previousBodyOverflow = document.body.style.overflow;
|
|
173
|
+
document.body.style.overflow = "hidden";
|
|
174
|
+
isBodyLocked = true;
|
|
175
|
+
}
|
|
176
|
+
function unlockBody() {
|
|
177
|
+
if (!isBodyLocked || typeof document === "undefined") return;
|
|
178
|
+
document.body.style.overflow = previousBodyOverflow;
|
|
179
|
+
isBodyLocked = false;
|
|
180
|
+
}
|
|
181
|
+
watch([() => __props.modal, open], ([modalOpen, openNow], _, onCleanup) => {
|
|
182
|
+
onCleanup(() => {
|
|
183
|
+
unlockBody();
|
|
184
|
+
if (typeof window !== "undefined") window.removeEventListener("keydown", handleWindowKeydown, true);
|
|
185
|
+
});
|
|
186
|
+
if (modalOpen && openNow) {
|
|
187
|
+
lockBody();
|
|
188
|
+
if (typeof window !== "undefined") window.addEventListener("keydown", handleWindowKeydown, true);
|
|
189
|
+
} else unlockBody();
|
|
190
|
+
}, { immediate: true });
|
|
191
|
+
onBeforeUnmount(() => {
|
|
192
|
+
revoke?.();
|
|
193
|
+
url.value = "";
|
|
194
|
+
});
|
|
195
|
+
return (_ctx, _cache) => {
|
|
196
|
+
return openBlock(), createBlock(Teleport, {
|
|
197
|
+
to: "body",
|
|
198
|
+
disabled: !__props.modal
|
|
199
|
+
}, [createVNode(Transition, { name: __props.modal ? "u-image-previewer-fade" : "" }, {
|
|
200
|
+
default: withCtx(() => [!__props.modal || open.value ? (openBlock(), createElementBlock("div", {
|
|
201
|
+
key: 0,
|
|
202
|
+
class: normalizeClass([unref(cls).b, unref(bem).is("modal", __props.modal)])
|
|
203
|
+
}, [createElementVNode("div", mergeProps({
|
|
204
|
+
ref_key: "stage",
|
|
205
|
+
ref: stage,
|
|
206
|
+
class: [
|
|
207
|
+
unref(cls).e("stage"),
|
|
208
|
+
unref(bem).is("pannable", scale.value > 1),
|
|
209
|
+
unref(bem).is("dragging", isDragging.value)
|
|
210
|
+
]
|
|
211
|
+
}, unref(attrs), {
|
|
212
|
+
onMousedown: withModifiers(onBackdropMousedown, ["self"]),
|
|
213
|
+
onPointerdown: onPointerDown,
|
|
214
|
+
onPointermove: onPointerMove,
|
|
215
|
+
onPointerup: onPointerEnd,
|
|
216
|
+
onPointercancel: onPointerEnd,
|
|
217
|
+
onWheel,
|
|
218
|
+
onDblclick
|
|
219
|
+
}), [url.value ? (openBlock(), createElementBlock("img", {
|
|
220
|
+
key: 0,
|
|
221
|
+
src: url.value,
|
|
222
|
+
alt: __props.alt ?? "图片预览",
|
|
223
|
+
draggable: "false",
|
|
224
|
+
onDragstart: _cache[0] || (_cache[0] = withModifiers(() => {}, ["prevent"])),
|
|
225
|
+
onLoad: _cache[1] || (_cache[1] = ($event) => loading.value = false),
|
|
226
|
+
onError: onImgError
|
|
227
|
+
}, null, 40, _hoisted_1)) : createCommentVNode("v-if", true), loading.value ? (openBlock(), createElementBlock("div", {
|
|
228
|
+
key: 1,
|
|
229
|
+
class: normalizeClass(unref(cls).e("loading"))
|
|
230
|
+
}, "加载中…", 2)) : failed.value ? (openBlock(), createElementBlock("div", {
|
|
231
|
+
key: 2,
|
|
232
|
+
class: normalizeClass(unref(cls).e("loading"))
|
|
233
|
+
}, "图片加载失败", 2)) : createCommentVNode("v-if", true)], 16), __props.modal ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [createElementVNode("button", {
|
|
234
|
+
class: normalizeClass(unref(cls).e("close")),
|
|
235
|
+
type: "button",
|
|
236
|
+
"aria-label": "关闭",
|
|
237
|
+
title: "关闭",
|
|
238
|
+
onClick: close
|
|
239
|
+
}, [createVNode(unref(_sfc_main$1), { size: 18 }, {
|
|
240
|
+
default: withCtx(() => [createVNode(unref(Close))]),
|
|
241
|
+
_: 1
|
|
242
|
+
})], 2), createElementVNode("div", { class: normalizeClass(unref(cls).e("toolbar")) }, [
|
|
243
|
+
createElementVNode("button", {
|
|
244
|
+
class: normalizeClass(unref(cls).e("tool")),
|
|
245
|
+
type: "button",
|
|
246
|
+
disabled: scale.value <= unref(ZOOM_MIN),
|
|
247
|
+
"aria-label": "缩小",
|
|
248
|
+
title: "缩小",
|
|
249
|
+
onClick: zoomOut
|
|
250
|
+
}, [createVNode(unref(_sfc_main$1), { size: 16 }, {
|
|
251
|
+
default: withCtx(() => [createVNode(unref(ZoomOut))]),
|
|
252
|
+
_: 1
|
|
253
|
+
})], 10, _hoisted_2),
|
|
254
|
+
createElementVNode("span", { class: normalizeClass(unref(cls).e("zoom-value")) }, toDisplayString(zoomPercent.value), 3),
|
|
255
|
+
createElementVNode("button", {
|
|
256
|
+
class: normalizeClass(unref(cls).e("tool")),
|
|
257
|
+
type: "button",
|
|
258
|
+
disabled: scale.value >= unref(3),
|
|
259
|
+
"aria-label": "放大",
|
|
260
|
+
title: "放大",
|
|
261
|
+
onClick: zoomIn
|
|
262
|
+
}, [createVNode(unref(_sfc_main$1), { size: 16 }, {
|
|
263
|
+
default: withCtx(() => [createVNode(unref(ZoomIn))]),
|
|
264
|
+
_: 1
|
|
265
|
+
})], 10, _hoisted_3),
|
|
266
|
+
createElementVNode("button", {
|
|
267
|
+
class: normalizeClass(unref(cls).e("tool")),
|
|
268
|
+
type: "button",
|
|
269
|
+
disabled: scale.value === 1,
|
|
270
|
+
"aria-label": "重置视图",
|
|
271
|
+
title: "重置视图",
|
|
272
|
+
onClick: resetZoom
|
|
273
|
+
}, [createVNode(unref(_sfc_main$1), { size: 16 }, {
|
|
274
|
+
default: withCtx(() => [createVNode(unref(Refresh))]),
|
|
275
|
+
_: 1
|
|
276
|
+
})], 10, _hoisted_4)
|
|
277
|
+
], 2)], 64)) : createCommentVNode("v-if", true)], 2)) : createCommentVNode("v-if", true)]),
|
|
278
|
+
_: 1
|
|
279
|
+
}, 8, ["name"])], 8, ["disabled"]);
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
//#endregion
|
|
284
|
+
export { _sfc_main as default };
|
|
285
|
+
|
|
286
|
+
//# sourceMappingURL=image-previewer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-previewer.js","names":["_useModel","_openBlock","_createBlock","_Teleport","_createVNode","_Transition","_withCtx","_createElementBlock","_normalizeClass","_unref","_createElementVNode","_mergeProps","_withModifiers","_createCommentVNode","_Fragment","UIcon","_toDisplayString"],"sources":["../../../src/components/image-previewer/image-previewer.vue"],"sourcesContent":["<template>\n <Teleport to=\"body\" :disabled=\"!modal\">\n <transition :name=\"modal ? 'u-image-previewer-fade' : ''\">\n <div v-if=\"!modal || open\" :class=\"[cls.b, bem.is('modal', modal)]\">\n <div\n ref=\"stage\"\n :class=\"[cls.e('stage'), bem.is('pannable', scale > 1), bem.is('dragging', isDragging)]\"\n v-bind=\"attrs\"\n @mousedown.self=\"onBackdropMousedown\"\n @pointerdown=\"onPointerDown\"\n @pointermove=\"onPointerMove\"\n @pointerup=\"onPointerEnd\"\n @pointercancel=\"onPointerEnd\"\n @wheel=\"onWheel\"\n @dblclick=\"onDblclick\"\n >\n <img\n v-if=\"url\"\n :src=\"url\"\n :alt=\"alt ?? '图片预览'\"\n draggable=\"false\"\n @dragstart.prevent\n @load=\"loading = false\"\n @error=\"onImgError\"\n />\n <div v-if=\"loading\" :class=\"cls.e('loading')\">加载中…</div>\n <div v-else-if=\"failed\" :class=\"cls.e('loading')\">图片加载失败</div>\n </div>\n\n <template v-if=\"modal\">\n <button\n :class=\"cls.e('close')\"\n type=\"button\"\n aria-label=\"关闭\"\n title=\"关闭\"\n @click=\"close\"\n >\n <u-icon :size=\"18\">\n <Close />\n </u-icon>\n </button>\n <div :class=\"cls.e('toolbar')\">\n <button\n :class=\"cls.e('tool')\"\n type=\"button\"\n :disabled=\"scale <= ZOOM_MIN\"\n aria-label=\"缩小\"\n title=\"缩小\"\n @click=\"zoomOut\"\n >\n <u-icon :size=\"16\">\n <ZoomOut />\n </u-icon>\n </button>\n <span :class=\"cls.e('zoom-value')\">{{ zoomPercent }}</span>\n <button\n :class=\"cls.e('tool')\"\n type=\"button\"\n :disabled=\"scale >= ZOOM_MAX\"\n aria-label=\"放大\"\n title=\"放大\"\n @click=\"zoomIn\"\n >\n <u-icon :size=\"16\">\n <ZoomIn />\n </u-icon>\n </button>\n <button\n :class=\"cls.e('tool')\"\n type=\"button\"\n :disabled=\"scale === 1\"\n aria-label=\"重置视图\"\n title=\"重置视图\"\n @click=\"resetZoom\"\n >\n <u-icon :size=\"16\">\n <Refresh />\n </u-icon>\n </button>\n </div>\n </template>\n </div>\n </transition>\n </Teleport>\n</template>\n\n<script lang=\"ts\" setup>\nimport { Close, Refresh, ZoomIn, ZoomOut } from '@veltra/icons/normal'\nimport { bem } from '@veltra/utils'\nimport { computed, onBeforeUnmount, ref, shallowRef, useAttrs, useTemplateRef, watch } from 'vue'\n\nimport type {\n ImagePreviewerEmits,\n ImagePreviewerExposed,\n ImagePreviewerProps\n} from '../../types/image-previewer'\nimport { ZOOM_MAX, ZOOM_MIN, ZOOM_STEP, clampZoom, toBlobUrl } from '../file-viewer/helper'\nimport { UIcon } from '../icon'\n\n// 根为 Teleport,无 fallthrough 落点:attrs(含宿主 class)由内层预览面承接\ndefineOptions({ name: 'UImagePreviewer', inheritAttrs: false })\n\nconst {\n src,\n alt,\n mime,\n modal = true,\n closeOnClickBackdrop = true,\n closeOnEsc = true\n} = defineProps<ImagePreviewerProps>()\n\nconst emit = defineEmits<ImagePreviewerEmits>()\n\nconst cls = bem('image-previewer')\nconst attrs = useAttrs()\n\nconst stage = useTemplateRef<HTMLDivElement>('stage')\n\nconst open = defineModel<boolean>('open', { default: true })\n\nconst url = shallowRef<string>('')\nconst loading = ref(false)\nconst failed = ref(false)\n\n/** 缩放级别;缩放入口统一经 setScale 收敛到 [ZOOM_MIN, ZOOM_MAX] */\nconst scale = ref(1)\n/** 拖拽起止各写一次,仅驱动 grabbing 光标 */\nconst isDragging = ref(false)\n\nconst zoomPercent = computed(() => `${Math.round(scale.value * 100)}%`)\n\n// ---- pan 热状态:全部走普通变量,pointermove 不触发重渲染 ----\nlet panState:\n | { pointerId: number; startX: number; startY: number; originX: number; originY: number }\n | undefined\nlet offsetX = 0\nlet offsetY = 0\n\n/** transform 唯一写入口:直接写预览面 style,绕开响应式 */\nfunction applyTransform() {\n const el = stage.value\n if (!el) return\n el.style.transform = `translate3d(${offsetX}px, ${offsetY}px, 0) scale(${scale.value})`\n}\n\nfunction setScale(value: number) {\n scale.value = clampZoom(value)\n if (scale.value <= 1) {\n // 未放大时不允许平移,offset 归零\n offsetX = 0\n offsetY = 0\n }\n applyTransform()\n emit('zoom-change', scale.value)\n}\n\nfunction zoomIn() {\n setScale(scale.value + ZOOM_STEP)\n}\n\nfunction zoomOut() {\n setScale(scale.value - ZOOM_STEP)\n}\n\nfunction resetZoom() {\n setScale(1)\n}\n\ndefineExpose<ImagePreviewerExposed>({ zoomIn, zoomOut, resetZoom })\n\nfunction onPointerDown(e: PointerEvent) {\n if (scale.value <= 1 || e.button !== 0) return\n panState = {\n pointerId: e.pointerId,\n startX: e.clientX,\n startY: e.clientY,\n originX: offsetX,\n originY: offsetY\n }\n isDragging.value = true\n stage.value?.setPointerCapture(e.pointerId)\n e.preventDefault()\n}\n\nfunction onPointerMove(e: PointerEvent) {\n if (!panState || panState.pointerId !== e.pointerId) return\n offsetX = panState.originX + e.clientX - panState.startX\n offsetY = panState.originY + e.clientY - panState.startY\n applyTransform()\n}\n\nfunction onPointerEnd(e: PointerEvent) {\n if (!panState || panState.pointerId !== e.pointerId) return\n const el = stage.value\n if (el?.hasPointerCapture(e.pointerId)) {\n el.releasePointerCapture(e.pointerId)\n }\n panState = undefined\n isDragging.value = false\n}\n\nfunction onWheel(e: WheelEvent) {\n if (!(e.ctrlKey || e.metaKey)) return\n e.preventDefault()\n setScale(scale.value + (e.deltaY > 0 ? -ZOOM_STEP : ZOOM_STEP))\n}\n\nfunction onDblclick() {\n if (scale.value === 1) {\n setScale(2)\n } else {\n resetZoom()\n }\n}\n\nfunction onBackdropMousedown() {\n if (!modal) return\n if (closeOnClickBackdrop === false) return\n // 放大后空白区域是平移热区,不作为关闭入口\n if (scale.value > 1) return\n close()\n}\n\nfunction close() {\n if (!modal) return\n open.value = false\n emit('close')\n}\n\nfunction handleWindowKeydown(e: KeyboardEvent) {\n if (e.key !== 'Escape') return\n if (!modal || !open.value) return\n if (closeOnEsc === false) return\n e.stopPropagation()\n close()\n}\n\nlet revoke: (() => void) | undefined\n\nfunction load() {\n if (src === undefined || src === null) {\n revoke?.()\n revoke = undefined\n url.value = ''\n loading.value = false\n failed.value = false\n return\n }\n loading.value = true\n failed.value = false\n revoke?.()\n const r = toBlobUrl(src, mime)\n url.value = r.url\n revoke = r.revoke\n // 新图回到初始视图,并同步工具栏回显\n setScale(1)\n}\n\nfunction onImgError(e: Event) {\n loading.value = false\n failed.value = true\n emit('error', e)\n}\n\nwatch(\n () => src,\n () => load(),\n { immediate: true }\n)\n\n// lightbox 打开时:锁定 body 滚动 + 挂 Esc 监听\nlet previousBodyOverflow = ''\nlet isBodyLocked = false\n\nfunction lockBody() {\n if (isBodyLocked || typeof document === 'undefined') return\n previousBodyOverflow = document.body.style.overflow\n document.body.style.overflow = 'hidden'\n isBodyLocked = true\n}\n\nfunction unlockBody() {\n if (!isBodyLocked || typeof document === 'undefined') return\n document.body.style.overflow = previousBodyOverflow\n isBodyLocked = false\n}\n\nwatch(\n [() => modal, open],\n ([modalOpen, openNow], _, onCleanup) => {\n // 依赖重跑前与作用域销毁时统一解锁 + 摘除 keydown 监听\n onCleanup(() => {\n unlockBody()\n if (typeof window !== 'undefined') {\n window.removeEventListener('keydown', handleWindowKeydown, true)\n }\n })\n if (modalOpen && openNow) {\n lockBody()\n if (typeof window !== 'undefined') {\n window.addEventListener('keydown', handleWindowKeydown, true)\n }\n } else {\n unlockBody()\n }\n },\n { immediate: true }\n)\n\nonBeforeUnmount(() => {\n revoke?.()\n url.value = ''\n})\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+GA,MAAM,OAAO;EAEb,MAAM,MAAM,IAAI,iBAAiB;EACjC,MAAM,QAAQ,SAAS;EAEvB,MAAM,QAAQ,eAA+B,OAAO;EAEpD,MAAM,OAAOA,SAAoB,SAAC,MAAyB;EAE3D,MAAM,MAAM,WAAmB,EAAE;EACjC,MAAM,UAAU,IAAI,KAAK;EACzB,MAAM,SAAS,IAAI,KAAK;;EAGxB,MAAM,QAAQ,IAAI,CAAC;;EAEnB,MAAM,aAAa,IAAI,KAAK;EAE5B,MAAM,cAAc,eAAe,GAAG,KAAK,MAAM,MAAM,QAAQ,GAAG,EAAE,EAAE;EAGtE,IAAI;EAGJ,IAAI,UAAU;EACd,IAAI,UAAU;;EAGd,SAAS,iBAAiB;GACxB,MAAM,KAAK,MAAM;GACjB,IAAI,CAAC,IAAI;GACT,GAAG,MAAM,YAAY,eAAe,QAAQ,MAAM,QAAQ,eAAe,MAAM,MAAM;EACvF;EAEA,SAAS,SAAS,OAAe;GAC/B,MAAM,QAAQ,UAAU,KAAK;GAC7B,IAAI,MAAM,SAAS,GAAG;IAEpB,UAAU;IACV,UAAU;GACZ;GACA,eAAe;GACf,KAAK,eAAe,MAAM,KAAK;EACjC;EAEA,SAAS,SAAS;GAChB,SAAS,MAAM,QAAQ,SAAS;EAClC;EAEA,SAAS,UAAU;GACjB,SAAS,MAAM,QAAQ,SAAS;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ACpB,cAAW;MACX,OAAM;MACL,SAAO;KAER,GAAA,CAAAL,YAESK,MAAAM,WAAA,GAAA,EAFA,MAAM,GAAE,GAAA;MACf,SAAAT,cAAU,CAAVF,YAAUK,MAAA,MAAA,CAAA,CAAA,CAAA;;;KAGdC,mBAWS,UAAA;MAVN,OAAKF,eAAEC,MAAA,GAAA,CAAG,CAAC,EAAC,MAAA,CAAA;MACb,MAAK;MACJ,UAAU,MAAA,UAAK;MAChB,cAAW;MACX,OAAM;MACL,SAAO;KAER,GAAA,CAAAL,YAESK,MAAAM,WAAA,GAAA,EAFA,MAAM,GAAE,GAAA;MACf,SAAAT,cAAW,CAAXF,YAAWK,MAAA,OAAA,CAAA,CAAA,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
@charset "UTF-8";
|
|
2
|
+
/** flex布局 */
|
|
3
|
+
/**
|
|
4
|
+
* 设置css变量
|
|
5
|
+
* 参数1:变量前缀
|
|
6
|
+
* 参数2: 一个由值组成的列表或者由key, value组成的map
|
|
7
|
+
* css-var(height, (
|
|
8
|
+
* large: 40px
|
|
9
|
+
* default: 32px
|
|
10
|
+
* small: 24px
|
|
11
|
+
* ))
|
|
12
|
+
* 生成的css变量:
|
|
13
|
+
* --u-height-large: 40px;
|
|
14
|
+
* --u-height-default: 32px;
|
|
15
|
+
* --u-height-small: 24px;
|
|
16
|
+
*/
|
|
17
|
+
/** 暗色:`UITheme.render()` 按主题系列写入 html[data-theme] */
|
|
18
|
+
/**
|
|
19
|
+
* 图片预览 lightbox 样式
|
|
20
|
+
*
|
|
21
|
+
* modal(默认):Teleport 到 body 的全屏遮罩 + 关闭按钮 + 底部缩放工具;
|
|
22
|
+
* 非 modal(file-viewer 等宿主内嵌):根节点 display: contents 透传,预览面
|
|
23
|
+
* 绝对定位铺满宿主的定位容器,视觉规则与 file-viewer 画布一致。
|
|
24
|
+
*/
|
|
25
|
+
.u-image-previewer {
|
|
26
|
+
--u-image-previewer-paper: #fff;
|
|
27
|
+
}
|
|
28
|
+
.u-image-previewer:not(.is-modal) {
|
|
29
|
+
display: contents;
|
|
30
|
+
}
|
|
31
|
+
.u-image-previewer.is-modal {
|
|
32
|
+
position: fixed;
|
|
33
|
+
inset: 0;
|
|
34
|
+
z-index: 2000;
|
|
35
|
+
background: var(--u-bg-color-black-a-70);
|
|
36
|
+
backdrop-filter: blur(4px);
|
|
37
|
+
-webkit-backdrop-filter: blur(4px);
|
|
38
|
+
}
|
|
39
|
+
.u-image-previewer__stage {
|
|
40
|
+
position: absolute;
|
|
41
|
+
inset: 0;
|
|
42
|
+
display: flex;
|
|
43
|
+
align-items: center;
|
|
44
|
+
justify-content: center;
|
|
45
|
+
padding: clamp(20px, 3vw, 44px);
|
|
46
|
+
user-select: none;
|
|
47
|
+
transform-origin: center center;
|
|
48
|
+
transition: transform var(--u-transition-fast) var(--u-transition-ease);
|
|
49
|
+
will-change: transform;
|
|
50
|
+
}
|
|
51
|
+
.u-image-previewer__stage.is-pannable {
|
|
52
|
+
cursor: grab;
|
|
53
|
+
touch-action: none;
|
|
54
|
+
}
|
|
55
|
+
.u-image-previewer__stage.is-dragging {
|
|
56
|
+
cursor: grabbing;
|
|
57
|
+
transition: none;
|
|
58
|
+
}
|
|
59
|
+
.u-image-previewer__stage img {
|
|
60
|
+
max-width: 100%;
|
|
61
|
+
max-height: 100%;
|
|
62
|
+
object-fit: contain;
|
|
63
|
+
border-radius: 6px;
|
|
64
|
+
background: var(--u-image-previewer-paper);
|
|
65
|
+
}
|
|
66
|
+
.u-image-previewer__loading {
|
|
67
|
+
position: absolute;
|
|
68
|
+
inset: 0;
|
|
69
|
+
display: flex;
|
|
70
|
+
align-items: center;
|
|
71
|
+
justify-content: center;
|
|
72
|
+
color: var(--u-text-color-second);
|
|
73
|
+
background: var(--u-bg-color-bottom-a-70);
|
|
74
|
+
backdrop-filter: blur(4px);
|
|
75
|
+
-webkit-backdrop-filter: blur(4px);
|
|
76
|
+
font-size: 13px;
|
|
77
|
+
letter-spacing: 0.02em;
|
|
78
|
+
pointer-events: none;
|
|
79
|
+
}
|
|
80
|
+
.u-image-previewer.is-modal .u-image-previewer__loading {
|
|
81
|
+
color: var(--u-text-color-white);
|
|
82
|
+
background: transparent;
|
|
83
|
+
backdrop-filter: none;
|
|
84
|
+
-webkit-backdrop-filter: none;
|
|
85
|
+
}
|
|
86
|
+
.u-image-previewer__close {
|
|
87
|
+
position: absolute;
|
|
88
|
+
top: 18px;
|
|
89
|
+
right: 18px;
|
|
90
|
+
z-index: 1;
|
|
91
|
+
display: inline-flex;
|
|
92
|
+
align-items: center;
|
|
93
|
+
justify-content: center;
|
|
94
|
+
width: 36px;
|
|
95
|
+
height: 36px;
|
|
96
|
+
border: none;
|
|
97
|
+
border-radius: 10px;
|
|
98
|
+
color: var(--u-text-color-white);
|
|
99
|
+
background: var(--u-text-color-white-a-10);
|
|
100
|
+
cursor: pointer;
|
|
101
|
+
transition: background var(--u-transition-fast) var(--u-transition-ease), transform var(--u-transition-fast) var(--u-transition-ease);
|
|
102
|
+
}
|
|
103
|
+
.u-image-previewer__close:hover {
|
|
104
|
+
background: var(--u-text-color-white-a-22);
|
|
105
|
+
}
|
|
106
|
+
.u-image-previewer__close:active {
|
|
107
|
+
transform: translateY(1px);
|
|
108
|
+
}
|
|
109
|
+
.u-image-previewer__close:focus-visible {
|
|
110
|
+
box-shadow: var(--u-focus-ring);
|
|
111
|
+
}
|
|
112
|
+
.u-image-previewer__toolbar {
|
|
113
|
+
position: absolute;
|
|
114
|
+
left: 50%;
|
|
115
|
+
bottom: 26px;
|
|
116
|
+
z-index: 1;
|
|
117
|
+
display: inline-flex;
|
|
118
|
+
align-items: center;
|
|
119
|
+
gap: 2px;
|
|
120
|
+
height: 38px;
|
|
121
|
+
padding: 3px;
|
|
122
|
+
border: none;
|
|
123
|
+
border-radius: 10px;
|
|
124
|
+
color: var(--u-text-color-white);
|
|
125
|
+
background: var(--u-text-color-white-a-10);
|
|
126
|
+
backdrop-filter: blur(8px);
|
|
127
|
+
-webkit-backdrop-filter: blur(8px);
|
|
128
|
+
}
|
|
129
|
+
.u-image-previewer__tool {
|
|
130
|
+
display: inline-flex;
|
|
131
|
+
align-items: center;
|
|
132
|
+
justify-content: center;
|
|
133
|
+
width: 32px;
|
|
134
|
+
height: 32px;
|
|
135
|
+
border: none;
|
|
136
|
+
border-radius: 7px;
|
|
137
|
+
color: inherit;
|
|
138
|
+
background: transparent;
|
|
139
|
+
cursor: pointer;
|
|
140
|
+
transition: background var(--u-transition-fast) var(--u-transition-ease);
|
|
141
|
+
}
|
|
142
|
+
.u-image-previewer__tool:not(:disabled):hover {
|
|
143
|
+
background: var(--u-text-color-white-a-22);
|
|
144
|
+
}
|
|
145
|
+
.u-image-previewer__tool:disabled {
|
|
146
|
+
opacity: 0.38;
|
|
147
|
+
cursor: not-allowed;
|
|
148
|
+
}
|
|
149
|
+
.u-image-previewer__tool:focus-visible {
|
|
150
|
+
box-shadow: var(--u-focus-ring);
|
|
151
|
+
}
|
|
152
|
+
.u-image-previewer__zoom-value {
|
|
153
|
+
min-width: 48px;
|
|
154
|
+
color: var(--u-text-color-white);
|
|
155
|
+
font-size: 12px;
|
|
156
|
+
font-variant-numeric: tabular-nums;
|
|
157
|
+
text-align: center;
|
|
158
|
+
user-select: none;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.u-image-previewer-fade-enter-active,
|
|
162
|
+
.u-image-previewer-fade-leave-active {
|
|
163
|
+
transition: opacity var(--u-transition-normal) var(--u-transition-ease);
|
|
164
|
+
will-change: opacity;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.u-image-previewer-fade-enter-from,
|
|
168
|
+
.u-image-previewer-fade-leave-to {
|
|
169
|
+
opacity: 0;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.u-image-previewer-fade-leave-active {
|
|
173
|
+
pointer-events: none;
|
|
174
|
+
}
|
|
@@ -90,24 +90,26 @@ import _sfc_main$84 from "./float-button/float-button.js";
|
|
|
90
90
|
import _sfc_main$85 from "./badge/badge.js";
|
|
91
91
|
import _sfc_main$86 from "./segment/segment.js";
|
|
92
92
|
import _sfc_main$87 from "./image-cropper/image-cropper.js";
|
|
93
|
-
import _sfc_main$88 from "./
|
|
94
|
-
import _sfc_main$89 from "./
|
|
95
|
-
import _sfc_main$90 from "./anchor/anchor
|
|
96
|
-
import _sfc_main$91 from "./
|
|
97
|
-
import _sfc_main$92 from "./avatar/avatar
|
|
98
|
-
import _sfc_main$93 from "./
|
|
99
|
-
import _sfc_main$94 from "./
|
|
100
|
-
import _sfc_main$95 from "./
|
|
101
|
-
import _sfc_main$96 from "./
|
|
102
|
-
import _sfc_main$97 from "./
|
|
103
|
-
import _sfc_main$98 from "./
|
|
104
|
-
import _sfc_main$99 from "./
|
|
105
|
-
import _sfc_main$100 from "./
|
|
106
|
-
import _sfc_main$101 from "./descriptions/descriptions.js";
|
|
107
|
-
import _sfc_main$102 from "./
|
|
108
|
-
import _sfc_main$103 from "./timeline/timeline
|
|
109
|
-
import _sfc_main$104 from "./
|
|
110
|
-
import _sfc_main$105 from "./carousel/carousel
|
|
93
|
+
import _sfc_main$88 from "./image-previewer/image-previewer.js";
|
|
94
|
+
import _sfc_main$89 from "./kanban/kanban.js";
|
|
95
|
+
import _sfc_main$90 from "./anchor/anchor.js";
|
|
96
|
+
import _sfc_main$91 from "./anchor/anchor-item.js";
|
|
97
|
+
import _sfc_main$92 from "./avatar/avatar.js";
|
|
98
|
+
import _sfc_main$93 from "./avatar/avatar-group.js";
|
|
99
|
+
import _sfc_main$94 from "./back-top/back-top.js";
|
|
100
|
+
import _sfc_main$95 from "./alert/alert.js";
|
|
101
|
+
import _sfc_main$96 from "./rate/rate.js";
|
|
102
|
+
import _sfc_main$97 from "./divider/divider.js";
|
|
103
|
+
import _sfc_main$98 from "./space/space.js";
|
|
104
|
+
import _sfc_main$99 from "./skeleton/skeleton.js";
|
|
105
|
+
import _sfc_main$100 from "./time-picker/time-picker.js";
|
|
106
|
+
import _sfc_main$101 from "./descriptions/descriptions-item.js";
|
|
107
|
+
import _sfc_main$102 from "./descriptions/descriptions.js";
|
|
108
|
+
import _sfc_main$103 from "./timeline/timeline.js";
|
|
109
|
+
import _sfc_main$104 from "./timeline/timeline-item.js";
|
|
110
|
+
import _sfc_main$105 from "./carousel/carousel.js";
|
|
111
|
+
import _sfc_main$106 from "./carousel/carousel-item.js";
|
|
112
|
+
import _sfc_main$107 from "./ai-button/ai-button.js";
|
|
111
113
|
import { EvaluateOptions, createEmptyGroup, createEmptyLeaf, evaluate } from "./condition-editor/core/evaluator.js";
|
|
112
114
|
import "./condition-editor/index.js";
|
|
113
115
|
import { messageConfirm } from "./message-confirm/message-confirm.js";
|
|
@@ -127,4 +129,4 @@ import { defineBatchEditColumns } from "./batch-edit/helper.js";
|
|
|
127
129
|
import "./batch-edit/index.js";
|
|
128
130
|
import { defineTableColumns } from "./table/use-columns.js";
|
|
129
131
|
import "./table/index.js";
|
|
130
|
-
export { type EvaluateOptions as ConditionEvaluateOptions, ContextmenuPanelDIKey, ContextmenuRootDIKey, _sfc_main$57 as UAction, action_group_default as UActionGroup, _sfc_main$
|
|
132
|
+
export { type EvaluateOptions as ConditionEvaluateOptions, ContextmenuPanelDIKey, ContextmenuRootDIKey, _sfc_main$57 as UAction, action_group_default as UActionGroup, _sfc_main$107 as UAiButton, _sfc_main$95 as UAlert, _sfc_main$90 as UAnchor, _sfc_main$91 as UAnchorItem, _sfc_main$31 as UAutoComplete, _sfc_main$92 as UAvatar, _sfc_main$93 as UAvatarGroup, _sfc_main$94 as UBackTop, _sfc_main$85 as UBadge, _sfc_main$58 as UBatchEdit, _sfc_main$82 as UBreadcrumb, _sfc_main$18 as UButton, _sfc_main$19 as UButtonGroup, _sfc_main$21 as UCalendar, _sfc_main$23 as UCard, _sfc_main$27 as UCardAction, _sfc_main$26 as UCardContent, _sfc_main$25 as UCardCover, _sfc_main$24 as UCardHeader, _sfc_main$105 as UCarousel, _sfc_main$106 as UCarouselItem, _sfc_main$61 as UCascade, _sfc_main$48 as UCheckTag, _sfc_main$11 as UCheckbox, _sfc_main$36 as UCheckboxButton, _sfc_main$79 as UCheckboxGroup, _sfc_main$14 as UCodeEditor, _sfc_main$44 as UCollapse, _sfc_main$45 as UCollapseItem, _sfc_main$7 as UConditionEditor, _sfc_main$49 as UContextmenu, _sfc_main$28 as UDatePanel, _sfc_main$63 as UDatePicker, _sfc_main$29 as UDateRangePicker, _sfc_main$102 as UDescriptions, _sfc_main$101 as UDescriptionsItem, _sfc_main$52 as UDialog, _sfc_main$97 as UDivider, _sfc_main$15 as UDrawer, _sfc_main$4 as UDropdown, _sfc_main$74 as UDualNav, _sfc_main$1 as UEmpty, _sfc_main$53 as UExpressionEditor, _sfc_main$41 as UFilePicker, _sfc_main$80 as UFileViewer, _sfc_main$84 as UFloatButton, form_default as UForm, form_item_default as UFormItem, _sfc_main$39 as UGanttChart, _sfc_main$16 as UGrid, _sfc_main$76 as UGridInput, _sfc_main$17 as UGridItem, _sfc_main$67 as UGroupInput, _sfc_main$75 as UGroupNav, _sfc_main as UIcon, _sfc_main$87 as UImageCropper, _sfc_main$88 as UImagePreviewer, input_default as UInput, _sfc_main$89 as UKanban, _sfc_main$55 as UKbd, _sfc_main$34 as ULayout, _sfc_main$68 as UList, _sfc_main$69 as UListItem, _sfc_main$5 as ULoading, _sfc_main$40 as UMessage, _sfc_main$20 as UMessageConfirm, _sfc_main$37 as UMultiSelect, _sfc_main$66 as UMultiTreeSelect, _sfc_main$73 as UNav, _sfc_main$71 as UNavItem, _sfc_main$72 as UNavSub, NodeRender as UNodeRender, _sfc_main$33 as UNotification, _sfc_main$51 as UNumber, _sfc_main$42 as UNumberInput, _sfc_main$43 as UNumberRangeInput, _sfc_main$83 as UPaginator, _sfc_main$64 as UPalette, _sfc_main$50 as UPasswordInput, _sfc_main$56 as UPopConfirm, _sfc_main$32 as UProgress, _sfc_main$30 as UProgressNodes, _sfc_main$22 as URadio, _sfc_main$78 as URadioGroup, _sfc_main$96 as URate, _sfc_main$70 as URichTextEditor, _sfc_main$2 as UScroll, _sfc_main$86 as USegment, _sfc_main$6 as USelect, _sfc_main$99 as USkeleton, _sfc_main$38 as USlider, _sfc_main$98 as USpace, _sfc_main$62 as USteps, _sfc_main$77 as USwitch, _sfc_main$46 as UTable, _sfc_main$47 as UTableEditor, _sfc_main$10 as UTabs, _sfc_main$8 as UTabsHorizontal, _sfc_main$9 as UTabsVertical, _sfc_main$35 as UTag, _sfc_main$81 as UText, _sfc_main$60 as UTextarea, _sfc_main$65 as UTheme, _sfc_main$100 as UTimePicker, _sfc_main$103 as UTimeline, _sfc_main$104 as UTimelineItem, _sfc_main$3 as UTip, _sfc_main$59 as UTransfer, _sfc_main$12 as UTree, _sfc_main$13 as UTreeSelect, _sfc_main$54 as UWatermark, contextmenu, createEmptyGroup, createEmptyLeaf, defineBatchEditColumns, defineTableColumns, evaluate as evaluateConditionExpression, message, messageConfirm, notification, vLoading };
|