@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.
Files changed (221) hide show
  1. package/dist/chunk-53M2BTB5.mjs +22 -0
  2. package/dist/chunk-7AFJ7TKW.js +266 -0
  3. package/dist/chunk-GNKXBRXH.js +189 -0
  4. package/dist/chunk-HTMTOXUO.mjs +186 -0
  5. package/dist/chunk-K2U3FEL7.js +373 -0
  6. package/dist/chunk-K6HDRMPN.js +197 -0
  7. package/dist/chunk-LDCTSE6Y.mjs +60 -0
  8. package/dist/chunk-LNWRZKX2.js +64 -0
  9. package/dist/chunk-MB7W46IY.mjs +193 -0
  10. package/dist/chunk-MMQ34S5M.mjs +263 -0
  11. package/dist/chunk-PNKVD2UK.js +26 -0
  12. package/dist/chunk-T77L326M.mjs +370 -0
  13. package/dist/components/ActivityFeed.js +5 -4
  14. package/dist/components/ActivityFeed.mjs +3 -2
  15. package/dist/components/Alert.js +1 -0
  16. package/dist/components/Alert.mjs +1 -0
  17. package/dist/components/Anchor.js +1 -0
  18. package/dist/components/Anchor.mjs +1 -0
  19. package/dist/components/AnchorLink.js +1 -0
  20. package/dist/components/AnchorLink.mjs +1 -0
  21. package/dist/components/AreaChart.js +1 -0
  22. package/dist/components/AreaChart.mjs +1 -0
  23. package/dist/components/Avatar.js +1 -0
  24. package/dist/components/Avatar.mjs +1 -0
  25. package/dist/components/BackTop.js +1 -0
  26. package/dist/components/BackTop.mjs +1 -0
  27. package/dist/components/Badge.js +1 -0
  28. package/dist/components/Badge.mjs +1 -0
  29. package/dist/components/BarChart.js +1 -0
  30. package/dist/components/BarChart.mjs +1 -0
  31. package/dist/components/Breadcrumb.js +1 -0
  32. package/dist/components/Breadcrumb.mjs +1 -0
  33. package/dist/components/BreadcrumbItem.js +1 -0
  34. package/dist/components/BreadcrumbItem.mjs +1 -0
  35. package/dist/components/Button.js +1 -0
  36. package/dist/components/Button.mjs +1 -0
  37. package/dist/components/Card.js +1 -0
  38. package/dist/components/Card.mjs +1 -0
  39. package/dist/components/Carousel.js +1 -0
  40. package/dist/components/Carousel.mjs +1 -0
  41. package/dist/components/ChartAxis.js +1 -0
  42. package/dist/components/ChartAxis.mjs +1 -0
  43. package/dist/components/ChartCanvas.js +1 -0
  44. package/dist/components/ChartCanvas.mjs +1 -0
  45. package/dist/components/ChartGrid.js +1 -0
  46. package/dist/components/ChartGrid.mjs +1 -0
  47. package/dist/components/ChartLegend.js +1 -0
  48. package/dist/components/ChartLegend.mjs +1 -0
  49. package/dist/components/ChartSeries.js +1 -0
  50. package/dist/components/ChartSeries.mjs +1 -0
  51. package/dist/components/ChartTooltip.js +1 -0
  52. package/dist/components/ChartTooltip.mjs +1 -0
  53. package/dist/components/ChatWindow.js +1 -0
  54. package/dist/components/ChatWindow.mjs +1 -0
  55. package/dist/components/Checkbox.js +1 -0
  56. package/dist/components/Checkbox.mjs +1 -0
  57. package/dist/components/CheckboxGroup.js +1 -0
  58. package/dist/components/CheckboxGroup.mjs +1 -0
  59. package/dist/components/Code.js +1 -0
  60. package/dist/components/Code.mjs +1 -0
  61. package/dist/components/Col.js +1 -0
  62. package/dist/components/Col.mjs +1 -0
  63. package/dist/components/Collapse.js +1 -0
  64. package/dist/components/Collapse.mjs +1 -0
  65. package/dist/components/CollapsePanel.js +1 -0
  66. package/dist/components/CollapsePanel.mjs +1 -0
  67. package/dist/components/CommentThread.js +1 -0
  68. package/dist/components/CommentThread.mjs +1 -0
  69. package/dist/components/ConfigProvider.js +1 -0
  70. package/dist/components/ConfigProvider.mjs +1 -0
  71. package/dist/components/Container.js +1 -0
  72. package/dist/components/Container.mjs +1 -0
  73. package/dist/components/Content.js +1 -0
  74. package/dist/components/Content.mjs +1 -0
  75. package/dist/components/CropUpload.d.mts +97 -0
  76. package/dist/components/CropUpload.d.ts +97 -0
  77. package/dist/components/CropUpload.js +20 -0
  78. package/dist/components/CropUpload.mjs +5 -0
  79. package/dist/components/DataTableWithToolbar.js +1 -0
  80. package/dist/components/DataTableWithToolbar.mjs +1 -0
  81. package/dist/components/DatePicker.js +1 -0
  82. package/dist/components/DatePicker.mjs +1 -0
  83. package/dist/components/Descriptions.js +1 -0
  84. package/dist/components/Descriptions.mjs +1 -0
  85. package/dist/components/Divider.js +1 -0
  86. package/dist/components/Divider.mjs +1 -0
  87. package/dist/components/DonutChart.js +1 -0
  88. package/dist/components/DonutChart.mjs +1 -0
  89. package/dist/components/Drawer.d.mts +2 -2
  90. package/dist/components/Drawer.d.ts +2 -2
  91. package/dist/components/Drawer.js +1 -0
  92. package/dist/components/Drawer.mjs +1 -0
  93. package/dist/components/Dropdown.js +1 -0
  94. package/dist/components/Dropdown.mjs +1 -0
  95. package/dist/components/DropdownItem.js +1 -0
  96. package/dist/components/DropdownItem.mjs +1 -0
  97. package/dist/components/DropdownMenu.js +1 -0
  98. package/dist/components/DropdownMenu.mjs +1 -0
  99. package/dist/components/Footer.js +1 -0
  100. package/dist/components/Footer.mjs +1 -0
  101. package/dist/components/Form.js +1 -0
  102. package/dist/components/Form.mjs +1 -0
  103. package/dist/components/FormItem.js +1 -0
  104. package/dist/components/FormItem.mjs +1 -0
  105. package/dist/components/FormWizard.js +1 -0
  106. package/dist/components/FormWizard.mjs +1 -0
  107. package/dist/components/Header.js +1 -0
  108. package/dist/components/Header.mjs +1 -0
  109. package/dist/components/Icon.js +1 -0
  110. package/dist/components/Icon.mjs +1 -0
  111. package/dist/components/Image.d.mts +119 -0
  112. package/dist/components/Image.d.ts +119 -0
  113. package/dist/components/Image.js +22 -0
  114. package/dist/components/Image.mjs +3 -0
  115. package/dist/components/ImageCropper.d.mts +105 -0
  116. package/dist/components/ImageCropper.d.ts +105 -0
  117. package/dist/components/ImageCropper.js +17 -0
  118. package/dist/components/ImageCropper.mjs +2 -0
  119. package/dist/components/ImageGroup.d.mts +30 -0
  120. package/dist/components/ImageGroup.d.ts +30 -0
  121. package/dist/components/ImageGroup.js +22 -0
  122. package/dist/components/ImageGroup.mjs +3 -0
  123. package/dist/components/ImagePreview.d.mts +97 -0
  124. package/dist/components/ImagePreview.d.ts +97 -0
  125. package/dist/components/ImagePreview.js +17 -0
  126. package/dist/components/ImagePreview.mjs +5 -0
  127. package/dist/components/Input.js +1 -0
  128. package/dist/components/Input.mjs +1 -0
  129. package/dist/components/Layout.js +1 -0
  130. package/dist/components/Layout.mjs +1 -0
  131. package/dist/components/LineChart.js +1 -0
  132. package/dist/components/LineChart.mjs +1 -0
  133. package/dist/components/Link.js +1 -0
  134. package/dist/components/Link.mjs +1 -0
  135. package/dist/components/List.js +1 -0
  136. package/dist/components/List.mjs +1 -0
  137. package/dist/components/Loading.js +1 -0
  138. package/dist/components/Loading.mjs +1 -0
  139. package/dist/components/Menu.js +1 -0
  140. package/dist/components/Menu.mjs +1 -0
  141. package/dist/components/MenuItem.js +1 -0
  142. package/dist/components/MenuItem.mjs +1 -0
  143. package/dist/components/MenuItemGroup.js +1 -0
  144. package/dist/components/MenuItemGroup.mjs +1 -0
  145. package/dist/components/Message.js +1 -0
  146. package/dist/components/Message.mjs +1 -0
  147. package/dist/components/Modal.d.mts +2 -2
  148. package/dist/components/Modal.d.ts +2 -2
  149. package/dist/components/Modal.js +1 -0
  150. package/dist/components/Modal.mjs +1 -0
  151. package/dist/components/Notification.js +1 -0
  152. package/dist/components/Notification.mjs +1 -0
  153. package/dist/components/NotificationCenter.js +1 -0
  154. package/dist/components/NotificationCenter.mjs +1 -0
  155. package/dist/components/Pagination.js +1 -0
  156. package/dist/components/Pagination.mjs +1 -0
  157. package/dist/components/PieChart.js +1 -0
  158. package/dist/components/PieChart.mjs +1 -0
  159. package/dist/components/Popconfirm.js +1 -0
  160. package/dist/components/Popconfirm.mjs +1 -0
  161. package/dist/components/Popover.js +1 -0
  162. package/dist/components/Popover.mjs +1 -0
  163. package/dist/components/Progress.js +1 -0
  164. package/dist/components/Progress.mjs +1 -0
  165. package/dist/components/RadarChart.js +1 -0
  166. package/dist/components/RadarChart.mjs +1 -0
  167. package/dist/components/Radio.js +1 -0
  168. package/dist/components/Radio.mjs +1 -0
  169. package/dist/components/RadioGroup.js +1 -0
  170. package/dist/components/RadioGroup.mjs +1 -0
  171. package/dist/components/Row.js +1 -0
  172. package/dist/components/Row.mjs +1 -0
  173. package/dist/components/ScatterChart.js +1 -0
  174. package/dist/components/ScatterChart.mjs +1 -0
  175. package/dist/components/Select.js +1 -0
  176. package/dist/components/Select.mjs +1 -0
  177. package/dist/components/Sidebar.js +1 -0
  178. package/dist/components/Sidebar.mjs +1 -0
  179. package/dist/components/Skeleton.js +1 -0
  180. package/dist/components/Skeleton.mjs +1 -0
  181. package/dist/components/Slider.js +1 -0
  182. package/dist/components/Slider.mjs +1 -0
  183. package/dist/components/Space.js +1 -0
  184. package/dist/components/Space.mjs +1 -0
  185. package/dist/components/Steps.js +1 -0
  186. package/dist/components/Steps.mjs +1 -0
  187. package/dist/components/StepsItem.js +1 -0
  188. package/dist/components/StepsItem.mjs +1 -0
  189. package/dist/components/SubMenu.js +1 -0
  190. package/dist/components/SubMenu.mjs +1 -0
  191. package/dist/components/Switch.js +1 -0
  192. package/dist/components/Switch.mjs +1 -0
  193. package/dist/components/TabPane.js +1 -0
  194. package/dist/components/TabPane.mjs +1 -0
  195. package/dist/components/Table.js +1 -0
  196. package/dist/components/Table.mjs +1 -0
  197. package/dist/components/Tabs.js +1 -0
  198. package/dist/components/Tabs.mjs +1 -0
  199. package/dist/components/Tag.js +1 -0
  200. package/dist/components/Tag.mjs +1 -0
  201. package/dist/components/Text.js +1 -0
  202. package/dist/components/Text.mjs +1 -0
  203. package/dist/components/Textarea.js +1 -0
  204. package/dist/components/Textarea.mjs +1 -0
  205. package/dist/components/TimePicker.js +1 -0
  206. package/dist/components/TimePicker.mjs +1 -0
  207. package/dist/components/Timeline.js +1 -0
  208. package/dist/components/Timeline.mjs +1 -0
  209. package/dist/components/Tooltip.js +1 -0
  210. package/dist/components/Tooltip.mjs +1 -0
  211. package/dist/components/Tree.js +1 -0
  212. package/dist/components/Tree.mjs +1 -0
  213. package/dist/components/Upload.js +1 -0
  214. package/dist/components/Upload.mjs +1 -0
  215. package/dist/index.d.mts +5 -0
  216. package/dist/index.d.ts +5 -0
  217. package/dist/index.js +98 -70
  218. package/dist/index.mjs +26 -17
  219. package/package.json +2 -2
  220. package/dist/{chunk-RVEEEDJQ.mjs → chunk-D7VMY6WX.mjs} +1 -1
  221. 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;