@expcat/tigercat-vue 0.3.69 → 0.3.70
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/chunk-53M2BTB5.mjs +22 -0
- package/dist/chunk-7AFJ7TKW.js +266 -0
- package/dist/chunk-GNKXBRXH.js +189 -0
- package/dist/chunk-HTMTOXUO.mjs +186 -0
- package/dist/chunk-K2U3FEL7.js +373 -0
- package/dist/chunk-K6HDRMPN.js +197 -0
- package/dist/chunk-LDCTSE6Y.mjs +60 -0
- package/dist/chunk-LNWRZKX2.js +64 -0
- package/dist/chunk-MB7W46IY.mjs +193 -0
- package/dist/chunk-MMQ34S5M.mjs +263 -0
- package/dist/chunk-PNKVD2UK.js +26 -0
- package/dist/chunk-T77L326M.mjs +370 -0
- package/dist/components/ActivityFeed.js +5 -4
- package/dist/components/ActivityFeed.mjs +3 -2
- package/dist/components/Alert.js +1 -0
- package/dist/components/Alert.mjs +1 -0
- package/dist/components/Anchor.js +1 -0
- package/dist/components/Anchor.mjs +1 -0
- package/dist/components/AnchorLink.js +1 -0
- package/dist/components/AnchorLink.mjs +1 -0
- package/dist/components/AreaChart.js +1 -0
- package/dist/components/AreaChart.mjs +1 -0
- package/dist/components/Avatar.js +1 -0
- package/dist/components/Avatar.mjs +1 -0
- package/dist/components/BackTop.js +1 -0
- package/dist/components/BackTop.mjs +1 -0
- package/dist/components/Badge.js +1 -0
- package/dist/components/Badge.mjs +1 -0
- package/dist/components/BarChart.js +1 -0
- package/dist/components/BarChart.mjs +1 -0
- package/dist/components/Breadcrumb.js +1 -0
- package/dist/components/Breadcrumb.mjs +1 -0
- package/dist/components/BreadcrumbItem.js +1 -0
- package/dist/components/BreadcrumbItem.mjs +1 -0
- package/dist/components/Button.js +1 -0
- package/dist/components/Button.mjs +1 -0
- package/dist/components/Card.js +1 -0
- package/dist/components/Card.mjs +1 -0
- package/dist/components/Carousel.js +1 -0
- package/dist/components/Carousel.mjs +1 -0
- package/dist/components/ChartAxis.js +1 -0
- package/dist/components/ChartAxis.mjs +1 -0
- package/dist/components/ChartCanvas.js +1 -0
- package/dist/components/ChartCanvas.mjs +1 -0
- package/dist/components/ChartGrid.js +1 -0
- package/dist/components/ChartGrid.mjs +1 -0
- package/dist/components/ChartLegend.js +1 -0
- package/dist/components/ChartLegend.mjs +1 -0
- package/dist/components/ChartSeries.js +1 -0
- package/dist/components/ChartSeries.mjs +1 -0
- package/dist/components/ChartTooltip.js +1 -0
- package/dist/components/ChartTooltip.mjs +1 -0
- package/dist/components/ChatWindow.js +1 -0
- package/dist/components/ChatWindow.mjs +1 -0
- package/dist/components/Checkbox.js +1 -0
- package/dist/components/Checkbox.mjs +1 -0
- package/dist/components/CheckboxGroup.js +1 -0
- package/dist/components/CheckboxGroup.mjs +1 -0
- package/dist/components/Code.js +1 -0
- package/dist/components/Code.mjs +1 -0
- package/dist/components/Col.js +1 -0
- package/dist/components/Col.mjs +1 -0
- package/dist/components/Collapse.js +1 -0
- package/dist/components/Collapse.mjs +1 -0
- package/dist/components/CollapsePanel.js +1 -0
- package/dist/components/CollapsePanel.mjs +1 -0
- package/dist/components/CommentThread.js +1 -0
- package/dist/components/CommentThread.mjs +1 -0
- package/dist/components/ConfigProvider.js +1 -0
- package/dist/components/ConfigProvider.mjs +1 -0
- package/dist/components/Container.js +1 -0
- package/dist/components/Container.mjs +1 -0
- package/dist/components/Content.js +1 -0
- package/dist/components/Content.mjs +1 -0
- package/dist/components/CropUpload.d.mts +97 -0
- package/dist/components/CropUpload.d.ts +97 -0
- package/dist/components/CropUpload.js +20 -0
- package/dist/components/CropUpload.mjs +5 -0
- package/dist/components/DataTableWithToolbar.js +1 -0
- package/dist/components/DataTableWithToolbar.mjs +1 -0
- package/dist/components/DatePicker.js +1 -0
- package/dist/components/DatePicker.mjs +1 -0
- package/dist/components/Descriptions.js +1 -0
- package/dist/components/Descriptions.mjs +1 -0
- package/dist/components/Divider.js +1 -0
- package/dist/components/Divider.mjs +1 -0
- package/dist/components/DonutChart.js +1 -0
- package/dist/components/DonutChart.mjs +1 -0
- package/dist/components/Drawer.d.mts +2 -2
- package/dist/components/Drawer.d.ts +2 -2
- package/dist/components/Drawer.js +1 -0
- package/dist/components/Drawer.mjs +1 -0
- package/dist/components/Dropdown.js +1 -0
- package/dist/components/Dropdown.mjs +1 -0
- package/dist/components/DropdownItem.js +1 -0
- package/dist/components/DropdownItem.mjs +1 -0
- package/dist/components/DropdownMenu.js +1 -0
- package/dist/components/DropdownMenu.mjs +1 -0
- package/dist/components/Footer.js +1 -0
- package/dist/components/Footer.mjs +1 -0
- package/dist/components/Form.js +1 -0
- package/dist/components/Form.mjs +1 -0
- package/dist/components/FormItem.js +1 -0
- package/dist/components/FormItem.mjs +1 -0
- package/dist/components/FormWizard.js +1 -0
- package/dist/components/FormWizard.mjs +1 -0
- package/dist/components/Header.js +1 -0
- package/dist/components/Header.mjs +1 -0
- package/dist/components/Icon.js +1 -0
- package/dist/components/Icon.mjs +1 -0
- package/dist/components/Image.d.mts +119 -0
- package/dist/components/Image.d.ts +119 -0
- package/dist/components/Image.js +22 -0
- package/dist/components/Image.mjs +3 -0
- package/dist/components/ImageCropper.d.mts +105 -0
- package/dist/components/ImageCropper.d.ts +105 -0
- package/dist/components/ImageCropper.js +17 -0
- package/dist/components/ImageCropper.mjs +2 -0
- package/dist/components/ImageGroup.d.mts +30 -0
- package/dist/components/ImageGroup.d.ts +30 -0
- package/dist/components/ImageGroup.js +22 -0
- package/dist/components/ImageGroup.mjs +3 -0
- package/dist/components/ImagePreview.d.mts +97 -0
- package/dist/components/ImagePreview.d.ts +97 -0
- package/dist/components/ImagePreview.js +17 -0
- package/dist/components/ImagePreview.mjs +5 -0
- package/dist/components/Input.js +1 -0
- package/dist/components/Input.mjs +1 -0
- package/dist/components/Layout.js +1 -0
- package/dist/components/Layout.mjs +1 -0
- package/dist/components/LineChart.js +1 -0
- package/dist/components/LineChart.mjs +1 -0
- package/dist/components/Link.js +1 -0
- package/dist/components/Link.mjs +1 -0
- package/dist/components/List.js +1 -0
- package/dist/components/List.mjs +1 -0
- package/dist/components/Loading.js +1 -0
- package/dist/components/Loading.mjs +1 -0
- package/dist/components/Menu.js +1 -0
- package/dist/components/Menu.mjs +1 -0
- package/dist/components/MenuItem.js +1 -0
- package/dist/components/MenuItem.mjs +1 -0
- package/dist/components/MenuItemGroup.js +1 -0
- package/dist/components/MenuItemGroup.mjs +1 -0
- package/dist/components/Message.js +1 -0
- package/dist/components/Message.mjs +1 -0
- package/dist/components/Modal.d.mts +2 -2
- package/dist/components/Modal.d.ts +2 -2
- package/dist/components/Modal.js +1 -0
- package/dist/components/Modal.mjs +1 -0
- package/dist/components/Notification.js +1 -0
- package/dist/components/Notification.mjs +1 -0
- package/dist/components/NotificationCenter.js +1 -0
- package/dist/components/NotificationCenter.mjs +1 -0
- package/dist/components/Pagination.js +1 -0
- package/dist/components/Pagination.mjs +1 -0
- package/dist/components/PieChart.js +1 -0
- package/dist/components/PieChart.mjs +1 -0
- package/dist/components/Popconfirm.js +1 -0
- package/dist/components/Popconfirm.mjs +1 -0
- package/dist/components/Popover.js +1 -0
- package/dist/components/Popover.mjs +1 -0
- package/dist/components/Progress.js +1 -0
- package/dist/components/Progress.mjs +1 -0
- package/dist/components/RadarChart.js +1 -0
- package/dist/components/RadarChart.mjs +1 -0
- package/dist/components/Radio.js +1 -0
- package/dist/components/Radio.mjs +1 -0
- package/dist/components/RadioGroup.js +1 -0
- package/dist/components/RadioGroup.mjs +1 -0
- package/dist/components/Row.js +1 -0
- package/dist/components/Row.mjs +1 -0
- package/dist/components/ScatterChart.js +1 -0
- package/dist/components/ScatterChart.mjs +1 -0
- package/dist/components/Select.js +1 -0
- package/dist/components/Select.mjs +1 -0
- package/dist/components/Sidebar.js +1 -0
- package/dist/components/Sidebar.mjs +1 -0
- package/dist/components/Skeleton.js +1 -0
- package/dist/components/Skeleton.mjs +1 -0
- package/dist/components/Slider.js +1 -0
- package/dist/components/Slider.mjs +1 -0
- package/dist/components/Space.js +1 -0
- package/dist/components/Space.mjs +1 -0
- package/dist/components/Steps.js +1 -0
- package/dist/components/Steps.mjs +1 -0
- package/dist/components/StepsItem.js +1 -0
- package/dist/components/StepsItem.mjs +1 -0
- package/dist/components/SubMenu.js +1 -0
- package/dist/components/SubMenu.mjs +1 -0
- package/dist/components/Switch.js +1 -0
- package/dist/components/Switch.mjs +1 -0
- package/dist/components/TabPane.js +1 -0
- package/dist/components/TabPane.mjs +1 -0
- package/dist/components/Table.js +1 -0
- package/dist/components/Table.mjs +1 -0
- package/dist/components/Tabs.js +1 -0
- package/dist/components/Tabs.mjs +1 -0
- package/dist/components/Tag.js +1 -0
- package/dist/components/Tag.mjs +1 -0
- package/dist/components/Text.js +1 -0
- package/dist/components/Text.mjs +1 -0
- package/dist/components/Textarea.js +1 -0
- package/dist/components/Textarea.mjs +1 -0
- package/dist/components/TimePicker.js +1 -0
- package/dist/components/TimePicker.mjs +1 -0
- package/dist/components/Timeline.js +1 -0
- package/dist/components/Timeline.mjs +1 -0
- package/dist/components/Tooltip.js +1 -0
- package/dist/components/Tooltip.mjs +1 -0
- package/dist/components/Tree.js +1 -0
- package/dist/components/Tree.mjs +1 -0
- package/dist/components/Upload.js +1 -0
- package/dist/components/Upload.mjs +1 -0
- package/dist/index.d.mts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +98 -70
- package/dist/index.mjs +26 -17
- package/package.json +2 -2
- package/dist/{chunk-RVEEEDJQ.mjs → chunk-D7VMY6WX.mjs} +1 -1
- package/dist/{chunk-EBTLMVDJ.js → chunk-NGW5UMAN.js} +1 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __esm = (fn, res) => function __init() {
|
|
6
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
7
|
+
};
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
export { __esm, __export, __toCommonJS };
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkPNKVD2UK_js = require('./chunk-PNKVD2UK.js');
|
|
4
|
+
var vue = require('vue');
|
|
5
|
+
var tigercatCore = require('@expcat/tigercat-core');
|
|
6
|
+
|
|
7
|
+
// src/components/ImagePreview.ts
|
|
8
|
+
var ImagePreview_exports = {};
|
|
9
|
+
chunkPNKVD2UK_js.__export(ImagePreview_exports, {
|
|
10
|
+
ImagePreview: () => exports.ImagePreview,
|
|
11
|
+
default: () => exports.ImagePreview_default
|
|
12
|
+
});
|
|
13
|
+
var svgIcon; exports.ImagePreview = void 0; exports.ImagePreview_default = void 0;
|
|
14
|
+
var init_ImagePreview = chunkPNKVD2UK_js.__esm({
|
|
15
|
+
"src/components/ImagePreview.ts"() {
|
|
16
|
+
svgIcon = (d, cls = "w-5 h-5") => vue.h(
|
|
17
|
+
"svg",
|
|
18
|
+
{
|
|
19
|
+
class: cls,
|
|
20
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
21
|
+
fill: "none",
|
|
22
|
+
viewBox: "0 0 24 24",
|
|
23
|
+
stroke: "currentColor"
|
|
24
|
+
},
|
|
25
|
+
[
|
|
26
|
+
vue.h("path", {
|
|
27
|
+
"stroke-linecap": "round",
|
|
28
|
+
"stroke-linejoin": "round",
|
|
29
|
+
"stroke-width": "2",
|
|
30
|
+
d
|
|
31
|
+
})
|
|
32
|
+
]
|
|
33
|
+
);
|
|
34
|
+
exports.ImagePreview = vue.defineComponent({
|
|
35
|
+
name: "TigerImagePreview",
|
|
36
|
+
inheritAttrs: false,
|
|
37
|
+
props: {
|
|
38
|
+
visible: { type: Boolean, default: false },
|
|
39
|
+
images: { type: Array, default: () => [] },
|
|
40
|
+
currentIndex: { type: Number, default: 0 },
|
|
41
|
+
zIndex: { type: Number, default: 1050 },
|
|
42
|
+
maskClosable: { type: Boolean, default: true },
|
|
43
|
+
scaleStep: { type: Number, default: 0.5 },
|
|
44
|
+
minScale: { type: Number, default: 0.25 },
|
|
45
|
+
maxScale: { type: Number, default: 5 }
|
|
46
|
+
},
|
|
47
|
+
emits: ["update:visible", "update:currentIndex", "scale-change"],
|
|
48
|
+
setup(props, { emit }) {
|
|
49
|
+
const scale = vue.ref(1);
|
|
50
|
+
const offsetX = vue.ref(0);
|
|
51
|
+
const offsetY = vue.ref(0);
|
|
52
|
+
const index = vue.ref(props.currentIndex);
|
|
53
|
+
const dragging = vue.ref(false);
|
|
54
|
+
const dragStart = vue.ref({ x: 0, y: 0, ox: 0, oy: 0 });
|
|
55
|
+
const resetTransform = () => {
|
|
56
|
+
scale.value = 1;
|
|
57
|
+
offsetX.value = 0;
|
|
58
|
+
offsetY.value = 0;
|
|
59
|
+
};
|
|
60
|
+
vue.watch(
|
|
61
|
+
() => props.currentIndex,
|
|
62
|
+
(val) => {
|
|
63
|
+
index.value = val;
|
|
64
|
+
resetTransform();
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
vue.watch(
|
|
68
|
+
() => props.visible,
|
|
69
|
+
(val) => {
|
|
70
|
+
if (val) {
|
|
71
|
+
resetTransform();
|
|
72
|
+
index.value = props.currentIndex;
|
|
73
|
+
document.body.style.overflow = "hidden";
|
|
74
|
+
} else {
|
|
75
|
+
document.body.style.overflow = "";
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
const navState = vue.computed(() => tigercatCore.getPreviewNavState(index.value, props.images.length));
|
|
80
|
+
const handleClose = () => {
|
|
81
|
+
emit("update:visible", false);
|
|
82
|
+
};
|
|
83
|
+
const handleZoomIn = () => {
|
|
84
|
+
scale.value = tigercatCore.clampScale(scale.value + props.scaleStep, props.minScale, props.maxScale);
|
|
85
|
+
emit("scale-change", scale.value);
|
|
86
|
+
};
|
|
87
|
+
const handleZoomOut = () => {
|
|
88
|
+
scale.value = tigercatCore.clampScale(scale.value - props.scaleStep, props.minScale, props.maxScale);
|
|
89
|
+
emit("scale-change", scale.value);
|
|
90
|
+
};
|
|
91
|
+
const handleReset = () => {
|
|
92
|
+
resetTransform();
|
|
93
|
+
emit("scale-change", 1);
|
|
94
|
+
};
|
|
95
|
+
const handlePrev = () => {
|
|
96
|
+
if (navState.value.hasPrev) {
|
|
97
|
+
index.value--;
|
|
98
|
+
resetTransform();
|
|
99
|
+
emit("update:currentIndex", index.value);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
const handleNext = () => {
|
|
103
|
+
if (navState.value.hasNext) {
|
|
104
|
+
index.value++;
|
|
105
|
+
resetTransform();
|
|
106
|
+
emit("update:currentIndex", index.value);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
const handleWheel = (e) => {
|
|
110
|
+
e.preventDefault();
|
|
111
|
+
const delta = e.deltaY > 0 ? -props.scaleStep : props.scaleStep;
|
|
112
|
+
scale.value = tigercatCore.clampScale(scale.value + delta, props.minScale, props.maxScale);
|
|
113
|
+
emit("scale-change", scale.value);
|
|
114
|
+
};
|
|
115
|
+
const handleMouseDown = (e) => {
|
|
116
|
+
if (e.button !== 0) return;
|
|
117
|
+
e.preventDefault();
|
|
118
|
+
dragging.value = true;
|
|
119
|
+
dragStart.value = {
|
|
120
|
+
x: e.clientX,
|
|
121
|
+
y: e.clientY,
|
|
122
|
+
ox: offsetX.value,
|
|
123
|
+
oy: offsetY.value
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
const handleMouseMove = (e) => {
|
|
127
|
+
if (!dragging.value) return;
|
|
128
|
+
offsetX.value = dragStart.value.ox + (e.clientX - dragStart.value.x);
|
|
129
|
+
offsetY.value = dragStart.value.oy + (e.clientY - dragStart.value.y);
|
|
130
|
+
};
|
|
131
|
+
const handleMouseUp = () => {
|
|
132
|
+
dragging.value = false;
|
|
133
|
+
};
|
|
134
|
+
const handleMaskClick = (e) => {
|
|
135
|
+
if (props.maskClosable && e.target === e.currentTarget) {
|
|
136
|
+
handleClose();
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
const handleKeyDown = (e) => {
|
|
140
|
+
if (!props.visible) return;
|
|
141
|
+
switch (e.key) {
|
|
142
|
+
case "Escape":
|
|
143
|
+
handleClose();
|
|
144
|
+
break;
|
|
145
|
+
case "ArrowLeft":
|
|
146
|
+
handlePrev();
|
|
147
|
+
break;
|
|
148
|
+
case "ArrowRight":
|
|
149
|
+
handleNext();
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
vue.onMounted(() => {
|
|
154
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
155
|
+
});
|
|
156
|
+
vue.onBeforeUnmount(() => {
|
|
157
|
+
document.removeEventListener("keydown", handleKeyDown);
|
|
158
|
+
document.body.style.overflow = "";
|
|
159
|
+
});
|
|
160
|
+
const transform = vue.computed(() => tigercatCore.calculateTransform(scale.value, offsetX.value, offsetY.value));
|
|
161
|
+
return () => {
|
|
162
|
+
if (!props.visible || !props.images.length) return null;
|
|
163
|
+
const currentSrc = props.images[index.value] || props.images[0];
|
|
164
|
+
const mask = vue.h("div", {
|
|
165
|
+
class: tigercatCore.imagePreviewMaskClasses,
|
|
166
|
+
"aria-hidden": "true"
|
|
167
|
+
});
|
|
168
|
+
const img = vue.h("img", {
|
|
169
|
+
src: currentSrc,
|
|
170
|
+
class: tigercatCore.imagePreviewImgClasses,
|
|
171
|
+
style: { transform: transform.value },
|
|
172
|
+
alt: `Preview image ${index.value + 1}`,
|
|
173
|
+
draggable: false,
|
|
174
|
+
onMousedown: handleMouseDown,
|
|
175
|
+
onMousemove: handleMouseMove,
|
|
176
|
+
onMouseup: handleMouseUp,
|
|
177
|
+
onMouseleave: handleMouseUp
|
|
178
|
+
});
|
|
179
|
+
const closeBtn = vue.h(
|
|
180
|
+
"button",
|
|
181
|
+
{
|
|
182
|
+
class: tigercatCore.imagePreviewCloseBtnClasses,
|
|
183
|
+
onClick: handleClose,
|
|
184
|
+
"aria-label": "Close preview",
|
|
185
|
+
type: "button"
|
|
186
|
+
},
|
|
187
|
+
[svgIcon(tigercatCore.previewCloseIconPath)]
|
|
188
|
+
);
|
|
189
|
+
const toolbar = vue.h("div", { class: tigercatCore.imagePreviewToolbarClasses }, [
|
|
190
|
+
vue.h(
|
|
191
|
+
"button",
|
|
192
|
+
{
|
|
193
|
+
class: tigercatCore.imagePreviewToolbarBtnClasses,
|
|
194
|
+
onClick: handleZoomOut,
|
|
195
|
+
"aria-label": "Zoom out",
|
|
196
|
+
type: "button"
|
|
197
|
+
},
|
|
198
|
+
[svgIcon(tigercatCore.zoomOutIconPath)]
|
|
199
|
+
),
|
|
200
|
+
vue.h(
|
|
201
|
+
"button",
|
|
202
|
+
{
|
|
203
|
+
class: tigercatCore.imagePreviewToolbarBtnClasses,
|
|
204
|
+
onClick: handleReset,
|
|
205
|
+
"aria-label": "Reset",
|
|
206
|
+
type: "button"
|
|
207
|
+
},
|
|
208
|
+
[svgIcon(tigercatCore.resetIconPath)]
|
|
209
|
+
),
|
|
210
|
+
vue.h(
|
|
211
|
+
"button",
|
|
212
|
+
{
|
|
213
|
+
class: tigercatCore.imagePreviewToolbarBtnClasses,
|
|
214
|
+
onClick: handleZoomIn,
|
|
215
|
+
"aria-label": "Zoom in",
|
|
216
|
+
type: "button"
|
|
217
|
+
},
|
|
218
|
+
[svgIcon(tigercatCore.zoomInIconPath)]
|
|
219
|
+
),
|
|
220
|
+
navState.value.counter ? vue.h("span", { class: tigercatCore.imagePreviewCounterClasses }, navState.value.counter) : null
|
|
221
|
+
]);
|
|
222
|
+
const prevBtn = props.images.length > 1 ? vue.h(
|
|
223
|
+
"button",
|
|
224
|
+
{
|
|
225
|
+
class: tigercatCore.classNames(tigercatCore.imagePreviewNavBtnClasses, "left-4"),
|
|
226
|
+
onClick: handlePrev,
|
|
227
|
+
disabled: !navState.value.hasPrev,
|
|
228
|
+
"aria-label": "Previous image",
|
|
229
|
+
type: "button"
|
|
230
|
+
},
|
|
231
|
+
[svgIcon(tigercatCore.prevIconPath)]
|
|
232
|
+
) : null;
|
|
233
|
+
const nextBtn = props.images.length > 1 ? vue.h(
|
|
234
|
+
"button",
|
|
235
|
+
{
|
|
236
|
+
class: tigercatCore.classNames(tigercatCore.imagePreviewNavBtnClasses, "right-4"),
|
|
237
|
+
onClick: handleNext,
|
|
238
|
+
disabled: !navState.value.hasNext,
|
|
239
|
+
"aria-label": "Next image",
|
|
240
|
+
type: "button"
|
|
241
|
+
},
|
|
242
|
+
[svgIcon(tigercatCore.nextIconPath)]
|
|
243
|
+
) : null;
|
|
244
|
+
const wrapper = vue.h(
|
|
245
|
+
"div",
|
|
246
|
+
{
|
|
247
|
+
class: tigercatCore.imagePreviewWrapperClasses,
|
|
248
|
+
style: { zIndex: props.zIndex },
|
|
249
|
+
role: "dialog",
|
|
250
|
+
"aria-modal": "true",
|
|
251
|
+
"aria-label": "Image preview",
|
|
252
|
+
onClick: handleMaskClick,
|
|
253
|
+
onWheel: handleWheel
|
|
254
|
+
},
|
|
255
|
+
[mask, img, closeBtn, prevBtn, nextBtn, toolbar]
|
|
256
|
+
);
|
|
257
|
+
return vue.h(vue.Teleport, { to: "body" }, [wrapper]);
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
exports.ImagePreview_default = exports.ImagePreview;
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
exports.ImagePreview_exports = ImagePreview_exports;
|
|
266
|
+
exports.init_ImagePreview = init_ImagePreview;
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkW36SYMVH_js = require('./chunk-W36SYMVH.js');
|
|
4
|
+
var chunkK2U3FEL7_js = require('./chunk-K2U3FEL7.js');
|
|
5
|
+
var chunkDELTFEEJ_js = require('./chunk-DELTFEEJ.js');
|
|
6
|
+
var vue = require('vue');
|
|
7
|
+
var tigercatCore = require('@expcat/tigercat-core');
|
|
8
|
+
|
|
9
|
+
var CropUpload = vue.defineComponent({
|
|
10
|
+
name: "TigerCropUpload",
|
|
11
|
+
inheritAttrs: false,
|
|
12
|
+
props: {
|
|
13
|
+
accept: { type: String, default: "image/*" },
|
|
14
|
+
disabled: { type: Boolean, default: false },
|
|
15
|
+
maxSize: { type: Number, default: void 0 },
|
|
16
|
+
cropperProps: {
|
|
17
|
+
type: Object,
|
|
18
|
+
default: void 0
|
|
19
|
+
},
|
|
20
|
+
modalTitle: { type: String, default: "\u88C1\u526A\u56FE\u7247" },
|
|
21
|
+
modalWidth: { type: Number, default: 520 },
|
|
22
|
+
className: { type: String, default: void 0 },
|
|
23
|
+
style: {
|
|
24
|
+
type: Object,
|
|
25
|
+
default: void 0
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
emits: ["crop-complete", "error"],
|
|
29
|
+
setup(props, { slots, emit, attrs }) {
|
|
30
|
+
const fileInputRef = vue.ref(null);
|
|
31
|
+
const modalVisible = vue.ref(false);
|
|
32
|
+
const imageSrc = vue.ref("");
|
|
33
|
+
const cropperRef = vue.ref(null);
|
|
34
|
+
const cropping = vue.ref(false);
|
|
35
|
+
const handleTriggerClick = () => {
|
|
36
|
+
if (props.disabled) return;
|
|
37
|
+
fileInputRef.value?.click();
|
|
38
|
+
};
|
|
39
|
+
const handleFileChange = (e) => {
|
|
40
|
+
const input = e.target;
|
|
41
|
+
const file = input.files?.[0];
|
|
42
|
+
if (!file) return;
|
|
43
|
+
if (props.maxSize && file.size > props.maxSize) {
|
|
44
|
+
emit("error", new Error(`File size exceeds maximum of ${props.maxSize} bytes`));
|
|
45
|
+
input.value = "";
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const reader = new FileReader();
|
|
49
|
+
reader.onload = (ev) => {
|
|
50
|
+
imageSrc.value = ev.target?.result;
|
|
51
|
+
modalVisible.value = true;
|
|
52
|
+
};
|
|
53
|
+
reader.readAsDataURL(file);
|
|
54
|
+
input.value = "";
|
|
55
|
+
};
|
|
56
|
+
const handleConfirm = async () => {
|
|
57
|
+
if (!cropperRef.value) return;
|
|
58
|
+
cropping.value = true;
|
|
59
|
+
try {
|
|
60
|
+
const result = await cropperRef.value.getCropResult();
|
|
61
|
+
emit("crop-complete", result);
|
|
62
|
+
modalVisible.value = false;
|
|
63
|
+
} catch (err) {
|
|
64
|
+
emit("error", err);
|
|
65
|
+
} finally {
|
|
66
|
+
cropping.value = false;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const handleCancel = () => {
|
|
70
|
+
modalVisible.value = false;
|
|
71
|
+
imageSrc.value = "";
|
|
72
|
+
};
|
|
73
|
+
const triggerClasses = vue.computed(
|
|
74
|
+
() => tigercatCore.classNames(
|
|
75
|
+
props.disabled ? tigercatCore.cropUploadTriggerDisabledClasses : tigercatCore.cropUploadTriggerClasses,
|
|
76
|
+
props.className,
|
|
77
|
+
tigercatCore.coerceClassValue(attrs.class)
|
|
78
|
+
)
|
|
79
|
+
);
|
|
80
|
+
const triggerStyle = vue.computed(
|
|
81
|
+
() => tigercatCore.mergeStyleValues(attrs.style, props.style)
|
|
82
|
+
);
|
|
83
|
+
return () => {
|
|
84
|
+
const forwardedAttrs = Object.fromEntries(
|
|
85
|
+
Object.entries(attrs).filter(([key]) => key !== "class" && key !== "style")
|
|
86
|
+
);
|
|
87
|
+
const fileInput = vue.h("input", {
|
|
88
|
+
ref: fileInputRef,
|
|
89
|
+
type: "file",
|
|
90
|
+
accept: props.accept,
|
|
91
|
+
style: { display: "none" },
|
|
92
|
+
onChange: handleFileChange
|
|
93
|
+
});
|
|
94
|
+
const trigger = slots.default ? vue.h(
|
|
95
|
+
"div",
|
|
96
|
+
{
|
|
97
|
+
...forwardedAttrs,
|
|
98
|
+
class: triggerClasses.value,
|
|
99
|
+
style: triggerStyle.value,
|
|
100
|
+
onClick: handleTriggerClick,
|
|
101
|
+
role: "button",
|
|
102
|
+
tabindex: props.disabled ? -1 : 0,
|
|
103
|
+
"aria-label": "Select image to crop and upload",
|
|
104
|
+
"aria-disabled": props.disabled ? "true" : void 0,
|
|
105
|
+
onKeydown: (e) => {
|
|
106
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
107
|
+
e.preventDefault();
|
|
108
|
+
handleTriggerClick();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
slots.default()
|
|
113
|
+
) : vue.h(
|
|
114
|
+
"div",
|
|
115
|
+
{
|
|
116
|
+
...forwardedAttrs,
|
|
117
|
+
class: triggerClasses.value,
|
|
118
|
+
style: triggerStyle.value,
|
|
119
|
+
onClick: handleTriggerClick,
|
|
120
|
+
role: "button",
|
|
121
|
+
tabindex: props.disabled ? -1 : 0,
|
|
122
|
+
"aria-label": "Select image to crop and upload",
|
|
123
|
+
"aria-disabled": props.disabled ? "true" : void 0,
|
|
124
|
+
onKeydown: (e) => {
|
|
125
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
126
|
+
e.preventDefault();
|
|
127
|
+
handleTriggerClick();
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
[
|
|
132
|
+
vue.h(
|
|
133
|
+
"svg",
|
|
134
|
+
{
|
|
135
|
+
class: "w-5 h-5",
|
|
136
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
137
|
+
fill: "none",
|
|
138
|
+
viewBox: "0 0 24 24",
|
|
139
|
+
stroke: "currentColor"
|
|
140
|
+
},
|
|
141
|
+
[
|
|
142
|
+
vue.h("path", {
|
|
143
|
+
"stroke-linecap": "round",
|
|
144
|
+
"stroke-linejoin": "round",
|
|
145
|
+
"stroke-width": "2",
|
|
146
|
+
d: tigercatCore.uploadPlusIconPath
|
|
147
|
+
})
|
|
148
|
+
]
|
|
149
|
+
),
|
|
150
|
+
vue.h("span", null, "\u9009\u62E9\u56FE\u7247")
|
|
151
|
+
]
|
|
152
|
+
);
|
|
153
|
+
const modal = vue.h(
|
|
154
|
+
chunkW36SYMVH_js.Modal,
|
|
155
|
+
{
|
|
156
|
+
visible: modalVisible.value,
|
|
157
|
+
size: "lg",
|
|
158
|
+
title: props.modalTitle,
|
|
159
|
+
closable: true,
|
|
160
|
+
maskClosable: false,
|
|
161
|
+
showDefaultFooter: false,
|
|
162
|
+
"onUpdate:visible": (val) => {
|
|
163
|
+
if (!val) handleCancel();
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
default: () => imageSrc.value ? vue.h(chunkK2U3FEL7_js.ImageCropper, {
|
|
168
|
+
ref: cropperRef,
|
|
169
|
+
src: imageSrc.value,
|
|
170
|
+
...props.cropperProps
|
|
171
|
+
}) : null,
|
|
172
|
+
footer: ({ cancel }) => vue.h("div", { class: tigercatCore.modalFooterClasses }, [
|
|
173
|
+
vue.h(chunkDELTFEEJ_js.Button, { variant: "secondary", onClick: handleCancel }, { default: () => "\u53D6\u6D88" }),
|
|
174
|
+
vue.h(
|
|
175
|
+
chunkDELTFEEJ_js.Button,
|
|
176
|
+
{ onClick: handleConfirm, loading: cropping.value },
|
|
177
|
+
{ default: () => "\u786E\u8BA4\u88C1\u526A" }
|
|
178
|
+
)
|
|
179
|
+
])
|
|
180
|
+
}
|
|
181
|
+
);
|
|
182
|
+
return vue.h("div", { class: "tiger-crop-upload inline-block" }, [fileInput, trigger, modal]);
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
var CropUpload_default = CropUpload;
|
|
187
|
+
|
|
188
|
+
exports.CropUpload = CropUpload;
|
|
189
|
+
exports.CropUpload_default = CropUpload_default;
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { Modal } from './chunk-P47EXOAW.mjs';
|
|
2
|
+
import { ImageCropper } from './chunk-T77L326M.mjs';
|
|
3
|
+
import { Button } from './chunk-D6MR5YRE.mjs';
|
|
4
|
+
import { defineComponent, ref, computed, h } from 'vue';
|
|
5
|
+
import { classNames, cropUploadTriggerDisabledClasses, cropUploadTriggerClasses, coerceClassValue, mergeStyleValues, uploadPlusIconPath, modalFooterClasses } from '@expcat/tigercat-core';
|
|
6
|
+
|
|
7
|
+
var CropUpload = defineComponent({
|
|
8
|
+
name: "TigerCropUpload",
|
|
9
|
+
inheritAttrs: false,
|
|
10
|
+
props: {
|
|
11
|
+
accept: { type: String, default: "image/*" },
|
|
12
|
+
disabled: { type: Boolean, default: false },
|
|
13
|
+
maxSize: { type: Number, default: void 0 },
|
|
14
|
+
cropperProps: {
|
|
15
|
+
type: Object,
|
|
16
|
+
default: void 0
|
|
17
|
+
},
|
|
18
|
+
modalTitle: { type: String, default: "\u88C1\u526A\u56FE\u7247" },
|
|
19
|
+
modalWidth: { type: Number, default: 520 },
|
|
20
|
+
className: { type: String, default: void 0 },
|
|
21
|
+
style: {
|
|
22
|
+
type: Object,
|
|
23
|
+
default: void 0
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
emits: ["crop-complete", "error"],
|
|
27
|
+
setup(props, { slots, emit, attrs }) {
|
|
28
|
+
const fileInputRef = ref(null);
|
|
29
|
+
const modalVisible = ref(false);
|
|
30
|
+
const imageSrc = ref("");
|
|
31
|
+
const cropperRef = ref(null);
|
|
32
|
+
const cropping = ref(false);
|
|
33
|
+
const handleTriggerClick = () => {
|
|
34
|
+
if (props.disabled) return;
|
|
35
|
+
fileInputRef.value?.click();
|
|
36
|
+
};
|
|
37
|
+
const handleFileChange = (e) => {
|
|
38
|
+
const input = e.target;
|
|
39
|
+
const file = input.files?.[0];
|
|
40
|
+
if (!file) return;
|
|
41
|
+
if (props.maxSize && file.size > props.maxSize) {
|
|
42
|
+
emit("error", new Error(`File size exceeds maximum of ${props.maxSize} bytes`));
|
|
43
|
+
input.value = "";
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const reader = new FileReader();
|
|
47
|
+
reader.onload = (ev) => {
|
|
48
|
+
imageSrc.value = ev.target?.result;
|
|
49
|
+
modalVisible.value = true;
|
|
50
|
+
};
|
|
51
|
+
reader.readAsDataURL(file);
|
|
52
|
+
input.value = "";
|
|
53
|
+
};
|
|
54
|
+
const handleConfirm = async () => {
|
|
55
|
+
if (!cropperRef.value) return;
|
|
56
|
+
cropping.value = true;
|
|
57
|
+
try {
|
|
58
|
+
const result = await cropperRef.value.getCropResult();
|
|
59
|
+
emit("crop-complete", result);
|
|
60
|
+
modalVisible.value = false;
|
|
61
|
+
} catch (err) {
|
|
62
|
+
emit("error", err);
|
|
63
|
+
} finally {
|
|
64
|
+
cropping.value = false;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
const handleCancel = () => {
|
|
68
|
+
modalVisible.value = false;
|
|
69
|
+
imageSrc.value = "";
|
|
70
|
+
};
|
|
71
|
+
const triggerClasses = computed(
|
|
72
|
+
() => classNames(
|
|
73
|
+
props.disabled ? cropUploadTriggerDisabledClasses : cropUploadTriggerClasses,
|
|
74
|
+
props.className,
|
|
75
|
+
coerceClassValue(attrs.class)
|
|
76
|
+
)
|
|
77
|
+
);
|
|
78
|
+
const triggerStyle = computed(
|
|
79
|
+
() => mergeStyleValues(attrs.style, props.style)
|
|
80
|
+
);
|
|
81
|
+
return () => {
|
|
82
|
+
const forwardedAttrs = Object.fromEntries(
|
|
83
|
+
Object.entries(attrs).filter(([key]) => key !== "class" && key !== "style")
|
|
84
|
+
);
|
|
85
|
+
const fileInput = h("input", {
|
|
86
|
+
ref: fileInputRef,
|
|
87
|
+
type: "file",
|
|
88
|
+
accept: props.accept,
|
|
89
|
+
style: { display: "none" },
|
|
90
|
+
onChange: handleFileChange
|
|
91
|
+
});
|
|
92
|
+
const trigger = slots.default ? h(
|
|
93
|
+
"div",
|
|
94
|
+
{
|
|
95
|
+
...forwardedAttrs,
|
|
96
|
+
class: triggerClasses.value,
|
|
97
|
+
style: triggerStyle.value,
|
|
98
|
+
onClick: handleTriggerClick,
|
|
99
|
+
role: "button",
|
|
100
|
+
tabindex: props.disabled ? -1 : 0,
|
|
101
|
+
"aria-label": "Select image to crop and upload",
|
|
102
|
+
"aria-disabled": props.disabled ? "true" : void 0,
|
|
103
|
+
onKeydown: (e) => {
|
|
104
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
105
|
+
e.preventDefault();
|
|
106
|
+
handleTriggerClick();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
slots.default()
|
|
111
|
+
) : h(
|
|
112
|
+
"div",
|
|
113
|
+
{
|
|
114
|
+
...forwardedAttrs,
|
|
115
|
+
class: triggerClasses.value,
|
|
116
|
+
style: triggerStyle.value,
|
|
117
|
+
onClick: handleTriggerClick,
|
|
118
|
+
role: "button",
|
|
119
|
+
tabindex: props.disabled ? -1 : 0,
|
|
120
|
+
"aria-label": "Select image to crop and upload",
|
|
121
|
+
"aria-disabled": props.disabled ? "true" : void 0,
|
|
122
|
+
onKeydown: (e) => {
|
|
123
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
124
|
+
e.preventDefault();
|
|
125
|
+
handleTriggerClick();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
[
|
|
130
|
+
h(
|
|
131
|
+
"svg",
|
|
132
|
+
{
|
|
133
|
+
class: "w-5 h-5",
|
|
134
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
135
|
+
fill: "none",
|
|
136
|
+
viewBox: "0 0 24 24",
|
|
137
|
+
stroke: "currentColor"
|
|
138
|
+
},
|
|
139
|
+
[
|
|
140
|
+
h("path", {
|
|
141
|
+
"stroke-linecap": "round",
|
|
142
|
+
"stroke-linejoin": "round",
|
|
143
|
+
"stroke-width": "2",
|
|
144
|
+
d: uploadPlusIconPath
|
|
145
|
+
})
|
|
146
|
+
]
|
|
147
|
+
),
|
|
148
|
+
h("span", null, "\u9009\u62E9\u56FE\u7247")
|
|
149
|
+
]
|
|
150
|
+
);
|
|
151
|
+
const modal = h(
|
|
152
|
+
Modal,
|
|
153
|
+
{
|
|
154
|
+
visible: modalVisible.value,
|
|
155
|
+
size: "lg",
|
|
156
|
+
title: props.modalTitle,
|
|
157
|
+
closable: true,
|
|
158
|
+
maskClosable: false,
|
|
159
|
+
showDefaultFooter: false,
|
|
160
|
+
"onUpdate:visible": (val) => {
|
|
161
|
+
if (!val) handleCancel();
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
default: () => imageSrc.value ? h(ImageCropper, {
|
|
166
|
+
ref: cropperRef,
|
|
167
|
+
src: imageSrc.value,
|
|
168
|
+
...props.cropperProps
|
|
169
|
+
}) : null,
|
|
170
|
+
footer: ({ cancel }) => h("div", { class: modalFooterClasses }, [
|
|
171
|
+
h(Button, { variant: "secondary", onClick: handleCancel }, { default: () => "\u53D6\u6D88" }),
|
|
172
|
+
h(
|
|
173
|
+
Button,
|
|
174
|
+
{ onClick: handleConfirm, loading: cropping.value },
|
|
175
|
+
{ default: () => "\u786E\u8BA4\u88C1\u526A" }
|
|
176
|
+
)
|
|
177
|
+
])
|
|
178
|
+
}
|
|
179
|
+
);
|
|
180
|
+
return h("div", { class: "tiger-crop-upload inline-block" }, [fileInput, trigger, modal]);
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
var CropUpload_default = CropUpload;
|
|
185
|
+
|
|
186
|
+
export { CropUpload, CropUpload_default };
|