uikit 3.11.2-dev.244aa5c8c → 3.11.2-dev.31cd2ba38

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 (48) 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 +1 -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 +78 -120
  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 +78 -120
  41. package/dist/js/uikit.min.js +1 -1
  42. package/package.json +1 -1
  43. package/src/js/api/state.js +4 -4
  44. package/src/js/core/img.js +68 -92
  45. package/src/js/util/options.js +5 -5
  46. package/tests/image.html +22 -38
  47. package/tests/images/test.avif +0 -0
  48. 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.31cd2ba38 | 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
+ ? options.match(/^[{[]/)
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
  )
@@ -3481,7 +3481,7 @@
3481
3481
  UIkit.data = '__uikit__';
3482
3482
  UIkit.prefix = 'uk-';
3483
3483
  UIkit.options = {};
3484
- UIkit.version = '3.11.2-dev.244aa5c8c';
3484
+ UIkit.version = '3.11.2-dev.31cd2ba38';
3485
3485
 
3486
3486
  globalAPI(UIkit);
3487
3487
  hooksAPI(UIkit);
@@ -5808,10 +5808,7 @@
5808
5808
 
5809
5809
  props: {
5810
5810
  dataSrc: String,
5811
- dataSrcset: Boolean,
5812
- sizes: String,
5813
- width: Number,
5814
- height: Number,
5811
+ dataSources: String,
5815
5812
  offsetTop: String,
5816
5813
  offsetLeft: String,
5817
5814
  target: String
@@ -5819,10 +5816,7 @@
5819
5816
 
5820
5817
  data: {
5821
5818
  dataSrc: '',
5822
- dataSrcset: false,
5823
- sizes: false,
5824
- width: false,
5825
- height: false,
5819
+ dataSources: [],
5826
5820
  offsetTop: '50vh',
5827
5821
  offsetLeft: '50vw',
5828
5822
  target: false
@@ -5830,37 +5824,6 @@
5830
5824
 
5831
5825
  computed: {
5832
5826
 
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
5827
  target: {
5865
5828
 
5866
5829
  get: function(ref) {
@@ -5873,18 +5836,6 @@
5873
5836
  this.observe();
5874
5837
  }
5875
5838
 
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
5839
  }
5889
5840
 
5890
5841
  },
@@ -5892,21 +5843,13 @@
5892
5843
  connected: function() {
5893
5844
 
5894
5845
  if (!window.IntersectionObserver) {
5895
- setSrcAttrs(this.$el, this.dataSrc, this.dataSrcset, this.sizes);
5846
+ setSrcAttrs(this.$el, this.dataSrc);
5896
5847
  return;
5897
5848
  }
5898
5849
 
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));
5903
- }
5904
-
5905
- this.observer = new IntersectionObserver(this.load, {
5906
- rootMargin: ((this.offsetTop) + "px " + (this.offsetLeft) + "px")
5907
- });
5908
-
5909
- requestAnimationFrame(this.observe);
5850
+ var rootMargin = (toPx(this.offsetTop, 'height')) + "px " + (toPx(this.offsetLeft, 'width')) + "px";
5851
+ this.observer = new IntersectionObserver(this.load, {rootMargin: rootMargin});
5852
+ this.observe();
5910
5853
 
5911
5854
  },
5912
5855
 
@@ -5917,34 +5860,26 @@
5917
5860
  update: {
5918
5861
 
5919
5862
  read: function(ref) {
5920
- var this$1$1 = this;
5921
5863
  var image = ref.image;
5922
5864
 
5923
5865
 
5924
- if (!this.observer) {
5866
+ if (!this.observer || isImg(this.$el)) {
5925
5867
  return false;
5926
5868
  }
5927
5869
 
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)); });
5870
+ setSrcAttrs(this.$el, image && image.currentSrc);
5937
5871
 
5938
5872
  },
5939
5873
 
5940
- write: function(data) {
5874
+ write: function(store) {
5941
5875
 
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,22 @@
5958
5893
  methods: {
5959
5894
 
5960
5895
  load: function(entries) {
5961
- var this$1$1 = this;
5962
-
5963
5896
 
5964
5897
  // Old chromium based browsers (UC Browser) did not implement `isIntersecting`
5965
5898
  if (!entries.some(function (entry) { return isUndefined(entry.isIntersecting) || entry.isIntersecting; })) {
5966
5899
  return;
5967
5900
  }
5968
5901
 
5969
- this._data.image = getImage(this.dataSrc, this.dataSrcset, this.sizes).then(function (img) {
5902
+ if (this._data.image) {
5903
+ return this._data.image;
5904
+ }
5970
5905
 
5971
- setSrcAttrs(this$1$1.$el, currentSrc(img), img.srcset, img.sizes);
5972
- storage[this$1$1.cacheKey] = currentSrc(img);
5973
- return img;
5906
+ var image = isImg(this.$el)
5907
+ ? this.$el
5908
+ : getImageFromElement(this.$el, this.dataSrc, parseOptions(this.dataSources));
5974
5909
 
5975
- }, function (e) { return trigger(this$1$1.$el, new e.constructor(e.type, e)); });
5910
+ this._data.image = image;
5911
+ setSrcAttrs(this.$el, image.currentSrc || this.dataSrc);
5976
5912
 
5977
5913
  this.observer.disconnect();
5978
5914
  },
@@ -5989,13 +5925,15 @@
5989
5925
 
5990
5926
  };
5991
5927
 
5992
- function setSrcAttrs(el, src, srcset, sizes) {
5928
+ function setSrcAttrs(el, src) {
5993
5929
 
5994
5930
  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);
5931
+
5932
+ var parentNode = parent(el);
5933
+ var elements = isPicture(parentNode) ? children(parentNode) : [el];
5934
+ elements.forEach(function (el) { return setSourceProps(el, el); });
5935
+ src && attr(el, 'src', src);
5936
+
5999
5937
  } else if (src) {
6000
5938
 
6001
5939
  var change = !includes(el.style.backgroundImage, src);
@@ -6008,15 +5946,43 @@
6008
5946
 
6009
5947
  }
6010
5948
 
6011
- function getPlaceholderImage(width, height, sizes) {
6012
- var assign;
5949
+ var srcProps = ['data-src', 'data-srcset', 'sizes'];
5950
+ function setSourceProps(sourceEl, targetEl) {
5951
+ srcProps.forEach(function (prop) {
5952
+ var value = data(sourceEl, prop);
5953
+ if (value) {
5954
+ attr(targetEl, prop.replace(/^(data-)+/, ''), value);
5955
+ }
5956
+ });
5957
+ }
5958
+
5959
+ function getImageFromElement(el, src, sources) {
5960
+ if ( sources === void 0 ) sources = [];
5961
+
5962
+
5963
+ if (!src) {
5964
+ return false;
5965
+ }
6013
5966
 
5967
+ var img = new Image();
6014
5968
 
6015
- if (sizes) {
6016
- ((assign = Dimensions.ratio({width: width, height: height}, 'width', toPx(sizesToPixel(sizes))), width = assign.width, height = assign.height));
5969
+ if (!isArray(sources) && isObject(sources)) {
5970
+ sources = [sources];
6017
5971
  }
6018
5972
 
6019
- return ("data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"" + width + "\" height=\"" + height + "\"></svg>");
5973
+ if (sources.length) {
5974
+ var picture = fragment('<picture>');
5975
+ sources.forEach(function (attrs) {
5976
+ var source = fragment('<source>');
5977
+ attr(source, attrs);
5978
+ append(picture, source);
5979
+ });
5980
+ append(picture, img);
5981
+ }
5982
+
5983
+ setSourceProps(el, img);
5984
+ attr(img, 'src', src);
5985
+ return img;
6020
5986
  }
6021
5987
 
6022
5988
  var sizesRe = /\s*(.*?)\s*(\w+|calc\(.*?\))\s*(?:,|$)/g;
@@ -6056,24 +6022,16 @@
6056
6022
  return descriptors.filter(function (size) { return size >= srcSize; })[0] || descriptors.pop() || '';
6057
6023
  }
6058
6024
 
6059
- function isImg(el) {
6060
- return el.tagName === 'IMG';
6025
+ function isPicture(el) {
6026
+ return isA(el, 'PICTURE');
6061
6027
  }
6062
6028
 
6063
- function currentSrc(el) {
6064
- return el.currentSrc || el.src;
6029
+ function isImg(el) {
6030
+ return isA(el, 'IMG');
6065
6031
  }
6066
6032
 
6067
- var key = '__test__';
6068
- var storage;
6069
-
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 = {};
6033
+ function isA(el, tagName) {
6034
+ return el && el.tagName === tagName;
6077
6035
  }
6078
6036
 
6079
6037
  var Media = {