uikit 3.12.3-dev.6377276f3 → 3.12.3-dev.8ce29ae1a

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 (64) hide show
  1. package/CHANGELOG.md +5 -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 +13 -2
  15. package/dist/js/components/lightbox-panel.min.js +1 -1
  16. package/dist/js/components/lightbox.js +13 -2
  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 +13 -2
  21. package/dist/js/components/parallax.min.js +1 -1
  22. package/dist/js/components/slider-parallax.js +9 -7
  23. package/dist/js/components/slider-parallax.min.js +1 -1
  24. package/dist/js/components/slider.js +13 -2
  25. package/dist/js/components/slider.min.js +1 -1
  26. package/dist/js/components/slideshow-parallax.js +9 -7
  27. package/dist/js/components/slideshow-parallax.min.js +1 -1
  28. package/dist/js/components/slideshow.js +13 -2
  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 +12 -20
  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 +178 -146
  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 +188 -154
  41. package/dist/js/uikit.min.js +1 -1
  42. package/package.json +1 -1
  43. package/src/js/api/hooks.js +3 -3
  44. package/src/js/api/state.js +25 -15
  45. package/src/js/components/parallax.js +2 -1
  46. package/src/js/components/slider-parallax.js +6 -4
  47. package/src/js/core/core.js +2 -17
  48. package/src/js/core/cover.js +3 -6
  49. package/src/js/core/drop.js +5 -10
  50. package/src/js/core/gif.js +5 -3
  51. package/src/js/core/height-match.js +21 -1
  52. package/src/js/core/height-viewport.js +1 -6
  53. package/src/js/core/img.js +1 -2
  54. package/src/js/core/leader.js +7 -13
  55. package/src/js/core/margin.js +18 -1
  56. package/src/js/core/overflow-auto.js +8 -7
  57. package/src/js/core/sticky.js +6 -1
  58. package/src/js/core/svg.js +16 -14
  59. package/src/js/core/video.js +2 -8
  60. package/src/js/mixin/position.js +10 -18
  61. package/src/js/mixin/resize.js +13 -0
  62. package/src/js/mixin/slider.js +2 -1
  63. package/src/js/util/class.js +1 -6
  64. package/src/js/util/observer.js +57 -20
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.12.3-dev.6377276f3",
5
+ "version": "3.12.3-dev.8ce29ae1a",
6
6
  "main": "dist/js/uikit.js",
7
7
  "style": "dist/css/uikit.css",
8
8
  "sideEffects": [
@@ -11,7 +11,7 @@ export default function (UIkit) {
11
11
  }
12
12
 
13
13
  this._data = {};
14
- this._computeds = {};
14
+ this._computed = {};
15
15
 
16
16
  this._initProps();
17
17
 
@@ -105,8 +105,8 @@ export default function (UIkit) {
105
105
  const {
106
106
  $options: { computed },
107
107
  } = this;
108
- const values = { ...this._computeds };
109
- this._computeds = {};
108
+ const values = { ...this._computed };
109
+ this._computed = {};
110
110
 
111
111
  for (const key in computed) {
112
112
  const { watch, immediate } = computed[key];
@@ -62,7 +62,7 @@ export default function (UIkit) {
62
62
  UIkit.prototype._initComputeds = function () {
63
63
  const { computed } = this.$options;
64
64
 
65
- this._computeds = {};
65
+ this._computed = {};
66
66
 
67
67
  if (computed) {
68
68
  for (const key in computed) {
@@ -101,11 +101,9 @@ export default function (UIkit) {
101
101
  }
102
102
  }
103
103
  }
104
- for (const { events = [] } of this.$options.update || []) {
105
- if (includes(events, 'scroll')) {
106
- registerScrollListener(this._uid, () => this.$emit('scroll'));
107
- break;
108
- }
104
+
105
+ if (hasUpdateOfType(this.$options.update, 'scroll')) {
106
+ registerScrollListener(this._uid, () => this.$emit('scroll'));
109
107
  }
110
108
  };
111
109
 
@@ -116,7 +114,11 @@ export default function (UIkit) {
116
114
  };
117
115
 
118
116
  UIkit.prototype._initObservers = function () {
119
- this._observers = [initChildListObserver(this), initPropsObserver(this)];
117
+ this._observers = [initPropsObserver(this)];
118
+
119
+ if (this.$options.computed) {
120
+ this.registerObserver(initChildListObserver(this));
121
+ }
120
122
  };
121
123
 
122
124
  UIkit.prototype.registerObserver = function (observer) {
@@ -170,22 +172,22 @@ function registerComputed(component, key, cb) {
170
172
  enumerable: true,
171
173
 
172
174
  get() {
173
- const { _computeds, $props, $el } = component;
175
+ const { _computed, $props, $el } = component;
174
176
 
175
- if (!hasOwn(_computeds, key)) {
176
- _computeds[key] = (cb.get || cb).call(component, $props, $el);
177
+ if (!hasOwn(_computed, key)) {
178
+ _computed[key] = (cb.get || cb).call(component, $props, $el);
177
179
  }
178
180
 
179
- return _computeds[key];
181
+ return _computed[key];
180
182
  },
181
183
 
182
184
  set(value) {
183
- const { _computeds } = component;
185
+ const { _computed } = component;
184
186
 
185
- _computeds[key] = cb.set ? cb.set.call(component, value) : value;
187
+ _computed[key] = cb.set ? cb.set.call(component, value) : value;
186
188
 
187
- if (isUndefined(_computeds[key])) {
188
- delete _computeds[key];
189
+ if (isUndefined(_computed[key])) {
190
+ delete _computed[key];
189
191
  }
190
192
  },
191
193
  });
@@ -313,6 +315,14 @@ function initPropsObserver(component) {
313
315
  return observer;
314
316
  }
315
317
 
318
+ function hasUpdateOfType(updates = [], type) {
319
+ for (const { events = [] } of updates) {
320
+ if (includes(events, type)) {
321
+ return true;
322
+ }
323
+ }
324
+ }
325
+
316
326
  const scrollListeners = new Map();
317
327
  let unbindScrollListener;
318
328
  function registerScrollListener(id, listener) {
@@ -1,8 +1,9 @@
1
+ import Resize from '../mixin/resize';
1
2
  import Parallax from '../mixin/parallax';
2
3
  import { css, parent, query, scrolledOver, toPx } from 'uikit-util';
3
4
 
4
5
  export default {
5
- mixins: [Parallax],
6
+ mixins: [Parallax, Resize],
6
7
 
7
8
  props: {
8
9
  target: String,
@@ -8,10 +8,12 @@ export default {
8
8
  selItem: '!li',
9
9
  },
10
10
 
11
- computed: {
12
- item({ selItem }, $el) {
13
- return query(selItem, $el);
14
- },
11
+ connected() {
12
+ this.item = query(this.selItem, this.$el);
13
+ },
14
+
15
+ disconnected() {
16
+ this.item = null;
15
17
  },
16
18
 
17
19
  events: [
@@ -1,25 +1,10 @@
1
- import { css, fastdom, inBrowser, observeResize, on, toMs } from 'uikit-util';
1
+ import { css, inBrowser, on, toMs } from 'uikit-util';
2
2
 
3
- export default function (UIkit) {
3
+ export default function () {
4
4
  if (!inBrowser) {
5
5
  return;
6
6
  }
7
7
 
8
- // throttle 'resize'
9
- let pendingResize;
10
- const handleResize = () => {
11
- if (pendingResize) {
12
- return;
13
- }
14
- pendingResize = true;
15
- fastdom.read(() => (pendingResize = false));
16
- UIkit.update(null, 'resize');
17
- };
18
-
19
- on(window, 'load resize', handleResize);
20
- on(document, 'loadedmetadata load', handleResize, true);
21
- observeResize(document.documentElement, handleResize);
22
-
23
8
  let started = 0;
24
9
  on(
25
10
  document,
@@ -1,8 +1,9 @@
1
1
  import Video from './video';
2
- import { css, Dimensions, observeResize, parent } from 'uikit-util';
2
+ import { css, Dimensions, parent } from 'uikit-util';
3
+ import Resize from '../mixin/resize';
3
4
 
4
5
  export default {
5
- mixins: [Video],
6
+ mixins: [Resize, Video],
6
7
 
7
8
  props: {
8
9
  width: Number,
@@ -13,10 +14,6 @@ export default {
13
14
  automute: true,
14
15
  },
15
16
 
16
- connected() {
17
- this.registerObserver(observeResize(this.$el, () => this.$emit('resize')));
18
- },
19
-
20
17
  update: {
21
18
  read() {
22
19
  const el = this.$el;
@@ -224,9 +224,7 @@ export default {
224
224
 
225
225
  this.tracker.init();
226
226
 
227
- once(
228
- this.$el,
229
- 'hide',
227
+ for (const handler of [
230
228
  on(
231
229
  document,
232
230
  pointerDown,
@@ -248,19 +246,16 @@ export default {
248
246
  true
249
247
  )
250
248
  ),
251
- { self: true }
252
- );
253
249
 
254
- once(
255
- this.$el,
256
- 'hide',
257
250
  on(document, 'keydown', (e) => {
258
251
  if (e.keyCode === 27) {
259
252
  this.hide(false);
260
253
  }
261
254
  }),
262
- { self: true }
263
- );
255
+ on(window, 'resize', () => this.$emit('resize')),
256
+ ]) {
257
+ once(this.$el, 'hide', handler, { self: true });
258
+ }
264
259
  },
265
260
  },
266
261
 
@@ -1,7 +1,11 @@
1
- import { isInView } from 'uikit-util';
1
+ import { isInView, observeIntersection } from 'uikit-util';
2
2
 
3
3
  // Deprecated
4
4
  export default {
5
+ connected() {
6
+ this.registerObserver(observeIntersection(this.$el, () => this.$emit()));
7
+ },
8
+
5
9
  update: {
6
10
  read(data) {
7
11
  const inview = isInView(this.$el);
@@ -16,7 +20,5 @@ export default {
16
20
  write() {
17
21
  this.$el.src = '' + this.$el.src; // force self-assign
18
22
  },
19
-
20
- events: ['scroll', 'resize'],
21
23
  },
22
24
  };
@@ -1,5 +1,13 @@
1
1
  import { getRows } from './margin';
2
- import { $$, boxModelAdjust, css, dimensions, isVisible, toFloat } from 'uikit-util';
2
+ import {
3
+ $$,
4
+ boxModelAdjust,
5
+ css,
6
+ dimensions,
7
+ isVisible,
8
+ observeMutation,
9
+ toFloat,
10
+ } from 'uikit-util';
3
11
 
4
12
  export default {
5
13
  args: 'target',
@@ -19,6 +27,18 @@ export default {
19
27
  elements({ target }, $el) {
20
28
  return $$(target, $el);
21
29
  },
30
+
31
+ resizeTargets() {
32
+ this.$el.children;
33
+ },
34
+ },
35
+
36
+ connected() {
37
+ this.registerObserver(
38
+ observeMutation(this.$el, () => this.$reset(), {
39
+ childList: true,
40
+ })
41
+ );
22
42
  },
23
43
 
24
44
  update: {
@@ -11,7 +11,6 @@ import {
11
11
  offset,
12
12
  query,
13
13
  toFloat,
14
- trigger,
15
14
  } from 'uikit-util';
16
15
 
17
16
  export default {
@@ -71,13 +70,9 @@ export default {
71
70
  return { minHeight, prev };
72
71
  },
73
72
 
74
- write({ minHeight, prev }) {
73
+ write({ minHeight }) {
75
74
  css(this.$el, { minHeight });
76
75
 
77
- if (minHeight !== prev) {
78
- trigger(this.$el, 'resize');
79
- }
80
-
81
76
  if (this.minHeight && toFloat(css(this.$el, 'minHeight')) < this.minHeight) {
82
77
  css(this.$el, 'minHeight', this.minHeight);
83
78
  }
@@ -8,7 +8,6 @@ import {
8
8
  escape,
9
9
  fragment,
10
10
  hasAttr,
11
- hasIntersectionObserver,
12
11
  includes,
13
12
  isArray,
14
13
  isEmpty,
@@ -60,7 +59,7 @@ export default {
60
59
  },
61
60
 
62
61
  connected() {
63
- if (this.loading !== 'lazy' || !hasIntersectionObserver) {
62
+ if (this.loading !== 'lazy') {
64
63
  this.load();
65
64
  return;
66
65
  }
@@ -1,9 +1,10 @@
1
1
  import Class from '../mixin/class';
2
2
  import Media from '../mixin/media';
3
3
  import { attr, getCssVar, toggleClass, unwrap, wrapInner } from 'uikit-util';
4
+ import Resize from '../mixin/resize';
4
5
 
5
6
  export default {
6
- mixins: [Class, Media],
7
+ mixins: [Class, Media, Resize],
7
8
 
8
9
  props: {
9
10
  fill: String,
@@ -31,26 +32,19 @@ export default {
31
32
  },
32
33
 
33
34
  update: {
34
- read({ changed, width }) {
35
- const prev = width;
36
-
37
- width = Math.floor(this.$el.offsetWidth / 2);
35
+ read() {
36
+ const width = Math.trunc(this.$el.offsetWidth / 2);
38
37
 
39
38
  return {
40
39
  width,
41
40
  fill: this.fill,
42
- changed: changed || prev !== width,
43
41
  hide: !this.matchMedia,
44
42
  };
45
43
  },
46
44
 
47
- write(data) {
48
- toggleClass(this.wrapper, this.clsHide, data.hide);
49
-
50
- if (data.changed) {
51
- data.changed = false;
52
- attr(this.wrapper, this.attrFill, new Array(data.width).join(data.fill));
53
- }
45
+ write({ width, fill, hide }) {
46
+ toggleClass(this.wrapper, this.clsHide, hide);
47
+ attr(this.wrapper, this.attrFill, new Array(width).join(fill));
54
48
  },
55
49
 
56
50
  events: ['resize'],
@@ -1,4 +1,11 @@
1
- import { isRtl, isVisible, offsetPosition, toggleClass } from 'uikit-util';
1
+ import {
2
+ isRtl,
3
+ isVisible,
4
+ observeMutation,
5
+ observeResize,
6
+ offsetPosition,
7
+ toggleClass,
8
+ } from 'uikit-util';
2
9
 
3
10
  export default {
4
11
  props: {
@@ -11,6 +18,16 @@ export default {
11
18
  firstColumn: 'uk-first-column',
12
19
  },
13
20
 
21
+ connected() {
22
+ this.registerObserver(
23
+ observeMutation(this.$el, () => this.$reset(), {
24
+ childList: true,
25
+ })
26
+ );
27
+
28
+ this.registerObserver(observeResize(this.$el.children, () => this.$emit('resize')));
29
+ },
30
+
14
31
  update: {
15
32
  read() {
16
33
  const rows = getRows(this.$el.children);
@@ -1,8 +1,9 @@
1
1
  import Class from '../mixin/class';
2
- import { closest, css, dimensions, height, isVisible, toFloat, trigger } from 'uikit-util';
2
+ import Resize from '../mixin/resize';
3
+ import { closest, css, dimensions, height, isVisible } from 'uikit-util';
3
4
 
4
5
  export default {
5
- mixins: [Class],
6
+ mixins: [Class, Resize],
6
7
 
7
8
  props: {
8
9
  selContainer: String,
@@ -24,6 +25,10 @@ export default {
24
25
  content({ selContent }, $el) {
25
26
  return closest($el, selContent);
26
27
  },
28
+
29
+ resizeTargets() {
30
+ return [this.container, this.content];
31
+ },
27
32
  },
28
33
 
29
34
  connected() {
@@ -37,7 +42,6 @@ export default {
37
42
  }
38
43
 
39
44
  return {
40
- current: toFloat(css(this.$el, 'maxHeight')),
41
45
  max: Math.max(
42
46
  this.minHeight,
43
47
  height(this.container) - (dimensions(this.content).height - height(this.$el))
@@ -45,11 +49,8 @@ export default {
45
49
  };
46
50
  },
47
51
 
48
- write({ current, max }) {
52
+ write({ max }) {
49
53
  css(this.$el, 'maxHeight', max);
50
- if (Math.round(current) !== Math.round(max)) {
51
- trigger(this.$el, 'resize');
52
- }
53
54
  },
54
55
 
55
56
  events: ['resize'],
@@ -1,5 +1,6 @@
1
1
  import Class from '../mixin/class';
2
2
  import Media from '../mixin/media';
3
+ import Resize from '../mixin/resize';
3
4
  import {
4
5
  $,
5
6
  addClass,
@@ -32,7 +33,7 @@ import {
32
33
  } from 'uikit-util';
33
34
 
34
35
  export default {
35
- mixins: [Class, Media],
36
+ mixins: [Class, Media, Resize],
36
37
 
37
38
  props: {
38
39
  position: String,
@@ -75,6 +76,10 @@ export default {
75
76
  return query(widthElement, $el) || this.placeholder;
76
77
  },
77
78
 
79
+ resizeTargets() {
80
+ return document.documentElement;
81
+ },
82
+
78
83
  isActive: {
79
84
  get() {
80
85
  return hasClass(this.selTarget, this.clsActive);
@@ -6,10 +6,10 @@ import {
6
6
  attr,
7
7
  includes,
8
8
  isTag,
9
- isVisible,
10
9
  isVoidElement,
11
10
  memoize,
12
11
  noop,
12
+ observeIntersection,
13
13
  once,
14
14
  remove,
15
15
  removeAttr,
@@ -59,10 +59,24 @@ export default {
59
59
  }
60
60
 
61
61
  this.applyAttributes(svg, el);
62
- this.$emit();
62
+
63
63
  return (this.svgEl = svg);
64
64
  }
65
65
  }, noop);
66
+
67
+ if (this.strokeAnimation) {
68
+ this.svg.then((el) => {
69
+ if (this._connected) {
70
+ applyAnimation(el);
71
+ this.registerObserver(
72
+ observeIntersection(el, (records, observer) => {
73
+ applyAnimation(el);
74
+ observer.disconnect();
75
+ })
76
+ );
77
+ }
78
+ });
79
+ }
66
80
  },
67
81
 
68
82
  disconnected() {
@@ -82,18 +96,6 @@ export default {
82
96
  this.svg = null;
83
97
  },
84
98
 
85
- update: {
86
- read() {
87
- return !!(this.strokeAnimation && this.svgEl && isVisible(this.svgEl));
88
- },
89
-
90
- write() {
91
- applyAnimation(this.svgEl);
92
- },
93
-
94
- type: ['resize'],
95
- },
96
-
97
99
  methods: {
98
100
  async getSvg() {
99
101
  if (isTag(this.$el, 'img') && !this.$el.complete && this.$el.loading === 'lazy') {
@@ -23,13 +23,9 @@ export default {
23
23
  autoplay: true,
24
24
  },
25
25
 
26
- computed: {
27
- inView({ autoplay }) {
28
- return autoplay === 'inview';
29
- },
30
- },
31
-
32
26
  connected() {
27
+ this.inView = this.autoplay === 'inview';
28
+
33
29
  if (this.inView && !hasAttr(this.$el, 'preload')) {
34
30
  this.$el.preload = 'none';
35
31
  }
@@ -60,7 +56,5 @@ export default {
60
56
  play(this.$el);
61
57
  }
62
58
  },
63
-
64
- events: ['resize', 'scroll'],
65
59
  },
66
60
  };
@@ -24,18 +24,10 @@ export default {
24
24
  clsPos: '',
25
25
  },
26
26
 
27
- computed: {
28
- pos({ pos }) {
29
- return pos.split('-').concat('center').slice(0, 2);
30
- },
31
-
32
- dir() {
33
- return this.pos[0];
34
- },
35
-
36
- align() {
37
- return this.pos[1];
38
- },
27
+ connected() {
28
+ this.pos = this.pos.split('-').concat('center').slice(0, 2);
29
+ this.dir = this.pos[0];
30
+ this.align = this.pos[1];
39
31
  },
40
32
 
41
33
  methods: {
@@ -44,6 +36,8 @@ export default {
44
36
 
45
37
  let { offset } = this;
46
38
  const axis = this.getAxis();
39
+ const dir = this.pos[0];
40
+ const align = this.pos[1];
47
41
 
48
42
  if (!isNumeric(offset)) {
49
43
  const node = $(offset);
@@ -56,13 +50,11 @@ export default {
56
50
  const { x, y } = positionAt(
57
51
  element,
58
52
  target,
53
+ axis === 'x' ? `${flipPosition(dir)} ${align}` : `${align} ${flipPosition(dir)}`,
54
+ axis === 'x' ? `${dir} ${align}` : `${align} ${dir}`,
59
55
  axis === 'x'
60
- ? `${flipPosition(this.dir)} ${this.align}`
61
- : `${this.align} ${flipPosition(this.dir)}`,
62
- axis === 'x' ? `${this.dir} ${this.align}` : `${this.align} ${this.dir}`,
63
- axis === 'x'
64
- ? `${this.dir === 'left' ? -offset : offset}`
65
- : ` ${this.dir === 'top' ? -offset : offset}`,
56
+ ? `${dir === 'left' ? -offset : offset}`
57
+ : ` ${dir === 'top' ? -offset : offset}`,
66
58
  null,
67
59
  this.flip,
68
60
  boundary
@@ -0,0 +1,13 @@
1
+ import { observeResize } from 'uikit-util';
2
+
3
+ export default {
4
+ computed: {
5
+ resizeTargets() {
6
+ return this.$el;
7
+ },
8
+ },
9
+
10
+ connected() {
11
+ this.registerObserver(observeResize(this.resizeTargets, () => this.$emit('resize')));
12
+ },
13
+ };
@@ -1,3 +1,4 @@
1
+ import Resize from './resize';
1
2
  import SliderAutoplay from './slider-autoplay';
2
3
  import SliderDrag from './slider-drag';
3
4
  import SliderNav from './slider-nav';
@@ -15,7 +16,7 @@ import {
15
16
  } from 'uikit-util';
16
17
 
17
18
  export default {
18
- mixins: [SliderAutoplay, SliderDrag, SliderNav],
19
+ mixins: [SliderAutoplay, SliderDrag, SliderNav, Resize],
19
20
 
20
21
  props: {
21
22
  clsActivated: Boolean,
@@ -20,12 +20,7 @@ export function replaceClass(element, ...args) {
20
20
 
21
21
  export function hasClass(element, cls) {
22
22
  [cls] = getClasses(cls);
23
- for (const node of toNodes(element)) {
24
- if (cls && node.classList.contains(cls)) {
25
- return true;
26
- }
27
- }
28
- return false;
23
+ return !!cls && toNodes(element).some((node) => node.classList.contains(cls));
29
24
  }
30
25
 
31
26
  export function toggleClass(element, cls, force) {