@yogiswara/honcho-editor-ui 2.2.4 → 2.2.6
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/components/editor/GalleryAlbum/AlbumImageGallery.d.ts +3 -11
- package/dist/components/editor/GalleryAlbum/AlbumImageGallery.js +2 -6
- package/dist/components/editor/GalleryAlbum/ImageItem.d.ts +2 -18
- package/dist/components/editor/GalleryAlbum/ImageItem.js +17 -99
- package/dist/hooks/editor/useHonchoEditorBulk.d.ts +1 -1
- package/dist/hooks/editor/useHonchoEditorBulk.js +17 -21
- package/dist/index.d.ts +1 -3
- package/dist/index.js +0 -2
- package/package.json +1 -1
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
import type { PhotoData as BulkPhotoData } from "../../../hooks/editor/useHonchoEditorBulk";
|
|
4
|
-
export interface ExtendedPhotoData extends BulkPhotoData {
|
|
5
|
-
adjustments?: Partial<AdjustmentValues>;
|
|
6
|
-
frame?: string;
|
|
7
|
-
}
|
|
2
|
+
import type { PhotoData } from "../../../hooks/editor/useHonchoEditorBulk";
|
|
8
3
|
interface ImageGalleryProps {
|
|
9
|
-
imageCollection:
|
|
10
|
-
|
|
11
|
-
isHiddenGallery: boolean;
|
|
12
|
-
enableEditor: boolean;
|
|
13
|
-
onToggleSelect: (photo: ExtendedPhotoData) => void;
|
|
4
|
+
imageCollection: PhotoData[];
|
|
5
|
+
onToggleSelect: (photo: PhotoData) => void;
|
|
14
6
|
}
|
|
15
7
|
export declare const AlbumImageGallery: React.FC<ImageGalleryProps>;
|
|
16
8
|
export {};
|
|
@@ -4,9 +4,7 @@ import { Box, Stack } from "@mui/material";
|
|
|
4
4
|
import Masonry, { ResponsiveMasonry } from "react-responsive-masonry";
|
|
5
5
|
import GalleryImageItem from "./ImageItem";
|
|
6
6
|
export const AlbumImageGallery = (props) => {
|
|
7
|
-
const { imageCollection,
|
|
8
|
-
onToggleSelect, } = props;
|
|
9
|
-
console.log("imageCollection: ", imageCollection);
|
|
7
|
+
const { imageCollection, onToggleSelect } = props;
|
|
10
8
|
return (_jsx(Stack, { sx: { width: '100%', maxHeight: '100%', overflowY: 'auto' }, children: _jsx(ResponsiveMasonry, { columnsCountBreakPoints: { 750: 2, 900: 4 }, children: _jsx(Masonry, { children: imageCollection.map((photo, index) => {
|
|
11
9
|
// This guard clause is still important for runtime safety.
|
|
12
10
|
if (!photo.key || !photo.src) {
|
|
@@ -25,8 +23,6 @@ export const AlbumImageGallery = (props) => {
|
|
|
25
23
|
// in case ImageItem needs it for other operations.
|
|
26
24
|
photo: photo,
|
|
27
25
|
};
|
|
28
|
-
return (_jsx(Box, { sx: { m: 0.5 }, children: _jsx(GalleryImageItem, { margin: "0px", index: index,
|
|
29
|
-
// UPDATED: Pass the new, correctly-typed object.
|
|
30
|
-
photo: imageItemPhotoProps, direction: "column", isFullScreenMode: false, isSelected: photo.isSelected, isSelectedMode: isSelectedMode, isHiddenGallery: isHiddenGallery, onToggleSelect: () => { onToggleSelect(photo); }, enableEditor: enableEditor, adjustments: photo.adjustments, frame: photo.frame, data: photo }) }, photo.key));
|
|
26
|
+
return (_jsx(Box, { sx: { m: 0.5 }, children: _jsx(GalleryImageItem, { margin: "0px", index: index, direction: "column", onToggleSelect: () => { onToggleSelect(photo); }, data: photo }) }, photo.key));
|
|
31
27
|
}) }) }) }));
|
|
32
28
|
};
|
|
@@ -1,26 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { GallerySetup } from "../../../hooks/editor/type";
|
|
3
|
-
interface PhotoProps<T> {
|
|
4
|
-
src: string;
|
|
5
|
-
alt?: string;
|
|
6
|
-
width: number;
|
|
7
|
-
height: number;
|
|
8
|
-
key: string;
|
|
9
|
-
}
|
|
1
|
+
import { PhotoData } from "../../../hooks/editor/useHonchoEditorBulk";
|
|
10
2
|
interface Props {
|
|
11
3
|
margin?: any;
|
|
12
4
|
index: number;
|
|
13
|
-
|
|
14
|
-
data: GallerySetup;
|
|
5
|
+
data: PhotoData;
|
|
15
6
|
direction: "row" | "column";
|
|
16
|
-
isSelectedMode: boolean;
|
|
17
|
-
isFullScreenMode: boolean;
|
|
18
|
-
isSelected?: boolean;
|
|
19
|
-
isHiddenGallery: boolean;
|
|
20
7
|
onToggleSelect: () => void;
|
|
21
|
-
enableEditor?: boolean;
|
|
22
|
-
adjustments?: Partial<AdjustmentValues>;
|
|
23
|
-
frame?: string | null;
|
|
24
8
|
}
|
|
25
9
|
declare const GalleryImageItem: (props: Props) => import("react/jsx-runtime").JSX.Element;
|
|
26
10
|
export default GalleryImageItem;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo } from "react";
|
|
3
3
|
import { Box, CardMedia, useTheme } from "@mui/material";
|
|
4
|
-
import { TickCircle } from "iconsax-react";
|
|
5
|
-
import CustomTickIcon from "../svg/Tick";
|
|
6
4
|
import { neutral } from "../../../color";
|
|
7
5
|
const initialAdjustments = {
|
|
8
6
|
temperature: 0, tint: 0, saturation: 0, vibrance: 0, exposure: 0, contrast: 0,
|
|
@@ -20,70 +18,32 @@ const selectedImgStyle = {
|
|
|
20
18
|
// transition: "transform .135s cubic-bezier(0.0,0.0,0.2,1),opacity linear .15s"
|
|
21
19
|
};
|
|
22
20
|
const GalleryImageItem = (props) => {
|
|
23
|
-
const {
|
|
21
|
+
const { margin, data } = props;
|
|
24
22
|
const theme = useTheme();
|
|
25
23
|
const imageData = data;
|
|
26
|
-
const hasAdjustments = useMemo(() => {
|
|
27
|
-
if (!adjustments)
|
|
28
|
-
return false;
|
|
29
|
-
return Object.keys(initialAdjustments).some(key => adjustments[key] !== initialAdjustments[key]);
|
|
30
|
-
}, [adjustments]);
|
|
31
|
-
const styleHiddenGallery = useMemo(() => {
|
|
32
|
-
if (props.isHiddenGallery) {
|
|
33
|
-
return { filter: "blur(20px)", pointerEvents: "none" };
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
return {};
|
|
37
|
-
}
|
|
38
|
-
}, [props.isHiddenGallery]);
|
|
39
24
|
const commonStyle = useMemo(() => {
|
|
40
25
|
return {
|
|
41
26
|
backgroundColor: neutral.white,
|
|
42
27
|
overflow: "hidden",
|
|
43
28
|
position: "relative",
|
|
44
29
|
width: "100%",
|
|
45
|
-
aspectRatio: `${
|
|
30
|
+
aspectRatio: `${imageData.width}/${imageData.height}`,
|
|
46
31
|
};
|
|
47
|
-
}, [props.direction,
|
|
48
|
-
const handleImageClick = () => {
|
|
49
|
-
console.debug({
|
|
50
|
-
isFullMode: props.isFullScreenMode,
|
|
51
|
-
isShowGallery: props.isHiddenGallery,
|
|
52
|
-
}, "handleImageClick");
|
|
53
|
-
if (!props.isFullScreenMode && !props.isHiddenGallery) {
|
|
54
|
-
if (props.isSelectedMode) {
|
|
55
|
-
console.debug("handleImageClick with toggle select");
|
|
56
|
-
props.onToggleSelect();
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
console.debug("handleImageClick with preview");
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
const handleImageSelectedIconClick = () => {
|
|
64
|
-
console.debug("handleImageSelectedIconClick");
|
|
65
|
-
if (!props.isFullScreenMode) {
|
|
66
|
-
if (!props.isSelectedMode) {
|
|
67
|
-
}
|
|
68
|
-
props.onToggleSelect();
|
|
69
|
-
}
|
|
70
|
-
};
|
|
32
|
+
}, [props.direction, imageData]);
|
|
71
33
|
const imageSx = useMemo(() => {
|
|
72
|
-
const baseStyles = isSelected ? {
|
|
34
|
+
const baseStyles = imageData.isSelected ? {
|
|
73
35
|
...imgStyle,
|
|
74
36
|
...selectedImgStyle,
|
|
75
|
-
|
|
76
|
-
aspectRatio: `${photo.width}/${photo.height}`,
|
|
37
|
+
aspectRatio: `${imageData.width}/${imageData.height}`,
|
|
77
38
|
} : {
|
|
78
39
|
...imgStyle,
|
|
79
|
-
...styleHiddenGallery,
|
|
80
40
|
};
|
|
81
41
|
return {
|
|
82
42
|
...baseStyles,
|
|
83
43
|
opacity: 1, // Previously depended on isProcessingComplete
|
|
84
44
|
transition: 'opacity 0.3s ease-in-out',
|
|
85
45
|
};
|
|
86
|
-
}, [isSelected,
|
|
46
|
+
}, [props.data.isSelected, imageData.width, imageData.height]);
|
|
87
47
|
const boxNotSelected = useMemo(() => ({
|
|
88
48
|
margin,
|
|
89
49
|
// height: photo.height,
|
|
@@ -91,17 +51,15 @@ const GalleryImageItem = (props) => {
|
|
|
91
51
|
transition: ".3s",
|
|
92
52
|
// "&:hover": { padding: "12px", backgroundColor: "primary.light1" },
|
|
93
53
|
"&:-webkit-transition": { transition: ".3s" },
|
|
94
|
-
"&:hover > .checkbox": { display:
|
|
95
|
-
cursor:
|
|
96
|
-
backgroundColor:
|
|
97
|
-
|
|
98
|
-
: "transparent",
|
|
99
|
-
}), [margin, commonStyle, props.isHiddenGallery, props.isFullScreenMode]);
|
|
54
|
+
"&:hover > .checkbox": { display: "block" },
|
|
55
|
+
cursor: "pointer",
|
|
56
|
+
backgroundColor: "transparent",
|
|
57
|
+
}), [margin, commonStyle]);
|
|
100
58
|
const boxSelected = useMemo(() => ({
|
|
101
59
|
margin,
|
|
102
60
|
// height: photo.height,
|
|
103
61
|
...commonStyle,
|
|
104
|
-
cursor:
|
|
62
|
+
cursor: "pointer",
|
|
105
63
|
transition: ".3s",
|
|
106
64
|
"&:-webkit-transition": { transition: ".3s" },
|
|
107
65
|
padding: { xs: "13px 12px", sm: "21.31px 25.56px 21.32px 27.68px" },
|
|
@@ -109,55 +67,15 @@ const GalleryImageItem = (props) => {
|
|
|
109
67
|
margin,
|
|
110
68
|
commonStyle,
|
|
111
69
|
theme.palette.light,
|
|
112
|
-
props.isFullScreenMode,
|
|
113
|
-
props.isHiddenGallery,
|
|
114
70
|
]);
|
|
115
71
|
const boxOuterSx = useMemo(() => {
|
|
116
|
-
if (props.
|
|
117
|
-
return {
|
|
118
|
-
margin,
|
|
119
|
-
...commonStyle,
|
|
120
|
-
};
|
|
72
|
+
if (props.data.isSelected) {
|
|
73
|
+
return { ...boxSelected };
|
|
121
74
|
}
|
|
122
75
|
else {
|
|
123
|
-
|
|
124
|
-
return { ...boxSelected };
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
127
|
-
return { ...boxNotSelected };
|
|
128
|
-
}
|
|
76
|
+
return { ...boxNotSelected };
|
|
129
77
|
}
|
|
130
|
-
}, [
|
|
131
|
-
|
|
132
|
-
photo.height,
|
|
133
|
-
photo.width,
|
|
134
|
-
commonStyle,
|
|
135
|
-
boxSelected,
|
|
136
|
-
boxNotSelected,
|
|
137
|
-
margin,
|
|
138
|
-
props.isSelected,
|
|
139
|
-
]);
|
|
140
|
-
return (_jsxs(Box, { id: "Box_image", sx: boxOuterSx, className: "image", children: [!props.isHiddenGallery &&
|
|
141
|
-
(hasAdjustments && isSelected ? (_jsx(Box, { color: "primary.dark1", onClick: handleImageSelectedIconClick, sx: {
|
|
142
|
-
position: "absolute",
|
|
143
|
-
width: "19px",
|
|
144
|
-
height: "19px",
|
|
145
|
-
zIndex: "2",
|
|
146
|
-
left: "5px",
|
|
147
|
-
top: "5px",
|
|
148
|
-
borderRadius: { xs: "50%", sm: 0 },
|
|
149
|
-
}, className: "checkbox", children: _jsx(CustomTickIcon, {}) })) : (_jsx(Box, { color: "neutral.light2", onClick: handleImageSelectedIconClick, sx: {
|
|
150
|
-
position: "absolute",
|
|
151
|
-
width: "19px",
|
|
152
|
-
height: "19px",
|
|
153
|
-
zIndex: "1",
|
|
154
|
-
left: "5px",
|
|
155
|
-
top: "5px",
|
|
156
|
-
display: "none",
|
|
157
|
-
visibility: {
|
|
158
|
-
xs: props.isSelectedMode ? "visible" : "hidden",
|
|
159
|
-
sm: "visible",
|
|
160
|
-
},
|
|
161
|
-
}, className: "checkbox", children: _jsx(TickCircle, { style: { width: "24px", height: "24px" }, color: "white" }) }))), _jsx(CardMedia, { id: "card_media", component: "img", className: "image", loading: "lazy", alt: imageData.alt ?? "Image", sx: imageSx, src: imageData.src, width: "100%", onClick: handleImageClick })] }, photo.key));
|
|
78
|
+
}, [imageData.height, imageData.width, commonStyle, boxSelected, boxNotSelected, margin]);
|
|
79
|
+
return (_jsx(Box, { id: "Box_image", sx: boxOuterSx, className: "image", children: _jsx(CardMedia, { id: "card_media", component: "img", className: "image", loading: "lazy", alt: imageData.alt ?? "Image", sx: imageSx, src: imageData.src, width: "100%", onClick: props.onToggleSelect }) }, imageData.key));
|
|
162
80
|
};
|
|
163
81
|
export default GalleryImageItem;
|
|
@@ -22,7 +22,7 @@ export interface ControllerBulk {
|
|
|
22
22
|
deletePreset(firebaseUid: string, presetId: string): Promise<void>;
|
|
23
23
|
}
|
|
24
24
|
export declare function useHonchoEditorBulk(controller: Controller, eventID: string, firebaseUid: string): {
|
|
25
|
-
|
|
25
|
+
imageData: PhotoData[];
|
|
26
26
|
isLoading: boolean;
|
|
27
27
|
error: string | null;
|
|
28
28
|
selectedIds: string[];
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { useState, useCallback, useEffect } from 'react';
|
|
2
|
+
import { useState, useCallback, useEffect, useMemo } from 'react';
|
|
3
3
|
import { useAdjustmentHistoryBatch } from '../useAdjustmentHistoryBatch';
|
|
4
4
|
// Helper function to map the API response to the format our UI component needs
|
|
5
|
-
const mapGalleryToPhotoData = (gallery) => {
|
|
5
|
+
const mapGalleryToPhotoData = (gallery, selectedIds) => {
|
|
6
6
|
return {
|
|
7
7
|
key: gallery.id,
|
|
8
8
|
src: gallery.raw_thumbnail?.path ? gallery.raw_thumbnail.path : gallery.thumbnail?.path,
|
|
@@ -10,7 +10,7 @@ const mapGalleryToPhotoData = (gallery) => {
|
|
|
10
10
|
width: gallery.thumbnail?.width,
|
|
11
11
|
height: gallery.thumbnail?.height,
|
|
12
12
|
alt: gallery.id || 'gallery image',
|
|
13
|
-
isSelected:
|
|
13
|
+
isSelected: selectedIds.includes(gallery.id),
|
|
14
14
|
adjustments: gallery.editor_config?.color_adjustment,
|
|
15
15
|
};
|
|
16
16
|
};
|
|
@@ -45,13 +45,22 @@ export function useHonchoEditorBulk(controller, eventID, firebaseUid) {
|
|
|
45
45
|
const [isLoading, setIsLoading] = useState(true);
|
|
46
46
|
const [error, setError] = useState(null);
|
|
47
47
|
const [selectedBulkPreset, setSelectedBulkPreset] = useState('preset1');
|
|
48
|
+
const imageData = useMemo(() => {
|
|
49
|
+
return imageCollection.map(item => {
|
|
50
|
+
return mapGalleryToPhotoData(item, selectedIds);
|
|
51
|
+
}).map(item => {
|
|
52
|
+
const adjustment = currentBatch.allImages[item.key];
|
|
53
|
+
return adjustment ? { ...item, ...adjustment } : item;
|
|
54
|
+
});
|
|
55
|
+
}, [imageCollection, selectedIds, currentBatch.allImages]);
|
|
48
56
|
const handleBackCallbackBulk = useCallback(() => {
|
|
49
|
-
const lastSelectedId = selectedIds.length > 0 ? selectedIds[selectedIds.length - 1] :
|
|
57
|
+
const lastSelectedId = selectedIds.length > 0 ? selectedIds[selectedIds.length - 1] : "";
|
|
50
58
|
controller.handleBack(firebaseUid, lastSelectedId);
|
|
51
|
-
}, [controller, firebaseUid, selectedIds
|
|
59
|
+
}, [controller, firebaseUid, selectedIds]);
|
|
52
60
|
const handleSelectBulkPreset = (event) => setSelectedBulkPreset(event.target.value);
|
|
53
61
|
// This factory creates functions that adjust a value for all selected images
|
|
54
62
|
const createRelativeAdjuster = useCallback((key, amount) => () => {
|
|
63
|
+
console.debug("createRelativeAdjuster", key, amount);
|
|
55
64
|
batchActions.adjustSelected({ [key]: amount });
|
|
56
65
|
}, [batchActions]);
|
|
57
66
|
const handleBulkTempDecreaseMax = createRelativeAdjuster('tempScore', -20);
|
|
@@ -109,9 +118,9 @@ export function useHonchoEditorBulk(controller, eventID, firebaseUid) {
|
|
|
109
118
|
setError(null);
|
|
110
119
|
controller.getImageList(firebaseUid, eventID, 1)
|
|
111
120
|
.then(response => {
|
|
121
|
+
// TODO need do pagination for this one
|
|
112
122
|
batchActions.syncAdjustment(response.gallery.map(mapToImageAdjustmentConfig));
|
|
113
|
-
|
|
114
|
-
setImageCollection(mappedData);
|
|
123
|
+
setImageCollection(response.gallery);
|
|
115
124
|
})
|
|
116
125
|
.catch(err => {
|
|
117
126
|
console.error("Failed to fetch image list:", err);
|
|
@@ -122,21 +131,8 @@ export function useHonchoEditorBulk(controller, eventID, firebaseUid) {
|
|
|
122
131
|
});
|
|
123
132
|
}
|
|
124
133
|
}, [eventID, firebaseUid, controller]);
|
|
125
|
-
useEffect(() => {
|
|
126
|
-
// react the changes in the batch state
|
|
127
|
-
if (currentBatch.allImages) {
|
|
128
|
-
setImageCollection((current) => {
|
|
129
|
-
const updated = current.map((image) => {
|
|
130
|
-
const adjustment = currentBatch.allImages[image.key];
|
|
131
|
-
return adjustment ? { ...image, ...adjustment } : image;
|
|
132
|
-
});
|
|
133
|
-
return updated;
|
|
134
|
-
});
|
|
135
|
-
console.log("Adjustment changed detected");
|
|
136
|
-
}
|
|
137
|
-
}, [currentBatch.allImages]);
|
|
138
134
|
return {
|
|
139
|
-
|
|
135
|
+
imageData,
|
|
140
136
|
isLoading,
|
|
141
137
|
error,
|
|
142
138
|
selectedIds,
|
package/dist/index.d.ts
CHANGED
|
@@ -21,10 +21,8 @@ export { default as HWatermarkView } from './components/editor/HWatermarkView';
|
|
|
21
21
|
export { default as HModalMobile } from './components/editor/HModalMobile';
|
|
22
22
|
export { default as HPresetOptionsMenu } from './components/editor/HPresetOptionMenu';
|
|
23
23
|
export { HAlertInternetBox, HAlertCopyBox, HAlertInternetConnectionBox, HAlertPresetSave } from './components/editor/HAlertBox';
|
|
24
|
-
export { AlbumImageGallery
|
|
24
|
+
export { AlbumImageGallery } from './components/editor/GalleryAlbum/AlbumImageGallery';
|
|
25
25
|
export { default as GalleryImageItem } from './components/editor/GalleryAlbum/ImageItem';
|
|
26
|
-
export { default as SimplifiedAlbumGallery } from './components/editor/GalleryAlbum/SimplifiedAlbumGallery';
|
|
27
|
-
export { default as SimplifiedImageItem } from './components/editor/GalleryAlbum/SimplifiedImageItem';
|
|
28
26
|
export { EditorProvider, useEditorContext } from './lib/context/EditorContext';
|
|
29
27
|
export { useImageProcessor } from './lib/hooks/useImageProcessor';
|
|
30
28
|
export { useEditorHeadless } from './lib/hooks/useEditorHeadless';
|
package/dist/index.js
CHANGED
|
@@ -20,8 +20,6 @@ export { default as HPresetOptionsMenu } from './components/editor/HPresetOption
|
|
|
20
20
|
export { HAlertInternetBox, HAlertCopyBox, HAlertInternetConnectionBox, HAlertPresetSave } from './components/editor/HAlertBox';
|
|
21
21
|
export { AlbumImageGallery } from './components/editor/GalleryAlbum/AlbumImageGallery';
|
|
22
22
|
export { default as GalleryImageItem } from './components/editor/GalleryAlbum/ImageItem';
|
|
23
|
-
export { default as SimplifiedAlbumGallery } from './components/editor/GalleryAlbum/SimplifiedAlbumGallery';
|
|
24
|
-
export { default as SimplifiedImageItem } from './components/editor/GalleryAlbum/SimplifiedImageItem';
|
|
25
23
|
export { EditorProvider, useEditorContext } from './lib/context/EditorContext';
|
|
26
24
|
export { useImageProcessor } from './lib/hooks/useImageProcessor';
|
|
27
25
|
export { useEditorHeadless } from './lib/hooks/useEditorHeadless';
|