uikit 3.11.2-dev.9433cd5fd → 3.11.2-dev.a87448e52
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 +37 -28
- 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 +118 -201
- package/dist/css/uikit-core-rtl.min.css +1 -1
- package/dist/css/uikit-core.css +118 -201
- package/dist/css/uikit-core.min.css +1 -1
- package/dist/css/uikit-rtl.css +120 -207
- package/dist/css/uikit-rtl.min.css +1 -1
- package/dist/css/uikit.css +120 -207
- 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 +408 -439
- package/dist/js/components/filter.min.js +1 -1
- package/dist/js/components/lightbox-panel.js +1098 -1316
- package/dist/js/components/lightbox-panel.min.js +1 -1
- package/dist/js/components/lightbox.js +1144 -1393
- 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 +345 -358
- package/dist/js/components/parallax.min.js +1 -1
- package/dist/js/components/slider-parallax.js +343 -357
- package/dist/js/components/slider-parallax.min.js +1 -1
- package/dist/js/components/slider.js +768 -843
- package/dist/js/components/slider.min.js +1 -1
- package/dist/js/components/slideshow-parallax.js +343 -357
- package/dist/js/components/slideshow-parallax.min.js +1 -1
- package/dist/js/components/slideshow.js +645 -793
- package/dist/js/components/slideshow.min.js +1 -1
- package/dist/js/components/sortable.js +587 -620
- 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 +5412 -6733
- 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 +8008 -9705
- 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 +15 -28
- package/src/js/api/global.js +6 -12
- package/src/js/api/hooks.js +14 -33
- package/src/js/api/instance.js +7 -15
- package/src/js/api/state.js +79 -100
- package/src/js/components/countdown.js +24 -50
- package/src/js/components/filter.js +70 -66
- package/src/js/components/index.js +13 -13
- package/src/js/components/internal/lightbox-animations.js +14 -25
- package/src/js/components/internal/slider-preload.js +37 -0
- package/src/js/components/internal/slider-transitioner.js +66 -45
- package/src/js/components/internal/slideshow-animations.js +46 -64
- package/src/js/components/lightbox-panel.js +107 -105
- package/src/js/components/lightbox.js +17 -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 +95 -64
- package/src/js/components/slideshow-parallax.js +1 -1
- package/src/js/components/slideshow.js +15 -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 +9 -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 +47 -52
- package/src/js/core/img.js +96 -77
- 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 +49 -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 +68 -83
- package/src/js/core/switcher.js +47 -46
- package/src/js/core/tab.js +7 -10
- package/src/js/core/toggle.js +66 -67
- 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 +58 -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 +149 -106
- 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 +48 -55
- package/src/js/mixin/slideshow.js +13 -19
- package/src/js/mixin/togglable.js +89 -63
- package/src/js/uikit-core.js +2 -4
- package/src/js/uikit.js +2 -4
- package/src/js/util/ajax.js +20 -39
- package/src/js/util/animation.js +77 -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 +44 -80
- 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 +82 -121
- package/src/js/util/mouse.js +19 -17
- package/src/js/util/options.js +32 -46
- package/src/js/util/player.js +41 -36
- package/src/js/util/position.js +54 -46
- package/src/js/util/selector.js +43 -58
- package/src/js/util/style.js +39 -49
- package/src/js/util/viewport.js +75 -64
- package/src/less/components/base.less +10 -33
- package/src/less/components/flex.less +0 -9
- package/src/less/components/form-range.less +48 -95
- package/src/less/components/form.less +0 -1
- package/src/less/components/leader.less +0 -1
- package/src/less/components/lightbox.less +0 -1
- package/src/less/components/modal.less +3 -7
- package/src/less/components/navbar.less +0 -7
- package/src/less/components/progress.less +14 -36
- package/src/less/components/slider.less +0 -3
- package/src/less/components/slideshow.less +0 -3
- package/src/less/components/text.less +16 -32
- package/src/less/components/utility.less +22 -0
- package/src/scss/components/base.scss +10 -33
- package/src/scss/components/flex.scss +0 -9
- package/src/scss/components/form-range.scss +48 -95
- package/src/scss/components/form.scss +3 -4
- package/src/scss/components/icon.scss +2 -2
- package/src/scss/components/leader.scss +0 -1
- package/src/scss/components/lightbox.scss +0 -1
- package/src/scss/components/modal.scss +3 -7
- package/src/scss/components/navbar.scss +0 -7
- package/src/scss/components/progress.scss +14 -36
- package/src/scss/components/search.scss +1 -1
- package/src/scss/components/slider.scss +0 -3
- package/src/scss/components/slideshow.scss +0 -3
- package/src/scss/components/text.scss +16 -32
- package/src/scss/components/utility.scss +22 -0
- package/src/scss/mixins-theme.scss +1 -1
- package/src/scss/mixins.scss +1 -1
- package/src/scss/variables-theme.scss +9 -9
- package/src/scss/variables.scss +9 -9
- package/tests/align.html +10 -10
- package/tests/animation.html +2 -2
- package/tests/article.html +2 -2
- package/tests/base.html +3 -3
- package/tests/card.html +10 -10
- package/tests/column.html +3 -3
- package/tests/comment.html +9 -9
- package/tests/dotnav.html +3 -3
- package/tests/image.html +296 -48
- package/tests/images/image-type.avif +0 -0
- package/tests/images/image-type.jpeg +0 -0
- package/tests/images/image-type.webp +0 -0
- package/tests/index.html +8 -8
- package/tests/js/index.js +114 -85
- package/tests/lightbox.html +10 -10
- package/tests/marker.html +2 -2
- package/tests/modal.html +8 -9
- package/tests/navbar.html +2 -2
- package/tests/overlay.html +7 -7
- package/tests/parallax.html +14 -5
- package/tests/position.html +12 -12
- package/tests/slidenav.html +12 -12
- package/tests/slider.html +20 -20
- package/tests/sortable.html +1 -1
- package/tests/sticky-parallax.html +47 -62
- package/tests/svg.html +6 -6
- package/tests/table.html +11 -11
- package/tests/thumbnav.html +12 -12
- package/tests/transition.html +30 -30
- package/tests/utility.html +33 -33
- package/tests/video.html +1 -1
- package/tests/width.html +1 -1
- package/src/js/mixin/flex-bug.js +0 -56
- package/src/js/util/promise.js +0 -191
- package/tests/images/animated.gif +0 -0
- package/tests/images/test.avif +0 -0
- package/tests/images/test.webp +0 -0
|
@@ -1,14 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
children,
|
|
3
|
+
css,
|
|
4
|
+
fastdom,
|
|
5
|
+
includes,
|
|
6
|
+
index,
|
|
7
|
+
isVisible,
|
|
8
|
+
noop,
|
|
9
|
+
offset,
|
|
10
|
+
parent,
|
|
11
|
+
position,
|
|
12
|
+
Transition,
|
|
13
|
+
} from 'uikit-util';
|
|
2
14
|
|
|
3
15
|
export default function (action, target, duration) {
|
|
4
|
-
|
|
5
|
-
return new Promise(resolve =>
|
|
16
|
+
return new Promise((resolve) =>
|
|
6
17
|
requestAnimationFrame(() => {
|
|
7
|
-
|
|
8
18
|
let nodes = children(target);
|
|
9
19
|
|
|
10
20
|
// Get current state
|
|
11
|
-
const currentProps = nodes.map(el => getProps(el, true));
|
|
21
|
+
const currentProps = nodes.map((el) => getProps(el, true));
|
|
12
22
|
const targetProps = css(target, ['height', 'padding']);
|
|
13
23
|
|
|
14
24
|
// Cancel previous animations
|
|
@@ -20,11 +30,10 @@ export default function (action, target, duration) {
|
|
|
20
30
|
action();
|
|
21
31
|
|
|
22
32
|
// Find new nodes
|
|
23
|
-
nodes = nodes.concat(children(target).filter(el => !includes(nodes, el)));
|
|
33
|
+
nodes = nodes.concat(children(target).filter((el) => !includes(nodes, el)));
|
|
24
34
|
|
|
25
35
|
// Wait for update to propagate
|
|
26
36
|
Promise.resolve().then(() => {
|
|
27
|
-
|
|
28
37
|
// Force update
|
|
29
38
|
fastdom.flush();
|
|
30
39
|
|
|
@@ -34,53 +43,61 @@ export default function (action, target, duration) {
|
|
|
34
43
|
|
|
35
44
|
// Reset to previous state
|
|
36
45
|
nodes.forEach((el, i) => propsFrom[i] && css(el, propsFrom[i]));
|
|
37
|
-
css(target,
|
|
46
|
+
css(target, { display: 'block', ...targetProps });
|
|
38
47
|
|
|
39
48
|
// Start transitions on next frame
|
|
40
49
|
requestAnimationFrame(() => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
50
|
+
const transitions = nodes
|
|
51
|
+
.map(
|
|
52
|
+
(el, i) =>
|
|
53
|
+
parent(el) === target &&
|
|
54
|
+
Transition.start(el, propsTo[i], duration, 'ease')
|
|
55
|
+
)
|
|
56
|
+
.concat(Transition.start(target, targetPropsTo, duration, 'ease'));
|
|
57
|
+
|
|
58
|
+
Promise.all(transitions)
|
|
59
|
+
.then(() => {
|
|
60
|
+
nodes.forEach(
|
|
61
|
+
(el, i) =>
|
|
62
|
+
parent(el) === target &&
|
|
63
|
+
css(el, 'display', propsTo[i].opacity === 0 ? 'none' : '')
|
|
64
|
+
);
|
|
65
|
+
reset(target);
|
|
66
|
+
}, noop)
|
|
67
|
+
.then(resolve);
|
|
51
68
|
});
|
|
52
69
|
});
|
|
53
|
-
})
|
|
70
|
+
})
|
|
71
|
+
);
|
|
54
72
|
}
|
|
55
73
|
|
|
56
74
|
function getProps(el, opacity) {
|
|
57
|
-
|
|
58
75
|
const zIndex = css(el, 'zIndex');
|
|
59
76
|
|
|
60
77
|
return isVisible(el)
|
|
61
|
-
?
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
78
|
+
? {
|
|
79
|
+
display: '',
|
|
80
|
+
opacity: opacity ? css(el, 'opacity') : '0',
|
|
81
|
+
pointerEvents: 'none',
|
|
82
|
+
position: 'absolute',
|
|
83
|
+
zIndex: zIndex === 'auto' ? index(el) : zIndex,
|
|
84
|
+
...getPositionWithMargin(el),
|
|
85
|
+
}
|
|
68
86
|
: false;
|
|
69
87
|
}
|
|
70
88
|
|
|
71
89
|
function getTransitionProps(target, nodes, currentProps) {
|
|
72
|
-
|
|
73
90
|
const propsTo = nodes.map((el, i) =>
|
|
74
91
|
parent(el) && i in currentProps
|
|
75
92
|
? currentProps[i]
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
: false
|
|
93
|
+
? isVisible(el)
|
|
94
|
+
? getPositionWithMargin(el)
|
|
95
|
+
: { opacity: 0 }
|
|
96
|
+
: { opacity: isVisible(el) ? 1 : 0 }
|
|
97
|
+
: false
|
|
98
|
+
);
|
|
81
99
|
|
|
82
100
|
const propsFrom = propsTo.map((props, i) => {
|
|
83
|
-
|
|
84
101
|
const from = parent(nodes[i]) === target && (currentProps[i] || getProps(nodes[i]));
|
|
85
102
|
|
|
86
103
|
if (!from) {
|
|
@@ -90,7 +107,7 @@ function getTransitionProps(target, nodes, currentProps) {
|
|
|
90
107
|
if (!props) {
|
|
91
108
|
delete from.opacity;
|
|
92
109
|
} else if (!('opacity' in props)) {
|
|
93
|
-
const {opacity} = from;
|
|
110
|
+
const { opacity } = from;
|
|
94
111
|
|
|
95
112
|
if (opacity % 1) {
|
|
96
113
|
props.opacity = 1;
|
|
@@ -117,15 +134,15 @@ function reset(el) {
|
|
|
117
134
|
marginLeft: '',
|
|
118
135
|
transform: '',
|
|
119
136
|
width: '',
|
|
120
|
-
zIndex: ''
|
|
137
|
+
zIndex: '',
|
|
121
138
|
});
|
|
122
|
-
css(el, {height: '', display: '', padding: ''});
|
|
139
|
+
css(el, { height: '', display: '', padding: '' });
|
|
123
140
|
}
|
|
124
141
|
|
|
125
142
|
function getPositionWithMargin(el) {
|
|
126
|
-
const {height, width} = offset(el);
|
|
127
|
-
const {top, left} = position(el);
|
|
128
|
-
const {marginLeft, marginTop} = css(el, ['marginTop', 'marginLeft']);
|
|
143
|
+
const { height, width } = offset(el);
|
|
144
|
+
const { top, left } = position(el);
|
|
145
|
+
const { marginLeft, marginTop } = css(el, ['marginTop', 'marginLeft']);
|
|
129
146
|
|
|
130
|
-
return {top, left, height, width, marginLeft, marginTop, transform: ''};
|
|
147
|
+
return { top, left, height, width, marginLeft, marginTop, transform: '' };
|
|
131
148
|
}
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
import {css
|
|
1
|
+
import { css } from 'uikit-util';
|
|
2
2
|
|
|
3
3
|
export default {
|
|
4
|
-
|
|
5
4
|
slide: {
|
|
6
|
-
|
|
7
5
|
show(dir) {
|
|
8
|
-
return [
|
|
9
|
-
{transform: translate(dir * -100)},
|
|
10
|
-
{transform: translate()}
|
|
11
|
-
];
|
|
6
|
+
return [{ transform: translate(dir * -100) }, { transform: translate() }];
|
|
12
7
|
},
|
|
13
8
|
|
|
14
9
|
percent(current) {
|
|
@@ -17,13 +12,11 @@ export default {
|
|
|
17
12
|
|
|
18
13
|
translate(percent, dir) {
|
|
19
14
|
return [
|
|
20
|
-
{transform: translate(dir * -100 * percent)},
|
|
21
|
-
{transform: translate(dir * 100 * (1 - percent))}
|
|
15
|
+
{ transform: translate(dir * -100 * percent) },
|
|
16
|
+
{ transform: translate(dir * 100 * (1 - percent)) },
|
|
22
17
|
];
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
18
|
+
},
|
|
19
|
+
},
|
|
27
20
|
};
|
|
28
21
|
|
|
29
22
|
export function translated(el) {
|
|
@@ -32,7 +25,7 @@ export function translated(el) {
|
|
|
32
25
|
|
|
33
26
|
export function translate(value = 0, unit = '%') {
|
|
34
27
|
value += value ? unit : '';
|
|
35
|
-
return
|
|
28
|
+
return `translate3d(${value}, 0, 0)`;
|
|
36
29
|
}
|
|
37
30
|
|
|
38
31
|
export function scale3d(value) {
|
|
@@ -1,28 +1,25 @@
|
|
|
1
|
-
import {clamp, createEvent, css, Deferred, noop,
|
|
1
|
+
import { clamp, createEvent, css, Deferred, noop, Transition, trigger } from 'uikit-util';
|
|
2
2
|
|
|
3
|
-
export default function Transitioner(prev, next, dir, {animation, easing}) {
|
|
4
|
-
|
|
5
|
-
const {percent, translate, show = noop} = animation;
|
|
3
|
+
export default function Transitioner(prev, next, dir, { animation, easing }) {
|
|
4
|
+
const { percent, translate, show = noop } = animation;
|
|
6
5
|
const props = show(dir);
|
|
7
6
|
const deferred = new Deferred();
|
|
8
7
|
|
|
9
8
|
return {
|
|
10
|
-
|
|
11
9
|
dir,
|
|
12
10
|
|
|
13
11
|
show(duration, percent = 0, linear) {
|
|
14
|
-
|
|
15
12
|
const timing = linear ? 'linear' : easing;
|
|
16
13
|
duration -= Math.round(duration * clamp(percent, -1, 1));
|
|
17
14
|
|
|
18
15
|
this.translate(percent);
|
|
19
16
|
|
|
20
|
-
triggerUpdate(next, 'itemin', {percent, duration, timing, dir});
|
|
21
|
-
triggerUpdate(prev, 'itemout', {percent: 1 - percent, duration, timing, dir});
|
|
17
|
+
triggerUpdate(next, 'itemin', { percent, duration, timing, dir });
|
|
18
|
+
triggerUpdate(prev, 'itemout', { percent: 1 - percent, duration, timing, dir });
|
|
22
19
|
|
|
23
20
|
Promise.all([
|
|
24
21
|
Transition.start(next, props[1], duration, timing),
|
|
25
|
-
Transition.start(prev, props[0], duration, timing)
|
|
22
|
+
Transition.start(prev, props[0], duration, timing),
|
|
26
23
|
]).then(() => {
|
|
27
24
|
this.reset();
|
|
28
25
|
deferred.resolve();
|
|
@@ -47,15 +44,13 @@ export default function Transitioner(prev, next, dir, {animation, easing}) {
|
|
|
47
44
|
},
|
|
48
45
|
|
|
49
46
|
translate(percent) {
|
|
50
|
-
|
|
51
47
|
this.reset();
|
|
52
48
|
|
|
53
49
|
const props = translate(percent, dir);
|
|
54
50
|
css(next, props[1]);
|
|
55
51
|
css(prev, props[0]);
|
|
56
|
-
triggerUpdate(next, 'itemtranslatein', {percent, dir});
|
|
57
|
-
triggerUpdate(prev, 'itemtranslateout', {percent: 1 - percent, dir});
|
|
58
|
-
|
|
52
|
+
triggerUpdate(next, 'itemtranslatein', { percent, dir });
|
|
53
|
+
triggerUpdate(prev, 'itemtranslateout', { percent: 1 - percent, dir });
|
|
59
54
|
},
|
|
60
55
|
|
|
61
56
|
percent() {
|
|
@@ -63,11 +58,9 @@ export default function Transitioner(prev, next, dir, {animation, easing}) {
|
|
|
63
58
|
},
|
|
64
59
|
|
|
65
60
|
getDistance() {
|
|
66
|
-
return prev
|
|
67
|
-
}
|
|
68
|
-
|
|
61
|
+
return prev?.offsetWidth;
|
|
62
|
+
},
|
|
69
63
|
};
|
|
70
|
-
|
|
71
64
|
}
|
|
72
65
|
|
|
73
66
|
function triggerUpdate(el, type, data) {
|
package/src/js/mixin/media.js
CHANGED
|
@@ -1,28 +1,23 @@
|
|
|
1
|
-
import {getCssVar, isString, toFloat} from 'uikit-util';
|
|
1
|
+
import { getCssVar, isString, toFloat } from 'uikit-util';
|
|
2
2
|
|
|
3
3
|
export default {
|
|
4
|
-
|
|
5
4
|
props: {
|
|
6
|
-
media: Boolean
|
|
5
|
+
media: Boolean,
|
|
7
6
|
},
|
|
8
7
|
|
|
9
8
|
data: {
|
|
10
|
-
media: false
|
|
9
|
+
media: false,
|
|
11
10
|
},
|
|
12
11
|
|
|
13
12
|
computed: {
|
|
14
|
-
|
|
15
13
|
matchMedia() {
|
|
16
14
|
const media = toMedia(this.media);
|
|
17
15
|
return !media || window.matchMedia(media).matches;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
16
|
+
},
|
|
17
|
+
},
|
|
22
18
|
};
|
|
23
19
|
|
|
24
20
|
function toMedia(value) {
|
|
25
|
-
|
|
26
21
|
if (isString(value)) {
|
|
27
22
|
if (value[0] === '@') {
|
|
28
23
|
const name = `breakpoint-${value.substr(1)}`;
|
package/src/js/mixin/modal.js
CHANGED
|
@@ -1,4 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
$,
|
|
3
|
+
addClass,
|
|
4
|
+
append,
|
|
5
|
+
attr,
|
|
6
|
+
css,
|
|
7
|
+
includes,
|
|
8
|
+
isFocusable,
|
|
9
|
+
last,
|
|
10
|
+
on,
|
|
11
|
+
once,
|
|
12
|
+
parent,
|
|
13
|
+
pointerCancel,
|
|
14
|
+
pointerDown,
|
|
15
|
+
pointerUp,
|
|
16
|
+
removeClass,
|
|
17
|
+
toFloat,
|
|
18
|
+
toMs,
|
|
19
|
+
width,
|
|
20
|
+
within,
|
|
21
|
+
} from 'uikit-util';
|
|
2
22
|
import Class from './class';
|
|
3
23
|
import Container from './container';
|
|
4
24
|
import Togglable from './togglable';
|
|
@@ -6,7 +26,6 @@ import Togglable from './togglable';
|
|
|
6
26
|
const active = [];
|
|
7
27
|
|
|
8
28
|
export default {
|
|
9
|
-
|
|
10
29
|
mixins: [Class, Container, Togglable],
|
|
11
30
|
|
|
12
31
|
props: {
|
|
@@ -14,7 +33,7 @@ export default {
|
|
|
14
33
|
selClose: String,
|
|
15
34
|
escClose: Boolean,
|
|
16
35
|
bgClose: Boolean,
|
|
17
|
-
stack: Boolean
|
|
36
|
+
stack: Boolean,
|
|
18
37
|
},
|
|
19
38
|
|
|
20
39
|
data: {
|
|
@@ -22,12 +41,11 @@ export default {
|
|
|
22
41
|
escClose: true,
|
|
23
42
|
bgClose: true,
|
|
24
43
|
overlay: true,
|
|
25
|
-
stack: false
|
|
44
|
+
stack: false,
|
|
26
45
|
},
|
|
27
46
|
|
|
28
47
|
computed: {
|
|
29
|
-
|
|
30
|
-
panel({selPanel}, $el) {
|
|
48
|
+
panel({ selPanel }, $el) {
|
|
31
49
|
return $(selPanel, $el);
|
|
32
50
|
},
|
|
33
51
|
|
|
@@ -35,10 +53,9 @@ export default {
|
|
|
35
53
|
return this.panel;
|
|
36
54
|
},
|
|
37
55
|
|
|
38
|
-
bgClose({bgClose}) {
|
|
56
|
+
bgClose({ bgClose }) {
|
|
39
57
|
return bgClose && this.panel;
|
|
40
|
-
}
|
|
41
|
-
|
|
58
|
+
},
|
|
42
59
|
},
|
|
43
60
|
|
|
44
61
|
beforeDisconnect() {
|
|
@@ -48,9 +65,7 @@ export default {
|
|
|
48
65
|
},
|
|
49
66
|
|
|
50
67
|
events: [
|
|
51
|
-
|
|
52
68
|
{
|
|
53
|
-
|
|
54
69
|
name: 'click',
|
|
55
70
|
|
|
56
71
|
delegate() {
|
|
@@ -60,18 +75,15 @@ export default {
|
|
|
60
75
|
handler(e) {
|
|
61
76
|
e.preventDefault();
|
|
62
77
|
this.hide();
|
|
63
|
-
}
|
|
64
|
-
|
|
78
|
+
},
|
|
65
79
|
},
|
|
66
80
|
|
|
67
81
|
{
|
|
68
|
-
|
|
69
82
|
name: 'toggle',
|
|
70
83
|
|
|
71
84
|
self: true,
|
|
72
85
|
|
|
73
|
-
handler(e
|
|
74
|
-
|
|
86
|
+
handler(e) {
|
|
75
87
|
if (e.defaultPrevented) {
|
|
76
88
|
return;
|
|
77
89
|
}
|
|
@@ -81,8 +93,7 @@ export default {
|
|
|
81
93
|
if (this.isToggled() === includes(active, this)) {
|
|
82
94
|
this.toggle();
|
|
83
95
|
}
|
|
84
|
-
}
|
|
85
|
-
|
|
96
|
+
},
|
|
86
97
|
},
|
|
87
98
|
|
|
88
99
|
{
|
|
@@ -91,29 +102,25 @@ export default {
|
|
|
91
102
|
self: true,
|
|
92
103
|
|
|
93
104
|
handler(e) {
|
|
94
|
-
|
|
95
105
|
if (includes(active, this)) {
|
|
96
106
|
return false;
|
|
97
107
|
}
|
|
98
108
|
|
|
99
109
|
if (!this.stack && active.length) {
|
|
100
|
-
Promise.all(active.map(modal => modal.hide())).then(this.show);
|
|
110
|
+
Promise.all(active.map((modal) => modal.hide())).then(this.show);
|
|
101
111
|
e.preventDefault();
|
|
102
112
|
} else {
|
|
103
113
|
active.push(this);
|
|
104
114
|
}
|
|
105
|
-
}
|
|
106
|
-
|
|
115
|
+
},
|
|
107
116
|
},
|
|
108
117
|
|
|
109
118
|
{
|
|
110
|
-
|
|
111
119
|
name: 'show',
|
|
112
120
|
|
|
113
121
|
self: true,
|
|
114
122
|
|
|
115
123
|
handler() {
|
|
116
|
-
|
|
117
124
|
const docEl = document.documentElement;
|
|
118
125
|
|
|
119
126
|
if (width(window) > docEl.clientWidth && this.overlay) {
|
|
@@ -127,30 +134,50 @@ export default {
|
|
|
127
134
|
addClass(docEl, this.clsPage);
|
|
128
135
|
|
|
129
136
|
if (this.bgClose) {
|
|
130
|
-
once(
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
137
|
+
once(
|
|
138
|
+
this.$el,
|
|
139
|
+
'hide',
|
|
140
|
+
on(document, pointerDown, ({ target }) => {
|
|
141
|
+
if (
|
|
142
|
+
last(active) !== this ||
|
|
143
|
+
(this.overlay && !within(target, this.$el)) ||
|
|
144
|
+
within(target, this.panel)
|
|
145
|
+
) {
|
|
146
|
+
return;
|
|
139
147
|
}
|
|
140
|
-
}, true);
|
|
141
148
|
|
|
142
|
-
|
|
149
|
+
once(
|
|
150
|
+
document,
|
|
151
|
+
`${pointerUp} ${pointerCancel} scroll`,
|
|
152
|
+
({ defaultPrevented, type, target: newTarget }) => {
|
|
153
|
+
if (
|
|
154
|
+
!defaultPrevented &&
|
|
155
|
+
type === pointerUp &&
|
|
156
|
+
target === newTarget
|
|
157
|
+
) {
|
|
158
|
+
this.hide();
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
true
|
|
162
|
+
);
|
|
163
|
+
}),
|
|
164
|
+
{ self: true }
|
|
165
|
+
);
|
|
143
166
|
}
|
|
144
167
|
|
|
145
168
|
if (this.escClose) {
|
|
146
|
-
once(
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
169
|
+
once(
|
|
170
|
+
this.$el,
|
|
171
|
+
'hide',
|
|
172
|
+
on(document, 'keydown', (e) => {
|
|
173
|
+
if (e.keyCode === 27 && last(active) === this) {
|
|
174
|
+
this.hide();
|
|
175
|
+
}
|
|
176
|
+
}),
|
|
177
|
+
{ self: true }
|
|
178
|
+
);
|
|
151
179
|
}
|
|
152
|
-
}
|
|
153
|
-
|
|
180
|
+
},
|
|
154
181
|
},
|
|
155
182
|
|
|
156
183
|
{
|
|
@@ -166,17 +193,15 @@ export default {
|
|
|
166
193
|
if (!$(':focus', this.$el)) {
|
|
167
194
|
this.$el.focus();
|
|
168
195
|
}
|
|
169
|
-
}
|
|
196
|
+
},
|
|
170
197
|
},
|
|
171
198
|
|
|
172
199
|
{
|
|
173
|
-
|
|
174
200
|
name: 'hidden',
|
|
175
201
|
|
|
176
202
|
self: true,
|
|
177
203
|
|
|
178
204
|
handler() {
|
|
179
|
-
|
|
180
205
|
if (includes(active, this)) {
|
|
181
206
|
active.splice(active.indexOf(this), 1);
|
|
182
207
|
}
|
|
@@ -187,18 +212,14 @@ export default {
|
|
|
187
212
|
|
|
188
213
|
css(this.$el, 'zIndex', '');
|
|
189
214
|
|
|
190
|
-
if (!active.some(modal => modal.clsPage === this.clsPage)) {
|
|
215
|
+
if (!active.some((modal) => modal.clsPage === this.clsPage)) {
|
|
191
216
|
removeClass(document.documentElement, this.clsPage);
|
|
192
217
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
}
|
|
197
|
-
|
|
218
|
+
},
|
|
219
|
+
},
|
|
198
220
|
],
|
|
199
221
|
|
|
200
222
|
methods: {
|
|
201
|
-
|
|
202
223
|
toggle() {
|
|
203
224
|
return this.isToggled() ? this.hide() : this.show();
|
|
204
225
|
},
|
|
@@ -206,10 +227,8 @@ export default {
|
|
|
206
227
|
show() {
|
|
207
228
|
if (this.container && parent(this.$el) !== this.container) {
|
|
208
229
|
append(this.container, this.$el);
|
|
209
|
-
return new Promise(resolve =>
|
|
210
|
-
requestAnimationFrame(() =>
|
|
211
|
-
this.show().then(resolve)
|
|
212
|
-
)
|
|
230
|
+
return new Promise((resolve) =>
|
|
231
|
+
requestAnimationFrame(() => this.show().then(resolve))
|
|
213
232
|
);
|
|
214
233
|
}
|
|
215
234
|
|
|
@@ -218,13 +237,11 @@ export default {
|
|
|
218
237
|
|
|
219
238
|
hide() {
|
|
220
239
|
return this.toggleElement(this.$el, false, animate(this));
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
}
|
|
224
|
-
|
|
240
|
+
},
|
|
241
|
+
},
|
|
225
242
|
};
|
|
226
243
|
|
|
227
|
-
function animate({transitionElement, _toggle}) {
|
|
244
|
+
function animate({ transitionElement, _toggle }) {
|
|
228
245
|
return (el, show) =>
|
|
229
246
|
new Promise((resolve, reject) =>
|
|
230
247
|
once(el, 'show hide', () => {
|
|
@@ -233,16 +250,22 @@ function animate({transitionElement, _toggle}) {
|
|
|
233
250
|
|
|
234
251
|
_toggle(el, show);
|
|
235
252
|
|
|
236
|
-
const off = once(
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
253
|
+
const off = once(
|
|
254
|
+
transitionElement,
|
|
255
|
+
'transitionstart',
|
|
256
|
+
() => {
|
|
257
|
+
once(transitionElement, 'transitionend transitioncancel', resolve, {
|
|
258
|
+
self: true,
|
|
259
|
+
});
|
|
260
|
+
clearTimeout(timer);
|
|
261
|
+
},
|
|
262
|
+
{ self: true }
|
|
263
|
+
);
|
|
240
264
|
|
|
241
265
|
const timer = setTimeout(() => {
|
|
242
266
|
off();
|
|
243
267
|
resolve();
|
|
244
268
|
}, toMs(css(transitionElement, 'transitionDuration')));
|
|
245
|
-
|
|
246
269
|
})
|
|
247
270
|
).then(() => delete el._reject);
|
|
248
271
|
}
|