@mgonza02/goal-image-gallery 1.0.9 → 1.1.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/CHANGELOG.md +12 -0
- package/lib/hooks/use-image-gallery.js +31 -18
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,18 @@ All notable changes to the GoalImageGallery project will be documented in this f
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.1.0] - 2025-07-14
|
|
9
|
+
|
|
10
|
+
### 🐛 Bug Fixes
|
|
11
|
+
- **Fixed handleAfterUpload Array Structure**: Resolved issue where `handleAfterUpload` was creating nested arrays instead of flat arrays for `image_code` parameter
|
|
12
|
+
- **Improved Array Handling**: Enhanced logic to properly handle both single image replacement and bulk image addition scenarios
|
|
13
|
+
- **Better Code Organization**: Refactored `handleAfterUpload` method for clearer logic flow and better maintainability
|
|
14
|
+
|
|
15
|
+
### 🔧 Technical Improvements
|
|
16
|
+
- **Clearer Logic Separation**: Separated replacement logic from addition logic for better code readability
|
|
17
|
+
- **Duplicate Prevention**: Enhanced duplicate checking to prevent adding the same image code multiple times
|
|
18
|
+
- **Array Flattening**: Fixed array structure to ensure `image_code` is always a flat array of strings
|
|
19
|
+
|
|
8
20
|
## [1.0.9] - 2025-07-14
|
|
9
21
|
|
|
10
22
|
### ✨ New Features
|
|
@@ -109,32 +109,45 @@ export const useImageGallery = _ref => {
|
|
|
109
109
|
|
|
110
110
|
// Handle both single image and array of images
|
|
111
111
|
const imagesArray = Array.isArray(uploadedImages) ? uploadedImages : [uploadedImages];
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
112
|
+
let imagesToSave = [];
|
|
113
|
+
if (currentImageCode) {
|
|
114
|
+
// Replacing an existing image
|
|
115
|
+
imagesToSave = imageList.reduce((acc, img) => {
|
|
116
|
+
if (img.image_code !== '+') {
|
|
117
|
+
if (img.image_code === currentImageCode) {
|
|
118
|
+
// Replace the selected image with the first uploaded image
|
|
119
|
+
acc.push(imagesArray[0].code);
|
|
120
|
+
} else {
|
|
121
|
+
// Keep existing image codes
|
|
122
|
+
acc.push(img.image_code);
|
|
123
|
+
}
|
|
119
124
|
}
|
|
125
|
+
return acc;
|
|
126
|
+
}, []);
|
|
127
|
+
|
|
128
|
+
// If multiple images uploaded, add the additional ones
|
|
129
|
+
if (imagesArray.length > 1) {
|
|
130
|
+
imagesArray.slice(1).forEach(image => {
|
|
131
|
+
if (!imagesToSave.includes(image.code)) {
|
|
132
|
+
imagesToSave.push(image.code);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
120
135
|
}
|
|
121
|
-
|
|
122
|
-
|
|
136
|
+
} else {
|
|
137
|
+
// Adding new images (no current selection)
|
|
138
|
+
imagesToSave = imageList.reduce((acc, img) => {
|
|
139
|
+
if (img.image_code !== '+') {
|
|
140
|
+
acc.push(img.image_code);
|
|
141
|
+
}
|
|
142
|
+
return acc;
|
|
143
|
+
}, []);
|
|
123
144
|
|
|
124
|
-
|
|
125
|
-
if (!currentImageCode) {
|
|
145
|
+
// Add all new image codes
|
|
126
146
|
imagesArray.forEach(image => {
|
|
127
147
|
if (!imagesToSave.includes(image.code)) {
|
|
128
148
|
imagesToSave.push(image.code);
|
|
129
149
|
}
|
|
130
150
|
});
|
|
131
|
-
} else if (imagesArray.length > 1) {
|
|
132
|
-
// If replacing and multiple images uploaded, add additional images
|
|
133
|
-
imagesArray.slice(1).forEach(image => {
|
|
134
|
-
if (!imagesToSave.includes(image.code)) {
|
|
135
|
-
imagesToSave.push(image.code);
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
151
|
}
|
|
139
152
|
const result = await imageHandlerApi({
|
|
140
153
|
...ownerEntity,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mgonza02/goal-image-gallery",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Advanced, accessible, and highly customizable React image gallery component with multi-method upload, responsive design, and extensive TypeScript support",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/index.js",
|