sprintify-ui 0.1.5 → 0.1.7

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.1.5",
3
+ "version": "0.1.7",
4
4
  "scripts": {
5
5
  "build": "rimraf dist && vue-tsc && vite build",
6
6
  "build-fast": "rimraf dist && vite build",
@@ -312,8 +312,6 @@ async function save(
312
312
  circle: false,
313
313
  };
314
314
 
315
- console.log(resultConfig);
316
-
317
315
  const r = await cropper.result(resultConfig);
318
316
 
319
317
  saving.value = false;
@@ -52,6 +52,7 @@ const emit = defineEmits(['select']);
52
52
 
53
53
  const showCropperModal = ref(false);
54
54
  const cropperSource = ref('');
55
+ let filename = '';
55
56
 
56
57
  const cropperInternal = computed<BaseCropperConfig | null>(() => {
57
58
  if (!cropperSource.value) {
@@ -75,6 +76,8 @@ async function launchCropper(file: File) {
75
76
  return;
76
77
  }
77
78
 
79
+ filename = file.name;
80
+
78
81
  showCropperModal.value = false;
79
82
  cropperSource.value = await blobToBase64(file);
80
83
 
@@ -87,7 +90,7 @@ async function launchCropper(file: File) {
87
90
 
88
91
  async function onCropped(cropped: HTMLCanvasElement | string | Blob) {
89
92
  if (cropped instanceof Blob) {
90
- emit('select', cropped);
93
+ emitUpdate(cropped);
91
94
  return;
92
95
  }
93
96
 
@@ -102,15 +105,23 @@ async function onCropped(cropped: HTMLCanvasElement | string | Blob) {
102
105
  });
103
106
  });
104
107
 
105
- emit('select', blob);
108
+ emitUpdate(blob);
106
109
 
107
110
  return;
108
111
  }
109
112
 
110
113
  if (typeof cropped === 'string') {
111
114
  const blob = await fetch(cropped).then((r) => r.blob());
112
- emit('select', blob);
115
+ emitUpdate(blob);
113
116
  return;
114
117
  }
115
118
  }
119
+
120
+ function emitUpdate(blob: Blob) {
121
+ const file = new File([blob], filename, {
122
+ type: blob.type,
123
+ });
124
+
125
+ emit('select', file);
126
+ }
116
127
  </script>
@@ -28,6 +28,7 @@
28
28
  </a>
29
29
  <button
30
30
  v-if="showRemove"
31
+ type="button"
31
32
  :disabled="disabled"
32
33
  class="btn btn-white rounded-full p-1 shadow-sm ring-1 ring-black ring-opacity-10 disabled:bg-white disabled:opacity-70"
33
34
  @click="$emit('remove')"