uikit 3.21.14-dev.60ed95dfb → 3.21.14-dev.b1911d7ca

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 (98) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/css/uikit-core-rtl.css +216 -85
  3. package/dist/css/uikit-core-rtl.min.css +1 -1
  4. package/dist/css/uikit-core.css +216 -85
  5. package/dist/css/uikit-core.min.css +1 -1
  6. package/dist/css/uikit-rtl.css +220 -81
  7. package/dist/css/uikit-rtl.min.css +1 -1
  8. package/dist/css/uikit.css +220 -81
  9. package/dist/css/uikit.min.css +1 -1
  10. package/dist/js/components/countdown.js +1 -1
  11. package/dist/js/components/countdown.min.js +1 -1
  12. package/dist/js/components/filter.js +1 -1
  13. package/dist/js/components/filter.min.js +1 -1
  14. package/dist/js/components/lightbox-panel.js +406 -109
  15. package/dist/js/components/lightbox-panel.min.js +1 -1
  16. package/dist/js/components/lightbox.js +423 -114
  17. package/dist/js/components/lightbox.min.js +1 -1
  18. package/dist/js/components/notification.js +1 -1
  19. package/dist/js/components/notification.min.js +1 -1
  20. package/dist/js/components/parallax.js +1 -1
  21. package/dist/js/components/parallax.min.js +1 -1
  22. package/dist/js/components/slider-parallax.js +1 -1
  23. package/dist/js/components/slider-parallax.min.js +1 -1
  24. package/dist/js/components/slider.js +15 -20
  25. package/dist/js/components/slider.min.js +1 -1
  26. package/dist/js/components/slideshow-parallax.js +1 -1
  27. package/dist/js/components/slideshow-parallax.min.js +1 -1
  28. package/dist/js/components/slideshow.js +20 -26
  29. package/dist/js/components/slideshow.min.js +1 -1
  30. package/dist/js/components/sortable.js +1 -1
  31. package/dist/js/components/sortable.min.js +1 -1
  32. package/dist/js/components/tooltip.js +5 -2
  33. package/dist/js/components/tooltip.min.js +1 -1
  34. package/dist/js/components/upload.js +1 -1
  35. package/dist/js/components/upload.min.js +1 -1
  36. package/dist/js/uikit-core.js +125 -130
  37. package/dist/js/uikit-core.min.js +1 -1
  38. package/dist/js/uikit-icons.js +1 -1
  39. package/dist/js/uikit-icons.min.js +1 -1
  40. package/dist/js/uikit.js +478 -368
  41. package/dist/js/uikit.min.js +1 -1
  42. package/package.json +2 -2
  43. package/src/js/api/instance.js +1 -1
  44. package/src/js/components/internal/lightbox-animations.js +2 -1
  45. package/src/js/components/internal/slideshow-animations.js +5 -5
  46. package/src/js/components/lightbox-panel.js +172 -31
  47. package/src/js/components/lightbox.js +59 -6
  48. package/src/js/components/slideshow.js +1 -2
  49. package/src/js/core/icon.js +2 -2
  50. package/src/js/core/img.js +3 -5
  51. package/src/js/core/svg.js +8 -10
  52. package/src/js/core/video.js +4 -3
  53. package/src/js/mixin/internal/slideshow-animations.js +1 -6
  54. package/src/js/mixin/modal.js +1 -4
  55. package/src/js/mixin/slider-drag.js +5 -6
  56. package/src/js/mixin/slider-nav.js +1 -1
  57. package/src/js/mixin/slider.js +11 -13
  58. package/src/js/mixin/slideshow.js +1 -1
  59. package/src/js/mixin/togglable.js +4 -2
  60. package/src/js/util/dom.js +3 -1
  61. package/src/js/util/player.js +0 -4
  62. package/src/less/components/background.less +1 -9
  63. package/src/less/components/breadcrumb.less +6 -2
  64. package/src/less/components/button.less +1 -1
  65. package/src/less/components/form-range.less +52 -0
  66. package/src/less/components/form.less +1 -1
  67. package/src/less/components/lightbox.less +57 -89
  68. package/src/less/components/search.less +49 -23
  69. package/src/less/components/sticky.less +1 -10
  70. package/src/less/components/totop.less +1 -1
  71. package/src/less/components/transition.less +4 -4
  72. package/src/less/components/visibility.less +3 -2
  73. package/src/less/theme/form-range.less +12 -0
  74. package/src/less/theme/lightbox.less +2 -20
  75. package/src/less/theme/search.less +24 -10
  76. package/src/scss/components/background.scss +1 -9
  77. package/src/scss/components/breadcrumb.scss +6 -2
  78. package/src/scss/components/button.scss +1 -1
  79. package/src/scss/components/form-range.scss +12 -0
  80. package/src/scss/components/form.scss +1 -1
  81. package/src/scss/components/lightbox.scss +49 -77
  82. package/src/scss/components/search.scss +30 -12
  83. package/src/scss/components/sticky.scss +1 -10
  84. package/src/scss/components/totop.scss +1 -1
  85. package/src/scss/components/transition.scss +4 -4
  86. package/src/scss/components/visibility.scss +3 -2
  87. package/src/scss/mixins-theme.scss +51 -12
  88. package/src/scss/mixins.scss +45 -6
  89. package/src/scss/theme/form-range.scss +10 -0
  90. package/src/scss/theme/lightbox.scss +2 -20
  91. package/src/scss/theme/search.scss +10 -6
  92. package/src/scss/variables-theme.scss +32 -20
  93. package/src/scss/variables.scss +29 -24
  94. package/tests/breadcrumb.html +23 -5
  95. package/tests/lightbox.html +345 -30
  96. package/tests/navbar.html +19 -19
  97. package/tests/slideshow.html +1 -1
  98. package/tests/transition.html +2 -1
@@ -1,4 +1,4 @@
1
- /*! UIkit 3.21.14-dev.60ed95dfb | https://www.getuikit.com | (c) 2014 - 2024 YOOtheme | MIT License */
1
+ /*! UIkit 3.21.14-dev.b1911d7ca | https://www.getuikit.com | (c) 2014 - 2024 YOOtheme | MIT License */
2
2
 
3
3
  (function (global, factory) {
4
4
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('uikit-util')) :
@@ -20,6 +20,177 @@
20
20
  }
21
21
  }
22
22
 
23
+ function callUpdate(instance, e = "update") {
24
+ if (!instance._connected) {
25
+ return;
26
+ }
27
+ if (!instance._updates.length) {
28
+ return;
29
+ }
30
+ if (!instance._queued) {
31
+ instance._queued = /* @__PURE__ */ new Set();
32
+ util.fastdom.read(() => {
33
+ if (instance._connected) {
34
+ runUpdates(instance, instance._queued);
35
+ }
36
+ instance._queued = null;
37
+ });
38
+ }
39
+ instance._queued.add(e.type || e);
40
+ }
41
+ function runUpdates(instance, types) {
42
+ for (const { read, write, events = [] } of instance._updates) {
43
+ if (!types.has("update") && !events.some((type) => types.has(type))) {
44
+ continue;
45
+ }
46
+ let result;
47
+ if (read) {
48
+ result = read.call(instance, instance._data, types);
49
+ if (result && util.isPlainObject(result)) {
50
+ util.assign(instance._data, result);
51
+ }
52
+ }
53
+ if (write && result !== false) {
54
+ util.fastdom.write(() => {
55
+ if (instance._connected) {
56
+ write.call(instance, instance._data, types);
57
+ }
58
+ });
59
+ }
60
+ }
61
+ }
62
+
63
+ function resize(options) {
64
+ return observe(util.observeResize, options, "resize");
65
+ }
66
+ function intersection(options) {
67
+ return observe(util.observeIntersection, options);
68
+ }
69
+ function observe(observe2, options, emit) {
70
+ return {
71
+ observe: observe2,
72
+ handler() {
73
+ callUpdate(this, emit);
74
+ },
75
+ ...options
76
+ };
77
+ }
78
+
79
+ ({
80
+ args: "dataSrc",
81
+ props: {
82
+ dataSrc: String,
83
+ sources: String,
84
+ margin: String,
85
+ target: String,
86
+ loading: String
87
+ },
88
+ data: {
89
+ dataSrc: "",
90
+ sources: false,
91
+ margin: "50%",
92
+ target: false,
93
+ loading: "lazy"
94
+ },
95
+ connected() {
96
+ if (this.loading !== "lazy") {
97
+ this.load();
98
+ } else if (isImg(this.$el)) {
99
+ this.$el.loading = "lazy";
100
+ setSrcAttrs(this.$el);
101
+ }
102
+ },
103
+ disconnected() {
104
+ if (this.img) {
105
+ this.img.onload = "";
106
+ }
107
+ delete this.img;
108
+ },
109
+ observe: intersection({
110
+ handler(entries, observer) {
111
+ this.load();
112
+ observer.disconnect();
113
+ },
114
+ options: ({ margin }) => ({ rootMargin: margin }),
115
+ filter: ({ loading }) => loading === "lazy",
116
+ target: ({ $el, $props }) => $props.target ? [$el, ...util.queryAll($props.target, $el)] : $el
117
+ }),
118
+ methods: {
119
+ load() {
120
+ if (this.img) {
121
+ return this.img;
122
+ }
123
+ const image = isImg(this.$el) ? this.$el : getImageFromElement(this.$el, this.dataSrc, this.sources);
124
+ util.removeAttr(image, "loading");
125
+ setSrcAttrs(this.$el, image.currentSrc);
126
+ return this.img = image;
127
+ }
128
+ }
129
+ });
130
+ function setSrcAttrs(el, src) {
131
+ if (isImg(el)) {
132
+ const parentNode = util.parent(el);
133
+ const elements = util.isTag(parentNode, "picture") ? util.children(parentNode) : [el];
134
+ elements.forEach((el2) => setSourceProps(el2, el2));
135
+ } else if (src) {
136
+ const change = !util.includes(el.style.backgroundImage, src);
137
+ if (change) {
138
+ util.css(el, "backgroundImage", `url(${util.escape(src)})`);
139
+ util.trigger(el, util.createEvent("load", false));
140
+ }
141
+ }
142
+ }
143
+ const srcProps = ["data-src", "data-srcset", "sizes"];
144
+ function setSourceProps(sourceEl, targetEl) {
145
+ for (const prop of srcProps) {
146
+ const value = util.data(sourceEl, prop);
147
+ if (value) {
148
+ util.attr(targetEl, prop.replace(/data-/g, ""), value);
149
+ }
150
+ }
151
+ }
152
+ function getImageFromElement(el, src, sources) {
153
+ const img = new Image();
154
+ wrapInPicture(img, sources);
155
+ setSourceProps(el, img);
156
+ img.onload = () => setSrcAttrs(el, img.currentSrc);
157
+ util.attr(img, "src", src);
158
+ return img;
159
+ }
160
+ function wrapInPicture(img, sources) {
161
+ sources = parseSources(sources);
162
+ if (sources.length) {
163
+ const picture = util.fragment("<picture>");
164
+ for (const attrs of sources) {
165
+ const source = util.fragment("<source>");
166
+ util.attr(source, attrs);
167
+ util.append(picture, source);
168
+ }
169
+ util.append(picture, img);
170
+ }
171
+ }
172
+ function parseSources(sources) {
173
+ if (!sources) {
174
+ return [];
175
+ }
176
+ if (util.startsWith(sources, "[")) {
177
+ try {
178
+ sources = JSON.parse(sources);
179
+ } catch (e) {
180
+ sources = [];
181
+ }
182
+ } else {
183
+ sources = parseOptions(sources);
184
+ }
185
+ if (!util.isArray(sources)) {
186
+ sources = [sources];
187
+ }
188
+ return sources.filter((source) => !util.isEmpty(source));
189
+ }
190
+ function isImg(el) {
191
+ return util.isTag(el, "img");
192
+ }
193
+
23
194
  let prevented;
24
195
  function preventBackgroundScroll(el) {
25
196
  const off = util.on(
@@ -129,8 +300,12 @@
129
300
  util.addClass(el, cls);
130
301
  util.trigger(el, show ? "show" : "hide", [this]);
131
302
  const done = () => {
303
+ var _a;
132
304
  util.removeClass(el, cls);
133
305
  util.trigger(el, show ? "shown" : "hidden", [this]);
306
+ if (show) {
307
+ (_a = util.$$("[autofocus]", el).find(util.isVisible)) == null ? void 0 : _a.focus();
308
+ }
134
309
  };
135
310
  return promise ? promise.then(done, () => {
136
311
  util.removeClass(el, cls);
@@ -163,7 +338,6 @@
163
338
  if (changed) {
164
339
  util.trigger(el, "toggled", [toggled, this]);
165
340
  }
166
- util.$$("[autofocus]", el).some((el2) => util.isVisible(el2) ? el2.focus() || true : el2.blur());
167
341
  }
168
342
  }
169
343
  };
@@ -294,9 +468,6 @@
294
468
  panel: ({ selPanel }, $el) => util.$(selPanel, $el),
295
469
  transitionElement() {
296
470
  return this.panel;
297
- },
298
- bgClose({ bgClose }) {
299
- return bgClose && this.panel;
300
471
  }
301
472
  },
302
473
  connected() {
@@ -459,7 +630,7 @@
459
630
  }
460
631
  function listenForBackgroundClose(modal) {
461
632
  return util.on(document, util.pointerDown, ({ target }) => {
462
- if (util.last(active) !== modal || modal.overlay && !modal.$el.contains(target) || modal.panel.contains(target)) {
633
+ if (util.last(active) !== modal || modal.overlay && !modal.$el.contains(target) || !modal.panel || modal.panel.contains(target)) {
463
634
  return;
464
635
  }
465
636
  util.once(
@@ -482,59 +653,6 @@
482
653
  });
483
654
  }
484
655
 
485
- function callUpdate(instance, e = "update") {
486
- if (!instance._connected) {
487
- return;
488
- }
489
- if (!instance._updates.length) {
490
- return;
491
- }
492
- if (!instance._queued) {
493
- instance._queued = /* @__PURE__ */ new Set();
494
- util.fastdom.read(() => {
495
- if (instance._connected) {
496
- runUpdates(instance, instance._queued);
497
- }
498
- instance._queued = null;
499
- });
500
- }
501
- instance._queued.add(e.type || e);
502
- }
503
- function runUpdates(instance, types) {
504
- for (const { read, write, events = [] } of instance._updates) {
505
- if (!types.has("update") && !events.some((type) => types.has(type))) {
506
- continue;
507
- }
508
- let result;
509
- if (read) {
510
- result = read.call(instance, instance._data, types);
511
- if (result && util.isPlainObject(result)) {
512
- util.assign(instance._data, result);
513
- }
514
- }
515
- if (write && result !== false) {
516
- util.fastdom.write(() => {
517
- if (instance._connected) {
518
- write.call(instance, instance._data, types);
519
- }
520
- });
521
- }
522
- }
523
- }
524
-
525
- function resize(options) {
526
- return observe(util.observeResize, options, "resize");
527
- }
528
- function observe(observe2, options, emit) {
529
- return {
530
- observe: observe2,
531
- handler() {
532
- callUpdate(this, emit);
533
- },
534
- ...options
535
- };
536
- }
537
-
538
656
  var Animations$1 = {
539
657
  slide: {
540
658
  show(dir) {
@@ -555,11 +673,7 @@
555
673
  return Math.abs(new DOMMatrix(util.css(el, "transform")).m41 / el.offsetWidth);
556
674
  }
557
675
  function translate(value = 0, unit = "%") {
558
- value += value ? unit : "";
559
- return `translate3d(${value}, 0, 0)`;
560
- }
561
- function scale3d(value) {
562
- return `scale3d(${value}, ${value}, 1)`;
676
+ return value ? `translate3d(${value + unit}, 0, 0)` : "";
563
677
  }
564
678
 
565
679
  function Transitioner(prev, next, dir, { animation, easing }) {
@@ -693,7 +807,6 @@
693
807
  const pointerDown = "touchstart mousedown";
694
808
  const pointerMove = "touchmove mousemove";
695
809
  const pointerUp = "touchend touchcancel mouseup click input scroll";
696
- const preventClick = (e) => e.preventDefault();
697
810
  var SliderDrag = {
698
811
  props: {
699
812
  draggable: Boolean
@@ -761,9 +874,6 @@
761
874
  if (distance === 0 || this.prevPos === this.pos || !this.dragging && Math.abs(distance) < this.threshold) {
762
875
  return;
763
876
  }
764
- if (!this.dragging) {
765
- util.on(this.list, "click", preventClick, pointerOptions);
766
- }
767
877
  e.cancelable && e.preventDefault();
768
878
  this.dragging = true;
769
879
  this.dir = distance < 0 ? 1 : -1;
@@ -812,6 +922,7 @@
812
922
  util.off(document, pointerMove, this.move, pointerOptions);
813
923
  util.off(document, pointerUp, this.end, pointerUpOptions);
814
924
  if (this.dragging) {
925
+ setTimeout(util.on(this.list, "click", (e) => e.preventDefault(), pointerOptions));
815
926
  this.dragging = null;
816
927
  if (this.index === this.prevIndex) {
817
928
  this.percent = 1 - this.percent;
@@ -822,6 +933,8 @@
822
933
  const dirChange = (util.isRtl ? this.dir * (util.isRtl ? 1 : -1) : this.dir) < 0 === this.prevPos > this.pos;
823
934
  this.index = dirChange ? this.index : this.prevIndex;
824
935
  if (dirChange) {
936
+ util.trigger(this.slides[this.prevIndex], "itemhidden", [this]);
937
+ util.trigger(this.slides[this.index], "itemshown", [this]);
825
938
  this.percent = 1 - this.percent;
826
939
  }
827
940
  this.show(
@@ -830,7 +943,6 @@
830
943
  );
831
944
  }
832
945
  }
833
- setTimeout(() => util.off(this.list, "click", preventClick, pointerOptions));
834
946
  util.css(this.list, { userSelect: "" });
835
947
  this.drag = this.percent = null;
836
948
  }
@@ -1010,7 +1122,7 @@
1010
1122
  const item = util.toNumber(cmd);
1011
1123
  const active = item === index;
1012
1124
  util.toggleClass(el, this.clsActive, active);
1013
- util.toggleClass(button, "uk-disabled", this.parallax);
1125
+ util.toggleClass(button, "uk-disabled", !!this.parallax);
1014
1126
  util.attr(button, {
1015
1127
  "aria-selected": active,
1016
1128
  tabindex: active && !this.parallax ? null : -1
@@ -1113,7 +1225,7 @@
1113
1225
  }
1114
1226
  },
1115
1227
  methods: {
1116
- show(index, force = false) {
1228
+ async show(index, force = false) {
1117
1229
  var _a;
1118
1230
  if (this.dragging || !this.length || this.parallax) {
1119
1231
  return;
@@ -1149,18 +1261,16 @@
1149
1261
  reset();
1150
1262
  return;
1151
1263
  }
1152
- const promise = this._show(prev, next, force).then(() => {
1153
- prev && util.trigger(prev, "itemhidden", [this]);
1154
- util.trigger(next, "itemshown", [this]);
1155
- stack.shift();
1156
- this._transitioner = null;
1157
- if (stack.length) {
1158
- requestAnimationFrame(() => stack.length && this.show(stack.shift(), true));
1159
- }
1160
- });
1161
1264
  prev && util.trigger(prev, "itemhide", [this]);
1162
1265
  util.trigger(next, "itemshow", [this]);
1163
- return promise;
1266
+ await this._show(prev, next, force);
1267
+ prev && util.trigger(prev, "itemhidden", [this]);
1268
+ util.trigger(next, "itemshown", [this]);
1269
+ stack.shift();
1270
+ this._transitioner = null;
1271
+ if (stack.length) {
1272
+ requestAnimationFrame(() => stack.length && this.show(stack.shift(), true));
1273
+ }
1164
1274
  },
1165
1275
  getIndex(index = this.index, prev = this.index) {
1166
1276
  return util.clamp(
@@ -1230,7 +1340,7 @@
1230
1340
  },
1231
1341
  observe: resize(),
1232
1342
  events: {
1233
- beforeitemshow({ target }) {
1343
+ itemshow({ target }) {
1234
1344
  util.addClass(target, this.clsActive);
1235
1345
  },
1236
1346
  itemshown({ target }) {
@@ -1242,6 +1352,84 @@
1242
1352
  }
1243
1353
  };
1244
1354
 
1355
+ ({
1356
+ ...Animations$1,
1357
+ fade: {
1358
+ show() {
1359
+ return [{ opacity: 0, zIndex: 0 }, { zIndex: -1 }];
1360
+ },
1361
+ percent(current) {
1362
+ return 1 - util.css(current, "opacity");
1363
+ },
1364
+ translate(percent) {
1365
+ return [{ opacity: 1 - percent, zIndex: 0 }, { zIndex: -1 }];
1366
+ }
1367
+ },
1368
+ scale: {
1369
+ show() {
1370
+ return [{ opacity: 0, transform: scale3d(1 + 0.5), zIndex: 0 }, { zIndex: -1 }];
1371
+ },
1372
+ percent(current) {
1373
+ return 1 - util.css(current, "opacity");
1374
+ },
1375
+ translate(percent) {
1376
+ return [
1377
+ { opacity: 1 - percent, transform: scale3d(1 + 0.5 * percent), zIndex: 0 },
1378
+ { zIndex: -1 }
1379
+ ];
1380
+ }
1381
+ },
1382
+ pull: {
1383
+ show(dir) {
1384
+ return dir < 0 ? [
1385
+ { transform: translate(30), zIndex: -1 },
1386
+ { transform: translate(), zIndex: 0 }
1387
+ ] : [
1388
+ { transform: translate(-100), zIndex: 0 },
1389
+ { transform: translate(), zIndex: -1 }
1390
+ ];
1391
+ },
1392
+ percent(current, next, dir) {
1393
+ return dir < 0 ? 1 - translated(next) : translated(current);
1394
+ },
1395
+ translate(percent, dir) {
1396
+ return dir < 0 ? [
1397
+ { transform: translate(30 * percent), zIndex: -1 },
1398
+ { transform: translate(-100 * (1 - percent)), zIndex: 0 }
1399
+ ] : [
1400
+ { transform: translate(-percent * 100), zIndex: 0 },
1401
+ { transform: translate(30 * (1 - percent)), zIndex: -1 }
1402
+ ];
1403
+ }
1404
+ },
1405
+ push: {
1406
+ show(dir) {
1407
+ return dir < 0 ? [
1408
+ { transform: translate(100), zIndex: 0 },
1409
+ { transform: translate(), zIndex: -1 }
1410
+ ] : [
1411
+ { transform: translate(-30), zIndex: -1 },
1412
+ { transform: translate(), zIndex: 0 }
1413
+ ];
1414
+ },
1415
+ percent(current, next, dir) {
1416
+ return dir > 0 ? 1 - translated(next) : translated(current);
1417
+ },
1418
+ translate(percent, dir) {
1419
+ return dir < 0 ? [
1420
+ { transform: translate(percent * 100), zIndex: 0 },
1421
+ { transform: translate(-30 * (1 - percent)), zIndex: -1 }
1422
+ ] : [
1423
+ { transform: translate(-30 * percent), zIndex: -1 },
1424
+ { transform: translate(100 * (1 - percent)), zIndex: 0 }
1425
+ ];
1426
+ }
1427
+ }
1428
+ });
1429
+ function scale3d(value) {
1430
+ return `scale3d(${value}, ${value}, 1)`;
1431
+ }
1432
+
1245
1433
  var Animations = {
1246
1434
  ...Animations$1,
1247
1435
  fade: {
@@ -1275,34 +1463,67 @@
1275
1463
  };
1276
1464
 
1277
1465
  var LightboxPanel = {
1466
+ i18n: {
1467
+ counter: "%s / %s"
1468
+ },
1278
1469
  mixins: [Modal, Slideshow],
1279
1470
  functional: true,
1280
1471
  props: {
1281
- delayControls: Number,
1472
+ counter: Boolean,
1282
1473
  preload: Number,
1474
+ nav: Boolean,
1475
+ slidenav: Boolean,
1476
+ delayControls: Number,
1283
1477
  videoAutoplay: Boolean,
1284
1478
  template: String
1285
1479
  },
1286
1480
  data: () => ({
1481
+ counter: false,
1287
1482
  preload: 1,
1288
- videoAutoplay: false,
1483
+ nav: false,
1484
+ slidenav: true,
1289
1485
  delayControls: 3e3,
1486
+ videoAutoplay: false,
1290
1487
  items: [],
1291
1488
  cls: "uk-open",
1292
1489
  clsPage: "uk-lightbox-page",
1293
- selList: ".uk-lightbox-items",
1490
+ clsFit: "uk-lightbox-items-fit",
1491
+ clsZoom: "uk-lightbox-zoom",
1294
1492
  attrItem: "uk-lightbox-item",
1493
+ selList: ".uk-lightbox-items",
1295
1494
  selClose: ".uk-close-large",
1495
+ selNav: ".uk-lightbox-thumbnav, .uk-lightbox-dotnav",
1296
1496
  selCaption: ".uk-lightbox-caption",
1497
+ selCounter: ".uk-lightbox-counter",
1297
1498
  pauseOnHover: false,
1298
1499
  velocity: 2,
1299
1500
  Animations,
1300
- template: `<div class="uk-lightbox uk-overflow-hidden"> <div class="uk-lightbox-items"></div> <div class="uk-lightbox-toolbar uk-position-top uk-text-right uk-transition-slide-top uk-transition-opaque"> <button class="uk-lightbox-toolbar-icon uk-close-large" type="button" uk-close></button> </div> <a class="uk-lightbox-button uk-position-center-left uk-position-medium uk-transition-fade" href uk-slidenav-previous uk-lightbox-item="previous"></a> <a class="uk-lightbox-button uk-position-center-right uk-position-medium uk-transition-fade" href uk-slidenav-next uk-lightbox-item="next"></a> <div class="uk-lightbox-toolbar uk-lightbox-caption uk-position-bottom uk-text-center uk-transition-slide-bottom uk-transition-opaque"></div> </div>`
1501
+ template: `<div class="uk-lightbox uk-overflow-hidden"> <div class="uk-lightbox-items"></div> <div class="uk-position-top-right uk-position-small uk-transition-fade" uk-inverse> <button class="uk-lightbox-close uk-close-large" type="button" uk-close></button> </div> <div class="uk-lightbox-slidenav uk-position-center-left uk-position-medium uk-transition-fade" uk-inverse> <a href uk-slidenav-previous uk-lightbox-item="previous"></a> </div> <div class="uk-lightbox-slidenav uk-position-center-right uk-position-medium uk-transition-fade" uk-inverse> <a href uk-slidenav-next uk-lightbox-item="next"></a> </div> <div class="uk-position-center-right uk-position-medium uk-transition-fade" uk-inverse style="max-height: 90vh; overflow: auto;"> <ul class="uk-lightbox-thumbnav uk-lightbox-thumbnav-vertical uk-thumbnav uk-thumbnav-vertical"></ul> <ul class="uk-lightbox-dotnav uk-dotnav uk-dotnav-vertical"></ul> </div> <div class="uk-lightbox-counter uk-text-large uk-position-top-left uk-position-small uk-transition-fade" uk-inverse></div> <div class="uk-lightbox-caption uk-position-bottom uk-text-center uk-transition-slide-bottom uk-transition-opaque"></div> </div>`
1301
1502
  }),
1302
1503
  created() {
1303
- const $el = util.$(this.template);
1504
+ let $el = util.$(this.template);
1505
+ if (util.isTag($el, "template")) {
1506
+ $el = util.fragment(util.html($el));
1507
+ }
1304
1508
  const list = util.$(this.selList, $el);
1305
- this.items.forEach(() => util.append(list, "<div>"));
1509
+ const navType = this.$props.nav;
1510
+ util.remove(util.$$(this.selNav, $el).filter((el) => !util.matches(el, `.uk-${navType}`)));
1511
+ for (const [i, item] of this.items.entries()) {
1512
+ util.append(list, "<div>");
1513
+ if (navType === "thumbnav") {
1514
+ util.wrapAll(
1515
+ toThumbnavItem(item, this.videoAutoplay),
1516
+ util.append(util.$(this.selNav, $el), `<li uk-lightbox-item="${i}"><a href></a></li>`)
1517
+ );
1518
+ }
1519
+ }
1520
+ if (!this.slidenav) {
1521
+ util.remove(util.$$(".uk-lightbox-slidenav", $el));
1522
+ }
1523
+ if (!this.counter) {
1524
+ util.remove(util.$(this.selCounter, $el));
1525
+ }
1526
+ util.addClass(list, this.clsFit);
1306
1527
  const close = util.$("[uk-close]", $el);
1307
1528
  const closeLabel = this.t("close");
1308
1529
  if (close && closeLabel) {
@@ -1312,21 +1533,33 @@
1312
1533
  },
1313
1534
  events: [
1314
1535
  {
1315
- name: `${util.pointerMove} ${util.pointerDown} keydown`,
1316
- handler() {
1317
- this.showControls();
1536
+ name: "click",
1537
+ self: true,
1538
+ filter: ({ bgClose }) => bgClose,
1539
+ delegate: ({ selList }) => `${selList} > *`,
1540
+ handler(e) {
1541
+ if (!e.defaultPrevented) {
1542
+ this.hide();
1543
+ }
1318
1544
  }
1319
1545
  },
1320
1546
  {
1321
1547
  name: "click",
1322
1548
  self: true,
1323
- delegate: ({ selList }) => `${selList} > *`,
1549
+ delegate: ({ clsZoom }) => `.${clsZoom}`,
1324
1550
  handler(e) {
1325
1551
  if (!e.defaultPrevented) {
1326
- this.hide();
1552
+ util.toggleClass(this.list, this.clsFit);
1327
1553
  }
1328
1554
  }
1329
1555
  },
1556
+ {
1557
+ name: `${util.pointerMove} ${util.pointerDown} keydown`,
1558
+ filter: ({ delayControls }) => delayControls,
1559
+ handler() {
1560
+ this.showControls();
1561
+ }
1562
+ },
1330
1563
  {
1331
1564
  name: "shown",
1332
1565
  self: true,
@@ -1381,7 +1614,7 @@
1381
1614
  this.draggable = false;
1382
1615
  e.preventDefault();
1383
1616
  this.toggleElement(this.$el, true, false);
1384
- this.animation = Animations["scale"];
1617
+ this.animation = Animations.scale;
1385
1618
  util.removeClass(e.target, this.clsActive);
1386
1619
  this.stack.splice(1, 0, this.index);
1387
1620
  }
@@ -1390,6 +1623,10 @@
1390
1623
  name: "itemshow",
1391
1624
  handler() {
1392
1625
  util.html(util.$(this.selCaption, this.$el), this.getItem().caption || "");
1626
+ util.html(
1627
+ util.$(this.selCounter, this.$el),
1628
+ this.t("counter", this.index + 1, this.slides.length)
1629
+ );
1393
1630
  for (let j = -this.preload; j <= this.preload; j++) {
1394
1631
  this.loadItem(this.index + j);
1395
1632
  }
@@ -1404,29 +1641,36 @@
1404
1641
  {
1405
1642
  name: "itemload",
1406
1643
  async handler(_, item) {
1407
- const { source: src, type, alt = "", poster, attrs = {} } = item;
1644
+ const { source: src, type, attrs = {} } = item;
1408
1645
  this.setItem(item, "<span uk-spinner></span>");
1409
1646
  if (!src) {
1410
1647
  return;
1411
1648
  }
1412
- let matches;
1649
+ let matches2;
1413
1650
  const iframeAttrs = {
1414
1651
  allowfullscreen: "",
1415
1652
  style: "max-width: 100%; box-sizing: border-box;",
1416
1653
  "uk-responsive": "",
1417
- "uk-video": `${this.videoAutoplay}`
1654
+ "uk-video": `${Boolean(this.videoAutoplay)}`
1418
1655
  };
1419
- if (type === "image" || src.match(/\.(avif|jpe?g|jfif|a?png|gif|svg|webp)($|\?)/i)) {
1420
- const img = createEl("img", { src, alt, ...attrs });
1421
- util.on(img, "load", () => this.setItem(item, img));
1656
+ if (type === "image" || isImage(src)) {
1657
+ const img = createEl("img");
1658
+ wrapInPicture(img, item.sources);
1659
+ util.attr(img, {
1660
+ src,
1661
+ ...util.pick(item, ["alt", "srcset", "sizes"]),
1662
+ ...attrs
1663
+ });
1664
+ util.on(img, "load", () => this.setItem(item, util.parent(img) || img));
1422
1665
  util.on(img, "error", () => this.setError(item));
1423
- } else if (type === "video" || src.match(/\.(mp4|webm|ogv)($|\?)/i)) {
1666
+ } else if (type === "video" || isVideo(src)) {
1667
+ const inline = this.videoAutoplay === "inline";
1424
1668
  const video = createEl("video", {
1425
1669
  src,
1426
- poster,
1427
- controls: "",
1428
1670
  playsinline: "",
1429
- "uk-video": `${this.videoAutoplay}`,
1671
+ controls: inline ? null : "",
1672
+ poster: this.videoAutoplay ? null : item.poster,
1673
+ "uk-video": inline ? "automute: true" : Boolean(this.videoAutoplay),
1430
1674
  ...attrs
1431
1675
  });
1432
1676
  util.on(video, "loadedmetadata", () => this.setItem(item, video));
@@ -1441,20 +1685,20 @@
1441
1685
  ...attrs
1442
1686
  })
1443
1687
  );
1444
- } else if (matches = src.match(
1688
+ } else if (matches2 = src.match(
1445
1689
  /\/\/(?:.*?youtube(-nocookie)?\..*?(?:[?&]v=|\/shorts\/)|youtu\.be\/)([\w-]{11})[&?]?(.*)?/
1446
1690
  )) {
1447
1691
  this.setItem(
1448
1692
  item,
1449
1693
  createEl("iframe", {
1450
- src: `https://www.youtube${matches[1] || ""}.com/embed/${matches[2]}${matches[3] ? `?${matches[3]}` : ""}`,
1694
+ src: `https://www.youtube${matches2[1] || ""}.com/embed/${matches2[2]}${matches2[3] ? `?${matches2[3]}` : ""}`,
1451
1695
  width: 1920,
1452
1696
  height: 1080,
1453
1697
  ...iframeAttrs,
1454
1698
  ...attrs
1455
1699
  })
1456
1700
  );
1457
- } else if (matches = src.match(/\/\/.*?vimeo\.[a-z]+\/(\d+)[&?]?(.*)?/)) {
1701
+ } else if (matches2 = src.match(/\/\/.*?vimeo\.[a-z]+\/(\d+)[&?]?(.*)?/)) {
1458
1702
  try {
1459
1703
  const { height, width } = await (await fetch(
1460
1704
  `https://vimeo.com/api/oembed.json?maxwidth=1920&url=${encodeURI(
@@ -1465,7 +1709,7 @@
1465
1709
  this.setItem(
1466
1710
  item,
1467
1711
  createEl("iframe", {
1468
- src: `https://player.vimeo.com/video/${matches[1]}${matches[2] ? `?${matches[2]}` : ""}`,
1712
+ src: `https://player.vimeo.com/video/${matches2[1]}${matches2[2] ? `?${matches2[2]}` : ""}`,
1469
1713
  width,
1470
1714
  height,
1471
1715
  ...iframeAttrs,
@@ -1477,8 +1721,29 @@
1477
1721
  }
1478
1722
  }
1479
1723
  }
1724
+ },
1725
+ {
1726
+ name: "itemloaded",
1727
+ handler() {
1728
+ this.$emit("resize");
1729
+ }
1480
1730
  }
1481
1731
  ],
1732
+ update: {
1733
+ read() {
1734
+ for (const media of util.$$(`${this.selList} :not([controls]):is(img,video)`, this.$el)) {
1735
+ util.toggleClass(
1736
+ media,
1737
+ this.clsZoom,
1738
+ (media.naturalHeight || media.videoHeight) - this.$el.offsetHeight > Math.max(
1739
+ 0,
1740
+ (media.naturalWidth || media.videoWidth) - this.$el.offsetWidth
1741
+ )
1742
+ );
1743
+ }
1744
+ },
1745
+ events: ["resize"]
1746
+ },
1482
1747
  methods: {
1483
1748
  loadItem(index = this.index) {
1484
1749
  const item = this.getItem(index);
@@ -1500,7 +1765,7 @@
1500
1765
  },
1501
1766
  showControls() {
1502
1767
  clearTimeout(this.controlsTimer);
1503
- this.controlsTimer = setTimeout(this.hideControls, this.delayControls);
1768
+ this.controlsTimer = this.delayControls && setTimeout(this.hideControls, this.delayControls);
1504
1769
  util.addClass(this.$el, "uk-active", "uk-transition-active");
1505
1770
  },
1506
1771
  hideControls() {
@@ -1513,7 +1778,26 @@
1513
1778
  util.attr(el, attrs);
1514
1779
  return el;
1515
1780
  }
1781
+ function toThumbnavItem(item, videoAutoplay) {
1782
+ const el = item.poster || item.thumb && (item.type === "image" || isImage(item.thumb)) ? createEl("img", { src: item.poster || item.thumb, alt: "" }) : item.thumb && (item.type === "video" || isVideo(item.thumb)) ? createEl("video", {
1783
+ src: item.thumb,
1784
+ loop: "",
1785
+ playsinline: "",
1786
+ "uk-video": `autoplay: ${Boolean(videoAutoplay)}; automute: true`
1787
+ }) : createEl("canvas");
1788
+ if (item.thumbRatio) {
1789
+ el.style.aspectRatio = item.thumbRatio;
1790
+ }
1791
+ return el;
1792
+ }
1793
+ function isImage(src) {
1794
+ return src == null ? void 0 : src.match(/\.(avif|jpe?g|jfif|a?png|gif|svg|webp)($|\?)/i);
1795
+ }
1796
+ function isVideo(src) {
1797
+ return src == null ? void 0 : src.match(/\.(mp4|webm|ogv)($|\?)/i);
1798
+ }
1516
1799
 
1800
+ const selDisabled = ".uk-disabled *, .uk-disabled, [disabled]";
1517
1801
  var Component = {
1518
1802
  install,
1519
1803
  props: { toggle: String },
@@ -1536,17 +1820,23 @@
1536
1820
  },
1537
1821
  events: {
1538
1822
  name: "click",
1539
- delegate: ({ toggle }) => `${toggle}:not(.uk-disabled)`,
1823
+ delegate: ({ toggle }) => toggle,
1540
1824
  handler(e) {
1541
1825
  if (!e.defaultPrevented) {
1542
1826
  e.preventDefault();
1543
- this.show(e.current);
1827
+ if (!util.matches(e.current, selDisabled)) {
1828
+ this.show(e.current);
1829
+ }
1544
1830
  }
1545
1831
  }
1546
1832
  },
1547
1833
  methods: {
1548
1834
  show(index) {
1549
- const items = util.uniqueBy(this.toggles.map(toItem), "source");
1835
+ let items = this.toggles.map(toItem);
1836
+ if (this.nav === "thumbnav") {
1837
+ ensureThumb.call(this, this.toggles, items);
1838
+ }
1839
+ items = util.uniqueBy(items, "source");
1550
1840
  if (util.isElement(index)) {
1551
1841
  const { source } = toItem(index);
1552
1842
  index = util.findIndex(items, ({ source: src }) => source === src);
@@ -1567,10 +1857,29 @@
1567
1857
  }
1568
1858
  util.assign(Lightbox.props, UIkit.component("lightboxPanel").options.props);
1569
1859
  }
1860
+ function ensureThumb(toggles, items) {
1861
+ for (const [i, toggle] of Object.entries(toggles)) {
1862
+ if (items[i].thumb) {
1863
+ continue;
1864
+ }
1865
+ const parent = util.parents(toggle).reverse().concat(toggle).find(
1866
+ (parent2) => this.$el.contains(parent2) && (parent2 === toggle || util.$$(this.toggle, parent2).length === 1)
1867
+ );
1868
+ if (!parent) {
1869
+ continue;
1870
+ }
1871
+ const media = util.$("img,video", parent);
1872
+ if (media) {
1873
+ items[i].thumb = media.currentSrc || media.poster || media.src;
1874
+ items[i].thumbRatio = (media.naturalWidth || media.videoWidth) / (media.naturalHeight || media.videoHeight);
1875
+ }
1876
+ }
1877
+ }
1570
1878
  function toItem(el) {
1571
1879
  const item = {};
1572
- for (const attr2 of ["href", "caption", "type", "poster", "alt", "attrs"]) {
1573
- item[attr2 === "href" ? "source" : attr2] = util.data(el, attr2);
1880
+ for (const attribute of el.getAttributeNames()) {
1881
+ const key = attribute.replace(/^data-/, "");
1882
+ item[key === "href" ? "source" : key] = el.getAttribute(attribute);
1574
1883
  }
1575
1884
  item.attrs = parseOptions(item.attrs);
1576
1885
  return item;