uikit 3.11.2-dev.3dfa2c50b → 3.11.2-dev.45194f70c

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 (147) hide show
  1. package/CHANGELOG.md +40 -19
  2. package/dist/css/uikit-core-rtl.css +86 -185
  3. package/dist/css/uikit-core-rtl.min.css +1 -1
  4. package/dist/css/uikit-core.css +86 -185
  5. package/dist/css/uikit-core.min.css +1 -1
  6. package/dist/css/uikit-rtl.css +88 -191
  7. package/dist/css/uikit-rtl.min.css +1 -1
  8. package/dist/css/uikit.css +88 -191
  9. package/dist/css/uikit.min.css +1 -1
  10. package/dist/js/components/countdown.js +3 -3
  11. package/dist/js/components/countdown.min.js +1 -1
  12. package/dist/js/components/filter.js +6 -8
  13. package/dist/js/components/filter.min.js +1 -1
  14. package/dist/js/components/lightbox-panel.js +29 -68
  15. package/dist/js/components/lightbox-panel.min.js +1 -1
  16. package/dist/js/components/lightbox.js +30 -70
  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 +115 -78
  21. package/dist/js/components/parallax.min.js +1 -1
  22. package/dist/js/components/slider-parallax.js +115 -78
  23. package/dist/js/components/slider-parallax.min.js +1 -1
  24. package/dist/js/components/slider.js +79 -58
  25. package/dist/js/components/slider.min.js +1 -1
  26. package/dist/js/components/slideshow-parallax.js +115 -78
  27. package/dist/js/components/slideshow-parallax.min.js +1 -1
  28. package/dist/js/components/slideshow.js +35 -29
  29. package/dist/js/components/slideshow.min.js +1 -1
  30. package/dist/js/components/sortable.js +5 -7
  31. package/dist/js/components/sortable.min.js +1 -1
  32. package/dist/js/components/tooltip.js +2 -2
  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 +408 -326
  37. package/dist/js/uikit-core.min.js +1 -1
  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 +646 -528
  41. package/dist/js/uikit.min.js +1 -1
  42. package/package.json +1 -1
  43. package/src/js/api/component.js +2 -11
  44. package/src/js/api/hooks.js +3 -3
  45. package/src/js/api/state.js +34 -1
  46. package/src/js/components/countdown.js +2 -2
  47. package/src/js/components/filter.js +2 -3
  48. package/src/js/components/internal/lightbox-animations.js +4 -3
  49. package/src/js/components/internal/slider-preload.js +18 -0
  50. package/src/js/components/internal/slideshow-animations.js +4 -3
  51. package/src/js/components/lightbox-panel.js +34 -58
  52. package/src/js/components/lightbox.js +1 -2
  53. package/src/js/components/slider.js +60 -43
  54. package/src/js/components/slideshow.js +8 -1
  55. package/src/js/components/sortable.js +1 -1
  56. package/src/js/core/accordion.js +6 -1
  57. package/src/js/core/alert.js +1 -2
  58. package/src/js/core/core.js +2 -21
  59. package/src/js/core/cover.js +5 -1
  60. package/src/js/core/drop.js +3 -1
  61. package/src/js/core/form-custom.js +2 -2
  62. package/src/js/core/height-viewport.js +3 -0
  63. package/src/js/core/icon.js +13 -6
  64. package/src/js/core/img.js +131 -122
  65. package/src/js/core/modal.js +1 -2
  66. package/src/js/core/navbar.js +3 -3
  67. package/src/js/core/sticky.js +51 -57
  68. package/src/js/core/svg.js +10 -6
  69. package/src/js/core/switcher.js +6 -1
  70. package/src/js/core/toggle.js +5 -2
  71. package/src/js/core/video.js +13 -1
  72. package/src/js/mixin/internal/animate-slide.js +9 -12
  73. package/src/js/mixin/lazyload.js +16 -0
  74. package/src/js/mixin/parallax.js +116 -79
  75. package/src/js/mixin/slider.js +8 -22
  76. package/src/js/mixin/slideshow.js +2 -6
  77. package/src/js/mixin/togglable.js +1 -2
  78. package/src/js/util/ajax.js +15 -14
  79. package/src/js/util/animation.js +7 -12
  80. package/src/js/util/dimensions.js +4 -4
  81. package/src/js/util/dom.js +37 -31
  82. package/src/js/util/index.js +1 -0
  83. package/src/js/util/lang.js +7 -6
  84. package/src/js/util/observer.js +36 -0
  85. package/src/js/util/options.js +2 -11
  86. package/src/js/util/player.js +5 -4
  87. package/src/js/util/selector.js +12 -18
  88. package/src/js/util/style.js +4 -4
  89. package/src/less/components/base.less +10 -33
  90. package/src/less/components/form-range.less +48 -95
  91. package/src/less/components/form.less +0 -1
  92. package/src/less/components/height.less +3 -0
  93. package/src/less/components/leader.less +0 -1
  94. package/src/less/components/lightbox.less +0 -1
  95. package/src/less/components/modal.less +3 -7
  96. package/src/less/components/progress.less +14 -36
  97. package/src/less/components/slider.less +0 -3
  98. package/src/less/components/slideshow.less +0 -3
  99. package/src/less/components/text.less +16 -32
  100. package/src/scss/components/base.scss +10 -33
  101. package/src/scss/components/form-range.scss +48 -95
  102. package/src/scss/components/form.scss +0 -1
  103. package/src/scss/components/height.scss +3 -0
  104. package/src/scss/components/leader.scss +0 -1
  105. package/src/scss/components/lightbox.scss +0 -1
  106. package/src/scss/components/modal.scss +3 -7
  107. package/src/scss/components/progress.scss +14 -36
  108. package/src/scss/components/slider.scss +0 -3
  109. package/src/scss/components/slideshow.scss +0 -3
  110. package/src/scss/components/text.scss +16 -32
  111. package/src/scss/mixins-theme.scss +1 -1
  112. package/src/scss/mixins.scss +1 -1
  113. package/src/scss/variables-theme.scss +3 -3
  114. package/src/scss/variables.scss +3 -3
  115. package/tests/align.html +10 -10
  116. package/tests/animation.html +2 -2
  117. package/tests/article.html +2 -2
  118. package/tests/base.html +3 -3
  119. package/tests/card.html +10 -10
  120. package/tests/column.html +3 -3
  121. package/tests/comment.html +9 -9
  122. package/tests/dotnav.html +3 -3
  123. package/tests/image.html +296 -64
  124. package/tests/images/image-type.avif +0 -0
  125. package/tests/images/image-type.jpeg +0 -0
  126. package/tests/images/image-type.webp +0 -0
  127. package/tests/index.html +8 -8
  128. package/tests/lightbox.html +10 -10
  129. package/tests/marker.html +2 -2
  130. package/tests/modal.html +8 -9
  131. package/tests/navbar.html +2 -2
  132. package/tests/overlay.html +7 -7
  133. package/tests/parallax.html +16 -7
  134. package/tests/position.html +12 -12
  135. package/tests/slidenav.html +12 -12
  136. package/tests/slider.html +20 -20
  137. package/tests/sortable.html +1 -1
  138. package/tests/sticky-parallax.html +56 -71
  139. package/tests/svg.html +6 -6
  140. package/tests/table.html +11 -11
  141. package/tests/thumbnav.html +12 -12
  142. package/tests/transition.html +30 -30
  143. package/tests/utility.html +50 -33
  144. package/tests/video.html +1 -1
  145. package/tests/width.html +1 -1
  146. package/src/js/util/promise.js +0 -0
  147. package/tests/images/animated.gif +0 -0
@@ -10,13 +10,12 @@ import {
10
10
  dimensions,
11
11
  fastdom,
12
12
  height as getHeight,
13
+ offset as getOffset,
13
14
  getScrollingElement,
14
15
  hasClass,
15
- isNumeric,
16
16
  isString,
17
17
  isVisible,
18
18
  noop,
19
- offset,
20
19
  offsetPosition,
21
20
  parent,
22
21
  query,
@@ -29,6 +28,7 @@ import {
29
28
  toPx,
30
29
  trigger,
31
30
  within,
31
+ intersectRect,
32
32
  } from 'uikit-util';
33
33
 
34
34
  export default {
@@ -67,21 +67,6 @@ export default {
67
67
  },
68
68
 
69
69
  computed: {
70
- position({ position }, $el) {
71
- return position === 'auto'
72
- ? (this.isFixed ? this.placeholder : $el).offsetHeight > getHeight(window)
73
- ? 'bottom'
74
- : 'top'
75
- : position;
76
- },
77
-
78
- offset({ offset }, $el) {
79
- if (this.position === 'bottom') {
80
- offset += '+100vh-100%';
81
- }
82
- return toPx(offset, 'height', $el);
83
- },
84
-
85
70
  selTarget({ selTarget }, $el) {
86
71
  return (selTarget && $(selTarget, $el)) || $el;
87
72
  },
@@ -134,34 +119,29 @@ export default {
134
119
  return window;
135
120
  },
136
121
 
122
+ filter() {
123
+ return this.targetOffset !== false;
124
+ },
125
+
137
126
  handler() {
138
- if (!(this.targetOffset !== false && location.hash && scrollTop(window) > 0)) {
127
+ if (!location.hash || scrollTop(window) === 0) {
139
128
  return;
140
129
  }
141
130
 
142
- const target = $(location.hash);
143
-
144
- if (target) {
145
- fastdom.read(() => {
146
- const { top } = offset(target);
147
- const elTop = offset(this.$el).top;
148
- const elHeight = this.$el.offsetHeight;
149
-
150
- if (
151
- this.isFixed &&
152
- elTop + elHeight >= top &&
153
- elTop <= top + target.offsetHeight
154
- ) {
155
- scrollTop(
156
- window,
157
- top -
158
- elHeight -
159
- (isNumeric(this.targetOffset) ? this.targetOffset : 0) -
160
- this.offset
161
- );
162
- }
163
- });
164
- }
131
+ fastdom.read(() => {
132
+ const targetOffset = getOffset($(location.hash));
133
+ const elOffset = getOffset(this.$el);
134
+
135
+ if (this.isFixed && intersectRect(targetOffset, elOffset)) {
136
+ scrollTop(
137
+ window,
138
+ targetOffset.top -
139
+ elOffset.height -
140
+ toPx(this.targetOffset, 'height') -
141
+ toPx(this.offset, 'height')
142
+ );
143
+ }
144
+ });
165
145
  },
166
146
  },
167
147
  ],
@@ -177,35 +157,49 @@ export default {
177
157
 
178
158
  const hide = this.isActive && types.has('resize');
179
159
  if (hide) {
160
+ css(this.selTarget, 'transition', '0s');
180
161
  this.hide();
181
162
  }
182
163
 
183
164
  if (!this.isActive) {
184
- height = this.$el.offsetHeight;
165
+ height = getOffset(this.$el).height;
185
166
  margin = css(this.$el, 'margin');
186
167
  }
187
168
 
188
169
  if (hide) {
189
170
  this.show();
171
+ fastdom.write(() => css(this.selTarget, 'transition', ''));
190
172
  }
191
173
 
192
- const overflow = Math.max(0, height + this.offset - getHeight(window));
193
-
194
174
  const referenceElement = this.isFixed ? this.placeholder : this.$el;
195
- const topOffset = offset(referenceElement).top;
196
- const offsetParentTop = offset(referenceElement.offsetParent).top;
175
+ const windowHeight = getHeight(window);
176
+
177
+ let position = this.position;
178
+ if (position === 'auto' && height > windowHeight) {
179
+ position = 'bottom';
180
+ }
181
+
182
+ let offset = toPx(this.offset, 'height', referenceElement);
183
+ if (position === 'bottom') {
184
+ offset += windowHeight - height;
185
+ }
186
+
187
+ const overflow = Math.max(0, height + offset - windowHeight);
188
+ const topOffset = getOffset(referenceElement).top;
189
+ const offsetParentTop = getOffset(referenceElement.offsetParent).top;
197
190
 
198
191
  const top = parseProp(this.top, this.$el, topOffset);
199
192
  const bottom = parseProp(this.bottom, this.$el, topOffset + height, true);
200
193
 
201
- const start = Math.max(top, topOffset) - this.offset;
194
+ const start = Math.max(top, topOffset) - offset;
202
195
  const end = bottom
203
- ? bottom - this.$el.offsetHeight + overflow - this.offset
204
- : getScrollingElement(this.$el).scrollHeight - getHeight(window);
196
+ ? bottom - getOffset(this.$el).height + overflow - offset
197
+ : getScrollingElement(this.$el).scrollHeight - windowHeight;
205
198
 
206
199
  return {
207
200
  start,
208
201
  end,
202
+ offset,
209
203
  overflow,
210
204
  topOffset,
211
205
  offsetParentTop,
@@ -213,7 +207,7 @@ export default {
213
207
  margin,
214
208
  width: dimensions(isVisible(this.widthElement) ? this.widthElement : this.$el)
215
209
  .width,
216
- top: offsetPosition(this.placeholder)[0],
210
+ top: offsetPosition(referenceElement)[0],
217
211
  };
218
212
  },
219
213
 
@@ -322,7 +316,7 @@ export default {
322
316
  }
323
317
  } else if (this.isFixed) {
324
318
  this.update();
325
- } else if (this.animation) {
319
+ } else if (this.animation && scroll > topOffset) {
326
320
  Animation.cancel(this.$el);
327
321
  this.show();
328
322
  Animation.in(this.$el, this.animation).catch(noop);
@@ -350,33 +344,33 @@ export default {
350
344
  },
351
345
 
352
346
  update() {
353
- const {
347
+ let {
354
348
  width,
355
349
  scroll = 0,
356
350
  overflow,
357
351
  overflowScroll = 0,
358
352
  start,
359
353
  end,
354
+ offset,
360
355
  topOffset,
361
356
  height,
362
357
  offsetParentTop,
363
358
  } = this._data;
364
359
  const active = start !== 0 || scroll > start;
365
- let top = this.offset;
366
360
  let position = 'fixed';
367
361
 
368
362
  if (scroll > end) {
369
- top = end + this.offset - offsetParentTop;
363
+ offset += end - offsetParentTop;
370
364
  position = 'absolute';
371
365
  }
372
366
 
373
367
  if (overflow) {
374
- top -= overflowScroll;
368
+ offset -= overflowScroll;
375
369
  }
376
370
 
377
371
  css(this.$el, {
378
372
  position,
379
- top: `${top}px`,
373
+ top: `${offset}px`,
380
374
  width,
381
375
  });
382
376
 
@@ -397,7 +391,7 @@ function parseProp(value, el, propOffset, padding) {
397
391
  } else {
398
392
  const refElement = value === true ? parent(el) : query(value, el);
399
393
  return (
400
- offset(refElement).bottom -
394
+ getOffset(refElement).bottom -
401
395
  (padding && refElement && within(el, refElement)
402
396
  ? toFloat(css(refElement, 'paddingBottom'))
403
397
  : 0)
@@ -5,10 +5,12 @@ import {
5
5
  append,
6
6
  attr,
7
7
  includes,
8
+ isTag,
8
9
  isVisible,
9
10
  isVoidElement,
10
11
  memoize,
11
12
  noop,
13
+ once,
12
14
  remove,
13
15
  removeAttr,
14
16
  startsWith,
@@ -94,6 +96,12 @@ export default {
94
96
 
95
97
  methods: {
96
98
  async getSvg() {
99
+ if (isTag(this.$el, 'img') && !this.$el.complete && this.$el.loading === 'lazy') {
100
+ return new Promise((resolve) =>
101
+ once(this.$el, 'load', () => resolve(this.getSvg()))
102
+ );
103
+ }
104
+
97
105
  return parseSVG(await loadSVG(this.src), this.icon) || Promise.reject('SVG not found.');
98
106
  },
99
107
 
@@ -193,7 +201,7 @@ export function getMaxPathLength(el) {
193
201
  }
194
202
 
195
203
  function insertSVG(el, root) {
196
- if (isVoidElement(root) || root.tagName === 'CANVAS') {
204
+ if (isVoidElement(root) || isTag(root, 'canvas')) {
197
205
  root.hidden = true;
198
206
 
199
207
  const next = root.nextElementSibling;
@@ -205,11 +213,7 @@ function insertSVG(el, root) {
205
213
  }
206
214
 
207
215
  function equals(el, other) {
208
- return isSVG(el) && isSVG(other) && innerHTML(el) === innerHTML(other);
209
- }
210
-
211
- function isSVG(el) {
212
- return el?.tagName === 'svg';
216
+ return isTag(el, 'svg') && isTag(other, 'svg') && innerHTML(el) === innerHTML(other);
213
217
  }
214
218
 
215
219
  function innerHTML(el) {
@@ -1,3 +1,4 @@
1
+ import Lazyload from '../mixin/lazyload';
1
2
  import Togglable from '../mixin/togglable';
2
3
  import {
3
4
  $$,
@@ -17,7 +18,7 @@ import {
17
18
  } from 'uikit-util';
18
19
 
19
20
  export default {
20
- mixins: [Togglable],
21
+ mixins: [Lazyload, Togglable],
21
22
 
22
23
  args: 'connect',
23
24
 
@@ -81,6 +82,10 @@ export default {
81
82
  },
82
83
  },
83
84
 
85
+ connected() {
86
+ this.lazyload(this.$el, this.connects);
87
+ },
88
+
84
89
  events: [
85
90
  {
86
91
  name: 'click',
@@ -1,3 +1,4 @@
1
+ import Lazyload from '../mixin/lazyload';
1
2
  import Media from '../mixin/media';
2
3
  import Togglable from '../mixin/togglable';
3
4
  import {
@@ -7,6 +8,7 @@ import {
7
8
  includes,
8
9
  isBoolean,
9
10
  isFocusable,
11
+ isTag,
10
12
  isTouch,
11
13
  matches,
12
14
  once,
@@ -21,7 +23,7 @@ import {
21
23
  const KEY_SPACE = 32;
22
24
 
23
25
  export default {
24
- mixins: [Media, Togglable],
26
+ mixins: [Lazyload, Media, Togglable],
25
27
 
26
28
  args: 'target',
27
29
 
@@ -43,6 +45,7 @@ export default {
43
45
  if (!includes(this.mode, 'media') && !isFocusable(this.$el)) {
44
46
  attr(this.$el, 'tabindex', '0');
45
47
  }
48
+ this.lazyload(this.$el, this.target);
46
49
  },
47
50
 
48
51
  computed: {
@@ -134,7 +137,7 @@ export default {
134
137
  name: 'keydown',
135
138
 
136
139
  filter() {
137
- return includes(this.mode, 'click') && this.$el.tagName !== 'INPUT';
140
+ return includes(this.mode, 'click') && !isTag(this.$el, 'input');
138
141
  },
139
142
 
140
143
  handler(e) {
@@ -1,4 +1,14 @@
1
- import { css, hasAttr, isInView, isVideo, isVisible, mute, pause, play } from 'uikit-util';
1
+ import {
2
+ css,
3
+ hasAttr,
4
+ isInView,
5
+ isVideo,
6
+ isVisible,
7
+ mute,
8
+ observeIntersection,
9
+ pause,
10
+ play,
11
+ } from 'uikit-util';
2
12
 
3
13
  export default {
4
14
  args: 'autoplay',
@@ -27,6 +37,8 @@ export default {
27
37
  if (this.automute) {
28
38
  mute(this.$el);
29
39
  }
40
+
41
+ this.registerObserver(observeIntersection(this.$el, () => this.$emit('resize')));
30
42
  },
31
43
 
32
44
  update: {
@@ -1,5 +1,4 @@
1
1
  import {
2
- assign,
3
2
  children,
4
3
  css,
5
4
  fastdom,
@@ -44,7 +43,7 @@ export default function (action, target, duration) {
44
43
 
45
44
  // Reset to previous state
46
45
  nodes.forEach((el, i) => propsFrom[i] && css(el, propsFrom[i]));
47
- css(target, assign({ display: 'block' }, targetProps));
46
+ css(target, { display: 'block', ...targetProps });
48
47
 
49
48
  // Start transitions on next frame
50
49
  requestAnimationFrame(() => {
@@ -76,16 +75,14 @@ function getProps(el, opacity) {
76
75
  const zIndex = css(el, 'zIndex');
77
76
 
78
77
  return isVisible(el)
79
- ? assign(
80
- {
81
- display: '',
82
- opacity: opacity ? css(el, 'opacity') : '0',
83
- pointerEvents: 'none',
84
- position: 'absolute',
85
- zIndex: zIndex === 'auto' ? index(el) : zIndex,
86
- },
87
- getPositionWithMargin(el)
88
- )
78
+ ? {
79
+ display: '',
80
+ opacity: opacity ? css(el, 'opacity') : '0',
81
+ pointerEvents: 'none',
82
+ position: 'absolute',
83
+ zIndex: zIndex === 'auto' ? index(el) : zIndex,
84
+ ...getPositionWithMargin(el),
85
+ }
89
86
  : false;
90
87
  }
91
88
 
@@ -0,0 +1,16 @@
1
+ import { $$, isArray, observeIntersection, removeAttr } from 'uikit-util';
2
+
3
+ export default {
4
+ methods: {
5
+ lazyload(observeTargets = this.$el, targets = this.$el) {
6
+ this.registerObserver(
7
+ observeIntersection(observeTargets, (entries, observer) => {
8
+ for (const el of isArray(targets) ? targets : [targets]) {
9
+ $$('img[loading="lazy"]', el).forEach((el) => removeAttr(el, 'loading'));
10
+ }
11
+ observer.disconnect();
12
+ })
13
+ );
14
+ },
15
+ },
16
+ };