@layers-app/shared 0.2.5 → 0.2.7
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/assets/svg/flags/es.svg.js +4 -0
- package/dist/assets/svg/flags/ru.svg.js +4 -0
- package/dist/assets/svg/flags/us.svg.js +4 -0
- package/dist/assets/svg/globeIcon.svg.js +5 -0
- package/dist/assets/svg/socials/github.svg.js +5 -0
- package/dist/assets/svg/socials/instagram.svg.js +5 -0
- package/dist/assets/svg/socials/x.svg.js +5 -0
- package/dist/assets/svg/socials/youtube.svg.js +5 -0
- package/dist/components/AppContainer/components/AppSidebarButton.d.ts +1 -1
- package/dist/components/AppContainer/components/AppSidebarButton.d.ts.map +1 -1
- package/dist/components/AppContainer/components/AppSidebarButton.js +4 -4
- package/dist/components/AppContainer/components/AppsSidebar/AppsSection.js +22 -22
- package/dist/components/AppContainer/components/AppsSidebar/TopSection.d.ts.map +1 -1
- package/dist/components/AppContainer/components/AppsSidebar/TopSection.js +25 -25
- package/dist/components/AppContainer/components/AppsSidebar/UserSection.d.ts.map +1 -1
- package/dist/components/AppContainer/components/AppsSidebar/UserSection.js +40 -40
- package/dist/components/AppContainer/components/menus/HelpMenu/HelpMenu.js +1 -1
- package/dist/components/AppContainer/hooks/useAppContainer.d.ts +1 -1
- package/dist/components/AppContainer/hooks/useAppContainer.d.ts.map +1 -1
- package/dist/components/AppContainer/hooks/useAppContainer.js +49 -43
- package/dist/components/AppContainer/hooks/useAppContainerDataStore.d.ts.map +1 -1
- package/dist/components/AppContainer/hooks/useAppContainerDataStore.js +4 -2
- package/dist/components/AppContainer/types.d.ts +2 -0
- package/dist/components/AppContainer/types.d.ts.map +1 -1
- package/dist/components/AttachmentsGalleryModal/components/ShakePlayer/ShakaPlayer.d.ts.map +1 -1
- package/dist/components/FilePicker/FilePicker.d.ts +33 -2
- package/dist/components/FilePicker/FilePicker.d.ts.map +1 -1
- package/dist/components/FilePicker/FilePicker.js +161 -110
- package/dist/components/FilePicker/FilePicker.module.css.js +9 -7
- package/dist/components/FilePicker/FilePickerGoogleDrive.d.ts +22 -0
- package/dist/components/FilePicker/FilePickerGoogleDrive.d.ts.map +1 -0
- package/dist/components/FilePicker/FilePickerGoogleDrive.js +86 -0
- package/dist/components/FilePicker/FilePickerUnsplash.d.ts.map +1 -1
- package/dist/components/FilePicker/FilePickerUnsplash.js +69 -52
- package/dist/components/FormViewer/components/OneSlideLayput.js +39 -37
- package/dist/components/FormViewer/hooks/useCreateFormContext.d.ts.map +1 -1
- package/dist/components/FormViewer/hooks/useCreateFormContext.js +10 -10
- package/dist/components/FormViewer/hooks/useFormGlobalTheme.js +15 -15
- package/dist/components/FormViewer/hooks/useInterpolateText.js +3 -3
- package/dist/components/FormViewer/store/formStore.js +3 -3
- package/dist/components/FormViewer/store/formStoreApi.js +13 -13
- package/dist/components/FormViewer/store/selectors.js +1 -1
- package/dist/components/GroupAvatar/index.d.ts +1 -0
- package/dist/components/GroupAvatar/index.d.ts.map +1 -1
- package/dist/components/GroupAvatar/index.js +9 -8
- package/dist/components/ImageCropper/ImageCropper.d.ts +19 -0
- package/dist/components/ImageCropper/ImageCropper.d.ts.map +1 -0
- package/dist/components/ImageCropper/ImageCropper.js +358 -0
- package/dist/components/ImageCropper/ImageCropper.module.css.js +51 -0
- package/dist/components/ImageCropper/cropUtils.d.ts +22 -0
- package/dist/components/ImageCropper/cropUtils.d.ts.map +1 -0
- package/dist/components/ImageCropper/cropUtils.js +42 -0
- package/dist/components/ImageCropper/index.d.ts +4 -0
- package/dist/components/ImageCropper/index.d.ts.map +1 -0
- package/dist/components/ImageCropper/useCropInteraction.d.ts +28 -0
- package/dist/components/ImageCropper/useCropInteraction.d.ts.map +1 -0
- package/dist/components/ImageCropper/useCropInteraction.js +76 -0
- package/dist/components/IntegrationFlowAnimation/IntegrationFlowAnimation.d.ts +21 -0
- package/dist/components/IntegrationFlowAnimation/IntegrationFlowAnimation.d.ts.map +1 -0
- package/dist/components/IntegrationFlowAnimation/IntegrationFlowAnimation.js +73 -0
- package/dist/components/IntegrationFlowAnimation/IntegrationFlowAnimation.module.css.js +19 -0
- package/dist/components/IntegrationFlowAnimation/icons/GoogleDriveIcon.d.ts +6 -0
- package/dist/components/IntegrationFlowAnimation/icons/GoogleDriveIcon.d.ts.map +1 -0
- package/dist/components/IntegrationFlowAnimation/icons/GoogleDriveIcon.js +60 -0
- package/dist/components/IntegrationFlowAnimation/icons/LayersCubeIcon.d.ts +6 -0
- package/dist/components/IntegrationFlowAnimation/icons/LayersCubeIcon.d.ts.map +1 -0
- package/dist/components/IntegrationFlowAnimation/icons/LayersCubeIcon.js +21 -0
- package/dist/components/IntegrationFlowAnimation/icons/NotionIcon.d.ts +6 -0
- package/dist/components/IntegrationFlowAnimation/icons/NotionIcon.d.ts.map +1 -0
- package/dist/components/IntegrationFlowAnimation/icons/NotionIcon.js +35 -0
- package/dist/components/IntegrationFlowAnimation/icons/index.d.ts +4 -0
- package/dist/components/IntegrationFlowAnimation/icons/index.d.ts.map +1 -0
- package/dist/components/IntegrationFlowAnimation/index.d.ts +5 -0
- package/dist/components/IntegrationFlowAnimation/index.d.ts.map +1 -0
- package/dist/components/LanguagePicker/LanguagePicker.d.ts +2 -1
- package/dist/components/LanguagePicker/LanguagePicker.d.ts.map +1 -1
- package/dist/components/LanguagePicker/LanguagePicker.js +44 -31
- package/dist/components/LanguagePicker/LanguagePicker.module.css.js +6 -4
- package/dist/components/MediaLibrary/MediaLibrary.d.ts +3 -0
- package/dist/components/MediaLibrary/MediaLibrary.d.ts.map +1 -0
- package/dist/components/MediaLibrary/MediaLibrary.js +93 -0
- package/dist/components/MediaLibrary/MediaLibrary.module.css.js +17 -0
- package/dist/components/MediaLibrary/MediaLibraryBreadcrumbs.d.ts +8 -0
- package/dist/components/MediaLibrary/MediaLibraryBreadcrumbs.d.ts.map +1 -0
- package/dist/components/MediaLibrary/MediaLibraryBreadcrumbs.js +22 -0
- package/dist/components/MediaLibrary/MediaLibraryBrowser.d.ts +12 -0
- package/dist/components/MediaLibrary/MediaLibraryBrowser.d.ts.map +1 -0
- package/dist/components/MediaLibrary/MediaLibraryBrowser.js +52 -0
- package/dist/components/MediaLibrary/MediaLibraryRow.d.ts +9 -0
- package/dist/components/MediaLibrary/MediaLibraryRow.d.ts.map +1 -0
- package/dist/components/MediaLibrary/MediaLibraryRow.js +29 -0
- package/dist/components/MediaLibrary/index.d.ts +4 -0
- package/dist/components/MediaLibrary/index.d.ts.map +1 -0
- package/dist/components/MediaLibrary/types.d.ts +31 -0
- package/dist/components/MediaLibrary/types.d.ts.map +1 -0
- package/dist/components/NavMenu/components/NavMenuItem.d.ts.map +1 -1
- package/dist/components/NavMenu/components/NavMenuItem.js +53 -50
- package/dist/components/NavMenu/types.d.ts +1 -0
- package/dist/components/NavMenu/types.d.ts.map +1 -1
- package/dist/components/NoData/NoData.d.ts +6 -1
- package/dist/components/NoData/NoData.d.ts.map +1 -1
- package/dist/components/NoData/NoData.js +85 -82
- package/dist/components/SettingsSection/index.d.ts +12 -0
- package/dist/components/SettingsSection/index.d.ts.map +1 -0
- package/dist/components/SettingsSection/index.js +36 -0
- package/dist/components/SettingsSection/styles.module.css.js +7 -0
- package/dist/components/SocialLinkRow/index.d.ts +11 -0
- package/dist/components/SocialLinkRow/index.d.ts.map +1 -0
- package/dist/components/SocialLinkRow/index.js +131 -0
- package/dist/components/SortableList/components/SortableItem/SortableItem.js +3 -3
- package/dist/components/StorageUsageProgress/index.js +26 -24
- package/dist/components/TimezonePicker/index.d.ts +9 -0
- package/dist/components/TimezonePicker/index.d.ts.map +1 -0
- package/dist/components/TimezonePicker/index.js +91 -0
- package/dist/components/UserAvatar/index.d.ts.map +1 -1
- package/dist/components/UserAvatar/index.js +11 -10
- package/dist/components/WorkspaceMenu/WorkspaceItem.d.ts.map +1 -1
- package/dist/components/WorkspaceMenu/WorkspaceItem.js +18 -17
- package/dist/components/WorkspaceMenu/WorkspaceMenu.d.ts.map +1 -1
- package/dist/components/WorkspaceMenu/WorkspaceMenu.js +70 -69
- package/dist/components/modals/RemoveConfirmModal.js +1 -1
- package/dist/components/table/components/TableHeaders.js +3 -3
- package/dist/components/table/components/TablePanel.js +1 -1
- package/dist/components/table/helpers/columns.js +3 -3
- package/dist/components/table/hooks/TableProvider.js +3 -3
- package/dist/components/table/selectors.js +6 -6
- package/dist/helpers/getFileType.d.ts +1 -2
- package/dist/helpers/getFileType.d.ts.map +1 -1
- package/dist/helpers/getFileType.js +5 -6
- package/dist/helpers/showFeatureFeedback.d.ts +16 -0
- package/dist/helpers/showFeatureFeedback.d.ts.map +1 -0
- package/dist/helpers/showFeatureFeedback.js +109 -0
- package/dist/helpers/showFeatureFeedback.module.css.js +9 -0
- package/dist/helpers/showNotifications.d.ts +14 -3
- package/dist/helpers/showNotifications.d.ts.map +1 -1
- package/dist/helpers/showNotifications.js +120 -61
- package/dist/helpers/showNotifications.module.css.js +29 -0
- package/dist/helpers/timezones.d.ts +12 -0
- package/dist/helpers/timezones.d.ts.map +1 -0
- package/dist/helpers/timezones.js +59 -0
- package/dist/hooks/useFeatureFeedback.d.ts +23 -0
- package/dist/hooks/useFeatureFeedback.d.ts.map +1 -0
- package/dist/hooks/useFeatureFeedback.js +48 -0
- package/dist/hooks/useNumberQueryParam.js +3 -3
- package/dist/hooks/useVideoUploadGuard.d.ts +2 -0
- package/dist/hooks/useVideoUploadGuard.d.ts.map +1 -0
- package/dist/hooks/useVideoUploadGuard.js +24 -0
- package/dist/index.css +1 -1
- package/dist/index.d.ts +13 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +461 -406
- package/dist/lang/locales/ui_en.json.js +24 -22
- package/dist/lang/locales/ui_es.json.js +20 -18
- package/dist/lang/locales/ui_ru.json.js +20 -18
- package/dist/lib/contentImport/index.d.ts +4 -0
- package/dist/lib/contentImport/index.d.ts.map +1 -0
- package/dist/lib/contentImport/lexicalSerializer.d.ts +19 -0
- package/dist/lib/contentImport/lexicalSerializer.d.ts.map +1 -0
- package/dist/lib/contentImport/lexicalSerializer.js +215 -0
- package/dist/lib/contentImport/types.d.ts +161 -0
- package/dist/lib/contentImport/types.d.ts.map +1 -0
- package/dist/lib/contentImport/utils.d.ts +35 -0
- package/dist/lib/contentImport/utils.d.ts.map +1 -0
- package/dist/lib/contentImport/utils.js +145 -0
- package/dist/lib/layersVisitData.d.ts +13 -0
- package/dist/lib/layersVisitData.d.ts.map +1 -0
- package/dist/lib/layersVisitData.js +37 -0
- package/dist/node_modules/countries-and-timezones/esm/index.js +4031 -0
- package/dist/store/plansModal.d.ts.map +1 -1
- package/dist/store/plansModal.js +8 -7
- package/dist/utils/formatStorage.d.ts +7 -1
- package/dist/utils/formatStorage.d.ts.map +1 -1
- package/dist/utils/formatStorage.js +10 -5
- package/dist/utils/getCroppedBlob.d.ts +3 -0
- package/dist/utils/getCroppedBlob.d.ts.map +1 -0
- package/dist/utils/getCroppedBlob.js +21 -0
- package/package.json +1 -1
- package/dist/assets/images/flags/es.svg.js +0 -4
- package/dist/assets/images/flags/ru.svg.js +0 -4
- package/dist/assets/images/flags/us.svg.js +0 -4
- package/dist/components/PaymentSuccess/PaymentSuccess.d.ts +0 -2
- package/dist/components/PaymentSuccess/PaymentSuccess.d.ts.map +0 -1
- package/dist/components/PaymentSuccess/PaymentSuccess.js +0 -41
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface ImageCropperProps {
|
|
2
|
+
src: string;
|
|
3
|
+
variant?: 'square' | 'rounded';
|
|
4
|
+
aspectRatio?: number;
|
|
5
|
+
minSize?: number;
|
|
6
|
+
maxSize?: number;
|
|
7
|
+
onCropComplete?: (croppedImage: Blob) => void;
|
|
8
|
+
onCropDataChange?: (data: CropData) => void;
|
|
9
|
+
}
|
|
10
|
+
export interface CropData {
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
width: number;
|
|
14
|
+
height: number;
|
|
15
|
+
scale: number;
|
|
16
|
+
}
|
|
17
|
+
export declare const ImageCropper: ({ src, variant, aspectRatio, minSize, maxSize, onCropComplete, onCropDataChange, }: ImageCropperProps) => import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export default ImageCropper;
|
|
19
|
+
//# sourceMappingURL=ImageCropper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ImageCropper.d.ts","sourceRoot":"","sources":["../../../src/components/ImageCropper/ImageCropper.tsx"],"names":[],"mappings":"AAOA,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,CAAC,YAAY,EAAE,IAAI,KAAK,IAAI,CAAC;IAC9C,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;CAC7C;AAED,MAAM,WAAW,QAAQ;IACvB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AASD,eAAO,MAAM,YAAY,GAAI,oFAQ1B,iBAAiB,4CAujBnB,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
import { jsxs as b, jsx as a, Fragment as O } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as ne, useState as H, useMemo as ce, useEffect as j, useCallback as G } from "react";
|
|
3
|
+
import { Box as oe } from "@mantine/core";
|
|
4
|
+
import { useElementSize as ae } from "@mantine/hooks";
|
|
5
|
+
import h from "./ImageCropper.module.css.js";
|
|
6
|
+
const fe = ({
|
|
7
|
+
src: ie,
|
|
8
|
+
variant: I = "square",
|
|
9
|
+
aspectRatio: o = 1,
|
|
10
|
+
minSize: m = 50,
|
|
11
|
+
maxSize: X,
|
|
12
|
+
onCropComplete: J,
|
|
13
|
+
onCropDataChange: K
|
|
14
|
+
}) => {
|
|
15
|
+
const {
|
|
16
|
+
ref: he,
|
|
17
|
+
width: v,
|
|
18
|
+
height: M
|
|
19
|
+
} = ae(), W = ne(null), Q = ne(null), [Y, se] = H(!1), [f, de] = H({ width: 0, height: 0 }), r = ce(() => {
|
|
20
|
+
if (!Y || v === 0 || M === 0 || f.width === 0)
|
|
21
|
+
return { x: 0, y: 0, width: v, height: M };
|
|
22
|
+
const n = v / M, i = f.width / f.height;
|
|
23
|
+
if (i > n) {
|
|
24
|
+
const s = v / i;
|
|
25
|
+
return {
|
|
26
|
+
x: 0,
|
|
27
|
+
y: (M - s) / 2,
|
|
28
|
+
width: v,
|
|
29
|
+
height: s
|
|
30
|
+
};
|
|
31
|
+
} else {
|
|
32
|
+
const s = M * i;
|
|
33
|
+
return {
|
|
34
|
+
x: (v - s) / 2,
|
|
35
|
+
y: 0,
|
|
36
|
+
width: s,
|
|
37
|
+
height: M
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}, [Y, v, M, f]), [t, U] = H({
|
|
41
|
+
x: 0,
|
|
42
|
+
y: 0,
|
|
43
|
+
width: 200,
|
|
44
|
+
height: 200
|
|
45
|
+
}), [P, Z] = H(!1), [T, _] = H(!1), [l, S] = H(null), [V, R] = H({ x: 0, y: 0 }), [e, z] = H({
|
|
46
|
+
x: 0,
|
|
47
|
+
y: 0,
|
|
48
|
+
width: 0,
|
|
49
|
+
height: 0
|
|
50
|
+
});
|
|
51
|
+
j(() => {
|
|
52
|
+
if (!Y || v === 0 || M === 0 || r.width === 0)
|
|
53
|
+
return;
|
|
54
|
+
let n, i, s = Math.min(r.width, r.height) * 0.8;
|
|
55
|
+
X && (s = Math.min(s, X)), o >= 1 ? (n = s, i = s / o) : (i = s, n = s * o);
|
|
56
|
+
const u = r.x + (r.width - n) / 2, k = r.y + (r.height - i) / 2;
|
|
57
|
+
U({ x: u, y: k, width: n, height: i });
|
|
58
|
+
}, [
|
|
59
|
+
Y,
|
|
60
|
+
o,
|
|
61
|
+
v,
|
|
62
|
+
M,
|
|
63
|
+
r,
|
|
64
|
+
X
|
|
65
|
+
]);
|
|
66
|
+
const re = G(() => {
|
|
67
|
+
W.current && (de({
|
|
68
|
+
width: W.current.naturalWidth,
|
|
69
|
+
height: W.current.naturalHeight
|
|
70
|
+
}), se(!0));
|
|
71
|
+
}, []), ee = G(
|
|
72
|
+
(n) => {
|
|
73
|
+
n.preventDefault(), n.stopPropagation();
|
|
74
|
+
const i = "touches" in n ? n.touches[0].clientX : n.clientX, s = "touches" in n ? n.touches[0].clientY : n.clientY;
|
|
75
|
+
Z(!0), R({ x: i, y: s }), z({ ...t });
|
|
76
|
+
},
|
|
77
|
+
[t]
|
|
78
|
+
), q = G(
|
|
79
|
+
(n) => (i) => {
|
|
80
|
+
i.preventDefault(), i.stopPropagation();
|
|
81
|
+
const s = "touches" in i ? i.touches[0].clientX : i.clientX, u = "touches" in i ? i.touches[0].clientY : i.clientY;
|
|
82
|
+
_(!0), S(n), R({ x: s, y: u }), z({ ...t });
|
|
83
|
+
},
|
|
84
|
+
[t]
|
|
85
|
+
);
|
|
86
|
+
j(() => {
|
|
87
|
+
const n = (s) => {
|
|
88
|
+
if (!P && !T) return;
|
|
89
|
+
const u = "touches" in s ? s.touches[0].clientX : s.clientX, k = "touches" in s ? s.touches[0].clientY : s.clientY, y = u - V.x, D = k - V.y, B = r.x, L = r.y, N = r.x + r.width, A = r.y + r.height;
|
|
90
|
+
if (P) {
|
|
91
|
+
let g = e.x + y, w = e.y + D;
|
|
92
|
+
g = Math.max(B, Math.min(g, N - t.width)), w = Math.max(L, Math.min(w, A - t.height)), U((d) => ({ ...d, x: g, y: w }));
|
|
93
|
+
}
|
|
94
|
+
if (T && l) {
|
|
95
|
+
let g = e.x, w = e.y, d = e.width, c = e.height;
|
|
96
|
+
switch (l) {
|
|
97
|
+
case "se":
|
|
98
|
+
d = Math.max(m, e.width + y), c = d / o;
|
|
99
|
+
break;
|
|
100
|
+
case "sw":
|
|
101
|
+
d = Math.max(m, e.width - y), c = d / o, g = e.x + e.width - d;
|
|
102
|
+
break;
|
|
103
|
+
case "ne":
|
|
104
|
+
d = Math.max(m, e.width + y), c = d / o, w = e.y + e.height - c;
|
|
105
|
+
break;
|
|
106
|
+
case "nw":
|
|
107
|
+
d = Math.max(m, e.width - y), c = d / o, g = e.x + e.width - d, w = e.y + e.height - c;
|
|
108
|
+
break;
|
|
109
|
+
case "e":
|
|
110
|
+
d = Math.max(m, e.width + y), c = d / o, w = e.y + (e.height - c) / 2;
|
|
111
|
+
break;
|
|
112
|
+
case "w":
|
|
113
|
+
d = Math.max(m, e.width - y), c = d / o, g = e.x + e.width - d, w = e.y + (e.height - c) / 2;
|
|
114
|
+
break;
|
|
115
|
+
case "s":
|
|
116
|
+
c = Math.max(m, e.height + D), d = c * o, g = e.x + (e.width - d) / 2;
|
|
117
|
+
break;
|
|
118
|
+
case "n":
|
|
119
|
+
c = Math.max(m, e.height - D), d = c * o, g = e.x + (e.width - d) / 2, w = e.y + e.height - c;
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
const p = l.includes("w") ? e.x + e.width : l.includes("e") ? e.x : e.x + e.width / 2, $ = l.includes("n") ? e.y + e.height : l.includes("s") ? e.y : e.y + e.height / 2;
|
|
123
|
+
let x, E;
|
|
124
|
+
l.includes("w") ? x = p - B : l.includes("e") ? x = N - p : x = Math.min(p - B, N - p) * 2, l.includes("n") ? E = $ - L : l.includes("s") ? E = A - $ : E = Math.min($ - L, A - $) * 2, X && (o >= 1 ? x = Math.min(x, X) : E = Math.min(E, X)), x / o < E ? E = x / o : x = E * o, d > x && (d = x, c = d / o), l.includes("w") ? g = p - d : l.includes("e") ? g = p : g = p - d / 2, l.includes("n") ? w = $ - c : l.includes("s") ? w = $ : w = $ - c / 2, d >= m && c >= m && U({ x: g, y: w, width: d, height: c });
|
|
125
|
+
}
|
|
126
|
+
}, i = () => {
|
|
127
|
+
Z(!1), _(!1), S(null);
|
|
128
|
+
};
|
|
129
|
+
return (P || T) && (window.addEventListener("mousemove", n), window.addEventListener("mouseup", i), window.addEventListener("touchmove", n), window.addEventListener("touchend", i)), () => {
|
|
130
|
+
window.removeEventListener("mousemove", n), window.removeEventListener("mouseup", i), window.removeEventListener("touchmove", n), window.removeEventListener("touchend", i);
|
|
131
|
+
};
|
|
132
|
+
}, [
|
|
133
|
+
P,
|
|
134
|
+
T,
|
|
135
|
+
l,
|
|
136
|
+
V,
|
|
137
|
+
e,
|
|
138
|
+
r,
|
|
139
|
+
t.width,
|
|
140
|
+
t.height,
|
|
141
|
+
o,
|
|
142
|
+
m,
|
|
143
|
+
X
|
|
144
|
+
]), j(() => {
|
|
145
|
+
if (K && Y && r.width > 0) {
|
|
146
|
+
const n = f.width / r.width, i = f.height / r.height;
|
|
147
|
+
K({
|
|
148
|
+
x: (t.x - r.x) * n,
|
|
149
|
+
y: (t.y - r.y) * i,
|
|
150
|
+
width: t.width * n,
|
|
151
|
+
height: t.height * i,
|
|
152
|
+
scale: n
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
}, [t, f, r, Y, K]);
|
|
156
|
+
const te = G(() => new Promise((n, i) => {
|
|
157
|
+
if (!W.current || !Q.current) {
|
|
158
|
+
i(new Error("Image or canvas not ready"));
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
const s = Q.current, u = s.getContext("2d");
|
|
162
|
+
if (!u) {
|
|
163
|
+
i(new Error("Could not get canvas context"));
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
const k = f.width / r.width, y = f.height / r.height, D = (t.x - r.x) * k, B = (t.y - r.y) * y, L = t.width * k, N = t.height * y;
|
|
167
|
+
s.width = L, s.height = N, I === "rounded" && (u.beginPath(), u.arc(
|
|
168
|
+
L / 2,
|
|
169
|
+
N / 2,
|
|
170
|
+
Math.min(L, N) / 2,
|
|
171
|
+
0,
|
|
172
|
+
Math.PI * 2
|
|
173
|
+
), u.closePath(), u.clip()), u.drawImage(
|
|
174
|
+
W.current,
|
|
175
|
+
D,
|
|
176
|
+
B,
|
|
177
|
+
L,
|
|
178
|
+
N,
|
|
179
|
+
0,
|
|
180
|
+
0,
|
|
181
|
+
L,
|
|
182
|
+
N
|
|
183
|
+
), s.toBlob(
|
|
184
|
+
(A) => {
|
|
185
|
+
A ? n(A) : i(new Error("Failed to create blob"));
|
|
186
|
+
},
|
|
187
|
+
"image/png",
|
|
188
|
+
1
|
|
189
|
+
);
|
|
190
|
+
}), [t, f, r, I]);
|
|
191
|
+
j(() => {
|
|
192
|
+
J && te().then(J).catch(() => {
|
|
193
|
+
});
|
|
194
|
+
}, [te, J]);
|
|
195
|
+
const C = (n) => {
|
|
196
|
+
const i = {
|
|
197
|
+
nw: h.handleNW,
|
|
198
|
+
ne: h.handleNE,
|
|
199
|
+
sw: h.handleSW,
|
|
200
|
+
se: h.handleSE
|
|
201
|
+
};
|
|
202
|
+
return /* @__PURE__ */ b(
|
|
203
|
+
"div",
|
|
204
|
+
{
|
|
205
|
+
className: `${h.cornerHandle} ${i[n]}`,
|
|
206
|
+
onMouseDown: q(n),
|
|
207
|
+
onTouchStart: q(n),
|
|
208
|
+
children: [
|
|
209
|
+
/* @__PURE__ */ a("div", { className: h.cornerHandleArm, "data-direction": "horizontal" }),
|
|
210
|
+
/* @__PURE__ */ a("div", { className: h.cornerHandleArm, "data-direction": "vertical" })
|
|
211
|
+
]
|
|
212
|
+
}
|
|
213
|
+
);
|
|
214
|
+
}, F = (n) => {
|
|
215
|
+
const i = {
|
|
216
|
+
n: h.handleN,
|
|
217
|
+
s: h.handleS,
|
|
218
|
+
e: h.handleE,
|
|
219
|
+
w: h.handleW
|
|
220
|
+
};
|
|
221
|
+
return /* @__PURE__ */ a(
|
|
222
|
+
"div",
|
|
223
|
+
{
|
|
224
|
+
className: `${h.edgeHandle} ${i[n]}`,
|
|
225
|
+
onMouseDown: q(n),
|
|
226
|
+
onTouchStart: q(n),
|
|
227
|
+
children: /* @__PURE__ */ a("div", { className: h.edgeHandleBar })
|
|
228
|
+
}
|
|
229
|
+
);
|
|
230
|
+
};
|
|
231
|
+
return /* @__PURE__ */ b(oe, { className: h.container, ref: he, children: [
|
|
232
|
+
/* @__PURE__ */ a("canvas", { ref: Q, style: { display: "none" } }),
|
|
233
|
+
/* @__PURE__ */ a(
|
|
234
|
+
"img",
|
|
235
|
+
{
|
|
236
|
+
ref: W,
|
|
237
|
+
src: ie,
|
|
238
|
+
alt: "Crop preview",
|
|
239
|
+
className: h.image,
|
|
240
|
+
onLoad: re,
|
|
241
|
+
draggable: !1
|
|
242
|
+
}
|
|
243
|
+
),
|
|
244
|
+
Y && /* @__PURE__ */ b(O, { children: [
|
|
245
|
+
I === "square" ? /* @__PURE__ */ b(O, { children: [
|
|
246
|
+
/* @__PURE__ */ a(
|
|
247
|
+
"div",
|
|
248
|
+
{
|
|
249
|
+
className: h.overlay,
|
|
250
|
+
style: {
|
|
251
|
+
top: 0,
|
|
252
|
+
left: 0,
|
|
253
|
+
right: 0,
|
|
254
|
+
height: t.y
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
),
|
|
258
|
+
/* @__PURE__ */ a(
|
|
259
|
+
"div",
|
|
260
|
+
{
|
|
261
|
+
className: h.overlay,
|
|
262
|
+
style: {
|
|
263
|
+
top: t.y + t.height,
|
|
264
|
+
left: 0,
|
|
265
|
+
right: 0,
|
|
266
|
+
bottom: 0
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
),
|
|
270
|
+
/* @__PURE__ */ a(
|
|
271
|
+
"div",
|
|
272
|
+
{
|
|
273
|
+
className: h.overlay,
|
|
274
|
+
style: {
|
|
275
|
+
top: t.y,
|
|
276
|
+
left: 0,
|
|
277
|
+
width: t.x,
|
|
278
|
+
height: t.height
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
),
|
|
282
|
+
/* @__PURE__ */ a(
|
|
283
|
+
"div",
|
|
284
|
+
{
|
|
285
|
+
className: h.overlay,
|
|
286
|
+
style: {
|
|
287
|
+
top: t.y,
|
|
288
|
+
left: t.x + t.width,
|
|
289
|
+
right: 0,
|
|
290
|
+
height: t.height
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
)
|
|
294
|
+
] }) : /* @__PURE__ */ a(
|
|
295
|
+
"div",
|
|
296
|
+
{
|
|
297
|
+
className: h.circularOverlay,
|
|
298
|
+
style: {
|
|
299
|
+
left: t.x + t.width / 2,
|
|
300
|
+
top: t.y + t.height / 2,
|
|
301
|
+
width: t.width - 4,
|
|
302
|
+
height: t.height - 4
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
),
|
|
306
|
+
/* @__PURE__ */ b(
|
|
307
|
+
"div",
|
|
308
|
+
{
|
|
309
|
+
className: `${h.cropArea} ${I === "rounded" ? h.cropAreaRounded : ""}`,
|
|
310
|
+
style: {
|
|
311
|
+
left: t.x,
|
|
312
|
+
top: t.y,
|
|
313
|
+
width: t.width,
|
|
314
|
+
height: t.height
|
|
315
|
+
},
|
|
316
|
+
onMouseDown: ee,
|
|
317
|
+
onTouchStart: ee,
|
|
318
|
+
children: [
|
|
319
|
+
I === "square" ? /* @__PURE__ */ a("div", { className: h.dashedBorder }) : /* @__PURE__ */ b(O, { children: [
|
|
320
|
+
/* @__PURE__ */ a("div", { className: `${h.edgeLine} ${h.edgeLineTop}` }),
|
|
321
|
+
/* @__PURE__ */ a(
|
|
322
|
+
"div",
|
|
323
|
+
{
|
|
324
|
+
className: `${h.edgeLine} ${h.edgeLineBottom}`
|
|
325
|
+
}
|
|
326
|
+
),
|
|
327
|
+
/* @__PURE__ */ a(
|
|
328
|
+
"div",
|
|
329
|
+
{
|
|
330
|
+
className: `${h.edgeLine} ${h.edgeLineLeft}`
|
|
331
|
+
}
|
|
332
|
+
),
|
|
333
|
+
/* @__PURE__ */ a(
|
|
334
|
+
"div",
|
|
335
|
+
{
|
|
336
|
+
className: `${h.edgeLine} ${h.edgeLineRight}`
|
|
337
|
+
}
|
|
338
|
+
)
|
|
339
|
+
] }),
|
|
340
|
+
C("nw"),
|
|
341
|
+
C("ne"),
|
|
342
|
+
C("sw"),
|
|
343
|
+
C("se"),
|
|
344
|
+
I === "square" && /* @__PURE__ */ b(O, { children: [
|
|
345
|
+
F("n"),
|
|
346
|
+
F("s"),
|
|
347
|
+
F("e"),
|
|
348
|
+
F("w")
|
|
349
|
+
] })
|
|
350
|
+
]
|
|
351
|
+
}
|
|
352
|
+
)
|
|
353
|
+
] })
|
|
354
|
+
] });
|
|
355
|
+
};
|
|
356
|
+
export {
|
|
357
|
+
fe as ImageCropper
|
|
358
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const e = "_container_z996o_1", n = "_image_z996o_12", o = "_overlay_z996o_19", _ = "_circularOverlay_z996o_25", d = "_cropArea_z996o_33", a = "_dashedBorder_z996o_39", l = "_edgeLine_z996o_46", r = "_edgeLineTop_z996o_52", c = "_edgeLineBottom_z996o_60", t = "_edgeLineLeft_z996o_68", s = "_edgeLineRight_z996o_76", h = "_cornerHandle_z996o_84", g = "_cornerHandleArm_z996o_92", i = "_handleNW_z996o_107", z = "_handleNE_z996o_123", L = "_handleSW_z996o_139", H = "_handleSE_z996o_156", m = "_edgeHandle_z996o_172", B = "_edgeHandleBar_z996o_181", E = "_handleN_z996o_107", N = "_handleS_z996o_139", S = "_handleE_z996o_213", W = "_handleW_z996o_227", p = {
|
|
2
|
+
container: e,
|
|
3
|
+
image: n,
|
|
4
|
+
overlay: o,
|
|
5
|
+
circularOverlay: _,
|
|
6
|
+
cropArea: d,
|
|
7
|
+
dashedBorder: a,
|
|
8
|
+
edgeLine: l,
|
|
9
|
+
edgeLineTop: r,
|
|
10
|
+
edgeLineBottom: c,
|
|
11
|
+
edgeLineLeft: t,
|
|
12
|
+
edgeLineRight: s,
|
|
13
|
+
cornerHandle: h,
|
|
14
|
+
cornerHandleArm: g,
|
|
15
|
+
handleNW: i,
|
|
16
|
+
handleNE: z,
|
|
17
|
+
handleSW: L,
|
|
18
|
+
handleSE: H,
|
|
19
|
+
edgeHandle: m,
|
|
20
|
+
edgeHandleBar: B,
|
|
21
|
+
handleN: E,
|
|
22
|
+
handleS: N,
|
|
23
|
+
handleE: S,
|
|
24
|
+
handleW: W
|
|
25
|
+
};
|
|
26
|
+
export {
|
|
27
|
+
_ as circularOverlay,
|
|
28
|
+
e as container,
|
|
29
|
+
h as cornerHandle,
|
|
30
|
+
g as cornerHandleArm,
|
|
31
|
+
d as cropArea,
|
|
32
|
+
a as dashedBorder,
|
|
33
|
+
p as default,
|
|
34
|
+
m as edgeHandle,
|
|
35
|
+
B as edgeHandleBar,
|
|
36
|
+
l as edgeLine,
|
|
37
|
+
c as edgeLineBottom,
|
|
38
|
+
t as edgeLineLeft,
|
|
39
|
+
s as edgeLineRight,
|
|
40
|
+
r as edgeLineTop,
|
|
41
|
+
S as handleE,
|
|
42
|
+
E as handleN,
|
|
43
|
+
z as handleNE,
|
|
44
|
+
i as handleNW,
|
|
45
|
+
N as handleS,
|
|
46
|
+
H as handleSE,
|
|
47
|
+
L as handleSW,
|
|
48
|
+
W as handleW,
|
|
49
|
+
n as image,
|
|
50
|
+
o as overlay
|
|
51
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface CropBounds {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
}
|
|
7
|
+
export type CropShape = 'square' | 'rounded';
|
|
8
|
+
export interface CropImageOptions {
|
|
9
|
+
image: HTMLImageElement;
|
|
10
|
+
bounds: CropBounds;
|
|
11
|
+
shape: CropShape;
|
|
12
|
+
outputWidth?: number;
|
|
13
|
+
outputHeight?: number;
|
|
14
|
+
quality?: number;
|
|
15
|
+
mimeType?: 'image/png' | 'image/jpeg' | 'image/webp';
|
|
16
|
+
}
|
|
17
|
+
export declare const cropImage: ({ image, bounds, shape, outputWidth, outputHeight, quality, mimeType, }: CropImageOptions) => Promise<Blob>;
|
|
18
|
+
export declare const blobToBase64: (blob: Blob) => Promise<string>;
|
|
19
|
+
export declare const scaleCropBounds: (cropBounds: CropBounds, containerWidth: number, containerHeight: number, imageWidth: number, imageHeight: number) => CropBounds;
|
|
20
|
+
export declare const getInitialCropBounds: (containerWidth: number, containerHeight: number, aspectRatio: number, sizePercent?: number) => CropBounds;
|
|
21
|
+
export declare const constrainCropBounds: (bounds: CropBounds, containerWidth: number, containerHeight: number, minSize: number) => CropBounds;
|
|
22
|
+
//# sourceMappingURL=cropUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cropUtils.d.ts","sourceRoot":"","sources":["../../../src/components/ImageCropper/cropUtils.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;AAE7C,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,gBAAgB,CAAC;IACxB,MAAM,EAAE,UAAU,CAAC;IACnB,KAAK,EAAE,SAAS,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,WAAW,GAAG,YAAY,GAAG,YAAY,CAAC;CACtD;AAED,eAAO,MAAM,SAAS,GAAU,yEAQ7B,gBAAgB,KAAG,OAAO,CAAC,IAAI,CAuDjC,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,MAAM,IAAI,KAAG,OAAO,CAAC,MAAM,CAavD,CAAC;AAEF,eAAO,MAAM,eAAe,GAC1B,YAAY,UAAU,EACtB,gBAAgB,MAAM,EACtB,iBAAiB,MAAM,EACvB,YAAY,MAAM,EAClB,aAAa,MAAM,KAClB,UAUF,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,gBAAgB,MAAM,EACtB,iBAAiB,MAAM,EACvB,aAAa,MAAM,EACnB,oBAAiB,KAChB,UAkBF,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAC9B,QAAQ,UAAU,EAClB,gBAAgB,MAAM,EACtB,iBAAiB,MAAM,EACvB,SAAS,MAAM,KACd,UAiBF,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const d = async ({
|
|
2
|
+
image: h,
|
|
3
|
+
bounds: t,
|
|
4
|
+
shape: o,
|
|
5
|
+
outputWidth: g,
|
|
6
|
+
outputHeight: l,
|
|
7
|
+
quality: m = 1,
|
|
8
|
+
mimeType: s = "image/png"
|
|
9
|
+
}) => new Promise((w, c) => {
|
|
10
|
+
const a = document.createElement("canvas"), e = a.getContext("2d");
|
|
11
|
+
if (!e) {
|
|
12
|
+
c(new Error("Could not get canvas context"));
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const n = g ?? t.width, i = l ?? t.height;
|
|
16
|
+
a.width = n, a.height = i, o === "rounded" && (e.beginPath(), e.arc(
|
|
17
|
+
n / 2,
|
|
18
|
+
i / 2,
|
|
19
|
+
Math.min(n, i) / 2,
|
|
20
|
+
0,
|
|
21
|
+
Math.PI * 2
|
|
22
|
+
), e.closePath(), e.clip()), e.drawImage(
|
|
23
|
+
h,
|
|
24
|
+
t.x,
|
|
25
|
+
t.y,
|
|
26
|
+
t.width,
|
|
27
|
+
t.height,
|
|
28
|
+
0,
|
|
29
|
+
0,
|
|
30
|
+
n,
|
|
31
|
+
i
|
|
32
|
+
), a.toBlob(
|
|
33
|
+
(r) => {
|
|
34
|
+
r ? w(r) : c(new Error("Failed to create blob"));
|
|
35
|
+
},
|
|
36
|
+
s,
|
|
37
|
+
m
|
|
38
|
+
);
|
|
39
|
+
});
|
|
40
|
+
export {
|
|
41
|
+
d as cropImage
|
|
42
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/ImageCropper/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACrF,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
interface CropBounds {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
}
|
|
7
|
+
interface ContainerSize {
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
}
|
|
11
|
+
type ResizeHandle = 'nw' | 'ne' | 'sw' | 'se' | null;
|
|
12
|
+
interface UseCropInteractionOptions {
|
|
13
|
+
initialCrop: CropBounds;
|
|
14
|
+
containerSize: ContainerSize;
|
|
15
|
+
aspectRatio: number;
|
|
16
|
+
minSize: number;
|
|
17
|
+
onCropChange: (crop: CropBounds) => void;
|
|
18
|
+
}
|
|
19
|
+
interface UseCropInteractionReturn {
|
|
20
|
+
isDragging: boolean;
|
|
21
|
+
isResizing: boolean;
|
|
22
|
+
activeHandle: ResizeHandle;
|
|
23
|
+
handleCropMouseDown: (e: React.MouseEvent | React.TouchEvent) => void;
|
|
24
|
+
handleResizeMouseDown: (handle: Exclude<ResizeHandle, null>) => (e: React.MouseEvent | React.TouchEvent) => void;
|
|
25
|
+
}
|
|
26
|
+
export declare const useCropInteraction: ({ initialCrop, containerSize, aspectRatio, minSize, onCropChange, }: UseCropInteractionOptions) => UseCropInteractionReturn;
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=useCropInteraction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCropInteraction.d.ts","sourceRoot":"","sources":["../../../src/components/ImageCropper/useCropInteraction.ts"],"names":[],"mappings":"AAOA,UAAU,UAAU;IAClB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,aAAa;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,KAAK,YAAY,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAErD,UAAU,yBAAyB;IACjC,WAAW,EAAE,UAAU,CAAC;IACxB,aAAa,EAAE,aAAa,CAAC;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;CAC1C;AAED,UAAU,wBAAwB;IAChC,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,YAAY,EAAE,YAAY,CAAC;IAC3B,mBAAmB,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU,KAAK,IAAI,CAAC;IACtE,qBAAqB,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU,KAAK,IAAI,CAAC;CAClH;AAED,eAAO,MAAM,kBAAkB,GAAI,qEAMhC,yBAAyB,KAAG,wBAwJ9B,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { useState as g, useCallback as D, useEffect as P } from "react";
|
|
2
|
+
const W = ({
|
|
3
|
+
initialCrop: u,
|
|
4
|
+
containerSize: l,
|
|
5
|
+
aspectRatio: d,
|
|
6
|
+
minSize: w,
|
|
7
|
+
onCropChange: x
|
|
8
|
+
}) => {
|
|
9
|
+
const [r, Y] = g(!1), [a, M] = g(!1), [f, y] = g(null), [m, E] = g({ x: 0, y: 0 }), [t, L] = g(u), b = D(
|
|
10
|
+
(n) => {
|
|
11
|
+
n.preventDefault(), n.stopPropagation();
|
|
12
|
+
const s = "touches" in n ? n.touches[0].clientX : n.clientX, i = "touches" in n ? n.touches[0].clientY : n.clientY;
|
|
13
|
+
Y(!0), E({ x: s, y: i }), L(u);
|
|
14
|
+
},
|
|
15
|
+
[u]
|
|
16
|
+
), k = D(
|
|
17
|
+
(n) => (s) => {
|
|
18
|
+
s.preventDefault(), s.stopPropagation();
|
|
19
|
+
const i = "touches" in s ? s.touches[0].clientX : s.clientX, X = "touches" in s ? s.touches[0].clientY : s.clientY;
|
|
20
|
+
M(!0), y(n), E({ x: i, y: X }), L(u);
|
|
21
|
+
},
|
|
22
|
+
[u]
|
|
23
|
+
);
|
|
24
|
+
return P(() => {
|
|
25
|
+
const n = (i) => {
|
|
26
|
+
if (!r && !a) return;
|
|
27
|
+
const X = "touches" in i ? i.touches[0].clientX : i.clientX, H = "touches" in i ? i.touches[0].clientY : i.clientY, v = X - m.x, I = H - m.y;
|
|
28
|
+
if (r) {
|
|
29
|
+
let o = t.x + v, c = t.y + I;
|
|
30
|
+
o = Math.max(0, Math.min(o, l.width - t.width)), c = Math.max(0, Math.min(c, l.height - t.height)), x({ ...t, x: o, y: c });
|
|
31
|
+
}
|
|
32
|
+
if (a && f) {
|
|
33
|
+
let o = t.x, c = t.y, e = t.width, h = t.height;
|
|
34
|
+
switch (f) {
|
|
35
|
+
case "se":
|
|
36
|
+
e = Math.max(w, t.width + v), h = e / d;
|
|
37
|
+
break;
|
|
38
|
+
case "sw":
|
|
39
|
+
e = Math.max(w, t.width - v), h = e / d, o = t.x + t.width - e;
|
|
40
|
+
break;
|
|
41
|
+
case "ne":
|
|
42
|
+
e = Math.max(w, t.width + v), h = e / d, c = t.y + t.height - h;
|
|
43
|
+
break;
|
|
44
|
+
case "nw":
|
|
45
|
+
e = Math.max(w, t.width - v), h = e / d, o = t.x + t.width - e, c = t.y + t.height - h;
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
o < 0 && (e += o, h = e / d, o = 0), c < 0 && (h += c, e = h * d, c = 0), o + e > l.width && (e = l.width - o, h = e / d), c + h > l.height && (h = l.height - c, e = h * d), e >= w && h >= w && x({ x: o, y: c, width: e, height: h });
|
|
49
|
+
}
|
|
50
|
+
}, s = () => {
|
|
51
|
+
Y(!1), M(!1), y(null);
|
|
52
|
+
};
|
|
53
|
+
return (r || a) && (window.addEventListener("mousemove", n), window.addEventListener("mouseup", s), window.addEventListener("touchmove", n), window.addEventListener("touchend", s)), () => {
|
|
54
|
+
window.removeEventListener("mousemove", n), window.removeEventListener("mouseup", s), window.removeEventListener("touchmove", n), window.removeEventListener("touchend", s);
|
|
55
|
+
};
|
|
56
|
+
}, [
|
|
57
|
+
r,
|
|
58
|
+
a,
|
|
59
|
+
f,
|
|
60
|
+
m,
|
|
61
|
+
t,
|
|
62
|
+
l,
|
|
63
|
+
d,
|
|
64
|
+
w,
|
|
65
|
+
x
|
|
66
|
+
]), {
|
|
67
|
+
isDragging: r,
|
|
68
|
+
isResizing: a,
|
|
69
|
+
activeHandle: f,
|
|
70
|
+
handleCropMouseDown: b,
|
|
71
|
+
handleResizeMouseDown: k
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
export {
|
|
75
|
+
W as useCropInteraction
|
|
76
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
export interface IntegrationFlowAnimationProps {
|
|
3
|
+
/** Icon component to display on the left (source) */
|
|
4
|
+
leftIcon: ReactNode;
|
|
5
|
+
/** Icon component to display on the right (destination) */
|
|
6
|
+
rightIcon: ReactNode;
|
|
7
|
+
/** Height of the component */
|
|
8
|
+
height?: number | string;
|
|
9
|
+
/** Number of particles to animate */
|
|
10
|
+
particleCount?: number;
|
|
11
|
+
/** Custom colors for particles (defaults to blue, green, yellow-orange distribution) */
|
|
12
|
+
colors?: string[];
|
|
13
|
+
/** Background image URL */
|
|
14
|
+
backgroundImage?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A reusable animation component showing data flow between two integration icons.
|
|
18
|
+
* Displays animated particles flowing from left icon to right icon.
|
|
19
|
+
*/
|
|
20
|
+
export declare const IntegrationFlowAnimation: ({ leftIcon, rightIcon, height, particleCount, colors, backgroundImage, }: IntegrationFlowAnimationProps) => ReactNode;
|
|
21
|
+
//# sourceMappingURL=IntegrationFlowAnimation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IntegrationFlowAnimation.d.ts","sourceRoot":"","sources":["../../../src/components/IntegrationFlowAnimation/IntegrationFlowAnimation.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAqB,MAAM,OAAO,CAAC;AAiD1D,MAAM,WAAW,6BAA6B;IAC5C,qDAAqD;IACrD,QAAQ,EAAE,SAAS,CAAC;IACpB,2DAA2D;IAC3D,SAAS,EAAE,SAAS,CAAC;IACrB,8BAA8B;IAC9B,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,qCAAqC;IACrC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,wFAAwF;IACxF,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,2BAA2B;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;GAGG;AACH,eAAO,MAAM,wBAAwB,GAAI,0EAOtC,6BAA6B,KAAG,SAqElC,CAAC"}
|