uikit 3.9.4 → 3.9.5-dev.630197adb

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 (45) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/build/util.js +4 -1
  3. package/dist/css/uikit-core-rtl.css +1 -1
  4. package/dist/css/uikit-core-rtl.min.css +1 -1
  5. package/dist/css/uikit-core.css +1 -1
  6. package/dist/css/uikit-core.min.css +1 -1
  7. package/dist/css/uikit-rtl.css +1 -1
  8. package/dist/css/uikit-rtl.min.css +1 -1
  9. package/dist/css/uikit.css +1 -1
  10. package/dist/css/uikit.min.css +1 -1
  11. package/dist/js/components/countdown.js +1 -1
  12. package/dist/js/components/countdown.min.js +1 -1
  13. package/dist/js/components/filter.js +1 -1
  14. package/dist/js/components/filter.min.js +1 -1
  15. package/dist/js/components/lightbox-panel.js +1 -1
  16. package/dist/js/components/lightbox-panel.min.js +1 -1
  17. package/dist/js/components/lightbox.js +1 -1
  18. package/dist/js/components/lightbox.min.js +1 -1
  19. package/dist/js/components/notification.js +1 -1
  20. package/dist/js/components/notification.min.js +1 -1
  21. package/dist/js/components/parallax.js +1 -1
  22. package/dist/js/components/parallax.min.js +1 -1
  23. package/dist/js/components/slider-parallax.js +1 -1
  24. package/dist/js/components/slider-parallax.min.js +1 -1
  25. package/dist/js/components/slider.js +1 -1
  26. package/dist/js/components/slider.min.js +1 -1
  27. package/dist/js/components/slideshow-parallax.js +1 -1
  28. package/dist/js/components/slideshow-parallax.min.js +1 -1
  29. package/dist/js/components/slideshow.js +1 -1
  30. package/dist/js/components/slideshow.min.js +1 -1
  31. package/dist/js/components/sortable.js +1 -1
  32. package/dist/js/components/sortable.min.js +1 -1
  33. package/dist/js/components/tooltip.js +1 -1
  34. package/dist/js/components/tooltip.min.js +1 -1
  35. package/dist/js/components/upload.js +1 -1
  36. package/dist/js/components/upload.min.js +1 -1
  37. package/dist/js/uikit-core.js +55 -45
  38. package/dist/js/uikit-core.min.js +1 -1
  39. package/dist/js/uikit-icons.js +1 -1
  40. package/dist/js/uikit-icons.min.js +1 -1
  41. package/dist/js/uikit.js +55 -45
  42. package/dist/js/uikit.min.js +1 -1
  43. package/package.json +1 -1
  44. package/src/js/core/drop.js +3 -2
  45. package/src/js/core/img.js +53 -38
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "uikit",
3
3
  "title": "UIkit",
4
4
  "description": "UIkit is a lightweight and modular front-end framework for developing fast and powerful web interfaces.",
5
- "version": "3.9.4",
5
+ "version": "3.9.5-dev.630197adb",
6
6
  "main": "dist/js/uikit.js",
7
7
  "style": "dist/css/uikit.css",
8
8
  "sideEffects": [
@@ -1,7 +1,7 @@
1
1
  import Container from '../mixin/container';
2
2
  import Position from '../mixin/position';
3
3
  import Togglable from '../mixin/togglable';
4
- import {addClass, append, apply, css, hasClass, includes, isTouch, matches, MouseTracker, offset, on, once, parent, pointerCancel, pointerDown, pointerEnter, pointerLeave, pointerUp, query, removeClass, toggleClass, within} from 'uikit-util';
4
+ import {addClass, append, apply, attr, css, hasClass, includes, isTouch, matches, MouseTracker, offset, on, once, parent, pointerCancel, pointerDown, pointerEnter, pointerLeave, pointerUp, query, removeClass, toggleClass, within} from 'uikit-util';
5
5
 
6
6
  export let active;
7
7
 
@@ -62,7 +62,8 @@ export default {
62
62
  this.target = this.$create('toggle', query(this.toggle, this.$el), {
63
63
  target: this.$el,
64
64
  mode: this.mode
65
- });
65
+ }).$el;
66
+ attr(this.target, 'aria-haspopup', true);
66
67
  }
67
68
 
68
69
  },
@@ -1,13 +1,8 @@
1
- import {createEvent, css, Dimensions, escape, getImage, includes, isUndefined, queryAll, startsWith, toFloat, toPx, trigger} from 'uikit-util';
1
+ import {attr, children, createEvent, css, data, Dimensions, escape, getImage, includes, isUndefined, once, parent, queryAll, startsWith, toFloat, toPx, trigger} from 'uikit-util';
2
2
 
3
3
  export default {
4
4
 
5
- args: 'dataSrc',
6
-
7
5
  props: {
8
- dataSrc: String,
9
- dataSrcset: Boolean,
10
- sizes: String,
11
6
  width: Number,
12
7
  height: Number,
13
8
  offsetTop: String,
@@ -16,9 +11,6 @@ export default {
16
11
  },
17
12
 
18
13
  data: {
19
- dataSrc: '',
20
- dataSrcset: false,
21
- sizes: false,
22
14
  width: false,
23
15
  height: false,
24
16
  offsetTop: '50vh',
@@ -28,8 +20,8 @@ export default {
28
20
 
29
21
  computed: {
30
22
 
31
- cacheKey({dataSrc}) {
32
- return `${this.$name}.${dataSrc}`;
23
+ cacheKey() {
24
+ return `${this.$name}.${data(this.$el, 'data-src')}`;
33
25
  },
34
26
 
35
27
  width({width, dataWidth}) {
@@ -40,14 +32,6 @@ export default {
40
32
  return height || dataHeight;
41
33
  },
42
34
 
43
- sizes({sizes, dataSizes}) {
44
- return sizes || dataSizes;
45
- },
46
-
47
- isImg(_, $el) {
48
- return isImg($el);
49
- },
50
-
51
35
  target: {
52
36
 
53
37
  get({target}) {
@@ -73,14 +57,14 @@ export default {
73
57
  connected() {
74
58
 
75
59
  if (!window.IntersectionObserver) {
76
- setSrcAttrs(this.$el, this.dataSrc, this.dataSrcset, this.sizes);
60
+ setSrcAttrs(this.$el);
77
61
  return;
78
62
  }
79
63
 
80
64
  if (storage[this.cacheKey]) {
81
- setSrcAttrs(this.$el, storage[this.cacheKey], this.dataSrcset, this.sizes);
82
- } else if (this.isImg && this.width && this.height) {
83
- setSrcAttrs(this.$el, getPlaceholderImage(this.width, this.height, this.sizes));
65
+ setSrcAttrs(this.$el, storage[this.cacheKey]);
66
+ } else if (isImg(this.$el) && this.width && this.height) {
67
+ attr(this.$el, 'src', getPlaceholderImage(this.$el));
84
68
  }
85
69
 
86
70
  this.observer = new IntersectionObserver(this.load, {
@@ -107,7 +91,7 @@ export default {
107
91
  this.load(this.observer.takeRecords());
108
92
  }
109
93
 
110
- if (this.isImg) {
94
+ if (isImg(this.$el)) {
111
95
  return false;
112
96
  }
113
97
 
@@ -115,14 +99,15 @@ export default {
115
99
 
116
100
  },
117
101
 
118
- write(data) {
102
+ write(store) {
119
103
 
120
- if (this.dataSrcset && window.devicePixelRatio !== 1) {
104
+ const srcset = data(this.$el, 'data-srcset');
105
+ if (srcset && window.devicePixelRatio !== 1) {
121
106
 
122
107
  const bgSize = css(this.$el, 'backgroundSize');
123
- if (bgSize.match(/^(auto\s?)+$/) || toFloat(bgSize) === data.bgSize) {
124
- data.bgSize = getSourceSize(this.dataSrcset, this.sizes);
125
- css(this.$el, 'backgroundSize', `${data.bgSize}px`);
108
+ if (bgSize.match(/^(auto\s?)+$/) || toFloat(bgSize) === store.bgSize) {
109
+ store.bgSize = getSourceSize(srcset, data(this.$el, 'sizes'));
110
+ css(this.$el, 'backgroundSize', `${store.bgSize}px`);
126
111
  }
127
112
 
128
113
  }
@@ -142,9 +127,9 @@ export default {
142
127
  return;
143
128
  }
144
129
 
145
- this._data.image = getImage(this.dataSrc, this.dataSrcset, this.sizes).then(img => {
130
+ this._data.image = getImageFromElement(this.$el).then(img => {
146
131
 
147
- setSrcAttrs(this.$el, currentSrc(img), img.srcset, img.sizes);
132
+ setSrcAttrs(this.$el, currentSrc(img));
148
133
  storage[this.cacheKey] = currentSrc(img);
149
134
  return img;
150
135
 
@@ -163,13 +148,19 @@ export default {
163
148
 
164
149
  };
165
150
 
166
- function setSrcAttrs(el, src, srcset, sizes) {
151
+ const srcProps = ['data-src', 'data-srcset', 'sizes'];
152
+ function setSrcAttrs(el, src) {
167
153
 
154
+ const parentNode = parent(el);
168
155
  if (isImg(el)) {
169
- const set = (prop, val) => val && val !== el[prop] && (el[prop] = val);
170
- set('sizes', sizes);
171
- set('srcset', srcset);
172
- set('src', src);
156
+ (isPicture(parentNode) ? children(parentNode) : [el]).forEach(el =>
157
+ srcProps.forEach(prop => {
158
+ const value = data(el, prop);
159
+ if (value) {
160
+ attr(el, prop.replace(/^(data-)+/, ''), value);
161
+ }
162
+ })
163
+ );
173
164
  } else if (src) {
174
165
 
175
166
  const change = !includes(el.style.backgroundImage, src);
@@ -182,7 +173,10 @@ function setSrcAttrs(el, src, srcset, sizes) {
182
173
 
183
174
  }
184
175
 
185
- function getPlaceholderImage(width, height, sizes) {
176
+ function getPlaceholderImage(el) {
177
+ const sizes = data(el, 'sizes');
178
+ let width = data(el, 'width');
179
+ let height = data(el, 'height');
186
180
 
187
181
  if (sizes) {
188
182
  ({width, height} = Dimensions.ratio({width, height}, 'width', toPx(sizesToPixel(sizes))));
@@ -207,6 +201,19 @@ function sizesToPixel(sizes) {
207
201
  return matches || '100vw';
208
202
  }
209
203
 
204
+ function getImageFromElement(el) {
205
+ const parentNode = parent(el);
206
+ if (!isPicture(parentNode)) {
207
+ return getImage(...srcProps.map(prop => data(el, prop)));
208
+ }
209
+
210
+ return new Promise((resolve, reject) => {
211
+ const picture = parentNode.cloneNode(true);
212
+ once(picture, 'load error', e => e.type === 'error' ? reject(e) : resolve(e.target), true);
213
+ setSrcAttrs(el);
214
+ });
215
+ }
216
+
210
217
  const sizeRe = /\d+(?:\w+|%)/g;
211
218
  const additionRe = /[+-]?(\d+)/g;
212
219
  function evaluateSize(size) {
@@ -228,8 +235,16 @@ function getSourceSize(srcset, sizes) {
228
235
  return descriptors.filter(size => size >= srcSize)[0] || descriptors.pop() || '';
229
236
  }
230
237
 
238
+ function isPicture(el) {
239
+ return isA(el, 'PICTURE');
240
+ }
241
+
231
242
  function isImg(el) {
232
- return el.tagName === 'IMG';
243
+ return isA(el, 'IMG');
244
+ }
245
+
246
+ function isA(el, tagName) {
247
+ return el && el.tagName === tagName;
233
248
  }
234
249
 
235
250
  function currentSrc(el) {