uikit 3.11.2-dev.31cd2ba38 → 3.11.2-dev.4274bc35b

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 (221) hide show
  1. package/.eslintrc.json +4 -49
  2. package/.prettierignore +14 -0
  3. package/.prettierrc.json +13 -0
  4. package/.webstorm.js +3 -3
  5. package/CHANGELOG.md +38 -28
  6. package/build/.eslintrc.json +1 -3
  7. package/build/build.js +26 -28
  8. package/build/icons.js +7 -11
  9. package/build/less.js +48 -36
  10. package/build/package.json +2 -2
  11. package/build/prefix.js +21 -18
  12. package/build/publishDev.js +6 -8
  13. package/build/release.js +20 -17
  14. package/build/scope.js +21 -11
  15. package/build/scss.js +72 -39
  16. package/build/util.js +71 -62
  17. package/build/wrapper/icons.js +0 -2
  18. package/dist/css/uikit-core-rtl.css +121 -202
  19. package/dist/css/uikit-core-rtl.min.css +1 -1
  20. package/dist/css/uikit-core.css +121 -202
  21. package/dist/css/uikit-core.min.css +1 -1
  22. package/dist/css/uikit-rtl.css +123 -208
  23. package/dist/css/uikit-rtl.min.css +1 -1
  24. package/dist/css/uikit.css +123 -208
  25. package/dist/css/uikit.min.css +1 -1
  26. package/dist/js/components/countdown.js +88 -133
  27. package/dist/js/components/countdown.min.js +1 -1
  28. package/dist/js/components/filter.js +408 -439
  29. package/dist/js/components/filter.min.js +1 -1
  30. package/dist/js/components/lightbox-panel.js +1098 -1316
  31. package/dist/js/components/lightbox-panel.min.js +1 -1
  32. package/dist/js/components/lightbox.js +1144 -1393
  33. package/dist/js/components/lightbox.min.js +1 -1
  34. package/dist/js/components/notification.js +94 -114
  35. package/dist/js/components/notification.min.js +1 -1
  36. package/dist/js/components/parallax.js +326 -358
  37. package/dist/js/components/parallax.min.js +1 -1
  38. package/dist/js/components/slider-parallax.js +324 -357
  39. package/dist/js/components/slider-parallax.min.js +1 -1
  40. package/dist/js/components/slider.js +768 -843
  41. package/dist/js/components/slider.min.js +1 -1
  42. package/dist/js/components/slideshow-parallax.js +324 -357
  43. package/dist/js/components/slideshow-parallax.min.js +1 -1
  44. package/dist/js/components/slideshow.js +645 -793
  45. package/dist/js/components/slideshow.min.js +1 -1
  46. package/dist/js/components/sortable.js +587 -620
  47. package/dist/js/components/sortable.min.js +1 -1
  48. package/dist/js/components/tooltip.js +324 -356
  49. package/dist/js/components/tooltip.min.js +1 -1
  50. package/dist/js/components/upload.js +155 -167
  51. package/dist/js/components/upload.min.js +1 -1
  52. package/dist/js/uikit-core.js +5405 -6716
  53. package/dist/js/uikit-core.min.js +1 -1
  54. package/dist/js/uikit-icons.js +7 -9
  55. package/dist/js/uikit-icons.min.js +1 -1
  56. package/dist/js/uikit.js +7997 -9703
  57. package/dist/js/uikit.min.js +1 -1
  58. package/jsconfig.json +1 -1
  59. package/package.json +64 -60
  60. package/src/js/api/boot.js +25 -32
  61. package/src/js/api/component.js +15 -28
  62. package/src/js/api/global.js +6 -12
  63. package/src/js/api/hooks.js +14 -33
  64. package/src/js/api/instance.js +7 -15
  65. package/src/js/api/state.js +79 -100
  66. package/src/js/components/countdown.js +24 -50
  67. package/src/js/components/filter.js +70 -66
  68. package/src/js/components/index.js +13 -13
  69. package/src/js/components/internal/lightbox-animations.js +14 -25
  70. package/src/js/components/internal/slider-preload.js +37 -0
  71. package/src/js/components/internal/slider-transitioner.js +66 -45
  72. package/src/js/components/internal/slideshow-animations.js +46 -64
  73. package/src/js/components/lightbox-panel.js +107 -105
  74. package/src/js/components/lightbox.js +17 -39
  75. package/src/js/components/notification.js +49 -43
  76. package/src/js/components/parallax.js +16 -30
  77. package/src/js/components/slider-parallax.js +13 -23
  78. package/src/js/components/slider.js +95 -64
  79. package/src/js/components/slideshow-parallax.js +1 -1
  80. package/src/js/components/slideshow.js +15 -13
  81. package/src/js/components/sortable.js +125 -106
  82. package/src/js/components/tooltip.js +41 -31
  83. package/src/js/components/upload.js +52 -63
  84. package/src/js/core/accordion.js +53 -48
  85. package/src/js/core/alert.js +9 -17
  86. package/src/js/core/core.js +74 -53
  87. package/src/js/core/cover.js +11 -15
  88. package/src/js/core/drop.js +106 -92
  89. package/src/js/core/form-custom.js +20 -25
  90. package/src/js/core/gif.js +3 -7
  91. package/src/js/core/grid.js +57 -58
  92. package/src/js/core/height-match.js +16 -29
  93. package/src/js/core/height-viewport.js +28 -35
  94. package/src/js/core/icon.js +38 -50
  95. package/src/js/core/img.js +127 -87
  96. package/src/js/core/index.js +39 -39
  97. package/src/js/core/leader.js +9 -18
  98. package/src/js/core/margin.js +21 -37
  99. package/src/js/core/modal.js +49 -36
  100. package/src/js/core/nav.js +2 -4
  101. package/src/js/core/navbar.js +112 -88
  102. package/src/js/core/offcanvas.js +49 -53
  103. package/src/js/core/overflow-auto.js +13 -17
  104. package/src/js/core/responsive.js +14 -12
  105. package/src/js/core/scroll.js +10 -20
  106. package/src/js/core/scrollspy-nav.js +34 -31
  107. package/src/js/core/scrollspy.js +37 -54
  108. package/src/js/core/sticky.js +130 -91
  109. package/src/js/core/svg.js +68 -83
  110. package/src/js/core/switcher.js +47 -46
  111. package/src/js/core/tab.js +7 -10
  112. package/src/js/core/toggle.js +66 -67
  113. package/src/js/core/video.js +11 -22
  114. package/src/js/mixin/animate.js +19 -20
  115. package/src/js/mixin/class.js +2 -4
  116. package/src/js/mixin/container.js +7 -11
  117. package/src/js/mixin/internal/animate-fade.js +73 -30
  118. package/src/js/mixin/internal/animate-slide.js +58 -41
  119. package/src/js/mixin/internal/slideshow-animations.js +7 -14
  120. package/src/js/mixin/internal/slideshow-transitioner.js +10 -17
  121. package/src/js/mixin/media.js +5 -10
  122. package/src/js/mixin/modal.js +89 -66
  123. package/src/js/mixin/parallax.js +130 -106
  124. package/src/js/mixin/position.js +26 -20
  125. package/src/js/mixin/slider-autoplay.js +12 -21
  126. package/src/js/mixin/slider-drag.js +64 -65
  127. package/src/js/mixin/slider-nav.js +26 -35
  128. package/src/js/mixin/slider-reactive.js +2 -8
  129. package/src/js/mixin/slider.js +48 -55
  130. package/src/js/mixin/slideshow.js +13 -19
  131. package/src/js/mixin/togglable.js +89 -63
  132. package/src/js/uikit-core.js +2 -4
  133. package/src/js/uikit.js +2 -4
  134. package/src/js/util/ajax.js +20 -39
  135. package/src/js/util/animation.js +77 -75
  136. package/src/js/util/attr.js +17 -21
  137. package/src/js/util/class.js +14 -52
  138. package/src/js/util/dimensions.js +56 -43
  139. package/src/js/util/dom.js +44 -80
  140. package/src/js/util/env.js +7 -12
  141. package/src/js/util/event.js +60 -59
  142. package/src/js/util/fastdom.js +1 -6
  143. package/src/js/util/filter.js +17 -34
  144. package/src/js/util/index.js +0 -1
  145. package/src/js/util/lang.js +82 -121
  146. package/src/js/util/mouse.js +19 -17
  147. package/src/js/util/options.js +33 -47
  148. package/src/js/util/player.js +41 -36
  149. package/src/js/util/position.js +54 -46
  150. package/src/js/util/selector.js +43 -58
  151. package/src/js/util/style.js +39 -49
  152. package/src/js/util/viewport.js +75 -64
  153. package/src/less/components/base.less +10 -33
  154. package/src/less/components/flex.less +0 -9
  155. package/src/less/components/form-range.less +52 -97
  156. package/src/less/components/form.less +0 -1
  157. package/src/less/components/leader.less +0 -1
  158. package/src/less/components/lightbox.less +0 -1
  159. package/src/less/components/modal.less +3 -7
  160. package/src/less/components/navbar.less +0 -7
  161. package/src/less/components/progress.less +14 -36
  162. package/src/less/components/slider.less +0 -3
  163. package/src/less/components/slideshow.less +0 -3
  164. package/src/less/components/text.less +16 -32
  165. package/src/less/components/utility.less +22 -0
  166. package/src/scss/components/base.scss +10 -33
  167. package/src/scss/components/flex.scss +0 -9
  168. package/src/scss/components/form-range.scss +52 -97
  169. package/src/scss/components/form.scss +3 -4
  170. package/src/scss/components/icon.scss +2 -2
  171. package/src/scss/components/leader.scss +0 -1
  172. package/src/scss/components/lightbox.scss +0 -1
  173. package/src/scss/components/modal.scss +3 -7
  174. package/src/scss/components/navbar.scss +0 -7
  175. package/src/scss/components/progress.scss +14 -36
  176. package/src/scss/components/search.scss +1 -1
  177. package/src/scss/components/slider.scss +0 -3
  178. package/src/scss/components/slideshow.scss +0 -3
  179. package/src/scss/components/text.scss +16 -32
  180. package/src/scss/components/utility.scss +22 -0
  181. package/src/scss/mixins-theme.scss +1 -1
  182. package/src/scss/mixins.scss +1 -1
  183. package/src/scss/variables-theme.scss +9 -9
  184. package/src/scss/variables.scss +9 -9
  185. package/tests/align.html +10 -10
  186. package/tests/animation.html +2 -2
  187. package/tests/article.html +2 -2
  188. package/tests/base.html +3 -3
  189. package/tests/card.html +10 -10
  190. package/tests/column.html +3 -3
  191. package/tests/comment.html +9 -9
  192. package/tests/dotnav.html +3 -3
  193. package/tests/image.html +296 -48
  194. package/tests/images/image-type.avif +0 -0
  195. package/tests/images/image-type.jpeg +0 -0
  196. package/tests/images/image-type.webp +0 -0
  197. package/tests/index.html +8 -8
  198. package/tests/js/index.js +114 -85
  199. package/tests/lightbox.html +10 -10
  200. package/tests/marker.html +2 -2
  201. package/tests/modal.html +8 -9
  202. package/tests/navbar.html +2 -2
  203. package/tests/overlay.html +7 -7
  204. package/tests/parallax.html +14 -5
  205. package/tests/position.html +12 -12
  206. package/tests/slidenav.html +12 -12
  207. package/tests/slider.html +20 -20
  208. package/tests/sortable.html +1 -1
  209. package/tests/sticky-parallax.html +47 -62
  210. package/tests/svg.html +6 -6
  211. package/tests/table.html +11 -11
  212. package/tests/thumbnav.html +12 -12
  213. package/tests/transition.html +30 -30
  214. package/tests/utility.html +33 -33
  215. package/tests/video.html +1 -1
  216. package/tests/width.html +1 -1
  217. package/src/js/mixin/flex-bug.js +0 -56
  218. package/src/js/util/promise.js +0 -191
  219. package/tests/images/animated.gif +0 -0
  220. package/tests/images/test.avif +0 -0
  221. package/tests/images/test.webp +0 -0
@@ -1,8 +1,20 @@
1
1
  import Modal from '../mixin/modal';
2
- import {$, addClass, append, css, endsWith, hasClass, height, isVisible, parent, removeClass, unwrap, wrapAll} from 'uikit-util';
2
+ import {
3
+ $,
4
+ addClass,
5
+ append,
6
+ css,
7
+ endsWith,
8
+ hasClass,
9
+ height,
10
+ isVisible,
11
+ parent,
12
+ removeClass,
13
+ unwrap,
14
+ wrapAll,
15
+ } from 'uikit-util';
3
16
 
4
17
  export default {
5
-
6
18
  mixins: [Modal],
7
19
 
8
20
  args: 'mode',
@@ -10,7 +22,7 @@ export default {
10
22
  props: {
11
23
  mode: String,
12
24
  flip: Boolean,
13
- overlay: Boolean
25
+ overlay: Boolean,
14
26
  },
15
27
 
16
28
  data: {
@@ -26,65 +38,58 @@ export default {
26
38
  clsMode: 'uk-offcanvas',
27
39
  clsOverlay: 'uk-offcanvas-overlay',
28
40
  selClose: '.uk-offcanvas-close',
29
- container: false
41
+ container: false,
30
42
  },
31
43
 
32
44
  computed: {
33
-
34
- clsFlip({flip, clsFlip}) {
45
+ clsFlip({ flip, clsFlip }) {
35
46
  return flip ? clsFlip : '';
36
47
  },
37
48
 
38
- clsOverlay({overlay, clsOverlay}) {
49
+ clsOverlay({ overlay, clsOverlay }) {
39
50
  return overlay ? clsOverlay : '';
40
51
  },
41
52
 
42
- clsMode({mode, clsMode}) {
53
+ clsMode({ mode, clsMode }) {
43
54
  return `${clsMode}-${mode}`;
44
55
  },
45
56
 
46
- clsSidebarAnimation({mode, clsSidebarAnimation}) {
57
+ clsSidebarAnimation({ mode, clsSidebarAnimation }) {
47
58
  return mode === 'none' || mode === 'reveal' ? '' : clsSidebarAnimation;
48
59
  },
49
60
 
50
- clsContainerAnimation({mode, clsContainerAnimation}) {
61
+ clsContainerAnimation({ mode, clsContainerAnimation }) {
51
62
  return mode !== 'push' && mode !== 'reveal' ? '' : clsContainerAnimation;
52
63
  },
53
64
 
54
- transitionElement({mode}) {
65
+ transitionElement({ mode }) {
55
66
  return mode === 'reveal' ? parent(this.panel) : this.panel;
56
- }
57
-
67
+ },
58
68
  },
59
69
 
60
70
  update: {
61
-
62
71
  read() {
63
72
  if (this.isToggled() && !isVisible(this.$el)) {
64
73
  this.hide();
65
74
  }
66
75
  },
67
76
 
68
- events: ['resize']
69
-
77
+ events: ['resize'],
70
78
  },
71
79
 
72
80
  events: [
73
-
74
81
  {
75
-
76
82
  name: 'click',
77
83
 
78
84
  delegate() {
79
85
  return 'a[href^="#"]';
80
86
  },
81
87
 
82
- handler({current: {hash}, defaultPrevented}) {
88
+ handler({ current: { hash }, defaultPrevented }) {
83
89
  if (!defaultPrevented && hash && $(hash, document.body)) {
84
90
  this.hide();
85
91
  }
86
- }
87
-
92
+ },
88
93
  },
89
94
 
90
95
  {
@@ -96,14 +101,11 @@ export default {
96
101
  return this.panel;
97
102
  },
98
103
 
99
- handler({targetTouches}) {
100
-
104
+ handler({ targetTouches }) {
101
105
  if (targetTouches.length === 1) {
102
106
  this.clientY = targetTouches[0].clientY;
103
107
  }
104
-
105
- }
106
-
108
+ },
107
109
  },
108
110
 
109
111
  {
@@ -118,8 +120,7 @@ export default {
118
120
 
119
121
  handler(e) {
120
122
  e.cancelable && e.preventDefault();
121
- }
122
-
123
+ },
123
124
  },
124
125
 
125
126
  {
@@ -132,23 +133,21 @@ export default {
132
133
  },
133
134
 
134
135
  handler(e) {
135
-
136
136
  if (e.targetTouches.length !== 1) {
137
137
  return;
138
138
  }
139
139
 
140
140
  const clientY = e.targetTouches[0].clientY - this.clientY;
141
- const {scrollTop, scrollHeight, clientHeight} = this.panel;
141
+ const { scrollTop, scrollHeight, clientHeight } = this.panel;
142
142
 
143
- if (clientHeight >= scrollHeight
144
- || scrollTop === 0 && clientY > 0
145
- || scrollHeight - scrollTop <= clientHeight && clientY < 0
143
+ if (
144
+ clientHeight >= scrollHeight ||
145
+ (scrollTop === 0 && clientY > 0) ||
146
+ (scrollHeight - scrollTop <= clientHeight && clientY < 0)
146
147
  ) {
147
148
  e.cancelable && e.preventDefault();
148
149
  }
149
-
150
- }
151
-
150
+ },
152
151
  },
153
152
 
154
153
  {
@@ -157,7 +156,6 @@ export default {
157
156
  self: true,
158
157
 
159
158
  handler() {
160
-
161
159
  if (this.mode === 'reveal' && !hasClass(parent(this.panel), this.clsMode)) {
162
160
  wrapAll(this.panel, '<div>');
163
161
  addClass(parent(this.panel), this.clsMode);
@@ -168,15 +166,17 @@ export default {
168
166
  css(document.body, 'touch-action', 'pan-y pinch-zoom');
169
167
  css(this.$el, 'display', 'block');
170
168
  addClass(this.$el, this.clsOverlay);
171
- addClass(this.panel, this.clsSidebarAnimation, this.mode !== 'reveal' ? this.clsMode : '');
169
+ addClass(
170
+ this.panel,
171
+ this.clsSidebarAnimation,
172
+ this.mode !== 'reveal' ? this.clsMode : ''
173
+ );
172
174
 
173
175
  height(document.body); // force reflow
174
176
  addClass(document.body, this.clsContainerAnimation);
175
177
 
176
178
  this.clsContainerAnimation && suppressUserScale();
177
-
178
-
179
- }
179
+ },
180
180
  },
181
181
 
182
182
  {
@@ -187,7 +187,7 @@ export default {
187
187
  handler() {
188
188
  removeClass(document.body, this.clsContainerAnimation);
189
189
  css(document.body, 'touch-action', '');
190
- }
190
+ },
191
191
  },
192
192
 
193
193
  {
@@ -196,7 +196,6 @@ export default {
196
196
  self: true,
197
197
 
198
198
  handler() {
199
-
200
199
  this.clsContainerAnimation && resumeUserScale();
201
200
 
202
201
  if (this.mode === 'reveal') {
@@ -209,24 +208,19 @@ export default {
209
208
  removeClass(document.body, this.clsContainer, this.clsFlip);
210
209
 
211
210
  css(document.documentElement, 'overflowY', '');
212
-
213
- }
211
+ },
214
212
  },
215
213
 
216
214
  {
217
215
  name: 'swipeLeft swipeRight',
218
216
 
219
217
  handler(e) {
220
-
221
218
  if (this.isToggled() && endsWith(e.type, 'Left') ^ this.flip) {
222
219
  this.hide();
223
220
  }
224
-
225
- }
226
- }
227
-
228
- ]
229
-
221
+ },
222
+ },
223
+ ],
230
224
  };
231
225
 
232
226
  // Chrome in responsive mode zooms page upon opening offcanvas
@@ -240,5 +234,7 @@ function resumeUserScale() {
240
234
  }
241
235
 
242
236
  function getViewport() {
243
- return $('meta[name="viewport"]', document.head) || append(document.head, '<meta name="viewport">');
237
+ return (
238
+ $('meta[name="viewport"]', document.head) || append(document.head, '<meta name="viewport">')
239
+ );
244
240
  }
@@ -1,32 +1,29 @@
1
1
  import Class from '../mixin/class';
2
- import {closest, css, dimensions, height, isVisible, toFloat, trigger} from 'uikit-util';
2
+ import { closest, css, dimensions, height, isVisible, toFloat, trigger } from 'uikit-util';
3
3
 
4
4
  export default {
5
-
6
5
  mixins: [Class],
7
6
 
8
7
  props: {
9
8
  selContainer: String,
10
9
  selContent: String,
11
- minHeight: Number
10
+ minHeight: Number,
12
11
  },
13
12
 
14
13
  data: {
15
14
  selContainer: '.uk-modal',
16
15
  selContent: '.uk-modal-dialog',
17
- minHeight: 150
16
+ minHeight: 150,
18
17
  },
19
18
 
20
19
  computed: {
21
-
22
- container({selContainer}, $el) {
20
+ container({ selContainer }, $el) {
23
21
  return closest($el, selContainer);
24
22
  },
25
23
 
26
- content({selContent}, $el) {
24
+ content({ selContent }, $el) {
27
25
  return closest($el, selContent);
28
- }
29
-
26
+ },
30
27
  },
31
28
 
32
29
  connected() {
@@ -34,28 +31,27 @@ export default {
34
31
  },
35
32
 
36
33
  update: {
37
-
38
34
  read() {
39
-
40
35
  if (!this.content || !this.container || !isVisible(this.$el)) {
41
36
  return false;
42
37
  }
43
38
 
44
39
  return {
45
40
  current: toFloat(css(this.$el, 'maxHeight')),
46
- max: Math.max(this.minHeight, height(this.container) - (dimensions(this.content).height - height(this.$el)))
41
+ max: Math.max(
42
+ this.minHeight,
43
+ height(this.container) - (dimensions(this.content).height - height(this.$el))
44
+ ),
47
45
  };
48
46
  },
49
47
 
50
- write({current, max}) {
48
+ write({ current, max }) {
51
49
  css(this.$el, 'maxHeight', max);
52
50
  if (Math.round(current) !== Math.round(max)) {
53
51
  trigger(this.$el, 'resize');
54
52
  }
55
53
  },
56
54
 
57
- events: ['resize']
58
-
59
- }
60
-
55
+ events: ['resize'],
56
+ },
61
57
  };
@@ -1,7 +1,6 @@
1
- import {addClass, Dimensions, height, isVisible, parent, width} from 'uikit-util';
1
+ import { addClass, Dimensions, height, isVisible, parent, width } from 'uikit-util';
2
2
 
3
3
  export default {
4
-
5
4
  props: ['width', 'height'],
6
5
 
7
6
  connected() {
@@ -9,22 +8,25 @@ export default {
9
8
  },
10
9
 
11
10
  update: {
12
-
13
11
  read() {
14
12
  return isVisible(this.$el) && this.width && this.height
15
- ? {width: width(parent(this.$el)), height: this.height}
13
+ ? { width: width(parent(this.$el)), height: this.height }
16
14
  : false;
17
15
  },
18
16
 
19
17
  write(dim) {
20
- height(this.$el, Dimensions.contain({
21
- height: this.height,
22
- width: this.width
23
- }, dim).height);
18
+ height(
19
+ this.$el,
20
+ Dimensions.contain(
21
+ {
22
+ height: this.height,
23
+ width: this.width,
24
+ },
25
+ dim
26
+ ).height
27
+ );
24
28
  },
25
29
 
26
- events: ['resize']
27
-
28
- }
29
-
30
+ events: ['resize'],
31
+ },
30
32
  };
@@ -1,43 +1,33 @@
1
- import {$, escape, scrollIntoView, trigger} from 'uikit-util';
1
+ import { $, escape, scrollIntoView, trigger } from 'uikit-util';
2
2
 
3
3
  export default {
4
-
5
4
  props: {
6
- offset: Number
5
+ offset: Number,
7
6
  },
8
7
 
9
8
  data: {
10
- offset: 0
9
+ offset: 0,
11
10
  },
12
11
 
13
12
  methods: {
14
-
15
- scrollTo(el) {
16
-
17
- el = el && $(el) || document.body;
13
+ async scrollTo(el) {
14
+ el = (el && $(el)) || document.body;
18
15
 
19
16
  if (trigger(this.$el, 'beforescroll', [this, el])) {
20
- scrollIntoView(el, {offset: this.offset}).then(() =>
21
- trigger(this.$el, 'scrolled', [this, el])
22
- );
17
+ await scrollIntoView(el, { offset: this.offset });
18
+ trigger(this.$el, 'scrolled', [this, el]);
23
19
  }
24
-
25
- }
26
-
20
+ },
27
21
  },
28
22
 
29
23
  events: {
30
-
31
24
  click(e) {
32
-
33
25
  if (e.defaultPrevented) {
34
26
  return;
35
27
  }
36
28
 
37
29
  e.preventDefault();
38
30
  this.scrollTo(`#${escape(decodeURIComponent((this.$el.hash || '').substr(1)))}`);
39
- }
40
-
41
- }
42
-
31
+ },
32
+ },
43
33
  };
@@ -1,13 +1,25 @@
1
- import {$$, addClass, closest, escape, getViewport, getViewportClientHeight, hasClass, isVisible, offset, removeClass, scrollParents, trigger} from 'uikit-util';
1
+ import {
2
+ $$,
3
+ addClass,
4
+ closest,
5
+ escape,
6
+ getViewport,
7
+ getViewportClientHeight,
8
+ hasClass,
9
+ isVisible,
10
+ offset,
11
+ removeClass,
12
+ scrollParents,
13
+ trigger,
14
+ } from 'uikit-util';
2
15
 
3
16
  export default {
4
-
5
17
  props: {
6
18
  cls: String,
7
19
  closest: String,
8
20
  scroll: Boolean,
9
21
  overflow: Boolean,
10
- offset: Number
22
+ offset: Number,
11
23
  },
12
24
 
13
25
  data: {
@@ -15,60 +27,55 @@ export default {
15
27
  closest: false,
16
28
  scroll: false,
17
29
  overflow: true,
18
- offset: 0
30
+ offset: 0,
19
31
  },
20
32
 
21
33
  computed: {
22
-
23
34
  links: {
24
-
25
35
  get(_, $el) {
26
- return $$('a[href^="#"]', $el).filter(el => el.hash);
36
+ return $$('a[href^="#"]', $el).filter((el) => el.hash);
27
37
  },
28
38
 
29
39
  watch(links) {
30
40
  if (this.scroll) {
31
- this.$create('scroll', links, {offset: this.offset || 0});
41
+ this.$create('scroll', links, { offset: this.offset || 0 });
32
42
  }
33
43
  },
34
44
 
35
- immediate: true
36
-
45
+ immediate: true,
37
46
  },
38
47
 
39
48
  targets() {
40
- return $$(this.links.map(el => escape(el.hash).substr(1)).join(','));
49
+ return $$(this.links.map((el) => escape(el.hash).substr(1)).join(','));
41
50
  },
42
51
 
43
- elements({closest: selector}) {
52
+ elements({ closest: selector }) {
44
53
  return closest(this.links, selector || '*');
45
- }
46
-
54
+ },
47
55
  },
48
56
 
49
57
  update: [
50
-
51
58
  {
52
-
53
59
  read() {
54
-
55
- const {length} = this.targets;
60
+ const { length } = this.targets;
56
61
 
57
62
  if (!length || !isVisible(this.$el)) {
58
63
  return false;
59
64
  }
60
65
 
61
66
  const [scrollElement] = scrollParents(this.targets, /auto|scroll/, true);
62
- const {scrollTop, scrollHeight} = scrollElement;
67
+ const { scrollTop, scrollHeight } = scrollElement;
63
68
  const max = scrollHeight - getViewportClientHeight(scrollElement);
64
69
  let active = false;
65
70
 
66
71
  if (scrollTop === max) {
67
72
  active = length - 1;
68
73
  } else {
69
-
70
74
  this.targets.every((el, i) => {
71
- if (offset(el).top - offset(getViewport(scrollElement)).top - this.offset <= 0) {
75
+ if (
76
+ offset(el).top - offset(getViewport(scrollElement)).top - this.offset <=
77
+ 0
78
+ ) {
72
79
  active = i;
73
80
  return true;
74
81
  }
@@ -79,14 +86,13 @@ export default {
79
86
  }
80
87
  }
81
88
 
82
- return {active};
89
+ return { active };
83
90
  },
84
91
 
85
- write({active}) {
86
-
92
+ write({ active }) {
87
93
  const changed = active !== false && !hasClass(this.elements[active], this.cls);
88
94
 
89
- this.links.forEach(el => el.blur());
95
+ this.links.forEach((el) => el.blur());
90
96
  removeClass(this.elements, this.cls);
91
97
  addClass(this.elements[active], this.cls);
92
98
 
@@ -95,10 +101,7 @@ export default {
95
101
  }
96
102
  },
97
103
 
98
- events: ['scroll', 'resize']
99
-
100
- }
101
-
102
- ]
103
-
104
+ events: ['scroll', 'resize'],
105
+ },
106
+ ],
104
107
  };