uikit 3.11.2-dev.28b7953b9 → 3.11.2-dev.29f2881ed

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 (223) 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 +42 -29
  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 +127 -201
  19. package/dist/css/uikit-core-rtl.min.css +1 -1
  20. package/dist/css/uikit-core.css +127 -201
  21. package/dist/css/uikit-core.min.css +1 -1
  22. package/dist/css/uikit-rtl.css +129 -207
  23. package/dist/css/uikit-rtl.min.css +1 -1
  24. package/dist/css/uikit.css +129 -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 +643 -826
  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 +5339 -6661
  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 +8156 -9889
  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-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 -44
  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 +80 -78
  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 +156 -118
  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 +25 -40
  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 +58 -45
  139. package/src/js/util/dom.js +39 -66
  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/height.less +3 -0
  158. package/src/less/components/leader.less +0 -1
  159. package/src/less/components/lightbox.less +0 -1
  160. package/src/less/components/modal.less +3 -7
  161. package/src/less/components/navbar.less +0 -7
  162. package/src/less/components/progress.less +14 -36
  163. package/src/less/components/slider.less +0 -3
  164. package/src/less/components/slideshow.less +0 -3
  165. package/src/less/components/text.less +16 -32
  166. package/src/less/components/utility.less +22 -0
  167. package/src/scss/components/base.scss +10 -33
  168. package/src/scss/components/flex.scss +0 -9
  169. package/src/scss/components/form-range.scss +48 -95
  170. package/src/scss/components/form.scss +3 -4
  171. package/src/scss/components/height.scss +3 -0
  172. package/src/scss/components/icon.scss +2 -2
  173. package/src/scss/components/leader.scss +0 -1
  174. package/src/scss/components/lightbox.scss +0 -1
  175. package/src/scss/components/modal.scss +3 -7
  176. package/src/scss/components/navbar.scss +0 -7
  177. package/src/scss/components/progress.scss +14 -36
  178. package/src/scss/components/search.scss +1 -1
  179. package/src/scss/components/slider.scss +0 -3
  180. package/src/scss/components/slideshow.scss +0 -3
  181. package/src/scss/components/text.scss +16 -32
  182. package/src/scss/components/utility.scss +22 -0
  183. package/src/scss/mixins-theme.scss +1 -1
  184. package/src/scss/mixins.scss +1 -1
  185. package/src/scss/variables-theme.scss +9 -9
  186. package/src/scss/variables.scss +9 -9
  187. package/tests/align.html +10 -10
  188. package/tests/animation.html +2 -2
  189. package/tests/article.html +2 -2
  190. package/tests/base.html +3 -3
  191. package/tests/card.html +10 -10
  192. package/tests/column.html +3 -3
  193. package/tests/comment.html +9 -9
  194. package/tests/dotnav.html +3 -3
  195. package/tests/image.html +296 -54
  196. package/tests/images/image-type.avif +0 -0
  197. package/tests/images/image-type.jpeg +0 -0
  198. package/tests/images/image-type.webp +0 -0
  199. package/tests/index.html +8 -8
  200. package/tests/js/index.js +114 -85
  201. package/tests/lightbox.html +10 -10
  202. package/tests/marker.html +2 -2
  203. package/tests/modal.html +8 -9
  204. package/tests/navbar.html +2 -2
  205. package/tests/overlay.html +7 -7
  206. package/tests/parallax.html +14 -5
  207. package/tests/position.html +12 -12
  208. package/tests/slidenav.html +12 -12
  209. package/tests/slider.html +20 -20
  210. package/tests/sortable.html +1 -1
  211. package/tests/sticky-parallax.html +55 -70
  212. package/tests/svg.html +6 -6
  213. package/tests/table.html +11 -11
  214. package/tests/thumbnav.html +12 -12
  215. package/tests/transition.html +30 -30
  216. package/tests/utility.html +33 -33
  217. package/tests/video.html +1 -1
  218. package/tests/width.html +1 -1
  219. package/src/js/mixin/flex-bug.js +0 -56
  220. package/src/js/util/promise.js +0 -191
  221. package/tests/images/animated.gif +0 -0
  222. package/tests/images/test.avif +0 -0
  223. package/tests/images/test.webp +0 -0
@@ -1,17 +1,31 @@
1
1
  import Container from '../mixin/container';
2
2
  import Togglable from '../mixin/togglable';
3
3
  import Position from '../mixin/position';
4
- import {append, attr, flipPosition, hasAttr, isFocusable, isTouch, matches, on, once, pointerDown, pointerEnter, pointerLeave, remove, within} from 'uikit-util';
4
+ import {
5
+ append,
6
+ attr,
7
+ flipPosition,
8
+ hasAttr,
9
+ isFocusable,
10
+ isTouch,
11
+ matches,
12
+ on,
13
+ once,
14
+ pointerDown,
15
+ pointerEnter,
16
+ pointerLeave,
17
+ remove,
18
+ within,
19
+ } from 'uikit-util';
5
20
 
6
21
  export default {
7
-
8
22
  mixins: [Container, Togglable, Position],
9
23
 
10
24
  args: 'title',
11
25
 
12
26
  props: {
13
27
  delay: Number,
14
- title: String
28
+ title: String,
15
29
  },
16
30
 
17
31
  data: {
@@ -21,7 +35,7 @@ export default {
21
35
  animation: ['uk-animation-scale-up'],
22
36
  duration: 100,
23
37
  cls: 'uk-active',
24
- clsPos: 'uk-tooltip'
38
+ clsPos: 'uk-tooltip',
25
39
  },
26
40
 
27
41
  beforeConnect() {
@@ -37,25 +51,27 @@ export default {
37
51
  },
38
52
 
39
53
  methods: {
40
-
41
54
  show() {
42
-
43
55
  if (this.isToggled(this.tooltip || null) || !this.title) {
44
56
  return;
45
57
  }
46
58
 
47
- this._unbind = once(document, `show keydown ${pointerDown}`, this.hide, false, e =>
48
- e.type === pointerDown && !within(e.target, this.$el)
49
- || e.type === 'keydown' && e.keyCode === 27
50
- || e.type === 'show' && e.detail[0] !== this && e.detail[0].$name === this.$name
59
+ this._unbind = once(
60
+ document,
61
+ `show keydown ${pointerDown}`,
62
+ this.hide,
63
+ false,
64
+ (e) =>
65
+ (e.type === pointerDown && !within(e.target, this.$el)) ||
66
+ (e.type === 'keydown' && e.keyCode === 27) ||
67
+ (e.type === 'show' && e.detail[0] !== this && e.detail[0].$name === this.$name)
51
68
  );
52
69
 
53
70
  clearTimeout(this.showTimer);
54
71
  this.showTimer = setTimeout(this._show, this.delay);
55
72
  },
56
73
 
57
- hide() {
58
-
74
+ async hide() {
59
75
  if (matches(this.$el, 'input:focus')) {
60
76
  return;
61
77
  }
@@ -66,23 +82,21 @@ export default {
66
82
  return;
67
83
  }
68
84
 
69
- this.toggleElement(this.tooltip, false, false).then(() => {
70
- remove(this.tooltip);
71
- this.tooltip = null;
72
- this._unbind();
73
- });
85
+ await this.toggleElement(this.tooltip, false, false);
86
+ remove(this.tooltip);
87
+ this.tooltip = null;
88
+ this._unbind();
74
89
  },
75
90
 
76
91
  _show() {
77
-
78
- this.tooltip = append(this.container,
92
+ this.tooltip = append(
93
+ this.container,
79
94
  `<div class="${this.clsPos}">
80
95
  <div class="${this.clsPos}-inner">${this.title}</div>
81
96
  </div>`
82
97
  );
83
98
 
84
99
  on(this.tooltip, 'toggled', (e, toggled) => {
85
-
86
100
  this.updateAria(toggled);
87
101
 
88
102
  if (!toggled) {
@@ -91,23 +105,21 @@ export default {
91
105
 
92
106
  this.positionAt(this.tooltip, this.$el);
93
107
 
94
- this.origin = this.getAxis() === 'y'
95
- ? `${flipPosition(this.dir)}-${this.align}`
96
- : `${this.align}-${flipPosition(this.dir)}`;
108
+ this.origin =
109
+ this.getAxis() === 'y'
110
+ ? `${flipPosition(this.dir)}-${this.align}`
111
+ : `${this.align}-${flipPosition(this.dir)}`;
97
112
  });
98
113
 
99
114
  this.toggleElement(this.tooltip, true);
100
-
101
115
  },
102
116
 
103
117
  updateAria(toggled) {
104
118
  attr(this.$el, 'aria-expanded', toggled);
105
- }
106
-
119
+ },
107
120
  },
108
121
 
109
122
  events: {
110
-
111
123
  focus: 'show',
112
124
  blur: 'hide',
113
125
 
@@ -123,10 +135,8 @@ export default {
123
135
  if (isTouch(e)) {
124
136
  this.show();
125
137
  }
126
- }
127
-
128
- }
129
-
138
+ },
139
+ },
130
140
  };
131
141
 
132
142
  function makeFocusable(el) {
@@ -1,7 +1,6 @@
1
- import {addClass, ajax, matches, noop, on, removeClass, trigger} from 'uikit-util';
1
+ import { addClass, ajax, matches, noop, on, removeClass, trigger } from 'uikit-util';
2
2
 
3
3
  export default {
4
-
5
4
  props: {
6
5
  allow: String,
7
6
  clsDragover: String,
@@ -16,7 +15,7 @@ export default {
16
15
  name: String,
17
16
  params: Object,
18
17
  type: String,
19
- url: String
18
+ url: String,
20
19
  },
21
20
 
22
21
  data: {
@@ -44,13 +43,11 @@ export default {
44
43
  load: noop,
45
44
  loadEnd: noop,
46
45
  loadStart: noop,
47
- progress: noop
46
+ progress: noop,
48
47
  },
49
48
 
50
49
  events: {
51
-
52
50
  change(e) {
53
-
54
51
  if (!matches(e.target, 'input[type="file"]')) {
55
52
  return;
56
53
  }
@@ -69,7 +66,7 @@ export default {
69
66
 
70
67
  const transfer = e.dataTransfer;
71
68
 
72
- if (!transfer || !transfer.files) {
69
+ if (!transfer?.files) {
73
70
  return;
74
71
  }
75
72
 
@@ -90,108 +87,100 @@ export default {
90
87
  dragleave(e) {
91
88
  stop(e);
92
89
  removeClass(this.$el, this.clsDragover);
93
- }
94
-
90
+ },
95
91
  },
96
92
 
97
93
  methods: {
98
-
99
- upload(files) {
100
-
94
+ async upload(files) {
101
95
  if (!files.length) {
102
96
  return;
103
97
  }
104
98
 
105
99
  trigger(this.$el, 'upload', [files]);
106
100
 
107
- for (let i = 0; i < files.length; i++) {
108
-
109
- if (this.maxSize && this.maxSize * 1000 < files[i].size) {
101
+ for (const file of files) {
102
+ if (this.maxSize && this.maxSize * 1000 < file.size) {
110
103
  this.fail(this.msgInvalidSize.replace('%s', this.maxSize));
111
104
  return;
112
105
  }
113
106
 
114
- if (this.allow && !match(this.allow, files[i].name)) {
107
+ if (this.allow && !match(this.allow, file.name)) {
115
108
  this.fail(this.msgInvalidName.replace('%s', this.allow));
116
109
  return;
117
110
  }
118
111
 
119
- if (this.mime && !match(this.mime, files[i].type)) {
112
+ if (this.mime && !match(this.mime, file.type)) {
120
113
  this.fail(this.msgInvalidMime.replace('%s', this.mime));
121
114
  return;
122
115
  }
123
-
124
116
  }
125
117
 
126
118
  if (!this.multiple) {
127
- files = [files[0]];
119
+ files = files.slice(0, 1);
128
120
  }
129
121
 
130
122
  this.beforeAll(this, files);
131
123
 
132
124
  const chunks = chunk(files, this.concurrent);
133
- const upload = files => {
134
-
125
+ const upload = async (files) => {
135
126
  const data = new FormData();
136
127
 
137
- files.forEach(file => data.append(this.name, file));
128
+ files.forEach((file) => data.append(this.name, file));
138
129
 
139
130
  for (const key in this.params) {
140
131
  data.append(key, this.params[key]);
141
132
  }
142
133
 
143
- ajax(this.url, {
144
- data,
145
- method: this.method,
146
- responseType: this.type,
147
- beforeSend: env => {
148
-
149
- const {xhr} = env;
150
- xhr.upload && on(xhr.upload, 'progress', this.progress);
151
- ['loadStart', 'load', 'loadEnd', 'abort'].forEach(type =>
152
- on(xhr, type.toLowerCase(), this[type])
153
- );
154
-
155
- return this.beforeSend(env);
156
-
134
+ try {
135
+ const xhr = await ajax(this.url, {
136
+ data,
137
+ method: this.method,
138
+ responseType: this.type,
139
+ beforeSend: (env) => {
140
+ const { xhr } = env;
141
+ xhr.upload && on(xhr.upload, 'progress', this.progress);
142
+ for (const type of ['loadStart', 'load', 'loadEnd', 'abort']) {
143
+ on(xhr, type.toLowerCase(), this[type]);
144
+ }
145
+
146
+ return this.beforeSend(env);
147
+ },
148
+ });
149
+
150
+ this.complete(xhr);
151
+
152
+ if (chunks.length) {
153
+ await upload(chunks.shift());
154
+ } else {
155
+ this.completeAll(xhr);
157
156
  }
158
- }).then(
159
- xhr => {
160
-
161
- this.complete(xhr);
162
-
163
- if (chunks.length) {
164
- upload(chunks.shift());
165
- } else {
166
- this.completeAll(xhr);
167
- }
168
-
169
- },
170
- e => this.error(e)
171
- );
172
-
157
+ } catch (e) {
158
+ this.error(e);
159
+ }
173
160
  };
174
161
 
175
- upload(chunks.shift());
176
-
177
- }
178
-
179
- }
180
-
162
+ await upload(chunks.shift());
163
+ },
164
+ },
181
165
  };
182
166
 
183
167
  function match(pattern, path) {
184
- return path.match(new RegExp(`^${pattern.replace(/\//g, '\\/').replace(/\*\*/g, '(\\/[^\\/]+)*').replace(/\*/g, '[^\\/]+').replace(/((?!\\))\?/g, '$1.')}$`, 'i'));
168
+ return path.match(
169
+ new RegExp(
170
+ `^${pattern
171
+ .replace(/\//g, '\\/')
172
+ .replace(/\*\*/g, '(\\/[^\\/]+)*')
173
+ .replace(/\*/g, '[^\\/]+')
174
+ .replace(/((?!\\))\?/g, '$1.')}$`,
175
+ 'i'
176
+ )
177
+ );
185
178
  }
186
179
 
187
180
  function chunk(files, size) {
188
181
  const chunks = [];
189
182
  for (let i = 0; i < files.length; i += size) {
190
- const chunk = [];
191
- for (let j = 0; j < size; j++) {
192
- chunk.push(files[i + j]);
193
- }
194
- chunks.push(chunk);
183
+ chunks.push(files.slice(i, i + size));
195
184
  }
196
185
  return chunks;
197
186
  }
@@ -1,9 +1,22 @@
1
1
  import Class from '../mixin/class';
2
- import {default as Togglable, toggleHeight} from '../mixin/togglable';
3
- import {$, $$, attr, filter, getIndex, hasClass, includes, index, isInView, scrollIntoView, toggleClass, unwrap, wrapAll} from 'uikit-util';
2
+ import { default as Togglable, toggleHeight } from '../mixin/togglable';
3
+ import {
4
+ $,
5
+ $$,
6
+ attr,
7
+ filter,
8
+ getIndex,
9
+ hasClass,
10
+ includes,
11
+ index,
12
+ isInView,
13
+ scrollIntoView,
14
+ toggleClass,
15
+ unwrap,
16
+ wrapAll,
17
+ } from 'uikit-util';
4
18
 
5
19
  export default {
6
-
7
20
  mixins: [Class, Togglable],
8
21
 
9
22
  props: {
@@ -14,7 +27,7 @@ export default {
14
27
  toggle: String,
15
28
  content: String,
16
29
  transition: String,
17
- offset: Number
30
+ offset: Number,
18
31
  },
19
32
 
20
33
  data: {
@@ -27,48 +40,41 @@ export default {
27
40
  toggle: '> .uk-accordion-title',
28
41
  content: '> .uk-accordion-content',
29
42
  transition: 'ease',
30
- offset: 0
43
+ offset: 0,
31
44
  },
32
45
 
33
46
  computed: {
34
-
35
47
  items: {
36
-
37
- get({targets}, $el) {
48
+ get({ targets }, $el) {
38
49
  return $$(targets, $el);
39
50
  },
40
51
 
41
52
  watch(items, prev) {
42
-
43
- items.forEach(el => hide($(this.content, el), !hasClass(el, this.clsOpen)));
53
+ items.forEach((el) => hide($(this.content, el), !hasClass(el, this.clsOpen)));
44
54
 
45
55
  if (prev || hasClass(items, this.clsOpen)) {
46
56
  return;
47
57
  }
48
58
 
49
- const active = this.active !== false && items[Number(this.active)]
50
- || !this.collapsible && items[0];
59
+ const active =
60
+ (this.active !== false && items[Number(this.active)]) ||
61
+ (!this.collapsible && items[0]);
51
62
 
52
63
  if (active) {
53
64
  this.toggle(active, false);
54
65
  }
55
-
56
66
  },
57
67
 
58
- immediate: true
59
-
68
+ immediate: true,
60
69
  },
61
70
 
62
- toggles({toggle}) {
63
- return this.items.map(item => $(toggle, item));
64
- }
65
-
71
+ toggles({ toggle }) {
72
+ return this.items.map((item) => $(toggle, item));
73
+ },
66
74
  },
67
75
 
68
76
  events: [
69
-
70
77
  {
71
-
72
78
  name: 'click',
73
79
 
74
80
  delegate() {
@@ -78,16 +84,12 @@ export default {
78
84
  handler(e) {
79
85
  e.preventDefault();
80
86
  this.toggle(index(this.toggles, e.current));
81
- }
82
-
83
- }
84
-
87
+ },
88
+ },
85
89
  ],
86
90
 
87
91
  methods: {
88
-
89
92
  toggle(item, animate) {
90
-
91
93
  let items = [this.items[getIndex(item, this.items)]];
92
94
  const activeItems = filter(this.items, `.${this.clsOpen}`);
93
95
 
@@ -95,44 +97,47 @@ export default {
95
97
  items = items.concat(activeItems);
96
98
  }
97
99
 
98
- if (!this.collapsible && activeItems.length < 2 && !filter(items, `:not(.${this.clsOpen})`).length) {
100
+ if (
101
+ !this.collapsible &&
102
+ activeItems.length < 2 &&
103
+ !filter(items, `:not(.${this.clsOpen})`).length
104
+ ) {
99
105
  return;
100
106
  }
101
107
 
102
- items.forEach(el => this.toggleElement(el, !hasClass(el, this.clsOpen), (el, show) => {
108
+ for (const el of items) {
109
+ this.toggleElement(el, !hasClass(el, this.clsOpen), async (el, show) => {
110
+ toggleClass(el, this.clsOpen, show);
111
+ attr($(this.$props.toggle, el), 'aria-expanded', show);
103
112
 
104
- toggleClass(el, this.clsOpen, show);
105
- attr($(this.$props.toggle, el), 'aria-expanded', show);
113
+ const content = $(`${el._wrapper ? '> * ' : ''}${this.content}`, el);
106
114
 
107
- const content = $(`${el._wrapper ? '> * ' : ''}${this.content}`, el);
108
-
109
- if (animate === false || !this.hasTransition) {
110
- hide(content, !show);
111
- return;
112
- }
115
+ if (animate === false || !this.hasTransition) {
116
+ hide(content, !show);
117
+ return;
118
+ }
113
119
 
114
- if (!el._wrapper) {
115
- el._wrapper = wrapAll(content, `<div${show ? ' hidden' : ''}>`);
116
- }
120
+ if (!el._wrapper) {
121
+ el._wrapper = wrapAll(content, `<div${show ? ' hidden' : ''}>`);
122
+ }
117
123
 
118
- hide(content, false);
119
- return toggleHeight(this)(el._wrapper, show).then(() => {
124
+ hide(content, false);
125
+ await toggleHeight(this)(el._wrapper, show);
120
126
  hide(content, !show);
127
+
121
128
  delete el._wrapper;
122
129
  unwrap(content);
123
130
 
124
131
  if (show) {
125
132
  const toggle = $(this.$props.toggle, el);
126
133
  if (!isInView(toggle)) {
127
- scrollIntoView(toggle, {offset: this.offset});
134
+ scrollIntoView(toggle, { offset: this.offset });
128
135
  }
129
136
  }
130
137
  });
131
- }));
132
- }
133
-
134
- }
135
-
138
+ }
139
+ },
140
+ },
136
141
  };
137
142
 
138
143
  function hide(el, hide) {
@@ -1,28 +1,24 @@
1
1
  import Class from '../mixin/class';
2
2
  import Togglable from '../mixin/togglable';
3
- import {assign} from 'uikit-util';
4
3
 
5
4
  export default {
6
-
7
5
  mixins: [Class, Togglable],
8
6
 
9
7
  args: 'animation',
10
8
 
11
9
  props: {
12
- close: String
10
+ close: String,
13
11
  },
14
12
 
15
13
  data: {
16
14
  animation: [true],
17
15
  selClose: '.uk-alert-close',
18
16
  duration: 150,
19
- hideProps: assign({opacity: 0}, Togglable.data.hideProps)
17
+ hideProps: { opacity: 0, ...Togglable.data.hideProps },
20
18
  },
21
19
 
22
20
  events: [
23
-
24
21
  {
25
-
26
22
  name: 'click',
27
23
 
28
24
  delegate() {
@@ -32,18 +28,14 @@ export default {
32
28
  handler(e) {
33
29
  e.preventDefault();
34
30
  this.close();
35
- }
36
-
37
- }
38
-
31
+ },
32
+ },
39
33
  ],
40
34
 
41
35
  methods: {
42
-
43
- close() {
44
- this.toggleElement(this.$el).then(() => this.$destroy(true));
45
- }
46
-
47
- }
48
-
36
+ async close() {
37
+ await this.toggleElement(this.$el);
38
+ this.$destroy(true);
39
+ },
40
+ },
49
41
  };