@neatui/vue 2.7.1 → 2.7.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": "@neatui/vue",
3
- "version": "2.7.1",
3
+ "version": "2.7.3",
4
4
  "description": "basic component ui",
5
5
  "main": "./src/index.ts",
6
6
  "license": "MIT",
@@ -13,8 +13,8 @@
13
13
  const props = defineProps({
14
14
  lists: {
15
15
  type: Array as PropType<any[]>,
16
- default: () => []
17
- }
16
+ default: () => [],
17
+ },
18
18
  });
19
19
  const emit = defineEmits(['update:lists']);
20
20
 
@@ -25,14 +25,14 @@
25
25
  watch(
26
26
  () => props.lists,
27
27
  (newVal, oldVal) => {
28
- console.log('IDraggable props.lists changed:', {
29
- newLength: newVal?.length,
30
- oldLength: oldVal?.length,
31
- newVal: newVal?.map((item) => item.label || item.field),
32
- oldVal: oldVal?.map((item) => item.label || item.field)
33
- });
28
+ // console.log('IDraggable props.lists changed:', {
29
+ // newLength: newVal?.length,
30
+ // oldLength: oldVal?.length,
31
+ // newVal: newVal?.map((item) => item.label || item.field),
32
+ // oldVal: oldVal?.map((item) => item.label || item.field)
33
+ // });
34
34
  },
35
- { deep: true }
35
+ { deep: true },
36
36
  );
37
37
 
38
38
  onMounted(() => {
@@ -54,13 +54,13 @@
54
54
 
55
55
  console.log(
56
56
  'Emitting new list:',
57
- newList.map((item) => item.label || item.field)
57
+ newList.map((item) => item.label || item.field),
58
58
  );
59
59
 
60
60
  // 通知父组件更新数据
61
61
  emit('update:lists', newList);
62
62
  }
63
- }
63
+ },
64
64
  });
65
65
  }
66
66
  });
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <div ui-flex="row lm :wrap" class="neatui-upload mb-sm-sub mr-sm-sub" v-bind="{ ...attrs }">
3
- <div v-for="(file, idx) in state.files" :key="idx" ui-flex="col cm" class="flex-fixed bg-fore n-sl w-ms h-ms b-solid bk-case b-xs r-sm pr">
3
+ <div v-for="(file, idx) in state.files" :key="idx" ui-flex="col cm" class="flex-fixed bg-fore n-sl w-ms h-ms b-solid bk-case b-xs r-sm pr" v-bind="itemAttrs">
4
4
  <!-- 删除按钮 -->
5
5
  <div class="pa ot-ss or-ss bg-fore co-risk lh-xs r-xl parent-hover:show" @click="remove(idx)">
6
6
  <svg class="block" viewBox="0 0 1024 1024" style="width: 1em; height: 1em">
@@ -147,7 +147,7 @@
147
147
  </svg>
148
148
  </template>
149
149
 
150
- <!-- 上传状态显示 -->
150
+ <!-- 上传状态 -->
151
151
  <div v-if="file.status === 'uploading'" class="upload-status">
152
152
  <div class="loading-spinner"></div>
153
153
  <span class="status-text">上传中...</span>
@@ -155,14 +155,11 @@
155
155
  <div v-else-if="file.status === 'error'" class="upload-status error">
156
156
  <span class="status-text">上传失败</span>
157
157
  </div>
158
-
159
- <!-- 文件名 -->
160
- <!-- <p ui-omit="1" class="fs-ss ac">{{ file.name }}</p> -->
161
158
  </div>
162
159
 
163
160
  <!-- 上传按钮 -->
164
161
  <div v-if="showUploadButton">
165
- <slot>
162
+ <slot name="btn">
166
163
  <label ui-flex="row cm" ui-form="@a type:upload tips:hover" :class="`upload w-ms h-ms n-sl bg-fore b-solid bk-case b-xs r-sm ${uploadClass}`" :style="uploadStyle">
167
164
  <div v-if="tips" ui-form-tips>
168
165
  {{ tips }}
@@ -189,6 +186,7 @@
189
186
  modelValue?: string | any[];
190
187
  max?: number;
191
188
  attrs?: object;
189
+ itemAttrs?: object;
192
190
  uploadClass?: string;
193
191
  uploadStyle?: string;
194
192
  tips?: string;
@@ -196,6 +194,7 @@
196
194
  upload?: (formData: FormData) => Promise<any>;
197
195
  maxSize?: number;
198
196
  compress?: boolean;
197
+ disabled?: boolean;
199
198
  }
200
199
 
201
200
  const props = withDefaults(defineProps<Props>(), {
@@ -203,12 +202,14 @@
203
202
  uploadClass: '',
204
203
  uploadStyle: '',
205
204
  attrs: () => ({}),
206
- tips: '', // 提示文案
207
- accept: '*', // 文件类型
208
- upload: async () => null, // 请求上传接口
209
- maxSize: 10, // 文件大小限制(MB)
210
- compress: true, // 是否启用图片压缩
211
- max: 0 // 文件数量限制
205
+ itemAttrs: () => ({}),
206
+ tips: '',
207
+ accept: '*',
208
+ upload: async () => null,
209
+ maxSize: 10,
210
+ compress: true,
211
+ max: 0,
212
+ disabled: false,
212
213
  });
213
214
 
214
215
  interface UploadFile {
@@ -226,7 +227,7 @@
226
227
  isInternalUpdate: boolean; // 标记是否为内部更新
227
228
  }>({
228
229
  files: [],
229
- isInternalUpdate: false
230
+ isInternalUpdate: false,
230
231
  });
231
232
 
232
233
  const emit = defineEmits(['update:modelValue', 'change', 'error']);
@@ -314,7 +315,7 @@
314
315
  success: (result) => {
315
316
  resolve(new File([result], file.name, { type: result.type }));
316
317
  },
317
- error: reject
318
+ error: reject,
318
319
  });
319
320
  });
320
321
  };
@@ -395,7 +396,7 @@
395
396
  type: getFileType(file),
396
397
  path: previewUrl,
397
398
  status: 'uploading',
398
- size: file.size
399
+ size: file.size,
399
400
  };
400
401
  state.files.push(uploadFile);
401
402
  validFiles.push({ file, uploadFile });
@@ -475,7 +476,7 @@
475
476
  type: 'image',
476
477
  path: item,
477
478
  status: 'success' as const,
478
- result: item
479
+ result: item,
479
480
  };
480
481
  } else {
481
482
  // 如果是对象
@@ -484,7 +485,7 @@
484
485
  type: item.type || 'file',
485
486
  path: item.url || item.path || '',
486
487
  status: 'success' as const,
487
- result: item
488
+ result: item,
488
489
  };
489
490
  }
490
491
  });
@@ -495,8 +496,8 @@
495
496
  type: 'image',
496
497
  path: newValue,
497
498
  status: 'success',
498
- result: newValue
499
- }
499
+ result: newValue,
500
+ },
500
501
  ];
501
502
  } else if (newValue && typeof newValue === 'object') {
502
503
  const objValue = newValue as any;
@@ -506,14 +507,14 @@
506
507
  type: objValue.type || 'file',
507
508
  path: objValue.url || objValue.path || '',
508
509
  status: 'success',
509
- result: newValue
510
- }
510
+ result: newValue,
511
+ },
511
512
  ];
512
513
  } else {
513
514
  state.files = [];
514
515
  }
515
516
  },
516
- { immediate: true, deep: true }
517
+ { immediate: true, deep: true },
517
518
  );
518
519
 
519
520
  // 组件销毁时清理资源