@xuda.io/xuda-widget-plugin-xuda-drive 1.0.6 → 1.0.8

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.
Files changed (3) hide show
  1. package/index.mjs +18 -2
  2. package/package.json +1 -1
  3. package/runtime.mjs +42 -20
package/index.mjs CHANGED
@@ -153,8 +153,8 @@ export const methods = {
153
153
  value: "",
154
154
  },
155
155
  {
156
- label: "Thumbnails",
157
- value: "thumbnails",
156
+ label: "Gallery",
157
+ value: "gallery",
158
158
  },
159
159
  {
160
160
  label: "List",
@@ -208,6 +208,22 @@ export const methods = {
208
208
  },
209
209
  ],
210
210
  },
211
+ show_toolbar: {
212
+ label: "Show Toolbar",
213
+ type: "string",
214
+ render: "segment",
215
+ tooltip: "",
216
+ options: [
217
+ {
218
+ label: "No",
219
+ value: "",
220
+ },
221
+ {
222
+ label: "Yes",
223
+ value: "yes",
224
+ },
225
+ ],
226
+ },
211
227
  },
212
228
  response: { uploaded_files: "" },
213
229
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/xuda-widget-plugin-xuda-drive",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "Xuda Drive widget plugin",
5
5
  "scripts": {
6
6
  "pub": "npm version patch --force && npm publish --access public"
package/runtime.mjs CHANGED
@@ -530,28 +530,16 @@ export async function viewer(fields, e) {
530
530
  </svg>
531
531
  <span class="sr-only">Use grid view</span>
532
532
  </button>
533
+ <button type="button" class="ml-0.5 rounded-md bg-white p-1.5 text-gray-400 shadow-sm focus:outline-none focus:ring-2 focus:ring-inset focus:ring-indigo-500">
534
+ <svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="#000000" viewBox="0 0 256 256"><path d="M200,64V192a8,8,0,0,1-8,8H64a8,8,0,0,1-8-8V64a8,8,0,0,1,8-8H192A8,8,0,0,1,200,64Z" opacity="0.2"></path><path d="M192,48H64A16,16,0,0,0,48,64V192a16,16,0,0,0,16,16H192a16,16,0,0,0,16-16V64A16,16,0,0,0,192,48Zm0,144H64V64H192V192ZM240,56V200a8,8,0,0,1-16,0V56a8,8,0,0,1,16,0ZM32,56V200a8,8,0,0,1-16,0V56a8,8,0,0,1,16,0Z"></path></svg>
535
+ <span class="sr-only">Use grid view</span>
536
+ </button>
533
537
  </div>
534
538
  </div>
535
539
 
536
540
  <!-- Tabs -->
537
541
 
538
- <!-- Gallery -->
539
- <section class="mt-8 pb-16" aria-labelledby="gallery-heading">
540
- <h2 id="gallery-heading" class="sr-only">Recently viewed</h2>
541
- <ul role="list" class="grid grid-cols-2 gap-x-4 gap-y-8 sm:grid-cols-3 sm:gap-x-6 md:grid-cols-4 lg:grid-cols-3 xl:grid-cols-4 xl:gap-x-8 [&>li>div>img]:aspect-[3/2]">
542
- <li class="relative">
543
- <div class="aspect-w-10 aspect-h-7 group block w-full overflow-hidden rounded-lg bg-gray-100 ring-2 ring-indigo-500 ring-offset-2" x-state:on="Current" x-state:off="Default" x-state-description='Current: "ring-2 ring-indigo-500 ring-offset-2", Default: "focus-within:ring-2 focus-within:ring-indigo-500 focus-within:ring-offset-2 focus-within:ring-offset-gray-100"'>
544
- <img src="https://images.unsplash.com/photo-1582053433976-25c00369fc93?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&amp;ixlib=rb-1.2.1&amp;auto=format&amp;fit=crop&amp;w=512&amp;q=80" alt="" class="pointer-events-none object-cover" x-state:on="Current" x-state:off="Default" x-state-description='Current: "", Default: "group-hover:opacity-75"' />
545
- <button type="button" class="absolute inset-0 focus:outline-none">
546
- <span class="sr-only">View details for IMG_4985.HEIC</span>
547
- </button>
548
- </div>
549
- <p class="pointer-events-none mt-2 block truncate text-sm font-medium text-gray-900">IMG_4985.HEIC</p>
550
- <p class="pointer-events-none block text-sm font-medium text-gray-500">3.9 MB</p>
551
- </li>
552
-
553
- </ul>
554
- </section>
542
+
555
543
  </div>
556
544
  </main>
557
545
 
@@ -559,9 +547,7 @@ export async function viewer(fields, e) {
559
547
 
560
548
  e.$containerP.html(html);
561
549
 
562
- let opt = { app_id };
563
-
564
- try {
550
+ const search_drive = async function () {
565
551
  let domain =
566
552
  e._session.engine_mode === "live_preview" ? `dev.xuda.io` : `xuda.io`;
567
553
 
@@ -584,6 +570,42 @@ export async function viewer(fields, e) {
584
570
  }
585
571
  const json = await response.json();
586
572
  return json;
573
+ };
574
+
575
+ let viewer_type = fields.default_view_type || "gallery";
576
+
577
+ let opt = { app_id, type: "file", search_string: "a" };
578
+
579
+ try {
580
+ const ret = search_drive();
581
+
582
+ for (let file of ret.data.docs) {
583
+ switch (viewer_type) {
584
+ case "gallery": {
585
+ e.$containerP.append(`
586
+ <section class="mt-8 pb-16" aria-labelledby="gallery-heading">
587
+ <h2 id="gallery-heading" class="sr-only">Recently viewed</h2>
588
+ <ul role="list" class="grid grid-cols-2 gap-x-4 gap-y-8 sm:grid-cols-3 sm:gap-x-6 md:grid-cols-4 lg:grid-cols-3 xl:grid-cols-4 xl:gap-x-8 [&>li>div>img]:aspect-[3/2]">
589
+ <li class="relative">
590
+ <div class="aspect-w-10 aspect-h-7 group block w-full overflow-hidden rounded-lg bg-gray-100 ring-2 ring-indigo-500 ring-offset-2" x-state:on="Current" x-state:off="Default" x-state-description='Current: "ring-2 ring-indigo-500 ring-offset-2", Default: "focus-within:ring-2 focus-within:ring-indigo-500 focus-within:ring-offset-2 focus-within:ring-offset-gray-100"'>
591
+ <img src="https://images.unsplash.com/photo-1582053433976-25c00369fc93?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&amp;ixlib=rb-1.2.1&amp;auto=format&amp;fit=crop&amp;w=512&amp;q=80" alt="" class="pointer-events-none object-cover" x-state:on="Current" x-state:off="Default" x-state-description='Current: "", Default: "group-hover:opacity-75"' />
592
+ <button type="button" class="absolute inset-0 focus:outline-none">
593
+ <span class="sr-only">View details for IMG_4985.HEIC</span>
594
+ </button>
595
+ </div>
596
+ <p class="pointer-events-none mt-2 block truncate text-sm font-medium text-gray-900">IMG_4985.HEIC</p>
597
+ <p class="pointer-events-none block text-sm font-medium text-gray-500">3.9 MB</p>
598
+ </li>
599
+
600
+ </ul>
601
+ </section>
602
+ `);
603
+ break;
604
+ }
605
+ default:
606
+ break;
607
+ }
608
+ }
587
609
  } catch (err) {
588
610
  console.error(err);
589
611
  }