uikit 3.15.4-dev.dbc0ede84 → 3.15.5-dev.ec9b624fd

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 (48) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/css/uikit-core-rtl.css +1 -1
  3. package/dist/css/uikit-core-rtl.min.css +1 -1
  4. package/dist/css/uikit-core.css +1 -1
  5. package/dist/css/uikit-core.min.css +1 -1
  6. package/dist/css/uikit-rtl.css +1 -1
  7. package/dist/css/uikit-rtl.min.css +1 -1
  8. package/dist/css/uikit.css +1 -1
  9. package/dist/css/uikit.min.css +1 -1
  10. package/dist/js/components/countdown.js +1 -1
  11. package/dist/js/components/countdown.min.js +1 -1
  12. package/dist/js/components/filter.js +14 -13
  13. package/dist/js/components/filter.min.js +1 -1
  14. package/dist/js/components/lightbox-panel.js +105 -110
  15. package/dist/js/components/lightbox-panel.min.js +1 -1
  16. package/dist/js/components/lightbox.js +105 -110
  17. package/dist/js/components/lightbox.min.js +1 -1
  18. package/dist/js/components/notification.js +1 -1
  19. package/dist/js/components/notification.min.js +1 -1
  20. package/dist/js/components/parallax.js +1 -1
  21. package/dist/js/components/parallax.min.js +1 -1
  22. package/dist/js/components/slider-parallax.js +1 -1
  23. package/dist/js/components/slider-parallax.min.js +1 -1
  24. package/dist/js/components/slider.js +1 -1
  25. package/dist/js/components/slider.min.js +1 -1
  26. package/dist/js/components/slideshow-parallax.js +1 -1
  27. package/dist/js/components/slideshow-parallax.min.js +1 -1
  28. package/dist/js/components/slideshow.js +1 -1
  29. package/dist/js/components/slideshow.min.js +1 -1
  30. package/dist/js/components/sortable.js +1 -1
  31. package/dist/js/components/sortable.min.js +1 -1
  32. package/dist/js/components/tooltip.js +101 -105
  33. package/dist/js/components/tooltip.min.js +1 -1
  34. package/dist/js/components/upload.js +1 -1
  35. package/dist/js/components/upload.min.js +1 -1
  36. package/dist/js/uikit-core.js +169 -147
  37. package/dist/js/uikit-core.min.js +2 -2
  38. package/dist/js/uikit-icons.js +1 -1
  39. package/dist/js/uikit-icons.min.js +1 -1
  40. package/dist/js/uikit.js +184 -161
  41. package/dist/js/uikit.min.js +2 -2
  42. package/package.json +1 -1
  43. package/src/js/components/filter.js +14 -12
  44. package/src/js/core/accordion.js +51 -16
  45. package/src/js/core/alert.js +19 -21
  46. package/src/js/mixin/modal.js +28 -29
  47. package/src/js/mixin/togglable.js +109 -113
  48. package/tests/accordion.html +1 -1
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "uikit",
3
3
  "title": "UIkit",
4
4
  "description": "UIkit is a lightweight and modular front-end framework for developing fast and powerful web interfaces.",
5
- "version": "3.15.4-dev.dbc0ede84",
5
+ "version": "3.15.5-dev.ec9b624fd",
6
6
  "main": "dist/js/uikit.js",
7
7
  "style": "dist/css/uikit.css",
8
8
  "sideEffects": [
@@ -5,6 +5,7 @@ import {
5
5
  css,
6
6
  data,
7
7
  each,
8
+ fastdom,
8
9
  children as getChildren,
9
10
  hasClass,
10
11
  includes,
@@ -42,7 +43,7 @@ export default {
42
43
  },
43
44
 
44
45
  watch() {
45
- this.$emit();
46
+ this.updateState();
46
47
 
47
48
  if (this.selActive !== false) {
48
49
  const actives = $$(this.selActive, this.$el);
@@ -60,7 +61,7 @@ export default {
60
61
 
61
62
  watch(list, old) {
62
63
  if (old && !isEqualList(list, old)) {
63
- this.$emit();
64
+ this.updateState();
64
65
  }
65
66
  },
66
67
 
@@ -68,12 +69,6 @@ export default {
68
69
  },
69
70
  },
70
71
 
71
- update: {
72
- write() {
73
- this.setState(this.getState(), false);
74
- },
75
- },
76
-
77
72
  events: [
78
73
  {
79
74
  name: 'click',
@@ -113,19 +108,26 @@ export default {
113
108
 
114
109
  trigger(this.$el, 'beforeFilter', [this, state]);
115
110
 
116
- for (const el of this.toggles) {
117
- toggleClass(el, this.cls, !!matchFilter(el, this.attrItem, state));
118
- }
111
+ this.toggles.forEach((el) =>
112
+ toggleClass(el, this.cls, !!matchFilter(el, this.attrItem, state))
113
+ );
119
114
 
120
115
  await Promise.all(
121
116
  $$(this.target, this.$el).map((target) => {
122
- const filterFn = () => applyState(state, target, getChildren(target));
117
+ const filterFn = () => {
118
+ applyState(state, target, getChildren(target));
119
+ this.$update(this.$el);
120
+ };
123
121
  return animate ? this.animate(filterFn, target) : filterFn();
124
122
  })
125
123
  );
126
124
 
127
125
  trigger(this.$el, 'afterFilter', [this]);
128
126
  },
127
+
128
+ updateState() {
129
+ fastdom.write(() => this.setState(this.getState(), false));
130
+ },
129
131
  },
130
132
  };
131
133
 
@@ -1,19 +1,25 @@
1
1
  import Class from '../mixin/class';
2
2
  import Lazyload from '../mixin/lazyload';
3
- import { default as Togglable, toggleTransition } from '../mixin/togglable';
3
+ import Togglable from '../mixin/togglable';
4
4
  import {
5
5
  $,
6
6
  $$,
7
7
  attr,
8
+ css,
8
9
  filter,
9
10
  getIndex,
10
11
  hasClass,
11
12
  includes,
12
13
  index,
13
14
  isInView,
15
+ noop,
14
16
  scrollIntoView,
17
+ toFloat,
15
18
  toggleClass,
19
+ Transition,
20
+ unwrap,
16
21
  within,
22
+ wrapAll,
17
23
  } from 'uikit-util';
18
24
 
19
25
  export default {
@@ -127,28 +133,25 @@ export default {
127
133
  }
128
134
 
129
135
  for (const el of items) {
130
- this.toggleElement(el, !hasClass(el, this.clsOpen), async (el, show) => {
136
+ this.toggleElement(el, !hasClass(el, this.clsOpen), (el, show) => {
131
137
  toggleClass(el, this.clsOpen, show);
132
138
  attr($(this.$props.toggle, el), 'aria-expanded', show);
133
139
 
134
- const content = $(this.content, el);
135
-
136
140
  if (animate === false || !this.animation) {
137
- content.hidden = !show;
138
- hide(content, !show);
141
+ hide($(this.content, el), !show);
139
142
  return;
140
143
  }
141
144
 
142
- await toggleTransition(this)(content, show);
143
-
144
- if (show) {
145
- const toggle = $(this.$props.toggle, el);
146
- requestAnimationFrame(() => {
147
- if (!isInView(toggle)) {
148
- scrollIntoView(toggle, { offset: this.offset });
149
- }
150
- });
151
- }
145
+ return transition(el, show, this).then(() => {
146
+ if (show) {
147
+ const toggle = $(this.$props.toggle, el);
148
+ requestAnimationFrame(() => {
149
+ if (!isInView(toggle)) {
150
+ scrollIntoView(toggle, { offset: this.offset });
151
+ }
152
+ });
153
+ }
154
+ }, noop);
152
155
  });
153
156
  }
154
157
  },
@@ -158,3 +161,35 @@ export default {
158
161
  function hide(el, hide) {
159
162
  el && (el.hidden = hide);
160
163
  }
164
+
165
+ async function transition(el, show, { content, duration, velocity, transition }) {
166
+ content = el._wrapper?.firstElementChild || $(content, el);
167
+
168
+ if (!el._wrapper) {
169
+ el._wrapper = wrapAll(content, '<div>');
170
+ }
171
+
172
+ const wrapper = el._wrapper;
173
+ css(wrapper, 'overflow', 'hidden');
174
+ const currentHeight = toFloat(css(wrapper, 'height'));
175
+
176
+ await Transition.cancel(wrapper);
177
+ hide(content, false);
178
+
179
+ const endHeight =
180
+ toFloat(css(content, 'height')) +
181
+ toFloat(css(content, 'marginTop')) +
182
+ toFloat(css(content, 'marginBottom'));
183
+ const percent = currentHeight / endHeight;
184
+ duration = (velocity * endHeight + duration) * (show ? 1 - percent : percent);
185
+ css(wrapper, 'height', currentHeight);
186
+
187
+ await Transition.start(wrapper, { height: show ? endHeight : 0 }, duration, transition);
188
+
189
+ unwrap(content);
190
+ delete el._wrapper;
191
+
192
+ if (!show) {
193
+ hide(content, true);
194
+ }
195
+ }
@@ -33,30 +33,28 @@ export default {
33
33
 
34
34
  methods: {
35
35
  async close() {
36
- await this.toggleElement(this.$el, false, animate(this));
36
+ await this.toggleElement(this.$el, false, animate);
37
37
  this.$destroy(true);
38
38
  },
39
39
  },
40
40
  };
41
41
 
42
- function animate({ duration, transition, velocity }) {
43
- return (el) => {
44
- const height = toFloat(css(el, 'height'));
45
- css(el, 'height', height);
46
- return Transition.start(
47
- el,
48
- {
49
- height: 0,
50
- marginTop: 0,
51
- marginBottom: 0,
52
- paddingTop: 0,
53
- paddingBottom: 0,
54
- borderTop: 0,
55
- borderBottom: 0,
56
- opacity: 0,
57
- },
58
- velocity * height + duration,
59
- transition
60
- );
61
- };
42
+ function animate(el, show, { duration, transition, velocity }) {
43
+ const height = toFloat(css(el, 'height'));
44
+ css(el, 'height', height);
45
+ return Transition.start(
46
+ el,
47
+ {
48
+ height: 0,
49
+ marginTop: 0,
50
+ marginBottom: 0,
51
+ paddingTop: 0,
52
+ paddingBottom: 0,
53
+ borderTop: 0,
54
+ borderBottom: 0,
55
+ opacity: 0,
56
+ },
57
+ velocity * height + duration,
58
+ transition
59
+ );
62
60
  }
@@ -240,42 +240,41 @@ export default {
240
240
  );
241
241
  }
242
242
 
243
- return this.toggleElement(this.$el, true, animate(this));
243
+ return this.toggleElement(this.$el, true, animate);
244
244
  },
245
245
 
246
246
  hide() {
247
- return this.toggleElement(this.$el, false, animate(this));
247
+ return this.toggleElement(this.$el, false, animate);
248
248
  },
249
249
  },
250
250
  };
251
251
 
252
- function animate({ transitionElement, _toggle }) {
253
- return (el, show) =>
254
- new Promise((resolve, reject) =>
255
- once(el, 'show hide', () => {
256
- el._reject?.();
257
- el._reject = reject;
258
-
259
- _toggle(el, show);
260
-
261
- const off = once(
262
- transitionElement,
263
- 'transitionstart',
264
- () => {
265
- once(transitionElement, 'transitionend transitioncancel', resolve, {
266
- self: true,
267
- });
268
- clearTimeout(timer);
269
- },
270
- { self: true }
271
- );
272
-
273
- const timer = setTimeout(() => {
274
- off();
275
- resolve();
276
- }, toMs(css(transitionElement, 'transitionDuration')));
277
- })
278
- ).then(() => delete el._reject);
252
+ function animate(el, show, { transitionElement, _toggle }) {
253
+ return new Promise((resolve, reject) =>
254
+ once(el, 'show hide', () => {
255
+ el._reject?.();
256
+ el._reject = reject;
257
+
258
+ _toggle(el, show);
259
+
260
+ const off = once(
261
+ transitionElement,
262
+ 'transitionstart',
263
+ () => {
264
+ once(transitionElement, 'transitionend transitioncancel', resolve, {
265
+ self: true,
266
+ });
267
+ clearTimeout(timer);
268
+ },
269
+ { self: true }
270
+ );
271
+
272
+ const timer = setTimeout(() => {
273
+ off();
274
+ resolve();
275
+ }, toMs(css(transitionElement, 'transitionDuration')));
276
+ })
277
+ ).then(() => delete el._reject);
279
278
  }
280
279
 
281
280
  function toMs(time) {
@@ -67,11 +67,11 @@ export default {
67
67
  isFunction(animate)
68
68
  ? animate
69
69
  : animate === false || !this.hasAnimation
70
- ? toggleInstant(this)
70
+ ? toggleInstant
71
71
  : this.hasTransition
72
- ? toggleTransition(this)
73
- : toggleAnimation(this)
74
- )(el, show);
72
+ ? toggleTransition
73
+ : toggleAnimation
74
+ )(el, show, this);
75
75
 
76
76
  const cls = show ? this.clsEnter : this.clsLeave;
77
77
 
@@ -131,16 +131,18 @@ export default {
131
131
  },
132
132
  };
133
133
 
134
- function toggleInstant({ _toggle }) {
135
- return (el, show) => {
136
- Animation.cancel(el);
137
- Transition.cancel(el);
138
- return _toggle(el, show);
139
- };
134
+ function toggleInstant(el, show, { _toggle }) {
135
+ Animation.cancel(el);
136
+ Transition.cancel(el);
137
+ return _toggle(el, show);
140
138
  }
141
139
 
142
- export function toggleTransition(cmp) {
143
- const [mode = 'reveal', startProp = 'top'] = cmp.animation[0]?.split('-') || [];
140
+ export async function toggleTransition(
141
+ el,
142
+ show,
143
+ { animation, duration, velocity, transition, _toggle }
144
+ ) {
145
+ const [mode = 'reveal', startProp = 'top'] = animation[0]?.split('-') || [];
144
146
 
145
147
  const dirs = [
146
148
  ['left', 'right'],
@@ -153,111 +155,105 @@ export function toggleTransition(cmp) {
153
155
  const marginProp = `margin-${dir[0]}`;
154
156
  const marginStartProp = `margin-${startProp}`;
155
157
 
156
- return async (el, show) => {
157
- let { duration, velocity, transition, _toggle } = cmp;
158
-
159
- let currentDim = dimensions(el)[dimProp];
160
-
161
- const inProgress = Transition.inProgress(el);
162
- await Transition.cancel(el);
163
-
164
- if (show) {
165
- _toggle(el, true);
166
- }
167
-
168
- const prevProps = Object.fromEntries(
169
- [
170
- 'padding',
171
- 'border',
172
- 'width',
173
- 'height',
174
- 'minWidth',
175
- 'minHeight',
176
- 'overflowY',
177
- 'overflowX',
178
- marginProp,
179
- marginStartProp,
180
- ].map((key) => [key, el.style[key]])
181
- );
182
-
183
- const dim = dimensions(el);
184
- const currentMargin = toFloat(css(el, marginProp));
185
- const marginStart = toFloat(css(el, marginStartProp));
186
- const endDim = dim[dimProp] + marginStart;
187
-
188
- if (!inProgress && !show) {
189
- currentDim += marginStart;
190
- }
191
-
192
- const [wrapper] = wrapInner(el, '<div>');
193
- css(wrapper, {
194
- boxSizing: 'border-box',
195
- height: dim.height,
196
- width: dim.width,
197
- ...css(el, [
198
- 'overflow',
199
- 'padding',
200
- 'borderTop',
201
- 'borderRight',
202
- 'borderBottom',
203
- 'borderLeft',
204
- 'borderImage',
205
- marginStartProp,
206
- ]),
207
- });
208
-
209
- css(el, {
210
- padding: 0,
211
- border: 0,
212
- minWidth: 0,
213
- minHeight: 0,
214
- [marginStartProp]: 0,
215
- width: dim.width,
216
- height: dim.height,
217
- overflow: 'hidden',
218
- [dimProp]: currentDim,
219
- });
220
-
221
- const percent = currentDim / endDim;
222
- duration = (velocity * endDim + duration) * (show ? 1 - percent : percent);
223
- const endProps = { [dimProp]: show ? endDim : 0 };
224
-
225
- if (end) {
226
- css(el, marginProp, endDim - currentDim + currentMargin);
227
- endProps[marginProp] = show ? currentMargin : endDim + currentMargin;
158
+ let currentDim = dimensions(el)[dimProp];
159
+
160
+ const inProgress = Transition.inProgress(el);
161
+ await Transition.cancel(el);
162
+
163
+ if (show) {
164
+ _toggle(el, true);
165
+ }
166
+
167
+ const prevProps = Object.fromEntries(
168
+ [
169
+ 'padding',
170
+ 'border',
171
+ 'width',
172
+ 'height',
173
+ 'minWidth',
174
+ 'minHeight',
175
+ 'overflowY',
176
+ 'overflowX',
177
+ marginProp,
178
+ marginStartProp,
179
+ ].map((key) => [key, el.style[key]])
180
+ );
181
+
182
+ const dim = dimensions(el);
183
+ const currentMargin = toFloat(css(el, marginProp));
184
+ const marginStart = toFloat(css(el, marginStartProp));
185
+ const endDim = dim[dimProp] + marginStart;
186
+
187
+ if (!inProgress && !show) {
188
+ currentDim += marginStart;
189
+ }
190
+
191
+ const [wrapper] = wrapInner(el, '<div>');
192
+ css(wrapper, {
193
+ boxSizing: 'border-box',
194
+ height: dim.height,
195
+ width: dim.width,
196
+ ...css(el, [
197
+ 'overflow',
198
+ 'padding',
199
+ 'borderTop',
200
+ 'borderRight',
201
+ 'borderBottom',
202
+ 'borderLeft',
203
+ 'borderImage',
204
+ marginStartProp,
205
+ ]),
206
+ });
207
+
208
+ css(el, {
209
+ padding: 0,
210
+ border: 0,
211
+ minWidth: 0,
212
+ minHeight: 0,
213
+ [marginStartProp]: 0,
214
+ width: dim.width,
215
+ height: dim.height,
216
+ overflow: 'hidden',
217
+ [dimProp]: currentDim,
218
+ });
219
+
220
+ const percent = currentDim / endDim;
221
+ duration = (velocity * endDim + duration) * (show ? 1 - percent : percent);
222
+ const endProps = { [dimProp]: show ? endDim : 0 };
223
+
224
+ if (end) {
225
+ css(el, marginProp, endDim - currentDim + currentMargin);
226
+ endProps[marginProp] = show ? currentMargin : endDim + currentMargin;
227
+ }
228
+
229
+ if (!end ^ (mode === 'reveal')) {
230
+ css(wrapper, marginProp, -endDim + currentDim);
231
+ Transition.start(wrapper, { [marginProp]: show ? 0 : -endDim }, duration, transition);
232
+ }
233
+
234
+ try {
235
+ await Transition.start(el, endProps, duration, transition);
236
+ } finally {
237
+ css(el, prevProps);
238
+ unwrap(wrapper.firstChild);
239
+
240
+ if (!show) {
241
+ _toggle(el, false);
228
242
  }
229
-
230
- if (!end ^ (mode === 'reveal')) {
231
- css(wrapper, marginProp, -endDim + currentDim);
232
- Transition.start(wrapper, { [marginProp]: show ? 0 : -endDim }, duration, transition);
233
- }
234
-
235
- try {
236
- await Transition.start(el, endProps, duration, transition);
237
- } finally {
238
- css(el, prevProps);
239
- unwrap(wrapper.firstChild);
240
-
241
- if (!show) {
242
- _toggle(el, false);
243
- }
244
- }
245
- };
243
+ }
246
244
  }
247
245
 
248
- function toggleAnimation(cmp) {
249
- return (el, show) => {
250
- Animation.cancel(el);
246
+ function toggleAnimation(el, show, cmp) {
247
+ Animation.cancel(el);
251
248
 
252
- const { animation, duration, _toggle } = cmp;
249
+ const { animation, duration, _toggle } = cmp;
253
250
 
254
- if (show) {
255
- _toggle(el, true);
256
- return Animation.in(el, animation[0], duration, cmp.origin);
257
- }
251
+ if (show) {
252
+ _toggle(el, true);
253
+ return Animation.in(el, animation[0], duration, cmp.origin);
254
+ }
258
255
 
259
- return Animation.out(el, animation[1] || animation[0], duration, cmp.origin).then(() =>
260
- _toggle(el, false)
261
- );
262
- };
256
+ return Animation.out(el, animation[1] || animation[0], duration, cmp.origin).then(() =>
257
+ _toggle(el, false)
258
+ );
263
259
  }
@@ -191,7 +191,7 @@
191
191
  <td><code>animation</code></td>
192
192
  <td>Boolean</td>
193
193
  <td>true</td>
194
- <td>Space-separated names of animations. Comma-separated for animation out.</td>
194
+ <td>Reveal item directly or with a transition. </td>
195
195
  </tr>
196
196
  <tr>
197
197
  <td><code>duration</code></td>