@xuda.io/xuda-widget-plugin-xuda-drive 1.0.12 → 1.0.14

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 (2) hide show
  1. package/package.json +1 -1
  2. package/runtime.mjs +73 -24
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/xuda-widget-plugin-xuda-drive",
3
- "version": "1.0.12",
3
+ "version": "1.0.14",
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
@@ -573,40 +573,89 @@ export async function viewer(fields, e) {
573
573
  };
574
574
 
575
575
  let viewer_type = fields.default_view_type || "gallery";
576
-
577
576
  let opt = { app_id, type: "file", search_string: "a" };
578
577
 
579
- try {
580
- const ret = await search_drive();
578
+ const render_view = async function () {
579
+ const expand = function (e) {
580
+ console.log(e);
581
+ alert("aaa");
582
+ };
583
+
584
+ e.$containerP.find(".drive_view_wrapper").empty();
585
+
586
+ try {
587
+ const ret = await search_drive();
588
+
589
+ let $wrapper;
581
590
 
582
- for (let file of ret.data) {
583
591
  switch (viewer_type) {
584
592
  case "gallery": {
585
- e.$containerP.append(`
586
- <section class="mt-8 pb-16" aria-labelledby="gallery-heading">
593
+ $wrapper = `
594
+ <div class="drive_view_wrapper">
595
+ <section class="mt-8 pb-16" aria-labelledby="gallery-heading">
587
596
  <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="${file.file_url}" alt="${file.name}" 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
- `);
597
+ <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]">`;
603
598
  break;
604
599
  }
605
600
  default:
606
601
  break;
607
602
  }
603
+ let $item;
604
+ for (let file of ret.data) {
605
+ switch (viewer_type) {
606
+ case "gallery": {
607
+ $item = `
608
+ <li class="relative">
609
+ <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"'>
610
+ <img src="${file.file_url}" alt="${file.name}" class="pointer-events-none object-cover" x-state:on="Current" x-state:off="Default" x-state-description='Current: "", Default: "group-hover:opacity-75"' />
611
+ <button type="button" class="absolute inset-0 focus:outline-none">
612
+ <span class="sr-only">View details for IMG_4985.HEIC</span>
613
+ </button>
614
+ </div>
615
+ <p class="pointer-events-none mt-2 block truncate text-sm font-medium text-gray-900">IMG_4985.HEIC</p>
616
+ <p class="pointer-events-none block text-sm font-medium text-gray-500">3.9 MB</p>
617
+ </li> `.on("click", (e) => {
618
+ expand(e);
619
+ });
620
+
621
+ $wrapper.append($item);
622
+ break;
623
+ }
624
+ default:
625
+ break;
626
+ }
627
+ }
628
+
629
+ e.$containerP.append($wrapper);
630
+ } catch (err) {
631
+ console.error(err);
608
632
  }
609
- } catch (err) {
610
- console.error(err);
611
- }
633
+ };
634
+
635
+ render_view();
612
636
  }
637
+
638
+ // `
639
+
640
+ // <div class="drive_view_wrapper">
641
+
642
+ // <section class="mt-8 pb-16" aria-labelledby="gallery-heading">
643
+ // <h2 id="gallery-heading" class="sr-only">Recently viewed</h2>
644
+ // <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]">
645
+
646
+ // <li class="relative">
647
+ // <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"'>
648
+ // <img src="${file.file_url}" alt="${file.name}" class="pointer-events-none object-cover" x-state:on="Current" x-state:off="Default" x-state-description='Current: "", Default: "group-hover:opacity-75"' />
649
+ // <button type="button" class="absolute inset-0 focus:outline-none">
650
+ // <span class="sr-only">View details for IMG_4985.HEIC</span>
651
+ // </button>
652
+ // </div>
653
+ // <p class="pointer-events-none mt-2 block truncate text-sm font-medium text-gray-900">IMG_4985.HEIC</p>
654
+ // <p class="pointer-events-none block text-sm font-medium text-gray-500">3.9 MB</p>
655
+ // </li>
656
+
657
+ // </ul>
658
+ // </section>
659
+
660
+ // <div>
661
+ // `