uikit 3.11.2-dev.244aa5c8c → 3.11.2-dev.28b7953b9

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 (50) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/css/uikit-core-rtl.css +1 -1
  3. package/dist/css/uikit-core-rtl.min.css +1 -1
  4. package/dist/css/uikit-core.css +1 -1
  5. package/dist/css/uikit-core.min.css +1 -1
  6. package/dist/css/uikit-rtl.css +1 -1
  7. package/dist/css/uikit-rtl.min.css +1 -1
  8. package/dist/css/uikit.css +1 -1
  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 +1 -1
  15. package/dist/js/components/lightbox-panel.min.js +1 -1
  16. package/dist/js/components/lightbox.js +1 -1
  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 +1 -1
  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 +36 -1
  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 +1 -1
  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 +139 -149
  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 +174 -149
  41. package/dist/js/uikit.min.js +1 -1
  42. package/package.json +1 -1
  43. package/src/js/api/component.js +1 -1
  44. package/src/js/api/state.js +20 -24
  45. package/src/js/components/slideshow.js +32 -1
  46. package/src/js/core/img.js +114 -98
  47. package/src/js/util/options.js +4 -4
  48. package/tests/image.html +31 -41
  49. package/tests/images/test.avif +0 -0
  50. package/tests/images/test.webp +0 -0
package/dist/js/uikit.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! UIkit 3.11.2-dev.244aa5c8c | https://www.getuikit.com | (c) 2014 - 2022 YOOtheme | MIT License */
1
+ /*! UIkit 3.11.2-dev.28b7953b9 | https://www.getuikit.com | (c) 2014 - 2022 YOOtheme | MIT License */
2
2
 
3
3
  (function (global, factory) {
4
4
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -2093,9 +2093,8 @@
2093
2093
 
2094
2094
  try {
2095
2095
 
2096
- return !options
2097
- ? {}
2098
- : startsWith(options, '{')
2096
+ return options
2097
+ ? startsWith(options, '{')
2099
2098
  ? JSON.parse(options)
2100
2099
  : args.length && !includes(options, ':')
2101
2100
  ? (( obj = {}, obj[args[0]] = options, obj ))
@@ -2107,7 +2106,8 @@
2107
2106
  options[key.trim()] = value.trim();
2108
2107
  }
2109
2108
  return options;
2110
- }, {});
2109
+ }, {})
2110
+ : {};
2111
2111
 
2112
2112
  } catch (e) {
2113
2113
  return {};
@@ -3156,11 +3156,11 @@
3156
3156
  on(
3157
3157
  el,
3158
3158
  name,
3159
- !delegate
3160
- ? null
3161
- : isString(delegate)
3159
+ delegate
3160
+ ? isString(delegate)
3162
3161
  ? delegate
3163
- : delegate.call(component),
3162
+ : delegate.call(component)
3163
+ : null,
3164
3164
  isString(handler) ? component[handler] : handler.bind(component),
3165
3165
  {passive: passive, capture: capture, self: self}
3166
3166
  )
@@ -3196,30 +3196,26 @@
3196
3196
  }
3197
3197
 
3198
3198
  function normalizeData(ref, ref$1) {
3199
- var data = ref.data;
3200
- var args = ref$1.args;
3199
+ var data = ref.data; if ( data === void 0 ) data = {};
3200
+ var args = ref$1.args; if ( args === void 0 ) args = [];
3201
3201
  var props = ref$1.props; if ( props === void 0 ) props = {};
3202
3202
 
3203
- data = isArray(data)
3204
- ? !isEmpty(args)
3205
- ? data.slice(0, args.length).reduce(function (data, value, index) {
3206
- if (isPlainObject(value)) {
3207
- assign(data, value);
3208
- } else {
3209
- data[args[index]] = value;
3210
- }
3211
- return data;
3212
- }, {})
3213
- : undefined
3214
- : data;
3215
-
3216
- if (data) {
3217
- for (var key in data) {
3218
- if (isUndefined(data[key])) {
3219
- delete data[key];
3203
+ if (isArray(data)) {
3204
+ data = data.slice(0, args.length).reduce(function (data, value, index) {
3205
+ if (isPlainObject(value)) {
3206
+ assign(data, value);
3220
3207
  } else {
3221
- data[key] = props[key] ? coerce(props[key], data[key]) : data[key];
3208
+ data[args[index]] = value;
3222
3209
  }
3210
+ return data;
3211
+ }, {});
3212
+ }
3213
+
3214
+ for (var key in data) {
3215
+ if (isUndefined(data[key])) {
3216
+ delete data[key];
3217
+ } else if (props[key]) {
3218
+ data[key] = coerce(props[key], data[key]);
3223
3219
  }
3224
3220
  }
3225
3221
 
@@ -3401,7 +3397,7 @@
3401
3397
 
3402
3398
  return component.options.functional
3403
3399
  ? new component({data: isPlainObject(element) ? element : [].concat( argsArray )})
3404
- : !element ? init(element) : $$(element).map(init)[0];
3400
+ : element ? $$(element).map(init)[0] : init();
3405
3401
 
3406
3402
  function init(element) {
3407
3403
 
@@ -3481,7 +3477,7 @@
3481
3477
  UIkit.data = '__uikit__';
3482
3478
  UIkit.prefix = 'uk-';
3483
3479
  UIkit.options = {};
3484
- UIkit.version = '3.11.2-dev.244aa5c8c';
3480
+ UIkit.version = '3.11.2-dev.28b7953b9';
3485
3481
 
3486
3482
  globalAPI(UIkit);
3487
3483
  hooksAPI(UIkit);
@@ -5802,16 +5798,16 @@
5802
5798
  return isRtl ? swap(swap(icon, 'left', 'right'), 'previous', 'next') : icon;
5803
5799
  }
5804
5800
 
5801
+ var nativeLazyLoad = 'loading' in HTMLImageElement.prototype;
5802
+ var nativeIsIntersecting = 'isIntersecting' in IntersectionObserverEntry.prototype; // Old chromium based browsers (UC Browser) did not implement `isIntersecting`
5803
+
5805
5804
  var img = {
5806
5805
 
5807
5806
  args: 'dataSrc',
5808
5807
 
5809
5808
  props: {
5810
5809
  dataSrc: String,
5811
- dataSrcset: Boolean,
5812
- sizes: String,
5813
- width: Number,
5814
- height: Number,
5810
+ dataSources: String,
5815
5811
  offsetTop: String,
5816
5812
  offsetLeft: String,
5817
5813
  target: String
@@ -5819,10 +5815,7 @@
5819
5815
 
5820
5816
  data: {
5821
5817
  dataSrc: '',
5822
- dataSrcset: false,
5823
- sizes: false,
5824
- width: false,
5825
- height: false,
5818
+ dataSources: [],
5826
5819
  offsetTop: '50vh',
5827
5820
  offsetLeft: '50vw',
5828
5821
  target: false
@@ -5830,37 +5823,6 @@
5830
5823
 
5831
5824
  computed: {
5832
5825
 
5833
- cacheKey: function(ref) {
5834
- var dataSrc = ref.dataSrc;
5835
-
5836
- return ((this.$name) + "." + dataSrc);
5837
- },
5838
-
5839
- width: function(ref) {
5840
- var width = ref.width;
5841
- var dataWidth = ref.dataWidth;
5842
-
5843
- return width || dataWidth;
5844
- },
5845
-
5846
- height: function(ref) {
5847
- var height = ref.height;
5848
- var dataHeight = ref.dataHeight;
5849
-
5850
- return height || dataHeight;
5851
- },
5852
-
5853
- sizes: function(ref) {
5854
- var sizes = ref.sizes;
5855
- var dataSizes = ref.dataSizes;
5856
-
5857
- return sizes || dataSizes;
5858
- },
5859
-
5860
- isImg: function(_, $el) {
5861
- return isImg($el);
5862
- },
5863
-
5864
5826
  target: {
5865
5827
 
5866
5828
  get: function(ref) {
@@ -5873,40 +5835,31 @@
5873
5835
  this.observe();
5874
5836
  }
5875
5837
 
5876
- },
5877
-
5878
- offsetTop: function(ref) {
5879
- var offsetTop = ref.offsetTop;
5880
-
5881
- return toPx(offsetTop, 'height');
5882
- },
5883
-
5884
- offsetLeft: function(ref) {
5885
- var offsetLeft = ref.offsetLeft;
5886
-
5887
- return toPx(offsetLeft, 'width');
5888
5838
  }
5889
5839
 
5890
5840
  },
5891
5841
 
5892
5842
  connected: function() {
5893
5843
 
5894
- if (!window.IntersectionObserver) {
5895
- setSrcAttrs(this.$el, this.dataSrc, this.dataSrcset, this.sizes);
5844
+ if (!window.IntersectionObserver || !nativeIsIntersecting) {
5845
+ setSrcAttrs(this.$el, this.dataSrc);
5896
5846
  return;
5897
5847
  }
5898
5848
 
5899
- if (storage[this.cacheKey]) {
5900
- setSrcAttrs(this.$el, storage[this.cacheKey], this.dataSrcset, this.sizes);
5901
- } else if (this.isImg && this.width && this.height) {
5902
- setSrcAttrs(this.$el, getPlaceholderImage(this.width, this.height, this.sizes));
5849
+ if (nativeLazyLoad && isImg(this.$el)) {
5850
+ this.$el.loading = 'lazy';
5851
+ setSrcAttrs(this.$el);
5852
+
5853
+ if (this.target.length === 1) {
5854
+ return;
5855
+ }
5903
5856
  }
5904
5857
 
5905
- this.observer = new IntersectionObserver(this.load, {
5906
- rootMargin: ((this.offsetTop) + "px " + (this.offsetLeft) + "px")
5907
- });
5858
+ ensureSrcAttribute(this.$el);
5908
5859
 
5909
- requestAnimationFrame(this.observe);
5860
+ var rootMargin = (toPx(this.offsetTop, 'height')) + "px " + (toPx(this.offsetLeft, 'width')) + "px";
5861
+ this.observer = new IntersectionObserver(this.load, {rootMargin: rootMargin});
5862
+ this.observe();
5910
5863
 
5911
5864
  },
5912
5865
 
@@ -5916,35 +5869,17 @@
5916
5869
 
5917
5870
  update: {
5918
5871
 
5919
- read: function(ref) {
5920
- var this$1$1 = this;
5921
- var image = ref.image;
5922
-
5923
-
5924
- if (!this.observer) {
5872
+ write: function(store) {
5873
+ if (!this.observer || isImg(this.$el)) {
5925
5874
  return false;
5926
5875
  }
5927
-
5928
- if (!image && document.readyState === 'complete') {
5929
- this.load(this.observer.takeRecords());
5930
- }
5931
-
5932
- if (this.isImg) {
5933
- return false;
5934
- }
5935
-
5936
- image && image.then(function (img) { return img && img.currentSrc !== '' && setSrcAttrs(this$1$1.$el, currentSrc(img)); });
5937
-
5938
- },
5939
-
5940
- write: function(data) {
5941
-
5942
- if (this.dataSrcset && window.devicePixelRatio !== 1) {
5876
+ var srcset = data(this.$el, 'data-srcset');
5877
+ if (srcset && window.devicePixelRatio !== 1) {
5943
5878
 
5944
5879
  var bgSize = css(this.$el, 'backgroundSize');
5945
- if (bgSize.match(/^(auto\s?)+$/) || toFloat(bgSize) === data.bgSize) {
5946
- data.bgSize = getSourceSize(this.dataSrcset, this.sizes);
5947
- css(this.$el, 'backgroundSize', ((data.bgSize) + "px"));
5880
+ if (bgSize.match(/^(auto\s?)+$/) || toFloat(bgSize) === store.bgSize) {
5881
+ store.bgSize = getSourceSize(srcset, data(this.$el, 'sizes'));
5882
+ css(this.$el, 'backgroundSize', ((store.bgSize) + "px"));
5948
5883
  }
5949
5884
 
5950
5885
  }
@@ -5958,21 +5893,26 @@
5958
5893
  methods: {
5959
5894
 
5960
5895
  load: function(entries) {
5961
- var this$1$1 = this;
5962
5896
 
5963
-
5964
- // Old chromium based browsers (UC Browser) did not implement `isIntersecting`
5965
- if (!entries.some(function (entry) { return isUndefined(entry.isIntersecting) || entry.isIntersecting; })) {
5897
+ if (!entries.some(function (entry) { return entry.isIntersecting; })) {
5966
5898
  return;
5967
5899
  }
5968
5900
 
5969
- this._data.image = getImage(this.dataSrc, this.dataSrcset, this.sizes).then(function (img) {
5901
+ if (this._data.image) {
5902
+ return this._data.image;
5903
+ }
5970
5904
 
5971
- setSrcAttrs(this$1$1.$el, currentSrc(img), img.srcset, img.sizes);
5972
- storage[this$1$1.cacheKey] = currentSrc(img);
5973
- return img;
5905
+ var image = isImg(this.$el)
5906
+ ? this.$el
5907
+ : getImageFromElement(
5908
+ this.$el,
5909
+ this.dataSrc,
5910
+ this.dataSources
5911
+ );
5974
5912
 
5975
- }, function (e) { return trigger(this$1$1.$el, new e.constructor(e.type, e)); });
5913
+ this._data.image = image;
5914
+ image.loading = 'eager';
5915
+ setSrcAttrs(this.$el, image.currentSrc);
5976
5916
 
5977
5917
  this.observer.disconnect();
5978
5918
  },
@@ -5989,13 +5929,14 @@
5989
5929
 
5990
5930
  };
5991
5931
 
5992
- function setSrcAttrs(el, src, srcset, sizes) {
5932
+ function setSrcAttrs(el, src) {
5993
5933
 
5994
5934
  if (isImg(el)) {
5995
- var set = function (prop, val) { return val && val !== el[prop] && (el[prop] = val); };
5996
- set('sizes', sizes);
5997
- set('srcset', srcset);
5998
- set('src', src);
5935
+
5936
+ var parentNode = parent(el);
5937
+ var elements = isPicture(parentNode) ? children(parentNode) : [el];
5938
+ elements.forEach(function (el) { return setSourceProps(el, el); });
5939
+
5999
5940
  } else if (src) {
6000
5941
 
6001
5942
  var change = !includes(el.style.backgroundImage, src);
@@ -6008,15 +5949,66 @@
6008
5949
 
6009
5950
  }
6010
5951
 
6011
- function getPlaceholderImage(width, height, sizes) {
6012
- var assign;
5952
+ var srcProps = ['data-src', 'data-srcset', 'sizes'];
5953
+ function setSourceProps(sourceEl, targetEl) {
5954
+ srcProps.forEach(function (prop) {
5955
+ var value = data(sourceEl, prop);
5956
+ if (value) {
5957
+ attr(targetEl, prop.replace(/^(data-)+/, ''), value);
5958
+ }
5959
+ });
5960
+ }
6013
5961
 
5962
+ function getImageFromElement(el, src, sources) {
6014
5963
 
6015
- if (sizes) {
6016
- ((assign = Dimensions.ratio({width: width, height: height}, 'width', toPx(sizesToPixel(sizes))), width = assign.width, height = assign.height));
5964
+ if (!src) {
5965
+ return false;
6017
5966
  }
6018
5967
 
6019
- return ("data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"" + width + "\" height=\"" + height + "\"></svg>");
5968
+ var img = new Image();
5969
+
5970
+ wrapInPicture(img, sources);
5971
+ setSourceProps(el, img);
5972
+ img.onload = function () { return setSrcAttrs(el, img.currentSrc); };
5973
+ attr(img, 'src', src);
5974
+ return img;
5975
+ }
5976
+
5977
+ function wrapInPicture(img, sources) {
5978
+
5979
+ sources = parseSources(sources);
5980
+
5981
+ if (sources.length) {
5982
+ var picture = fragment('<picture>');
5983
+ sources.forEach(function (attrs) {
5984
+ var source = fragment('<source>');
5985
+ attr(source, attrs);
5986
+ append(picture, source);
5987
+ });
5988
+ append(picture, img);
5989
+ }
5990
+ }
5991
+
5992
+ function parseSources(sources) {
5993
+ if (!sources) {
5994
+ return [];
5995
+ }
5996
+
5997
+ if (startsWith(sources, '[')) {
5998
+ try {
5999
+ sources = JSON.parse(sources);
6000
+ } catch (e) {
6001
+ sources = [];
6002
+ }
6003
+ } else {
6004
+ sources = parseOptions(sources);
6005
+ }
6006
+
6007
+ if (!isArray(sources)) {
6008
+ sources = [sources];
6009
+ }
6010
+
6011
+ return sources.filter(function (source) { return !isEmpty(source); });
6020
6012
  }
6021
6013
 
6022
6014
  var sizesRe = /\s*(.*?)\s*(\w+|calc\(.*?\))\s*(?:,|$)/g;
@@ -6056,24 +6048,22 @@
6056
6048
  return descriptors.filter(function (size) { return size >= srcSize; })[0] || descriptors.pop() || '';
6057
6049
  }
6058
6050
 
6059
- function isImg(el) {
6060
- return el.tagName === 'IMG';
6051
+ function ensureSrcAttribute(el) {
6052
+ if (isImg(el) && !hasAttr(el, 'src')) {
6053
+ attr(el, 'src', 'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg"></svg>');
6054
+ }
6061
6055
  }
6062
6056
 
6063
- function currentSrc(el) {
6064
- return el.currentSrc || el.src;
6057
+ function isPicture(el) {
6058
+ return isA(el, 'PICTURE');
6065
6059
  }
6066
6060
 
6067
- var key = '__test__';
6068
- var storage;
6061
+ function isImg(el) {
6062
+ return isA(el, 'IMG');
6063
+ }
6069
6064
 
6070
- // workaround for Safari's private browsing mode and accessing sessionStorage in Blink
6071
- try {
6072
- storage = window.sessionStorage || {};
6073
- storage[key] = 1;
6074
- delete storage[key];
6075
- } catch (e) {
6076
- storage = {};
6065
+ function isA(el, tagName) {
6066
+ return el && el.tagName === tagName;
6077
6067
  }
6078
6068
 
6079
6069
  var Media = {
@@ -11886,6 +11876,33 @@
11886
11876
  Animations: Animations
11887
11877
  },
11888
11878
 
11879
+ connected: function() {
11880
+ var this$1$1 = this;
11881
+
11882
+ if (window.IntersectionObserver) {
11883
+ this.observer = new IntersectionObserver(function (entries) {
11884
+ if (entries.some(function (entry) { return entry.isIntersecting; })) {
11885
+ this$1$1.preloadSlides();
11886
+ }
11887
+ });
11888
+ this.observer.observe(this.$el);
11889
+ }
11890
+ },
11891
+
11892
+ disconnected: function() {
11893
+ this.observer && this.observer.disconnect();
11894
+ },
11895
+
11896
+ methods: {
11897
+
11898
+ preloadSlides: function() {
11899
+ var this$1$1 = this;
11900
+
11901
+ [1, -1].forEach(function (i) { return removeLazyLoad(this$1$1.slides[this$1$1.getIndex(this$1$1.index + i)]); });
11902
+ }
11903
+
11904
+ },
11905
+
11889
11906
  update: {
11890
11907
 
11891
11908
  read: function() {
@@ -11908,6 +11925,10 @@
11908
11925
  height = Math.min(this.maxHeight, height);
11909
11926
  }
11910
11927
 
11928
+ if (isVisible(this.$el)) {
11929
+ this.preloadSlides();
11930
+ }
11931
+
11911
11932
  return {height: height - boxModelAdjust(this.list, 'height', 'content-box')};
11912
11933
  },
11913
11934
 
@@ -11923,6 +11944,10 @@
11923
11944
 
11924
11945
  };
11925
11946
 
11947
+ function removeLazyLoad(el) {
11948
+ el && $$('img[loading="lazy"]', el).forEach(function (el) { return el.loading = 'eager'; });
11949
+ }
11950
+
11926
11951
  var sortable = {
11927
11952
 
11928
11953
  mixins: [Class, Animate],