@expcat/tigercat-vue 0.3.69 → 0.4.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/chunk-53M2BTB5.mjs +22 -0
- package/dist/chunk-7AFJ7TKW.js +266 -0
- package/dist/chunk-GNKXBRXH.js +189 -0
- package/dist/chunk-HFBRO2IF.mjs +440 -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/chunk-YQGKXFV5.js +443 -0
- package/dist/components/ActivityFeed.d.mts +1 -1
- package/dist/components/ActivityFeed.d.ts +1 -1
- package/dist/components/ActivityFeed.js +5 -4
- package/dist/components/ActivityFeed.mjs +3 -2
- package/dist/components/Alert.d.mts +1 -1
- package/dist/components/Alert.d.ts +1 -1
- package/dist/components/Alert.js +1 -0
- package/dist/components/Alert.mjs +1 -0
- package/dist/components/Anchor.d.mts +5 -5
- package/dist/components/Anchor.d.ts +5 -5
- package/dist/components/Anchor.js +1 -0
- package/dist/components/Anchor.mjs +1 -0
- package/dist/components/AnchorLink.d.mts +1 -1
- package/dist/components/AnchorLink.d.ts +1 -1
- 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.d.mts +2 -2
- package/dist/components/Avatar.d.ts +2 -2
- package/dist/components/Avatar.js +1 -0
- package/dist/components/Avatar.mjs +1 -0
- package/dist/components/BackTop.d.mts +1 -1
- package/dist/components/BackTop.d.ts +1 -1
- package/dist/components/BackTop.js +1 -0
- package/dist/components/BackTop.mjs +1 -0
- package/dist/components/Badge.d.mts +1 -1
- package/dist/components/Badge.d.ts +1 -1
- 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.d.mts +1 -1
- package/dist/components/Breadcrumb.d.ts +1 -1
- package/dist/components/Breadcrumb.js +1 -0
- package/dist/components/Breadcrumb.mjs +1 -0
- package/dist/components/BreadcrumbItem.d.mts +1 -1
- package/dist/components/BreadcrumbItem.d.ts +1 -1
- package/dist/components/BreadcrumbItem.js +1 -0
- package/dist/components/BreadcrumbItem.mjs +1 -0
- package/dist/components/Button.d.mts +2 -2
- package/dist/components/Button.d.ts +2 -2
- package/dist/components/Button.js +1 -0
- package/dist/components/Button.mjs +1 -0
- package/dist/components/Card.d.mts +1 -1
- package/dist/components/Card.d.ts +1 -1
- package/dist/components/Card.js +1 -0
- package/dist/components/Card.mjs +1 -0
- package/dist/components/Carousel.d.mts +2 -2
- package/dist/components/Carousel.d.ts +2 -2
- package/dist/components/Carousel.js +1 -0
- package/dist/components/Carousel.mjs +1 -0
- package/dist/components/ChartAxis.d.mts +1 -1
- package/dist/components/ChartAxis.d.ts +1 -1
- 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.d.mts +2 -2
- package/dist/components/ChartGrid.d.ts +2 -2
- 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.d.mts +1 -1
- package/dist/components/ChartTooltip.d.ts +1 -1
- package/dist/components/ChartTooltip.js +1 -0
- package/dist/components/ChartTooltip.mjs +1 -0
- package/dist/components/ChatWindow.d.mts +1 -1
- package/dist/components/ChatWindow.d.ts +1 -1
- 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.d.mts +1 -1
- package/dist/components/Code.d.ts +1 -1
- 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.d.mts +2 -2
- package/dist/components/Collapse.d.ts +2 -2
- package/dist/components/Collapse.js +1 -0
- package/dist/components/Collapse.mjs +1 -0
- package/dist/components/CollapsePanel.d.mts +2 -2
- package/dist/components/CollapsePanel.d.ts +2 -2
- package/dist/components/CollapsePanel.js +1 -0
- package/dist/components/CollapsePanel.mjs +1 -0
- package/dist/components/CommentThread.d.mts +1 -1
- package/dist/components/CommentThread.d.ts +1 -1
- 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.d.mts +1 -1
- package/dist/components/Content.d.ts +1 -1
- 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.d.mts +3 -3
- package/dist/components/DataTableWithToolbar.d.ts +3 -3
- package/dist/components/DataTableWithToolbar.js +1 -0
- package/dist/components/DataTableWithToolbar.mjs +1 -0
- package/dist/components/DatePicker.d.mts +1 -1
- package/dist/components/DatePicker.d.ts +1 -1
- package/dist/components/DatePicker.js +1 -0
- package/dist/components/DatePicker.mjs +1 -0
- package/dist/components/Descriptions.d.mts +1 -1
- package/dist/components/Descriptions.d.ts +1 -1
- 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 +5 -5
- package/dist/components/Drawer.d.ts +5 -5
- package/dist/components/Drawer.js +1 -0
- package/dist/components/Drawer.mjs +1 -0
- package/dist/components/Dropdown.d.mts +1 -1
- package/dist/components/Dropdown.d.ts +1 -1
- package/dist/components/Dropdown.js +1 -0
- package/dist/components/Dropdown.mjs +1 -0
- package/dist/components/DropdownItem.d.mts +1 -1
- package/dist/components/DropdownItem.d.ts +1 -1
- package/dist/components/DropdownItem.js +1 -0
- package/dist/components/DropdownItem.mjs +1 -0
- package/dist/components/DropdownMenu.d.mts +1 -1
- package/dist/components/DropdownMenu.d.ts +1 -1
- package/dist/components/DropdownMenu.js +1 -0
- package/dist/components/DropdownMenu.mjs +1 -0
- package/dist/components/Footer.d.mts +1 -1
- package/dist/components/Footer.d.ts +1 -1
- 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.d.mts +3 -3
- package/dist/components/FormWizard.d.ts +3 -3
- package/dist/components/FormWizard.js +1 -0
- package/dist/components/FormWizard.mjs +1 -0
- package/dist/components/Header.d.mts +1 -1
- package/dist/components/Header.d.ts +1 -1
- 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.d.mts +1 -1
- package/dist/components/Input.d.ts +1 -1
- package/dist/components/Input.js +1 -0
- package/dist/components/Input.mjs +1 -0
- package/dist/components/Layout.d.mts +1 -1
- package/dist/components/Layout.d.ts +1 -1
- 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.d.mts +2 -2
- package/dist/components/List.d.ts +2 -2
- package/dist/components/List.js +1 -0
- package/dist/components/List.mjs +1 -0
- package/dist/components/Loading.d.mts +2 -2
- package/dist/components/Loading.d.ts +2 -2
- package/dist/components/Loading.js +1 -0
- package/dist/components/Loading.mjs +1 -0
- package/dist/components/Menu.d.mts +1 -1
- package/dist/components/Menu.d.ts +1 -1
- package/dist/components/Menu.js +1 -0
- package/dist/components/Menu.mjs +1 -0
- package/dist/components/MenuItem.d.mts +1 -1
- package/dist/components/MenuItem.d.ts +1 -1
- package/dist/components/MenuItem.js +1 -0
- package/dist/components/MenuItem.mjs +1 -0
- package/dist/components/MenuItemGroup.d.mts +1 -1
- package/dist/components/MenuItemGroup.d.ts +1 -1
- 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 +5 -5
- package/dist/components/Modal.d.ts +5 -5
- 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.d.mts +1 -1
- package/dist/components/NotificationCenter.d.ts +1 -1
- package/dist/components/NotificationCenter.js +1 -0
- package/dist/components/NotificationCenter.mjs +1 -0
- package/dist/components/Pagination.d.mts +2 -2
- package/dist/components/Pagination.d.ts +2 -2
- 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.d.mts +1 -1
- package/dist/components/Popconfirm.d.ts +1 -1
- package/dist/components/Popconfirm.js +1 -0
- package/dist/components/Popconfirm.mjs +1 -0
- package/dist/components/Popover.d.mts +3 -3
- package/dist/components/Popover.d.ts +3 -3
- package/dist/components/Popover.js +1 -0
- package/dist/components/Popover.mjs +1 -0
- package/dist/components/Progress.d.mts +4 -4
- package/dist/components/Progress.d.ts +4 -4
- 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.d.mts +1 -1
- package/dist/components/Select.d.ts +1 -1
- package/dist/components/Select.js +1 -0
- package/dist/components/Select.mjs +1 -0
- package/dist/components/Sidebar.d.mts +1 -1
- package/dist/components/Sidebar.d.ts +1 -1
- package/dist/components/Sidebar.js +1 -0
- package/dist/components/Sidebar.mjs +1 -0
- package/dist/components/Skeleton.d.mts +1 -1
- package/dist/components/Skeleton.d.ts +1 -1
- package/dist/components/Skeleton.js +1 -0
- package/dist/components/Skeleton.mjs +1 -0
- package/dist/components/Slider.d.mts +1 -1
- package/dist/components/Slider.d.ts +1 -1
- package/dist/components/Slider.js +1 -0
- package/dist/components/Slider.mjs +1 -0
- package/dist/components/Space.d.mts +1 -1
- package/dist/components/Space.d.ts +1 -1
- package/dist/components/Space.js +1 -0
- package/dist/components/Space.mjs +1 -0
- package/dist/components/Steps.d.mts +2 -2
- package/dist/components/Steps.d.ts +2 -2
- package/dist/components/Steps.js +1 -0
- package/dist/components/Steps.mjs +1 -0
- package/dist/components/StepsItem.d.mts +1 -1
- package/dist/components/StepsItem.d.ts +1 -1
- package/dist/components/StepsItem.js +1 -0
- package/dist/components/StepsItem.mjs +1 -0
- package/dist/components/SubMenu.d.mts +1 -1
- package/dist/components/SubMenu.d.ts +1 -1
- 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.d.mts +1 -1
- package/dist/components/TabPane.d.ts +1 -1
- 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.d.mts +1 -1
- package/dist/components/Tabs.d.ts +1 -1
- package/dist/components/Tabs.js +1 -0
- package/dist/components/Tabs.mjs +1 -0
- package/dist/components/Tag.d.mts +1 -1
- package/dist/components/Tag.d.ts +1 -1
- package/dist/components/Tag.js +1 -0
- package/dist/components/Tag.mjs +1 -0
- package/dist/components/TaskBoard.d.mts +129 -0
- package/dist/components/TaskBoard.d.ts +129 -0
- package/dist/components/TaskBoard.js +18 -0
- package/dist/components/TaskBoard.mjs +3 -0
- package/dist/components/Text.js +1 -0
- package/dist/components/Text.mjs +1 -0
- package/dist/components/Textarea.d.mts +1 -1
- package/dist/components/Textarea.d.ts +1 -1
- package/dist/components/Textarea.js +1 -0
- package/dist/components/Textarea.mjs +1 -0
- package/dist/components/TimePicker.d.mts +2 -2
- package/dist/components/TimePicker.d.ts +2 -2
- package/dist/components/TimePicker.js +1 -0
- package/dist/components/TimePicker.mjs +1 -0
- package/dist/components/Timeline.d.mts +2 -2
- package/dist/components/Timeline.d.ts +2 -2
- package/dist/components/Timeline.js +1 -0
- package/dist/components/Timeline.mjs +1 -0
- package/dist/components/Tooltip.d.mts +1 -1
- package/dist/components/Tooltip.d.ts +1 -1
- 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.d.mts +3 -3
- package/dist/components/Upload.d.ts +3 -3
- package/dist/components/Upload.js +1 -0
- package/dist/components/Upload.mjs +1 -0
- package/dist/index.d.mts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +103 -70
- package/dist/index.mjs +27 -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,373 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var vue = require('vue');
|
|
4
|
+
var tigercatCore = require('@expcat/tigercat-core');
|
|
5
|
+
|
|
6
|
+
// src/components/ImageCropper.ts
|
|
7
|
+
var ImageCropper = vue.defineComponent({
|
|
8
|
+
name: "TigerImageCropper",
|
|
9
|
+
inheritAttrs: false,
|
|
10
|
+
props: {
|
|
11
|
+
src: { type: String, required: true },
|
|
12
|
+
aspectRatio: { type: Number, default: void 0 },
|
|
13
|
+
minWidth: { type: Number, default: 20 },
|
|
14
|
+
minHeight: { type: Number, default: 20 },
|
|
15
|
+
outputType: {
|
|
16
|
+
type: String,
|
|
17
|
+
default: "image/png"
|
|
18
|
+
},
|
|
19
|
+
quality: { type: Number, default: 0.92 },
|
|
20
|
+
guides: { type: Boolean, default: true },
|
|
21
|
+
className: { type: String, default: void 0 },
|
|
22
|
+
style: {
|
|
23
|
+
type: Object,
|
|
24
|
+
default: void 0
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
emits: ["crop-change", "ready"],
|
|
28
|
+
setup(props, { emit, attrs, expose }) {
|
|
29
|
+
const containerRef = vue.ref(null);
|
|
30
|
+
const imageRef = vue.ref(null);
|
|
31
|
+
const imageLoaded = vue.ref(false);
|
|
32
|
+
const displayWidth = vue.ref(0);
|
|
33
|
+
const displayHeight = vue.ref(0);
|
|
34
|
+
const cropRect = vue.ref({ x: 0, y: 0, width: 0, height: 0 });
|
|
35
|
+
const dragMode = vue.ref("none");
|
|
36
|
+
const activeHandle = vue.ref(null);
|
|
37
|
+
const dragStartPos = vue.ref({ x: 0, y: 0 });
|
|
38
|
+
const dragStartRect = vue.ref({ x: 0, y: 0, width: 0, height: 0 });
|
|
39
|
+
const loadImage = () => {
|
|
40
|
+
const img = new window.Image();
|
|
41
|
+
img.crossOrigin = "anonymous";
|
|
42
|
+
img.onload = () => {
|
|
43
|
+
imageRef.value = img;
|
|
44
|
+
if (containerRef.value) {
|
|
45
|
+
const containerW = containerRef.value.clientWidth;
|
|
46
|
+
const containerH = containerRef.value.clientHeight || 400;
|
|
47
|
+
const ratio = Math.min(containerW / img.naturalWidth, containerH / img.naturalHeight, 1);
|
|
48
|
+
displayWidth.value = img.naturalWidth * ratio;
|
|
49
|
+
displayHeight.value = img.naturalHeight * ratio;
|
|
50
|
+
} else {
|
|
51
|
+
displayWidth.value = img.naturalWidth;
|
|
52
|
+
displayHeight.value = img.naturalHeight;
|
|
53
|
+
}
|
|
54
|
+
cropRect.value = tigercatCore.getInitialCropRect(
|
|
55
|
+
displayWidth.value,
|
|
56
|
+
displayHeight.value,
|
|
57
|
+
props.aspectRatio
|
|
58
|
+
);
|
|
59
|
+
imageLoaded.value = true;
|
|
60
|
+
emit("ready");
|
|
61
|
+
};
|
|
62
|
+
img.src = props.src;
|
|
63
|
+
};
|
|
64
|
+
vue.watch(
|
|
65
|
+
() => props.src,
|
|
66
|
+
() => {
|
|
67
|
+
imageLoaded.value = false;
|
|
68
|
+
loadImage();
|
|
69
|
+
}
|
|
70
|
+
);
|
|
71
|
+
vue.onMounted(() => {
|
|
72
|
+
loadImage();
|
|
73
|
+
});
|
|
74
|
+
const handleMouseDown = (e, mode, handle) => {
|
|
75
|
+
e.preventDefault();
|
|
76
|
+
e.stopPropagation();
|
|
77
|
+
dragMode.value = mode;
|
|
78
|
+
activeHandle.value = handle || null;
|
|
79
|
+
dragStartPos.value = { x: e.clientX, y: e.clientY };
|
|
80
|
+
dragStartRect.value = { ...cropRect.value };
|
|
81
|
+
const onMouseMove = (ev) => {
|
|
82
|
+
const dx = ev.clientX - dragStartPos.value.x;
|
|
83
|
+
const dy = ev.clientY - dragStartPos.value.y;
|
|
84
|
+
if (dragMode.value === "move") {
|
|
85
|
+
cropRect.value = tigercatCore.moveCropRect(
|
|
86
|
+
dragStartRect.value,
|
|
87
|
+
dx,
|
|
88
|
+
dy,
|
|
89
|
+
displayWidth.value,
|
|
90
|
+
displayHeight.value
|
|
91
|
+
);
|
|
92
|
+
} else if (dragMode.value === "resize" && activeHandle.value) {
|
|
93
|
+
cropRect.value = tigercatCore.resizeCropRect(
|
|
94
|
+
dragStartRect.value,
|
|
95
|
+
activeHandle.value,
|
|
96
|
+
dx,
|
|
97
|
+
dy,
|
|
98
|
+
displayWidth.value,
|
|
99
|
+
displayHeight.value,
|
|
100
|
+
props.aspectRatio,
|
|
101
|
+
props.minWidth,
|
|
102
|
+
props.minHeight
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
emit("crop-change", cropRect.value);
|
|
106
|
+
};
|
|
107
|
+
const onMouseUp = () => {
|
|
108
|
+
dragMode.value = "none";
|
|
109
|
+
activeHandle.value = null;
|
|
110
|
+
document.removeEventListener("mousemove", onMouseMove);
|
|
111
|
+
document.removeEventListener("mouseup", onMouseUp);
|
|
112
|
+
};
|
|
113
|
+
document.addEventListener("mousemove", onMouseMove);
|
|
114
|
+
document.addEventListener("mouseup", onMouseUp);
|
|
115
|
+
};
|
|
116
|
+
const handleTouchStart = (e, mode, handle) => {
|
|
117
|
+
if (e.touches.length !== 1) return;
|
|
118
|
+
e.preventDefault();
|
|
119
|
+
e.stopPropagation();
|
|
120
|
+
const touch = e.touches[0];
|
|
121
|
+
dragMode.value = mode;
|
|
122
|
+
activeHandle.value = handle || null;
|
|
123
|
+
dragStartPos.value = { x: touch.clientX, y: touch.clientY };
|
|
124
|
+
dragStartRect.value = { ...cropRect.value };
|
|
125
|
+
const onTouchMove = (ev) => {
|
|
126
|
+
if (ev.touches.length !== 1) return;
|
|
127
|
+
const t = ev.touches[0];
|
|
128
|
+
const dx = t.clientX - dragStartPos.value.x;
|
|
129
|
+
const dy = t.clientY - dragStartPos.value.y;
|
|
130
|
+
if (dragMode.value === "move") {
|
|
131
|
+
cropRect.value = tigercatCore.moveCropRect(
|
|
132
|
+
dragStartRect.value,
|
|
133
|
+
dx,
|
|
134
|
+
dy,
|
|
135
|
+
displayWidth.value,
|
|
136
|
+
displayHeight.value
|
|
137
|
+
);
|
|
138
|
+
} else if (dragMode.value === "resize" && activeHandle.value) {
|
|
139
|
+
cropRect.value = tigercatCore.resizeCropRect(
|
|
140
|
+
dragStartRect.value,
|
|
141
|
+
activeHandle.value,
|
|
142
|
+
dx,
|
|
143
|
+
dy,
|
|
144
|
+
displayWidth.value,
|
|
145
|
+
displayHeight.value,
|
|
146
|
+
props.aspectRatio,
|
|
147
|
+
props.minWidth,
|
|
148
|
+
props.minHeight
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
emit("crop-change", cropRect.value);
|
|
152
|
+
};
|
|
153
|
+
const onTouchEnd = () => {
|
|
154
|
+
dragMode.value = "none";
|
|
155
|
+
activeHandle.value = null;
|
|
156
|
+
document.removeEventListener("touchmove", onTouchMove);
|
|
157
|
+
document.removeEventListener("touchend", onTouchEnd);
|
|
158
|
+
};
|
|
159
|
+
document.addEventListener("touchmove", onTouchMove, { passive: false });
|
|
160
|
+
document.addEventListener("touchend", onTouchEnd);
|
|
161
|
+
};
|
|
162
|
+
const getCropResult = () => {
|
|
163
|
+
return new Promise((resolve, reject) => {
|
|
164
|
+
if (!imageRef.value) {
|
|
165
|
+
reject(new Error("Image not loaded"));
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
const { canvas, dataUrl } = tigercatCore.cropCanvas(
|
|
169
|
+
imageRef.value,
|
|
170
|
+
cropRect.value,
|
|
171
|
+
displayWidth.value,
|
|
172
|
+
displayHeight.value,
|
|
173
|
+
props.outputType,
|
|
174
|
+
props.quality
|
|
175
|
+
);
|
|
176
|
+
canvas.toBlob(
|
|
177
|
+
(blob) => {
|
|
178
|
+
if (blob) {
|
|
179
|
+
resolve({ canvas, blob, dataUrl, cropRect: { ...cropRect.value } });
|
|
180
|
+
} else {
|
|
181
|
+
reject(new Error("Failed to create blob"));
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
props.outputType,
|
|
185
|
+
props.quality
|
|
186
|
+
);
|
|
187
|
+
});
|
|
188
|
+
};
|
|
189
|
+
expose({ getCropResult });
|
|
190
|
+
const containerClasses = vue.computed(
|
|
191
|
+
() => tigercatCore.classNames(
|
|
192
|
+
tigercatCore.imageCropperContainerClasses,
|
|
193
|
+
props.className,
|
|
194
|
+
tigercatCore.coerceClassValue(attrs.class)
|
|
195
|
+
)
|
|
196
|
+
);
|
|
197
|
+
const containerStyle = vue.computed(
|
|
198
|
+
() => tigercatCore.mergeStyleValues(attrs.style, props.style)
|
|
199
|
+
);
|
|
200
|
+
return () => {
|
|
201
|
+
const forwardedAttrs = Object.fromEntries(
|
|
202
|
+
Object.entries(attrs).filter(([key]) => key !== "class" && key !== "style")
|
|
203
|
+
);
|
|
204
|
+
if (!imageLoaded.value) {
|
|
205
|
+
return vue.h(
|
|
206
|
+
"div",
|
|
207
|
+
{
|
|
208
|
+
...forwardedAttrs,
|
|
209
|
+
ref: containerRef,
|
|
210
|
+
class: tigercatCore.classNames(containerClasses.value, "flex items-center justify-center"),
|
|
211
|
+
style: Object.assign({}, containerStyle.value, {
|
|
212
|
+
minHeight: "200px"
|
|
213
|
+
}),
|
|
214
|
+
role: "img",
|
|
215
|
+
"aria-label": "Loading image for cropping"
|
|
216
|
+
},
|
|
217
|
+
[
|
|
218
|
+
vue.h("div", {
|
|
219
|
+
class: "w-8 h-8 border-2 border-white/30 border-t-white rounded-full animate-spin"
|
|
220
|
+
})
|
|
221
|
+
]
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
const cr = cropRect.value;
|
|
225
|
+
const img = vue.h("img", {
|
|
226
|
+
src: props.src,
|
|
227
|
+
class: tigercatCore.imageCropperImgClasses,
|
|
228
|
+
style: {
|
|
229
|
+
width: `${displayWidth.value}px`,
|
|
230
|
+
height: `${displayHeight.value}px`
|
|
231
|
+
},
|
|
232
|
+
draggable: false,
|
|
233
|
+
alt: "Image to crop"
|
|
234
|
+
});
|
|
235
|
+
const mask = vue.h(
|
|
236
|
+
"svg",
|
|
237
|
+
{
|
|
238
|
+
class: tigercatCore.imageCropperMaskClasses,
|
|
239
|
+
width: displayWidth.value,
|
|
240
|
+
height: displayHeight.value,
|
|
241
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
242
|
+
},
|
|
243
|
+
[
|
|
244
|
+
vue.h("defs", null, [
|
|
245
|
+
vue.h("mask", { id: "crop-mask" }, [
|
|
246
|
+
vue.h("rect", {
|
|
247
|
+
width: displayWidth.value,
|
|
248
|
+
height: displayHeight.value,
|
|
249
|
+
fill: "white"
|
|
250
|
+
}),
|
|
251
|
+
vue.h("rect", {
|
|
252
|
+
x: cr.x,
|
|
253
|
+
y: cr.y,
|
|
254
|
+
width: cr.width,
|
|
255
|
+
height: cr.height,
|
|
256
|
+
fill: "black"
|
|
257
|
+
})
|
|
258
|
+
])
|
|
259
|
+
]),
|
|
260
|
+
vue.h("rect", {
|
|
261
|
+
width: displayWidth.value,
|
|
262
|
+
height: displayHeight.value,
|
|
263
|
+
fill: "var(--tiger-image-cropper-mask, rgba(0,0,0,0.55))",
|
|
264
|
+
mask: "url(#crop-mask)"
|
|
265
|
+
})
|
|
266
|
+
]
|
|
267
|
+
);
|
|
268
|
+
const selection = vue.h("div", {
|
|
269
|
+
class: tigercatCore.imageCropperSelectionClasses,
|
|
270
|
+
style: {
|
|
271
|
+
left: `${cr.x}px`,
|
|
272
|
+
top: `${cr.y}px`,
|
|
273
|
+
width: `${cr.width}px`,
|
|
274
|
+
height: `${cr.height}px`
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
const dragArea = vue.h("div", {
|
|
278
|
+
class: tigercatCore.imageCropperDragAreaClasses,
|
|
279
|
+
style: {
|
|
280
|
+
left: `${cr.x}px`,
|
|
281
|
+
top: `${cr.y}px`,
|
|
282
|
+
width: `${cr.width}px`,
|
|
283
|
+
height: `${cr.height}px`
|
|
284
|
+
},
|
|
285
|
+
onMousedown: (e) => handleMouseDown(e, "move"),
|
|
286
|
+
onTouchstart: (e) => handleTouchStart(e, "move")
|
|
287
|
+
});
|
|
288
|
+
const guideLines = props.guides ? [
|
|
289
|
+
// Horizontal lines
|
|
290
|
+
vue.h("div", {
|
|
291
|
+
class: tigercatCore.imageCropperGuideClasses,
|
|
292
|
+
style: {
|
|
293
|
+
left: `${cr.x}px`,
|
|
294
|
+
top: `${cr.y + cr.height / 3}px`,
|
|
295
|
+
width: `${cr.width}px`,
|
|
296
|
+
height: "0px",
|
|
297
|
+
borderTopWidth: "1px",
|
|
298
|
+
borderTopStyle: "dashed"
|
|
299
|
+
}
|
|
300
|
+
}),
|
|
301
|
+
vue.h("div", {
|
|
302
|
+
class: tigercatCore.imageCropperGuideClasses,
|
|
303
|
+
style: {
|
|
304
|
+
left: `${cr.x}px`,
|
|
305
|
+
top: `${cr.y + cr.height * 2 / 3}px`,
|
|
306
|
+
width: `${cr.width}px`,
|
|
307
|
+
height: "0px",
|
|
308
|
+
borderTopWidth: "1px",
|
|
309
|
+
borderTopStyle: "dashed"
|
|
310
|
+
}
|
|
311
|
+
}),
|
|
312
|
+
// Vertical lines
|
|
313
|
+
vue.h("div", {
|
|
314
|
+
class: tigercatCore.imageCropperGuideClasses,
|
|
315
|
+
style: {
|
|
316
|
+
left: `${cr.x + cr.width / 3}px`,
|
|
317
|
+
top: `${cr.y}px`,
|
|
318
|
+
width: "0px",
|
|
319
|
+
height: `${cr.height}px`,
|
|
320
|
+
borderLeftWidth: "1px",
|
|
321
|
+
borderLeftStyle: "dashed"
|
|
322
|
+
}
|
|
323
|
+
}),
|
|
324
|
+
vue.h("div", {
|
|
325
|
+
class: tigercatCore.imageCropperGuideClasses,
|
|
326
|
+
style: {
|
|
327
|
+
left: `${cr.x + cr.width * 2 / 3}px`,
|
|
328
|
+
top: `${cr.y}px`,
|
|
329
|
+
width: "0px",
|
|
330
|
+
height: `${cr.height}px`,
|
|
331
|
+
borderLeftWidth: "1px",
|
|
332
|
+
borderLeftStyle: "dashed"
|
|
333
|
+
}
|
|
334
|
+
})
|
|
335
|
+
] : [];
|
|
336
|
+
const handles = tigercatCore.CROP_HANDLES.map((handle) => {
|
|
337
|
+
const pos = {};
|
|
338
|
+
if (handle.includes("n")) pos.top = `${cr.y}px`;
|
|
339
|
+
if (handle.includes("s")) pos.top = `${cr.y + cr.height}px`;
|
|
340
|
+
if (handle === "e" || handle === "w") pos.top = `${cr.y + cr.height / 2}px`;
|
|
341
|
+
if (handle.includes("w")) pos.left = `${cr.x}px`;
|
|
342
|
+
if (handle.includes("e")) pos.left = `${cr.x + cr.width}px`;
|
|
343
|
+
if (handle === "n" || handle === "s") pos.left = `${cr.x + cr.width / 2}px`;
|
|
344
|
+
return vue.h("div", {
|
|
345
|
+
class: tigercatCore.getCropperHandleClasses(handle),
|
|
346
|
+
style: pos,
|
|
347
|
+
onMousedown: (e) => handleMouseDown(e, "resize", handle),
|
|
348
|
+
onTouchstart: (e) => handleTouchStart(e, "resize", handle)
|
|
349
|
+
});
|
|
350
|
+
});
|
|
351
|
+
return vue.h(
|
|
352
|
+
"div",
|
|
353
|
+
{
|
|
354
|
+
...forwardedAttrs,
|
|
355
|
+
ref: containerRef,
|
|
356
|
+
class: containerClasses.value,
|
|
357
|
+
style: Object.assign({}, containerStyle.value, {
|
|
358
|
+
width: `${displayWidth.value}px`,
|
|
359
|
+
height: `${displayHeight.value}px`
|
|
360
|
+
}),
|
|
361
|
+
role: "application",
|
|
362
|
+
"aria-label": "Image cropper",
|
|
363
|
+
"aria-roledescription": "image cropper"
|
|
364
|
+
},
|
|
365
|
+
[img, mask, selection, dragArea, ...guideLines, ...handles]
|
|
366
|
+
);
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
});
|
|
370
|
+
var ImageCropper_default = ImageCropper;
|
|
371
|
+
|
|
372
|
+
exports.ImageCropper = ImageCropper;
|
|
373
|
+
exports.ImageCropper_default = ImageCropper_default;
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunk7AFJ7TKW_js = require('./chunk-7AFJ7TKW.js');
|
|
4
|
+
var chunkPNKVD2UK_js = require('./chunk-PNKVD2UK.js');
|
|
5
|
+
var vue = require('vue');
|
|
6
|
+
var tigercatCore = require('@expcat/tigercat-core');
|
|
7
|
+
|
|
8
|
+
var IMAGE_GROUP_INJECTION_KEY = "tiger-image-group";
|
|
9
|
+
var Image = vue.defineComponent({
|
|
10
|
+
name: "TigerImage",
|
|
11
|
+
inheritAttrs: false,
|
|
12
|
+
props: {
|
|
13
|
+
src: { type: String, default: void 0 },
|
|
14
|
+
alt: { type: String, default: "" },
|
|
15
|
+
width: { type: [Number, String], default: void 0 },
|
|
16
|
+
height: { type: [Number, String], default: void 0 },
|
|
17
|
+
fit: { type: String, default: "cover" },
|
|
18
|
+
fallbackSrc: { type: String, default: void 0 },
|
|
19
|
+
preview: { type: Boolean, default: true },
|
|
20
|
+
lazy: { type: Boolean, default: false },
|
|
21
|
+
className: { type: String, default: void 0 },
|
|
22
|
+
style: {
|
|
23
|
+
type: Object,
|
|
24
|
+
default: void 0
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
emits: ["load", "error", "preview-visible-change"],
|
|
28
|
+
setup(props, { slots, emit, attrs }) {
|
|
29
|
+
const loading = vue.ref(true);
|
|
30
|
+
const error = vue.ref(false);
|
|
31
|
+
const actualSrc = vue.ref(props.lazy ? "" : props.src);
|
|
32
|
+
const containerRef = vue.ref(null);
|
|
33
|
+
const previewVisible = vue.ref(false);
|
|
34
|
+
let observer = null;
|
|
35
|
+
const group = vue.inject(IMAGE_GROUP_INJECTION_KEY, null);
|
|
36
|
+
const registeredIndex = vue.ref(-1);
|
|
37
|
+
vue.onMounted(() => {
|
|
38
|
+
if (group && props.src) {
|
|
39
|
+
registeredIndex.value = group.register(props.src);
|
|
40
|
+
}
|
|
41
|
+
if (props.lazy && containerRef.value) {
|
|
42
|
+
observer = new IntersectionObserver(
|
|
43
|
+
(entries) => {
|
|
44
|
+
if (entries[0]?.isIntersecting) {
|
|
45
|
+
actualSrc.value = props.src;
|
|
46
|
+
observer?.disconnect();
|
|
47
|
+
observer = null;
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
{ threshold: 0.01 }
|
|
51
|
+
);
|
|
52
|
+
observer.observe(containerRef.value);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
vue.onBeforeUnmount(() => {
|
|
56
|
+
observer?.disconnect();
|
|
57
|
+
if (group && props.src) {
|
|
58
|
+
group.unregister(props.src);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
const handleLoad = () => {
|
|
62
|
+
loading.value = false;
|
|
63
|
+
error.value = false;
|
|
64
|
+
emit("load");
|
|
65
|
+
};
|
|
66
|
+
const handleError = () => {
|
|
67
|
+
loading.value = false;
|
|
68
|
+
error.value = true;
|
|
69
|
+
if (props.fallbackSrc && actualSrc.value !== props.fallbackSrc) {
|
|
70
|
+
actualSrc.value = props.fallbackSrc;
|
|
71
|
+
error.value = false;
|
|
72
|
+
loading.value = true;
|
|
73
|
+
}
|
|
74
|
+
emit("error");
|
|
75
|
+
};
|
|
76
|
+
const handleClick = () => {
|
|
77
|
+
if (!props.preview) return;
|
|
78
|
+
if (group) {
|
|
79
|
+
group.openPreview(registeredIndex.value >= 0 ? registeredIndex.value : 0);
|
|
80
|
+
} else {
|
|
81
|
+
previewVisible.value = true;
|
|
82
|
+
emit("preview-visible-change", true);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
const containerClasses = vue.computed(
|
|
86
|
+
() => tigercatCore.classNames(
|
|
87
|
+
tigercatCore.imageBaseClasses,
|
|
88
|
+
props.preview && tigercatCore.imagePreviewCursorClass,
|
|
89
|
+
props.className,
|
|
90
|
+
tigercatCore.coerceClassValue(attrs.class)
|
|
91
|
+
)
|
|
92
|
+
);
|
|
93
|
+
const containerStyle = vue.computed(() => {
|
|
94
|
+
const base = {};
|
|
95
|
+
const w = tigercatCore.toCSSSize(props.width);
|
|
96
|
+
const ht = tigercatCore.toCSSSize(props.height);
|
|
97
|
+
if (w) base.width = w;
|
|
98
|
+
if (ht) base.height = ht;
|
|
99
|
+
return tigercatCore.mergeStyleValues(attrs.style, props.style, base);
|
|
100
|
+
});
|
|
101
|
+
const imgClasses = vue.computed(() => tigercatCore.getImageImgClasses(props.fit));
|
|
102
|
+
return () => {
|
|
103
|
+
const forwardedAttrs = Object.fromEntries(
|
|
104
|
+
Object.entries(attrs).filter(([key]) => key !== "class" && key !== "style")
|
|
105
|
+
);
|
|
106
|
+
let content;
|
|
107
|
+
if (error.value && !props.fallbackSrc) {
|
|
108
|
+
content = slots.error ? slots.error() : vue.h("div", { class: tigercatCore.imageErrorClasses }, [
|
|
109
|
+
vue.h(
|
|
110
|
+
"svg",
|
|
111
|
+
{
|
|
112
|
+
class: "w-8 h-8",
|
|
113
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
114
|
+
fill: "none",
|
|
115
|
+
viewBox: "0 0 24 24",
|
|
116
|
+
stroke: "currentColor"
|
|
117
|
+
},
|
|
118
|
+
[
|
|
119
|
+
vue.h("path", {
|
|
120
|
+
"stroke-linecap": "round",
|
|
121
|
+
"stroke-linejoin": "round",
|
|
122
|
+
"stroke-width": "1.5",
|
|
123
|
+
d: tigercatCore.imageErrorIconPath
|
|
124
|
+
})
|
|
125
|
+
]
|
|
126
|
+
)
|
|
127
|
+
]);
|
|
128
|
+
} else if (loading.value && !actualSrc.value) {
|
|
129
|
+
content = slots.placeholder ? slots.placeholder() : vue.h("div", { class: tigercatCore.imageLoadingClasses }, [
|
|
130
|
+
vue.h(
|
|
131
|
+
"svg",
|
|
132
|
+
{
|
|
133
|
+
class: "w-8 h-8",
|
|
134
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
135
|
+
fill: "none",
|
|
136
|
+
viewBox: "0 0 24 24",
|
|
137
|
+
stroke: "currentColor"
|
|
138
|
+
},
|
|
139
|
+
[
|
|
140
|
+
vue.h("path", {
|
|
141
|
+
"stroke-linecap": "round",
|
|
142
|
+
"stroke-linejoin": "round",
|
|
143
|
+
"stroke-width": "1.5",
|
|
144
|
+
d: tigercatCore.imageErrorIconPath
|
|
145
|
+
})
|
|
146
|
+
]
|
|
147
|
+
)
|
|
148
|
+
]);
|
|
149
|
+
} else {
|
|
150
|
+
content = vue.h("img", {
|
|
151
|
+
src: actualSrc.value,
|
|
152
|
+
alt: props.alt,
|
|
153
|
+
class: imgClasses.value,
|
|
154
|
+
onLoad: handleLoad,
|
|
155
|
+
onError: handleError
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
const previewEl = !group && previewVisible.value && props.src ? (() => {
|
|
159
|
+
const { ImagePreview } = (chunk7AFJ7TKW_js.init_ImagePreview(), chunkPNKVD2UK_js.__toCommonJS(chunk7AFJ7TKW_js.ImagePreview_exports));
|
|
160
|
+
return vue.h(ImagePreview, {
|
|
161
|
+
visible: previewVisible.value,
|
|
162
|
+
images: [props.src],
|
|
163
|
+
currentIndex: 0,
|
|
164
|
+
"onUpdate:visible": (val) => {
|
|
165
|
+
previewVisible.value = val;
|
|
166
|
+
emit("preview-visible-change", val);
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
})() : null;
|
|
170
|
+
return vue.h(
|
|
171
|
+
"div",
|
|
172
|
+
{
|
|
173
|
+
...forwardedAttrs,
|
|
174
|
+
ref: containerRef,
|
|
175
|
+
class: containerClasses.value,
|
|
176
|
+
style: containerStyle.value,
|
|
177
|
+
role: props.preview ? "button" : void 0,
|
|
178
|
+
tabindex: props.preview ? 0 : void 0,
|
|
179
|
+
"aria-label": props.preview ? `Preview ${props.alt || "image"}` : void 0,
|
|
180
|
+
onClick: handleClick,
|
|
181
|
+
onKeydown: (e) => {
|
|
182
|
+
if (props.preview && (e.key === "Enter" || e.key === " ")) {
|
|
183
|
+
e.preventDefault();
|
|
184
|
+
handleClick();
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
[content, previewEl]
|
|
189
|
+
);
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
var Image_default = Image;
|
|
194
|
+
|
|
195
|
+
exports.IMAGE_GROUP_INJECTION_KEY = IMAGE_GROUP_INJECTION_KEY;
|
|
196
|
+
exports.Image = Image;
|
|
197
|
+
exports.Image_default = Image_default;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { init_ImagePreview, ImagePreview } from './chunk-MMQ34S5M.mjs';
|
|
2
|
+
import { defineComponent, ref, provide, onBeforeUnmount, h } from 'vue';
|
|
3
|
+
|
|
4
|
+
// src/components/ImageGroup.ts
|
|
5
|
+
init_ImagePreview();
|
|
6
|
+
var IMAGE_GROUP_INJECTION_KEY = "tiger-image-group";
|
|
7
|
+
var ImageGroup = defineComponent({
|
|
8
|
+
name: "TigerImageGroup",
|
|
9
|
+
props: {
|
|
10
|
+
preview: { type: Boolean, default: true }
|
|
11
|
+
},
|
|
12
|
+
emits: ["preview-visible-change"],
|
|
13
|
+
setup(props, { slots, emit }) {
|
|
14
|
+
const images = ref([]);
|
|
15
|
+
const previewVisible = ref(false);
|
|
16
|
+
const previewIndex = ref(0);
|
|
17
|
+
const context = {
|
|
18
|
+
register(src) {
|
|
19
|
+
const idx = images.value.length;
|
|
20
|
+
images.value.push(src);
|
|
21
|
+
return idx;
|
|
22
|
+
},
|
|
23
|
+
unregister(src) {
|
|
24
|
+
const idx = images.value.indexOf(src);
|
|
25
|
+
if (idx > -1) {
|
|
26
|
+
images.value.splice(idx, 1);
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
openPreview(index) {
|
|
30
|
+
if (!props.preview) return;
|
|
31
|
+
previewIndex.value = index;
|
|
32
|
+
previewVisible.value = true;
|
|
33
|
+
emit("preview-visible-change", true);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
provide(IMAGE_GROUP_INJECTION_KEY, context);
|
|
37
|
+
onBeforeUnmount(() => {
|
|
38
|
+
images.value = [];
|
|
39
|
+
});
|
|
40
|
+
return () => {
|
|
41
|
+
const children = slots.default?.();
|
|
42
|
+
const preview = props.preview ? h(ImagePreview, {
|
|
43
|
+
visible: previewVisible.value,
|
|
44
|
+
images: images.value,
|
|
45
|
+
currentIndex: previewIndex.value,
|
|
46
|
+
"onUpdate:visible": (val) => {
|
|
47
|
+
previewVisible.value = val;
|
|
48
|
+
if (!val) emit("preview-visible-change", false);
|
|
49
|
+
},
|
|
50
|
+
"onUpdate:currentIndex": (val) => {
|
|
51
|
+
previewIndex.value = val;
|
|
52
|
+
}
|
|
53
|
+
}) : null;
|
|
54
|
+
return h("div", { class: "tiger-image-group", role: "group" }, [children, preview]);
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
var ImageGroup_default = ImageGroup;
|
|
59
|
+
|
|
60
|
+
export { IMAGE_GROUP_INJECTION_KEY, ImageGroup, ImageGroup_default };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunk7AFJ7TKW_js = require('./chunk-7AFJ7TKW.js');
|
|
4
|
+
var vue = require('vue');
|
|
5
|
+
|
|
6
|
+
// src/components/ImageGroup.ts
|
|
7
|
+
chunk7AFJ7TKW_js.init_ImagePreview();
|
|
8
|
+
var IMAGE_GROUP_INJECTION_KEY = "tiger-image-group";
|
|
9
|
+
var ImageGroup = vue.defineComponent({
|
|
10
|
+
name: "TigerImageGroup",
|
|
11
|
+
props: {
|
|
12
|
+
preview: { type: Boolean, default: true }
|
|
13
|
+
},
|
|
14
|
+
emits: ["preview-visible-change"],
|
|
15
|
+
setup(props, { slots, emit }) {
|
|
16
|
+
const images = vue.ref([]);
|
|
17
|
+
const previewVisible = vue.ref(false);
|
|
18
|
+
const previewIndex = vue.ref(0);
|
|
19
|
+
const context = {
|
|
20
|
+
register(src) {
|
|
21
|
+
const idx = images.value.length;
|
|
22
|
+
images.value.push(src);
|
|
23
|
+
return idx;
|
|
24
|
+
},
|
|
25
|
+
unregister(src) {
|
|
26
|
+
const idx = images.value.indexOf(src);
|
|
27
|
+
if (idx > -1) {
|
|
28
|
+
images.value.splice(idx, 1);
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
openPreview(index) {
|
|
32
|
+
if (!props.preview) return;
|
|
33
|
+
previewIndex.value = index;
|
|
34
|
+
previewVisible.value = true;
|
|
35
|
+
emit("preview-visible-change", true);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
vue.provide(IMAGE_GROUP_INJECTION_KEY, context);
|
|
39
|
+
vue.onBeforeUnmount(() => {
|
|
40
|
+
images.value = [];
|
|
41
|
+
});
|
|
42
|
+
return () => {
|
|
43
|
+
const children = slots.default?.();
|
|
44
|
+
const preview = props.preview ? vue.h(chunk7AFJ7TKW_js.ImagePreview, {
|
|
45
|
+
visible: previewVisible.value,
|
|
46
|
+
images: images.value,
|
|
47
|
+
currentIndex: previewIndex.value,
|
|
48
|
+
"onUpdate:visible": (val) => {
|
|
49
|
+
previewVisible.value = val;
|
|
50
|
+
if (!val) emit("preview-visible-change", false);
|
|
51
|
+
},
|
|
52
|
+
"onUpdate:currentIndex": (val) => {
|
|
53
|
+
previewIndex.value = val;
|
|
54
|
+
}
|
|
55
|
+
}) : null;
|
|
56
|
+
return vue.h("div", { class: "tiger-image-group", role: "group" }, [children, preview]);
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
var ImageGroup_default = ImageGroup;
|
|
61
|
+
|
|
62
|
+
exports.IMAGE_GROUP_INJECTION_KEY = IMAGE_GROUP_INJECTION_KEY;
|
|
63
|
+
exports.ImageGroup = ImageGroup;
|
|
64
|
+
exports.ImageGroup_default = ImageGroup_default;
|