uikit 3.16.10 → 3.16.11-dev.55a0fc5b5

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 (61) hide show
  1. package/CHANGELOG.md +7 -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 +24 -28
  13. package/dist/js/components/filter.min.js +1 -1
  14. package/dist/js/components/lightbox-panel.js +79 -72
  15. package/dist/js/components/lightbox-panel.min.js +1 -1
  16. package/dist/js/components/lightbox.js +90 -84
  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 +79 -72
  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 +79 -72
  29. package/dist/js/components/slideshow.min.js +1 -1
  30. package/dist/js/components/sortable.js +14 -18
  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 +256 -279
  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 +381 -406
  41. package/dist/js/uikit.min.js +1 -1
  42. package/package.json +1 -1
  43. package/src/js/api/computed.js +7 -1
  44. package/src/js/api/hooks.js +7 -4
  45. package/src/js/api/observer.js +44 -43
  46. package/src/js/api/options.js +1 -0
  47. package/src/js/api/update.js +15 -36
  48. package/src/js/api/watch.js +33 -20
  49. package/src/js/components/filter.js +23 -29
  50. package/src/js/components/lightbox.js +12 -14
  51. package/src/js/components/sortable.js +13 -19
  52. package/src/js/core/accordion.js +32 -45
  53. package/src/js/core/dropnav.js +37 -43
  54. package/src/js/core/height-match.js +2 -8
  55. package/src/js/core/navbar.js +3 -12
  56. package/src/js/core/scrollspy-nav.js +10 -12
  57. package/src/js/core/scrollspy.js +10 -12
  58. package/src/js/core/switcher.js +30 -37
  59. package/src/js/mixin/slider-nav.js +80 -76
  60. package/src/js/mixin/slider.js +10 -8
  61. package/src/js/util/fastdom.js +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.16.10",
5
+ "version": "3.16.11-dev.55a0fc5b5",
6
6
  "main": "dist/js/uikit.js",
7
7
  "style": "dist/css/uikit.css",
8
8
  "sideEffects": [
@@ -12,7 +12,13 @@ export function initComputed(instance) {
12
12
  }
13
13
  }
14
14
 
15
- function registerComputed(instance, key, cb) {
15
+ export function resetComputed(instance) {
16
+ const values = { ...instance._computed };
17
+ instance._computed = {};
18
+ return values;
19
+ }
20
+
21
+ export function registerComputed(instance, key, cb) {
16
22
  Object.defineProperty(instance, key, {
17
23
  enumerable: true,
18
24
 
@@ -1,8 +1,9 @@
1
1
  import { log } from './log';
2
- import { callUpdate, initUpdateObserver } from './update';
2
+ import { initWatches } from './watch';
3
+ import { callUpdate, initUpdates } from './update';
3
4
  import { initEvents, unbindEvents } from './events';
4
5
  import { initProps, initPropsObserver } from './props';
5
- import { disconnectObservers, initObservers } from './observer';
6
+ import { disconnectObservers, initObservers, initWatchObserver } from './observer';
6
7
 
7
8
  export function callHook(instance, hook) {
8
9
  LOG && log(instance, hook);
@@ -23,10 +24,12 @@ export function callConnected(instance) {
23
24
  instance._connected = true;
24
25
 
25
26
  initEvents(instance);
26
-
27
+ initUpdates(instance);
28
+ initWatches(instance);
27
29
  initObservers(instance);
30
+
28
31
  initPropsObserver(instance);
29
- initUpdateObserver(instance);
32
+ initWatchObserver(instance);
30
33
 
31
34
  callHook(instance, 'connected');
32
35
  callUpdate(instance);
@@ -1,22 +1,15 @@
1
- import {
2
- hasOwn,
3
- includes,
4
- isArray,
5
- isEqual,
6
- isFunction,
7
- isPlainObject,
8
- isString,
9
- } from 'uikit-util';
1
+ import { registerComputed } from './computed';
2
+ import { callWatches, registerWatch } from './watch';
3
+ import { hasOwn, includes, isArray, isFunction, isString } from 'uikit-util';
10
4
 
11
5
  export function initObservers(instance) {
12
6
  instance._observers = [];
13
- instance._observerUpdates = new Map();
14
7
  for (const observer of instance.$options.observe || []) {
15
8
  if (hasOwn(observer, 'handler')) {
16
9
  registerObservable(instance, observer);
17
10
  } else {
18
- for (const key in observer) {
19
- registerObservable(instance, observer[key], key);
11
+ for (const observable of observer) {
12
+ registerObservable(instance, observable);
20
13
  }
21
14
  }
22
15
  }
@@ -28,57 +21,65 @@ export function registerObserver(instance, ...observer) {
28
21
 
29
22
  export function disconnectObservers(instance) {
30
23
  for (const observer of instance._observers) {
31
- observer?.disconnect();
32
- instance._observerUpdates.delete(observer);
24
+ observer.disconnect();
33
25
  }
34
26
  }
35
27
 
36
- export function callObserverUpdates(instance) {
37
- for (const [observer, update] of instance._observerUpdates) {
38
- update(observer);
39
- }
40
- }
41
-
42
- function registerObservable(instance, observable, key) {
43
- let {
44
- observe,
45
- target = instance.$el,
46
- handler,
47
- options,
48
- filter,
49
- args,
50
- } = isPlainObject(observable) ? observable : { type: key, handler: observable };
28
+ function registerObservable(instance, observable) {
29
+ let { observe, target = instance.$el, handler, options, filter, args } = observable;
51
30
 
52
31
  if (filter && !filter.call(instance, instance)) {
53
32
  return;
54
33
  }
55
34
 
56
- const targets = isFunction(target) ? target.call(instance, instance) : target;
35
+ const key = `_observe${instance._observers.length}`;
36
+ if (isFunction(target) && !(key in instance)) {
37
+ registerComputed(instance, key, () => target.call(instance, instance));
38
+ target = instance[key];
39
+ }
40
+
57
41
  handler = isString(handler) ? instance[handler] : handler.bind(instance);
58
42
 
59
43
  if (isFunction(options)) {
60
44
  options = options.call(instance, instance);
61
45
  }
62
46
 
63
- const observer = observe(targets, handler, options, args);
47
+ const observer = observe(target, handler, options, args);
48
+
49
+ if (isFunction(target) && isArray(instance[key]) && observer.unobserve) {
50
+ registerWatch(
51
+ instance,
52
+ {
53
+ handler(targets, prev) {
54
+ for (const target of prev) {
55
+ !includes(targets, target) && observer.unobserve(target);
56
+ }
64
57
 
65
- if (isFunction(target) && isArray(targets) && observer.unobserve) {
66
- instance._observerUpdates.set(observer, watchChange(instance, target, targets));
58
+ for (const target of targets) {
59
+ !includes(prev, target) && observer.observe(target);
60
+ }
61
+ },
62
+ immediate: false,
63
+ },
64
+ key
65
+ );
67
66
  }
68
67
 
69
68
  registerObserver(instance, observer);
70
69
  }
71
70
 
72
- function watchChange(instance, targetFn, targets) {
73
- return (observer) => {
74
- const newTargets = targetFn.call(instance, instance);
71
+ export function initWatchObserver(instance) {
72
+ let { el, computed } = instance.$options;
75
73
 
76
- if (isEqual(targets, newTargets)) {
77
- return;
78
- }
74
+ if (!computed && !instance._watches) {
75
+ return;
76
+ }
79
77
 
80
- targets.forEach((target) => !includes(newTargets, target) && observer.unobserve(target));
81
- newTargets.forEach((target) => !includes(targets, target) && observer.observe(target));
82
- targets.splice(0, targets.length, ...newTargets);
83
- };
78
+ const observer = new MutationObserver(() => callWatches(instance));
79
+ observer.observe(instance._observeTarget || el, {
80
+ childList: true,
81
+ subtree: true,
82
+ });
83
+
84
+ registerObserver(instance, observer);
84
85
  }
@@ -15,6 +15,7 @@ import {
15
15
  const strats = {};
16
16
 
17
17
  strats.events =
18
+ strats.watch =
18
19
  strats.observe =
19
20
  strats.created =
20
21
  strats.beforeConnect =
@@ -1,35 +1,37 @@
1
- import { registerObserver } from './observer';
2
- import { callWatches } from './watch';
3
- import { assign, fastdom, isFunction, isPlainObject } from 'uikit-util';
1
+ import { assign, fastdom, isPlainObject } from 'uikit-util';
2
+
3
+ export function initUpdates(instance) {
4
+ instance._updates = [...(instance.$options.update || [])];
5
+ }
6
+
7
+ export function prependUpdate(instance, update) {
8
+ instance._updates.unshift(update);
9
+ }
4
10
 
5
11
  export function callUpdate(instance, e = 'update') {
6
12
  if (!instance._connected) {
7
13
  return;
8
14
  }
9
15
 
10
- if (e === 'update' || e === 'resize') {
11
- callWatches(instance);
12
- }
13
-
14
16
  if (!instance.$options.update) {
15
17
  return;
16
18
  }
17
19
 
18
- if (!instance._updates) {
19
- instance._updates = new Set();
20
+ if (!instance._queued) {
21
+ instance._queued = new Set();
20
22
  fastdom.read(() => {
21
23
  if (instance._connected) {
22
- runUpdates(instance, instance._updates);
24
+ runUpdates(instance, instance._queued);
23
25
  }
24
- delete instance._updates;
26
+ delete instance._queued;
25
27
  });
26
28
  }
27
29
 
28
- instance._updates.add(e.type || e);
30
+ instance._queued.add(e.type || e);
29
31
  }
30
32
 
31
33
  function runUpdates(instance, types) {
32
- for (const { read, write, events = [] } of instance.$options.update) {
34
+ for (const { read, write, events = [] } of instance._updates) {
33
35
  if (!types.has('update') && !events.some((type) => types.has(type))) {
34
36
  continue;
35
37
  }
@@ -52,26 +54,3 @@ function runUpdates(instance, types) {
52
54
  }
53
55
  }
54
56
  }
55
-
56
- export function initUpdateObserver(instance) {
57
- let { el, computed, observe } = instance.$options;
58
-
59
- if (!computed && !observe?.some((options) => isFunction(options.target))) {
60
- return;
61
- }
62
-
63
- for (const key in computed || {}) {
64
- if (computed[key].document) {
65
- el = el.ownerDocument;
66
- break;
67
- }
68
- }
69
-
70
- const observer = new MutationObserver(() => callWatches(instance));
71
- observer.observe(el, {
72
- childList: true,
73
- subtree: true,
74
- });
75
-
76
- registerObserver(instance, observer);
77
- }
@@ -1,34 +1,47 @@
1
- import { fastdom, hasOwn, isEqual } from 'uikit-util';
2
- import { callObserverUpdates } from './observer';
1
+ import { resetComputed } from './computed';
2
+ import { prependUpdate } from './update';
3
+ import { hasOwn, isEqual, isPlainObject } from 'uikit-util';
4
+
5
+ export function initWatches(instance) {
6
+ instance._watches = [];
7
+ for (const watches of instance.$options.watch || []) {
8
+ for (const [name, watch] of Object.entries(watches)) {
9
+ registerWatch(instance, watch, name);
10
+ }
11
+ }
12
+ instance._initial = true;
13
+ prependUpdate(instance, { read: () => callWatches(instance), events: ['resize'] });
14
+ }
15
+
16
+ export function registerWatch(instance, watch, name) {
17
+ instance._watches.push({
18
+ name,
19
+ ...(isPlainObject(watch) ? watch : { handler: watch }),
20
+ });
21
+
22
+ if (watch.document) {
23
+ instance._observeTarget = instance.$options.el.ownerDocumentocument;
24
+ }
25
+ }
3
26
 
4
27
  export function callWatches(instance) {
5
- if (instance._watch) {
28
+ if (!instance._connected) {
6
29
  return;
7
30
  }
8
31
 
9
- const initial = !hasOwn(instance, '_watch');
10
-
11
- instance._watch = fastdom.read(() => {
12
- if (instance._connected) {
13
- runWatches(instance, initial);
14
- }
15
- instance._watch = null;
16
- }, true);
32
+ runWatches(instance, instance._initial);
33
+ instance._initial = false;
17
34
  }
18
35
 
19
36
  function runWatches(instance, initial) {
20
- const values = { ...instance._computed };
21
- instance._computed = {};
37
+ const values = resetComputed(instance);
22
38
 
23
- for (const [key, { watch, immediate }] of Object.entries(instance.$options.computed || {})) {
39
+ for (const { name, handler, immediate = true } of instance._watches) {
24
40
  if (
25
- watch &&
26
- ((initial && immediate) ||
27
- (hasOwn(values, key) && !isEqual(values[key], instance[key])))
41
+ (initial && immediate) ||
42
+ (hasOwn(values, name) && !isEqual(values[name], instance[name]))
28
43
  ) {
29
- watch.call(instance, instance[key], initial ? undefined : values[key]);
44
+ handler.call(instance, instance[name], initial ? undefined : values[name]);
30
45
  }
31
46
  }
32
-
33
- callObserverUpdates(instance);
34
47
  }
@@ -42,41 +42,35 @@ export default {
42
42
  },
43
43
 
44
44
  computed: {
45
- toggles: {
46
- get({ attrItem }, $el) {
47
- return $$(`[${attrItem}],[data-${attrItem}]`, $el);
48
- },
49
-
50
- watch(toggles) {
51
- this.updateState();
52
-
53
- const actives = $$(this.selActive, this.$el);
54
- for (const toggle of toggles) {
55
- if (this.selActive !== false) {
56
- toggleClass(toggle, this.cls, includes(actives, toggle));
57
- }
58
- const button = findButton(toggle);
59
- if (isTag(button, 'a')) {
60
- attr(button, 'role', 'button');
61
- }
62
- }
63
- },
45
+ toggles({ attrItem }, $el) {
46
+ return $$(`[${attrItem}],[data-${attrItem}]`, $el);
47
+ },
64
48
 
65
- immediate: true,
49
+ children({ target }, $el) {
50
+ return $$(`${target} > *`, $el);
66
51
  },
52
+ },
67
53
 
68
- children: {
69
- get({ target }, $el) {
70
- return $$(`${target} > *`, $el);
71
- },
54
+ watch: {
55
+ toggles(toggles) {
56
+ this.updateState();
72
57
 
73
- watch(list, prev) {
74
- if (prev) {
75
- this.updateState();
58
+ const actives = $$(this.selActive, this.$el);
59
+ for (const toggle of toggles) {
60
+ if (this.selActive !== false) {
61
+ toggleClass(toggle, this.cls, includes(actives, toggle));
76
62
  }
77
- },
63
+ const button = findButton(toggle);
64
+ if (isTag(button, 'a')) {
65
+ attr(button, 'role', 'button');
66
+ }
67
+ }
68
+ },
78
69
 
79
- immediate: true,
70
+ children(list, prev) {
71
+ if (prev) {
72
+ this.updateState();
73
+ }
80
74
  },
81
75
  },
82
76
 
@@ -10,21 +10,19 @@ export default {
10
10
  data: { toggle: 'a' },
11
11
 
12
12
  computed: {
13
- toggles: {
14
- get({ toggle }, $el) {
15
- return $$(toggle, $el);
16
- },
17
-
18
- watch(toggles) {
19
- this.hide();
20
- for (const toggle of toggles) {
21
- if (isTag(toggle, 'a')) {
22
- attr(toggle, 'role', 'button');
23
- }
24
- }
25
- },
13
+ toggles({ toggle }, $el) {
14
+ return $$(toggle, $el);
15
+ },
16
+ },
26
17
 
27
- immediate: true,
18
+ watch: {
19
+ toggles(toggles) {
20
+ this.hide();
21
+ for (const toggle of toggles) {
22
+ if (isTag(toggle, 'a')) {
23
+ attr(toggle, 'role', 'button');
24
+ }
25
+ }
28
26
  },
29
27
  },
30
28
 
@@ -92,29 +92,23 @@ export default {
92
92
  return children(this.target);
93
93
  },
94
94
 
95
- isEmpty: {
96
- get() {
97
- return isEmpty(this.items);
98
- },
99
-
100
- watch(empty) {
101
- toggleClass(this.target, this.clsEmpty, empty);
102
- },
103
-
104
- immediate: true,
95
+ isEmpty() {
96
+ return isEmpty(this.items);
105
97
  },
106
98
 
107
- handles: {
108
- get({ handle }, el) {
109
- return handle ? $$(handle, el) : this.items;
110
- },
99
+ handles({ handle }, el) {
100
+ return handle ? $$(handle, el) : this.items;
101
+ },
102
+ },
111
103
 
112
- watch(handles, prev) {
113
- css(prev, { touchAction: '', userSelect: '' });
114
- css(handles, { touchAction: hasTouch ? 'none' : '', userSelect: 'none' }); // touchAction set to 'none' causes a performance drop in Chrome 80
115
- },
104
+ watch: {
105
+ isEmpty(empty) {
106
+ toggleClass(this.target, this.clsEmpty, empty);
107
+ },
116
108
 
117
- immediate: true,
109
+ handles(handles, prev) {
110
+ css(prev, { touchAction: '', userSelect: '' });
111
+ css(handles, { touchAction: hasTouch ? 'none' : '', userSelect: 'none' }); // touchAction set to 'none' causes a performance drop in Chrome 80
118
112
  },
119
113
  },
120
114
 
@@ -53,61 +53,48 @@ export default {
53
53
  },
54
54
 
55
55
  computed: {
56
- items: {
57
- get({ targets }, $el) {
58
- return $$(targets, $el);
59
- },
60
-
61
- watch(items, prev) {
62
- if (prev || hasClass(items, this.clsOpen)) {
63
- return;
64
- }
65
-
66
- const active =
67
- (this.active !== false && items[Number(this.active)]) ||
68
- (!this.collapsible && items[0]);
56
+ items({ targets }, $el) {
57
+ return $$(targets, $el);
58
+ },
69
59
 
70
- if (active) {
71
- this.toggle(active, false);
72
- }
73
- },
60
+ toggles({ toggle }) {
61
+ return this.items.map((item) => $(toggle, item));
62
+ },
74
63
 
75
- immediate: true,
64
+ contents({ content }) {
65
+ return this.items.map((item) => item._wrapper?.firstElementChild || $(content, item));
76
66
  },
67
+ },
77
68
 
78
- toggles: {
79
- get({ toggle }) {
80
- return this.items.map((item) => $(toggle, item));
81
- },
69
+ watch: {
70
+ items(items, prev) {
71
+ if (prev || hasClass(items, this.clsOpen)) {
72
+ return;
73
+ }
82
74
 
83
- watch() {
84
- this.$emit();
85
- },
75
+ const active =
76
+ (this.active !== false && items[Number(this.active)]) ||
77
+ (!this.collapsible && items[0]);
86
78
 
87
- immediate: true,
79
+ if (active) {
80
+ this.toggle(active, false);
81
+ }
88
82
  },
89
83
 
90
- contents: {
91
- get({ content }) {
92
- return this.items.map(
93
- (item) => item._wrapper?.firstElementChild || $(content, item)
94
- );
95
- },
84
+ toggles() {
85
+ this.$emit();
86
+ },
96
87
 
97
- watch(items) {
98
- for (const el of items) {
99
- hide(
100
- el,
101
- !hasClass(
102
- this.items.find((item) => within(el, item)),
103
- this.clsOpen
104
- )
105
- );
106
- }
107
- this.$emit();
108
- },
88
+ contents(items) {
89
+ for (const el of items) {
90
+ const isOpen = hasClass(
91
+ this.items.find((item) => within(el, item)),
92
+ this.clsOpen
93
+ );
109
94
 
110
- immediate: true,
95
+ hide(el, !isOpen);
96
+ }
97
+ this.$emit();
111
98
  },
112
99
  },
113
100