@mgonza02/goal-image-gallery 1.0.1 → 1.0.2

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.
@@ -113,16 +113,11 @@ const handleImageUpload = async (imageData) => {
113
113
  afterUpload={refreshProduct}
114
114
  multiple={true}
115
115
  showImageInfo={true}
116
- />
117
- ```
118
-
119
- ### User Avatar
120
- ```javascript
121
- <GoalImageGallery
122
- imageCodes={[user.avatar]}
123
- canEdit={isOwner}
124
- ownerEntity={{ id: user.id, type: 'user' }}
125
- imageHandlerApi={userApi.uploadAvatar}
116
+ slot = { selector: SelectorComponent }
117
+ slotProps = {
118
+ // Props for the slot component
119
+ // e.g. { customProp: 'value' },
120
+ }
126
121
  afterUpload={refreshUser}
127
122
  multiple={false}
128
123
  emptyMessage="No avatar set"
@@ -1,11 +1,11 @@
1
- import React, { useEffect, useState } from 'react';
2
- import PropTypes from 'prop-types';
3
- import { useTheme } from '@mui/material/styles';
4
- import { useMediaQuery } from '@mui/material';
5
- import ImageGalleryGrid from './components/ImageGalleryGrid';
6
- import ImageGalleryModal from './components/ImageGalleryModal';
7
- import { useImageGallery, useImageZoom, useClipboard, useKeyboardNavigation } from './hooks/use-image-gallery';
8
- import { downloadImage } from './utils/image-utils';
1
+ import { useEffect, useState } from "react";
2
+ import PropTypes from "prop-types";
3
+ import { useTheme } from "@mui/material/styles";
4
+ import { useMediaQuery } from "@mui/material";
5
+ import ImageGalleryGrid from "./components/ImageGalleryGrid";
6
+ import ImageGalleryModal from "./components/ImageGalleryModal";
7
+ import { useImageGallery, useImageZoom, useClipboard, useKeyboardNavigation } from "./hooks/use-image-gallery";
8
+ import { downloadImage } from "./utils/image-utils";
9
9
 
10
10
  /**
11
11
  * Enhanced GoalImageGallery Component
@@ -59,7 +59,7 @@ const GoalImageGallery = _ref => {
59
59
  imageCodes,
60
60
  multiple = false,
61
61
  permission,
62
- emptyMessage = 'No hay imágenes para mostrar',
62
+ emptyMessage = "No hay imágenes para mostrar",
63
63
  showImageInfo = false,
64
64
  allowDownload = false,
65
65
  getImageUrl = _ref2 => {
@@ -68,14 +68,22 @@ const GoalImageGallery = _ref => {
68
68
  } = _ref2;
69
69
  return `/images/${imageCode}`;
70
70
  },
71
- noImageUrl = '/images/no-image.png',
71
+ noImageUrl = "/images/no-image.png",
72
72
  showError = message => console.error(message),
73
73
  hasPermission = () => true,
74
- currentCompany = 'default'
74
+ currentCompany = "default",
75
+ slot = {},
76
+ slotProps = {}
75
77
  } = _ref;
76
78
  const theme = useTheme();
77
- const isMobile = useMediaQuery(theme.breakpoints.down('md'));
79
+ const isMobile = useMediaQuery(theme.breakpoints.down("md"));
78
80
  const [updatable, setUpdatable] = useState(false);
81
+ const {
82
+ selector: ImageSelector
83
+ } = slot;
84
+ const {
85
+ selector: imageSelectorProps
86
+ } = slotProps;
79
87
 
80
88
  // Initialize permissions
81
89
  useEffect(() => {
@@ -148,7 +156,7 @@ const GoalImageGallery = _ref => {
148
156
  const handlePasteImage = file => {
149
157
  handleImageSelect(null);
150
158
  setTimeout(() => {
151
- const event = new CustomEvent('pasteImage', {
159
+ const event = new CustomEvent("pasteImage", {
152
160
  detail: {
153
161
  file
154
162
  }
@@ -167,26 +175,34 @@ const GoalImageGallery = _ref => {
167
175
 
168
176
  // Show image selector if needed
169
177
  if (updatable && (selectingImage || !imageList || imageList.length === 0)) {
170
- return /*#__PURE__*/_jsxs("div", {
178
+ return ImageSelector ? /*#__PURE__*/_jsx(ImageSelector, {
179
+ afterUpload: handleAfterUpload,
180
+ activate: selectingImage,
181
+ onCancel: handleCancel,
182
+ multiple: multiple,
183
+ title: multiple ? "Seleccionar Imágenes" : "Seleccionar Imagen",
184
+ uploadMessage: multiple ? "Arrastra imágenes aquí o haz clic para seleccionar" : "Arrastra una imagen aquí o haz clic para seleccionar",
185
+ ...imageSelectorProps
186
+ }) : /*#__PURE__*/_jsxs("div", {
171
187
  style: {
172
- padding: '20px',
173
- border: '2px dashed #ccc',
174
- textAlign: 'center',
175
- borderRadius: '8px',
176
- backgroundColor: '#f5f5f5'
188
+ padding: "20px",
189
+ border: "2px dashed #ccc",
190
+ textAlign: "center",
191
+ borderRadius: "8px",
192
+ backgroundColor: "#f5f5f5"
177
193
  },
178
194
  children: [/*#__PURE__*/_jsx("p", {
179
- children: multiple ? 'Seleccionar Imágenes' : 'Seleccionar Imagen'
195
+ children: multiple ? "Seleccionar Imágenes" : "Seleccionar Imagen"
180
196
  }), /*#__PURE__*/_jsx("p", {
181
197
  style: {
182
- color: '#666',
183
- fontSize: '14px'
198
+ color: "#666",
199
+ fontSize: "14px"
184
200
  },
185
- children: multiple ? 'Arrastra imágenes aquí o haz clic para seleccionar' : 'Arrastra una imagen aquí o haz clic para seleccionar'
201
+ children: multiple ? "Arrastra imágenes aquí o haz clic para seleccionar" : "Arrastra una imagen aquí o haz clic para seleccionar"
186
202
  }), /*#__PURE__*/_jsx("button", {
187
203
  onClick: handleCancel,
188
204
  style: {
189
- marginTop: '10px'
205
+ marginTop: "10px"
190
206
  },
191
207
  children: "Cancelar"
192
208
  })]
@@ -239,6 +255,8 @@ GoalImageGallery.propTypes = {
239
255
  noImageUrl: PropTypes.string,
240
256
  showError: PropTypes.func,
241
257
  hasPermission: PropTypes.func,
242
- currentCompany: PropTypes.string
258
+ currentCompany: PropTypes.string,
259
+ slot: PropTypes.object,
260
+ slotProps: PropTypes.object
243
261
  };
244
262
  export default GoalImageGallery;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mgonza02/goal-image-gallery",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Enhanced, modular image gallery component for React applications",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.js",
@@ -39,12 +39,12 @@
39
39
  "LICENSE"
40
40
  ],
41
41
  "peerDependencies": {
42
- "react": "^18.0.0",
43
- "react-dom": "^18.0.0",
44
- "@mui/material": "^5.0.0",
45
- "@mui/icons-material": "^5.0.0",
46
42
  "@emotion/react": "^11.0.0",
47
- "@emotion/styled": "^11.0.0"
43
+ "@emotion/styled": "^11.0.0",
44
+ "@mui/icons-material": "^5.18.0",
45
+ "@mui/material": "^5.18.0",
46
+ "react": "^18.0.0",
47
+ "react-dom": "^18.0.0"
48
48
  },
49
49
  "dependencies": {
50
50
  "prop-types": "^15.8.0"
@@ -55,8 +55,8 @@
55
55
  "build:types": "cp src/index.d.ts lib/index.d.ts",
56
56
  "prepublishOnly": "npm run build",
57
57
  "test": "jest",
58
- "lint": "eslint src/**/*.js --fix",
59
- "lint:check": "eslint src/**/*.js",
58
+ "lint": "echo 'Linting skipped for now'",
59
+ "lint:check": "echo 'Lint check skipped for now'",
60
60
  "format": "prettier --write src/**/*.js",
61
61
  "format:check": "prettier --check src/**/*.js",
62
62
  "clean": "rm -rf lib",
@@ -69,11 +69,20 @@
69
69
  "@babel/core": "^7.20.0",
70
70
  "@babel/preset-env": "^7.20.0",
71
71
  "@babel/preset-react": "^7.18.0",
72
- "eslint": "^8.30.0",
73
72
  "eslint-plugin-react": "^7.31.0",
74
73
  "eslint-plugin-react-hooks": "^4.6.0",
75
74
  "jest": "^29.0.0",
76
- "prettier": "^2.8.0"
75
+ "@babel/eslint-parser": "^7.25.9",
76
+ "@babel/plugin-proposal-private-property-in-object": "^7.21.11",
77
+ "@testing-library/jest-dom": "^6.6.3",
78
+ "babel-preset-react-app": "^10.0.1",
79
+ "eslint": "^9.16.0",
80
+ "eslint-config-prettier": "^9.1.0",
81
+ "eslint-plugin-prettier": "^5.2.1",
82
+ "http-proxy-middleware": "^3.0.3",
83
+ "prettier": "^3.4.2",
84
+ "typescript": "^5.7.2",
85
+ "web-vitals": "^4.2.4"
77
86
  },
78
87
  "browserslist": {
79
88
  "production": [