uikit 3.16.11-dev.bde560a72 → 3.16.11-dev.cc1aeb568

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 +1 -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 +85 -562
  15. package/dist/js/components/lightbox-panel.min.js +1 -1
  16. package/dist/js/components/lightbox.js +96 -574
  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 +309 -336
  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 +435 -464
  41. package/dist/js/uikit.min.js +1 -1
  42. package/package.json +1 -1
  43. package/src/js/api/computed.js +48 -1
  44. package/src/js/api/hooks.js +12 -8
  45. package/src/js/api/observer.js +23 -41
  46. package/src/js/api/options.js +1 -0
  47. package/src/js/api/update.js +21 -37
  48. package/src/js/api/watch.js +21 -24
  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/drop.js +1 -1
  54. package/src/js/core/dropnav.js +46 -60
  55. package/src/js/core/height-match.js +2 -8
  56. package/src/js/core/img.js +6 -5
  57. package/src/js/core/navbar.js +19 -32
  58. package/src/js/core/scrollspy-nav.js +10 -12
  59. package/src/js/core/scrollspy.js +16 -17
  60. package/src/js/core/switcher.js +29 -40
  61. package/src/js/core/toggle.js +3 -7
  62. package/src/js/{util → mixin/internal}/scroll.js +1 -5
  63. package/src/js/mixin/modal.js +1 -1
  64. package/src/js/mixin/slider-nav.js +80 -76
  65. package/src/js/mixin/slider.js +10 -8
  66. package/src/js/util/fastdom.js +2 -2
  67. package/tests/drop.html +0 -1
  68. package/tests/dropnav.html +1 -1
  69. package/tests/icon.html +0 -2
  70. package/tests/modal.html +0 -1
  71. package/tests/nav.html +0 -1
  72. package/tests/navbar.html +0 -1
  73. package/tests/progress.html +0 -1
  74. package/tests/scroll.html +0 -1
  75. package/tests/sticky-navbar.html +6 -6
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.11-dev.bde560a72",
5
+ "version": "3.16.11-dev.cc1aeb568",
6
6
  "main": "dist/js/uikit.js",
7
7
  "style": "dist/css/uikit.css",
8
8
  "sideEffects": [
@@ -1,3 +1,5 @@
1
+ import { runWatches } from './watch';
2
+ import { callUpdate, prependUpdate } from './update';
1
3
  import { hasOwn, isUndefined } from 'uikit-util';
2
4
 
3
5
  export function initComputed(instance) {
@@ -12,7 +14,8 @@ export function initComputed(instance) {
12
14
  }
13
15
  }
14
16
 
15
- function registerComputed(instance, key, cb) {
17
+ export function registerComputed(instance, key, cb) {
18
+ instance._hasComputed = true;
16
19
  Object.defineProperty(instance, key, {
17
20
  enumerable: true,
18
21
 
@@ -37,3 +40,47 @@ function registerComputed(instance, key, cb) {
37
40
  },
38
41
  });
39
42
  }
43
+
44
+ export function initComputedUpdates(instance) {
45
+ if (!instance._hasComputed) {
46
+ return;
47
+ }
48
+
49
+ prependUpdate(instance, {
50
+ read: () => runWatches(instance, resetComputed(instance)),
51
+ events: ['resize', 'computed'],
52
+ });
53
+
54
+ registerComputedObserver();
55
+ instances.add(instance);
56
+ }
57
+
58
+ export function disconnectComputedUpdates(instance) {
59
+ instances?.delete(instance);
60
+ resetComputed(instance);
61
+ }
62
+
63
+ function resetComputed(instance) {
64
+ const values = { ...instance._computed };
65
+ instance._computed = {};
66
+ return values;
67
+ }
68
+
69
+ let observer;
70
+ let instances;
71
+ function registerComputedObserver() {
72
+ if (observer) {
73
+ return;
74
+ }
75
+
76
+ instances = new Set();
77
+ observer = new MutationObserver(() => {
78
+ for (const instance of instances) {
79
+ callUpdate(instance, 'computed');
80
+ }
81
+ });
82
+ observer.observe(document, {
83
+ childList: true,
84
+ subtree: true,
85
+ });
86
+ }
@@ -1,5 +1,7 @@
1
+ import { disconnectComputedUpdates, initComputedUpdates } from './computed';
1
2
  import { log } from './log';
2
- import { callUpdate, initUpdateObserver } from './update';
3
+ import { initWatches } from './watch';
4
+ import { callUpdate, clearUpdateData, initUpdates } from './update';
3
5
  import { initEvents, unbindEvents } from './events';
4
6
  import { initProps, initPropsObserver } from './props';
5
7
  import { disconnectObservers, initObservers } from './observer';
@@ -14,19 +16,18 @@ export function callConnected(instance) {
14
16
  return;
15
17
  }
16
18
 
17
- instance._data = {};
18
- instance._computed = {};
19
-
20
19
  initProps(instance);
21
20
 
22
21
  callHook(instance, 'beforeConnect');
23
22
  instance._connected = true;
24
23
 
25
24
  initEvents(instance);
26
-
25
+ initUpdates(instance);
26
+ initWatches(instance);
27
27
  initObservers(instance);
28
+
28
29
  initPropsObserver(instance);
29
- initUpdateObserver(instance);
30
+ initComputedUpdates(instance);
30
31
 
31
32
  callHook(instance, 'connected');
32
33
  callUpdate(instance);
@@ -38,10 +39,13 @@ export function callDisconnected(instance) {
38
39
  }
39
40
 
40
41
  callHook(instance, 'beforeDisconnect');
41
- disconnectObservers(instance);
42
+
42
43
  unbindEvents(instance);
44
+ clearUpdateData(instance);
45
+ disconnectObservers(instance);
46
+ disconnectComputedUpdates(instance);
47
+
43
48
  callHook(instance, 'disconnected');
44
49
 
45
50
  instance._connected = false;
46
- delete instance._watch;
47
51
  }
@@ -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 { registerWatch } from './watch';
2
+ import { registerComputed } from './computed';
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,46 @@ 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) && !hasOwn(instance, key)) {
37
+ registerComputed(instance, key, () => target.call(instance, instance));
38
+ }
39
+
57
40
  handler = isString(handler) ? instance[handler] : handler.bind(instance);
58
41
 
59
42
  if (isFunction(options)) {
60
43
  options = options.call(instance, instance);
61
44
  }
62
45
 
46
+ const targets = hasOwn(instance, key) ? instance[key] : target;
63
47
  const observer = observe(targets, handler, options, args);
64
48
 
65
- if (isFunction(target) && isArray(targets) && observer.unobserve) {
66
- instance._observerUpdates.set(observer, watchChange(instance, target, targets));
49
+ if (isFunction(target) && isArray(instance[key]) && observer.unobserve) {
50
+ registerWatch(instance, { handler: updateTargets(observer), immediate: false }, key);
67
51
  }
68
52
 
69
53
  registerObserver(instance, observer);
70
54
  }
71
55
 
72
- function watchChange(instance, targetFn, targets) {
73
- return (observer) => {
74
- const newTargets = targetFn.call(instance, instance);
75
-
76
- if (isEqual(targets, newTargets)) {
77
- return;
56
+ function updateTargets(observer) {
57
+ return (targets, prev) => {
58
+ for (const target of prev) {
59
+ !includes(targets, target) && observer.unobserve(target);
78
60
  }
79
61
 
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);
62
+ for (const target of targets) {
63
+ !includes(prev, target) && observer.observe(target);
64
+ }
83
65
  };
84
66
  }
@@ -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,42 @@
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._data = {};
5
+ instance._updates = [...(instance.$options.update || [])];
6
+ }
7
+
8
+ export function prependUpdate(instance, update) {
9
+ instance._updates.unshift(update);
10
+ }
11
+
12
+ export function clearUpdateData(instance) {
13
+ delete instance._data;
14
+ }
4
15
 
5
16
  export function callUpdate(instance, e = 'update') {
6
17
  if (!instance._connected) {
7
18
  return;
8
19
  }
9
20
 
10
- if (e === 'update' || e === 'resize') {
11
- callWatches(instance);
12
- }
13
-
14
- if (!instance.$options.update) {
21
+ if (!instance._updates.length) {
15
22
  return;
16
23
  }
17
24
 
18
- if (!instance._updates) {
19
- instance._updates = new Set();
25
+ if (!instance._queued) {
26
+ instance._queued = new Set();
20
27
  fastdom.read(() => {
21
28
  if (instance._connected) {
22
- runUpdates(instance, instance._updates);
29
+ runUpdates(instance, instance._queued);
23
30
  }
24
- delete instance._updates;
31
+ delete instance._queued;
25
32
  });
26
33
  }
27
34
 
28
- instance._updates.add(e.type || e);
35
+ instance._queued.add(e.type || e);
29
36
  }
30
37
 
31
38
  function runUpdates(instance, types) {
32
- for (const { read, write, events = [] } of instance.$options.update) {
39
+ for (const { read, write, events = [] } of instance._updates) {
33
40
  if (!types.has('update') && !events.some((type) => types.has(type))) {
34
41
  continue;
35
42
  }
@@ -52,26 +59,3 @@ function runUpdates(instance, types) {
52
59
  }
53
60
  }
54
61
  }
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,31 @@
1
- import { fastdom, hasOwn, isEqual } from 'uikit-util';
2
- import { callObserverUpdates } from './observer';
1
+ import { hasOwn, isEqual, isPlainObject } from 'uikit-util';
3
2
 
4
- export function callWatches(instance) {
5
- if (instance._watch) {
6
- return;
7
- }
8
-
9
- const initial = !hasOwn(instance, '_watch');
10
-
11
- instance._watch = fastdom.read(() => {
12
- if (instance._connected) {
13
- runWatches(instance, initial);
3
+ export function initWatches(instance) {
4
+ instance._watches = [];
5
+ for (const watches of instance.$options.watch || []) {
6
+ for (const [name, watch] of Object.entries(watches)) {
7
+ registerWatch(instance, watch, name);
14
8
  }
15
- instance._watch = null;
16
- }, true);
9
+ }
10
+ instance._initial = true;
17
11
  }
18
12
 
19
- function runWatches(instance, initial) {
20
- const values = { ...instance._computed };
21
- instance._computed = {};
13
+ export function registerWatch(instance, watch, name) {
14
+ instance._watches.push({
15
+ name,
16
+ ...(isPlainObject(watch) ? watch : { handler: watch }),
17
+ });
18
+ }
22
19
 
23
- for (const [key, { watch, immediate }] of Object.entries(instance.$options.computed || {})) {
20
+ export function runWatches(instance, values) {
21
+ for (const { name, handler, immediate = true } of instance._watches) {
24
22
  if (
25
- watch &&
26
- ((initial && immediate) ||
27
- (hasOwn(values, key) && !isEqual(values[key], instance[key])))
23
+ instance._initial
24
+ ? immediate
25
+ : hasOwn(values, name) && !isEqual(values[name], instance[name])
28
26
  ) {
29
- watch.call(instance, instance[key], initial ? undefined : values[key]);
27
+ handler.call(instance, instance[name], instance._initial ? undefined : values[name]);
30
28
  }
31
29
  }
32
-
33
- callObserverUpdates(instance);
30
+ instance._initial = false;
34
31
  }
@@ -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
 
@@ -3,7 +3,7 @@ import Position from '../mixin/position';
3
3
  import Container from '../mixin/container';
4
4
  import Togglable from '../mixin/togglable';
5
5
  import { keyMap } from '../util/keys';
6
- import { preventBackgroundScroll } from '../util/scroll';
6
+ import { preventBackgroundScroll } from '../mixin/internal/scroll';
7
7
  import {
8
8
  addClass,
9
9
  append,