@mgonza02/goal-image-gallery 1.2.3 → 1.2.4
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 +5 -0
- package/lib/GoalImageGallery.js +2 -0
- package/lib/components/ImageGalleryGrid.js +26 -5
- package/lib/hooks/use-image-gallery.js +3 -6
- package/lib/index.d.ts +2 -0
- package/lib/index.js +5 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,11 @@ 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.2.4] - 2026-10-12
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- **Floating Add Button**: Replaced the static '+' grid item with a floating action button (Fab) over the image gallery when `canAdd` is active.
|
|
12
|
+
|
|
8
13
|
## [1.2.3] - 2026-10-12
|
|
9
14
|
|
|
10
15
|
### Added
|
package/lib/GoalImageGallery.js
CHANGED
|
@@ -283,6 +283,7 @@ const GoalImageGallery = _ref => {
|
|
|
283
283
|
loading,
|
|
284
284
|
removable,
|
|
285
285
|
canSetDefault,
|
|
286
|
+
canAdd,
|
|
286
287
|
setZoomLevel,
|
|
287
288
|
handleOpenImage,
|
|
288
289
|
handleCloseImage,
|
|
@@ -415,6 +416,7 @@ const GoalImageGallery = _ref => {
|
|
|
415
416
|
onSetAsDefault: handleSetAsDefault,
|
|
416
417
|
onDownloadImage: handleDownloadImage,
|
|
417
418
|
canSetDefault: canSetDefault,
|
|
419
|
+
canAdd: canAdd,
|
|
418
420
|
defaultImageCode: defaultImageCode
|
|
419
421
|
}), /*#__PURE__*/_jsx(ImageGalleryModal, {
|
|
420
422
|
open: openImage !== null,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
|
-
import { Grid, Card, CardContent } from '@mui/material';
|
|
2
|
+
import { Grid, Card, CardContent, Fab, Tooltip } from '@mui/material';
|
|
3
|
+
import { Add as AddIcon } from '@mui/icons-material';
|
|
3
4
|
import { useTheme } from '@mui/material/styles';
|
|
4
5
|
import ImageGalleryItem from './ImageGalleryItem';
|
|
5
6
|
import ImageGalleryEmptyState from './ImageGalleryEmptyState';
|
|
@@ -8,7 +9,7 @@ import { StyledImageGridContainer } from '../styles/styled-components';
|
|
|
8
9
|
/**
|
|
9
10
|
* Image grid component for displaying gallery images
|
|
10
11
|
*/
|
|
11
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
13
|
const ImageGalleryGrid = _ref => {
|
|
13
14
|
let {
|
|
14
15
|
imageList,
|
|
@@ -28,6 +29,7 @@ const ImageGalleryGrid = _ref => {
|
|
|
28
29
|
onSetAsDefault,
|
|
29
30
|
onDownloadImage,
|
|
30
31
|
canSetDefault = false,
|
|
32
|
+
canAdd = false,
|
|
31
33
|
defaultImageCode
|
|
32
34
|
} = _ref;
|
|
33
35
|
const theme = useTheme();
|
|
@@ -44,9 +46,12 @@ const ImageGalleryGrid = _ref => {
|
|
|
44
46
|
})
|
|
45
47
|
});
|
|
46
48
|
}
|
|
47
|
-
return /*#__PURE__*/
|
|
49
|
+
return /*#__PURE__*/_jsxs(Card, {
|
|
48
50
|
elevation: 2,
|
|
49
|
-
|
|
51
|
+
sx: {
|
|
52
|
+
position: 'relative'
|
|
53
|
+
},
|
|
54
|
+
children: [/*#__PURE__*/_jsx(CardContent, {
|
|
50
55
|
children: /*#__PURE__*/_jsx(StyledImageGridContainer, {
|
|
51
56
|
children: /*#__PURE__*/_jsx(Grid, {
|
|
52
57
|
container: true,
|
|
@@ -81,7 +86,22 @@ const ImageGalleryGrid = _ref => {
|
|
|
81
86
|
}, image.id))
|
|
82
87
|
})
|
|
83
88
|
})
|
|
84
|
-
})
|
|
89
|
+
}), canAdd && /*#__PURE__*/_jsx(Tooltip, {
|
|
90
|
+
title: "Agregar imagen",
|
|
91
|
+
children: /*#__PURE__*/_jsx(Fab, {
|
|
92
|
+
color: "primary",
|
|
93
|
+
size: "small",
|
|
94
|
+
"aria-label": "Agregar imagen",
|
|
95
|
+
onClick: () => onImageSelect(null),
|
|
96
|
+
sx: {
|
|
97
|
+
position: 'absolute',
|
|
98
|
+
bottom: 16,
|
|
99
|
+
right: 16,
|
|
100
|
+
zIndex: 3
|
|
101
|
+
},
|
|
102
|
+
children: /*#__PURE__*/_jsx(AddIcon, {})
|
|
103
|
+
})
|
|
104
|
+
})]
|
|
85
105
|
});
|
|
86
106
|
};
|
|
87
107
|
ImageGalleryGrid.propTypes = {
|
|
@@ -102,6 +122,7 @@ ImageGalleryGrid.propTypes = {
|
|
|
102
122
|
onSetAsDefault: PropTypes.func,
|
|
103
123
|
onDownloadImage: PropTypes.func.isRequired,
|
|
104
124
|
canSetDefault: PropTypes.bool,
|
|
125
|
+
canAdd: PropTypes.bool,
|
|
105
126
|
defaultImageCode: PropTypes.string
|
|
106
127
|
};
|
|
107
128
|
export default ImageGalleryGrid;
|
|
@@ -32,6 +32,7 @@ export const useImageGallery = _ref => {
|
|
|
32
32
|
const [loading, setLoading] = useState(false);
|
|
33
33
|
const [removable, setRemovable] = useState(false);
|
|
34
34
|
const [canSetDefault, setCanSetDefault] = useState(false);
|
|
35
|
+
const [canAdd, setCanAdd] = useState(false);
|
|
35
36
|
|
|
36
37
|
// Process image codes into image list
|
|
37
38
|
useEffect(() => {
|
|
@@ -53,12 +54,7 @@ export const useImageGallery = _ref => {
|
|
|
53
54
|
const canRemoveMore = imageCount > minItems;
|
|
54
55
|
setRemovable(!!(updatable && allowDelete && imageCount > 0 && canRemoveMore));
|
|
55
56
|
const atMaxItems = maxItems != null && imageCount >= maxItems;
|
|
56
|
-
|
|
57
|
-
newList.push({
|
|
58
|
-
image_code: '+',
|
|
59
|
-
id: newList.length
|
|
60
|
-
});
|
|
61
|
-
}
|
|
57
|
+
setCanAdd(!!(updatable && multiple && !atMaxItems));
|
|
62
58
|
setCanSetDefault(!!(multiple && imageCount >= 2 && onSetAsDefault));
|
|
63
59
|
setImageList(newList);
|
|
64
60
|
}, [imageCodes, canEdit, multiple, updatable, maxItems, allowDelete, minItems, onSetAsDefault]);
|
|
@@ -228,6 +224,7 @@ export const useImageGallery = _ref => {
|
|
|
228
224
|
loading,
|
|
229
225
|
removable,
|
|
230
226
|
canSetDefault,
|
|
227
|
+
canAdd,
|
|
231
228
|
setZoomLevel,
|
|
232
229
|
handleOpenImage,
|
|
233
230
|
handleCloseImage,
|
package/lib/index.d.ts
CHANGED
|
@@ -93,6 +93,7 @@ export interface UseImageGalleryReturn {
|
|
|
93
93
|
loading: boolean;
|
|
94
94
|
removable: boolean;
|
|
95
95
|
canSetDefault: boolean;
|
|
96
|
+
canAdd: boolean;
|
|
96
97
|
setZoomLevel: (level: number) => void;
|
|
97
98
|
handleOpenImage: (imageUrl: string, index?: number) => void;
|
|
98
99
|
handleCloseImage: () => void;
|
|
@@ -137,6 +138,7 @@ export interface ImageGalleryGridProps {
|
|
|
137
138
|
onSetAsDefault?: (image: ImageItem) => void;
|
|
138
139
|
onDownloadImage: (imageCode: string) => void;
|
|
139
140
|
canSetDefault?: boolean;
|
|
141
|
+
canAdd?: boolean;
|
|
140
142
|
defaultImageCode?: string;
|
|
141
143
|
}
|
|
142
144
|
|
package/lib/index.js
CHANGED
|
@@ -120,8 +120,12 @@ export const CONFIG = {
|
|
|
120
120
|
};
|
|
121
121
|
|
|
122
122
|
// Export version info
|
|
123
|
-
export const VERSION = '1.2.
|
|
123
|
+
export const VERSION = '1.2.4';
|
|
124
124
|
export const CHANGELOG = [{
|
|
125
|
+
version: '1.2.4',
|
|
126
|
+
date: '2026-10-12',
|
|
127
|
+
changes: ['Replaced grid add placeholder tile with a floating action button over the image gallery when canAdd is true']
|
|
128
|
+
}, {
|
|
125
129
|
version: '1.2.3',
|
|
126
130
|
date: '2026-10-12',
|
|
127
131
|
changes: ['Added defaultImageCode, onSetAsDefault, onDelete, onUpdate, and onAdd lifecycle callbacks', 'Set-as-default control shown only when multiple is true and there are at least two images']
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mgonza02/goal-image-gallery",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4",
|
|
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",
|