@bagelink/vue 0.0.374 → 0.0.378

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.
@@ -1 +1 @@
1
- {"version":3,"file":"FileUpload.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/form/inputs/FileUpload.vue"],"names":[],"mappings":"AA8FA;AAGA,OAAO,EACD,KAAK,WAAW,EACrB,MAAM,eAAe,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4ZvB,wBAcG"}
1
+ {"version":3,"file":"FileUpload.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/form/inputs/FileUpload.vue"],"names":[],"mappings":"AAkEA;AAGA,OAAO,EAAO,KAAK,WAAW,EAA0B,MAAM,eAAe,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAya9E,wBAcG"}
package/dist/index.cjs CHANGED
@@ -4793,7 +4793,7 @@ class Bagel {
4793
4793
  async uploadFile(file, options) {
4794
4794
  const formData = new FormData();
4795
4795
  formData.append("file", file);
4796
- const { data: data2 } = await axios.post("/files/upload", formData, {
4796
+ const { data: data2 } = await axios.post("/static_files/upload", formData, {
4797
4797
  headers: {
4798
4798
  "Content-Type": "multipart/form-data"
4799
4799
  },
@@ -18435,20 +18435,28 @@ const _sfc_main$a = /* @__PURE__ */ vue.defineComponent({
18435
18435
  const file_ids = vue.useModel(__props, "modelValue");
18436
18436
  const storageFiles = vue.ref([]);
18437
18437
  const compareIds = (v1, v2) => [v1].flat().join(",") === [v2].flat().join(",");
18438
- vue.watch(() => props2.files, (newFiles) => {
18439
- if (newFiles)
18440
- storageFiles.value.push(...[newFiles].flat());
18441
- }, { immediate: true });
18442
- vue.watch(() => storageFiles.value, (newFiles) => {
18443
- var _a2;
18444
- let idValue = "";
18445
- if (props2.multiple)
18446
- idValue = newFiles.map((f2) => f2.id || "");
18447
- else
18448
- idValue = ((_a2 = newFiles[0]) == null ? void 0 : _a2.id) || "";
18449
- if (!compareIds(file_ids == null ? void 0 : file_ids.value, idValue))
18450
- file_ids.value = idValue;
18451
- }, { deep: true });
18438
+ vue.watch(
18439
+ () => props2.files,
18440
+ (newFiles) => {
18441
+ if (newFiles)
18442
+ storageFiles.value.push(...[newFiles].flat());
18443
+ },
18444
+ { immediate: true }
18445
+ );
18446
+ vue.watch(
18447
+ () => storageFiles.value,
18448
+ (newFiles) => {
18449
+ var _a2;
18450
+ let idValue = "";
18451
+ if (props2.multiple)
18452
+ idValue = newFiles.map((f2) => f2.id || "");
18453
+ else
18454
+ idValue = ((_a2 = newFiles[0]) == null ? void 0 : _a2.id) || "";
18455
+ if (!compareIds(file_ids == null ? void 0 : file_ids.value, idValue))
18456
+ file_ids.value = idValue;
18457
+ },
18458
+ { deep: true }
18459
+ );
18452
18460
  const fileQueue = vue.ref([]);
18453
18461
  let isDragOver = vue.ref(false);
18454
18462
  const preventDefault = (e) => {
@@ -18459,21 +18467,20 @@ const _sfc_main$a = /* @__PURE__ */ vue.defineComponent({
18459
18467
  const removeFile = (file) => {
18460
18468
  const index2 = storageFiles.value.indexOf(file);
18461
18469
  storageFiles.value.splice(index2, 1);
18462
- if (props2.deleteEndpoint)
18470
+ if (props2.deleteEndpoint) {
18463
18471
  void bagel.delete(`${props2.deleteEndpoint}/${file.id}`);
18472
+ }
18464
18473
  };
18465
18474
  const flushQueue = () => {
18466
- fileQueue.value.forEach(
18467
- async (file, i2) => {
18468
- if (!props2.multiple)
18469
- storageFiles.value.splice(0, 1);
18470
- const serverFile = await bagel.uploadFile(file.file, {
18471
- onUploadProgress: (e) => file.progress = e.progress * 100 - 1
18472
- });
18473
- storageFiles.value.push(serverFile);
18474
- fileQueue.value.splice(i2, 1);
18475
- }
18476
- );
18475
+ fileQueue.value.forEach(async (file, i2) => {
18476
+ if (!props2.multiple)
18477
+ storageFiles.value.splice(0, 1);
18478
+ const serverFile = await bagel.uploadFile(file.file, {
18479
+ onUploadProgress: (e) => file.progress = e.progress * 100 - 1
18480
+ });
18481
+ storageFiles.value.push(serverFile);
18482
+ fileQueue.value.splice(i2, 1);
18483
+ });
18477
18484
  };
18478
18485
  const browse = () => {
18479
18486
  const input = document.createElement("input");
@@ -18482,7 +18489,9 @@ const _sfc_main$a = /* @__PURE__ */ vue.defineComponent({
18482
18489
  input.onchange = (e) => {
18483
18490
  const target = e == null ? void 0 : e.target;
18484
18491
  if (target == null ? void 0 : target.files) {
18485
- Array.from(target.files).forEach((file) => fileQueue.value.push({ name: file.name, file, progress: 0 }));
18492
+ Array.from(target.files).forEach(
18493
+ (file) => fileQueue.value.push({ name: file.name, file, progress: 0 })
18494
+ );
18486
18495
  }
18487
18496
  flushQueue();
18488
18497
  };
@@ -18520,7 +18529,10 @@ const _sfc_main$a = /* @__PURE__ */ vue.defineComponent({
18520
18529
  onDragover: dragover,
18521
18530
  onDrop: drop3,
18522
18531
  onDragleave: dragleave,
18523
- class: vue.normalizeClass(["fileUploadWrap", { fileDropZone: !storageFiles.value.length && !fileQueue.value.length, dragover: vue.unref(isDragOver) }])
18532
+ class: vue.normalizeClass(["fileUploadWrap", {
18533
+ fileDropZone: !storageFiles.value.length && !fileQueue.value.length,
18534
+ dragover: vue.unref(isDragOver)
18535
+ }])
18524
18536
  }, [
18525
18537
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(storageFiles.value, (file) => {
18526
18538
  return vue.openBlock(), vue.createElementBlock(vue.Fragment, {
@@ -18590,7 +18602,7 @@ const _sfc_main$a = /* @__PURE__ */ vue.defineComponent({
18590
18602
  };
18591
18603
  }
18592
18604
  });
18593
- const FileUpload = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["__scopeId", "data-v-1be8d7b1"]]);
18605
+ const FileUpload = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["__scopeId", "data-v-3bb24b0c"]]);
18594
18606
  const _withScopeId = (n2) => (vue.pushScopeId("data-v-b87221d6"), n2 = n2(), vue.popScopeId(), n2);
18595
18607
  const _hoisted_1$e = ["title"];
18596
18608
  const _hoisted_2$b = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ vue.createElementVNode("span", { class: "slider round" }, null, -1));
package/dist/index.mjs CHANGED
@@ -4791,7 +4791,7 @@ class Bagel {
4791
4791
  async uploadFile(file, options) {
4792
4792
  const formData = new FormData();
4793
4793
  formData.append("file", file);
4794
- const { data: data2 } = await axios.post("/files/upload", formData, {
4794
+ const { data: data2 } = await axios.post("/static_files/upload", formData, {
4795
4795
  headers: {
4796
4796
  "Content-Type": "multipart/form-data"
4797
4797
  },
@@ -18433,20 +18433,28 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
18433
18433
  const file_ids = useModel(__props, "modelValue");
18434
18434
  const storageFiles = ref([]);
18435
18435
  const compareIds = (v1, v2) => [v1].flat().join(",") === [v2].flat().join(",");
18436
- watch(() => props2.files, (newFiles) => {
18437
- if (newFiles)
18438
- storageFiles.value.push(...[newFiles].flat());
18439
- }, { immediate: true });
18440
- watch(() => storageFiles.value, (newFiles) => {
18441
- var _a2;
18442
- let idValue = "";
18443
- if (props2.multiple)
18444
- idValue = newFiles.map((f2) => f2.id || "");
18445
- else
18446
- idValue = ((_a2 = newFiles[0]) == null ? void 0 : _a2.id) || "";
18447
- if (!compareIds(file_ids == null ? void 0 : file_ids.value, idValue))
18448
- file_ids.value = idValue;
18449
- }, { deep: true });
18436
+ watch(
18437
+ () => props2.files,
18438
+ (newFiles) => {
18439
+ if (newFiles)
18440
+ storageFiles.value.push(...[newFiles].flat());
18441
+ },
18442
+ { immediate: true }
18443
+ );
18444
+ watch(
18445
+ () => storageFiles.value,
18446
+ (newFiles) => {
18447
+ var _a2;
18448
+ let idValue = "";
18449
+ if (props2.multiple)
18450
+ idValue = newFiles.map((f2) => f2.id || "");
18451
+ else
18452
+ idValue = ((_a2 = newFiles[0]) == null ? void 0 : _a2.id) || "";
18453
+ if (!compareIds(file_ids == null ? void 0 : file_ids.value, idValue))
18454
+ file_ids.value = idValue;
18455
+ },
18456
+ { deep: true }
18457
+ );
18450
18458
  const fileQueue = ref([]);
18451
18459
  let isDragOver = ref(false);
18452
18460
  const preventDefault = (e) => {
@@ -18457,21 +18465,20 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
18457
18465
  const removeFile = (file) => {
18458
18466
  const index2 = storageFiles.value.indexOf(file);
18459
18467
  storageFiles.value.splice(index2, 1);
18460
- if (props2.deleteEndpoint)
18468
+ if (props2.deleteEndpoint) {
18461
18469
  void bagel.delete(`${props2.deleteEndpoint}/${file.id}`);
18470
+ }
18462
18471
  };
18463
18472
  const flushQueue = () => {
18464
- fileQueue.value.forEach(
18465
- async (file, i2) => {
18466
- if (!props2.multiple)
18467
- storageFiles.value.splice(0, 1);
18468
- const serverFile = await bagel.uploadFile(file.file, {
18469
- onUploadProgress: (e) => file.progress = e.progress * 100 - 1
18470
- });
18471
- storageFiles.value.push(serverFile);
18472
- fileQueue.value.splice(i2, 1);
18473
- }
18474
- );
18473
+ fileQueue.value.forEach(async (file, i2) => {
18474
+ if (!props2.multiple)
18475
+ storageFiles.value.splice(0, 1);
18476
+ const serverFile = await bagel.uploadFile(file.file, {
18477
+ onUploadProgress: (e) => file.progress = e.progress * 100 - 1
18478
+ });
18479
+ storageFiles.value.push(serverFile);
18480
+ fileQueue.value.splice(i2, 1);
18481
+ });
18475
18482
  };
18476
18483
  const browse = () => {
18477
18484
  const input = document.createElement("input");
@@ -18480,7 +18487,9 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
18480
18487
  input.onchange = (e) => {
18481
18488
  const target = e == null ? void 0 : e.target;
18482
18489
  if (target == null ? void 0 : target.files) {
18483
- Array.from(target.files).forEach((file) => fileQueue.value.push({ name: file.name, file, progress: 0 }));
18490
+ Array.from(target.files).forEach(
18491
+ (file) => fileQueue.value.push({ name: file.name, file, progress: 0 })
18492
+ );
18484
18493
  }
18485
18494
  flushQueue();
18486
18495
  };
@@ -18518,7 +18527,10 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
18518
18527
  onDragover: dragover,
18519
18528
  onDrop: drop3,
18520
18529
  onDragleave: dragleave,
18521
- class: normalizeClass(["fileUploadWrap", { fileDropZone: !storageFiles.value.length && !fileQueue.value.length, dragover: unref(isDragOver) }])
18530
+ class: normalizeClass(["fileUploadWrap", {
18531
+ fileDropZone: !storageFiles.value.length && !fileQueue.value.length,
18532
+ dragover: unref(isDragOver)
18533
+ }])
18522
18534
  }, [
18523
18535
  (openBlock(true), createElementBlock(Fragment$1, null, renderList(storageFiles.value, (file) => {
18524
18536
  return openBlock(), createElementBlock(Fragment$1, {
@@ -18588,7 +18600,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
18588
18600
  };
18589
18601
  }
18590
18602
  });
18591
- const FileUpload = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["__scopeId", "data-v-1be8d7b1"]]);
18603
+ const FileUpload = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["__scopeId", "data-v-3bb24b0c"]]);
18592
18604
  const _withScopeId = (n2) => (pushScopeId("data-v-b87221d6"), n2 = n2(), popScopeId(), n2);
18593
18605
  const _hoisted_1$e = ["title"];
18594
18606
  const _hoisted_2$b = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("span", { class: "slider round" }, null, -1));
package/dist/style.css CHANGED
@@ -1477,7 +1477,7 @@ display: block;
1477
1477
  color: var(--bgl-white);
1478
1478
  }
1479
1479
 
1480
- .bagel-input .fileUploadWrap[data-v-1be8d7b1] {
1480
+ .bagel-input .fileUploadWrap[data-v-3bb24b0c] {
1481
1481
  outline: 1px solid var(--border-color);
1482
1482
  border-radius: var(--input-border-radius);
1483
1483
  text-align: center;
@@ -1487,45 +1487,46 @@ display: block;
1487
1487
  height: 132px;
1488
1488
  font-size: var(--input-font-size);
1489
1489
  }
1490
- .previewName[data-v-1be8d7b1] {
1490
+ .previewName[data-v-3bb24b0c] {
1491
1491
  padding: 0.5rem;
1492
1492
  text-align: start;
1493
1493
  color: var(--input-color);
1494
1494
  display: grid;
1495
1495
  grid-template-columns: 1fr 22px;
1496
1496
  align-items: center;
1497
+ padding-inline: 14px;
1497
1498
  }
1498
- .previewName p[data-v-1be8d7b1] {
1499
+ .previewName p[data-v-3bb24b0c] {
1499
1500
  overflow: hidden;
1500
1501
  text-overflow: ellipsis;
1501
1502
  white-space: nowrap;
1502
1503
  }
1503
- .imagePreviewWrap[data-v-1be8d7b1] {
1504
+ .imagePreviewWrap[data-v-3bb24b0c] {
1504
1505
  background: var(--input-bg);
1505
1506
  border-radius: var(--input-border-radius);
1506
1507
  height: 90px;
1507
1508
  padding: 5px;
1508
1509
  }
1509
- img.preview[data-v-1be8d7b1] {
1510
+ img.preview[data-v-3bb24b0c] {
1510
1511
  height: 80px;
1511
1512
  border-radius: var(--input-border-radius);
1512
1513
  object-fit: contain;
1513
1514
  }
1514
- .fileUploadWrap.dragover[data-v-1be8d7b1],
1515
- .fileUploadWrap[data-v-1be8d7b1]:hover {
1515
+ .fileUploadWrap.dragover[data-v-3bb24b0c],
1516
+ .fileUploadWrap[data-v-3bb24b0c]:hover {
1516
1517
  box-shadow: inset 0 0 10px #00000012;
1517
1518
  }
1518
- .bagel-input .fileUploadWrap.fileDropZone[data-v-1be8d7b1] {
1519
+ .bagel-input .fileUploadWrap.fileDropZone[data-v-3bb24b0c] {
1519
1520
  background: var(--input-bg);
1520
1521
  display: flex;
1521
1522
  align-items: center;
1522
1523
  justify-content: center;
1523
1524
  color: var(--bgl-gray);
1524
1525
  }
1525
- .bagel-input .fileUploadWrap.fileDropZone[data-v-1be8d7b1]:after {
1526
- content: "Drop files here or click to upload";
1526
+ .bagel-input .fileUploadWrap.fileDropZone[data-v-3bb24b0c]:after {
1527
+ content: 'Drop files here or click to upload';
1527
1528
  }
1528
- .pie[data-v-1be8d7b1] {
1529
+ .pie[data-v-3bb24b0c] {
1529
1530
  width: 30px;
1530
1531
  height: 30px;
1531
1532
  position: relative;
@@ -1533,40 +1534,44 @@ img.preview[data-v-1be8d7b1] {
1533
1534
  align-items: center;
1534
1535
  justify-content: center;
1535
1536
  }
1536
- .pie[data-v-1be8d7b1]:before {
1537
- content: "";
1537
+ .pie[data-v-3bb24b0c]:before {
1538
+ content: '';
1538
1539
  position: absolute;
1539
1540
  border-radius: 50%;
1540
1541
  inset: 0;
1541
1542
  transition: all 0.2s ease-in-out;
1542
1543
  background: conic-gradient(var(--bgl-primary) calc(var(--p) * 1%), #0000 0);
1543
- -webkit-mask: radial-gradient(farthest-side,
1544
- #0000 calc(99% - var(--b)),
1545
- #000 calc(100% - var(--b)));
1546
- mask: radial-gradient(farthest-side,
1547
- #0000 calc(99% - var(--b)),
1548
- #000 calc(100% - var(--b)));
1549
- }
1550
- .pie .success[data-v-1be8d7b1] {
1544
+ -webkit-mask: radial-gradient(
1545
+ farthest-side,
1546
+ #0000 calc(99% - var(--b)),
1547
+ #000 calc(100% - var(--b))
1548
+ );
1549
+ mask: radial-gradient(
1550
+ farthest-side,
1551
+ #0000 calc(99% - var(--b)),
1552
+ #000 calc(100% - var(--b))
1553
+ );
1554
+ }
1555
+ .pie .success[data-v-3bb24b0c] {
1551
1556
  transform: scale(0);
1552
1557
  opacity: 0;
1553
1558
  transition: all 0.3s ease-in-out;
1554
1559
  }
1555
- .pie .progress[data-v-1be8d7b1] {
1560
+ .pie .progress[data-v-3bb24b0c] {
1556
1561
  position: absolute;
1557
1562
  font-size: 10px;
1558
1563
  }
1559
- .pie.complete .progress[data-v-1be8d7b1] {
1564
+ .pie.complete .progress[data-v-3bb24b0c] {
1560
1565
  display: none;
1561
1566
  }
1562
- .pie.complete .success[data-v-1be8d7b1] {
1567
+ .pie.complete .success[data-v-3bb24b0c] {
1563
1568
  transform: scale(1.3);
1564
1569
  opacity: 1;
1565
1570
  }
1566
- .pie.complete[data-v-1be8d7b1]:before {
1571
+ .pie.complete[data-v-3bb24b0c]:before {
1567
1572
  background: conic-gradient(var(--bgl-green) calc(var(--p) * 1%), #0000 0);
1568
1573
  }
1569
- .pie.complete[data-v-1be8d7b1] {
1574
+ .pie.complete[data-v-3bb24b0c] {
1570
1575
  color: var(--bgl-green);
1571
1576
  }
1572
1577
 
@@ -1688,10 +1693,10 @@ img.preview[data-v-1be8d7b1] {
1688
1693
  margin: 1rem 0;
1689
1694
  }
1690
1695
  .tiptap {
1691
- min-height: 500px;
1696
+ min-height: 200px;
1692
1697
  background: var(--input-bg);
1693
1698
  overflow: auto;
1694
- max-height: 600px;
1699
+ max-height: 500px;
1695
1700
  padding: 0.7rem;
1696
1701
  color: var(--input-color);
1697
1702
  border-radius: var(--input-border-radius);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bagelink/vue",
3
3
  "type": "module",
4
- "version": "0.0.374",
4
+ "version": "0.0.378",
5
5
  "description": "Bagel core sdk packages",
6
6
  "author": {
7
7
  "name": "Neveh Allon",
@@ -9,21 +9,13 @@
9
9
  @drop="drop"
10
10
  @dragleave="dragleave"
11
11
  class="fileUploadWrap"
12
- :class="{ fileDropZone: !storageFiles.length && !fileQueue.length, dragover: isDragOver }"
13
- >
14
- <template
15
- v-for="file in storageFiles"
16
- :key="file.id"
17
- >
18
- <div
19
- class="imagePreviewWrap"
20
- v-if="!multiple"
21
- >
22
- <img
23
- class="preview"
24
- :src="file.url"
25
- alt=""
26
- >
12
+ :class="{
13
+ fileDropZone: !storageFiles.length && !fileQueue.length,
14
+ dragover: isDragOver,
15
+ }">
16
+ <template v-for="file in storageFiles" :key="file.id">
17
+ <div class="imagePreviewWrap" v-if="!multiple">
18
+ <img class="preview" :src="file.url" alt="" />
27
19
  </div>
28
20
  <div class="previewName">
29
21
  <img
@@ -31,8 +23,7 @@
31
23
  v-if="multiple"
32
24
  class="preview"
33
25
  :src="file.url"
34
- alt=""
35
- >
26
+ alt="" />
36
27
  <p class="no-margin">
37
28
  {{ file.name }}
38
29
  </p>
@@ -41,23 +32,12 @@
41
32
  @click.stop="removeFile(file)"
42
33
  flat
43
34
  icon="delete"
44
- color="red"
45
- />
35
+ color="red" />
46
36
  </div>
47
37
  </template>
48
- <template
49
- v-for="fileQ in fileQueue"
50
- :key="fileQ.file"
51
- >
52
- <div
53
- class="imagePreviewWrap"
54
- v-if="!multiple"
55
- >
56
- <img
57
- class="preview"
58
- :src="fileToUrl(fileQ.file)"
59
- alt=""
60
- >
38
+ <template v-for="fileQ in fileQueue" :key="fileQ.file">
39
+ <div class="imagePreviewWrap" v-if="!multiple">
40
+ <img class="preview" :src="fileToUrl(fileQ.file)" alt="" />
61
41
  </div>
62
42
  <div class="previewName">
63
43
  <img
@@ -65,8 +45,7 @@
65
45
  v-if="multiple"
66
46
  class="preview"
67
47
  :src="fileToUrl(fileQ.file)"
68
- alt=""
69
- >
48
+ alt="" />
70
49
  <p class="no-margin">
71
50
  {{ fileQ.name }}
72
51
  </p>
@@ -74,18 +53,11 @@
74
53
  class="pie"
75
54
  :style="`--p:${fileQ.progress}`"
76
55
  style="--b: 2px"
77
- :class="{ complete: fileQ.progress === 100 }"
78
- >
79
- <span
80
- class="progress"
81
- v-if="fileQ.progress < 100"
82
- >
56
+ :class="{ complete: fileQ.progress === 100 }">
57
+ <span class="progress" v-if="fileQ.progress < 100">
83
58
  {{ `${fileQ.progress.toFixed(0)}` }}
84
59
  </span>
85
- <MaterialIcon
86
- class="success"
87
- icon="check"
88
- />
60
+ <MaterialIcon class="success" icon="check" />
89
61
  </div>
90
62
  </div>
91
63
  </template>
@@ -95,9 +67,7 @@
95
67
 
96
68
  <script setup lang="ts">
97
69
  import { watch } from 'vue';
98
- import {
99
- Btn, type StorageFile, useBagel, MaterialIcon,
100
- } from '@bagelink/vue';
70
+ import { Btn, type StorageFile, useBagel, MaterialIcon } from '@bagelink/vue';
101
71
 
102
72
  const bagel = useBagel();
103
73
 
@@ -110,27 +80,36 @@ type QueueFile = {
110
80
  };
111
81
 
112
82
  const props = defineProps<{
113
- label: string,
114
- multiple?: boolean,
115
- files?: StorageFile | StorageFile[],
83
+ label: string;
84
+ multiple?: boolean;
85
+ files?: StorageFile | StorageFile[];
116
86
  deleteEndpoint?: string;
117
87
  }>();
118
88
 
119
89
  const file_ids = defineModel<string[] | string>('modelValue');
120
90
  const storageFiles = $ref<StorageFile[]>([]);
121
91
 
122
- const compareIds = (v1?: string[] | string, v2?: string[] | string) => [v1].flat().join(',') === [v2].flat().join(',');
123
-
124
- watch(() => props.files, (newFiles) => {
125
- if (newFiles) storageFiles.push(...[newFiles].flat());
126
- }, { immediate: true });
127
-
128
- watch(() => storageFiles, (newFiles) => {
129
- let idValue: string[] | string = '';
130
- if (props.multiple) idValue = newFiles.map((f) => f.id || '');
131
- else idValue = newFiles[0]?.id || '';
132
- if (!compareIds(file_ids?.value, idValue)) file_ids.value = idValue;
133
- }, { deep: true });
92
+ const compareIds = (v1?: string[] | string, v2?: string[] | string) =>
93
+ [v1].flat().join(',') === [v2].flat().join(',');
94
+
95
+ watch(
96
+ () => props.files,
97
+ (newFiles) => {
98
+ if (newFiles) storageFiles.push(...[newFiles].flat());
99
+ },
100
+ { immediate: true }
101
+ );
102
+
103
+ watch(
104
+ () => storageFiles,
105
+ (newFiles) => {
106
+ let idValue: string[] | string = '';
107
+ if (props.multiple) idValue = newFiles.map((f) => f.id || '');
108
+ else idValue = newFiles[0]?.id || '';
109
+ if (!compareIds(file_ids?.value, idValue)) file_ids.value = idValue;
110
+ },
111
+ { deep: true }
112
+ );
134
113
 
135
114
  const fileQueue = $ref<QueueFile[]>([]);
136
115
  let isDragOver = $ref(false);
@@ -145,20 +124,20 @@ const removeFile = (file: StorageFile) => {
145
124
  const index = storageFiles.indexOf(file);
146
125
  storageFiles.splice(index, 1);
147
126
 
148
- if (props.deleteEndpoint) void bagel.delete(`${props.deleteEndpoint}/${file.id}`);
127
+ if (props.deleteEndpoint) {
128
+ void bagel.delete(`${props.deleteEndpoint}/${file.id}`);
129
+ }
149
130
  };
150
131
 
151
132
  const flushQueue = () => {
152
- fileQueue.forEach(
153
- async (file, i) => {
154
- if (!props.multiple) storageFiles.splice(0, 1);
155
- const serverFile = await bagel.uploadFile<StorageFile>(file.file, {
156
- onUploadProgress: (e: any) => (file.progress = e.progress * 100 - 1),
157
- });
158
- storageFiles.push(serverFile);
159
- fileQueue.splice(i, 1);
160
- },
161
- );
133
+ fileQueue.forEach(async (file, i) => {
134
+ if (!props.multiple) storageFiles.splice(0, 1);
135
+ const serverFile = await bagel.uploadFile<StorageFile>(file.file, {
136
+ onUploadProgress: (e: any) => (file.progress = e.progress * 100 - 1),
137
+ });
138
+ storageFiles.push(serverFile);
139
+ fileQueue.splice(i, 1);
140
+ });
162
141
  };
163
142
 
164
143
  const browse = () => {
@@ -168,7 +147,9 @@ const browse = () => {
168
147
  input.onchange = (e: Event) => {
169
148
  const target = e?.target as HTMLInputElement;
170
149
  if (target?.files) {
171
- Array.from(target.files).forEach((file: File) => fileQueue.push({ name: file.name, file, progress: 0 }));
150
+ Array.from(target.files).forEach((file: File) =>
151
+ fileQueue.push({ name: file.name, file, progress: 0 })
152
+ );
172
153
  }
173
154
  flushQueue();
174
155
  };
@@ -190,13 +171,9 @@ const dragover = (e: DragEvent) => {
190
171
  const drop = (e: DragEvent) => {
191
172
  preventDefault(e);
192
173
  if (e.dataTransfer) {
193
- Array
194
- .from(e.dataTransfer.files)
195
- .forEach(
196
- (file: File) => (
197
- fileQueue.push({ name: file.name, file, progress: 0 })
198
- ),
199
- );
174
+ Array.from(e.dataTransfer.files).forEach((file: File) =>
175
+ fileQueue.push({ name: file.name, file, progress: 0 })
176
+ );
200
177
  }
201
178
  isDragOver = false;
202
179
  flushQueue();
@@ -222,7 +199,7 @@ const drop = (e: DragEvent) => {
222
199
  display: grid;
223
200
  grid-template-columns: 1fr 22px;
224
201
  align-items: center;
225
-
202
+ padding-inline: 14px;
226
203
  }
227
204
 
228
205
  .previewName p {
@@ -258,7 +235,7 @@ img.preview {
258
235
  }
259
236
 
260
237
  .bagel-input .fileUploadWrap.fileDropZone:after {
261
- content: "Drop files here or click to upload";
238
+ content: 'Drop files here or click to upload';
262
239
  }
263
240
 
264
241
  .pie {
@@ -271,18 +248,22 @@ img.preview {
271
248
  }
272
249
 
273
250
  .pie:before {
274
- content: "";
251
+ content: '';
275
252
  position: absolute;
276
253
  border-radius: 50%;
277
254
  inset: 0;
278
255
  transition: all 0.2s ease-in-out;
279
256
  background: conic-gradient(var(--bgl-primary) calc(var(--p) * 1%), #0000 0);
280
- -webkit-mask: radial-gradient(farthest-side,
281
- #0000 calc(99% - var(--b)),
282
- #000 calc(100% - var(--b)));
283
- mask: radial-gradient(farthest-side,
284
- #0000 calc(99% - var(--b)),
285
- #000 calc(100% - var(--b)));
257
+ -webkit-mask: radial-gradient(
258
+ farthest-side,
259
+ #0000 calc(99% - var(--b)),
260
+ #000 calc(100% - var(--b))
261
+ );
262
+ mask: radial-gradient(
263
+ farthest-side,
264
+ #0000 calc(99% - var(--b)),
265
+ #000 calc(100% - var(--b))
266
+ );
286
267
  }
287
268
 
288
269
  .pie .success {
@@ -242,10 +242,10 @@ onBeforeUnmount(() => editor?.destroy());
242
242
  }
243
243
 
244
244
  .tiptap {
245
- min-height: 500px;
245
+ min-height: 200px;
246
246
  background: var(--input-bg);
247
247
  overflow: auto;
248
- max-height: 600px;
248
+ max-height: 500px;
249
249
  padding: 0.7rem;
250
250
  color: var(--input-color);
251
251
  border-radius: var(--input-border-radius);