zartui 3.1.92 → 3.1.94
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/es/composables/use-media-download.d.ts +20 -0
- package/es/composables/use-media-download.mjs +111 -0
- package/es/drawer-select/DrawerSelect.mjs +13 -30
- package/es/drawer-select/index.css +1 -1
- package/es/image-preview/ImagePreview.d.ts +2 -5
- package/es/image-preview/ImagePreview.mjs +32 -79
- package/es/image-preview/function-call.mjs +4 -1
- package/es/image-preview/index.css +1 -1
- package/es/image-preview/index.d.ts +1 -2
- package/es/image-preview/style/index.mjs +2 -0
- package/es/image-preview/types.d.ts +3 -1
- package/es/index.d.ts +1 -1
- package/es/index.mjs +1 -1
- package/es/media-picker/MediaPicker.d.ts +1 -1
- package/es/media-picker/MediaPicker.mjs +54 -36
- package/es/media-picker/index.d.ts +2 -2
- package/es/media-picker/style/index.mjs +3 -1
- package/es/media-player/MediaPlayer.d.ts +21 -0
- package/es/media-player/MediaPlayer.mjs +25 -2
- package/es/media-player/index.css +1 -1
- package/es/media-player/index.d.ts +14 -0
- package/es/media-player/style/index.mjs +4 -0
- package/es/photo-picker/index.d.ts +2 -2
- package/es/photo-picker/style/index.mjs +2 -0
- package/es/uploader/style/index.mjs +2 -0
- package/lib/composables/use-media-download.d.ts +20 -0
- package/lib/composables/use-media-download.js +138 -0
- package/lib/drawer-select/DrawerSelect.js +12 -29
- package/lib/drawer-select/index.css +1 -1
- package/lib/image-preview/ImagePreview.d.ts +2 -5
- package/lib/image-preview/ImagePreview.js +32 -79
- package/lib/image-preview/function-call.js +4 -1
- package/lib/image-preview/index.css +1 -1
- package/lib/image-preview/index.d.ts +1 -2
- package/lib/image-preview/style/index.js +2 -0
- package/lib/image-preview/types.d.ts +3 -1
- package/lib/index.css +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/media-picker/MediaPicker.d.ts +1 -1
- package/lib/media-picker/MediaPicker.js +51 -35
- package/lib/media-picker/index.d.ts +2 -2
- package/lib/media-picker/style/index.js +3 -1
- package/lib/media-player/MediaPlayer.d.ts +21 -0
- package/lib/media-player/MediaPlayer.js +25 -2
- package/lib/media-player/index.css +1 -1
- package/lib/media-player/index.d.ts +14 -0
- package/lib/media-player/style/index.js +4 -0
- package/lib/photo-picker/index.d.ts +2 -2
- package/lib/photo-picker/style/index.js +2 -0
- package/lib/uploader/style/index.js +2 -0
- package/lib/web-types.json +1 -1
- package/lib/zartui.cjs.js +208 -134
- package/lib/zartui.es.js +208 -134
- package/lib/zartui.js +216 -142
- package/lib/zartui.min.js +2 -2
- package/package.json +5 -5
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type DownloadActionParams = {
|
|
2
|
+
index: number;
|
|
3
|
+
url?: string;
|
|
4
|
+
title?: string;
|
|
5
|
+
fileName?: string;
|
|
6
|
+
};
|
|
7
|
+
export type FileDownloadOptions = {
|
|
8
|
+
url: string;
|
|
9
|
+
fileName?: string;
|
|
10
|
+
title?: string;
|
|
11
|
+
index?: number;
|
|
12
|
+
};
|
|
13
|
+
export declare function useMediaDownload(props: {
|
|
14
|
+
showDownload: boolean;
|
|
15
|
+
downloadAction?: (params: DownloadActionParams) => boolean;
|
|
16
|
+
}): {
|
|
17
|
+
downloading: import("vue").Ref<boolean, boolean>;
|
|
18
|
+
download: (params: DownloadActionParams, confirm?: boolean) => Promise<void>;
|
|
19
|
+
downloadFile: (options: FileDownloadOptions) => Promise<void>;
|
|
20
|
+
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __async = (__this, __arguments, generator) => {
|
|
21
|
+
return new Promise((resolve, reject) => {
|
|
22
|
+
var fulfilled = (value) => {
|
|
23
|
+
try {
|
|
24
|
+
step(generator.next(value));
|
|
25
|
+
} catch (e) {
|
|
26
|
+
reject(e);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
var rejected = (value) => {
|
|
30
|
+
try {
|
|
31
|
+
step(generator.throw(value));
|
|
32
|
+
} catch (e) {
|
|
33
|
+
reject(e);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
37
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
import { ref } from "vue";
|
|
41
|
+
import { showConfirmDialog } from "../dialog/index.mjs";
|
|
42
|
+
import { closeToast, showFailToast, showLoadingToast, showSuccessToast } from "../toast/index.mjs";
|
|
43
|
+
function useMediaDownload(props) {
|
|
44
|
+
const downloading = ref(false);
|
|
45
|
+
const downloadInBrowser = (params) => {
|
|
46
|
+
const link = document.createElement("a");
|
|
47
|
+
link.href = params.url;
|
|
48
|
+
link.download = params.fileName || "";
|
|
49
|
+
document.body.appendChild(link);
|
|
50
|
+
link.click();
|
|
51
|
+
link.remove();
|
|
52
|
+
};
|
|
53
|
+
const download = (params, confirm = false) => __async(this, null, function* () {
|
|
54
|
+
var _a, _b, _c;
|
|
55
|
+
if (!props.showDownload || downloading.value || !params.url || params.url.startsWith("data:")) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
downloading.value = true;
|
|
59
|
+
try {
|
|
60
|
+
if (confirm) {
|
|
61
|
+
try {
|
|
62
|
+
yield showConfirmDialog({ message: "\u9644\u4EF6\u683C\u5F0F\u6682\u4E0D\u652F\u6301\u9884\u89C8\uFF0C\u662F\u5426\u4E0B\u8F7D\u539F\u6587\u4EF6" });
|
|
63
|
+
} catch (action) {
|
|
64
|
+
if (action !== "cancel") {
|
|
65
|
+
throw action;
|
|
66
|
+
}
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (!props.showDownload || ((_a = props.downloadAction) == null ? void 0 : _a.call(props, params))) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
let file;
|
|
74
|
+
try {
|
|
75
|
+
const sdk = yield import("@egova/universal-js-sdk");
|
|
76
|
+
file = (_b = sdk.getJSI()) == null ? void 0 : _b.file;
|
|
77
|
+
} catch (e) {
|
|
78
|
+
downloadInBrowser(params);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (!(file == null ? void 0 : file.download)) {
|
|
82
|
+
downloadInBrowser(params);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
showLoadingToast({ message: "\u4E0B\u8F7D\u4E2D...", forbidClick: true, duration: 0 });
|
|
86
|
+
try {
|
|
87
|
+
const result = yield file.download({ url: params.url });
|
|
88
|
+
const displayPath = (_c = result == null ? void 0 : result.tempFilePath) == null ? void 0 : _c.replace(/^\/storage\/emulated\/0\//, "");
|
|
89
|
+
closeToast();
|
|
90
|
+
showSuccessToast({
|
|
91
|
+
message: displayPath ? `\u4E0B\u8F7D\u6210\u529F
|
|
92
|
+
\u4FDD\u5B58\u8DEF\u5F84\uFF1A${displayPath}` : "\u4E0B\u8F7D\u6210\u529F",
|
|
93
|
+
duration: 5e3
|
|
94
|
+
});
|
|
95
|
+
} catch (e) {
|
|
96
|
+
closeToast();
|
|
97
|
+
showFailToast("\u4E0B\u8F7D\u5931\u8D25");
|
|
98
|
+
}
|
|
99
|
+
} finally {
|
|
100
|
+
downloading.value = false;
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
const downloadFile = (options) => {
|
|
104
|
+
var _a;
|
|
105
|
+
return download(__spreadProps(__spreadValues({}, options), { index: (_a = options.index) != null ? _a : -1 }), true);
|
|
106
|
+
};
|
|
107
|
+
return { downloading, download, downloadFile };
|
|
108
|
+
}
|
|
109
|
+
export {
|
|
110
|
+
useMediaDownload
|
|
111
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { computed, defineComponent, nextTick,
|
|
1
|
+
import { computed, defineComponent, nextTick, onMounted, ref, watch, createVNode as _createVNode, createTextVNode as _createTextVNode, Fragment as _Fragment, vShow as _vShow, withDirectives as _withDirectives } from "vue";
|
|
2
2
|
import { useEventListener, useRect } from "@zartui/use";
|
|
3
3
|
import { createNamespace, makeArrayProp, makeStringProp } from "../utils/index.mjs";
|
|
4
4
|
import ZtSearch from "../search/index.mjs";
|
|
@@ -49,7 +49,6 @@ var stdin_default = defineComponent({
|
|
|
49
49
|
const commonTypesListRef = ref();
|
|
50
50
|
const showLeftCommonTypesMask = ref(false);
|
|
51
51
|
const showRightCommonTypesMask = ref(false);
|
|
52
|
-
let commonTypesResizeObserver;
|
|
53
52
|
const defaultTreeNode = ref(props.treeData);
|
|
54
53
|
const fields = computed(() => assignDefaultFields(props.treeFieldName));
|
|
55
54
|
const visibleCommonTypeList = computed(() => {
|
|
@@ -64,35 +63,25 @@ var stdin_default = defineComponent({
|
|
|
64
63
|
children,
|
|
65
64
|
text: key
|
|
66
65
|
} = fields.value;
|
|
66
|
+
const syncSelectCommonId = (node) => {
|
|
67
|
+
const selectedId = node == null ? void 0 : node[value];
|
|
68
|
+
selectCommonId.value = typeof selectedId === "string" || typeof selectedId === "number" ? selectedId : -1;
|
|
69
|
+
};
|
|
70
|
+
syncSelectCommonId(props.defaultSelectNode);
|
|
71
|
+
watch(() => props.defaultSelectNode, (node) => {
|
|
72
|
+
selectNode.value = node;
|
|
73
|
+
syncSelectCommonId(node);
|
|
74
|
+
});
|
|
67
75
|
const updateCommonTypesMask = () => {
|
|
68
76
|
const list = commonTypesListRef.value;
|
|
69
|
-
if (!list)
|
|
70
|
-
showLeftCommonTypesMask.value = false;
|
|
71
|
-
showRightCommonTypesMask.value = false;
|
|
77
|
+
if (!list)
|
|
72
78
|
return;
|
|
73
|
-
}
|
|
74
|
-
const remainingScrollWidth = list.scrollWidth - list.clientWidth - list.scrollLeft;
|
|
75
79
|
showLeftCommonTypesMask.value = list.scrollLeft > 0;
|
|
76
|
-
showRightCommonTypesMask.value =
|
|
80
|
+
showRightCommonTypesMask.value = list.scrollLeft + list.clientWidth < list.scrollWidth;
|
|
77
81
|
};
|
|
78
82
|
const onCommonTypesScroll = () => {
|
|
79
83
|
updateCommonTypesMask();
|
|
80
84
|
};
|
|
81
|
-
const observeCommonTypesList = () => {
|
|
82
|
-
commonTypesResizeObserver == null ? void 0 : commonTypesResizeObserver.disconnect();
|
|
83
|
-
const list = commonTypesListRef.value;
|
|
84
|
-
if (!list || typeof ResizeObserver === "undefined") {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
commonTypesResizeObserver = new ResizeObserver(updateCommonTypesMask);
|
|
88
|
-
commonTypesResizeObserver.observe(list);
|
|
89
|
-
};
|
|
90
|
-
const updateCommonTypesLayout = () => {
|
|
91
|
-
nextTick(() => {
|
|
92
|
-
observeCommonTypesList();
|
|
93
|
-
updateCommonTypesMask();
|
|
94
|
-
});
|
|
95
|
-
};
|
|
96
85
|
const allData = {
|
|
97
86
|
[value]: -1,
|
|
98
87
|
[key]: "\u5168\u90E8",
|
|
@@ -169,13 +158,7 @@ var stdin_default = defineComponent({
|
|
|
169
158
|
};
|
|
170
159
|
flatData(props.treeData);
|
|
171
160
|
updateOffset();
|
|
172
|
-
|
|
173
|
-
});
|
|
174
|
-
watch(visibleCommonTypeList, updateCommonTypesLayout, {
|
|
175
|
-
flush: "post"
|
|
176
|
-
});
|
|
177
|
-
onBeforeUnmount(() => {
|
|
178
|
-
commonTypesResizeObserver == null ? void 0 : commonTypesResizeObserver.disconnect();
|
|
161
|
+
nextTick(updateCommonTypesMask);
|
|
179
162
|
});
|
|
180
163
|
const isEmpty = (item) => !item[children] || item[children].length === 0;
|
|
181
164
|
const syncExpandNodeByParent = (item) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
:root{--zt-drawer-select-background: #ebf2f5}.zt-drawer-select{height:100%;width:100%;display:flex;flex-direction:column;background:var(--zt-background)}.zt-drawer-select__search{padding:var(--zt-padding-xs) 0}.zt-drawer-select__search--item{padding:var(--zt-padding-sm) 0 var(--zt-padding-sm) var(--zt-padding-md)}.zt-drawer-select__search--item:after{left:calc(-50% + 22px)}.zt-drawer-select__search--header{font-size:var(--zt-font-size-lg);font-weight:700;color:var(--zt-text-color);margin-bottom:4px}.zt-drawer-select__search--name{font-size:var(--zt-font-size-md);color:var(--zt-text-color-2)}.zt-drawer-select__wrap{position:fixed;right:0;left:0;bottom:0;z-index:999;overflow:hidden}.zt-drawer-select__popup{position:absolute;max-height:350px;border-radius:0 0 16px 16px}.zt-drawer-select__empty{font-size:var(--zt-font-size-md);color:var(--zt-gray-a4);text-align:center;padding:var(--zt-padding-lg) 0}.zt-drawer-select__history--title{height:44px;line-height:44px;font-weight:700;padding-left:var(--zt-padding-sm);color:var(--zt-text-color)}.zt-drawer-select__history--content{padding:var(--zt-padding-sm) var(--zt-padding-md) var(--zt-padding-xs)}.zt-drawer-select__history--content .zt-tag{line-height:28px;border-radius:14px;font-size:var(--zt-font-size-md);margin-right:4px;margin-bottom:8px}.zt-drawer-select__history--clear{display:flex;align-items:center;justify-content:center;height:44px;color:var(--zt-gray-a6);text-align:center;font-size:var(--zt-font-size-md)}.zt-drawer-select__name{position:relative;height:44px;line-height:44px;font-size:var(--zt-font-size-lg);color:var(--zt-text-color);font-weight:700;padding-left:var(--zt-padding-md)}.zt-drawer-select__name:before{content:"";position:absolute;width:4px;height:16px;top:14px;left:0;background:var(--zt-primary-color)}.zt-drawer-select__common-types{width:100%;background:var(--zt-white)}.zt-drawer-select__common-types--head{display:flex;align-items:center;min-height:44px;padding-left:var(--zt-padding-md);font-size:var(--zt-font-size-md);color:var(--zt-text-color)}.zt-drawer-select__common-types--label{flex-shrink:0;font-weight:700;padding-right:4px}.zt-drawer-select__common-types--mask{position:relative;flex:1;min-width:0;background:var(--zt-white)}.zt-drawer-select__common-types--mask:before,.zt-drawer-select__common-types--mask:after{content:"";position:absolute;top:0;bottom:0;width:32px;pointer-events:none;z-index:3;
|
|
1
|
+
:root{--zt-drawer-select-background: #ebf2f5}.zt-drawer-select{height:100%;width:100%;display:flex;flex-direction:column;background:var(--zt-background)}.zt-drawer-select__search{padding:var(--zt-padding-xs) 0}.zt-drawer-select__search--item{padding:var(--zt-padding-sm) 0 var(--zt-padding-sm) var(--zt-padding-md)}.zt-drawer-select__search--item:after{left:calc(-50% + 22px)}.zt-drawer-select__search--header{font-size:var(--zt-font-size-lg);font-weight:700;color:var(--zt-text-color);margin-bottom:4px}.zt-drawer-select__search--name{font-size:var(--zt-font-size-md);color:var(--zt-text-color-2)}.zt-drawer-select__wrap{position:fixed;right:0;left:0;bottom:0;z-index:999;overflow:hidden}.zt-drawer-select__popup{position:absolute;max-height:350px;border-radius:0 0 16px 16px}.zt-drawer-select__empty{font-size:var(--zt-font-size-md);color:var(--zt-gray-a4);text-align:center;padding:var(--zt-padding-lg) 0}.zt-drawer-select__history--title{height:44px;line-height:44px;font-weight:700;padding-left:var(--zt-padding-sm);color:var(--zt-text-color)}.zt-drawer-select__history--content{padding:var(--zt-padding-sm) var(--zt-padding-md) var(--zt-padding-xs)}.zt-drawer-select__history--content .zt-tag{line-height:28px;border-radius:14px;font-size:var(--zt-font-size-md);margin-right:4px;margin-bottom:8px}.zt-drawer-select__history--clear{display:flex;align-items:center;justify-content:center;height:44px;color:var(--zt-gray-a6);text-align:center;font-size:var(--zt-font-size-md)}.zt-drawer-select__name{position:relative;height:44px;line-height:44px;font-size:var(--zt-font-size-lg);color:var(--zt-text-color);font-weight:700;padding-left:var(--zt-padding-md)}.zt-drawer-select__name:before{content:"";position:absolute;width:4px;height:16px;top:14px;left:0;background:var(--zt-primary-color)}.zt-drawer-select__common-types{width:100%;background:var(--zt-white)}.zt-drawer-select__common-types--head{display:flex;align-items:center;min-height:44px;padding-left:var(--zt-padding-md);font-size:var(--zt-font-size-md);color:var(--zt-text-color)}.zt-drawer-select__common-types--label{flex-shrink:0;font-weight:700;padding-right:4px}.zt-drawer-select__common-types--mask{position:relative;flex:1;min-width:0;background:var(--zt-white)}.zt-drawer-select__common-types--mask:before,.zt-drawer-select__common-types--mask:after{content:"";position:absolute;top:0;bottom:0;width:32px;pointer-events:none;z-index:3;transition:opacity .2s}.zt-drawer-select__common-types--mask:before{left:-1px;opacity:0;background-image:linear-gradient(270deg,rgba(255,255,255,0) 0%,var(--zt-white) 100%)}.zt-drawer-select__common-types--mask:after{right:-1px;opacity:0;background-image:linear-gradient(90deg,rgba(255,255,255,0) 2.78%,var(--zt-white) 100%)}.zt-drawer-select__common-types--mask--left-mask:before,.zt-drawer-select__common-types--mask--right-mask:after{opacity:1}.zt-drawer-select__common-types--viewport{min-width:0;overflow:hidden}.zt-drawer-select__common-types--list{display:flex;align-items:center;gap:4px;padding:8px 16px;overflow-x:auto;overflow-y:hidden;white-space:nowrap;scrollbar-width:none}.zt-drawer-select__common-types--list::-webkit-scrollbar{display:none}.zt-drawer-select__common-types--icon{display:flex;align-items:center;justify-content:center;width:56px;height:44px;flex-shrink:0}.zt-drawer-select__common-types--empty{flex:1;min-width:0;padding-left:8px;color:var(--zt-text-color-2);opacity:.2}.zt-drawer-select__common-types--btn{flex-shrink:0;min-width:-moz-fit-content;min-width:fit-content;border-radius:15px;opacity:1;padding-top:15px;padding-bottom:15px}.zt-drawer-select__common-types--panel{padding:0 var(--zt-padding-md) 8px;background:var(--zt-white)}.zt-drawer-select__common-types--panel-list{display:flex;flex-wrap:wrap;gap:8px 4px;padding-bottom:8px}.zt-drawer-select__common-types--clear{display:flex;align-items:center;justify-content:center;height:44px;color:var(--zt-text-color-2);opacity:.6;font-size:var(--zt-font-size-md)}.zt-drawer-select__common-types--clear-text{margin-left:4px}.zt-drawer-select__hot-types{width:100%;padding:0 16px 4px;margin-top:8px;box-sizing:border-box;background:var(--zt-white)}.zt-drawer-select__hot-types--label{height:44px;line-height:44px;font-size:var(--zt-font-size-md);font-weight:700;color:var(--zt-text-color)}.zt-drawer-select__hot-types--list{display:flex;flex-wrap:wrap;gap:8px 4px;width:100%;max-height:108px;overflow-x:hidden;overflow-y:auto;padding-bottom:8px}.zt-drawer-select__tree{display:flex;flex:1;min-height:0}.zt-drawer-select__tree-left{width:120px}.zt-drawer-select__tree-right{flex:1;min-width:0;min-height:0;display:flex;flex-direction:column;background:var(--zt-white)}.zt-drawer-select__label{display:flex;align-items:center;line-height:28px;color:var(--zt-text-color);padding:var(--zt-padding-xs) 0 var(--zt-padding-xs) var(--zt-padding-base);font-size:var(--zt-font-size-md)}.zt-drawer-select__label--second{background:var(--zt-drawer-select-background);padding-left:var(--zt-padding-sm)}.zt-drawer-select__label--placeholder{display:flex;align-items:center;width:24px}.zt-drawer-select__label--text{display:flex;align-items:center;min-height:28px}.zt-drawer-select__label--icon--active{transform:rotate(90deg);color:var(--zt-primary-color)}.zt-drawer-select__label--active{color:var(--zt-primary-color);background:var(--zt-white)}.zt-drawer-select__title{display:flex;align-items:center;line-height:28px;font-size:var(--zt-font-size-md);color:var(--zt-text-color);font-weight:700;padding:var(--zt-padding-xs) var(--zt-padding-md)}.zt-drawer-select__content{flex:1;min-height:0;overflow-y:scroll}.zt-drawer-select__item--placeholder{width:30px}.zt-drawer-select__item--header{display:flex;min-height:44px;font-size:var(--zt-font-size-md);color:var(--zt-text-color);padding-left:4px}.zt-drawer-select__item--icon{display:flex;align-items:center;width:24px;margin-right:6px;height:100%}.zt-drawer-select__item--icon--active{transform:rotate(90deg);color:var(--zt-primary-color)}.zt-drawer-select__item--label{flex:1;display:flex;align-items:center;line-height:28px;padding:var(--zt-padding-xs) var(--zt-padding-md) var(--zt-padding-xs) 0}.zt-drawer-select__item--label--active{color:var(--zt-primary-color)}.zt-drawer-select__item--child{padding-left:var(--zt-padding-md)}.zt-drawer-select .zt-dialog__confirm{background:var(--zt-dialog-cancel-button-background-color);border:var(--zt-button-border-width) solid #ff5023;color:#ff5023}
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import type { PropType, CSSProperties, ExtractPropTypes } from 'vue';
|
|
2
2
|
import { Interceptor } from '../utils';
|
|
3
3
|
import { PopupCloseIconPosition } from '../popup';
|
|
4
|
+
import type { DownloadActionParams } from '../composables/use-media-download';
|
|
4
5
|
import { ImageItem } from './types';
|
|
5
|
-
export type DownloadActionParams
|
|
6
|
-
index: number;
|
|
7
|
-
url?: string;
|
|
8
|
-
title?: string;
|
|
9
|
-
};
|
|
6
|
+
export type { DownloadActionParams, FileDownloadOptions } from '../composables/use-media-download';
|
|
10
7
|
export declare const imagePreviewProps: {
|
|
11
8
|
show: BooleanConstructor;
|
|
12
9
|
loop: {
|
|
@@ -1,23 +1,3 @@
|
|
|
1
|
-
var __async = (__this, __arguments, generator) => {
|
|
2
|
-
return new Promise((resolve, reject) => {
|
|
3
|
-
var fulfilled = (value) => {
|
|
4
|
-
try {
|
|
5
|
-
step(generator.next(value));
|
|
6
|
-
} catch (e) {
|
|
7
|
-
reject(e);
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
var rejected = (value) => {
|
|
11
|
-
try {
|
|
12
|
-
step(generator.throw(value));
|
|
13
|
-
} catch (e) {
|
|
14
|
-
reject(e);
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
1
|
import { ref, watch, nextTick, reactive, onMounted, defineComponent, createVNode as _createVNode, mergeProps as _mergeProps } from "vue";
|
|
22
2
|
import { pick, truthProp, unknownProp, windowWidth, windowHeight, makeArrayProp, makeStringProp, makeNumericProp, callInterceptor, createNamespace, HAPTICS_FEEDBACK } from "../utils/index.mjs";
|
|
23
3
|
import { useRect } from "@zartui/use";
|
|
@@ -26,8 +6,7 @@ import { Icon } from "../icon/index.mjs";
|
|
|
26
6
|
import { Swipe } from "../swipe/index.mjs";
|
|
27
7
|
import { Popup } from "../popup/index.mjs";
|
|
28
8
|
import ImagePreviewItem from "./ImagePreviewItem.mjs";
|
|
29
|
-
import {
|
|
30
|
-
import { closeToast, showFailToast, showLoadingToast, showSuccessToast } from "../toast/index.mjs";
|
|
9
|
+
import { useMediaDownload } from "../composables/use-media-download.mjs";
|
|
31
10
|
const [name, bem] = createNamespace("image-preview");
|
|
32
11
|
const popupProps = ["show", "transition", "overlayStyle", "closeOnPopstate", "teleport"];
|
|
33
12
|
const imagePreviewProps = {
|
|
@@ -64,8 +43,13 @@ var stdin_default = defineComponent({
|
|
|
64
43
|
slots
|
|
65
44
|
}) {
|
|
66
45
|
const swipeRef = ref();
|
|
46
|
+
const {
|
|
47
|
+
downloading,
|
|
48
|
+
download,
|
|
49
|
+
downloadFile
|
|
50
|
+
} = useMediaDownload(props);
|
|
67
51
|
const state = reactive({
|
|
68
|
-
active:
|
|
52
|
+
active: +props.startPosition,
|
|
69
53
|
rootWidth: 0,
|
|
70
54
|
rootHeight: 0,
|
|
71
55
|
disableZoom: false
|
|
@@ -103,71 +87,38 @@ var stdin_default = defineComponent({
|
|
|
103
87
|
}, [props.images[state.active].title]);
|
|
104
88
|
}
|
|
105
89
|
};
|
|
106
|
-
const onDownload = () =>
|
|
90
|
+
const onDownload = () => {
|
|
107
91
|
var _a, _b, _c;
|
|
108
|
-
|
|
92
|
+
return download({
|
|
109
93
|
index: state.active,
|
|
110
94
|
url: (_a = props.images[state.active]) == null ? void 0 : _a.url,
|
|
111
|
-
title: (_b = props.images[state.active]) == null ? void 0 : _b.title
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
message: "\u4E0B\u8F7D\u4E2D...",
|
|
126
|
-
forbidClick: true,
|
|
127
|
-
duration: 0
|
|
128
|
-
});
|
|
129
|
-
fileJsi.download({
|
|
130
|
-
url: downloadParams.url
|
|
131
|
-
}).then(({
|
|
132
|
-
tempFilePath
|
|
133
|
-
}) => {
|
|
134
|
-
closeToast();
|
|
135
|
-
showSuccessToast("\u4E0B\u8F7D\u6210\u529F");
|
|
136
|
-
}).catch(() => {
|
|
137
|
-
closeToast();
|
|
138
|
-
showFailToast("\u4E0B\u8F7D\u5931\u8D25");
|
|
139
|
-
});
|
|
140
|
-
return;
|
|
141
|
-
} else {
|
|
142
|
-
showFailToast("\u5F53\u524D\u73AF\u5883\u6682\u4E0D\u652F\u6301\u4E0B\u8F7D");
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
} catch (e) {
|
|
146
|
-
console.log(e.message);
|
|
147
|
-
}
|
|
148
|
-
});
|
|
95
|
+
title: (_b = props.images[state.active]) == null ? void 0 : _b.title,
|
|
96
|
+
fileName: (_c = props.images[state.active]) == null ? void 0 : _c.fileName
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
const renderDownloadIcon = () => _createVNode("button", {
|
|
100
|
+
"type": "button",
|
|
101
|
+
"class": bem("download-icon"),
|
|
102
|
+
"aria-label": "\u4E0B\u8F7D\u539F\u56FE",
|
|
103
|
+
"disabled": downloading.value,
|
|
104
|
+
"onClick": onDownload
|
|
105
|
+
}, [_createVNode(Icon, {
|
|
106
|
+
"name": "download",
|
|
107
|
+
"size": "24"
|
|
108
|
+
}, null)]);
|
|
149
109
|
const renderIndex = () => {
|
|
150
110
|
const image = props.images[state.active];
|
|
151
|
-
const showDownload = props.showDownload && !image.url.startsWith("data:");
|
|
111
|
+
const showDownload = props.showDownload && (image == null ? void 0 : image.url) && !image.url.startsWith("data:");
|
|
152
112
|
if (props.showIndex || showDownload) {
|
|
153
|
-
if (props.showIndex && slots.index) {
|
|
154
|
-
return _createVNode("div", {
|
|
155
|
-
"class": bem("index")
|
|
156
|
-
}, [slots.index({
|
|
157
|
-
index: state.active
|
|
158
|
-
})]);
|
|
159
|
-
}
|
|
160
113
|
return _createVNode("div", {
|
|
161
114
|
"class": bem("index")
|
|
162
|
-
}, [props.showIndex &&
|
|
115
|
+
}, [props.showIndex && _createVNode("div", {
|
|
116
|
+
"class": bem("index-content")
|
|
117
|
+
}, [slots.index ? slots.index({
|
|
118
|
+
index: state.active
|
|
119
|
+
}) : [renderIndexText(), renderImageTitle()]]), showDownload && renderDownloadIcon()]);
|
|
163
120
|
}
|
|
164
121
|
};
|
|
165
|
-
const renderDownloadIcon = () => {
|
|
166
|
-
return _createVNode("div", {
|
|
167
|
-
"class": bem("download-icon"),
|
|
168
|
-
"onClick": onDownload
|
|
169
|
-
}, [Download(bem)]);
|
|
170
|
-
};
|
|
171
122
|
const renderCover = () => {
|
|
172
123
|
if (slots.cover) {
|
|
173
124
|
return _createVNode("div", {
|
|
@@ -229,7 +180,8 @@ var stdin_default = defineComponent({
|
|
|
229
180
|
return (_a = swipeRef.value) == null ? void 0 : _a.swipeTo(index, options);
|
|
230
181
|
};
|
|
231
182
|
useExpose({
|
|
232
|
-
swipeTo
|
|
183
|
+
swipeTo,
|
|
184
|
+
downloadFile
|
|
233
185
|
});
|
|
234
186
|
onMounted(() => {
|
|
235
187
|
resize();
|
|
@@ -259,6 +211,7 @@ var stdin_default = defineComponent({
|
|
|
259
211
|
return () => _createVNode(Popup, _mergeProps({
|
|
260
212
|
"class": [bem(), props.className],
|
|
261
213
|
"overlayClass": [bem("overlay"), props.overlayClass],
|
|
214
|
+
"onClick": (event) => event.stopPropagation(),
|
|
262
215
|
"onClosed": onClosed,
|
|
263
216
|
"onUpdate:show": updateShow
|
|
264
217
|
}, pick(props, popupProps)), {
|
|
@@ -15,6 +15,8 @@ const defaultConfig = {
|
|
|
15
15
|
className: "",
|
|
16
16
|
showIndex: true,
|
|
17
17
|
closeable: false,
|
|
18
|
+
showDownload: false,
|
|
19
|
+
downloadAction: void 0,
|
|
18
20
|
closeIcon: "clear",
|
|
19
21
|
transition: void 0,
|
|
20
22
|
beforeClose: void 0,
|
|
@@ -63,7 +65,8 @@ const showImagePreview = (options, startPosition = 0) => {
|
|
|
63
65
|
}
|
|
64
66
|
return {
|
|
65
67
|
url: opt.url,
|
|
66
|
-
title: opt.title || ""
|
|
68
|
+
title: opt.title || "",
|
|
69
|
+
fileName: opt.fileName
|
|
67
70
|
};
|
|
68
71
|
}),
|
|
69
72
|
startPosition
|
|
@@ -1 +1 @@
|
|
|
1
|
-
:root{--zt-image-preview-index-height: 48px;--zt-image-preview-index-background: var(--zt-gray-a4);--zt-image-preview-index-text-color: var(--zt-white);--zt-image-preview-overlay-background: rgba(0, 0, 0, .9);--zt-image-preview-close-icon-color: var(--zt-gray-5);--zt-image-preview-close-icon-margin: var(--zt-padding-md);--zt-image-preview-close-icon-z-index: 1;--zt-image-preview-error-font-size: 36px}:root[zt-theme-size=large]{--zt-image-preview-error-font-size: 42px}.zt-image-preview{position:fixed;top:0;left:0;width:100%;height:100%;max-width:none;background-color:transparent;transform:none}.zt-image-preview__swipe{height:100%}.zt-image-preview__swipe-item{display:flex;align-items:center;justify-content:center;overflow:hidden}.zt-image-preview__cover{position:absolute;top:0;left:0}.zt-image-preview__image,.zt-image-preview__image-wrap{width:100%;transition-property:transform}.zt-image-preview__image--vertical,.zt-image-preview__image-wrap--vertical{width:auto;height:100%}.zt-image-preview__image img,.zt-image-preview__image-wrap img,.zt-image-preview__image video,.zt-image-preview__image-wrap video{-webkit-user-drag:none}.zt-image-preview__image .zt-image__error,.zt-image-preview__image-wrap .zt-image__error{top:30%;height:40%}.zt-image-preview__image .zt-image__error-icon,.zt-image-preview__image-wrap .zt-image__error-icon{font-size:var(--zt-image-preview-error-font-size)}.zt-image-preview__image .zt-image__loading,.zt-image-preview__image-wrap .zt-image__loading{background-color:transparent}.zt-image-preview__index{box-sizing:border-box;display:flex;align-items:center;position:absolute;bottom:0;left:0;width:100%;height:var(--zt-image-preview-index-height);padding:0 16px;background-color:var(--zt-image-preview-index-background);color:var(--zt-image-preview-index-text-color);overflow:hidden}.zt-image-preview__index-number{height:var(--zt-line-height-xl);background:rgba(45,75,115,.8);border-radius:2px;font-size:var(--zt-font-size-sm);text-align:center;line-height:var(--zt-line-height-xl);padding:0 8px}.zt-image-preview__title{flex-shrink:0;margin-left:8px;margin-right:8px;font-size:var(--zt-font-size-md);line-height:var(--zt-line-height-md)}.zt-image-
|
|
1
|
+
:root{--zt-image-preview-index-height: 48px;--zt-image-preview-index-background: var(--zt-gray-a4);--zt-image-preview-index-text-color: var(--zt-white);--zt-image-preview-overlay-background: rgba(0, 0, 0, .9);--zt-image-preview-close-icon-color: var(--zt-gray-5);--zt-image-preview-close-icon-margin: var(--zt-padding-md);--zt-image-preview-close-icon-z-index: 1;--zt-image-preview-error-font-size: 36px}:root[zt-theme-size=large]{--zt-image-preview-error-font-size: 42px}.zt-image-preview{position:fixed;top:0;left:0;width:100%;height:100%;max-width:none;background-color:transparent;transform:none}.zt-image-preview__swipe{height:100%}.zt-image-preview__swipe-item{display:flex;align-items:center;justify-content:center;overflow:hidden}.zt-image-preview__cover{position:absolute;top:0;left:0}.zt-image-preview__image,.zt-image-preview__image-wrap{width:100%;transition-property:transform}.zt-image-preview__image--vertical,.zt-image-preview__image-wrap--vertical{width:auto;height:100%}.zt-image-preview__image img,.zt-image-preview__image-wrap img,.zt-image-preview__image video,.zt-image-preview__image-wrap video{-webkit-user-drag:none}.zt-image-preview__image .zt-image__error,.zt-image-preview__image-wrap .zt-image__error{top:30%;height:40%}.zt-image-preview__image .zt-image__error-icon,.zt-image-preview__image-wrap .zt-image__error-icon{font-size:var(--zt-image-preview-error-font-size)}.zt-image-preview__image .zt-image__loading,.zt-image-preview__image-wrap .zt-image__loading{background-color:transparent}.zt-image-preview__index{box-sizing:border-box;display:flex;align-items:center;position:absolute;bottom:0;left:0;width:100%;height:var(--zt-image-preview-index-height);padding:0 16px;background-color:var(--zt-image-preview-index-background);color:var(--zt-image-preview-index-text-color);overflow:hidden}.zt-image-preview__index-number{height:var(--zt-line-height-xl);background:rgba(45,75,115,.8);border-radius:2px;font-size:var(--zt-font-size-sm);text-align:center;line-height:var(--zt-line-height-xl);padding:0 8px}.zt-image-preview__title{flex-shrink:0;margin-left:8px;margin-right:8px;font-size:var(--zt-font-size-md);line-height:var(--zt-line-height-md)}.zt-image-preview__index-content{display:flex;align-items:center;flex:1;min-width:0;height:100%;overflow:hidden}.zt-image-preview__download-icon{display:flex;align-items:center;border:0;background:transparent;color:inherit;flex-shrink:0;margin-left:auto;padding:4px;cursor:pointer}.zt-image-preview__overlay{background:var(--zt-image-preview-overlay-background)}.zt-image-preview__close-icon{position:absolute;z-index:var(--zt-image-preview-close-icon-z-index);color:var(--zt-image-preview-close-icon-color);font-size:var(--zt-font-size-xxxl)}.zt-image-preview__close-icon--top-left{top:var(--zt-image-preview-close-icon-margin);left:var(--zt-image-preview-close-icon-margin)}.zt-image-preview__close-icon--top-right{top:var(--zt-image-preview-close-icon-margin);right:var(--zt-image-preview-close-icon-margin)}.zt-image-preview__close-icon--bottom-left{bottom:var(--zt-image-preview-close-icon-margin);left:var(--zt-image-preview-close-icon-margin)}.zt-image-preview__close-icon--bottom-right{right:var(--zt-image-preview-close-icon-margin);bottom:var(--zt-image-preview-close-icon-margin)}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { ImagePreviewProps } from './ImagePreview';
|
|
2
1
|
export declare const ImagePreview: import("../utils").WithInstall<import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
3
2
|
show: BooleanConstructor;
|
|
4
3
|
loop: {
|
|
@@ -148,7 +147,7 @@ export declare const ImagePreview: import("../utils").WithInstall<import("vue").
|
|
|
148
147
|
export default ImagePreview;
|
|
149
148
|
export { imagePreviewProps } from './ImagePreview';
|
|
150
149
|
export { showImagePreview } from './function-call';
|
|
151
|
-
export type { ImagePreviewProps };
|
|
150
|
+
export type { ImagePreviewProps, DownloadActionParams, FileDownloadOptions } from './ImagePreview';
|
|
152
151
|
export type { ImageItem, ImagePreviewOptions, ImagePreviewInstance, ImagePreviewScaleEventParams, ImagePreviewThemeVars, } from './types';
|
|
153
152
|
declare module 'vue' {
|
|
154
153
|
interface GlobalComponents {
|
|
@@ -6,6 +6,8 @@ import "../../overlay/index.css";
|
|
|
6
6
|
import "../../popup/index.css";
|
|
7
7
|
import "../../loading/index.css";
|
|
8
8
|
import "../../toast/index.css";
|
|
9
|
+
import "../../button/index.css";
|
|
10
|
+
import "../../dialog/index.css";
|
|
9
11
|
import "../../swipe/index.css";
|
|
10
12
|
import "../../swipe-item/index.css";
|
|
11
13
|
import "../index.css";
|
|
@@ -2,10 +2,11 @@ import type { CSSProperties, TeleportProps, ComponentPublicInstance } from 'vue'
|
|
|
2
2
|
import type { Interceptor } from '../utils';
|
|
3
3
|
import type { SwipeToOptions } from '../swipe';
|
|
4
4
|
import type { PopupCloseIconPosition } from '../popup';
|
|
5
|
-
import type { DownloadActionParams, ImagePreviewProps } from './ImagePreview';
|
|
5
|
+
import type { DownloadActionParams, FileDownloadOptions, ImagePreviewProps } from './ImagePreview';
|
|
6
6
|
export type ImageItem = {
|
|
7
7
|
url: string;
|
|
8
8
|
title?: string;
|
|
9
|
+
fileName?: string;
|
|
9
10
|
};
|
|
10
11
|
export type ImagePreviewOptions = {
|
|
11
12
|
loop?: boolean;
|
|
@@ -41,6 +42,7 @@ export type ImagePreviewScaleEventParams = {
|
|
|
41
42
|
index: number;
|
|
42
43
|
};
|
|
43
44
|
export type ImagePreviewExpose = {
|
|
45
|
+
downloadFile: (options: FileDownloadOptions) => Promise<void>;
|
|
44
46
|
swipeTo: (index: number, options?: SwipeToOptions) => void;
|
|
45
47
|
};
|
|
46
48
|
export type ImagePreviewInstance = ComponentPublicInstance<ImagePreviewProps, ImagePreviewExpose>;
|
package/es/index.d.ts
CHANGED
package/es/index.mjs
CHANGED
|
@@ -79,7 +79,7 @@ import { Timeline } from "./timeline/index.mjs";
|
|
|
79
79
|
import { Toast } from "./toast/index.mjs";
|
|
80
80
|
import { Uploader } from "./uploader/index.mjs";
|
|
81
81
|
import { Video } from "./video/index.mjs";
|
|
82
|
-
const version = "3.1.
|
|
82
|
+
const version = "3.1.94";
|
|
83
83
|
function install(app) {
|
|
84
84
|
const components = [
|
|
85
85
|
ActionSheet,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ComponentPublicInstance, ExtractPropTypes, PropType } from 'vue';
|
|
2
2
|
import type { Media, MediaAddType, MediaAfterRead, MediaBeforeDelete, MediaBeforeRead, MediaPick, MediaPreview, MediaSizeType, MediaType } from './type';
|
|
3
3
|
import { MediaPlayerProps } from '../media-player';
|
|
4
|
-
import { DownloadActionParams } from '../
|
|
4
|
+
import type { DownloadActionParams } from '../composables/use-media-download';
|
|
5
5
|
declare const mediaPickerProps: {
|
|
6
6
|
sortable: {
|
|
7
7
|
type: BooleanConstructor;
|