uikit 3.16.4 → 3.16.5-dev.2fd0fea3e

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 (51) hide show
  1. package/.eslintrc.json +1 -1
  2. package/CHANGELOG.md +7 -0
  3. package/build/util.js +2 -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 +14 -6
  17. package/dist/js/components/lightbox-panel.min.js +1 -1
  18. package/dist/js/components/lightbox.js +14 -6
  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 +5 -6
  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 +14 -6
  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 +14 -6
  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 +4 -4
  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 +54 -62
  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 +64 -64
  43. package/dist/js/uikit.min.js +1 -1
  44. package/package.json +1 -1
  45. package/src/js/api/component.js +2 -2
  46. package/src/js/api/hooks.js +1 -1
  47. package/src/js/api/observables.js +59 -6
  48. package/src/js/core/offcanvas.js +6 -2
  49. package/src/js/core/switcher.js +8 -8
  50. package/src/js/mixin/slider-autoplay.js +10 -2
  51. package/src/js/mixin/swipe.js +0 -74
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.16.4",
5
+ "version": "3.16.5-dev.2fd0fea3e",
6
6
  "main": "dist/js/uikit.js",
7
7
  "style": "dist/css/uikit.css",
8
8
  "sideEffects": [
@@ -35,11 +35,11 @@ export function component(name, options) {
35
35
  return (components[id] = opt);
36
36
  }
37
37
 
38
- export function createComponent(name, element, data) {
38
+ export function createComponent(name, element, data, ...args) {
39
39
  const Component = component(name);
40
40
 
41
41
  return Component.options.functional
42
- ? new Component({ data: isPlainObject(element) ? element : [...arguments] })
42
+ ? new Component({ data: isPlainObject(element) ? element : [element, data, ...args] })
43
43
  : element
44
44
  ? $$(element).map(init)[0]
45
45
  : init();
@@ -5,7 +5,7 @@ import { initProps, initPropsObserver } from './props';
5
5
  import { disconnectObservers, initObservers } from './observer';
6
6
 
7
7
  export function callHook(instance, hook) {
8
- DEBUG && log(instance, hook);
8
+ LOG && log(instance, hook);
9
9
  instance.$options[hook]?.forEach((handler) => handler.call(instance));
10
10
  }
11
11
 
@@ -1,12 +1,21 @@
1
1
  import {
2
2
  $$,
3
+ getEventPos,
3
4
  isFunction,
5
+ isTouch,
6
+ noop,
4
7
  observeIntersection,
5
8
  observeMutation,
6
9
  observeResize,
7
10
  on,
11
+ once,
12
+ parent,
13
+ pointerCancel,
14
+ pointerDown,
15
+ pointerUp,
8
16
  removeAttr,
9
17
  toNodes,
18
+ trigger,
10
19
  } from '../util';
11
20
 
12
21
  export function resize(options) {
@@ -44,13 +53,11 @@ export function lazyload(options = {}) {
44
53
  export function scroll(options) {
45
54
  return observe(
46
55
  function (target, handler) {
47
- const off = on(target, 'scroll', handler, {
48
- passive: true,
49
- capture: true,
50
- });
51
-
52
56
  return {
53
- disconnect: off,
57
+ disconnect: on(target, 'scroll', handler, {
58
+ passive: true,
59
+ capture: true,
60
+ }),
54
61
  };
55
62
  },
56
63
  {
@@ -61,6 +68,42 @@ export function scroll(options) {
61
68
  );
62
69
  }
63
70
 
71
+ export function swipe(options) {
72
+ return {
73
+ observe(target, handler) {
74
+ return {
75
+ observe: noop,
76
+ unobserve: noop,
77
+ disconnect: on(target, pointerDown, handler, { passive: true }),
78
+ };
79
+ },
80
+ handler(e) {
81
+ if (!isTouch(e)) {
82
+ return;
83
+ }
84
+
85
+ // Handle Swipe Gesture
86
+ const pos = getEventPos(e);
87
+ const target = 'tagName' in e.target ? e.target : parent(e.target);
88
+ once(document, `${pointerUp} ${pointerCancel} scroll`, (e) => {
89
+ const { x, y } = getEventPos(e);
90
+
91
+ // swipe
92
+ if (
93
+ (e.type !== 'scroll' && target && x && Math.abs(pos.x - x) > 100) ||
94
+ (y && Math.abs(pos.y - y) > 100)
95
+ ) {
96
+ setTimeout(() => {
97
+ trigger(target, 'swipe');
98
+ trigger(target, `swipe${swipeDirection(pos.x, pos.y, x, y)}`);
99
+ });
100
+ }
101
+ });
102
+ },
103
+ ...options,
104
+ };
105
+ }
106
+
64
107
  function observe(observe, options, emit) {
65
108
  return {
66
109
  observe,
@@ -70,3 +113,13 @@ function observe(observe, options, emit) {
70
113
  ...options,
71
114
  };
72
115
  }
116
+
117
+ function swipeDirection(x1, y1, x2, y2) {
118
+ return Math.abs(x1 - x2) >= Math.abs(y1 - y2)
119
+ ? x1 - x2 > 0
120
+ ? 'Left'
121
+ : 'Right'
122
+ : y1 - y2 > 0
123
+ ? 'Up'
124
+ : 'Down';
125
+ }
@@ -1,5 +1,5 @@
1
1
  import Modal from '../mixin/modal';
2
- import Swipe from '../mixin/swipe';
2
+ import { swipe } from '../api/observables';
3
3
  import {
4
4
  $,
5
5
  addClass,
@@ -16,7 +16,7 @@ import {
16
16
  } from 'uikit-util';
17
17
 
18
18
  export default {
19
- mixins: [Modal, Swipe],
19
+ mixins: [Modal],
20
20
 
21
21
  args: 'mode',
22
22
 
@@ -24,6 +24,7 @@ export default {
24
24
  mode: String,
25
25
  flip: Boolean,
26
26
  overlay: Boolean,
27
+ swiping: Boolean,
27
28
  },
28
29
 
29
30
  data: {
@@ -40,6 +41,7 @@ export default {
40
41
  clsOverlay: 'uk-offcanvas-overlay',
41
42
  selClose: '.uk-offcanvas-close',
42
43
  container: false,
44
+ swiping: true,
43
45
  },
44
46
 
45
47
  computed: {
@@ -68,6 +70,8 @@ export default {
68
70
  },
69
71
  },
70
72
 
73
+ observe: swipe({ filter: ({ swiping }) => swiping }),
74
+
71
75
  update: {
72
76
  read() {
73
77
  if (this.isToggled() && !isVisible(this.$el)) {
@@ -1,8 +1,7 @@
1
- import Swipe from '../mixin/swipe';
2
1
  import Togglable from '../mixin/togglable';
3
2
  import { keyMap } from '../util/keys';
4
3
  import { generateId } from '../api/instance';
5
- import { lazyload } from '../api/observables';
4
+ import { lazyload, swipe } from '../api/observables';
6
5
  import {
7
6
  $$,
8
7
  attr,
@@ -26,7 +25,7 @@ import {
26
25
  const selDisabled = '.uk-disabled *, .uk-disabled, [disabled]';
27
26
 
28
27
  export default {
29
- mixins: [Swipe, Togglable],
28
+ mixins: [Togglable],
30
29
 
31
30
  args: 'connect',
32
31
 
@@ -36,6 +35,7 @@ export default {
36
35
  itemNav: String,
37
36
  active: Number,
38
37
  followFocus: Boolean,
38
+ swiping: Boolean,
39
39
  },
40
40
 
41
41
  data: {
@@ -47,6 +47,7 @@ export default {
47
47
  attrItem: 'uk-switcher-item',
48
48
  selVertical: '.uk-nav',
49
49
  followFocus: false,
50
+ swiping: true,
50
51
  },
51
52
 
52
53
  computed: {
@@ -101,17 +102,16 @@ export default {
101
102
  this.toggles.some((toggle) => within(toggle, child))
102
103
  );
103
104
  },
104
-
105
- swipeTarget() {
106
- return this.connects;
107
- },
108
105
  },
109
106
 
110
107
  connected() {
111
108
  attr(this.$el, 'role', 'tablist');
112
109
  },
113
110
 
114
- observe: lazyload({ targets: ({ connectChildren }) => connectChildren }),
111
+ observe: [
112
+ lazyload({ targets: ({ connectChildren }) => connectChildren }),
113
+ swipe({ target: ({ connects }) => connects, filter: ({ swiping }) => swiping }),
114
+ ],
115
115
 
116
116
  events: [
117
117
  {
@@ -53,7 +53,11 @@ export default {
53
53
  return this.autoplay;
54
54
  },
55
55
 
56
- handler: 'stopAutoplay',
56
+ handler(e) {
57
+ if (e.type !== pointerEnter || this.pauseOnHover) {
58
+ this.stopAutoplay();
59
+ }
60
+ },
57
61
  },
58
62
  {
59
63
  name: `${pointerLeave} focusout`,
@@ -62,7 +66,11 @@ export default {
62
66
  return this.autoplay;
63
67
  },
64
68
 
65
- handler: 'startAutoplay',
69
+ handler(e) {
70
+ if (e.type !== pointerLeave || this.pauseOnHover) {
71
+ this.startAutoplay();
72
+ }
73
+ },
66
74
  },
67
75
  ],
68
76
 
@@ -1,74 +0,0 @@
1
- import {
2
- getEventPos,
3
- isTouch,
4
- once,
5
- parent,
6
- pointerCancel,
7
- pointerDown,
8
- pointerUp,
9
- trigger,
10
- } from 'uikit-util';
11
-
12
- // TODO
13
- import { registerEvent } from '../api/events';
14
-
15
- export default {
16
- props: {
17
- swiping: Boolean,
18
- },
19
-
20
- data: {
21
- swiping: true,
22
- },
23
-
24
- computed: {
25
- swipeTarget(props, $el) {
26
- return $el;
27
- },
28
- },
29
-
30
- connected() {
31
- if (!this.swiping) {
32
- return;
33
- }
34
-
35
- registerEvent(this, {
36
- el: this.swipeTarget,
37
- name: pointerDown,
38
- passive: true,
39
- handler(e) {
40
- if (!isTouch(e)) {
41
- return;
42
- }
43
-
44
- // Handle Swipe Gesture
45
- const pos = getEventPos(e);
46
- const target = 'tagName' in e.target ? e.target : parent(e.target);
47
- once(document, `${pointerUp} ${pointerCancel} scroll`, (e) => {
48
- const { x, y } = getEventPos(e);
49
-
50
- // swipe
51
- if (
52
- (e.type !== 'scroll' && target && x && Math.abs(pos.x - x) > 100) ||
53
- (y && Math.abs(pos.y - y) > 100)
54
- ) {
55
- setTimeout(() => {
56
- trigger(target, 'swipe');
57
- trigger(target, `swipe${swipeDirection(pos.x, pos.y, x, y)}`);
58
- });
59
- }
60
- });
61
- },
62
- });
63
- },
64
- };
65
-
66
- function swipeDirection(x1, y1, x2, y2) {
67
- return Math.abs(x1 - x2) >= Math.abs(y1 - y2)
68
- ? x1 - x2 > 0
69
- ? 'Left'
70
- : 'Right'
71
- : y1 - y2 > 0
72
- ? 'Up'
73
- : 'Down';
74
- }