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
package/dist/js/uikit.js CHANGED
@@ -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() :
@@ -746,7 +746,9 @@
746
746
  }
747
747
  function empty(element) {
748
748
  element = $(element);
749
- element.innerHTML = "";
749
+ if (element) {
750
+ element.innerHTML = "";
751
+ }
750
752
  return element;
751
753
  }
752
754
  function html(parent2, html2) {
@@ -1138,9 +1140,6 @@
1138
1140
  el.muted = true;
1139
1141
  }
1140
1142
  }
1141
- function isVideo(el) {
1142
- return isHTML5(el) || isIFrame(el);
1143
- }
1144
1143
  function isHTML5(el) {
1145
1144
  return isTag(el, "video");
1146
1145
  }
@@ -1606,7 +1605,6 @@
1606
1605
  isTag: isTag,
1607
1606
  isTouch: isTouch,
1608
1607
  isUndefined: isUndefined,
1609
- isVideo: isVideo,
1610
1608
  isVisible: isVisible,
1611
1609
  isVoidElement: isVoidElement,
1612
1610
  isWindow: isWindow,
@@ -2446,6 +2444,121 @@
2446
2444
  return $("a,button", el) || el;
2447
2445
  }
2448
2446
 
2447
+ var img = {
2448
+ args: "dataSrc",
2449
+ props: {
2450
+ dataSrc: String,
2451
+ sources: String,
2452
+ margin: String,
2453
+ target: String,
2454
+ loading: String
2455
+ },
2456
+ data: {
2457
+ dataSrc: "",
2458
+ sources: false,
2459
+ margin: "50%",
2460
+ target: false,
2461
+ loading: "lazy"
2462
+ },
2463
+ connected() {
2464
+ if (this.loading !== "lazy") {
2465
+ this.load();
2466
+ } else if (isImg(this.$el)) {
2467
+ this.$el.loading = "lazy";
2468
+ setSrcAttrs(this.$el);
2469
+ }
2470
+ },
2471
+ disconnected() {
2472
+ if (this.img) {
2473
+ this.img.onload = "";
2474
+ }
2475
+ delete this.img;
2476
+ },
2477
+ observe: intersection({
2478
+ handler(entries, observer) {
2479
+ this.load();
2480
+ observer.disconnect();
2481
+ },
2482
+ options: ({ margin }) => ({ rootMargin: margin }),
2483
+ filter: ({ loading }) => loading === "lazy",
2484
+ target: ({ $el, $props }) => $props.target ? [$el, ...queryAll($props.target, $el)] : $el
2485
+ }),
2486
+ methods: {
2487
+ load() {
2488
+ if (this.img) {
2489
+ return this.img;
2490
+ }
2491
+ const image = isImg(this.$el) ? this.$el : getImageFromElement(this.$el, this.dataSrc, this.sources);
2492
+ removeAttr(image, "loading");
2493
+ setSrcAttrs(this.$el, image.currentSrc);
2494
+ return this.img = image;
2495
+ }
2496
+ }
2497
+ };
2498
+ function setSrcAttrs(el, src) {
2499
+ if (isImg(el)) {
2500
+ const parentNode = parent(el);
2501
+ const elements = isTag(parentNode, "picture") ? children(parentNode) : [el];
2502
+ elements.forEach((el2) => setSourceProps(el2, el2));
2503
+ } else if (src) {
2504
+ const change = !includes(el.style.backgroundImage, src);
2505
+ if (change) {
2506
+ css(el, "backgroundImage", `url(${escape(src)})`);
2507
+ trigger(el, createEvent("load", false));
2508
+ }
2509
+ }
2510
+ }
2511
+ const srcProps = ["data-src", "data-srcset", "sizes"];
2512
+ function setSourceProps(sourceEl, targetEl) {
2513
+ for (const prop of srcProps) {
2514
+ const value = data(sourceEl, prop);
2515
+ if (value) {
2516
+ attr(targetEl, prop.replace(/data-/g, ""), value);
2517
+ }
2518
+ }
2519
+ }
2520
+ function getImageFromElement(el, src, sources) {
2521
+ const img = new Image();
2522
+ wrapInPicture(img, sources);
2523
+ setSourceProps(el, img);
2524
+ img.onload = () => setSrcAttrs(el, img.currentSrc);
2525
+ attr(img, "src", src);
2526
+ return img;
2527
+ }
2528
+ function wrapInPicture(img, sources) {
2529
+ sources = parseSources(sources);
2530
+ if (sources.length) {
2531
+ const picture = fragment("<picture>");
2532
+ for (const attrs of sources) {
2533
+ const source = fragment("<source>");
2534
+ attr(source, attrs);
2535
+ append(picture, source);
2536
+ }
2537
+ append(picture, img);
2538
+ }
2539
+ }
2540
+ function parseSources(sources) {
2541
+ if (!sources) {
2542
+ return [];
2543
+ }
2544
+ if (startsWith(sources, "[")) {
2545
+ try {
2546
+ sources = JSON.parse(sources);
2547
+ } catch (e) {
2548
+ sources = [];
2549
+ }
2550
+ } else {
2551
+ sources = parseOptions(sources);
2552
+ }
2553
+ if (!isArray(sources)) {
2554
+ sources = [sources];
2555
+ }
2556
+ return sources.filter((source) => !isEmpty(source));
2557
+ }
2558
+ function isImg(el) {
2559
+ return isTag(el, "img");
2560
+ }
2561
+
2449
2562
  let prevented;
2450
2563
  function preventBackgroundScroll(el) {
2451
2564
  const off = on(
@@ -2549,8 +2662,12 @@
2549
2662
  addClass(el, cls);
2550
2663
  trigger(el, show ? "show" : "hide", [this]);
2551
2664
  const done = () => {
2665
+ var _a;
2552
2666
  removeClass(el, cls);
2553
2667
  trigger(el, show ? "shown" : "hidden", [this]);
2668
+ if (show) {
2669
+ (_a = $$("[autofocus]", el).find(isVisible)) == null ? void 0 : _a.focus();
2670
+ }
2554
2671
  };
2555
2672
  return promise ? promise.then(done, () => {
2556
2673
  removeClass(el, cls);
@@ -2583,7 +2700,6 @@
2583
2700
  if (changed) {
2584
2701
  trigger(el, "toggled", [toggled, this]);
2585
2702
  }
2586
- $$("[autofocus]", el).some((el2) => isVisible(el2) ? el2.focus() || true : el2.blur());
2587
2703
  }
2588
2704
  }
2589
2705
  };
@@ -2714,9 +2830,6 @@
2714
2830
  panel: ({ selPanel }, $el) => $(selPanel, $el),
2715
2831
  transitionElement() {
2716
2832
  return this.panel;
2717
- },
2718
- bgClose({ bgClose }) {
2719
- return bgClose && this.panel;
2720
2833
  }
2721
2834
  },
2722
2835
  connected() {
@@ -2879,7 +2992,7 @@
2879
2992
  }
2880
2993
  function listenForBackgroundClose$1(modal) {
2881
2994
  return on(document, pointerDown$1, ({ target }) => {
2882
- if (last(active$1) !== modal || modal.overlay && !modal.$el.contains(target) || modal.panel.contains(target)) {
2995
+ if (last(active$1) !== modal || modal.overlay && !modal.$el.contains(target) || !modal.panel || modal.panel.contains(target)) {
2883
2996
  return;
2884
2997
  }
2885
2998
  once(
@@ -2922,11 +3035,7 @@
2922
3035
  return Math.abs(new DOMMatrix(css(el, "transform")).m41 / el.offsetWidth);
2923
3036
  }
2924
3037
  function translate(value = 0, unit = "%") {
2925
- value += value ? unit : "";
2926
- return `translate3d(${value}, 0, 0)`;
2927
- }
2928
- function scale3d(value) {
2929
- return `scale3d(${value}, ${value}, 1)`;
3038
+ return value ? `translate3d(${value + unit}, 0, 0)` : "";
2930
3039
  }
2931
3040
 
2932
3041
  function Transitioner$1(prev, next, dir, { animation, easing }) {
@@ -3060,7 +3169,6 @@
3060
3169
  const pointerDown = "touchstart mousedown";
3061
3170
  const pointerMove = "touchmove mousemove";
3062
3171
  const pointerUp = "touchend touchcancel mouseup click input scroll";
3063
- const preventClick = (e) => e.preventDefault();
3064
3172
  var SliderDrag = {
3065
3173
  props: {
3066
3174
  draggable: Boolean
@@ -3128,9 +3236,6 @@
3128
3236
  if (distance === 0 || this.prevPos === this.pos || !this.dragging && Math.abs(distance) < this.threshold) {
3129
3237
  return;
3130
3238
  }
3131
- if (!this.dragging) {
3132
- on(this.list, "click", preventClick, pointerOptions);
3133
- }
3134
3239
  e.cancelable && e.preventDefault();
3135
3240
  this.dragging = true;
3136
3241
  this.dir = distance < 0 ? 1 : -1;
@@ -3179,6 +3284,7 @@
3179
3284
  off(document, pointerMove, this.move, pointerOptions);
3180
3285
  off(document, pointerUp, this.end, pointerUpOptions);
3181
3286
  if (this.dragging) {
3287
+ setTimeout(on(this.list, "click", (e) => e.preventDefault(), pointerOptions));
3182
3288
  this.dragging = null;
3183
3289
  if (this.index === this.prevIndex) {
3184
3290
  this.percent = 1 - this.percent;
@@ -3189,6 +3295,8 @@
3189
3295
  const dirChange = (isRtl ? this.dir * (isRtl ? 1 : -1) : this.dir) < 0 === this.prevPos > this.pos;
3190
3296
  this.index = dirChange ? this.index : this.prevIndex;
3191
3297
  if (dirChange) {
3298
+ trigger(this.slides[this.prevIndex], "itemhidden", [this]);
3299
+ trigger(this.slides[this.index], "itemshown", [this]);
3192
3300
  this.percent = 1 - this.percent;
3193
3301
  }
3194
3302
  this.show(
@@ -3197,7 +3305,6 @@
3197
3305
  );
3198
3306
  }
3199
3307
  }
3200
- setTimeout(() => off(this.list, "click", preventClick, pointerOptions));
3201
3308
  css(this.list, { userSelect: "" });
3202
3309
  this.drag = this.percent = null;
3203
3310
  }
@@ -3531,7 +3638,7 @@
3531
3638
  };
3532
3639
  App.util = util;
3533
3640
  App.options = {};
3534
- App.version = "3.21.14-dev.60ed95dfb";
3641
+ App.version = "3.21.14-dev.b1911d7ca";
3535
3642
 
3536
3643
  const PREFIX = "uk-";
3537
3644
  const DATA = "__uikit__";
@@ -3650,7 +3757,7 @@
3650
3757
  const instance = this;
3651
3758
  attachToElement(el, instance);
3652
3759
  instance.$options.el = el;
3653
- if (document.contains(el)) {
3760
+ if (el.isConnected) {
3654
3761
  callConnected(instance);
3655
3762
  }
3656
3763
  };
@@ -3836,7 +3943,7 @@
3836
3943
  const item = toNumber(cmd);
3837
3944
  const active = item === index;
3838
3945
  toggleClass(el, this.clsActive, active);
3839
- toggleClass(button, "uk-disabled", this.parallax);
3946
+ toggleClass(button, "uk-disabled", !!this.parallax);
3840
3947
  attr(button, {
3841
3948
  "aria-selected": active,
3842
3949
  tabindex: active && !this.parallax ? null : -1
@@ -3939,7 +4046,7 @@
3939
4046
  }
3940
4047
  },
3941
4048
  methods: {
3942
- show(index, force = false) {
4049
+ async show(index, force = false) {
3943
4050
  var _a;
3944
4051
  if (this.dragging || !this.length || this.parallax) {
3945
4052
  return;
@@ -3975,18 +4082,16 @@
3975
4082
  reset();
3976
4083
  return;
3977
4084
  }
3978
- const promise = this._show(prev, next, force).then(() => {
3979
- prev && trigger(prev, "itemhidden", [this]);
3980
- trigger(next, "itemshown", [this]);
3981
- stack.shift();
3982
- this._transitioner = null;
3983
- if (stack.length) {
3984
- requestAnimationFrame(() => stack.length && this.show(stack.shift(), true));
3985
- }
3986
- });
3987
4085
  prev && trigger(prev, "itemhide", [this]);
3988
4086
  trigger(next, "itemshow", [this]);
3989
- return promise;
4087
+ await this._show(prev, next, force);
4088
+ prev && trigger(prev, "itemhidden", [this]);
4089
+ trigger(next, "itemshown", [this]);
4090
+ stack.shift();
4091
+ this._transitioner = null;
4092
+ if (stack.length) {
4093
+ requestAnimationFrame(() => stack.length && this.show(stack.shift(), true));
4094
+ }
3990
4095
  },
3991
4096
  getIndex(index = this.index, prev = this.index) {
3992
4097
  return clamp(
@@ -4056,7 +4161,7 @@
4056
4161
  },
4057
4162
  observe: resize(),
4058
4163
  events: {
4059
- beforeitemshow({ target }) {
4164
+ itemshow({ target }) {
4060
4165
  addClass(target, this.clsActive);
4061
4166
  },
4062
4167
  itemshown({ target }) {
@@ -4069,6 +4174,84 @@
4069
4174
  };
4070
4175
 
4071
4176
  var Animations$1 = {
4177
+ ...Animations$2,
4178
+ fade: {
4179
+ show() {
4180
+ return [{ opacity: 0, zIndex: 0 }, { zIndex: -1 }];
4181
+ },
4182
+ percent(current) {
4183
+ return 1 - css(current, "opacity");
4184
+ },
4185
+ translate(percent) {
4186
+ return [{ opacity: 1 - percent, zIndex: 0 }, { zIndex: -1 }];
4187
+ }
4188
+ },
4189
+ scale: {
4190
+ show() {
4191
+ return [{ opacity: 0, transform: scale3d(1 + 0.5), zIndex: 0 }, { zIndex: -1 }];
4192
+ },
4193
+ percent(current) {
4194
+ return 1 - css(current, "opacity");
4195
+ },
4196
+ translate(percent) {
4197
+ return [
4198
+ { opacity: 1 - percent, transform: scale3d(1 + 0.5 * percent), zIndex: 0 },
4199
+ { zIndex: -1 }
4200
+ ];
4201
+ }
4202
+ },
4203
+ pull: {
4204
+ show(dir) {
4205
+ return dir < 0 ? [
4206
+ { transform: translate(30), zIndex: -1 },
4207
+ { transform: translate(), zIndex: 0 }
4208
+ ] : [
4209
+ { transform: translate(-100), zIndex: 0 },
4210
+ { transform: translate(), zIndex: -1 }
4211
+ ];
4212
+ },
4213
+ percent(current, next, dir) {
4214
+ return dir < 0 ? 1 - translated(next) : translated(current);
4215
+ },
4216
+ translate(percent, dir) {
4217
+ return dir < 0 ? [
4218
+ { transform: translate(30 * percent), zIndex: -1 },
4219
+ { transform: translate(-100 * (1 - percent)), zIndex: 0 }
4220
+ ] : [
4221
+ { transform: translate(-percent * 100), zIndex: 0 },
4222
+ { transform: translate(30 * (1 - percent)), zIndex: -1 }
4223
+ ];
4224
+ }
4225
+ },
4226
+ push: {
4227
+ show(dir) {
4228
+ return dir < 0 ? [
4229
+ { transform: translate(100), zIndex: 0 },
4230
+ { transform: translate(), zIndex: -1 }
4231
+ ] : [
4232
+ { transform: translate(-30), zIndex: -1 },
4233
+ { transform: translate(), zIndex: 0 }
4234
+ ];
4235
+ },
4236
+ percent(current, next, dir) {
4237
+ return dir > 0 ? 1 - translated(next) : translated(current);
4238
+ },
4239
+ translate(percent, dir) {
4240
+ return dir < 0 ? [
4241
+ { transform: translate(percent * 100), zIndex: 0 },
4242
+ { transform: translate(-30 * (1 - percent)), zIndex: -1 }
4243
+ ] : [
4244
+ { transform: translate(-30 * percent), zIndex: -1 },
4245
+ { transform: translate(100 * (1 - percent)), zIndex: 0 }
4246
+ ];
4247
+ }
4248
+ }
4249
+ };
4250
+ function scale3d(value) {
4251
+ return `scale3d(${value}, ${value}, 1)`;
4252
+ }
4253
+
4254
+ var Animations = {
4072
4255
  ...Animations$2,
4073
4256
  fade: {
4074
4257
  show() {
@@ -4101,34 +4284,67 @@
4101
4284
  };
4102
4285
 
4103
4286
  var LightboxPanel = {
4287
+ i18n: {
4288
+ counter: "%s / %s"
4289
+ },
4104
4290
  mixins: [Modal, Slideshow],
4105
4291
  functional: true,
4106
4292
  props: {
4107
- delayControls: Number,
4293
+ counter: Boolean,
4108
4294
  preload: Number,
4295
+ nav: Boolean,
4296
+ slidenav: Boolean,
4297
+ delayControls: Number,
4109
4298
  videoAutoplay: Boolean,
4110
4299
  template: String
4111
4300
  },
4112
4301
  data: () => ({
4302
+ counter: false,
4113
4303
  preload: 1,
4114
- videoAutoplay: false,
4304
+ nav: false,
4305
+ slidenav: true,
4115
4306
  delayControls: 3e3,
4307
+ videoAutoplay: false,
4116
4308
  items: [],
4117
4309
  cls: "uk-open",
4118
4310
  clsPage: "uk-lightbox-page",
4119
- selList: ".uk-lightbox-items",
4311
+ clsFit: "uk-lightbox-items-fit",
4312
+ clsZoom: "uk-lightbox-zoom",
4120
4313
  attrItem: "uk-lightbox-item",
4314
+ selList: ".uk-lightbox-items",
4121
4315
  selClose: ".uk-close-large",
4316
+ selNav: ".uk-lightbox-thumbnav, .uk-lightbox-dotnav",
4122
4317
  selCaption: ".uk-lightbox-caption",
4318
+ selCounter: ".uk-lightbox-counter",
4123
4319
  pauseOnHover: false,
4124
4320
  velocity: 2,
4125
- Animations: Animations$1,
4126
- 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>`
4321
+ Animations,
4322
+ 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>`
4127
4323
  }),
4128
4324
  created() {
4129
- const $el = $(this.template);
4325
+ let $el = $(this.template);
4326
+ if (isTag($el, "template")) {
4327
+ $el = fragment(html($el));
4328
+ }
4130
4329
  const list = $(this.selList, $el);
4131
- this.items.forEach(() => append(list, "<div>"));
4330
+ const navType = this.$props.nav;
4331
+ remove$1($$(this.selNav, $el).filter((el) => !matches(el, `.uk-${navType}`)));
4332
+ for (const [i, item] of this.items.entries()) {
4333
+ append(list, "<div>");
4334
+ if (navType === "thumbnav") {
4335
+ wrapAll(
4336
+ toThumbnavItem(item, this.videoAutoplay),
4337
+ append($(this.selNav, $el), `<li uk-lightbox-item="${i}"><a href></a></li>`)
4338
+ );
4339
+ }
4340
+ }
4341
+ if (!this.slidenav) {
4342
+ remove$1($$(".uk-lightbox-slidenav", $el));
4343
+ }
4344
+ if (!this.counter) {
4345
+ remove$1($(this.selCounter, $el));
4346
+ }
4347
+ addClass(list, this.clsFit);
4132
4348
  const close = $("[uk-close]", $el);
4133
4349
  const closeLabel = this.t("close");
4134
4350
  if (close && closeLabel) {
@@ -4138,21 +4354,33 @@
4138
4354
  },
4139
4355
  events: [
4140
4356
  {
4141
- name: `${pointerMove$1} ${pointerDown$1} keydown`,
4142
- handler() {
4143
- this.showControls();
4357
+ name: "click",
4358
+ self: true,
4359
+ filter: ({ bgClose }) => bgClose,
4360
+ delegate: ({ selList }) => `${selList} > *`,
4361
+ handler(e) {
4362
+ if (!e.defaultPrevented) {
4363
+ this.hide();
4364
+ }
4144
4365
  }
4145
4366
  },
4146
4367
  {
4147
4368
  name: "click",
4148
4369
  self: true,
4149
- delegate: ({ selList }) => `${selList} > *`,
4370
+ delegate: ({ clsZoom }) => `.${clsZoom}`,
4150
4371
  handler(e) {
4151
4372
  if (!e.defaultPrevented) {
4152
- this.hide();
4373
+ toggleClass(this.list, this.clsFit);
4153
4374
  }
4154
4375
  }
4155
4376
  },
4377
+ {
4378
+ name: `${pointerMove$1} ${pointerDown$1} keydown`,
4379
+ filter: ({ delayControls }) => delayControls,
4380
+ handler() {
4381
+ this.showControls();
4382
+ }
4383
+ },
4156
4384
  {
4157
4385
  name: "shown",
4158
4386
  self: true,
@@ -4207,7 +4435,7 @@
4207
4435
  this.draggable = false;
4208
4436
  e.preventDefault();
4209
4437
  this.toggleElement(this.$el, true, false);
4210
- this.animation = Animations$1["scale"];
4438
+ this.animation = Animations.scale;
4211
4439
  removeClass(e.target, this.clsActive);
4212
4440
  this.stack.splice(1, 0, this.index);
4213
4441
  }
@@ -4216,6 +4444,10 @@
4216
4444
  name: "itemshow",
4217
4445
  handler() {
4218
4446
  html($(this.selCaption, this.$el), this.getItem().caption || "");
4447
+ html(
4448
+ $(this.selCounter, this.$el),
4449
+ this.t("counter", this.index + 1, this.slides.length)
4450
+ );
4219
4451
  for (let j = -this.preload; j <= this.preload; j++) {
4220
4452
  this.loadItem(this.index + j);
4221
4453
  }
@@ -4230,29 +4462,36 @@
4230
4462
  {
4231
4463
  name: "itemload",
4232
4464
  async handler(_, item) {
4233
- const { source: src, type, alt = "", poster, attrs = {} } = item;
4465
+ const { source: src, type, attrs = {} } = item;
4234
4466
  this.setItem(item, "<span uk-spinner></span>");
4235
4467
  if (!src) {
4236
4468
  return;
4237
4469
  }
4238
- let matches;
4470
+ let matches2;
4239
4471
  const iframeAttrs = {
4240
4472
  allowfullscreen: "",
4241
4473
  style: "max-width: 100%; box-sizing: border-box;",
4242
4474
  "uk-responsive": "",
4243
- "uk-video": `${this.videoAutoplay}`
4475
+ "uk-video": `${Boolean(this.videoAutoplay)}`
4244
4476
  };
4245
- if (type === "image" || src.match(/\.(avif|jpe?g|jfif|a?png|gif|svg|webp)($|\?)/i)) {
4246
- const img = createEl("img", { src, alt, ...attrs });
4247
- on(img, "load", () => this.setItem(item, img));
4477
+ if (type === "image" || isImage(src)) {
4478
+ const img = createEl("img");
4479
+ wrapInPicture(img, item.sources);
4480
+ attr(img, {
4481
+ src,
4482
+ ...pick(item, ["alt", "srcset", "sizes"]),
4483
+ ...attrs
4484
+ });
4485
+ on(img, "load", () => this.setItem(item, parent(img) || img));
4248
4486
  on(img, "error", () => this.setError(item));
4249
- } else if (type === "video" || src.match(/\.(mp4|webm|ogv)($|\?)/i)) {
4487
+ } else if (type === "video" || isVideo(src)) {
4488
+ const inline = this.videoAutoplay === "inline";
4250
4489
  const video = createEl("video", {
4251
4490
  src,
4252
- poster,
4253
- controls: "",
4254
4491
  playsinline: "",
4255
- "uk-video": `${this.videoAutoplay}`,
4492
+ controls: inline ? null : "",
4493
+ poster: this.videoAutoplay ? null : item.poster,
4494
+ "uk-video": inline ? "automute: true" : Boolean(this.videoAutoplay),
4256
4495
  ...attrs
4257
4496
  });
4258
4497
  on(video, "loadedmetadata", () => this.setItem(item, video));
@@ -4267,20 +4506,20 @@
4267
4506
  ...attrs
4268
4507
  })
4269
4508
  );
4270
- } else if (matches = src.match(
4509
+ } else if (matches2 = src.match(
4271
4510
  /\/\/(?:.*?youtube(-nocookie)?\..*?(?:[?&]v=|\/shorts\/)|youtu\.be\/)([\w-]{11})[&?]?(.*)?/
4272
4511
  )) {
4273
4512
  this.setItem(
4274
4513
  item,
4275
4514
  createEl("iframe", {
4276
- src: `https://www.youtube${matches[1] || ""}.com/embed/${matches[2]}${matches[3] ? `?${matches[3]}` : ""}`,
4515
+ src: `https://www.youtube${matches2[1] || ""}.com/embed/${matches2[2]}${matches2[3] ? `?${matches2[3]}` : ""}`,
4277
4516
  width: 1920,
4278
4517
  height: 1080,
4279
4518
  ...iframeAttrs,
4280
4519
  ...attrs
4281
4520
  })
4282
4521
  );
4283
- } else if (matches = src.match(/\/\/.*?vimeo\.[a-z]+\/(\d+)[&?]?(.*)?/)) {
4522
+ } else if (matches2 = src.match(/\/\/.*?vimeo\.[a-z]+\/(\d+)[&?]?(.*)?/)) {
4284
4523
  try {
4285
4524
  const { height, width } = await (await fetch(
4286
4525
  `https://vimeo.com/api/oembed.json?maxwidth=1920&url=${encodeURI(
@@ -4291,7 +4530,7 @@
4291
4530
  this.setItem(
4292
4531
  item,
4293
4532
  createEl("iframe", {
4294
- src: `https://player.vimeo.com/video/${matches[1]}${matches[2] ? `?${matches[2]}` : ""}`,
4533
+ src: `https://player.vimeo.com/video/${matches2[1]}${matches2[2] ? `?${matches2[2]}` : ""}`,
4295
4534
  width,
4296
4535
  height,
4297
4536
  ...iframeAttrs,
@@ -4303,8 +4542,29 @@
4303
4542
  }
4304
4543
  }
4305
4544
  }
4545
+ },
4546
+ {
4547
+ name: "itemloaded",
4548
+ handler() {
4549
+ this.$emit("resize");
4550
+ }
4306
4551
  }
4307
4552
  ],
4553
+ update: {
4554
+ read() {
4555
+ for (const media of $$(`${this.selList} :not([controls]):is(img,video)`, this.$el)) {
4556
+ toggleClass(
4557
+ media,
4558
+ this.clsZoom,
4559
+ (media.naturalHeight || media.videoHeight) - this.$el.offsetHeight > Math.max(
4560
+ 0,
4561
+ (media.naturalWidth || media.videoWidth) - this.$el.offsetWidth
4562
+ )
4563
+ );
4564
+ }
4565
+ },
4566
+ events: ["resize"]
4567
+ },
4308
4568
  methods: {
4309
4569
  loadItem(index = this.index) {
4310
4570
  const item = this.getItem(index);
@@ -4326,7 +4586,7 @@
4326
4586
  },
4327
4587
  showControls() {
4328
4588
  clearTimeout(this.controlsTimer);
4329
- this.controlsTimer = setTimeout(this.hideControls, this.delayControls);
4589
+ this.controlsTimer = this.delayControls && setTimeout(this.hideControls, this.delayControls);
4330
4590
  addClass(this.$el, "uk-active", "uk-transition-active");
4331
4591
  },
4332
4592
  hideControls() {
@@ -4339,7 +4599,26 @@
4339
4599
  attr(el, attrs);
4340
4600
  return el;
4341
4601
  }
4602
+ function toThumbnavItem(item, videoAutoplay) {
4603
+ 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", {
4604
+ src: item.thumb,
4605
+ loop: "",
4606
+ playsinline: "",
4607
+ "uk-video": `autoplay: ${Boolean(videoAutoplay)}; automute: true`
4608
+ }) : createEl("canvas");
4609
+ if (item.thumbRatio) {
4610
+ el.style.aspectRatio = item.thumbRatio;
4611
+ }
4612
+ return el;
4613
+ }
4614
+ function isImage(src) {
4615
+ return src == null ? void 0 : src.match(/\.(avif|jpe?g|jfif|a?png|gif|svg|webp)($|\?)/i);
4616
+ }
4617
+ function isVideo(src) {
4618
+ return src == null ? void 0 : src.match(/\.(mp4|webm|ogv)($|\?)/i);
4619
+ }
4342
4620
 
4621
+ const selDisabled$1 = ".uk-disabled *, .uk-disabled, [disabled]";
4343
4622
  var lightbox = {
4344
4623
  install: install$3,
4345
4624
  props: { toggle: String },
@@ -4362,17 +4641,23 @@
4362
4641
  },
4363
4642
  events: {
4364
4643
  name: "click",
4365
- delegate: ({ toggle }) => `${toggle}:not(.uk-disabled)`,
4644
+ delegate: ({ toggle }) => toggle,
4366
4645
  handler(e) {
4367
4646
  if (!e.defaultPrevented) {
4368
4647
  e.preventDefault();
4369
- this.show(e.current);
4648
+ if (!matches(e.current, selDisabled$1)) {
4649
+ this.show(e.current);
4650
+ }
4370
4651
  }
4371
4652
  }
4372
4653
  },
4373
4654
  methods: {
4374
4655
  show(index) {
4375
- const items = uniqueBy(this.toggles.map(toItem), "source");
4656
+ let items = this.toggles.map(toItem);
4657
+ if (this.nav === "thumbnav") {
4658
+ ensureThumb.call(this, this.toggles, items);
4659
+ }
4660
+ items = uniqueBy(items, "source");
4376
4661
  if (isElement(index)) {
4377
4662
  const { source } = toItem(index);
4378
4663
  index = findIndex(items, ({ source: src }) => source === src);
@@ -4393,10 +4678,29 @@
4393
4678
  }
4394
4679
  assign(Lightbox.props, UIkit.component("lightboxPanel").options.props);
4395
4680
  }
4681
+ function ensureThumb(toggles, items) {
4682
+ for (const [i, toggle] of Object.entries(toggles)) {
4683
+ if (items[i].thumb) {
4684
+ continue;
4685
+ }
4686
+ const parent = parents(toggle).reverse().concat(toggle).find(
4687
+ (parent2) => this.$el.contains(parent2) && (parent2 === toggle || $$(this.toggle, parent2).length === 1)
4688
+ );
4689
+ if (!parent) {
4690
+ continue;
4691
+ }
4692
+ const media = $("img,video", parent);
4693
+ if (media) {
4694
+ items[i].thumb = media.currentSrc || media.poster || media.src;
4695
+ items[i].thumbRatio = (media.naturalWidth || media.videoWidth) / (media.naturalHeight || media.videoHeight);
4696
+ }
4697
+ }
4698
+ }
4396
4699
  function toItem(el) {
4397
4700
  const item = {};
4398
- for (const attr2 of ["href", "caption", "type", "poster", "alt", "attrs"]) {
4399
- item[attr2 === "href" ? "source" : attr2] = data(el, attr2);
4701
+ for (const attribute of el.getAttributeNames()) {
4702
+ const key = attribute.replace(/^data-/, "");
4703
+ item[key === "href" ? "source" : key] = el.getAttribute(attribute);
4400
4704
  }
4401
4705
  item.attrs = parseOptions(item.attrs);
4402
4706
  return item;
@@ -5504,81 +5808,6 @@
5504
5808
  return isIn(type) ^ dir < 0 ? percent : 1 - percent;
5505
5809
  }
5506
5810
 
5507
- var Animations = {
5508
- ...Animations$2,
5509
- fade: {
5510
- show() {
5511
- return [{ opacity: 0, zIndex: 0 }, { zIndex: -1 }];
5512
- },
5513
- percent(current) {
5514
- return 1 - css(current, "opacity");
5515
- },
5516
- translate(percent) {
5517
- return [{ opacity: 1 - percent, zIndex: 0 }, { zIndex: -1 }];
5518
- }
5519
- },
5520
- scale: {
5521
- show() {
5522
- return [{ opacity: 0, transform: scale3d(1 + 0.5), zIndex: 0 }, { zIndex: -1 }];
5523
- },
5524
- percent(current) {
5525
- return 1 - css(current, "opacity");
5526
- },
5527
- translate(percent) {
5528
- return [
5529
- { opacity: 1 - percent, transform: scale3d(1 + 0.5 * percent), zIndex: 0 },
5530
- { zIndex: -1 }
5531
- ];
5532
- }
5533
- },
5534
- pull: {
5535
- show(dir) {
5536
- return dir < 0 ? [
5537
- { transform: translate(30), zIndex: -1 },
5538
- { transform: translate(), zIndex: 0 }
5539
- ] : [
5540
- { transform: translate(-100), zIndex: 0 },
5541
- { transform: translate(), zIndex: -1 }
5542
- ];
5543
- },
5544
- percent(current, next, dir) {
5545
- return dir < 0 ? 1 - translated(next) : translated(current);
5546
- },
5547
- translate(percent, dir) {
5548
- return dir < 0 ? [
5549
- { transform: translate(30 * percent), zIndex: -1 },
5550
- { transform: translate(-100 * (1 - percent)), zIndex: 0 }
5551
- ] : [
5552
- { transform: translate(-percent * 100), zIndex: 0 },
5553
- { transform: translate(30 * (1 - percent)), zIndex: -1 }
5554
- ];
5555
- }
5556
- },
5557
- push: {
5558
- show(dir) {
5559
- return dir < 0 ? [
5560
- { transform: translate(100), zIndex: 0 },
5561
- { transform: translate(), zIndex: -1 }
5562
- ] : [
5563
- { transform: translate(-30), zIndex: -1 },
5564
- { transform: translate(), zIndex: 0 }
5565
- ];
5566
- },
5567
- percent(current, next, dir) {
5568
- return dir > 0 ? 1 - translated(next) : translated(current);
5569
- },
5570
- translate(percent, dir) {
5571
- return dir < 0 ? [
5572
- { transform: translate(percent * 100), zIndex: 0 },
5573
- { transform: translate(-30 * (1 - percent)), zIndex: -1 }
5574
- ] : [
5575
- { transform: translate(-30 * percent), zIndex: -1 },
5576
- { transform: translate(100 * (1 - percent)), zIndex: 0 }
5577
- ];
5578
- }
5579
- }
5580
- };
5581
-
5582
5811
  var slideshow = {
5583
5812
  mixins: [Class, Slideshow, SliderReactive, SliderParallax, SliderPreload],
5584
5813
  props: {
@@ -5593,7 +5822,7 @@
5593
5822
  selList: ".uk-slideshow-items",
5594
5823
  attrItem: "uk-slideshow-item",
5595
5824
  selNav: ".uk-slideshow-nav",
5596
- Animations
5825
+ Animations: Animations$1
5597
5826
  },
5598
5827
  watch: {
5599
5828
  list(list) {
@@ -5601,8 +5830,7 @@
5601
5830
  aspectRatio: this.ratio ? this.ratio.replace(":", "/") : void 0,
5602
5831
  minHeight: this.minHeight,
5603
5832
  maxHeight: this.maxHeight,
5604
- minWidth: "100%",
5605
- maxWidth: "100%"
5833
+ width: "100%"
5606
5834
  });
5607
5835
  }
5608
5836
  },
@@ -6687,7 +6915,7 @@
6687
6915
  ],
6688
6916
  observe: [
6689
6917
  intersection({
6690
- filter: ({ $el, autoplay }) => autoplay !== "hover" && isVideo($el),
6918
+ filter: ({ autoplay }) => autoplay !== "hover",
6691
6919
  handler([{ isIntersecting }]) {
6692
6920
  if (!document.fullscreenElement) {
6693
6921
  if (isIntersecting) {
@@ -6700,7 +6928,9 @@
6700
6928
  }
6701
6929
  },
6702
6930
  args: { intersecting: false },
6703
- options: ({ $el, autoplay }) => ({ root: autoplay === "inview" ? null : parent($el) })
6931
+ options: ({ $el, autoplay }) => ({
6932
+ root: autoplay === "inview" ? null : parent($el).closest(":not(a)")
6933
+ })
6704
6934
  })
6705
6935
  ]
6706
6936
  };
@@ -7895,107 +8125,6 @@
7895
8125
  dimensions.forEach((val, i) => attr(el, props[i], toFloat(val) * this.ratio || null));
7896
8126
  }
7897
8127
 
7898
- var svg = {
7899
- mixins: [Svg],
7900
- args: "src",
7901
- props: {
7902
- src: String,
7903
- icon: String,
7904
- attributes: "list",
7905
- strokeAnimation: Boolean
7906
- },
7907
- data: {
7908
- strokeAnimation: false
7909
- },
7910
- observe: [
7911
- mutation({
7912
- async handler() {
7913
- const svg = await this.svg;
7914
- if (svg) {
7915
- applyAttributes.call(this, svg);
7916
- }
7917
- },
7918
- options: {
7919
- attributes: true,
7920
- attributeFilter: ["id", "class", "style"]
7921
- }
7922
- })
7923
- ],
7924
- async connected() {
7925
- if (includes(this.src, "#")) {
7926
- [this.src, this.icon] = this.src.split("#");
7927
- }
7928
- const svg = await this.svg;
7929
- if (svg) {
7930
- applyAttributes.call(this, svg);
7931
- if (this.strokeAnimation) {
7932
- applyAnimation(svg);
7933
- }
7934
- }
7935
- },
7936
- methods: {
7937
- async getSvg() {
7938
- if (isTag(this.$el, "img") && !this.$el.complete && this.$el.loading === "lazy") {
7939
- await new Promise((resolve) => once(this.$el, "load", resolve));
7940
- }
7941
- return parseSVG(await loadSVG(this.src), this.icon) || Promise.reject("SVG not found.");
7942
- }
7943
- }
7944
- };
7945
- function applyAttributes(el) {
7946
- const { $el } = this;
7947
- addClass(el, attr($el, "class"), "uk-svg");
7948
- for (let i = 0; i < $el.style.length; i++) {
7949
- const prop = $el.style[i];
7950
- css(el, prop, css($el, prop));
7951
- }
7952
- for (const attribute in this.attributes) {
7953
- const [prop, value] = this.attributes[attribute].split(":", 2);
7954
- attr(el, prop, value);
7955
- }
7956
- if (!this.$el.id) {
7957
- removeAttr(el, "id");
7958
- }
7959
- }
7960
- const loadSVG = memoize(async (src) => {
7961
- if (src) {
7962
- if (startsWith(src, "data:")) {
7963
- return decodeURIComponent(src.split(",")[1]);
7964
- } else {
7965
- return (await fetch(src)).text();
7966
- }
7967
- } else {
7968
- return Promise.reject();
7969
- }
7970
- });
7971
- function parseSVG(svg, icon) {
7972
- if (icon && includes(svg, "<symbol")) {
7973
- svg = parseSymbols(svg)[icon] || svg;
7974
- }
7975
- return stringToSvg(svg);
7976
- }
7977
- const symbolRe = /<symbol([^]*?id=(['"])(.+?)\2[^]*?<\/)symbol>/g;
7978
- const parseSymbols = memoize(function(svg) {
7979
- const symbols = {};
7980
- symbolRe.lastIndex = 0;
7981
- let match;
7982
- while (match = symbolRe.exec(svg)) {
7983
- symbols[match[3]] = `<svg ${match[1]}svg>`;
7984
- }
7985
- return symbols;
7986
- });
7987
- function applyAnimation(el) {
7988
- const length = getMaxPathLength(el);
7989
- if (length) {
7990
- css(el, "--uk-animation-stroke", length);
7991
- }
7992
- }
7993
- function stringToSvg(string) {
7994
- const container = document.createElement("template");
7995
- container.innerHTML = string;
7996
- return container.content.firstElementChild;
7997
- }
7998
-
7999
8128
  const icons = {
8000
8129
  spinner,
8001
8130
  totop,
@@ -8166,7 +8295,7 @@
8166
8295
  return null;
8167
8296
  }
8168
8297
  if (!parsed[icon]) {
8169
- parsed[icon] = stringToSvg(icons[applyRtl(icon)] || icons[icon]);
8298
+ parsed[icon] = fragment(icons[applyRtl(icon)] || icons[icon]);
8170
8299
  }
8171
8300
  return parsed[icon].cloneNode(true);
8172
8301
  }
@@ -8174,123 +8303,6 @@
8174
8303
  return isRtl ? swap(swap(icon, "left", "right"), "previous", "next") : icon;
8175
8304
  }
8176
8305
 
8177
- var img = {
8178
- args: "dataSrc",
8179
- props: {
8180
- dataSrc: String,
8181
- sources: String,
8182
- margin: String,
8183
- target: String,
8184
- loading: String
8185
- },
8186
- data: {
8187
- dataSrc: "",
8188
- sources: false,
8189
- margin: "50%",
8190
- target: false,
8191
- loading: "lazy"
8192
- },
8193
- connected() {
8194
- if (this.loading !== "lazy") {
8195
- this.load();
8196
- } else if (isImg(this.$el)) {
8197
- this.$el.loading = "lazy";
8198
- setSrcAttrs(this.$el);
8199
- }
8200
- },
8201
- disconnected() {
8202
- if (this.img) {
8203
- this.img.onload = "";
8204
- }
8205
- delete this.img;
8206
- },
8207
- observe: intersection({
8208
- handler(entries, observer) {
8209
- this.load();
8210
- observer.disconnect();
8211
- },
8212
- options: ({ margin }) => ({ rootMargin: margin }),
8213
- filter: ({ loading }) => loading === "lazy",
8214
- target: ({ $el, $props }) => $props.target ? [$el, ...queryAll($props.target, $el)] : $el
8215
- }),
8216
- methods: {
8217
- load() {
8218
- if (this.img) {
8219
- return this.img;
8220
- }
8221
- const image = isImg(this.$el) ? this.$el : getImageFromElement(this.$el, this.dataSrc, this.sources);
8222
- removeAttr(image, "loading");
8223
- setSrcAttrs(this.$el, image.currentSrc);
8224
- return this.img = image;
8225
- }
8226
- }
8227
- };
8228
- function setSrcAttrs(el, src) {
8229
- if (isImg(el)) {
8230
- const parentNode = parent(el);
8231
- const elements = isTag(parentNode, "picture") ? children(parentNode) : [el];
8232
- elements.forEach((el2) => setSourceProps(el2, el2));
8233
- } else if (src) {
8234
- const change = !includes(el.style.backgroundImage, src);
8235
- if (change) {
8236
- css(el, "backgroundImage", `url(${escape(src)})`);
8237
- trigger(el, createEvent("load", false));
8238
- }
8239
- }
8240
- }
8241
- const srcProps = ["data-src", "data-srcset", "sizes"];
8242
- function setSourceProps(sourceEl, targetEl) {
8243
- for (const prop of srcProps) {
8244
- const value = data(sourceEl, prop);
8245
- if (value) {
8246
- attr(targetEl, prop.replace(/^(data-)+/, ""), value);
8247
- }
8248
- }
8249
- }
8250
- function getImageFromElement(el, src, sources) {
8251
- const img = new Image();
8252
- wrapInPicture(img, sources);
8253
- setSourceProps(el, img);
8254
- img.onload = () => {
8255
- setSrcAttrs(el, img.currentSrc);
8256
- };
8257
- attr(img, "src", src);
8258
- return img;
8259
- }
8260
- function wrapInPicture(img, sources) {
8261
- sources = parseSources(sources);
8262
- if (sources.length) {
8263
- const picture = fragment("<picture>");
8264
- for (const attrs of sources) {
8265
- const source = fragment("<source>");
8266
- attr(source, attrs);
8267
- append(picture, source);
8268
- }
8269
- append(picture, img);
8270
- }
8271
- }
8272
- function parseSources(sources) {
8273
- if (!sources) {
8274
- return [];
8275
- }
8276
- if (startsWith(sources, "[")) {
8277
- try {
8278
- sources = JSON.parse(sources);
8279
- } catch (e) {
8280
- sources = [];
8281
- }
8282
- } else {
8283
- sources = parseOptions(sources);
8284
- }
8285
- if (!isArray(sources)) {
8286
- sources = [sources];
8287
- }
8288
- return sources.filter((source) => !isEmpty(source));
8289
- }
8290
- function isImg(el) {
8291
- return isTag(el, "img");
8292
- }
8293
-
8294
8306
  var inverse = {
8295
8307
  props: {
8296
8308
  target: String,
@@ -9393,6 +9405,104 @@
9393
9405
  }
9394
9406
  }
9395
9407
 
9408
+ var svg = {
9409
+ mixins: [Svg],
9410
+ args: "src",
9411
+ props: {
9412
+ src: String,
9413
+ icon: String,
9414
+ attributes: "list",
9415
+ strokeAnimation: Boolean
9416
+ },
9417
+ data: {
9418
+ strokeAnimation: false
9419
+ },
9420
+ observe: [
9421
+ mutation({
9422
+ async handler() {
9423
+ const svg = await this.svg;
9424
+ if (svg) {
9425
+ applyAttributes.call(this, svg);
9426
+ }
9427
+ },
9428
+ options: {
9429
+ attributes: true,
9430
+ attributeFilter: ["id", "class", "style"]
9431
+ }
9432
+ })
9433
+ ],
9434
+ async connected() {
9435
+ if (includes(this.src, "#")) {
9436
+ [this.src, this.icon] = this.src.split("#");
9437
+ }
9438
+ const svg = await this.svg;
9439
+ if (svg) {
9440
+ applyAttributes.call(this, svg);
9441
+ if (this.strokeAnimation) {
9442
+ applyAnimation(svg);
9443
+ }
9444
+ }
9445
+ },
9446
+ methods: {
9447
+ async getSvg() {
9448
+ if (isTag(this.$el, "img") && !this.$el.complete && this.$el.loading === "lazy") {
9449
+ await new Promise((resolve) => once(this.$el, "load", resolve));
9450
+ }
9451
+ return parseSVG(await loadSVG(this.src), this.icon) || Promise.reject("SVG not found.");
9452
+ }
9453
+ }
9454
+ };
9455
+ function applyAttributes(el) {
9456
+ const { $el } = this;
9457
+ addClass(el, attr($el, "class"), "uk-svg");
9458
+ for (let i = 0; i < $el.style.length; i++) {
9459
+ const prop = $el.style[i];
9460
+ css(el, prop, css($el, prop));
9461
+ }
9462
+ for (const attribute in this.attributes) {
9463
+ const [prop, value] = this.attributes[attribute].split(":", 2);
9464
+ attr(el, prop, value);
9465
+ }
9466
+ if (!this.$el.id) {
9467
+ removeAttr(el, "id");
9468
+ }
9469
+ }
9470
+ const loadSVG = memoize(async (src) => {
9471
+ if (src) {
9472
+ if (startsWith(src, "data:")) {
9473
+ return decodeURIComponent(src.split(",")[1]);
9474
+ } else {
9475
+ const response = await fetch(src);
9476
+ if (response.headers.get("Content-Type") === "image/svg+xml") {
9477
+ return response.text();
9478
+ }
9479
+ }
9480
+ }
9481
+ return Promise.reject();
9482
+ });
9483
+ function parseSVG(svg, icon) {
9484
+ if (icon && includes(svg, "<symbol")) {
9485
+ svg = parseSymbols(svg)[icon] || svg;
9486
+ }
9487
+ return fragment(svg);
9488
+ }
9489
+ const symbolRe = /<symbol([^]*?id=(['"])(.+?)\2[^]*?<\/)symbol>/g;
9490
+ const parseSymbols = memoize(function(svg) {
9491
+ const symbols = {};
9492
+ symbolRe.lastIndex = 0;
9493
+ let match;
9494
+ while (match = symbolRe.exec(svg)) {
9495
+ symbols[match[3]] = `<svg ${match[1]}svg>`;
9496
+ }
9497
+ return symbols;
9498
+ });
9499
+ function applyAnimation(el) {
9500
+ const length = getMaxPathLength(el);
9501
+ if (length) {
9502
+ css(el, "--uk-animation-stroke", length);
9503
+ }
9504
+ }
9505
+
9396
9506
  const selDisabled = ".uk-disabled *, .uk-disabled, [disabled]";
9397
9507
  var Switcher = {
9398
9508
  mixins: [Togglable],