uikit 3.11.2-dev.c08a5b5f0 → 3.11.2-dev.d8c101f07

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 (157) 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 +5 -15
  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 +1 -1
  19. package/dist/css/uikit-core-rtl.min.css +1 -1
  20. package/dist/css/uikit-core.css +1 -1
  21. package/dist/css/uikit-core.min.css +1 -1
  22. package/dist/css/uikit-rtl.css +1 -1
  23. package/dist/css/uikit-rtl.min.css +1 -1
  24. package/dist/css/uikit.css +1 -1
  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 +294 -345
  37. package/dist/js/components/parallax.min.js +1 -1
  38. package/dist/js/components/slider-parallax.js +292 -344
  39. package/dist/js/components/slider-parallax.min.js +1 -1
  40. package/dist/js/components/slider.js +722 -852
  41. package/dist/js/components/slider.min.js +1 -1
  42. package/dist/js/components/slideshow-parallax.js +292 -344
  43. package/dist/js/components/slideshow-parallax.min.js +1 -1
  44. package/dist/js/components/slideshow.js +609 -834
  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 +5244 -6600
  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 +8041 -9907
  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 +65 -82
  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-transitioner.js +66 -45
  71. package/src/js/components/internal/slideshow-animations.js +46 -64
  72. package/src/js/components/lightbox-panel.js +107 -105
  73. package/src/js/components/lightbox.js +17 -39
  74. package/src/js/components/notification.js +49 -43
  75. package/src/js/components/parallax.js +16 -30
  76. package/src/js/components/slider-parallax.js +13 -23
  77. package/src/js/components/slider.js +75 -64
  78. package/src/js/components/slideshow-parallax.js +1 -1
  79. package/src/js/components/slideshow.js +8 -44
  80. package/src/js/components/sortable.js +125 -106
  81. package/src/js/components/tooltip.js +41 -31
  82. package/src/js/components/upload.js +52 -63
  83. package/src/js/core/accordion.js +53 -48
  84. package/src/js/core/alert.js +9 -17
  85. package/src/js/core/core.js +74 -53
  86. package/src/js/core/cover.js +11 -15
  87. package/src/js/core/drop.js +106 -92
  88. package/src/js/core/form-custom.js +20 -25
  89. package/src/js/core/gif.js +3 -7
  90. package/src/js/core/grid.js +57 -58
  91. package/src/js/core/height-match.js +16 -29
  92. package/src/js/core/height-viewport.js +28 -35
  93. package/src/js/core/icon.js +38 -50
  94. package/src/js/core/img.js +133 -152
  95. package/src/js/core/index.js +39 -39
  96. package/src/js/core/leader.js +9 -18
  97. package/src/js/core/margin.js +21 -37
  98. package/src/js/core/modal.js +49 -36
  99. package/src/js/core/nav.js +2 -4
  100. package/src/js/core/navbar.js +112 -88
  101. package/src/js/core/offcanvas.js +49 -53
  102. package/src/js/core/overflow-auto.js +13 -17
  103. package/src/js/core/responsive.js +14 -12
  104. package/src/js/core/scroll.js +10 -20
  105. package/src/js/core/scrollspy-nav.js +34 -31
  106. package/src/js/core/scrollspy.js +37 -54
  107. package/src/js/core/sticky.js +130 -91
  108. package/src/js/core/svg.js +60 -79
  109. package/src/js/core/switcher.js +47 -46
  110. package/src/js/core/tab.js +7 -10
  111. package/src/js/core/toggle.js +64 -66
  112. package/src/js/core/video.js +11 -22
  113. package/src/js/mixin/animate.js +19 -20
  114. package/src/js/mixin/class.js +2 -4
  115. package/src/js/mixin/container.js +7 -11
  116. package/src/js/mixin/internal/animate-fade.js +73 -30
  117. package/src/js/mixin/internal/animate-slide.js +58 -41
  118. package/src/js/mixin/internal/slideshow-animations.js +7 -14
  119. package/src/js/mixin/internal/slideshow-transitioner.js +10 -17
  120. package/src/js/mixin/media.js +5 -10
  121. package/src/js/mixin/modal.js +89 -66
  122. package/src/js/mixin/parallax.js +53 -48
  123. package/src/js/mixin/position.js +26 -20
  124. package/src/js/mixin/slider-autoplay.js +12 -21
  125. package/src/js/mixin/slider-drag.js +64 -65
  126. package/src/js/mixin/slider-nav.js +26 -35
  127. package/src/js/mixin/slider-reactive.js +2 -8
  128. package/src/js/mixin/slider.js +48 -55
  129. package/src/js/mixin/slideshow.js +13 -19
  130. package/src/js/mixin/togglable.js +89 -63
  131. package/src/js/uikit-core.js +2 -4
  132. package/src/js/uikit.js +2 -4
  133. package/src/js/util/ajax.js +20 -39
  134. package/src/js/util/animation.js +77 -75
  135. package/src/js/util/attr.js +17 -21
  136. package/src/js/util/class.js +14 -52
  137. package/src/js/util/dimensions.js +56 -43
  138. package/src/js/util/dom.js +40 -73
  139. package/src/js/util/env.js +7 -12
  140. package/src/js/util/event.js +60 -59
  141. package/src/js/util/fastdom.js +1 -6
  142. package/src/js/util/filter.js +17 -34
  143. package/src/js/util/index.js +0 -1
  144. package/src/js/util/lang.js +81 -121
  145. package/src/js/util/mouse.js +19 -17
  146. package/src/js/util/options.js +32 -46
  147. package/src/js/util/player.js +40 -36
  148. package/src/js/util/position.js +54 -46
  149. package/src/js/util/selector.js +34 -49
  150. package/src/js/util/style.js +36 -46
  151. package/src/js/util/viewport.js +75 -64
  152. package/tests/image.html +37 -33
  153. package/tests/js/index.js +114 -85
  154. package/src/js/mixin/flex-bug.js +0 -56
  155. package/src/js/util/promise.js +0 -191
  156. package/tests/images/test.avif +0 -0
  157. package/tests/images/test.webp +0 -0
@@ -1,49 +1,45 @@
1
- import {$, $$, data, html, toggleClass, toNumber} from 'uikit-util';
1
+ import { $, $$, data, html, toggleClass, toNumber } from 'uikit-util';
2
2
 
3
3
  export default {
4
-
5
4
  data: {
6
- selNav: false
5
+ selNav: false,
7
6
  },
8
7
 
9
8
  computed: {
10
-
11
- nav({selNav}, $el) {
9
+ nav({ selNav }, $el) {
12
10
  return $(selNav, $el);
13
11
  },
14
12
 
15
- selNavItem({attrItem}) {
13
+ selNavItem({ attrItem }) {
16
14
  return `[${attrItem}],[data-${attrItem}]`;
17
15
  },
18
16
 
19
17
  navItems(_, $el) {
20
18
  return $$(this.selNavItem, $el);
21
- }
22
-
19
+ },
23
20
  },
24
21
 
25
22
  update: {
26
-
27
23
  write() {
28
-
29
24
  if (this.nav && this.length !== this.nav.children.length) {
30
- html(this.nav, this.slides.map((_, i) => `<li ${this.attrItem}="${i}"><a href></a></li>`).join(''));
25
+ html(
26
+ this.nav,
27
+ this.slides
28
+ .map((_, i) => `<li ${this.attrItem}="${i}"><a href></a></li>`)
29
+ .join('')
30
+ );
31
31
  }
32
32
 
33
- this.navItems.concat(this.nav).forEach(el => el && (el.hidden = !this.maxIndex));
33
+ this.navItems.concat(this.nav).forEach((el) => el && (el.hidden = !this.maxIndex));
34
34
 
35
35
  this.updateNav();
36
-
37
36
  },
38
37
 
39
- events: ['resize']
40
-
38
+ events: ['resize'],
41
39
  },
42
40
 
43
41
  events: [
44
-
45
42
  {
46
-
47
43
  name: 'click',
48
44
 
49
45
  delegate() {
@@ -53,34 +49,29 @@ export default {
53
49
  handler(e) {
54
50
  e.preventDefault();
55
51
  this.show(data(e.current, this.attrItem));
56
- }
57
-
52
+ },
58
53
  },
59
54
 
60
55
  {
61
-
62
56
  name: 'itemshow',
63
- handler: 'updateNav'
64
-
65
- }
66
-
57
+ handler: 'updateNav',
58
+ },
67
59
  ],
68
60
 
69
61
  methods: {
70
-
71
62
  updateNav() {
72
-
73
63
  const i = this.getValidIndex();
74
- this.navItems.forEach(el => {
75
-
64
+ for (const el of this.navItems) {
76
65
  const cmd = data(el, this.attrItem);
77
66
 
78
67
  toggleClass(el, this.clsActive, toNumber(cmd) === i);
79
- toggleClass(el, 'uk-invisible', this.finite && (cmd === 'previous' && i === 0 || cmd === 'next' && i >= this.maxIndex));
80
- });
81
-
82
- }
83
-
84
- }
85
-
68
+ toggleClass(
69
+ el,
70
+ 'uk-invisible',
71
+ this.finite &&
72
+ ((cmd === 'previous' && i === 0) || (cmd === 'next' && i >= this.maxIndex))
73
+ );
74
+ }
75
+ },
76
+ },
86
77
  };
@@ -1,9 +1,6 @@
1
1
  export default {
2
-
3
2
  update: {
4
-
5
3
  write() {
6
-
7
4
  if (this.stack.length || this.dragging) {
8
5
  return;
9
6
  }
@@ -13,11 +10,8 @@ export default {
13
10
  if (!~this.prevIndex || this.index !== index) {
14
11
  this.show(index);
15
12
  }
16
-
17
13
  },
18
14
 
19
- events: ['resize']
20
-
21
- }
22
-
15
+ events: ['resize'],
16
+ },
23
17
  };
@@ -1,10 +1,20 @@
1
1
  import SliderAutoplay from './slider-autoplay';
2
2
  import SliderDrag from './slider-drag';
3
3
  import SliderNav from './slider-nav';
4
- import {$, $$, assign, clamp, fastdom, getIndex, hasClass, isNumber, isRtl, Promise, removeClass, trigger} from 'uikit-util';
4
+ import {
5
+ $,
6
+ $$,
7
+ clamp,
8
+ fastdom,
9
+ getIndex,
10
+ hasClass,
11
+ isNumber,
12
+ isRtl,
13
+ removeClass,
14
+ trigger,
15
+ } from 'uikit-util';
5
16
 
6
17
  export default {
7
-
8
18
  mixins: [SliderAutoplay, SliderDrag, SliderNav],
9
19
 
10
20
  props: {
@@ -13,7 +23,7 @@ export default {
13
23
  index: Number,
14
24
  finite: Boolean,
15
25
  velocity: Number,
16
- selSlides: String
26
+ selSlides: String,
17
27
  },
18
28
 
19
29
  data: () => ({
@@ -27,7 +37,7 @@ export default {
27
37
  clsActive: 'uk-active',
28
38
  clsActivated: false,
29
39
  Transitioner: false,
30
- transitionOptions: {}
40
+ transitionOptions: {},
31
41
  }),
32
42
 
33
43
  connected() {
@@ -41,12 +51,11 @@ export default {
41
51
  },
42
52
 
43
53
  computed: {
44
-
45
- duration({velocity}, $el) {
54
+ duration({ velocity }, $el) {
46
55
  return speedUp($el.offsetWidth / velocity);
47
56
  },
48
57
 
49
- list({selList}, $el) {
58
+ list({ selList }, $el) {
50
59
  return $(selList, $el);
51
60
  },
52
61
 
@@ -54,45 +63,38 @@ export default {
54
63
  return this.length - 1;
55
64
  },
56
65
 
57
- selSlides({selList, selSlides}) {
66
+ selSlides({ selList, selSlides }) {
58
67
  return `${selList} ${selSlides || '> *'}`;
59
68
  },
60
69
 
61
70
  slides: {
62
-
63
71
  get() {
64
72
  return $$(this.selSlides, this.$el);
65
73
  },
66
74
 
67
75
  watch() {
68
76
  this.$reset();
69
- }
70
-
77
+ },
71
78
  },
72
79
 
73
80
  length() {
74
81
  return this.slides.length;
75
- }
76
-
82
+ },
77
83
  },
78
84
 
79
85
  events: {
80
-
81
86
  itemshown() {
82
87
  this.$update(this.list);
83
- }
84
-
88
+ },
85
89
  },
86
90
 
87
91
  methods: {
88
-
89
92
  show(index, force = false) {
90
-
91
93
  if (this.dragging || !this.length) {
92
94
  return;
93
95
  }
94
96
 
95
- const {stack} = this;
97
+ const { stack } = this;
96
98
  const queueIndex = force ? 0 : stack.length;
97
99
  const reset = () => {
98
100
  stack.splice(queueIndex, 1);
@@ -105,7 +107,6 @@ export default {
105
107
  stack[force ? 'unshift' : 'push'](index);
106
108
 
107
109
  if (!force && stack.length > 1) {
108
-
109
110
  if (stack.length === 2) {
110
111
  this._transitioner.forward(Math.min(this.duration, 200));
111
112
  }
@@ -127,8 +128,9 @@ export default {
127
128
  this.prevIndex = prevIndex;
128
129
  this.index = nextIndex;
129
130
 
130
- if (prev && !trigger(prev, 'beforeitemhide', [this])
131
- || !trigger(next, 'beforeitemshow', [this, prev])
131
+ if (
132
+ (prev && !trigger(prev, 'beforeitemhide', [this])) ||
133
+ !trigger(next, 'beforeitemshow', [this, prev])
132
134
  ) {
133
135
  this.index = this.prevIndex;
134
136
  reset();
@@ -136,11 +138,10 @@ export default {
136
138
  }
137
139
 
138
140
  const promise = this._show(prev, next, force).then(() => {
139
-
140
141
  prev && trigger(prev, 'itemhidden', [this]);
141
142
  trigger(next, 'itemshown', [this]);
142
143
 
143
- return new Promise(resolve => {
144
+ return new Promise((resolve) => {
144
145
  fastdom.write(() => {
145
146
  stack.shift();
146
147
  if (stack.length) {
@@ -151,14 +152,12 @@ export default {
151
152
  resolve();
152
153
  });
153
154
  });
154
-
155
155
  });
156
156
 
157
157
  prev && trigger(prev, 'itemhide', [this]);
158
158
  trigger(next, 'itemshow', [this]);
159
159
 
160
160
  return promise;
161
-
162
161
  },
163
162
 
164
163
  getIndex(index = this.index, prev = this.index) {
@@ -170,28 +169,25 @@ export default {
170
169
  },
171
170
 
172
171
  _show(prev, next, force) {
173
-
174
- this._transitioner = this._getTransitioner(
175
- prev,
176
- next,
177
- this.dir,
178
- assign({
179
- easing: force
180
- ? next.offsetWidth < 600
181
- ? 'cubic-bezier(0.25, 0.46, 0.45, 0.94)' /* easeOutQuad */
182
- : 'cubic-bezier(0.165, 0.84, 0.44, 1)' /* easeOutQuart */
183
- : this.easing
184
- }, this.transitionOptions)
185
- );
172
+ this._transitioner = this._getTransitioner(prev, next, this.dir, {
173
+ easing: force
174
+ ? next.offsetWidth < 600
175
+ ? 'cubic-bezier(0.25, 0.46, 0.45, 0.94)' /* easeOutQuad */
176
+ : 'cubic-bezier(0.165, 0.84, 0.44, 1)' /* easeOutQuart */
177
+ : this.easing,
178
+ ...this.transitionOptions,
179
+ });
186
180
 
187
181
  if (!force && !prev) {
188
182
  this._translate(1);
189
183
  return Promise.resolve();
190
184
  }
191
185
 
192
- const {length} = this.stack;
193
- return this._transitioner[length > 1 ? 'forward' : 'show'](length > 1 ? Math.min(this.duration, 75 + 75 / (length - 1)) : this.duration, this.percent);
194
-
186
+ const { length } = this.stack;
187
+ return this._transitioner[length > 1 ? 'forward' : 'show'](
188
+ length > 1 ? Math.min(this.duration, 75 + 75 / (length - 1)) : this.duration,
189
+ this.percent
190
+ );
195
191
  },
196
192
 
197
193
  _getDistance(prev, next) {
@@ -204,29 +200,26 @@ export default {
204
200
  return transitioner;
205
201
  },
206
202
 
207
- _getTransitioner(prev = this.prevIndex, next = this.index, dir = this.dir || 1, options = this.transitionOptions) {
203
+ _getTransitioner(
204
+ prev = this.prevIndex,
205
+ next = this.index,
206
+ dir = this.dir || 1,
207
+ options = this.transitionOptions
208
+ ) {
208
209
  return new this.Transitioner(
209
210
  isNumber(prev) ? this.slides[prev] : prev,
210
211
  isNumber(next) ? this.slides[next] : next,
211
212
  dir * (isRtl ? -1 : 1),
212
213
  options
213
214
  );
214
- }
215
-
216
- }
217
-
215
+ },
216
+ },
218
217
  };
219
218
 
220
219
  function getDirection(index, prevIndex) {
221
- return index === 'next'
222
- ? 1
223
- : index === 'previous'
224
- ? -1
225
- : index < prevIndex
226
- ? -1
227
- : 1;
220
+ return index === 'next' ? 1 : index === 'previous' ? -1 : index < prevIndex ? -1 : 1;
228
221
  }
229
222
 
230
223
  export function speedUp(x) {
231
- return .5 * x + 300; // parabola through (400,500; 600,600; 1800,1200)
224
+ return 0.5 * x + 300; // parabola through (400,500; 600,600; 1800,1200)
232
225
  }
@@ -1,53 +1,47 @@
1
1
  import Animations from './internal/slideshow-animations';
2
2
  import Transitioner from './internal/slideshow-transitioner';
3
3
  import Slider from './slider.js';
4
- import {addClass, assign, removeClass} from 'uikit-util';
4
+ import { addClass, removeClass } from 'uikit-util';
5
5
 
6
6
  export default {
7
-
8
7
  mixins: [Slider],
9
8
 
10
9
  props: {
11
- animation: String
10
+ animation: String,
12
11
  },
13
12
 
14
13
  data: {
15
14
  animation: 'slide',
16
15
  clsActivated: 'uk-transition-active',
17
16
  Animations,
18
- Transitioner
17
+ Transitioner,
19
18
  },
20
19
 
21
20
  computed: {
22
-
23
- animation({animation, Animations}) {
24
- return assign(Animations[animation] || Animations.slide, {name: animation});
21
+ animation({ animation, Animations }) {
22
+ return { ...(Animations[animation] || Animations.slide), name: animation };
25
23
  },
26
24
 
27
25
  transitionOptions() {
28
- return {animation: this.animation};
29
- }
30
-
26
+ return { animation: this.animation };
27
+ },
31
28
  },
32
29
 
33
30
  events: {
34
-
35
- 'itemshow itemhide itemshown itemhidden'({target}) {
31
+ 'itemshow itemhide itemshown itemhidden'({ target }) {
36
32
  this.$update(target);
37
33
  },
38
34
 
39
- beforeitemshow({target}) {
35
+ beforeitemshow({ target }) {
40
36
  addClass(target, this.clsActive);
41
37
  },
42
38
 
43
- itemshown({target}) {
39
+ itemshown({ target }) {
44
40
  addClass(target, this.clsActivated);
45
41
  },
46
42
 
47
- itemhidden({target}) {
43
+ itemhidden({ target }) {
48
44
  removeClass(target, this.clsActive, this.clsActivated);
49
- }
50
-
51
- }
52
-
45
+ },
46
+ },
53
47
  };
@@ -1,13 +1,31 @@
1
- import {$$, addClass, Animation, assign, css, fastdom, hasClass, height, includes, isBoolean, isFunction, isVisible, noop, Promise, removeClass, toFloat, toggleClass, toNodes, Transition, trigger} from 'uikit-util';
1
+ import {
2
+ $$,
3
+ addClass,
4
+ Animation,
5
+ css,
6
+ fastdom,
7
+ hasClass,
8
+ height,
9
+ includes,
10
+ isBoolean,
11
+ isFunction,
12
+ isVisible,
13
+ noop,
14
+ removeClass,
15
+ toFloat,
16
+ toggleClass,
17
+ toNodes,
18
+ Transition,
19
+ trigger,
20
+ } from 'uikit-util';
2
21
 
3
22
  export default {
4
-
5
23
  props: {
6
24
  cls: Boolean,
7
25
  animation: 'list',
8
26
  duration: Number,
9
27
  origin: String,
10
- transition: String
28
+ transition: String,
11
29
  },
12
30
 
13
31
  data: {
@@ -25,7 +43,7 @@ export default {
25
43
  paddingTop: '',
26
44
  paddingBottom: '',
27
45
  marginTop: '',
28
- marginBottom: ''
46
+ marginBottom: '',
29
47
  },
30
48
 
31
49
  hideProps: {
@@ -34,63 +52,61 @@ export default {
34
52
  paddingTop: 0,
35
53
  paddingBottom: 0,
36
54
  marginTop: 0,
37
- marginBottom: 0
38
- }
39
-
55
+ marginBottom: 0,
56
+ },
40
57
  },
41
58
 
42
59
  computed: {
43
-
44
- hasAnimation({animation}) {
60
+ hasAnimation({ animation }) {
45
61
  return !!animation[0];
46
62
  },
47
63
 
48
- hasTransition({animation}) {
64
+ hasTransition({ animation }) {
49
65
  return this.hasAnimation && animation[0] === true;
50
- }
51
-
66
+ },
52
67
  },
53
68
 
54
69
  methods: {
55
-
56
70
  toggleElement(targets, toggle, animate) {
57
- return new Promise(resolve =>
58
- Promise.all(toNodes(targets).map(el => {
59
-
60
- const show = isBoolean(toggle) ? toggle : !this.isToggled(el);
61
-
62
- if (!trigger(el, `before${show ? 'show' : 'hide'}`, [this])) {
63
- return Promise.reject();
64
- }
65
-
66
- const promise = (
67
- isFunction(animate)
68
- ? animate
69
- : animate === false || !this.hasAnimation
70
- ? this._toggle
71
- : this.hasTransition
71
+ return new Promise((resolve) =>
72
+ Promise.all(
73
+ toNodes(targets).map((el) => {
74
+ const show = isBoolean(toggle) ? toggle : !this.isToggled(el);
75
+
76
+ if (!trigger(el, `before${show ? 'show' : 'hide'}`, [this])) {
77
+ return Promise.reject();
78
+ }
79
+
80
+ const promise = (
81
+ isFunction(animate)
82
+ ? animate
83
+ : animate === false || !this.hasAnimation
84
+ ? this._toggle
85
+ : this.hasTransition
72
86
  ? toggleHeight(this)
73
87
  : toggleAnimation(this)
74
- )(el, show);
75
-
76
- const cls = show ? this.clsEnter : this.clsLeave;
88
+ )(el, show);
77
89
 
78
- addClass(el, cls);
90
+ const cls = show ? this.clsEnter : this.clsLeave;
79
91
 
80
- trigger(el, show ? 'show' : 'hide', [this]);
92
+ addClass(el, cls);
81
93
 
82
- const done = () => {
83
- removeClass(el, cls);
84
- trigger(el, show ? 'shown' : 'hidden', [this]);
85
- this.$update(el);
86
- };
94
+ trigger(el, show ? 'show' : 'hide', [this]);
87
95
 
88
- return promise ? promise.then(done, () => {
89
- removeClass(el, cls);
90
- return Promise.reject();
91
- }) : done();
96
+ const done = () => {
97
+ removeClass(el, cls);
98
+ trigger(el, show ? 'shown' : 'hidden', [this]);
99
+ this.$update(el);
100
+ };
92
101
 
93
- })).then(resolve, noop)
102
+ return promise
103
+ ? promise.then(done, () => {
104
+ removeClass(el, cls);
105
+ return Promise.reject();
106
+ })
107
+ : done();
108
+ })
109
+ ).then(resolve, noop)
94
110
  );
95
111
  },
96
112
 
@@ -99,14 +115,13 @@ export default {
99
115
  return hasClass(el, this.clsEnter)
100
116
  ? true
101
117
  : hasClass(el, this.clsLeave)
102
- ? false
103
- : this.cls
104
- ? hasClass(el, this.cls.split(' ')[0])
105
- : isVisible(el);
118
+ ? false
119
+ : this.cls
120
+ ? hasClass(el, this.cls.split(' ')[0])
121
+ : isVisible(el);
106
122
  },
107
123
 
108
124
  _toggle(el, toggled) {
109
-
110
125
  if (!el) {
111
126
  return;
112
127
  }
@@ -122,23 +137,23 @@ export default {
122
137
  changed && (el.hidden = !toggled);
123
138
  }
124
139
 
125
- $$('[autofocus]', el).some(el => isVisible(el) ? el.focus() || true : el.blur());
140
+ $$('[autofocus]', el).some((el) => (isVisible(el) ? el.focus() || true : el.blur()));
126
141
 
127
142
  if (changed) {
128
143
  trigger(el, 'toggled', [toggled, this]);
129
144
  this.$update(el);
130
145
  }
131
- }
132
-
133
- }
134
-
146
+ },
147
+ },
135
148
  };
136
149
 
137
- export function toggleHeight({isToggled, duration, initProps, hideProps, transition, _toggle}) {
150
+ export function toggleHeight({ isToggled, duration, initProps, hideProps, transition, _toggle }) {
138
151
  return (el, show) => {
139
-
140
152
  const inProgress = Transition.inProgress(el);
141
- const inner = el.hasChildNodes ? toFloat(css(el.firstElementChild, 'marginTop')) + toFloat(css(el.lastElementChild, 'marginBottom')) : 0;
153
+ const inner = el.hasChildNodes
154
+ ? toFloat(css(el.firstElementChild, 'marginTop')) +
155
+ toFloat(css(el.lastElementChild, 'marginBottom'))
156
+ : 0;
142
157
  const currentHeight = isVisible(el) ? height(el) + (inProgress ? 0 : inner) : 0;
143
158
 
144
159
  Transition.cancel(el);
@@ -155,26 +170,37 @@ export function toggleHeight({isToggled, duration, initProps, hideProps, transit
155
170
  const endHeight = height(el) + (inProgress ? 0 : inner);
156
171
  height(el, currentHeight);
157
172
 
158
- return (show
159
- ? Transition.start(el, assign({}, initProps, {overflow: 'hidden', height: endHeight}), Math.round(duration * (1 - currentHeight / endHeight)), transition)
160
- : Transition.start(el, hideProps, Math.round(duration * (currentHeight / endHeight)), transition).then(() => _toggle(el, false))
173
+ return (
174
+ show
175
+ ? Transition.start(
176
+ el,
177
+ { ...initProps, overflow: 'hidden', height: endHeight },
178
+ Math.round(duration * (1 - currentHeight / endHeight)),
179
+ transition
180
+ )
181
+ : Transition.start(
182
+ el,
183
+ hideProps,
184
+ Math.round(duration * (currentHeight / endHeight)),
185
+ transition
186
+ ).then(() => _toggle(el, false))
161
187
  ).then(() => css(el, initProps));
162
-
163
188
  };
164
189
  }
165
190
 
166
191
  function toggleAnimation(cmp) {
167
192
  return (el, show) => {
168
-
169
193
  Animation.cancel(el);
170
194
 
171
- const {animation, duration, _toggle} = cmp;
195
+ const { animation, duration, _toggle } = cmp;
172
196
 
173
197
  if (show) {
174
198
  _toggle(el, true);
175
199
  return Animation.in(el, animation[0], duration, cmp.origin);
176
200
  }
177
201
 
178
- return Animation.out(el, animation[1] || animation[0], duration, cmp.origin).then(() => _toggle(el, false));
202
+ return Animation.out(el, animation[1] || animation[0], duration, cmp.origin).then(() =>
203
+ _toggle(el, false)
204
+ );
179
205
  };
180
206
  }
@@ -2,12 +2,10 @@ import UIkit from './api/index';
2
2
  import Core from './core/core';
3
3
  import boot from './api/boot';
4
4
  import * as components from './core/index';
5
- import {each} from 'uikit-util';
5
+ import { each } from 'uikit-util';
6
6
 
7
7
  // register components
8
- each(components, (component, name) =>
9
- UIkit.component(name, component)
10
- );
8
+ each(components, (component, name) => UIkit.component(name, component));
11
9
 
12
10
  // core functionality
13
11
  UIkit.use(Core);