sprintify-ui 0.0.193 → 0.0.194

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": "sprintify-ui",
3
- "version": "0.0.193",
3
+ "version": "0.0.194",
4
4
  "scripts": {
5
5
  "build": "rimraf dist && vue-tsc && vite build",
6
6
  "build-fast": "rimraf dist && vite build",
@@ -53,12 +53,12 @@
53
53
  </BaseFileUploader>
54
54
 
55
55
  <div
56
- v-if="currentMediaInternal.length + normalizedModelValue.to_add.length"
56
+ v-if="filteredCurrentMedia.length + normalizedModelValue.to_add.length"
57
57
  class="mt-5"
58
58
  >
59
59
  <div class="-m-1 flex flex-wrap">
60
60
  <div
61
- v-for="(media, index) in currentMediaInternal"
61
+ v-for="(media, index) in filteredCurrentMedia"
62
62
  :key="media.id"
63
63
  class="min-w-[220px] flex-1 p-1"
64
64
  >
@@ -173,6 +173,12 @@ const emit = defineEmits([
173
173
  'upload:end',
174
174
  ]);
175
175
 
176
+ const filteredCurrentMedia = computed(() => {
177
+ return props.currentMedia.filter((media) => {
178
+ return !normalizedModelValue.value.to_remove.includes(media.id);
179
+ });
180
+ });
181
+
176
182
  const { emitUpdate, enableForm, disableForm } = useField({
177
183
  name: computed(() => props.name),
178
184
  required: computed(() => false),
@@ -189,8 +195,6 @@ const normalizedMax = computed(() => {
189
195
  return props.max;
190
196
  });
191
197
 
192
- const currentMediaInternal = ref(cloneDeep(props.currentMedia));
193
-
194
198
  const normalizedModelValue = computed(() => {
195
199
  if (
196
200
  props.modelValue &&
@@ -209,7 +213,7 @@ const normalizedModelValue = computed(() => {
209
213
 
210
214
  const numberOfFiles = computed((): number => {
211
215
  return (
212
- currentMediaInternal.value.length +
216
+ props.currentMedia.length +
213
217
  (props.modelValue?.to_add.length ?? 0) -
214
218
  (props.modelValue?.to_remove.length ?? 0)
215
219
  );
@@ -241,9 +245,8 @@ function onUploadSuccess(file: UploadedFile) {
241
245
 
242
246
  if (normalizedMax.value == 1) {
243
247
  // Remove everything...
244
- modelValue.to_remove.push(...currentMediaInternal.value.map((m) => m.id));
248
+ modelValue.to_remove.push(...props.currentMedia.map((m) => m.id));
245
249
  modelValue.to_add = [];
246
- currentMediaInternal.value = [];
247
250
  }
248
251
 
249
252
  modelValue.to_add.push(file);
@@ -284,7 +287,7 @@ function removeUploadedFile(index: number, length = 1) {
284
287
  }
285
288
 
286
289
  function removeMedia(index: number) {
287
- const media = currentMediaInternal.value[index];
290
+ const media = props.currentMedia[index];
288
291
 
289
292
  if (media) {
290
293
  const modelValue = cloneDeep(normalizedModelValue.value);
@@ -292,8 +295,6 @@ function removeMedia(index: number) {
292
295
  modelValue.to_remove.push(media.id);
293
296
 
294
297
  sync(modelValue);
295
-
296
- currentMediaInternal.value.splice(index, 1);
297
298
  }
298
299
  }
299
300