uikit 3.13.8-dev.f030a8b39 → 3.13.9

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 (75) hide show
  1. package/CHANGELOG.md +13 -6
  2. package/dist/css/uikit-core-rtl.css +5 -34
  3. package/dist/css/uikit-core-rtl.min.css +1 -1
  4. package/dist/css/uikit-core.css +5 -34
  5. package/dist/css/uikit-core.min.css +1 -1
  6. package/dist/css/uikit-rtl.css +3 -34
  7. package/dist/css/uikit-rtl.min.css +1 -1
  8. package/dist/css/uikit.css +3 -34
  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 +1 -1
  13. package/dist/js/components/filter.min.js +1 -1
  14. package/dist/js/components/lightbox-panel.js +5 -2
  15. package/dist/js/components/lightbox-panel.min.js +1 -1
  16. package/dist/js/components/lightbox.js +5 -2
  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 +29 -59
  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 +219 -205
  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 +227 -243
  41. package/dist/js/uikit.min.js +1 -1
  42. package/package.json +1 -1
  43. package/src/js/api/hooks.js +1 -1
  44. package/src/js/components/lightbox-panel.js +4 -1
  45. package/src/js/components/tooltip.js +3 -38
  46. package/src/js/core/accordion.js +1 -1
  47. package/src/js/core/drop.js +12 -9
  48. package/src/js/core/height-match.js +8 -17
  49. package/src/js/core/margin.js +1 -1
  50. package/src/js/core/navbar.js +1 -3
  51. package/src/js/core/scrollspy.js +45 -26
  52. package/src/js/core/sticky.js +2 -2
  53. package/src/js/core/toggle.js +1 -1
  54. package/src/js/mixin/position.js +24 -22
  55. package/src/js/util/position.js +129 -128
  56. package/src/less/components/dropdown.less +1 -11
  57. package/src/less/components/nav.less +0 -22
  58. package/src/less/components/navbar.less +2 -22
  59. package/src/less/theme/dropdown.less +0 -2
  60. package/src/less/theme/nav.less +0 -4
  61. package/src/less/theme/navbar.less +0 -2
  62. package/src/scss/components/dropdown.scss +1 -11
  63. package/src/scss/components/nav.scss +0 -22
  64. package/src/scss/components/navbar.scss +2 -22
  65. package/src/scss/mixins-theme.scss +0 -4
  66. package/src/scss/mixins.scss +0 -4
  67. package/src/scss/theme/dropdown.scss +0 -2
  68. package/src/scss/theme/nav.scss +0 -4
  69. package/src/scss/theme/navbar.scss +0 -2
  70. package/src/scss/variables-theme.scss +1 -5
  71. package/src/scss/variables.scss +1 -5
  72. package/tests/dropdown.html +2 -16
  73. package/tests/nav.html +0 -27
  74. package/tests/navbar.html +4 -18
  75. package/tests/position.html +39 -38
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.13.8-dev.f030a8b39",
5
+ "version": "3.13.9",
6
6
  "main": "dist/js/uikit.js",
7
7
  "style": "dist/css/uikit.css",
8
8
  "sideEffects": [
@@ -105,7 +105,7 @@ export default function (UIkit) {
105
105
  const {
106
106
  $options: { computed },
107
107
  } = this;
108
- const values = { ...this._computed };
108
+ const values = { ...(initial ? {} : this._computed) };
109
109
  this._computed = {};
110
110
 
111
111
  for (const key in computed) {
@@ -215,7 +215,10 @@ export default {
215
215
  };
216
216
 
217
217
  // Image
218
- if (type === 'image' || src.match(/\.(avif|jpe?g|a?png|gif|svg|webp)($|\?)/i)) {
218
+ if (
219
+ type === 'image' ||
220
+ src.match(/\.(avif|jpe?g|jfif|a?png|gif|svg|webp)($|\?)/i)
221
+ ) {
219
222
  try {
220
223
  const { width, height } = await getImage(src, attrs.srcset, attrs.size);
221
224
  this.setItem(item, createEl('img', { src, width, height, alt, ...attrs }));
@@ -6,11 +6,9 @@ import {
6
6
  attr,
7
7
  flipPosition,
8
8
  hasAttr,
9
- includes,
10
9
  isFocusable,
11
10
  isTouch,
12
11
  matches,
13
- offset,
14
12
  on,
15
13
  once,
16
14
  pointerDown,
@@ -106,12 +104,10 @@ export default {
106
104
 
107
105
  this.positionAt(this.tooltip, this.$el);
108
106
 
109
- const [dir, align] = getAlignment(this.tooltip, this.$el, this.pos);
110
-
111
107
  this.origin =
112
- this.axis === 'y'
113
- ? `${flipPosition(dir)}-${align}`
114
- : `${align}-${flipPosition(dir)}`;
108
+ this.getAxis() === 'y'
109
+ ? `${flipPosition(this.dir)}-${this.align}`
110
+ : `${this.align}-${flipPosition(this.dir)}`;
115
111
  });
116
112
 
117
113
  this.toggleElement(this.tooltip, true);
@@ -147,34 +143,3 @@ function makeFocusable(el) {
147
143
  attr(el, 'tabindex', '0');
148
144
  }
149
145
  }
150
-
151
- function getAlignment(el, target, [dir, align]) {
152
- const elOffset = offset(el);
153
- const targetOffset = offset(target);
154
- const properties = [
155
- ['left', 'right'],
156
- ['top', 'bottom'],
157
- ];
158
-
159
- for (const props of properties) {
160
- if (elOffset[props[0]] >= targetOffset[props[1]]) {
161
- dir = props[1];
162
- break;
163
- }
164
- if (elOffset[props[1]] <= targetOffset[props[0]]) {
165
- dir = props[0];
166
- break;
167
- }
168
- }
169
-
170
- const props = includes(properties[0], dir) ? properties[1] : properties[0];
171
- if (elOffset[props[0]] === targetOffset[props[0]]) {
172
- align = props[0];
173
- } else if (elOffset[props[1]] === targetOffset[props[1]]) {
174
- align = props[1];
175
- } else {
176
- align = 'center';
177
- }
178
-
179
- return [dir, align];
180
- }
@@ -48,7 +48,7 @@ export default {
48
48
  computed: {
49
49
  items: {
50
50
  get({ targets }, $el) {
51
- return $$(targets, $el);
51
+ return $$(targets, $el).filter((el) => $(this.content, el));
52
52
  },
53
53
 
54
54
  watch(items, prev) {
@@ -242,7 +242,13 @@ export default {
242
242
  this.hide(false);
243
243
  }
244
244
  }),
245
- on(window, 'resize', () => this.$emit('resize')),
245
+ on(window, 'resize', () => this.$emit()),
246
+ on(
247
+ document,
248
+ 'scroll',
249
+ ({ target }) => target.contains(this.$el) && this.$emit(),
250
+ true
251
+ ),
246
252
  ]) {
247
253
  once(this.$el, 'hide', handler, { self: true });
248
254
  }
@@ -283,8 +289,6 @@ export default {
283
289
  this.position();
284
290
  }
285
291
  },
286
-
287
- events: ['resize'],
288
292
  },
289
293
 
290
294
  methods: {
@@ -362,18 +366,17 @@ export default {
362
366
  const boundaryOffset = offset(boundary);
363
367
  const targetOffset = offset(this.target);
364
368
  const alignTo = this.boundaryAlign ? boundaryOffset : targetOffset;
365
- const prop = this.axis === 'y' ? 'width' : 'height';
366
-
367
- css(this.$el, `max-${prop}`, '');
368
369
 
369
370
  if (this.pos[1] === 'justify') {
371
+ const prop = this.getAxis() === 'y' ? 'width' : 'height';
370
372
  css(this.$el, prop, alignTo[prop]);
371
- } else if (this.$el.offsetWidth > boundaryOffset.width) {
373
+ } else if (
374
+ this.$el.offsetWidth >
375
+ Math.max(boundaryOffset.right - alignTo.left, alignTo.right - boundaryOffset.left)
376
+ ) {
372
377
  addClass(this.$el, `${this.clsDrop}-stack`);
373
378
  }
374
379
 
375
- css(this.$el, `max-${prop}`, boundaryOffset[prop]);
376
-
377
380
  this.positionAt(this.$el, this.boundaryAlign ? boundary : this.target, boundary);
378
381
  },
379
382
  },
@@ -1,6 +1,6 @@
1
1
  import Resize from '../mixin/resize';
2
2
  import { getRows } from './margin';
3
- import { $$, boxModelAdjust, css, dimensions, isVisible, toFloat } from 'uikit-util';
3
+ import { $$, boxModelAdjust, css, dimensions, isVisible } from 'uikit-util';
4
4
 
5
5
  export default {
6
6
  mixins: [Resize],
@@ -15,7 +15,6 @@ export default {
15
15
  data: {
16
16
  target: '> *',
17
17
  row: true,
18
- forceHeight: true,
19
18
  },
20
19
 
21
20
  computed: {
@@ -31,7 +30,7 @@ export default {
31
30
  },
32
31
 
33
32
  resizeTargets() {
34
- return this.elements;
33
+ return [this.$el, this.elements];
35
34
  },
36
35
 
37
36
  update: {
@@ -56,22 +55,14 @@ function match(elements) {
56
55
  return { heights: [''], elements };
57
56
  }
58
57
 
58
+ css(elements, 'minHeight', '');
59
59
  let heights = elements.map(getHeight);
60
- let max = Math.max(...heights);
61
- const hasMinHeight = elements.some((el) => el.style.minHeight);
62
- const hasShrunk = elements.some((el, i) => !el.style.minHeight && heights[i] < max);
63
-
64
- if (hasMinHeight && hasShrunk) {
65
- css(elements, 'minHeight', '');
66
- heights = elements.map(getHeight);
67
- max = Math.max(...heights);
68
- }
69
-
70
- heights = elements.map((el, i) =>
71
- heights[i] === max && toFloat(el.style.minHeight).toFixed(2) !== max.toFixed(2) ? '' : max
72
- );
60
+ const max = Math.max(...heights);
73
61
 
74
- return { heights, elements };
62
+ return {
63
+ heights: elements.map((el, i) => (heights[i].toFixed(2) === max.toFixed(2) ? '' : max)),
64
+ elements,
65
+ };
75
66
  }
76
67
 
77
68
  function getHeight(element) {
@@ -15,7 +15,7 @@ export default {
15
15
  },
16
16
 
17
17
  resizeTargets() {
18
- return this.$el.children;
18
+ return [this.$el, this.$el.children];
19
19
  },
20
20
 
21
21
  connected() {
@@ -61,8 +61,6 @@ export default {
61
61
  dropbar: false,
62
62
  dropbarAnchor: false,
63
63
  duration: 200,
64
- forceHeight: true,
65
- selMinHeight: navItem,
66
64
  container: false,
67
65
  },
68
66
 
@@ -299,7 +297,7 @@ export default {
299
297
  return this.dropbar;
300
298
  },
301
299
 
302
- handler(_, { $el, pos: [dir] = [] }) {
300
+ handler(_, { $el, dir }) {
303
301
  if (!hasClass($el, this.clsDrop)) {
304
302
  return;
305
303
  }
@@ -4,15 +4,15 @@ import {
4
4
  css,
5
5
  filter,
6
6
  data as getData,
7
- isInView,
7
+ observeIntersection,
8
8
  once,
9
9
  removeClass,
10
10
  removeClasses,
11
11
  toggleClass,
12
+ toPx,
12
13
  trigger,
13
14
  } from 'uikit-util';
14
15
 
15
- const stateKey = '_ukScrollspy';
16
16
  export default {
17
17
  mixins: [Scroll],
18
18
 
@@ -45,43 +45,64 @@ export default {
45
45
  return target ? $$(target, $el) : [$el];
46
46
  },
47
47
 
48
- watch(elements) {
48
+ watch(elements, prev) {
49
49
  if (this.hidden) {
50
50
  css(filter(elements, `:not(.${this.inViewClass})`), 'visibility', 'hidden');
51
51
  }
52
+
53
+ if (prev) {
54
+ this.$reset();
55
+ }
52
56
  },
53
57
 
54
58
  immediate: true,
55
59
  },
56
60
  },
57
61
 
62
+ connected() {
63
+ this._data.elements = new Map();
64
+ this.registerObserver(
65
+ observeIntersection(
66
+ this.elements,
67
+ (records) => {
68
+ const elements = this._data.elements;
69
+ for (const { target: el, isIntersecting } of records) {
70
+ if (!elements.has(el)) {
71
+ elements.set(el, {
72
+ cls: getData(el, 'uk-scrollspy-class') || this.cls,
73
+ });
74
+ }
75
+
76
+ const state = elements.get(el);
77
+ if (!this.repeat && state.show) {
78
+ continue;
79
+ }
80
+
81
+ state.show = isIntersecting;
82
+ }
83
+
84
+ this.$emit();
85
+ },
86
+ {
87
+ rootMargin: `${toPx(this.offsetTop, 'height') - 1}px ${
88
+ toPx(this.offsetLeft, 'width') - 1
89
+ }px`,
90
+ },
91
+ false
92
+ )
93
+ );
94
+ },
95
+
58
96
  disconnected() {
59
- for (const el of this.elements) {
60
- removeClass(el, this.inViewClass, el[stateKey]?.cls || '');
61
- delete el[stateKey];
97
+ for (const [el, state] of this._data.elements.entries()) {
98
+ removeClass(el, this.inViewClass, state?.cls || '');
62
99
  }
63
100
  },
64
101
 
65
102
  update: [
66
103
  {
67
- read() {
68
- for (const el of this.elements) {
69
- if (!el[stateKey]) {
70
- el[stateKey] = { cls: getData(el, 'uk-scrollspy-class') || this.cls };
71
- }
72
-
73
- if (!this.repeat && el[stateKey].show) {
74
- continue;
75
- }
76
-
77
- el[stateKey].show = isInView(el, this.offsetTop, this.offsetLeft);
78
- }
79
- },
80
-
81
104
  write(data) {
82
- for (const el of this.elements) {
83
- const state = el[stateKey];
84
-
105
+ for (const [el, state] of data.elements.entries()) {
85
106
  if (state.show && !state.inview && !state.queued) {
86
107
  state.queued = true;
87
108
 
@@ -99,14 +120,12 @@ export default {
99
120
  }
100
121
  }
101
122
  },
102
-
103
- events: ['scroll', 'resize'],
104
123
  },
105
124
  ],
106
125
 
107
126
  methods: {
108
127
  toggle(el, inview) {
109
- const state = el[stateKey];
128
+ const state = this._data.elements.get(el);
110
129
 
111
130
  state.off?.();
112
131
 
@@ -137,13 +137,13 @@ export default {
137
137
  return false;
138
138
  }
139
139
 
140
- const hide = this.isActive && types.has('resize');
140
+ const hide = this.active && types.has('resize');
141
141
  if (hide) {
142
142
  css(this.selTarget, 'transition', '0s');
143
143
  this.hide();
144
144
  }
145
145
 
146
- if (!this.isActive) {
146
+ if (!this.active) {
147
147
  height = getOffset(this.$el).height;
148
148
  margin = css(this.$el, 'margin');
149
149
  }
@@ -124,7 +124,7 @@ export default {
124
124
  }
125
125
 
126
126
  // Skip if state does not change e.g. hover + focus received
127
- if (this._showState && show === (expanded !== this._showState)) {
127
+ if (this._showState && show && expanded !== this._showState) {
128
128
  // Ensure reset if state has changed through click
129
129
  if (!show) {
130
130
  this._showState = null;
@@ -3,7 +3,6 @@ import {
3
3
  flipPosition,
4
4
  getCssVar,
5
5
  offset as getOffset,
6
- includes,
7
6
  isNumeric,
8
7
  isRtl,
9
8
  positionAt,
@@ -25,42 +24,45 @@ export default {
25
24
 
26
25
  connected() {
27
26
  this.pos = this.$props.pos.split('-').concat('center').slice(0, 2);
28
- this.axis = includes(['top', 'bottom'], this.pos[0]) ? 'y' : 'x';
27
+ this.dir = this.pos[0];
28
+ this.align = this.pos[1];
29
29
  },
30
30
 
31
31
  methods: {
32
32
  positionAt(element, target, boundary) {
33
- const [dir, align] = this.pos;
33
+ const axis = this.getAxis();
34
+ const dir = this.pos[0];
35
+ const align = this.pos[1];
34
36
 
35
37
  let { offset } = this;
36
38
  if (!isNumeric(offset)) {
37
39
  const node = $(offset);
38
40
  offset = node
39
- ? getOffset(node)[this.axis === 'x' ? 'left' : 'top'] -
40
- getOffset(target)[this.axis === 'x' ? 'right' : 'bottom']
41
+ ? getOffset(node)[axis === 'x' ? 'left' : 'top'] -
42
+ getOffset(target)[axis === 'x' ? 'right' : 'bottom']
41
43
  : 0;
42
44
  }
43
45
  offset = toPx(offset) + toPx(getCssVar('position-offset', element));
44
- offset = [includes(['left', 'top'], dir) ? -offset : +offset, 0];
45
46
 
46
- const attach = {
47
- element: [flipPosition(dir), align],
48
- target: [dir, align],
49
- };
47
+ const { x, y } = positionAt(
48
+ element,
49
+ target,
50
+ axis === 'x' ? `${flipPosition(dir)} ${align}` : `${align} ${flipPosition(dir)}`,
51
+ axis === 'x' ? `${dir} ${align}` : `${align} ${dir}`,
52
+ axis === 'x'
53
+ ? `${dir === 'left' ? -offset : offset}`
54
+ : ` ${dir === 'top' ? -offset : offset}`,
55
+ null,
56
+ this.flip,
57
+ boundary
58
+ ).target;
50
59
 
51
- if (this.axis === 'y') {
52
- for (const prop in attach) {
53
- attach[prop] = attach[prop].reverse();
54
- }
55
- offset = offset.reverse();
56
- }
60
+ this.dir = axis === 'x' ? x : y;
61
+ this.align = axis === 'x' ? y : x;
62
+ },
57
63
 
58
- positionAt(element, target, {
59
- attach,
60
- offset,
61
- boundary,
62
- flip: this.flip,
63
- });
64
+ getAxis() {
65
+ return this.dir === 'top' || this.dir === 'bottom' ? 'y' : 'x';
64
66
  },
65
67
  },
66
68
  };