uikit 3.11.2-dev.9433cd5fd → 3.11.2-dev.a87448e52

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 +37 -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 +118 -201
  19. package/dist/css/uikit-core-rtl.min.css +1 -1
  20. package/dist/css/uikit-core.css +118 -201
  21. package/dist/css/uikit-core.min.css +1 -1
  22. package/dist/css/uikit-rtl.css +120 -207
  23. package/dist/css/uikit-rtl.min.css +1 -1
  24. package/dist/css/uikit.css +120 -207
  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 +345 -358
  37. package/dist/js/components/parallax.min.js +1 -1
  38. package/dist/js/components/slider-parallax.js +343 -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 +343 -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 +5412 -6733
  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 +8008 -9705
  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 +47 -52
  95. package/src/js/core/img.js +96 -77
  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 +149 -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 +32 -46
  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 +48 -95
  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 +48 -95
  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,11 +1,27 @@
1
- import {assign, camelize, data as getData, hasOwn, hyphenate, isArray, isEmpty, isFunction, isNumeric, isPlainObject, isString, isUndefined, mergeOptions, on, parseOptions, startsWith, toBoolean, toNumber} from 'uikit-util';
1
+ import {
2
+ assign,
3
+ camelize,
4
+ data as getData,
5
+ hasOwn,
6
+ hyphenate,
7
+ isArray,
8
+ isFunction,
9
+ isNumeric,
10
+ isPlainObject,
11
+ isString,
12
+ isUndefined,
13
+ mergeOptions,
14
+ on,
15
+ parseOptions,
16
+ startsWith,
17
+ toBoolean,
18
+ toNumber,
19
+ } from 'uikit-util';
2
20
 
3
21
  export default function (UIkit) {
4
-
5
22
  let uid = 0;
6
23
 
7
24
  UIkit.prototype._init = function (options) {
8
-
9
25
  options = options || {};
10
26
  options.data = normalizeData(options, this.constructor.options);
11
27
 
@@ -25,8 +41,7 @@ export default function (UIkit) {
25
41
  };
26
42
 
27
43
  UIkit.prototype._initData = function () {
28
-
29
- const {data = {}} = this.$options;
44
+ const { data = {} } = this.$options;
30
45
 
31
46
  for (const key in data) {
32
47
  this.$props[key] = this[key] = data[key];
@@ -34,8 +49,7 @@ export default function (UIkit) {
34
49
  };
35
50
 
36
51
  UIkit.prototype._initMethods = function () {
37
-
38
- const {methods} = this.$options;
52
+ const { methods } = this.$options;
39
53
 
40
54
  if (methods) {
41
55
  for (const key in methods) {
@@ -45,8 +59,7 @@ export default function (UIkit) {
45
59
  };
46
60
 
47
61
  UIkit.prototype._initComputeds = function () {
48
-
49
- const {computed} = this.$options;
62
+ const { computed } = this.$options;
50
63
 
51
64
  this._computeds = {};
52
65
 
@@ -58,7 +71,6 @@ export default function (UIkit) {
58
71
  };
59
72
 
60
73
  UIkit.prototype._initProps = function (props) {
61
-
62
74
  let key;
63
75
 
64
76
  props = props || getProps(this.$options, this.$name);
@@ -78,49 +90,34 @@ export default function (UIkit) {
78
90
  };
79
91
 
80
92
  UIkit.prototype._initEvents = function () {
81
-
82
93
  this._events = [];
83
-
84
- const {events} = this.$options;
85
-
86
- if (events) {
87
-
88
- events.forEach(event => {
89
-
90
- if (hasOwn(event, 'handler')) {
91
- registerEvent(this, event);
92
- } else {
93
- for (const key in event) {
94
- registerEvent(this, event[key], key);
95
- }
94
+ for (const event of this.$options.events || []) {
95
+ if (hasOwn(event, 'handler')) {
96
+ registerEvent(this, event);
97
+ } else {
98
+ for (const key in event) {
99
+ registerEvent(this, event[key], key);
96
100
  }
97
-
98
- });
101
+ }
99
102
  }
100
103
  };
101
104
 
102
105
  UIkit.prototype._unbindEvents = function () {
103
- this._events.forEach(unbind => unbind());
106
+ this._events.forEach((unbind) => unbind());
104
107
  delete this._events;
105
108
  };
106
109
 
107
110
  UIkit.prototype._initObservers = function () {
108
- this._observers = [
109
- initChildListObserver(this),
110
- initPropsObserver(this)
111
- ];
111
+ this._observers = [initChildListObserver(this), initPropsObserver(this)];
112
112
  };
113
113
 
114
114
  UIkit.prototype._disconnectObservers = function () {
115
- this._observers.forEach(observer =>
116
- observer && observer.disconnect()
117
- );
115
+ this._observers.forEach((observer) => observer?.disconnect());
118
116
  };
119
117
 
120
118
  function getProps(opts, name) {
121
-
122
119
  const data = {};
123
- const {args = [], props = {}, el} = opts;
120
+ const { args = [], props = {}, el } = opts;
124
121
 
125
122
  if (!props) {
126
123
  return data;
@@ -134,9 +131,7 @@ export default function (UIkit) {
134
131
  continue;
135
132
  }
136
133
 
137
- value = props[key] === Boolean && value === ''
138
- ? true
139
- : coerce(props[key], value);
134
+ value = props[key] === Boolean && value === '' ? true : coerce(props[key], value);
140
135
 
141
136
  if (prop === 'target' && (!value || startsWith(value, '_'))) {
142
137
  continue;
@@ -159,12 +154,10 @@ export default function (UIkit) {
159
154
 
160
155
  function registerComputed(component, key, cb) {
161
156
  Object.defineProperty(component, key, {
162
-
163
157
  enumerable: true,
164
158
 
165
159
  get() {
166
-
167
- const {_computeds, $props, $el} = component;
160
+ const { _computeds, $props, $el } = component;
168
161
 
169
162
  if (!hasOwn(_computeds, key)) {
170
163
  _computeds[key] = (cb.get || cb).call(component, $props, $el);
@@ -174,36 +167,31 @@ export default function (UIkit) {
174
167
  },
175
168
 
176
169
  set(value) {
177
-
178
- const {_computeds} = component;
170
+ const { _computeds } = component;
179
171
 
180
172
  _computeds[key] = cb.set ? cb.set.call(component, value) : value;
181
173
 
182
174
  if (isUndefined(_computeds[key])) {
183
175
  delete _computeds[key];
184
176
  }
185
- }
186
-
177
+ },
187
178
  });
188
179
  }
189
180
 
190
181
  function registerEvent(component, event, key) {
191
-
192
182
  if (!isPlainObject(event)) {
193
- event = ({name: key, handler: event});
183
+ event = { name: key, handler: event };
194
184
  }
195
185
 
196
- let {name, el, handler, capture, passive, delegate, filter, self} = event;
197
- el = isFunction(el)
198
- ? el.call(component)
199
- : el || component.$el;
186
+ let { name, el, handler, capture, passive, delegate, filter, self } = event;
187
+ el = isFunction(el) ? el.call(component) : el || component.$el;
200
188
 
201
189
  if (isArray(el)) {
202
- el.forEach(el => registerEvent(component, assign({}, event, {el}), key));
190
+ el.forEach((el) => registerEvent(component, { ...event, el }, key));
203
191
  return;
204
192
  }
205
193
 
206
- if (!el || filter && !filter.call(component)) {
194
+ if (!el || (filter && !filter.call(component))) {
207
195
  return;
208
196
  }
209
197
 
@@ -211,24 +199,18 @@ export default function (UIkit) {
211
199
  on(
212
200
  el,
213
201
  name,
214
- delegate
215
- ? isString(delegate)
216
- ? delegate
217
- : delegate.call(component)
218
- : null,
202
+ delegate ? (isString(delegate) ? delegate : delegate.call(component)) : null,
219
203
  isString(handler) ? component[handler] : handler.bind(component),
220
- {passive, capture, self}
204
+ { passive, capture, self }
221
205
  )
222
206
  );
223
-
224
207
  }
225
208
 
226
209
  function notIn(options, key) {
227
- return options.every(arr => !arr || !hasOwn(arr, key));
210
+ return options.every((arr) => !arr || !hasOwn(arr, key));
228
211
  }
229
212
 
230
213
  function coerce(type, value) {
231
-
232
214
  if (type === Boolean) {
233
215
  return toBoolean(value);
234
216
  } else if (type === Number) {
@@ -244,33 +226,29 @@ export default function (UIkit) {
244
226
  return isArray(value)
245
227
  ? value
246
228
  : isString(value)
247
- ? value.split(/,(?![^(]*\))/).map(value => isNumeric(value)
248
- ? toNumber(value)
249
- : toBoolean(value.trim()))
250
- : [value];
229
+ ? value
230
+ .split(/,(?![^(]*\))/)
231
+ .map((value) => (isNumeric(value) ? toNumber(value) : toBoolean(value.trim())))
232
+ : [value];
251
233
  }
252
234
 
253
- function normalizeData({data}, {args, props = {}}) {
254
- data = isArray(data)
255
- ? !isEmpty(args)
256
- ? data.slice(0, args.length).reduce((data, value, index) => {
257
- if (isPlainObject(value)) {
258
- assign(data, value);
259
- } else {
260
- data[args[index]] = value;
261
- }
262
- return data;
263
- }, {})
264
- : undefined
265
- : data;
266
-
267
- if (data) {
268
- for (const key in data) {
269
- if (isUndefined(data[key])) {
270
- delete data[key];
235
+ function normalizeData({ data = {} }, { args = [], props = {} }) {
236
+ if (isArray(data)) {
237
+ data = data.slice(0, args.length).reduce((data, value, index) => {
238
+ if (isPlainObject(value)) {
239
+ assign(data, value);
271
240
  } else {
272
- data[key] = props[key] ? coerce(props[key], data[key]) : data[key];
241
+ data[args[index]] = value;
273
242
  }
243
+ return data;
244
+ }, {});
245
+ }
246
+
247
+ for (const key in data) {
248
+ if (isUndefined(data[key])) {
249
+ delete data[key];
250
+ } else if (props[key]) {
251
+ data[key] = coerce(props[key], data[key]);
274
252
  }
275
253
  }
276
254
 
@@ -278,44 +256,45 @@ export default function (UIkit) {
278
256
  }
279
257
 
280
258
  function initChildListObserver(component) {
281
- const {el} = component.$options;
259
+ const { el } = component.$options;
282
260
 
283
261
  const observer = new MutationObserver(() => component.$emit());
284
262
  observer.observe(el, {
285
263
  childList: true,
286
- subtree: true
264
+ subtree: true,
287
265
  });
288
266
 
289
267
  return observer;
290
268
  }
291
269
 
292
270
  function initPropsObserver(component) {
293
-
294
- const {$name, $options, $props} = component;
295
- const {attrs, props, el} = $options;
271
+ const { $name, $options, $props } = component;
272
+ const { attrs, props, el } = $options;
296
273
 
297
274
  if (!props || attrs === false) {
298
275
  return;
299
276
  }
300
277
 
301
278
  const attributes = isArray(attrs) ? attrs : Object.keys(props);
302
- const filter = attributes.map(key => hyphenate(key)).concat($name);
279
+ const filter = attributes.map((key) => hyphenate(key)).concat($name);
303
280
 
304
- const observer = new MutationObserver(records => {
281
+ const observer = new MutationObserver((records) => {
305
282
  const data = getProps($options, $name);
306
- if (records.some(({attributeName}) => {
307
- const prop = attributeName.replace('data-', '');
308
- return (prop === $name ? attributes : [camelize(prop), camelize(attributeName)]).some(prop =>
309
- !isUndefined(data[prop]) && data[prop] !== $props[prop]
310
- );
311
- })) {
283
+ if (
284
+ records.some(({ attributeName }) => {
285
+ const prop = attributeName.replace('data-', '');
286
+ return (
287
+ prop === $name ? attributes : [camelize(prop), camelize(attributeName)]
288
+ ).some((prop) => !isUndefined(data[prop]) && data[prop] !== $props[prop]);
289
+ })
290
+ ) {
312
291
  component.$reset();
313
292
  }
314
293
  });
315
294
 
316
295
  observer.observe(el, {
317
296
  attributes: true,
318
- attributeFilter: filter.concat(filter.map(key => `data-${key}`))
297
+ attributeFilter: filter.concat(filter.map((key) => `data-${key}`)),
319
298
  });
320
299
 
321
300
  return observer;
@@ -1,46 +1,43 @@
1
1
  import Class from '../mixin/class';
2
- import {$, empty, html} from 'uikit-util';
2
+ import { $, empty, html } from 'uikit-util';
3
3
 
4
4
  export default {
5
-
6
5
  mixins: [Class],
7
6
 
8
7
  props: {
9
8
  date: String,
10
- clsWrapper: String
9
+ clsWrapper: String,
11
10
  },
12
11
 
13
12
  data: {
14
13
  date: '',
15
- clsWrapper: '.uk-countdown-%unit%'
14
+ clsWrapper: '.uk-countdown-%unit%',
16
15
  },
17
16
 
18
17
  computed: {
19
-
20
- date({date}) {
18
+ date({ date }) {
21
19
  return Date.parse(date);
22
20
  },
23
21
 
24
- days({clsWrapper}, $el) {
22
+ days({ clsWrapper }, $el) {
25
23
  return $(clsWrapper.replace('%unit%', 'days'), $el);
26
24
  },
27
25
 
28
- hours({clsWrapper}, $el) {
26
+ hours({ clsWrapper }, $el) {
29
27
  return $(clsWrapper.replace('%unit%', 'hours'), $el);
30
28
  },
31
29
 
32
- minutes({clsWrapper}, $el) {
30
+ minutes({ clsWrapper }, $el) {
33
31
  return $(clsWrapper.replace('%unit%', 'minutes'), $el);
34
32
  },
35
33
 
36
- seconds({clsWrapper}, $el) {
34
+ seconds({ clsWrapper }, $el) {
37
35
  return $(clsWrapper.replace('%unit%', 'seconds'), $el);
38
36
  },
39
37
 
40
38
  units() {
41
- return ['days', 'hours', 'minutes', 'seconds'].filter(unit => this[unit]);
42
- }
43
-
39
+ return ['days', 'hours', 'minutes', 'seconds'].filter((unit) => this[unit]);
40
+ },
44
41
  },
45
42
 
46
43
  connected() {
@@ -49,13 +46,11 @@ export default {
49
46
 
50
47
  disconnected() {
51
48
  this.stop();
52
- this.units.forEach(unit => empty(this[unit]));
49
+ this.units.forEach((unit) => empty(this[unit]));
53
50
  },
54
51
 
55
52
  events: [
56
-
57
53
  {
58
-
59
54
  name: 'visibilitychange',
60
55
 
61
56
  el() {
@@ -68,31 +63,21 @@ export default {
68
63
  } else {
69
64
  this.start();
70
65
  }
71
- }
72
-
73
- }
74
-
66
+ },
67
+ },
75
68
  ],
76
69
 
77
70
  update: {
78
-
79
71
  write() {
80
-
81
72
  const timespan = getTimeSpan(this.date);
82
73
 
83
74
  if (timespan.total <= 0) {
84
-
85
75
  this.stop();
86
76
 
87
- timespan.days
88
- = timespan.hours
89
- = timespan.minutes
90
- = timespan.seconds
91
- = 0;
77
+ timespan.days = timespan.hours = timespan.minutes = timespan.seconds = 0;
92
78
  }
93
79
 
94
- this.units.forEach(unit => {
95
-
80
+ for (const unit of this.units) {
96
81
  let digits = String(Math.floor(timespan[unit]));
97
82
 
98
83
  digits = digits.length < 2 ? `0${digits}` : digits;
@@ -105,50 +90,39 @@ export default {
105
90
  html(el, digits.map(() => '<span></span>').join(''));
106
91
  }
107
92
 
108
- digits.forEach((digit, i) => el.children[i].textContent = digit);
93
+ digits.forEach((digit, i) => (el.children[i].textContent = digit));
109
94
  }
110
-
111
- });
112
-
113
- }
114
-
95
+ }
96
+ },
115
97
  },
116
98
 
117
99
  methods: {
118
-
119
100
  start() {
120
-
121
101
  this.stop();
122
102
 
123
103
  if (this.date && this.units.length) {
124
104
  this.$update();
125
105
  this.timer = setInterval(this.$update, 1000);
126
106
  }
127
-
128
107
  },
129
108
 
130
109
  stop() {
131
-
132
110
  if (this.timer) {
133
111
  clearInterval(this.timer);
134
112
  this.timer = null;
135
113
  }
136
-
137
- }
138
-
139
- }
140
-
114
+ },
115
+ },
141
116
  };
142
117
 
143
118
  function getTimeSpan(date) {
144
-
145
119
  const total = date - Date.now();
146
120
 
147
121
  return {
148
122
  total,
149
- seconds: total / 1000 % 60,
150
- minutes: total / 1000 / 60 % 60,
151
- hours: total / 1000 / 60 / 60 % 24,
152
- days: total / 1000 / 60 / 60 / 24
123
+ seconds: (total / 1000) % 60,
124
+ minutes: (total / 1000 / 60) % 60,
125
+ hours: (total / 1000 / 60 / 60) % 24,
126
+ days: total / 1000 / 60 / 60 / 24,
153
127
  };
154
128
  }