uikit 3.11.2-dev.c2430c233 → 3.11.2-dev.c7ed3c19b
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.
- package/.eslintrc.json +4 -49
- package/.prettierignore +14 -0
- package/.prettierrc.json +13 -0
- package/.webstorm.js +3 -3
- package/CHANGELOG.md +5 -0
- package/build/.eslintrc.json +1 -3
- package/build/build.js +26 -28
- package/build/icons.js +7 -11
- package/build/less.js +48 -36
- package/build/package.json +2 -2
- package/build/prefix.js +21 -18
- package/build/publishDev.js +6 -8
- package/build/release.js +20 -17
- package/build/scope.js +21 -11
- package/build/scss.js +72 -39
- package/build/util.js +71 -62
- package/build/wrapper/icons.js +0 -2
- package/dist/css/uikit-core-rtl.css +1 -1
- package/dist/css/uikit-core-rtl.min.css +1 -1
- package/dist/css/uikit-core.css +1 -1
- package/dist/css/uikit-core.min.css +1 -1
- package/dist/css/uikit-rtl.css +1 -1
- package/dist/css/uikit-rtl.min.css +1 -1
- package/dist/css/uikit.css +1 -1
- package/dist/css/uikit.min.css +1 -1
- package/dist/js/components/countdown.js +88 -133
- package/dist/js/components/countdown.min.js +1 -1
- package/dist/js/components/filter.js +409 -438
- package/dist/js/components/filter.min.js +1 -1
- package/dist/js/components/lightbox-panel.js +1116 -1305
- package/dist/js/components/lightbox-panel.min.js +1 -1
- package/dist/js/components/lightbox.js +1164 -1383
- package/dist/js/components/lightbox.min.js +1 -1
- package/dist/js/components/notification.js +94 -114
- package/dist/js/components/notification.min.js +1 -1
- package/dist/js/components/parallax.js +294 -345
- package/dist/js/components/parallax.min.js +1 -1
- package/dist/js/components/slider-parallax.js +292 -344
- package/dist/js/components/slider-parallax.min.js +1 -1
- package/dist/js/components/slider.js +727 -850
- package/dist/js/components/slider.min.js +1 -1
- package/dist/js/components/slideshow-parallax.js +292 -344
- package/dist/js/components/slideshow-parallax.min.js +1 -1
- package/dist/js/components/slideshow.js +615 -799
- package/dist/js/components/slideshow.min.js +1 -1
- package/dist/js/components/sortable.js +588 -619
- package/dist/js/components/sortable.min.js +1 -1
- package/dist/js/components/tooltip.js +324 -356
- package/dist/js/components/tooltip.min.js +1 -1
- package/dist/js/components/upload.js +155 -167
- package/dist/js/components/upload.min.js +1 -1
- package/dist/js/uikit-core.js +5356 -6705
- package/dist/js/uikit-core.min.js +1 -1
- package/dist/js/uikit-icons.js +7 -9
- package/dist/js/uikit-icons.min.js +1 -1
- package/dist/js/uikit.js +8116 -9909
- package/dist/js/uikit.min.js +1 -1
- package/jsconfig.json +1 -1
- package/package.json +64 -60
- package/src/js/api/boot.js +25 -32
- package/src/js/api/component.js +23 -27
- package/src/js/api/global.js +6 -12
- package/src/js/api/hooks.js +13 -32
- package/src/js/api/instance.js +7 -15
- package/src/js/api/state.js +65 -82
- package/src/js/components/countdown.js +24 -50
- package/src/js/components/filter.js +71 -66
- package/src/js/components/index.js +13 -13
- package/src/js/components/internal/lightbox-animations.js +11 -23
- package/src/js/components/internal/slider-transitioner.js +66 -45
- package/src/js/components/internal/slideshow-animations.js +42 -61
- package/src/js/components/lightbox-panel.js +135 -109
- package/src/js/components/lightbox.js +18 -39
- package/src/js/components/notification.js +49 -43
- package/src/js/components/parallax.js +16 -30
- package/src/js/components/slider-parallax.js +13 -23
- package/src/js/components/slider.js +75 -64
- package/src/js/components/slideshow-parallax.js +1 -1
- package/src/js/components/slideshow.js +8 -13
- package/src/js/components/sortable.js +125 -106
- package/src/js/components/tooltip.js +41 -31
- package/src/js/components/upload.js +52 -63
- package/src/js/core/accordion.js +53 -48
- package/src/js/core/alert.js +10 -17
- package/src/js/core/core.js +74 -53
- package/src/js/core/cover.js +11 -15
- package/src/js/core/drop.js +106 -92
- package/src/js/core/form-custom.js +20 -25
- package/src/js/core/gif.js +3 -7
- package/src/js/core/grid.js +57 -58
- package/src/js/core/height-match.js +16 -29
- package/src/js/core/height-viewport.js +28 -35
- package/src/js/core/icon.js +38 -50
- package/src/js/core/img.js +59 -58
- package/src/js/core/index.js +39 -39
- package/src/js/core/leader.js +9 -18
- package/src/js/core/margin.js +21 -37
- package/src/js/core/modal.js +50 -36
- package/src/js/core/nav.js +2 -4
- package/src/js/core/navbar.js +112 -88
- package/src/js/core/offcanvas.js +49 -53
- package/src/js/core/overflow-auto.js +13 -17
- package/src/js/core/responsive.js +14 -12
- package/src/js/core/scroll.js +10 -20
- package/src/js/core/scrollspy-nav.js +34 -31
- package/src/js/core/scrollspy.js +37 -54
- package/src/js/core/sticky.js +130 -91
- package/src/js/core/svg.js +60 -79
- package/src/js/core/switcher.js +47 -46
- package/src/js/core/tab.js +7 -10
- package/src/js/core/toggle.js +64 -66
- package/src/js/core/video.js +11 -22
- package/src/js/mixin/animate.js +19 -20
- package/src/js/mixin/class.js +2 -4
- package/src/js/mixin/container.js +7 -11
- package/src/js/mixin/internal/animate-fade.js +73 -30
- package/src/js/mixin/internal/animate-slide.js +61 -41
- package/src/js/mixin/internal/slideshow-animations.js +7 -14
- package/src/js/mixin/internal/slideshow-transitioner.js +10 -17
- package/src/js/mixin/media.js +5 -10
- package/src/js/mixin/modal.js +89 -66
- package/src/js/mixin/parallax.js +53 -48
- package/src/js/mixin/position.js +26 -20
- package/src/js/mixin/slider-autoplay.js +12 -21
- package/src/js/mixin/slider-drag.js +64 -65
- package/src/js/mixin/slider-nav.js +26 -35
- package/src/js/mixin/slider-reactive.js +2 -8
- package/src/js/mixin/slider.js +51 -50
- package/src/js/mixin/slideshow.js +13 -19
- package/src/js/mixin/togglable.js +90 -63
- package/src/js/uikit-core.js +2 -4
- package/src/js/uikit.js +2 -4
- package/src/js/util/ajax.js +27 -43
- package/src/js/util/animation.js +82 -75
- package/src/js/util/attr.js +17 -21
- package/src/js/util/class.js +14 -52
- package/src/js/util/dimensions.js +56 -43
- package/src/js/util/dom.js +40 -73
- package/src/js/util/env.js +7 -12
- package/src/js/util/event.js +60 -59
- package/src/js/util/fastdom.js +1 -6
- package/src/js/util/filter.js +17 -34
- package/src/js/util/index.js +0 -1
- package/src/js/util/lang.js +79 -119
- package/src/js/util/mouse.js +19 -17
- package/src/js/util/options.js +44 -49
- package/src/js/util/player.js +40 -36
- package/src/js/util/position.js +54 -46
- package/src/js/util/selector.js +34 -49
- package/src/js/util/style.js +36 -46
- package/src/js/util/viewport.js +75 -64
- package/tests/js/index.js +114 -85
- package/src/js/mixin/flex-bug.js +0 -56
- package/src/js/util/promise.js +0 -191
package/src/js/core/modal.js
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
import Modal from '../mixin/modal';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
$,
|
|
4
|
+
addClass,
|
|
5
|
+
assign,
|
|
6
|
+
css,
|
|
7
|
+
Deferred,
|
|
8
|
+
hasClass,
|
|
9
|
+
height,
|
|
10
|
+
html,
|
|
11
|
+
isString,
|
|
12
|
+
on,
|
|
13
|
+
removeClass,
|
|
14
|
+
} from 'uikit-util';
|
|
3
15
|
|
|
4
16
|
export default {
|
|
5
|
-
|
|
6
17
|
install,
|
|
7
18
|
|
|
8
19
|
mixins: [Modal],
|
|
@@ -10,18 +21,17 @@ export default {
|
|
|
10
21
|
data: {
|
|
11
22
|
clsPage: 'uk-modal-page',
|
|
12
23
|
selPanel: '.uk-modal-dialog',
|
|
13
|
-
selClose:
|
|
24
|
+
selClose:
|
|
25
|
+
'.uk-modal-close, .uk-modal-close-default, .uk-modal-close-outside, .uk-modal-close-full',
|
|
14
26
|
},
|
|
15
27
|
|
|
16
28
|
events: [
|
|
17
|
-
|
|
18
29
|
{
|
|
19
30
|
name: 'show',
|
|
20
31
|
|
|
21
32
|
self: true,
|
|
22
33
|
|
|
23
34
|
handler() {
|
|
24
|
-
|
|
25
35
|
if (hasClass(this.panel, 'uk-margin-auto-vertical')) {
|
|
26
36
|
addClass(this.$el, 'uk-flex');
|
|
27
37
|
} else {
|
|
@@ -29,7 +39,7 @@ export default {
|
|
|
29
39
|
}
|
|
30
40
|
|
|
31
41
|
height(this.$el); // force reflow
|
|
32
|
-
}
|
|
42
|
+
},
|
|
33
43
|
},
|
|
34
44
|
|
|
35
45
|
{
|
|
@@ -38,21 +48,15 @@ export default {
|
|
|
38
48
|
self: true,
|
|
39
49
|
|
|
40
50
|
handler() {
|
|
41
|
-
|
|
42
51
|
css(this.$el, 'display', '');
|
|
43
52
|
removeClass(this.$el, 'uk-flex');
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
]
|
|
49
|
-
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
],
|
|
50
56
|
};
|
|
51
57
|
|
|
52
|
-
function install({modal}) {
|
|
53
|
-
|
|
58
|
+
function install({ modal }) {
|
|
54
59
|
modal.dialog = function (content, options) {
|
|
55
|
-
|
|
56
60
|
const dialog = modal(
|
|
57
61
|
`<div class="uk-modal">
|
|
58
62
|
<div class="uk-modal-dialog">${content}</div>
|
|
@@ -62,10 +66,14 @@ function install({modal}) {
|
|
|
62
66
|
|
|
63
67
|
dialog.show();
|
|
64
68
|
|
|
65
|
-
on(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
)
|
|
69
|
+
on(
|
|
70
|
+
dialog.$el,
|
|
71
|
+
'hidden',
|
|
72
|
+
async () => {
|
|
73
|
+
await Promise.resolve();
|
|
74
|
+
dialog.$destroy(true);
|
|
75
|
+
},
|
|
76
|
+
{ self: true }
|
|
69
77
|
);
|
|
70
78
|
|
|
71
79
|
return dialog;
|
|
@@ -73,64 +81,71 @@ function install({modal}) {
|
|
|
73
81
|
|
|
74
82
|
modal.alert = function (message, options) {
|
|
75
83
|
return openDialog(
|
|
76
|
-
({labels}) => `<div class="uk-modal-body">${
|
|
84
|
+
({ labels }) => `<div class="uk-modal-body">${
|
|
85
|
+
isString(message) ? message : html(message)
|
|
86
|
+
}</div>
|
|
77
87
|
<div class="uk-modal-footer uk-text-right">
|
|
78
|
-
<button class="uk-button uk-button-primary uk-modal-close" autofocus>${
|
|
88
|
+
<button class="uk-button uk-button-primary uk-modal-close" autofocus>${
|
|
89
|
+
labels.ok
|
|
90
|
+
}</button>
|
|
79
91
|
</div>`,
|
|
80
92
|
options,
|
|
81
|
-
deferred => deferred.resolve()
|
|
93
|
+
(deferred) => deferred.resolve()
|
|
82
94
|
);
|
|
83
95
|
};
|
|
84
96
|
|
|
85
97
|
modal.confirm = function (message, options) {
|
|
86
98
|
return openDialog(
|
|
87
|
-
({labels}) => `<form>
|
|
99
|
+
({ labels }) => `<form>
|
|
88
100
|
<div class="uk-modal-body">${isString(message) ? message : html(message)}</div>
|
|
89
101
|
<div class="uk-modal-footer uk-text-right">
|
|
90
|
-
<button class="uk-button uk-button-default uk-modal-close" type="button">${
|
|
102
|
+
<button class="uk-button uk-button-default uk-modal-close" type="button">${
|
|
103
|
+
labels.cancel
|
|
104
|
+
}</button>
|
|
91
105
|
<button class="uk-button uk-button-primary" autofocus>${labels.ok}</button>
|
|
92
106
|
</div>
|
|
93
107
|
</form>`,
|
|
94
108
|
options,
|
|
95
|
-
deferred => deferred.reject()
|
|
109
|
+
(deferred) => deferred.reject()
|
|
96
110
|
);
|
|
97
111
|
};
|
|
98
112
|
|
|
99
113
|
modal.prompt = function (message, value, options) {
|
|
100
114
|
return openDialog(
|
|
101
|
-
({labels}) => `<form class="uk-form-stacked">
|
|
115
|
+
({ labels }) => `<form class="uk-form-stacked">
|
|
102
116
|
<div class="uk-modal-body">
|
|
103
117
|
<label>${isString(message) ? message : html(message)}</label>
|
|
104
118
|
<input class="uk-input" value="${value || ''}" autofocus>
|
|
105
119
|
</div>
|
|
106
120
|
<div class="uk-modal-footer uk-text-right">
|
|
107
|
-
<button class="uk-button uk-button-default uk-modal-close" type="button">${
|
|
121
|
+
<button class="uk-button uk-button-default uk-modal-close" type="button">${
|
|
122
|
+
labels.cancel
|
|
123
|
+
}</button>
|
|
108
124
|
<button class="uk-button uk-button-primary">${labels.ok}</button>
|
|
109
125
|
</div>
|
|
110
126
|
</form>`,
|
|
111
127
|
options,
|
|
112
|
-
deferred => deferred.resolve(null),
|
|
113
|
-
dialog => $('input', dialog.$el).value
|
|
128
|
+
(deferred) => deferred.resolve(null),
|
|
129
|
+
(dialog) => $('input', dialog.$el).value
|
|
114
130
|
);
|
|
115
131
|
};
|
|
116
132
|
|
|
117
133
|
modal.labels = {
|
|
118
134
|
ok: 'Ok',
|
|
119
|
-
cancel: 'Cancel'
|
|
135
|
+
cancel: 'Cancel',
|
|
120
136
|
};
|
|
121
137
|
|
|
122
138
|
function openDialog(tmpl, options, hideFn, submitFn) {
|
|
123
|
-
|
|
124
|
-
options = assign({bgClose: false, escClose: true, labels: modal.labels}, options);
|
|
139
|
+
options = assign({ bgClose: false, escClose: true, labels: modal.labels }, options);
|
|
125
140
|
|
|
126
141
|
const dialog = modal.dialog(tmpl(options), options);
|
|
127
142
|
const deferred = new Deferred();
|
|
128
143
|
|
|
129
144
|
let resolved = false;
|
|
130
145
|
|
|
131
|
-
on(dialog.$el, 'submit', 'form', e => {
|
|
146
|
+
on(dialog.$el, 'submit', 'form', (e) => {
|
|
132
147
|
e.preventDefault();
|
|
133
|
-
deferred.resolve(submitFn
|
|
148
|
+
deferred.resolve(submitFn?.(dialog));
|
|
134
149
|
resolved = true;
|
|
135
150
|
dialog.hide();
|
|
136
151
|
});
|
|
@@ -141,5 +156,4 @@ function install({modal}) {
|
|
|
141
156
|
|
|
142
157
|
return deferred.promise;
|
|
143
158
|
}
|
|
144
|
-
|
|
145
159
|
}
|
package/src/js/core/nav.js
CHANGED
package/src/js/core/navbar.js
CHANGED
|
@@ -1,14 +1,36 @@
|
|
|
1
|
-
import {active} from './drop';
|
|
1
|
+
import { active } from './drop';
|
|
2
2
|
import Class from '../mixin/class';
|
|
3
|
-
import FlexBug from '../mixin/flex-bug';
|
|
4
3
|
import Container from '../mixin/container';
|
|
5
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
$,
|
|
6
|
+
$$,
|
|
7
|
+
addClass,
|
|
8
|
+
after,
|
|
9
|
+
assign,
|
|
10
|
+
css,
|
|
11
|
+
findIndex,
|
|
12
|
+
hasAttr,
|
|
13
|
+
hasClass,
|
|
14
|
+
height,
|
|
15
|
+
includes,
|
|
16
|
+
isRtl,
|
|
17
|
+
isVisible,
|
|
18
|
+
matches,
|
|
19
|
+
noop,
|
|
20
|
+
once,
|
|
21
|
+
parent,
|
|
22
|
+
query,
|
|
23
|
+
remove,
|
|
24
|
+
selFocusable,
|
|
25
|
+
toFloat,
|
|
26
|
+
Transition,
|
|
27
|
+
within,
|
|
28
|
+
} from 'uikit-util';
|
|
6
29
|
|
|
7
30
|
const navItem = '.uk-navbar-nav > li > a, .uk-navbar-item, .uk-navbar-toggle';
|
|
8
31
|
|
|
9
32
|
export default {
|
|
10
|
-
|
|
11
|
-
mixins: [Class, Container, FlexBug],
|
|
33
|
+
mixins: [Class, Container],
|
|
12
34
|
|
|
13
35
|
props: {
|
|
14
36
|
dropdown: String,
|
|
@@ -23,7 +45,7 @@ export default {
|
|
|
23
45
|
dropbar: Boolean,
|
|
24
46
|
dropbarMode: String,
|
|
25
47
|
dropbarAnchor: Boolean,
|
|
26
|
-
duration: Number
|
|
48
|
+
duration: Number,
|
|
27
49
|
},
|
|
28
50
|
|
|
29
51
|
data: {
|
|
@@ -43,43 +65,41 @@ export default {
|
|
|
43
65
|
duration: 200,
|
|
44
66
|
forceHeight: true,
|
|
45
67
|
selMinHeight: navItem,
|
|
46
|
-
container: false
|
|
68
|
+
container: false,
|
|
47
69
|
},
|
|
48
70
|
|
|
49
71
|
computed: {
|
|
50
|
-
|
|
51
|
-
boundary({boundary, boundaryAlign}, $el) {
|
|
72
|
+
boundary({ boundary, boundaryAlign }, $el) {
|
|
52
73
|
return boundary === true || boundaryAlign ? $el : boundary;
|
|
53
74
|
},
|
|
54
75
|
|
|
55
|
-
dropbarAnchor({dropbarAnchor}, $el) {
|
|
76
|
+
dropbarAnchor({ dropbarAnchor }, $el) {
|
|
56
77
|
return query(dropbarAnchor, $el);
|
|
57
78
|
},
|
|
58
79
|
|
|
59
|
-
pos({align}) {
|
|
80
|
+
pos({ align }) {
|
|
60
81
|
return `bottom-${align}`;
|
|
61
82
|
},
|
|
62
83
|
|
|
63
84
|
dropbar: {
|
|
64
|
-
|
|
65
|
-
get({dropbar}) {
|
|
66
|
-
|
|
85
|
+
get({ dropbar }) {
|
|
67
86
|
if (!dropbar) {
|
|
68
87
|
return null;
|
|
69
88
|
}
|
|
70
89
|
|
|
71
|
-
dropbar =
|
|
90
|
+
dropbar =
|
|
91
|
+
this._dropbar ||
|
|
92
|
+
query(dropbar, this.$el) ||
|
|
93
|
+
$('+ .uk-navbar-dropbar', this.$el);
|
|
72
94
|
|
|
73
95
|
return dropbar ? dropbar : (this._dropbar = $('<div></div>'));
|
|
74
|
-
|
|
75
96
|
},
|
|
76
97
|
|
|
77
98
|
watch(dropbar) {
|
|
78
99
|
addClass(dropbar, 'uk-navbar-dropbar');
|
|
79
100
|
},
|
|
80
101
|
|
|
81
|
-
immediate: true
|
|
82
|
-
|
|
102
|
+
immediate: true,
|
|
83
103
|
},
|
|
84
104
|
|
|
85
105
|
dropContainer(_, $el) {
|
|
@@ -87,17 +107,16 @@ export default {
|
|
|
87
107
|
},
|
|
88
108
|
|
|
89
109
|
dropdowns: {
|
|
90
|
-
|
|
91
|
-
get({clsDrop}, $el) {
|
|
110
|
+
get({ clsDrop }, $el) {
|
|
92
111
|
const dropdowns = $$(`.${clsDrop}`, $el);
|
|
93
112
|
|
|
94
113
|
if (this.dropContainer !== $el) {
|
|
95
|
-
$$(`.${clsDrop}`, this.dropContainer)
|
|
96
|
-
const
|
|
97
|
-
if (!includes(dropdowns, el) &&
|
|
114
|
+
for (const el of $$(`.${clsDrop}`, this.dropContainer)) {
|
|
115
|
+
const target = this.getDropdown(el)?.target;
|
|
116
|
+
if (!includes(dropdowns, el) && target && within(target, this.$el)) {
|
|
98
117
|
dropdowns.push(el);
|
|
99
118
|
}
|
|
100
|
-
}
|
|
119
|
+
}
|
|
101
120
|
}
|
|
102
121
|
|
|
103
122
|
return dropdowns;
|
|
@@ -106,19 +125,21 @@ export default {
|
|
|
106
125
|
watch(dropdowns) {
|
|
107
126
|
this.$create(
|
|
108
127
|
'drop',
|
|
109
|
-
dropdowns.filter(el => !this.getDropdown(el)),
|
|
110
|
-
assign({}, this.$props, {
|
|
128
|
+
dropdowns.filter((el) => !this.getDropdown(el)),
|
|
129
|
+
assign({}, this.$props, {
|
|
130
|
+
boundary: this.boundary,
|
|
131
|
+
pos: this.pos,
|
|
132
|
+
offset: this.dropbar || this.offset,
|
|
133
|
+
})
|
|
111
134
|
);
|
|
112
135
|
},
|
|
113
136
|
|
|
114
|
-
immediate: true
|
|
115
|
-
|
|
137
|
+
immediate: true,
|
|
116
138
|
},
|
|
117
139
|
|
|
118
|
-
toggles({dropdown}, $el) {
|
|
140
|
+
toggles({ dropdown }, $el) {
|
|
119
141
|
return $$(dropdown, $el);
|
|
120
|
-
}
|
|
121
|
-
|
|
142
|
+
},
|
|
122
143
|
},
|
|
123
144
|
|
|
124
145
|
disconnected() {
|
|
@@ -127,7 +148,6 @@ export default {
|
|
|
127
148
|
},
|
|
128
149
|
|
|
129
150
|
events: [
|
|
130
|
-
|
|
131
151
|
{
|
|
132
152
|
name: 'mouseover focusin',
|
|
133
153
|
|
|
@@ -135,13 +155,18 @@ export default {
|
|
|
135
155
|
return this.dropdown;
|
|
136
156
|
},
|
|
137
157
|
|
|
138
|
-
handler({current}) {
|
|
158
|
+
handler({ current }) {
|
|
139
159
|
const active = this.getActive();
|
|
140
|
-
if (
|
|
160
|
+
if (
|
|
161
|
+
active &&
|
|
162
|
+
includes(active.mode, 'hover') &&
|
|
163
|
+
active.target &&
|
|
164
|
+
!within(active.target, current) &&
|
|
165
|
+
!active.isDelaying
|
|
166
|
+
) {
|
|
141
167
|
active.hide(false);
|
|
142
168
|
}
|
|
143
|
-
}
|
|
144
|
-
|
|
169
|
+
},
|
|
145
170
|
},
|
|
146
171
|
|
|
147
172
|
{
|
|
@@ -152,25 +177,24 @@ export default {
|
|
|
152
177
|
},
|
|
153
178
|
|
|
154
179
|
handler(e) {
|
|
155
|
-
|
|
156
|
-
const {current, keyCode} = e;
|
|
180
|
+
const { current, keyCode } = e;
|
|
157
181
|
const active = this.getActive();
|
|
158
182
|
|
|
159
183
|
if (keyCode === keyMap.DOWN && hasAttr(current, 'aria-expanded')) {
|
|
160
|
-
|
|
161
184
|
e.preventDefault();
|
|
162
185
|
|
|
163
186
|
if (!active || active.target !== current) {
|
|
164
187
|
current.click();
|
|
165
|
-
once(this.dropContainer, 'show', ({target}) =>
|
|
188
|
+
once(this.dropContainer, 'show', ({ target }) =>
|
|
189
|
+
focusFirstFocusableElement(target)
|
|
190
|
+
);
|
|
166
191
|
} else {
|
|
167
192
|
focusFirstFocusableElement(active.$el);
|
|
168
193
|
}
|
|
169
|
-
|
|
170
194
|
}
|
|
171
195
|
|
|
172
196
|
handleNavItemNavigation(e, this.toggles, active);
|
|
173
|
-
}
|
|
197
|
+
},
|
|
174
198
|
},
|
|
175
199
|
|
|
176
200
|
{
|
|
@@ -185,8 +209,7 @@ export default {
|
|
|
185
209
|
},
|
|
186
210
|
|
|
187
211
|
handler(e) {
|
|
188
|
-
|
|
189
|
-
const {current, keyCode} = e;
|
|
212
|
+
const { current, keyCode } = e;
|
|
190
213
|
|
|
191
214
|
if (!includes(this.dropdowns, current)) {
|
|
192
215
|
return;
|
|
@@ -194,7 +217,7 @@ export default {
|
|
|
194
217
|
|
|
195
218
|
const active = this.getActive();
|
|
196
219
|
const elements = $$(selFocusable, current);
|
|
197
|
-
const i = findIndex(elements, el => matches(el, ':focus'));
|
|
220
|
+
const i = findIndex(elements, (el) => matches(el, ':focus'));
|
|
198
221
|
|
|
199
222
|
if (keyCode === keyMap.UP) {
|
|
200
223
|
e.preventDefault();
|
|
@@ -211,11 +234,11 @@ export default {
|
|
|
211
234
|
}
|
|
212
235
|
|
|
213
236
|
if (keyCode === keyMap.ESC) {
|
|
214
|
-
active
|
|
237
|
+
active?.target?.focus();
|
|
215
238
|
}
|
|
216
239
|
|
|
217
240
|
handleNavItemNavigation(e, this.toggles, active);
|
|
218
|
-
}
|
|
241
|
+
},
|
|
219
242
|
},
|
|
220
243
|
|
|
221
244
|
{
|
|
@@ -232,10 +255,14 @@ export default {
|
|
|
232
255
|
handler() {
|
|
233
256
|
const active = this.getActive();
|
|
234
257
|
|
|
235
|
-
if (
|
|
258
|
+
if (
|
|
259
|
+
active &&
|
|
260
|
+
includes(active.mode, 'hover') &&
|
|
261
|
+
!this.dropdowns.some((el) => matches(el, ':hover'))
|
|
262
|
+
) {
|
|
236
263
|
active.hide();
|
|
237
264
|
}
|
|
238
|
-
}
|
|
265
|
+
},
|
|
239
266
|
},
|
|
240
267
|
|
|
241
268
|
{
|
|
@@ -250,12 +277,10 @@ export default {
|
|
|
250
277
|
},
|
|
251
278
|
|
|
252
279
|
handler() {
|
|
253
|
-
|
|
254
280
|
if (!parent(this.dropbar)) {
|
|
255
281
|
after(this.dropbarAnchor || this.$el, this.dropbar);
|
|
256
282
|
}
|
|
257
|
-
|
|
258
|
-
}
|
|
283
|
+
},
|
|
259
284
|
},
|
|
260
285
|
|
|
261
286
|
{
|
|
@@ -269,7 +294,7 @@ export default {
|
|
|
269
294
|
return this.dropbar;
|
|
270
295
|
},
|
|
271
296
|
|
|
272
|
-
handler(_, {$el, dir}) {
|
|
297
|
+
handler(_, { $el, dir }) {
|
|
273
298
|
if (!hasClass($el, this.clsDrop)) {
|
|
274
299
|
return;
|
|
275
300
|
}
|
|
@@ -281,9 +306,14 @@ export default {
|
|
|
281
306
|
this.clsDrop && addClass($el, `${this.clsDrop}-dropbar`);
|
|
282
307
|
|
|
283
308
|
if (dir === 'bottom') {
|
|
284
|
-
this.transitionTo(
|
|
309
|
+
this.transitionTo(
|
|
310
|
+
$el.offsetHeight +
|
|
311
|
+
toFloat(css($el, 'marginTop')) +
|
|
312
|
+
toFloat(css($el, 'marginBottom')),
|
|
313
|
+
$el
|
|
314
|
+
);
|
|
285
315
|
}
|
|
286
|
-
}
|
|
316
|
+
},
|
|
287
317
|
},
|
|
288
318
|
|
|
289
319
|
{
|
|
@@ -297,18 +327,17 @@ export default {
|
|
|
297
327
|
return this.dropbar;
|
|
298
328
|
},
|
|
299
329
|
|
|
300
|
-
handler(e, {$el}) {
|
|
301
|
-
|
|
330
|
+
handler(e, { $el }) {
|
|
302
331
|
const active = this.getActive();
|
|
303
332
|
|
|
304
|
-
if (
|
|
305
|
-
&&
|
|
306
|
-
|
|
307
|
-
|
|
333
|
+
if (
|
|
334
|
+
matches(this.dropbar, ':hover') &&
|
|
335
|
+
active?.$el === $el &&
|
|
336
|
+
!this.toggles.some((el) => active.target !== el && matches(el, ':focus'))
|
|
308
337
|
) {
|
|
309
338
|
e.preventDefault();
|
|
310
339
|
}
|
|
311
|
-
}
|
|
340
|
+
},
|
|
312
341
|
},
|
|
313
342
|
|
|
314
343
|
{
|
|
@@ -322,30 +351,27 @@ export default {
|
|
|
322
351
|
return this.dropbar;
|
|
323
352
|
},
|
|
324
353
|
|
|
325
|
-
handler(_, {$el}) {
|
|
354
|
+
handler(_, { $el }) {
|
|
326
355
|
if (!hasClass($el, this.clsDrop)) {
|
|
327
356
|
return;
|
|
328
357
|
}
|
|
329
358
|
|
|
330
359
|
const active = this.getActive();
|
|
331
360
|
|
|
332
|
-
if (!active || active
|
|
361
|
+
if (!active || active?.$el === $el) {
|
|
333
362
|
this.transitionTo(0);
|
|
334
363
|
}
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
|
|
364
|
+
},
|
|
365
|
+
},
|
|
338
366
|
],
|
|
339
367
|
|
|
340
368
|
methods: {
|
|
341
|
-
|
|
342
369
|
getActive() {
|
|
343
370
|
return active && within(active.target, this.$el) && active;
|
|
344
371
|
},
|
|
345
372
|
|
|
346
373
|
transitionTo(newHeight, el) {
|
|
347
|
-
|
|
348
|
-
const {dropbar} = this;
|
|
374
|
+
const { dropbar } = this;
|
|
349
375
|
const oldHeight = isVisible(dropbar) ? height(dropbar) : 0;
|
|
350
376
|
|
|
351
377
|
el = oldHeight < newHeight && el;
|
|
@@ -356,54 +382,52 @@ export default {
|
|
|
356
382
|
|
|
357
383
|
Transition.cancel([el, dropbar]);
|
|
358
384
|
return Promise.all([
|
|
359
|
-
Transition.start(dropbar, {height: newHeight}, this.duration),
|
|
360
|
-
Transition.start(
|
|
385
|
+
Transition.start(dropbar, { height: newHeight }, this.duration),
|
|
386
|
+
Transition.start(
|
|
387
|
+
el,
|
|
388
|
+
{ clip: `rect(0,${el.offsetWidth}px,${newHeight}px,0)` },
|
|
389
|
+
this.duration
|
|
390
|
+
),
|
|
361
391
|
])
|
|
362
392
|
.catch(noop)
|
|
363
393
|
.then(() => {
|
|
364
|
-
css(el, {clip: ''});
|
|
394
|
+
css(el, { clip: '' });
|
|
365
395
|
this.$update(dropbar);
|
|
366
396
|
});
|
|
367
397
|
},
|
|
368
398
|
|
|
369
399
|
getDropdown(el) {
|
|
370
400
|
return this.$getComponent(el, 'drop') || this.$getComponent(el, 'dropdown');
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
}
|
|
374
|
-
|
|
401
|
+
},
|
|
402
|
+
},
|
|
375
403
|
};
|
|
376
404
|
|
|
377
405
|
function handleNavItemNavigation(e, toggles, active) {
|
|
378
|
-
|
|
379
|
-
const
|
|
380
|
-
const target = active && active.target || current;
|
|
406
|
+
const { current, keyCode } = e;
|
|
407
|
+
const target = active?.target || current;
|
|
381
408
|
const i = toggles.indexOf(target);
|
|
382
409
|
|
|
383
410
|
// Left
|
|
384
411
|
if (keyCode === keyMap.LEFT && i > 0) {
|
|
385
|
-
active
|
|
412
|
+
active?.hide(false);
|
|
386
413
|
toggles[i - 1].focus();
|
|
387
414
|
}
|
|
388
415
|
|
|
389
416
|
// Right
|
|
390
417
|
if (keyCode === keyMap.RIGHT && i < toggles.length - 1) {
|
|
391
|
-
active
|
|
418
|
+
active?.hide(false);
|
|
392
419
|
toggles[i + 1].focus();
|
|
393
420
|
}
|
|
394
421
|
|
|
395
422
|
if (keyCode === keyMap.TAB) {
|
|
396
423
|
target.focus();
|
|
397
|
-
active
|
|
424
|
+
active?.hide(false);
|
|
398
425
|
}
|
|
399
426
|
}
|
|
400
427
|
|
|
401
428
|
function focusFirstFocusableElement(el) {
|
|
402
429
|
if (!$(':focus', el)) {
|
|
403
|
-
|
|
404
|
-
if (focusEl) {
|
|
405
|
-
focusEl.focus();
|
|
406
|
-
}
|
|
430
|
+
$(selFocusable, el)?.focus();
|
|
407
431
|
}
|
|
408
432
|
}
|
|
409
433
|
|
|
@@ -413,5 +437,5 @@ const keyMap = {
|
|
|
413
437
|
LEFT: 37,
|
|
414
438
|
UP: 38,
|
|
415
439
|
RIGHT: 39,
|
|
416
|
-
DOWN: 40
|
|
440
|
+
DOWN: 40,
|
|
417
441
|
};
|