@bagelink/vue 0.0.732 → 0.0.734

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":"index.d.ts","sourceRoot":"","sources":["../../../src/components/lightbox/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAA+B,MAAM,KAAK,CAAA;;iBA6D7C,GAAG;;AADjB,wBAIC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/lightbox/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAA+B,MAAM,KAAK,CAAA;;iBA2E7C,GAAG;;AADjB,wBAIC"}
package/dist/index.cjs CHANGED
@@ -5322,11 +5322,17 @@ const lightboxDirective = {
5322
5322
  mounted(el, binding) {
5323
5323
  el.classList.add("hover");
5324
5324
  const item = bindingToItem(binding, el);
5325
- if (item.group) {
5326
- if (!groups[item.group]) groups[item.group] = [];
5327
- const currentIndex = groups[item.group].findIndex((i2) => i2.src === item.src);
5328
- if (currentIndex === -1) groups[item.group].push(item);
5329
- }
5325
+ groupHandler(item);
5326
+ el.addEventListener("click", (e) => {
5327
+ openClickHandler(e, el, binding);
5328
+ });
5329
+ },
5330
+ updated(el, binding) {
5331
+ const item = bindingToItem(binding, el);
5332
+ groupHandler(item);
5333
+ el.removeEventListener("click", (e) => {
5334
+ openClickHandler(e, el, binding);
5335
+ });
5330
5336
  el.addEventListener("click", (e) => {
5331
5337
  openClickHandler(e, el, binding);
5332
5338
  });
@@ -5337,12 +5343,19 @@ const lightboxDirective = {
5337
5343
  });
5338
5344
  }
5339
5345
  };
5346
+ function groupHandler(item) {
5347
+ if (item.group) {
5348
+ if (!groups[item.group]) groups[item.group] = [];
5349
+ const currentIndex = groups[item.group].findIndex((i2) => i2.src === item.src);
5350
+ if (currentIndex === -1) groups[item.group].push(item);
5351
+ }
5352
+ }
5340
5353
  function openClickHandler(e, el, binding) {
5341
5354
  e.stopPropagation();
5342
5355
  const item = bindingToItem(binding, el);
5343
- const lightboxInstance = createLightboxInstance();
5344
- if (!lightboxInstance || !lightboxInstance.open) return;
5345
- const open = lightboxInstance.open;
5356
+ const lightboxInstance2 = getLightboxInstance();
5357
+ if (!lightboxInstance2 || !lightboxInstance2.open) return;
5358
+ const open = lightboxInstance2.open;
5346
5359
  const group = item && item.group ? groups[item.group] : void 0;
5347
5360
  open(item, group);
5348
5361
  }
@@ -5362,11 +5375,15 @@ function determineFileType(url) {
5362
5375
  if (["pdf"].includes(extension)) return "pdf";
5363
5376
  return "unknown";
5364
5377
  }
5365
- function createLightboxInstance() {
5366
- const lightboxEl = document.createElement("div");
5367
- document.body.prepend(lightboxEl);
5368
- const app = vue.createApp(Lightbox$1);
5369
- return app.mount(lightboxEl);
5378
+ let lightboxInstance = null;
5379
+ function getLightboxInstance() {
5380
+ if (!lightboxInstance) {
5381
+ const lightboxEl = document.createElement("div");
5382
+ document.body.prepend(lightboxEl);
5383
+ const app = vue.createApp(Lightbox$1);
5384
+ lightboxInstance = app.mount(lightboxEl);
5385
+ }
5386
+ return lightboxInstance;
5370
5387
  }
5371
5388
  const Lightbox = {
5372
5389
  install(app) {
package/dist/index.mjs CHANGED
@@ -5320,11 +5320,17 @@ const lightboxDirective = {
5320
5320
  mounted(el, binding) {
5321
5321
  el.classList.add("hover");
5322
5322
  const item = bindingToItem(binding, el);
5323
- if (item.group) {
5324
- if (!groups[item.group]) groups[item.group] = [];
5325
- const currentIndex = groups[item.group].findIndex((i2) => i2.src === item.src);
5326
- if (currentIndex === -1) groups[item.group].push(item);
5327
- }
5323
+ groupHandler(item);
5324
+ el.addEventListener("click", (e) => {
5325
+ openClickHandler(e, el, binding);
5326
+ });
5327
+ },
5328
+ updated(el, binding) {
5329
+ const item = bindingToItem(binding, el);
5330
+ groupHandler(item);
5331
+ el.removeEventListener("click", (e) => {
5332
+ openClickHandler(e, el, binding);
5333
+ });
5328
5334
  el.addEventListener("click", (e) => {
5329
5335
  openClickHandler(e, el, binding);
5330
5336
  });
@@ -5335,12 +5341,19 @@ const lightboxDirective = {
5335
5341
  });
5336
5342
  }
5337
5343
  };
5344
+ function groupHandler(item) {
5345
+ if (item.group) {
5346
+ if (!groups[item.group]) groups[item.group] = [];
5347
+ const currentIndex = groups[item.group].findIndex((i2) => i2.src === item.src);
5348
+ if (currentIndex === -1) groups[item.group].push(item);
5349
+ }
5350
+ }
5338
5351
  function openClickHandler(e, el, binding) {
5339
5352
  e.stopPropagation();
5340
5353
  const item = bindingToItem(binding, el);
5341
- const lightboxInstance = createLightboxInstance();
5342
- if (!lightboxInstance || !lightboxInstance.open) return;
5343
- const open = lightboxInstance.open;
5354
+ const lightboxInstance2 = getLightboxInstance();
5355
+ if (!lightboxInstance2 || !lightboxInstance2.open) return;
5356
+ const open = lightboxInstance2.open;
5344
5357
  const group = item && item.group ? groups[item.group] : void 0;
5345
5358
  open(item, group);
5346
5359
  }
@@ -5360,11 +5373,15 @@ function determineFileType(url) {
5360
5373
  if (["pdf"].includes(extension)) return "pdf";
5361
5374
  return "unknown";
5362
5375
  }
5363
- function createLightboxInstance() {
5364
- const lightboxEl = document.createElement("div");
5365
- document.body.prepend(lightboxEl);
5366
- const app = createApp(Lightbox$1);
5367
- return app.mount(lightboxEl);
5376
+ let lightboxInstance = null;
5377
+ function getLightboxInstance() {
5378
+ if (!lightboxInstance) {
5379
+ const lightboxEl = document.createElement("div");
5380
+ document.body.prepend(lightboxEl);
5381
+ const app = createApp(Lightbox$1);
5382
+ lightboxInstance = app.mount(lightboxEl);
5383
+ }
5384
+ return lightboxInstance;
5368
5385
  }
5369
5386
  const Lightbox = {
5370
5387
  install(app) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bagelink/vue",
3
3
  "type": "module",
4
- "version": "0.0.732",
4
+ "version": "0.0.734",
5
5
  "description": "Bagel core sdk packages",
6
6
  "author": {
7
7
  "name": "Neveh Allon",
@@ -10,11 +10,13 @@ const lightboxDirective: Directive = {
10
10
  mounted(el: HTMLElement, binding) {
11
11
  el.classList.add('hover')
12
12
  const item = bindingToItem(binding, el)
13
- if (item.group) {
14
- if (!groups[item.group]) groups[item.group] = []
15
- const currentIndex = groups[item.group].findIndex(i => i.src === item.src)
16
- if (currentIndex === -1) groups[item.group].push(item)
17
- }
13
+ groupHandler(item)
14
+ el.addEventListener('click', (e) => { openClickHandler(e, el, binding) })
15
+ },
16
+ updated(el: HTMLElement, binding) {
17
+ const item = bindingToItem(binding, el)
18
+ groupHandler(item)
19
+ el.removeEventListener('click', (e) => { openClickHandler(e, el, binding) })
18
20
  el.addEventListener('click', (e) => { openClickHandler(e, el, binding) })
19
21
  },
20
22
  unmounted(el: HTMLElement, binding) {
@@ -22,10 +24,18 @@ const lightboxDirective: Directive = {
22
24
  }
23
25
  }
24
26
 
27
+ function groupHandler(item: LightboxItem) {
28
+ if (item.group) {
29
+ if (!groups[item.group]) groups[item.group] = []
30
+ const currentIndex = groups[item.group].findIndex(i => i.src === item.src)
31
+ if (currentIndex === -1) groups[item.group].push(item)
32
+ }
33
+ }
34
+
25
35
  function openClickHandler(e: MouseEvent, el: HTMLElement, binding: DirectiveBinding) {
26
36
  e.stopPropagation()
27
37
  const item = bindingToItem(binding, el)
28
- const lightboxInstance = createLightboxInstance()
38
+ const lightboxInstance = getLightboxInstance()
29
39
  if (!lightboxInstance || !lightboxInstance.open) return
30
40
  const open = lightboxInstance.open as OpenFunction
31
41
  const group = item && item.group ? groups[item.group] : undefined
@@ -50,12 +60,16 @@ function determineFileType(url: string): string {
50
60
  return 'unknown'
51
61
  }
52
62
 
53
- function createLightboxInstance(): InstanceType<typeof Lightbox> | null {
54
- const lightboxEl = document.createElement('div')
55
- document.body.prepend(lightboxEl)
63
+ let lightboxInstance: InstanceType<typeof Lightbox> | null = null
56
64
 
57
- const app = createApp(Lightbox)
58
- return app.mount(lightboxEl) as InstanceType<typeof Lightbox>
65
+ function getLightboxInstance(): InstanceType<typeof Lightbox> {
66
+ if (!lightboxInstance) {
67
+ const lightboxEl = document.createElement('div')
68
+ document.body.prepend(lightboxEl)
69
+ const app = createApp(Lightbox)
70
+ lightboxInstance = app.mount(lightboxEl) as InstanceType<typeof Lightbox>
71
+ }
72
+ return lightboxInstance
59
73
  }
60
74
 
61
75
  export default {