uikit 3.9.3 → 3.9.5-dev.600ee2ba9

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 (47) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/build/build.js +4 -1
  3. package/build/util.js +4 -1
  4. package/dist/css/uikit-core-rtl.css +1 -1
  5. package/dist/css/uikit-core-rtl.min.css +1 -1
  6. package/dist/css/uikit-core.css +1 -1
  7. package/dist/css/uikit-core.min.css +1 -1
  8. package/dist/css/uikit-rtl.css +1 -1
  9. package/dist/css/uikit-rtl.min.css +1 -1
  10. package/dist/css/uikit.css +1 -1
  11. package/dist/css/uikit.min.css +1 -1
  12. package/dist/js/components/countdown.js +1 -1
  13. package/dist/js/components/countdown.min.js +1 -1
  14. package/dist/js/components/filter.js +1 -1
  15. package/dist/js/components/filter.min.js +1 -1
  16. package/dist/js/components/lightbox-panel.js +1 -1
  17. package/dist/js/components/lightbox-panel.min.js +1 -1
  18. package/dist/js/components/lightbox.js +1 -1
  19. package/dist/js/components/lightbox.min.js +1 -1
  20. package/dist/js/components/notification.js +1 -1
  21. package/dist/js/components/notification.min.js +1 -1
  22. package/dist/js/components/parallax.js +1 -1
  23. package/dist/js/components/parallax.min.js +1 -1
  24. package/dist/js/components/slider-parallax.js +1 -1
  25. package/dist/js/components/slider-parallax.min.js +1 -1
  26. package/dist/js/components/slider.js +1 -1
  27. package/dist/js/components/slider.min.js +1 -1
  28. package/dist/js/components/slideshow-parallax.js +1 -1
  29. package/dist/js/components/slideshow-parallax.min.js +1 -1
  30. package/dist/js/components/slideshow.js +1 -1
  31. package/dist/js/components/slideshow.min.js +1 -1
  32. package/dist/js/components/sortable.js +1 -1
  33. package/dist/js/components/sortable.min.js +1 -1
  34. package/dist/js/components/tooltip.js +1 -1
  35. package/dist/js/components/tooltip.min.js +1 -1
  36. package/dist/js/components/upload.js +1 -1
  37. package/dist/js/components/upload.min.js +1 -1
  38. package/dist/js/uikit-core.js +62 -53
  39. package/dist/js/uikit-core.min.js +1 -1
  40. package/dist/js/uikit-icons.js +1 -1
  41. package/dist/js/uikit-icons.min.js +1 -1
  42. package/dist/js/uikit.js +62 -53
  43. package/dist/js/uikit.min.js +1 -1
  44. package/package.json +2 -2
  45. package/src/js/core/drop.js +3 -2
  46. package/src/js/core/img.js +57 -40
  47. package/src/js/core/sticky.js +3 -2
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.3",
5
+ "version": "3.9.5-dev.600ee2ba9",
6
6
  "main": "dist/js/uikit.js",
7
7
  "style": "dist/css/uikit.css",
8
8
  "sideEffects": [
@@ -20,7 +20,7 @@
20
20
  "prefix": "node build/prefix",
21
21
  "scope": "node build/scope",
22
22
  "release": "node build/release",
23
- "watch-less": "watch-run -i -p 'src/less/**/*.less' yarn compile-less",
23
+ "watch": "watch-run -i -p 'src/less/**/*.less' yarn compile-less",
24
24
  "eslint": "eslint src/js",
25
25
  "eslint-fix": "eslint --fix src/js"
26
26
  },
@@ -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,4 +1,4 @@
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
 
@@ -6,8 +6,6 @@ export default {
6
6
 
7
7
  props: {
8
8
  dataSrc: String,
9
- dataSrcset: Boolean,
10
- sizes: String,
11
9
  width: Number,
12
10
  height: Number,
13
11
  offsetTop: String,
@@ -17,8 +15,6 @@ export default {
17
15
 
18
16
  data: {
19
17
  dataSrc: '',
20
- dataSrcset: false,
21
- sizes: false,
22
18
  width: false,
23
19
  height: false,
24
20
  offsetTop: '50vh',
@@ -32,22 +28,6 @@ export default {
32
28
  return `${this.$name}.${dataSrc}`;
33
29
  },
34
30
 
35
- width({width, dataWidth}) {
36
- return width || dataWidth;
37
- },
38
-
39
- height({height, dataHeight}) {
40
- return height || dataHeight;
41
- },
42
-
43
- sizes({sizes, dataSizes}) {
44
- return sizes || dataSizes;
45
- },
46
-
47
- isImg(_, $el) {
48
- return isImg($el);
49
- },
50
-
51
31
  target: {
52
32
 
53
33
  get({target}) {
@@ -73,14 +53,14 @@ export default {
73
53
  connected() {
74
54
 
75
55
  if (!window.IntersectionObserver) {
76
- setSrcAttrs(this.$el, this.dataSrc, this.dataSrcset, this.sizes);
56
+ setSrcAttrs(this.$el);
77
57
  return;
78
58
  }
79
59
 
80
60
  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));
61
+ setSrcAttrs(this.$el, storage[this.cacheKey]);
62
+ } else if (isImg(this.$el) && this.width && this.height) {
63
+ attr(this.$el, 'src', getPlaceholderImage(this.$el));
84
64
  }
85
65
 
86
66
  this.observer = new IntersectionObserver(this.load, {
@@ -107,7 +87,7 @@ export default {
107
87
  this.load(this.observer.takeRecords());
108
88
  }
109
89
 
110
- if (this.isImg) {
90
+ if (isImg(this.$el)) {
111
91
  return false;
112
92
  }
113
93
 
@@ -115,14 +95,15 @@ export default {
115
95
 
116
96
  },
117
97
 
118
- write(data) {
98
+ write(store) {
119
99
 
120
- if (this.dataSrcset && window.devicePixelRatio !== 1) {
100
+ const srcset = data(this.$el, 'data-srcset');
101
+ if (srcset && window.devicePixelRatio !== 1) {
121
102
 
122
103
  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`);
104
+ if (bgSize.match(/^(auto\s?)+$/) || toFloat(bgSize) === store.bgSize) {
105
+ store.bgSize = getSourceSize(srcset, data(this.$el, 'sizes'));
106
+ css(this.$el, 'backgroundSize', `${store.bgSize}px`);
126
107
  }
127
108
 
128
109
  }
@@ -142,9 +123,9 @@ export default {
142
123
  return;
143
124
  }
144
125
 
145
- this._data.image = getImage(this.dataSrc, this.dataSrcset, this.sizes).then(img => {
126
+ this._data.image = getImageFromElement(this.$el, this.dataSrc).then(img => {
146
127
 
147
- setSrcAttrs(this.$el, currentSrc(img), img.srcset, img.sizes);
128
+ setSrcAttrs(this.$el, currentSrc(img));
148
129
  storage[this.cacheKey] = currentSrc(img);
149
130
  return img;
150
131
 
@@ -163,13 +144,20 @@ export default {
163
144
 
164
145
  };
165
146
 
166
- function setSrcAttrs(el, src, srcset, sizes) {
147
+ const srcProps = ['data-src', 'data-srcset', 'sizes'];
148
+ function setSrcAttrs(el, src) {
167
149
 
150
+ const parentNode = parent(el);
168
151
  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);
152
+ (isPicture(parentNode) ? children(parentNode) : [el]).forEach(el =>
153
+ srcProps.forEach(prop => {
154
+ const value = data(el, prop);
155
+ if (value) {
156
+ attr(el, prop.replace(/^(data-)+/, ''), value);
157
+ }
158
+ })
159
+ );
160
+ attr(el, 'src', src);
173
161
  } else if (src) {
174
162
 
175
163
  const change = !includes(el.style.backgroundImage, src);
@@ -182,7 +170,10 @@ function setSrcAttrs(el, src, srcset, sizes) {
182
170
 
183
171
  }
184
172
 
185
- function getPlaceholderImage(width, height, sizes) {
173
+ function getPlaceholderImage(el) {
174
+ const sizes = data(el, 'sizes');
175
+ let width = data(el, 'width');
176
+ let height = data(el, 'height');
186
177
 
187
178
  if (sizes) {
188
179
  ({width, height} = Dimensions.ratio({width, height}, 'width', toPx(sizesToPixel(sizes))));
@@ -207,6 +198,24 @@ function sizesToPixel(sizes) {
207
198
  return matches || '100vw';
208
199
  }
209
200
 
201
+ function getImageFromElement(el, src) {
202
+ const parentNode = parent(el);
203
+
204
+ if (!src) {
205
+ return Promise.reject(createEvent('error', false));
206
+ }
207
+
208
+ if (!isPicture(parentNode)) {
209
+ return getImage(src, ...srcProps.slice(1).map(prop => data(el, prop)));
210
+ }
211
+
212
+ return new Promise((resolve, reject) => {
213
+ const picture = parentNode.cloneNode(true);
214
+ once(picture, 'load error', e => e.type === 'error' ? reject(e) : resolve(e.target), true);
215
+ setSrcAttrs(el);
216
+ });
217
+ }
218
+
210
219
  const sizeRe = /\d+(?:\w+|%)/g;
211
220
  const additionRe = /[+-]?(\d+)/g;
212
221
  function evaluateSize(size) {
@@ -228,8 +237,16 @@ function getSourceSize(srcset, sizes) {
228
237
  return descriptors.filter(size => size >= srcSize)[0] || descriptors.pop() || '';
229
238
  }
230
239
 
240
+ function isPicture(el) {
241
+ return isA(el, 'PICTURE');
242
+ }
243
+
231
244
  function isImg(el) {
232
- return el.tagName === 'IMG';
245
+ return isA(el, 'IMG');
246
+ }
247
+
248
+ function isA(el, tagName) {
249
+ return el && el.tagName === tagName;
233
250
  }
234
251
 
235
252
  function currentSrc(el) {
@@ -146,9 +146,10 @@ export default {
146
146
 
147
147
  height = !this.isActive ? this.$el.offsetHeight : height;
148
148
 
149
- this.topOffset = offset(this.isFixed ? this.placeholder : this.$el).top;
149
+ const referenceElement = this.isFixed ? this.placeholder : this.$el;
150
+ this.topOffset = offset(referenceElement).top;
150
151
  this.bottomOffset = this.topOffset + height;
151
- this.offsetParentTop = offset(this.$el.offsetParent).top;
152
+ this.offsetParentTop = offset(referenceElement.offsetParent).top;
152
153
 
153
154
  const bottom = parseProp('bottom', this);
154
155