uikit 3.19.4 → 3.19.5-dev.21fa5c45d

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 (55) hide show
  1. package/CHANGELOG.md +10 -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 +7 -8
  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 +58 -44
  21. package/dist/js/components/parallax.min.js +1 -1
  22. package/dist/js/components/slider-parallax.js +58 -44
  23. package/dist/js/components/slider-parallax.min.js +1 -1
  24. package/dist/js/components/slider.js +59 -45
  25. package/dist/js/components/slider.min.js +1 -1
  26. package/dist/js/components/slideshow-parallax.js +58 -44
  27. package/dist/js/components/slideshow-parallax.min.js +1 -1
  28. package/dist/js/components/slideshow.js +58 -44
  29. package/dist/js/components/slideshow.min.js +1 -1
  30. package/dist/js/components/sortable.js +3 -3
  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 +103 -65
  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 +107 -70
  41. package/dist/js/uikit.min.js +1 -1
  42. package/eslint.config.js +8 -5
  43. package/package.json +3 -4
  44. package/src/js/api/observer.js +17 -5
  45. package/src/js/components/filter.js +4 -5
  46. package/src/js/core/drop.js +0 -6
  47. package/src/js/core/img.js +1 -1
  48. package/src/js/core/inverse.js +18 -5
  49. package/src/js/core/margin.js +1 -1
  50. package/src/js/core/switcher.js +6 -1
  51. package/src/js/core/toggle.js +1 -1
  52. package/src/js/util/selector.js +61 -37
  53. package/src/js/util/svg.js +1 -12
  54. package/tests/modal.html +2 -2
  55. package/build/package.json +0 -4
package/eslint.config.js CHANGED
@@ -1,16 +1,19 @@
1
- const eslintJs = require('@eslint/js');
2
- const eslintConfigPrettier = require('eslint-config-prettier');
3
- const globals = require('globals');
1
+ import eslintJs from '@eslint/js';
2
+ import eslintConfigPrettier from 'eslint-config-prettier';
3
+ import globals from 'globals';
4
4
 
5
- module.exports = [
5
+ export default [
6
6
  eslintJs.configs.recommended,
7
7
  eslintConfigPrettier,
8
+ {
9
+ ignores: ['*', '!src/', '!src/*', '!src/js', '!build/', 'build/*', '!build/*.js'],
10
+ },
8
11
  {
9
12
  rules: {
10
13
  'no-unused-vars': ['error', { caughtErrors: 'none' }],
11
14
  },
12
15
  languageOptions: {
13
- ecmaVersion: 2022,
16
+ ecmaVersion: 'latest',
14
17
  sourceType: 'module',
15
18
  globals: {
16
19
  ...globals.browser,
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.19.4",
5
+ "version": "3.19.5-dev.21fa5c45d",
6
6
  "main": "dist/js/uikit.js",
7
7
  "style": "dist/css/uikit.css",
8
8
  "sideEffects": [
@@ -10,6 +10,7 @@
10
10
  "./src/js/*.js",
11
11
  "./dist/**/*.js"
12
12
  ],
13
+ "type": "module",
13
14
  "repository": {
14
15
  "type": "git",
15
16
  "url": "git+https://github.com/uikit/uikit.git"
@@ -60,8 +61,6 @@
60
61
  "prefix": "node build/prefix",
61
62
  "scope": "node build/scope",
62
63
  "release": "node build/release",
63
- "watch": "chokidar \"**/*.less\" --initial -i \"node_modules\" -c \"node build/less\"",
64
- "eslint": "eslint src/js build/*.js",
65
- "eslint-fix": "eslint --fix src/js build/*.js"
64
+ "watch": "chokidar \"**/*.less\" --initial -i \"node_modules\" -c \"node build/less\""
66
65
  }
67
66
  }
@@ -46,21 +46,33 @@ function registerObservable(instance, observable) {
46
46
  const targets = hasOwn(instance, key) ? instance[key] : target;
47
47
  const observer = observe(targets, handler, options, args);
48
48
 
49
- if (isFunction(target) && isArray(instance[key]) && observer.unobserve) {
50
- registerWatch(instance, { handler: updateTargets(observer), immediate: false }, key);
49
+ if (isFunction(target) && isArray(instance[key])) {
50
+ registerWatch(
51
+ instance,
52
+ { handler: updateTargets(observer, options), immediate: false },
53
+ key,
54
+ );
51
55
  }
52
56
 
53
57
  registerObserver(instance, observer);
54
58
  }
55
59
 
56
- function updateTargets(observer) {
60
+ function updateTargets(observer, options) {
57
61
  return (targets, prev) => {
58
62
  for (const target of prev) {
59
- !includes(targets, target) && observer.unobserve(target);
63
+ if (!includes(targets, target)) {
64
+ if (observer.unobserve) {
65
+ observer.unobserve(target);
66
+ } else {
67
+ observer.disconnect();
68
+ }
69
+ }
60
70
  }
61
71
 
62
72
  for (const target of targets) {
63
- !includes(prev, target) && observer.observe(target);
73
+ if (!includes(prev, target) || !observer.unobserve) {
74
+ observer.observe(target, options);
75
+ }
64
76
  }
65
77
  };
66
78
  }
@@ -118,10 +118,7 @@ export default {
118
118
 
119
119
  await Promise.all(
120
120
  $$(this.target, this.$el).map((target) => {
121
- const filterFn = () => {
122
- applyState(state, target, getChildren(target));
123
- this.$update(this.$el);
124
- };
121
+ const filterFn = () => applyState(state, target, getChildren(target));
125
122
  return animate ? this.animate(filterFn, target) : filterFn();
126
123
  }),
127
124
  );
@@ -146,7 +143,9 @@ function isEqualState(stateA, stateB) {
146
143
  function applyState(state, target, children) {
147
144
  const selector = getSelector(state);
148
145
 
149
- children.forEach((el) => css(el, 'display', selector && !matches(el, selector) ? 'none' : ''));
146
+ for (const el of children) {
147
+ css(el, 'display', selector && !matches(el, selector) ? 'none' : '');
148
+ }
150
149
 
151
150
  const [sort, order] = state.sort;
152
151
 
@@ -29,7 +29,6 @@ import {
29
29
  removeClass,
30
30
  within,
31
31
  } from 'uikit-util';
32
- import { lazyload } from '../api/observables';
33
32
  import Container from '../mixin/container';
34
33
  import Position from '../mixin/position';
35
34
  import Togglable from '../mixin/togglable';
@@ -129,11 +128,6 @@ export default {
129
128
  css(this.$el, this._style);
130
129
  },
131
130
 
132
- observe: lazyload({
133
- target: ({ toggle, $el }) => query(toggle, $el),
134
- targets: ({ $el }) => $el,
135
- }),
136
-
137
131
  events: [
138
132
  {
139
133
  name: 'click',
@@ -56,13 +56,13 @@ export default {
56
56
  },
57
57
 
58
58
  observe: intersection({
59
- target: ({ $el, $props }) => [$el, ...queryAll($props.target, $el)],
60
59
  handler(entries, observer) {
61
60
  this.load();
62
61
  observer.disconnect();
63
62
  },
64
63
  options: ({ margin }) => ({ rootMargin: margin }),
65
64
  filter: ({ loading }) => loading === 'lazy',
65
+ target: ({ $el, $props }) => ($props.target ? [$el, ...queryAll($props.target, $el)] : $el),
66
66
  }),
67
67
 
68
68
  methods: {
@@ -1,5 +1,5 @@
1
- import { $$, css, dimensions, matches, observeResize, on, replaceClass } from 'uikit-util';
2
- import { mutation } from '../api/observables';
1
+ import { $$, css, dimensions, matches, observeResize, on, replaceClass, toNodes } from 'uikit-util';
2
+ import { intersection, mutation } from '../api/observables';
3
3
 
4
4
  export default {
5
5
  props: {
@@ -13,10 +13,16 @@ export default {
13
13
  },
14
14
 
15
15
  computed: {
16
- target: ({ target }, $el) => (target ? $$(target, $el) : [$el]),
16
+ target: ({ target }, $el) => (target ? $$(target, $el) : $el),
17
17
  },
18
18
 
19
19
  observe: [
20
+ intersection({
21
+ handler([{ isIntersecting }]) {
22
+ this.isIntersecting = isIntersecting;
23
+ },
24
+ args: { intersecting: false },
25
+ }),
20
26
  mutation({
21
27
  target: ({ target }) => target,
22
28
  options: { attributes: true, attributeFilter: ['class'], attributeOldValue: true },
@@ -24,7 +30,10 @@ export default {
24
30
  {
25
31
  target: ({ target }) => target,
26
32
  observe: (target, handler) => {
27
- const observer = observeResize([...target, document.documentElement], handler);
33
+ const observer = observeResize(
34
+ [...toNodes(target), document.documentElement],
35
+ handler,
36
+ );
28
37
  const listener = [
29
38
  on(document, 'scroll itemshown itemhidden', handler, {
30
39
  passive: true,
@@ -55,7 +64,11 @@ export default {
55
64
 
56
65
  update: {
57
66
  read() {
58
- for (const target of this.target) {
67
+ if (!this.isIntersecting) {
68
+ return false;
69
+ }
70
+
71
+ for (const target of toNodes(this.target)) {
59
72
  replaceClass(
60
73
  target,
61
74
  'uk-light,uk-dark',
@@ -15,10 +15,10 @@ export default {
15
15
  observe: [
16
16
  mutation({
17
17
  options: {
18
- childList: true,
19
18
  attributes: true,
20
19
  attributeFilter: ['style'],
21
20
  },
21
+ target: ({ $el }) => [$el, ...children($el)],
22
22
  }),
23
23
  resize({
24
24
  target: ({ $el }) => [$el, ...children($el)],
@@ -10,6 +10,7 @@ import {
10
10
  hasClass,
11
11
  includes,
12
12
  isNode,
13
+ isTag,
13
14
  matches,
14
15
  queryAll,
15
16
  toArray,
@@ -188,7 +189,11 @@ export default {
188
189
  ],
189
190
 
190
191
  update() {
191
- attr(this.connects, 'role', 'presentation');
192
+ for (const el of this.connects) {
193
+ if (isTag(el, 'ul')) {
194
+ attr(el, 'role', 'presentation');
195
+ }
196
+ }
192
197
  attr(children(this.$el), 'role', 'presentation');
193
198
 
194
199
  for (const index in this.toggles) {
@@ -58,7 +58,7 @@ export default {
58
58
  }
59
59
  },
60
60
 
61
- observe: lazyload({ target: ({ target }) => target }),
61
+ observe: lazyload({ targets: ({ target }) => target }),
62
62
 
63
63
  events: [
64
64
  {
@@ -18,57 +18,87 @@ export function findAll(selector, context) {
18
18
  return toNodes(_query(selector, toNode(context), 'querySelectorAll'));
19
19
  }
20
20
 
21
- const contextSelectorRe = /(^|[^\\],)\s*[!>+~-]/;
22
- const isContextSelector = memoize((selector) => selector.match(contextSelectorRe));
23
-
24
21
  function getContext(selector, context = document) {
25
- return (isString(selector) && isContextSelector(selector)) || isDocument(context)
22
+ return (isString(selector) && parseSelector(selector).isContextSelector) || isDocument(context)
26
23
  ? context
27
24
  : context.ownerDocument;
28
25
  }
29
26
 
30
- const contextSanitizeRe = /([!>+~-])(?=\s+[!>+~-]|\s*$)/g;
31
- const sanatize = memoize((selector) => selector.replace(contextSanitizeRe, '$1 *'));
27
+ const addStarRe = /([!>+~-])(?=\s+[!>+~-]|\s*$)/g;
28
+ const splitSelectorRe = /.*?[^\\](?![^(]*\))(?:,|$)/g;
29
+ const trailingCommaRe = /\s*,$/;
30
+
31
+ const parseSelector = memoize((selector) => {
32
+ selector = selector.replace(addStarRe, '$1 *');
33
+ let isContextSelector = false;
34
+
35
+ const selectors = [];
36
+ for (let sel of selector.match(splitSelectorRe)) {
37
+ sel = sel.replace(trailingCommaRe, '').trim();
38
+ if (sel[0] === '>') {
39
+ sel = `:scope ${sel}`;
40
+ }
41
+ isContextSelector ||= ['!', '+', '~', '-'].includes(sel[0]);
42
+ selectors.push(sel);
43
+ }
44
+
45
+ return {
46
+ selector: selectors.join(','),
47
+ selectors,
48
+ isContextSelector,
49
+ };
50
+ });
32
51
 
33
52
  function _query(selector, context = document, queryFn) {
34
53
  if (!selector || !isString(selector)) {
35
54
  return selector;
36
55
  }
37
56
 
38
- selector = sanatize(selector);
39
-
40
- if (isContextSelector(selector)) {
41
- const split = splitSelector(selector);
42
- selector = '';
43
- for (let sel of split) {
44
- let ctx = context;
45
-
46
- if (sel[0] === '!') {
47
- const selectors = sel.substr(1).trim().split(' ');
48
- ctx = parent(context).closest(selectors[0]);
49
- sel = selectors.slice(1).join(' ').trim();
50
- if (!sel.length && split.length === 1) {
51
- return ctx;
52
- }
53
- }
57
+ const parsed = parseSelector(selector);
58
+
59
+ if (!parsed.isContextSelector) {
60
+ return _doQuery(context, queryFn, parsed.selector);
61
+ }
54
62
 
55
- if (sel[0] === '-') {
56
- const selectors = sel.substr(1).trim().split(' ');
57
- const prev = (ctx || context).previousElementSibling;
58
- ctx = matches(prev, sel.substr(1)) ? prev : null;
59
- sel = selectors.slice(1).join(' ');
63
+ selector = '';
64
+ const isSingle = parsed.selectors.length === 1;
65
+ for (let sel of parsed.selectors) {
66
+ let ctx = context;
67
+
68
+ if (sel[0] === '!') {
69
+ const selectors = sel.substr(1).trim().split(' ');
70
+ ctx = parent(context).closest(selectors[0]);
71
+ sel = selectors.slice(1).join(' ').trim();
72
+ if (!sel.length && isSingle) {
73
+ return ctx;
60
74
  }
75
+ }
61
76
 
62
- if (ctx) {
63
- selector += `${selector ? ',' : ''}${domPath(ctx)} ${sel}`;
77
+ if (sel[0] === '-') {
78
+ const selectors = sel.substr(1).trim().split(' ');
79
+ const prev = (ctx || context).previousElementSibling;
80
+ ctx = matches(prev, sel.substr(1)) ? prev : null;
81
+ sel = selectors.slice(1).join(' ');
82
+ if (!sel.length && isSingle) {
83
+ return ctx;
64
84
  }
85
+ } else if (sel[0] === '~' || (sel[0] === '+' && isSingle)) {
86
+ return _doQuery(parent(ctx), queryFn, `:scope :nth-child(${index(ctx) + 1}) ${sel}`);
65
87
  }
66
88
 
67
- if (!isDocument(context)) {
68
- context = context.ownerDocument;
89
+ if (ctx) {
90
+ selector += `${selector ? ',' : ''}${domPath(ctx)} ${sel}`;
69
91
  }
70
92
  }
71
93
 
94
+ if (!isDocument(context)) {
95
+ context = context.ownerDocument;
96
+ }
97
+
98
+ return _doQuery(context, queryFn, selector);
99
+ }
100
+
101
+ function _doQuery(context, queryFn, selector) {
72
102
  try {
73
103
  return context[queryFn](selector);
74
104
  } catch (e) {
@@ -76,12 +106,6 @@ function _query(selector, context = document, queryFn) {
76
106
  }
77
107
  }
78
108
 
79
- const selectorRe = /.*?[^\\](?![^(]*\))(?:,|$)/g;
80
-
81
- const splitSelector = memoize((selector) =>
82
- selector.match(selectorRe).map((selector) => selector.replace(/,$/, '').trim()),
83
- );
84
-
85
109
  function domPath(element) {
86
110
  const names = [];
87
111
  while (element.parentNode) {
@@ -1,16 +1,5 @@
1
1
  import { $$ } from './dom';
2
2
 
3
3
  export function getMaxPathLength(el) {
4
- return Math.ceil(
5
- Math.max(
6
- 0,
7
- ...$$('[stroke]', el).map((stroke) => {
8
- try {
9
- return stroke.getTotalLength();
10
- } catch (e) {
11
- return 0;
12
- }
13
- }),
14
- ),
15
- );
4
+ return Math.ceil(Math.max(0, ...$$('[stroke]', el).map((stroke) => stroke.getTotalLength?.())));
16
5
  }
package/tests/modal.html CHANGED
@@ -382,14 +382,14 @@
382
382
  <div id="modal-media-youtube" uk-modal>
383
383
  <div class="uk-modal-dialog uk-width-auto uk-margin-auto-vertical">
384
384
  <button class="uk-modal-close-outside" type="button" uk-close></button>
385
- <iframe src="https://www.youtube-nocookie.com/embed/c2pz2mlSfXA" width="1920" height="1080" uk-responsive uk-video></iframe>
385
+ <iframe src="https://www.youtube-nocookie.com/embed/c2pz2mlSfXA" width="1920" height="1080" loading="lazy" uk-responsive uk-video></iframe>
386
386
  </div>
387
387
  </div>
388
388
 
389
389
  <div id="modal-media-vimeo" uk-modal>
390
390
  <div class="uk-modal-dialog uk-width-auto uk-margin-auto-vertical">
391
391
  <button class="uk-modal-close-outside" type="button" uk-close></button>
392
- <iframe src="https://player.vimeo.com/video/1084537" width="500" height="281" uk-responsive uk-video></iframe>
392
+ <iframe src="https://player.vimeo.com/video/1084537" width="500" height="281" loading="lazy" uk-responsive uk-video></iframe>
393
393
  </div>
394
394
  </div>
395
395
 
@@ -1,4 +0,0 @@
1
- {
2
- "private": true,
3
- "type": "module"
4
- }