uikit 3.25.30-dev.6f7d153 → 3.25.30

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 (47) hide show
  1. package/CHANGELOG.md +1 -6
  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 +1 -1
  13. package/dist/js/components/filter.min.js +1 -1
  14. package/dist/js/components/lightbox-panel.js +1 -1
  15. package/dist/js/components/lightbox-panel.min.js +1 -1
  16. package/dist/js/components/lightbox.js +1 -1
  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 +1 -1
  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 +81 -93
  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 +81 -93
  41. package/dist/js/uikit.min.js +1 -1
  42. package/package.json +1 -1
  43. package/src/js/core/drop.js +3 -12
  44. package/src/js/core/dropnav.js +44 -67
  45. package/src/js/core/navbar.js +1 -1
  46. package/src/js/core/toggle.js +47 -36
  47. package/tests/toggle.html +2 -2
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.25.30-dev.6f7d153",
5
+ "version": "3.25.30",
6
6
  "main": "dist/js/uikit.js",
7
7
  "style": "dist/css/uikit.css",
8
8
  "sideEffects": [
@@ -194,7 +194,7 @@ export default {
194
194
 
195
195
  handler(e) {
196
196
  e.preventDefault();
197
- if (!matches(this.$el, ':focus-within,:hover')) {
197
+ if (!matches(this.$el, ':focus,:hover')) {
198
198
  this.hide();
199
199
  }
200
200
  },
@@ -213,12 +213,12 @@ export default {
213
213
  },
214
214
 
215
215
  {
216
- name: pointerLeave,
216
+ name: `${pointerLeave} focusout`,
217
217
 
218
218
  filter: ({ mode }) => includes(mode, 'hover'),
219
219
 
220
220
  handler(e) {
221
- if (!isTouch(e) && e.relatedTarget && !matches(this.$el, ':focus-within')) {
221
+ if (!isTouch(e) && e.relatedTarget) {
222
222
  this.hide();
223
223
  }
224
224
  },
@@ -252,7 +252,6 @@ export default {
252
252
  const handlers = [
253
253
  listenForResize(this),
254
254
  listenForEscClose(this),
255
- listenForFocusClose(this),
256
255
  listenForBackgroundClose(this),
257
256
  this.autoUpdate && listenForScroll(this),
258
257
  this.closeOnScroll && listenForScrollClose(this),
@@ -502,14 +501,6 @@ function listenForScrollClose(drop) {
502
501
  return listenForScroll(drop, () => drop.hide(false));
503
502
  }
504
503
 
505
- function listenForFocusClose(drop) {
506
- return on(document, 'focusin', ({ target }) => {
507
- if (!drop.$el.contains(target) && !drop.targetEl?.contains(target)) {
508
- drop.hide(false);
509
- }
510
- });
511
- }
512
-
513
504
  function listenForBackgroundClose(drop) {
514
505
  return onOutsidePointer(
515
506
  (target) => {
@@ -4,13 +4,13 @@ import {
4
4
  addClass,
5
5
  after,
6
6
  css,
7
+ findIndex,
7
8
  getIndex,
8
9
  hasClass,
9
10
  height,
10
11
  includes,
11
12
  isInput,
12
13
  isRtl,
13
- isVisible,
14
14
  matches,
15
15
  noop,
16
16
  observeResize,
@@ -65,7 +65,7 @@ export default {
65
65
  delayShow: 160,
66
66
  duration: 200,
67
67
  container: false,
68
- selNavItem: '> li > a, > li > button, > ul > li > a, > ul > li > button',
68
+ selNavItem: '> li > a, > ul > li > a',
69
69
  },
70
70
 
71
71
  computed: {
@@ -135,7 +135,7 @@ export default {
135
135
 
136
136
  events: [
137
137
  {
138
- name: 'mouseover',
138
+ name: 'mouseover focusin',
139
139
 
140
140
  delegate: ({ selNavItem }) => selNavItem,
141
141
 
@@ -161,31 +161,27 @@ export default {
161
161
  delegate: ({ selNavItem }) => selNavItem,
162
162
 
163
163
  handler(e) {
164
- if (e.defaultPrevented || e.altKey || e.ctrlKey || e.metaKey) {
165
- return;
166
- }
167
-
168
- const { current, keyCode, shiftKey } = e;
164
+ const { current, keyCode } = e;
169
165
  const active = this.getActive();
170
166
 
171
- if (keyCode === keyMap.ESC && active) {
172
- closeDropdown(e, active);
173
- return;
174
- }
175
-
176
- if (
177
- active?.targetEl === current &&
178
- (keyCode === keyMap.DOWN || (keyCode === keyMap.TAB && !shiftKey))
179
- ) {
180
- const [first] = getFocusableElements(active.$el);
181
- if (first) {
167
+ if (keyCode === keyMap.DOWN) {
168
+ if (active?.targetEl === current) {
182
169
  e.preventDefault();
183
- first.focus();
170
+ $(selFocusable, active.$el)?.focus();
171
+ } else {
172
+ const dropdown = this.dropdowns.find(
173
+ (el) => this.getDropdown(el)?.targetEl === current,
174
+ );
175
+
176
+ if (dropdown) {
177
+ e.preventDefault();
178
+ current.click();
179
+ once(dropdown, 'show', (e) => $(selFocusable, e.target)?.focus());
180
+ }
184
181
  }
185
- return;
186
182
  }
187
183
 
188
- handleNavigation(e, getFocusableElements(this.$el, this.selNavItem), current);
184
+ handleNavItemNavigation(e, this.items, active);
189
185
  },
190
186
  },
191
187
 
@@ -197,39 +193,32 @@ export default {
197
193
  delegate: ({ clsDrop }) => `.${clsDrop}`,
198
194
 
199
195
  handler(e) {
200
- if (e.defaultPrevented || e.altKey || e.ctrlKey || e.metaKey) {
201
- return;
202
- }
203
-
204
196
  const { current, keyCode, target } = e;
205
197
 
206
- const active = this.getActive();
207
- if (!active || active.$el !== current) {
198
+ if (isInput(target) || !includes(this.dropdowns, current)) {
208
199
  return;
209
200
  }
210
201
 
211
- if (keyCode === keyMap.ESC) {
212
- closeDropdown(e, active);
202
+ const active = this.getActive();
203
+ const next = getNavigationIndex(keyCode, keyMap.UP, keyMap.DOWN);
204
+ if (~next) {
205
+ e.preventDefault();
206
+ const elements = $$(selFocusable, current);
207
+ elements[
208
+ getIndex(
209
+ next,
210
+ elements,
211
+ findIndex(elements, (el) => matches(el, ':focus')),
212
+ )
213
+ ]?.focus();
213
214
  return;
214
215
  }
215
216
 
216
- const elements = getFocusableElements(current);
217
- if (keyCode === keyMap.TAB) {
218
- if (target === elements[e.shiftKey ? 0 : elements.length - 1]) {
219
- active.targetEl.focus();
220
- if (e.shiftKey) {
221
- e.preventDefault();
222
- } else {
223
- // Resume native Tab navigation after the toggle.
224
- active.hide(false, false);
225
- }
226
- }
227
- return;
217
+ if (keyCode === keyMap.ESC) {
218
+ active.targetEl?.focus();
228
219
  }
229
220
 
230
- if (!isInput(target)) {
231
- handleNavigation(e, elements, target);
232
- }
221
+ handleNavItemNavigation(e, this.items, active);
233
222
  },
234
223
  },
235
224
 
@@ -417,38 +406,26 @@ export default {
417
406
  },
418
407
  };
419
408
 
420
- function handleNavigation(e, elements, current) {
421
- const keyCode =
422
- { [keyMap.UP]: keyMap.LEFT, [keyMap.DOWN]: keyMap.RIGHT }[e.keyCode] || e.keyCode;
409
+ function handleNavItemNavigation(e, toggles, active) {
410
+ const { current, keyCode } = e;
423
411
  const next = getNavigationIndex(keyCode);
412
+
424
413
  if (~next) {
425
414
  e.preventDefault();
426
- elements[getIndex(next, elements, elements.indexOf(current), true)]?.focus();
415
+ active.hide?.(false);
416
+ toggles[getIndex(next, toggles, toggles.indexOf(active.targetEl || current))].focus();
417
+ } else if (keyCode === keyMap.TAB) {
418
+ active.targetEl?.focus();
419
+ active.hide?.(false);
427
420
  }
428
421
  }
429
422
 
430
- function closeDropdown(e, drop) {
431
- e.preventDefault();
432
- drop.hide(false);
433
- drop.targetEl?.focus();
434
- }
435
-
436
- function getFocusableElements(el, selector = selFocusable) {
437
- return $$(selector, el).filter(
438
- (el) =>
439
- el.tabIndex >= 0 &&
440
- !matches(el, ':disabled') &&
441
- !el.closest('[inert]') &&
442
- isVisible(el),
443
- );
444
- }
445
-
446
423
  // Prevents initial pointer events from opening dropdowns on page load (Safari/Firefox)
447
424
  function preventInitialPointerEnter(el) {
448
425
  const off = () => handlers.forEach((handler) => handler());
449
426
  const handlers = [
450
427
  once(el.ownerDocument, pointerMove, (e) => el.contains(e.target) || off()),
451
- on(el, `mouseenter ${pointerEnter}`, (e) => e.stopPropagation(), true),
452
- on(el, `mouseleave ${pointerLeave}`, off, true),
428
+ on(el, `mouseenter ${pointerEnter}`, (e) => e.stopPropagation(), { capture: true }),
429
+ on(el, `mouseleave ${pointerLeave}`, off, { capture: true }),
453
430
  ];
454
431
  }
@@ -18,7 +18,7 @@ export default {
18
18
  delayShow: 200,
19
19
  clsDrop: 'uk-navbar-dropdown',
20
20
  selNavItem:
21
- '.uk-navbar-nav > li > a,.uk-navbar-nav > li > button,a.uk-navbar-item,button.uk-navbar-item,.uk-navbar-item a,.uk-navbar-item button,.uk-navbar-toggle', // Simplify with :where() selector once browser target is Safari 14+
21
+ '.uk-navbar-nav > li > a,a.uk-navbar-item,button.uk-navbar-item,.uk-navbar-item a,.uk-navbar-item button,.uk-navbar-toggle', // Simplify with :where() selector once browser target is Safari 14+
22
22
  dropbarTransparentMode: false,
23
23
  },
24
24
 
@@ -8,6 +8,7 @@ import {
8
8
  isTag,
9
9
  isTouch,
10
10
  matches,
11
+ once,
11
12
  pointerDown,
12
13
  pointerEnter,
13
14
  pointerLeave,
@@ -68,60 +69,72 @@ export default {
68
69
  filter: ({ mode }) => includes(mode, 'hover'),
69
70
 
70
71
  handler(e) {
71
- // Preserve touch input for browsers whose click events lack pointerType.
72
- this._touch = isTouch(e);
72
+ this._preventClick = null;
73
+
74
+ if (!isTouch(e) || isBoolean(this._showState) || this.$el.disabled) {
75
+ return;
76
+ }
77
+
78
+ // Clicking a button does not give it focus on all browsers and platforms
79
+ // https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#clicking_and_focus
80
+ trigger(this.$el, 'focus');
81
+ once(
82
+ document,
83
+ pointerDown,
84
+ () => trigger(this.$el, 'blur'),
85
+ true,
86
+ (e) => !this.$el.contains(e.target),
87
+ );
88
+
89
+ // Prevent initial click to prevent double toggle through focus + click
90
+ if (includes(this.mode, 'click')) {
91
+ this._preventClick = true;
92
+ }
73
93
  },
74
94
  },
75
95
 
76
96
  {
77
- name: `${pointerEnter} ${pointerLeave} click`,
97
+ name: `${pointerEnter} ${pointerLeave} focus blur`,
78
98
 
79
99
  filter: ({ mode }) => includes(mode, 'hover'),
80
100
 
81
101
  handler(e) {
82
- const click = e.type === 'click';
83
- const allowClick =
84
- includes(this.mode, 'click') || e.detail === 0 || isTouch(e) || this._touch;
85
- if (
86
- this.$el.disabled ||
87
- (click
88
- ? e.defaultPrevented || !allowClick
89
- : isTouch(e) || document.readyState === 'loading')
90
- ) {
102
+ if (isTouch(e) || this.$el.disabled || document.readyState === 'loading') {
91
103
  return;
92
104
  }
93
105
 
106
+ const show = includes([pointerEnter, 'focus'], e.type);
94
107
  const expanded = this.isToggled(this.target);
95
- if (e.type === pointerLeave) {
96
- const initial = this._showState;
97
- if (!isBoolean(initial)) {
98
- return;
99
- }
100
- this._showState = null;
101
- if (expanded !== initial) {
102
- this.toggle('togglehide');
103
- } else {
104
- // Drops may have canceled a delayed hide on pointer re-entry.
105
- trigger(this.target, 'togglehide', [this]);
108
+
109
+ // Skip hide if still hovered or focused
110
+ if (
111
+ !show &&
112
+ (!isBoolean(this._showState) ||
113
+ (e.type === pointerLeave && matches(this.$el, ':focus')) ||
114
+ (e.type === 'blur' && matches(this.$el, ':hover')))
115
+ ) {
116
+ // Reset showState if already hidden
117
+ if (expanded === this._showState) {
118
+ this._showState = null;
106
119
  }
107
120
  return;
108
121
  }
109
122
 
110
- // Snapshot before hover or explicit activation changes the target.
111
- if (!isBoolean(this._showState)) {
112
- this._showState = expanded;
113
- }
114
- if (!click && expanded === this._showState) {
115
- this.toggle('toggleshow');
123
+ // Skip show if state does not change e.g. hover + focus received
124
+ if (show && isBoolean(this._showState) && expanded !== this._showState) {
125
+ return;
116
126
  }
127
+
128
+ this._showState = show ? expanded : null;
129
+
130
+ this.toggle(`toggle${show ? 'show' : 'hide'}`);
117
131
  },
118
132
  },
119
133
 
120
134
  {
121
135
  name: 'keydown',
122
136
 
123
- filter: ({ $el, mode }) =>
124
- ['click', 'hover'].some((m) => includes(mode, m)) && !isTag($el, 'input'),
137
+ filter: ({ $el, mode }) => includes(mode, 'click') && !isTag($el, 'input'),
125
138
 
126
139
  handler(e) {
127
140
  if (e.keyCode === keyMap.SPACE || e.keyCode === keyMap.ENTER) {
@@ -137,9 +150,6 @@ export default {
137
150
  filter: ({ mode }) => ['click', 'hover'].some((m) => includes(mode, m)),
138
151
 
139
152
  handler(e) {
140
- const touch = this._touch;
141
- this._touch = false;
142
-
143
153
  if (e.defaultPrevented) {
144
154
  return;
145
155
  }
@@ -148,12 +158,13 @@ export default {
148
158
  const isButtonLike =
149
159
  isSameSiteAnchor(link) && (!link.hash || matches(this.target, link.hash));
150
160
 
151
- if (isButtonLike || (link && !this.isToggled(this.target))) {
161
+ if (this._preventClick || isButtonLike || (link && !this.isToggled(this.target))) {
152
162
  e.preventDefault();
153
163
  }
154
164
 
155
165
  if (
156
- (includes(this.mode, 'click') || e.detail === 0 || isTouch(e) || touch) &&
166
+ !this._preventClick &&
167
+ includes(this.mode, 'click') &&
157
168
  (!link || isButtonLike || e.defaultPrevented)
158
169
  ) {
159
170
  this.toggle();
package/tests/toggle.html CHANGED
@@ -113,10 +113,10 @@
113
113
 
114
114
  <h3>Mode Hover</h3>
115
115
 
116
- <button class="uk-button uk-button-default" type="button" uk-toggle="target: ~; mode: hover">Hover, Activate</button>
116
+ <button class="uk-button uk-button-default" type="button" uk-toggle="target: ~; mode: hover">Hover, Focus</button>
117
117
 
118
118
  <p>What's up?</p>
119
- <p hidden>Hovered, Activated</p>
119
+ <p hidden>Hovered, Focused</p>
120
120
 
121
121
  </div>
122
122
  </div>