uikit 3.14.4-dev.fea9fd466 → 3.15.1-dev.f849bb0c8

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 (126) hide show
  1. package/CHANGELOG.md +32 -18
  2. package/build/util.js +1 -0
  3. package/dist/css/uikit-core-rtl.css +284 -63
  4. package/dist/css/uikit-core-rtl.min.css +1 -1
  5. package/dist/css/uikit-core.css +284 -63
  6. package/dist/css/uikit-core.min.css +1 -1
  7. package/dist/css/uikit-rtl.css +306 -92
  8. package/dist/css/uikit-rtl.min.css +1 -1
  9. package/dist/css/uikit.css +306 -92
  10. package/dist/css/uikit.min.css +1 -1
  11. package/dist/js/components/countdown.js +1 -1
  12. package/dist/js/components/countdown.min.js +1 -1
  13. package/dist/js/components/filter.js +1 -1
  14. package/dist/js/components/filter.min.js +1 -1
  15. package/dist/js/components/lightbox-panel.js +98 -131
  16. package/dist/js/components/lightbox-panel.min.js +1 -1
  17. package/dist/js/components/lightbox.js +98 -131
  18. package/dist/js/components/lightbox.min.js +1 -1
  19. package/dist/js/components/notification.js +4 -2
  20. package/dist/js/components/notification.min.js +1 -1
  21. package/dist/js/components/parallax.js +1 -1
  22. package/dist/js/components/parallax.min.js +1 -1
  23. package/dist/js/components/slider-parallax.js +1 -1
  24. package/dist/js/components/slider-parallax.min.js +1 -1
  25. package/dist/js/components/slider.js +1 -1
  26. package/dist/js/components/slider.min.js +1 -1
  27. package/dist/js/components/slideshow-parallax.js +1 -1
  28. package/dist/js/components/slideshow-parallax.min.js +1 -1
  29. package/dist/js/components/slideshow.js +1 -1
  30. package/dist/js/components/slideshow.min.js +1 -1
  31. package/dist/js/components/sortable.js +1 -1
  32. package/dist/js/components/sortable.min.js +1 -1
  33. package/dist/js/components/tooltip.js +101 -136
  34. package/dist/js/components/tooltip.min.js +1 -1
  35. package/dist/js/components/upload.js +1 -1
  36. package/dist/js/components/upload.min.js +1 -1
  37. package/dist/js/uikit-core.js +518 -478
  38. package/dist/js/uikit-core.min.js +17 -1
  39. package/dist/js/uikit-icons.js +1 -1
  40. package/dist/js/uikit-icons.min.js +1 -1
  41. package/dist/js/uikit.js +521 -479
  42. package/dist/js/uikit.min.js +17 -1
  43. package/package.json +11 -11
  44. package/src/images/components/navbar-toggle-icon.svg +25 -3
  45. package/src/js/api/hooks.js +5 -1
  46. package/src/js/api/state.js +2 -2
  47. package/src/js/components/notification.js +3 -1
  48. package/src/js/core/accordion.js +9 -17
  49. package/src/js/core/alert.js +35 -14
  50. package/src/js/core/drop.js +110 -82
  51. package/src/js/core/navbar.js +33 -49
  52. package/src/js/core/offcanvas.js +8 -4
  53. package/src/js/core/scroll.js +37 -10
  54. package/src/js/core/toggle.js +3 -5
  55. package/src/js/mixin/modal.js +15 -12
  56. package/src/js/mixin/position.js +21 -22
  57. package/src/js/mixin/style.js +11 -0
  58. package/src/js/mixin/togglable.js +90 -124
  59. package/src/js/util/animation.js +9 -7
  60. package/src/js/util/class.js +3 -1
  61. package/src/js/util/filter.js +3 -7
  62. package/src/js/util/position.js +136 -130
  63. package/src/js/util/viewport.js +1 -1
  64. package/src/less/components/_import.less +1 -0
  65. package/src/less/components/drop.less +1 -18
  66. package/src/less/components/dropbar.less +126 -0
  67. package/src/less/components/dropdown.less +6 -20
  68. package/src/less/components/nav.less +214 -23
  69. package/src/less/components/navbar.less +26 -54
  70. package/src/less/theme/_import.less +1 -0
  71. package/src/less/theme/dropbar.less +44 -0
  72. package/src/less/theme/dropdown.less +0 -11
  73. package/src/less/theme/nav.less +46 -0
  74. package/src/less/theme/navbar.less +5 -36
  75. package/src/scss/components/_import.scss +1 -0
  76. package/src/scss/components/drop.scss +1 -18
  77. package/src/scss/components/dropbar.scss +126 -0
  78. package/src/scss/components/dropdown.scss +6 -20
  79. package/src/scss/components/nav.scss +163 -22
  80. package/src/scss/components/navbar.scss +26 -54
  81. package/src/scss/mixins-theme.scss +81 -35
  82. package/src/scss/mixins.scss +77 -3
  83. package/src/scss/theme/_import.scss +1 -0
  84. package/src/scss/theme/dropbar.scss +44 -0
  85. package/src/scss/theme/dropdown.scss +0 -8
  86. package/src/scss/theme/nav.scss +44 -0
  87. package/src/scss/theme/navbar.scss +4 -8
  88. package/src/scss/variables-theme.scss +58 -13
  89. package/src/scss/variables.scss +46 -8
  90. package/tests/accordion.html +2 -2
  91. package/tests/alert.html +2 -2
  92. package/tests/countdown.html +1 -1
  93. package/tests/drop.html +446 -416
  94. package/tests/dropbar.html +458 -0
  95. package/tests/dropdown.html +8 -470
  96. package/tests/filter.html +9 -12
  97. package/tests/flex.html +36 -36
  98. package/tests/form.html +1 -1
  99. package/tests/grid.html +22 -22
  100. package/tests/height.html +6 -6
  101. package/tests/index.html +127 -108
  102. package/tests/js/index.js +1 -4
  103. package/tests/lightbox.html +5 -5
  104. package/tests/list.html +8 -8
  105. package/tests/modal.html +13 -13
  106. package/tests/nav.html +121 -12
  107. package/tests/navbar.html +111 -220
  108. package/tests/offcanvas.html +10 -14
  109. package/tests/pagination.html +6 -6
  110. package/tests/parallax.html +1 -1
  111. package/tests/position.html +18 -16
  112. package/tests/progress.html +9 -9
  113. package/tests/scroll.html +7 -10
  114. package/tests/search.html +6 -6
  115. package/tests/slider.html +6 -5
  116. package/tests/slideshow.html +8 -8
  117. package/tests/sortable.html +6 -8
  118. package/tests/sticky-navbar.html +15 -15
  119. package/tests/sticky.html +8 -8
  120. package/tests/switcher.html +1 -1
  121. package/tests/tab.html +1 -1
  122. package/tests/table.html +7 -7
  123. package/tests/toggle.html +2 -2
  124. package/tests/tooltip.html +1 -1
  125. package/tests/upload.html +11 -11
  126. package/tests/utility.html +16 -16
@@ -18,7 +18,7 @@ import {
18
18
  observeResize,
19
19
  offset,
20
20
  once,
21
- parent,
21
+ parents,
22
22
  query,
23
23
  remove,
24
24
  selFocusable,
@@ -36,7 +36,9 @@ export default {
36
36
  align: String,
37
37
  offset: Number,
38
38
  boundary: Boolean,
39
- boundaryAlign: Boolean,
39
+ target: Boolean,
40
+ targetX: Boolean,
41
+ targetY: Boolean,
40
42
  clsDrop: String,
41
43
  delayShow: Number,
42
44
  delayHide: Number,
@@ -53,9 +55,12 @@ export default {
53
55
  offset: undefined,
54
56
  delayShow: undefined,
55
57
  delayHide: undefined,
56
- boundaryAlign: undefined,
57
- flip: 'x',
58
+ flip: false,
59
+ shift: true,
58
60
  boundary: true,
61
+ target: false,
62
+ targetX: false,
63
+ targetY: false,
59
64
  dropbar: false,
60
65
  dropbarAnchor: false,
61
66
  duration: 200,
@@ -68,7 +73,7 @@ export default {
68
73
  },
69
74
 
70
75
  dropbarAnchor({ dropbarAnchor }, $el) {
71
- return query(dropbarAnchor, $el);
76
+ return query(dropbarAnchor, $el) || $el;
72
77
  },
73
78
 
74
79
  pos({ align }) {
@@ -90,7 +95,7 @@ export default {
90
95
  },
91
96
 
92
97
  watch(dropbar) {
93
- addClass(dropbar, 'uk-navbar-dropbar');
98
+ addClass(dropbar, 'uk-dropbar', 'uk-dropbar-top', 'uk-navbar-dropbar');
94
99
  },
95
100
 
96
101
  immediate: true,
@@ -106,7 +111,7 @@ export default {
106
111
 
107
112
  if (this.dropContainer !== $el) {
108
113
  for (const el of $$(`.${clsDrop}`, this.dropContainer)) {
109
- const target = this.getDropdown(el)?.target;
114
+ const target = this.getDropdown(el)?.targetEl;
110
115
  if (!includes(dropdowns, el) && target && within(target, this.$el)) {
111
116
  dropdowns.push(el);
112
117
  }
@@ -168,8 +173,8 @@ export default {
168
173
  if (
169
174
  active &&
170
175
  includes(active.mode, 'hover') &&
171
- active.target &&
172
- !within(active.target, current) &&
176
+ active.targetEl &&
177
+ !within(active.targetEl, current) &&
173
178
  !active.isDelaying
174
179
  ) {
175
180
  active.hide(false);
@@ -191,7 +196,7 @@ export default {
191
196
  if (keyCode === keyMap.DOWN && hasAttr(current, 'aria-expanded')) {
192
197
  e.preventDefault();
193
198
 
194
- if (!active || active.target !== current) {
199
+ if (!active || active.targetEl !== current) {
195
200
  current.click();
196
201
  once(this.dropContainer, 'show', ({ target }) =>
197
202
  focusFirstFocusableElement(target)
@@ -242,7 +247,7 @@ export default {
242
247
  }
243
248
 
244
249
  if (keyCode === keyMap.ESC) {
245
- active?.target?.focus();
250
+ active?.targetEl?.focus();
246
251
  }
247
252
 
248
253
  handleNavItemNavigation(e, this.toggles, active);
@@ -289,8 +294,8 @@ export default {
289
294
  return;
290
295
  }
291
296
 
292
- if (!parent(this.dropbar)) {
293
- after(this.dropbarAnchor || this.$el, this.dropbar);
297
+ if (this.dropbar.previousElementSibling !== this.dropbarAnchor) {
298
+ after(this.dropbarAnchor, this.dropbar);
294
299
  }
295
300
 
296
301
  addClass(target, `${this.clsDrop}-dropbar`);
@@ -313,39 +318,19 @@ export default {
313
318
  return;
314
319
  }
315
320
 
316
- this._observer = observeResize(target, () =>
321
+ this._observer = observeResize(target, () => {
322
+ const targetOffsets = parents(target, `.${this.clsDrop}`)
323
+ .concat(target)
324
+ .map((el) => offset(el));
325
+ const minTop = Math.min(...targetOffsets.map(({ top }) => top));
326
+ const maxBottom = Math.max(...targetOffsets.map(({ bottom }) => bottom));
327
+ const dropbarOffset = offset(this.dropbar);
328
+ css(this.dropbar, 'top', this.dropbar.offsetTop - (dropbarOffset.top - minTop));
317
329
  this.transitionTo(
318
- offset(target).bottom -
319
- offset(this.dropbar).top +
320
- toFloat(css(target, 'marginBottom')),
330
+ maxBottom - minTop + toFloat(css(target, 'marginBottom')),
321
331
  target
322
- )
323
- );
324
- },
325
- },
326
-
327
- {
328
- name: 'beforeposition',
329
-
330
- el() {
331
- return this.dropContainer;
332
- },
333
-
334
- filter() {
335
- return this.dropbar;
336
- },
337
-
338
- handler(e, element, target, options) {
339
- if (!this.isDropbarDrop(element)) {
340
- return;
341
- }
342
-
343
- const dropbarOffset = offset(this.dropbar);
344
-
345
- css(element, 'maxWidth', dropbarOffset.width - options.viewportOffset * 2);
346
-
347
- options.offset[1] = dropbarOffset.top - offset(target).bottom;
348
- options.viewportOffset += dropbarOffset.left;
332
+ );
333
+ });
349
334
  },
350
335
  },
351
336
 
@@ -366,7 +351,7 @@ export default {
366
351
  if (
367
352
  matches(this.dropbar, ':hover') &&
368
353
  active?.$el === e.target &&
369
- !this.toggles.some((el) => active.target !== el && matches(el, ':focus'))
354
+ !this.toggles.some((el) => active.targetEl !== el && matches(el, ':focus'))
370
355
  ) {
371
356
  e.preventDefault();
372
357
  }
@@ -402,7 +387,7 @@ export default {
402
387
 
403
388
  methods: {
404
389
  getActive() {
405
- return active && within(active.target, this.$el) && active;
390
+ return includes(this.dropdowns, active?.$el) && active;
406
391
  },
407
392
 
408
393
  transitionTo(newHeight, el) {
@@ -435,15 +420,14 @@ export default {
435
420
  },
436
421
 
437
422
  isDropbarDrop(el) {
438
- const drop = this.getDropdown(el);
439
- return drop && hasClass(el, this.clsDrop) && drop.align !== 'stretch';
423
+ return this.getDropdown(el) && hasClass(el, this.clsDrop);
440
424
  },
441
425
  },
442
426
  };
443
427
 
444
428
  function handleNavItemNavigation(e, toggles, active) {
445
429
  const { current, keyCode } = e;
446
- const target = active?.target || current;
430
+ const target = active?.targetEl || current;
447
431
  const i = toggles.indexOf(target);
448
432
 
449
433
  // Left
@@ -119,9 +119,12 @@ export default {
119
119
  addClass(parent(this.panel), this.clsMode);
120
120
  }
121
121
 
122
- addClass(document.body, this.clsContainer, this.clsFlip);
123
- css(document.body, 'touch-action', 'pan-y pinch-zoom');
122
+ const { body, scrollingElement } = document;
123
+
124
+ addClass(body, this.clsContainer, this.clsFlip);
125
+ css(body, 'touch-action', 'pan-y pinch-zoom');
124
126
  css(this.$el, 'display', 'block');
127
+ css(this.panel, 'maxWidth', scrollingElement.clientWidth);
125
128
  addClass(this.$el, this.clsOverlay);
126
129
  addClass(
127
130
  this.panel,
@@ -129,8 +132,8 @@ export default {
129
132
  this.mode === 'reveal' ? '' : this.clsMode
130
133
  );
131
134
 
132
- height(document.body); // force reflow
133
- addClass(document.body, this.clsContainerAnimation);
135
+ height(body); // force reflow
136
+ addClass(body, this.clsContainerAnimation);
134
137
 
135
138
  this.clsContainerAnimation && suppressUserScale();
136
139
  },
@@ -162,6 +165,7 @@ export default {
162
165
  removeClass(this.panel, this.clsSidebarAnimation, this.clsMode);
163
166
  removeClass(this.$el, this.clsOverlay);
164
167
  css(this.$el, 'display', '');
168
+ css(this.panel, 'maxWidth', '');
165
169
  removeClass(document.body, this.clsContainer, this.clsFlip);
166
170
  },
167
171
  },
@@ -1,4 +1,4 @@
1
- import { $, scrollIntoView, trigger } from 'uikit-util';
1
+ import { $, off, on, scrollIntoView, trigger, within } from 'uikit-util';
2
2
 
3
3
  export default {
4
4
  props: {
@@ -9,6 +9,14 @@ export default {
9
9
  offset: 0,
10
10
  },
11
11
 
12
+ connected() {
13
+ registerClick(this);
14
+ },
15
+
16
+ disconnected() {
17
+ unregisterClick(this);
18
+ },
19
+
12
20
  methods: {
13
21
  async scrollTo(el) {
14
22
  el = (el && $(el)) || document.body;
@@ -19,18 +27,37 @@ export default {
19
27
  }
20
28
  },
21
29
  },
30
+ };
22
31
 
23
- events: {
24
- click(e) {
25
- if (e.defaultPrevented) {
26
- return;
27
- }
32
+ const components = new Set();
33
+ function registerClick(cmp) {
34
+ if (!components.size) {
35
+ on(document, 'click', clickHandler);
36
+ }
37
+
38
+ components.add(cmp);
39
+ }
28
40
 
41
+ function unregisterClick(cmp) {
42
+ components.delete(cmp);
43
+
44
+ if (!components.length) {
45
+ off(document, 'click', clickHandler);
46
+ }
47
+ }
48
+
49
+ function clickHandler(e) {
50
+ if (e.defaultPrevented) {
51
+ return;
52
+ }
53
+
54
+ for (const component of components) {
55
+ if (within(e.target, component.$el)) {
29
56
  e.preventDefault();
30
- this.scrollTo(getTargetElement(this.$el));
31
- },
32
- },
33
- };
57
+ component.scrollTo(getTargetElement(component.$el));
58
+ }
59
+ }
60
+ }
34
61
 
35
62
  export function getTargetElement(el) {
36
63
  return document.getElementById(decodeURIComponent(el.hash).substring(1));
@@ -181,7 +181,7 @@ export default {
181
181
  },
182
182
 
183
183
  {
184
- name: 'toggled',
184
+ name: 'hide show',
185
185
 
186
186
  self: true,
187
187
 
@@ -189,10 +189,8 @@ export default {
189
189
  return this.target;
190
190
  },
191
191
 
192
- handler(e, toggled) {
193
- if (e.target === this.target[0]) {
194
- this.updateAria(toggled);
195
- }
192
+ handler({ type }) {
193
+ this.updateAria(type === 'show');
196
194
  },
197
195
  },
198
196
 
@@ -9,6 +9,7 @@ import {
9
9
  includes,
10
10
  isFocusable,
11
11
  last,
12
+ noop,
12
13
  on,
13
14
  once,
14
15
  parent,
@@ -134,8 +135,8 @@ export default {
134
135
  );
135
136
 
136
137
  if (this.overlay) {
137
- once(this.$el, 'hide', preventOverscroll(this.$el));
138
- once(this.$el, 'hide', preventBackgroundScroll());
138
+ once(this.$el, 'hidden', preventOverscroll(this.$el), { self: true });
139
+ once(this.$el, 'hidden', preventBackgroundScroll(), { self: true });
139
140
  }
140
141
 
141
142
  if (this.stack) {
@@ -217,10 +218,6 @@ export default {
217
218
  active.splice(active.indexOf(this), 1);
218
219
  }
219
220
 
220
- if (!active.length) {
221
- css(document.body, 'overflowY', '');
222
- }
223
-
224
221
  css(this.$el, 'zIndex', '');
225
222
 
226
223
  if (!active.some((modal) => modal.clsPage === this.clsPage)) {
@@ -337,16 +334,22 @@ export function preventOverscroll(el) {
337
334
  return () => events.forEach((fn) => fn());
338
335
  }
339
336
 
337
+ let prevented;
340
338
  export function preventBackgroundScroll() {
341
- const { body, documentElement } = document;
342
- css(body, {
343
- overflowY: width(window) > documentElement.clientWidth ? 'scroll' : '',
339
+ if (prevented) {
340
+ return noop;
341
+ }
342
+ prevented = true;
343
+
344
+ const { scrollingElement } = document;
345
+ css(scrollingElement, {
346
+ overflowY: 'hidden',
344
347
  touchAction: 'none',
348
+ paddingRight: width(window) - scrollingElement.clientWidth,
345
349
  });
346
- css(documentElement, 'overflowY', 'hidden');
347
350
  return () => {
348
- css(documentElement, 'overflowY', '');
349
- css(body, { overflowY: '', touchAction: '' });
351
+ prevented = false;
352
+ css(scrollingElement, { overflowY: '', touchAction: '', paddingRight: '' });
350
353
  };
351
354
  }
352
355
 
@@ -7,7 +7,6 @@ import {
7
7
  positionAt,
8
8
  scrollParents,
9
9
  toPx,
10
- trigger,
11
10
  } from 'uikit-util';
12
11
 
13
12
  export default {
@@ -15,12 +14,16 @@ export default {
15
14
  pos: String,
16
15
  offset: null,
17
16
  flip: Boolean,
17
+ shift: Boolean,
18
+ inset: Boolean,
18
19
  },
19
20
 
20
21
  data: {
21
22
  pos: `bottom-${isRtl ? 'right' : 'left'}`,
22
- flip: true,
23
23
  offset: false,
24
+ flip: true,
25
+ shift: true,
26
+ inset: false,
24
27
  },
25
28
 
26
29
  connected() {
@@ -32,17 +35,19 @@ export default {
32
35
  methods: {
33
36
  positionAt(element, target, boundary) {
34
37
  let offset = [this.getPositionOffset(element), this.getShiftOffset(element)];
38
+ const placement = [this.flip && 'flip', this.shift && 'shift'];
35
39
 
36
40
  const attach = {
37
- element: [flipPosition(this.dir), this.align],
41
+ element: [this.inset ? this.dir : flipPosition(this.dir), this.align],
38
42
  target: [this.dir, this.align],
39
43
  };
40
44
 
41
45
  if (this.axis === 'y') {
42
46
  for (const prop in attach) {
43
- attach[prop] = attach[prop].reverse();
47
+ attach[prop].reverse();
44
48
  }
45
- offset = offset.reverse();
49
+ offset.reverse();
50
+ placement.reverse();
46
51
  }
47
52
 
48
53
  const [scrollElement] = scrollParents(element, /auto|scroll/);
@@ -52,21 +57,13 @@ export default {
52
57
  const elDim = dimensions(element);
53
58
  css(element, { top: -elDim.height, left: -elDim.width });
54
59
 
55
- const args = [
56
- element,
57
- target,
58
- {
59
- attach,
60
- offset,
61
- boundary,
62
- flip: this.flip,
63
- viewportOffset: this.getViewportOffset(element),
64
- },
65
- ];
66
-
67
- trigger(element, 'beforeposition', args);
68
-
69
- positionAt(...args);
60
+ positionAt(element, target, {
61
+ attach,
62
+ offset,
63
+ boundary,
64
+ placement,
65
+ viewportOffset: this.getViewportOffset(element),
66
+ });
70
67
 
71
68
  // Restore scroll position
72
69
  scrollElement.scrollTop = scrollTop;
@@ -79,12 +76,14 @@ export default {
79
76
  this.offset === false ? css(element, '--uk-position-offset') : this.offset,
80
77
  this.axis === 'x' ? 'width' : 'height',
81
78
  element
82
- ) * (includes(['left', 'top'], this.dir) ? -1 : 1)
79
+ ) *
80
+ (includes(['left', 'top'], this.dir) ? -1 : 1) *
81
+ (this.inset ? -1 : 1)
83
82
  );
84
83
  },
85
84
 
86
85
  getShiftOffset(element) {
87
- return includes(['center', 'justify', 'stretch'], this.align)
86
+ return this.align === 'center'
88
87
  ? 0
89
88
  : toPx(
90
89
  css(element, '--uk-position-shift-offset'),
@@ -0,0 +1,11 @@
1
+ import { attr } from 'uikit-util';
2
+
3
+ export default {
4
+ beforeConnect() {
5
+ this._style = attr(this.$el, 'style');
6
+ },
7
+
8
+ disconnected() {
9
+ attr(this.$el, 'style', this._style);
10
+ },
11
+ };