@wzyjs/antd 0.3.2 → 0.3.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wzyjs/antd",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "description": "description",
5
5
  "author": "wzy",
6
6
  "main": "src/index.ts",
@@ -20,7 +20,7 @@
20
20
  "@wzyjs/utils": "^0.2.37",
21
21
  "antd": "^5.24.3"
22
22
  },
23
- "gitHead": "22c3d24e9f596ff0171bf93c85d17c9615690981",
23
+ "gitHead": "c0a83557cdfb520becc4d5924f1b101e0bd43d1e",
24
24
  "publishConfig": {
25
25
  "access": "public"
26
26
  }
@@ -20,7 +20,7 @@ export const RadioButton = <V = string | number | boolean | null>(props: FilterB
20
20
  buttonStyle={buttonStyle}
21
21
  value={value}
22
22
  style={style}
23
- onChange={e => onChange(e.target.value as V)}
23
+ onChange={e => onChange?.(e.target.value as V)}
24
24
  >
25
25
  {options.filter(item => item.label).map(item => (
26
26
  <Radio key={String(item.value)} value={item.value}>{item.label}</Radio>
@@ -8,6 +8,7 @@ interface UploadImageProps {
8
8
  value?: string[];
9
9
  onChange?: (value: string[]) => void;
10
10
  maxImages?: number;
11
+ enablePreview?: boolean;
11
12
  enableDragDrop?: boolean;
12
13
  enableFileSelect?: boolean;
13
14
  enablePaste?: boolean;
@@ -19,6 +20,7 @@ export const UploadImage = (props: UploadImageProps) => {
19
20
  value = [],
20
21
  onChange,
21
22
  maxImages = 10,
23
+ enablePreview = false,
22
24
  enableDragDrop = false,
23
25
  enableFileSelect = false,
24
26
  enablePaste = true,
@@ -206,47 +208,62 @@ export const UploadImage = (props: UploadImageProps) => {
206
208
  return (
207
209
  <div className='w-full space-y-4'>
208
210
  <div className='flex flex-wrap gap-3'>
209
- {value.map((image, index) => (
210
- <div
211
- key={index}
212
- className='relative'
213
- style={{ width: '100px', height: '100px' }}
214
- >
215
- <Popover
216
- trigger='hover'
217
- placement='top'
218
- content={(
219
- <img
220
- src={image}
221
- alt={`预览图片 ${index + 1}`}
222
- style={{
223
- maxWidth: '300px',
224
- maxHeight: '300px',
225
- }}
226
- />
227
- )}
211
+ {value.map((image, index) => {
212
+ const imageNode = (
213
+ <div
214
+ className='rounded border overflow-hidden relative group bg-white'
215
+ style={{ maxWidth: 200, maxHeight: 200 }}
228
216
  >
229
- <div className='rounded border overflow-hidden h-full w-full relative group'>
230
- <img
231
- src={image}
232
- alt={`上传图片 ${index + 1}`}
233
- className='w-full h-full object-cover'
234
- />
235
- <Button
236
- type='text'
237
- icon={<DeleteOutlined />}
238
- onClick={(e) => {
239
- e.stopPropagation()
240
- handleRemoveImage(index)
241
- }}
242
- style={{ position: 'absolute', top: 0, right: 0 }}
243
- className='absolute top-0 right-0 bg-black/40 text-white border-none hover:bg-black/60'
244
- size='small'
245
- />
217
+ <img
218
+ src={image}
219
+ alt={`图片 ${index + 1}`}
220
+ className='object-contain'
221
+ style={{ maxWidth: '100%', maxHeight: '100%', display: 'block' }}
222
+ />
223
+ <Button
224
+ type='text'
225
+ icon={<DeleteOutlined />}
226
+ onClick={(e) => {
227
+ e.stopPropagation()
228
+ handleRemoveImage(index)
229
+ }}
230
+ style={{ position: 'absolute', top: 0, right: 0 }}
231
+ className='absolute top-0 right-0 bg-black/40 text-white border-none hover:bg-black/60'
232
+ size='small'
233
+ />
234
+ </div>
235
+ )
236
+
237
+ if (!enablePreview) {
238
+ return (
239
+ <div key={index} className='relative'>
240
+ {imageNode}
246
241
  </div>
247
- </Popover>
248
- </div>
249
- ))}
242
+ )
243
+ }
244
+
245
+ return (
246
+ <div key={index} className='relative'>
247
+ <Popover
248
+ trigger='hover'
249
+ placement='top'
250
+ content={(
251
+ <img
252
+ src={image}
253
+ alt={`预览图片 ${index + 1}`}
254
+ style={{
255
+ maxWidth: '200px',
256
+ maxHeight: '200px',
257
+ objectFit: 'contain',
258
+ }}
259
+ />
260
+ )}
261
+ >
262
+ {imageNode}
263
+ </Popover>
264
+ </div>
265
+ )
266
+ })}
250
267
 
251
268
  {value.length < maxImages && (
252
269
  <Space style={{ width: '100%' }}>