uikit 3.11.2-dev.31cd2ba38 → 3.11.2-dev.4274bc35b
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 +38 -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 +121 -202
- package/dist/css/uikit-core-rtl.min.css +1 -1
- package/dist/css/uikit-core.css +121 -202
- package/dist/css/uikit-core.min.css +1 -1
- package/dist/css/uikit-rtl.css +123 -208
- package/dist/css/uikit-rtl.min.css +1 -1
- package/dist/css/uikit.css +123 -208
- 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 +326 -358
- package/dist/js/components/parallax.min.js +1 -1
- package/dist/js/components/slider-parallax.js +324 -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 +324 -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 +5405 -6716
- 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 +7997 -9703
- 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 +38 -50
- package/src/js/core/img.js +127 -87
- 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 +130 -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 +33 -47
- 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 +52 -97
- 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 +52 -97
- 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,13 +1,31 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
$$,
|
|
3
|
+
addClass,
|
|
4
|
+
Animation,
|
|
5
|
+
css,
|
|
6
|
+
fastdom,
|
|
7
|
+
hasClass,
|
|
8
|
+
height,
|
|
9
|
+
includes,
|
|
10
|
+
isBoolean,
|
|
11
|
+
isFunction,
|
|
12
|
+
isVisible,
|
|
13
|
+
noop,
|
|
14
|
+
removeClass,
|
|
15
|
+
toFloat,
|
|
16
|
+
toggleClass,
|
|
17
|
+
toNodes,
|
|
18
|
+
Transition,
|
|
19
|
+
trigger,
|
|
20
|
+
} from 'uikit-util';
|
|
2
21
|
|
|
3
22
|
export default {
|
|
4
|
-
|
|
5
23
|
props: {
|
|
6
24
|
cls: Boolean,
|
|
7
25
|
animation: 'list',
|
|
8
26
|
duration: Number,
|
|
9
27
|
origin: String,
|
|
10
|
-
transition: String
|
|
28
|
+
transition: String,
|
|
11
29
|
},
|
|
12
30
|
|
|
13
31
|
data: {
|
|
@@ -25,7 +43,7 @@ export default {
|
|
|
25
43
|
paddingTop: '',
|
|
26
44
|
paddingBottom: '',
|
|
27
45
|
marginTop: '',
|
|
28
|
-
marginBottom: ''
|
|
46
|
+
marginBottom: '',
|
|
29
47
|
},
|
|
30
48
|
|
|
31
49
|
hideProps: {
|
|
@@ -34,63 +52,61 @@ export default {
|
|
|
34
52
|
paddingTop: 0,
|
|
35
53
|
paddingBottom: 0,
|
|
36
54
|
marginTop: 0,
|
|
37
|
-
marginBottom: 0
|
|
38
|
-
}
|
|
39
|
-
|
|
55
|
+
marginBottom: 0,
|
|
56
|
+
},
|
|
40
57
|
},
|
|
41
58
|
|
|
42
59
|
computed: {
|
|
43
|
-
|
|
44
|
-
hasAnimation({animation}) {
|
|
60
|
+
hasAnimation({ animation }) {
|
|
45
61
|
return !!animation[0];
|
|
46
62
|
},
|
|
47
63
|
|
|
48
|
-
hasTransition({animation}) {
|
|
64
|
+
hasTransition({ animation }) {
|
|
49
65
|
return this.hasAnimation && animation[0] === true;
|
|
50
|
-
}
|
|
51
|
-
|
|
66
|
+
},
|
|
52
67
|
},
|
|
53
68
|
|
|
54
69
|
methods: {
|
|
55
|
-
|
|
56
70
|
toggleElement(targets, toggle, animate) {
|
|
57
|
-
return new Promise(resolve =>
|
|
58
|
-
Promise.all(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
return new Promise((resolve) =>
|
|
72
|
+
Promise.all(
|
|
73
|
+
toNodes(targets).map((el) => {
|
|
74
|
+
const show = isBoolean(toggle) ? toggle : !this.isToggled(el);
|
|
75
|
+
|
|
76
|
+
if (!trigger(el, `before${show ? 'show' : 'hide'}`, [this])) {
|
|
77
|
+
return Promise.reject();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const promise = (
|
|
81
|
+
isFunction(animate)
|
|
82
|
+
? animate
|
|
83
|
+
: animate === false || !this.hasAnimation
|
|
84
|
+
? this._toggle
|
|
85
|
+
: this.hasTransition
|
|
72
86
|
? toggleHeight(this)
|
|
73
87
|
: toggleAnimation(this)
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const cls = show ? this.clsEnter : this.clsLeave;
|
|
88
|
+
)(el, show);
|
|
77
89
|
|
|
78
|
-
|
|
90
|
+
const cls = show ? this.clsEnter : this.clsLeave;
|
|
79
91
|
|
|
80
|
-
|
|
92
|
+
addClass(el, cls);
|
|
81
93
|
|
|
82
|
-
|
|
83
|
-
removeClass(el, cls);
|
|
84
|
-
trigger(el, show ? 'shown' : 'hidden', [this]);
|
|
85
|
-
this.$update(el);
|
|
86
|
-
};
|
|
94
|
+
trigger(el, show ? 'show' : 'hide', [this]);
|
|
87
95
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
96
|
+
const done = () => {
|
|
97
|
+
removeClass(el, cls);
|
|
98
|
+
trigger(el, show ? 'shown' : 'hidden', [this]);
|
|
99
|
+
this.$update(el);
|
|
100
|
+
};
|
|
92
101
|
|
|
93
|
-
|
|
102
|
+
return promise
|
|
103
|
+
? promise.then(done, () => {
|
|
104
|
+
removeClass(el, cls);
|
|
105
|
+
return Promise.reject();
|
|
106
|
+
})
|
|
107
|
+
: done();
|
|
108
|
+
})
|
|
109
|
+
).then(resolve, noop)
|
|
94
110
|
);
|
|
95
111
|
},
|
|
96
112
|
|
|
@@ -99,14 +115,13 @@ export default {
|
|
|
99
115
|
return hasClass(el, this.clsEnter)
|
|
100
116
|
? true
|
|
101
117
|
: hasClass(el, this.clsLeave)
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
118
|
+
? false
|
|
119
|
+
: this.cls
|
|
120
|
+
? hasClass(el, this.cls.split(' ')[0])
|
|
121
|
+
: isVisible(el);
|
|
106
122
|
},
|
|
107
123
|
|
|
108
124
|
_toggle(el, toggled) {
|
|
109
|
-
|
|
110
125
|
if (!el) {
|
|
111
126
|
return;
|
|
112
127
|
}
|
|
@@ -122,23 +137,23 @@ export default {
|
|
|
122
137
|
changed && (el.hidden = !toggled);
|
|
123
138
|
}
|
|
124
139
|
|
|
125
|
-
$$('[autofocus]', el).some(el => isVisible(el) ? el.focus() || true : el.blur());
|
|
140
|
+
$$('[autofocus]', el).some((el) => (isVisible(el) ? el.focus() || true : el.blur()));
|
|
126
141
|
|
|
127
142
|
if (changed) {
|
|
128
143
|
trigger(el, 'toggled', [toggled, this]);
|
|
129
144
|
this.$update(el);
|
|
130
145
|
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
|
|
146
|
+
},
|
|
147
|
+
},
|
|
135
148
|
};
|
|
136
149
|
|
|
137
|
-
export function toggleHeight({isToggled, duration, initProps, hideProps, transition, _toggle}) {
|
|
150
|
+
export function toggleHeight({ isToggled, duration, initProps, hideProps, transition, _toggle }) {
|
|
138
151
|
return (el, show) => {
|
|
139
|
-
|
|
140
152
|
const inProgress = Transition.inProgress(el);
|
|
141
|
-
const inner = el.hasChildNodes
|
|
153
|
+
const inner = el.hasChildNodes
|
|
154
|
+
? toFloat(css(el.firstElementChild, 'marginTop')) +
|
|
155
|
+
toFloat(css(el.lastElementChild, 'marginBottom'))
|
|
156
|
+
: 0;
|
|
142
157
|
const currentHeight = isVisible(el) ? height(el) + (inProgress ? 0 : inner) : 0;
|
|
143
158
|
|
|
144
159
|
Transition.cancel(el);
|
|
@@ -155,26 +170,37 @@ export function toggleHeight({isToggled, duration, initProps, hideProps, transit
|
|
|
155
170
|
const endHeight = height(el) + (inProgress ? 0 : inner);
|
|
156
171
|
height(el, currentHeight);
|
|
157
172
|
|
|
158
|
-
return (
|
|
159
|
-
|
|
160
|
-
|
|
173
|
+
return (
|
|
174
|
+
show
|
|
175
|
+
? Transition.start(
|
|
176
|
+
el,
|
|
177
|
+
{ ...initProps, overflow: 'hidden', height: endHeight },
|
|
178
|
+
Math.round(duration * (1 - currentHeight / endHeight)),
|
|
179
|
+
transition
|
|
180
|
+
)
|
|
181
|
+
: Transition.start(
|
|
182
|
+
el,
|
|
183
|
+
hideProps,
|
|
184
|
+
Math.round(duration * (currentHeight / endHeight)),
|
|
185
|
+
transition
|
|
186
|
+
).then(() => _toggle(el, false))
|
|
161
187
|
).then(() => css(el, initProps));
|
|
162
|
-
|
|
163
188
|
};
|
|
164
189
|
}
|
|
165
190
|
|
|
166
191
|
function toggleAnimation(cmp) {
|
|
167
192
|
return (el, show) => {
|
|
168
|
-
|
|
169
193
|
Animation.cancel(el);
|
|
170
194
|
|
|
171
|
-
const {animation, duration, _toggle} = cmp;
|
|
195
|
+
const { animation, duration, _toggle } = cmp;
|
|
172
196
|
|
|
173
197
|
if (show) {
|
|
174
198
|
_toggle(el, true);
|
|
175
199
|
return Animation.in(el, animation[0], duration, cmp.origin);
|
|
176
200
|
}
|
|
177
201
|
|
|
178
|
-
return Animation.out(el, animation[1] || animation[0], duration, cmp.origin).then(() =>
|
|
202
|
+
return Animation.out(el, animation[1] || animation[0], duration, cmp.origin).then(() =>
|
|
203
|
+
_toggle(el, false)
|
|
204
|
+
);
|
|
179
205
|
};
|
|
180
206
|
}
|
package/src/js/uikit-core.js
CHANGED
|
@@ -2,12 +2,10 @@ import UIkit from './api/index';
|
|
|
2
2
|
import Core from './core/core';
|
|
3
3
|
import boot from './api/boot';
|
|
4
4
|
import * as components from './core/index';
|
|
5
|
-
import {each} from 'uikit-util';
|
|
5
|
+
import { each } from 'uikit-util';
|
|
6
6
|
|
|
7
7
|
// register components
|
|
8
|
-
each(components, (component, name) =>
|
|
9
|
-
UIkit.component(name, component)
|
|
10
|
-
);
|
|
8
|
+
each(components, (component, name) => UIkit.component(name, component));
|
|
11
9
|
|
|
12
10
|
// core functionality
|
|
13
11
|
UIkit.use(Core);
|
package/src/js/uikit.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import UIkit from './uikit-core';
|
|
2
2
|
import * as components from './components/index';
|
|
3
|
-
import {each} from 'uikit-util';
|
|
3
|
+
import { each } from 'uikit-util';
|
|
4
4
|
|
|
5
|
-
each(components, (component, name) =>
|
|
6
|
-
UIkit.component(name, component)
|
|
7
|
-
);
|
|
5
|
+
each(components, (component, name) => UIkit.component(name, component));
|
|
8
6
|
|
|
9
7
|
export default UIkit;
|
package/src/js/util/ajax.js
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import {on} from './event';
|
|
2
|
-
import {
|
|
3
|
-
import {assign, isString, noop} from './lang';
|
|
1
|
+
import { on } from './event';
|
|
2
|
+
import { assign, noop } from './lang';
|
|
4
3
|
|
|
5
4
|
export function ajax(url, options) {
|
|
6
|
-
|
|
7
|
-
const env = assign({
|
|
5
|
+
const env = {
|
|
8
6
|
data: null,
|
|
9
7
|
method: 'GET',
|
|
10
8
|
headers: {},
|
|
11
9
|
xhr: new XMLHttpRequest(),
|
|
12
10
|
beforeSend: noop,
|
|
13
|
-
responseType: ''
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
responseType: '',
|
|
12
|
+
...options,
|
|
13
|
+
};
|
|
16
14
|
return Promise.resolve()
|
|
17
15
|
.then(() => env.beforeSend(env))
|
|
18
16
|
.then(() => send(url, env));
|
|
@@ -20,15 +18,15 @@ export function ajax(url, options) {
|
|
|
20
18
|
|
|
21
19
|
function send(url, env) {
|
|
22
20
|
return new Promise((resolve, reject) => {
|
|
23
|
-
|
|
21
|
+
const { xhr } = env;
|
|
24
22
|
|
|
25
23
|
for (const prop in env) {
|
|
26
24
|
if (prop in xhr) {
|
|
27
25
|
try {
|
|
28
|
-
|
|
29
26
|
xhr[prop] = env[prop];
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
} catch (e) {
|
|
28
|
+
// noop
|
|
29
|
+
}
|
|
32
30
|
}
|
|
33
31
|
}
|
|
34
32
|
|
|
@@ -39,51 +37,34 @@ function send(url, env) {
|
|
|
39
37
|
}
|
|
40
38
|
|
|
41
39
|
on(xhr, 'load', () => {
|
|
42
|
-
|
|
43
|
-
if (xhr.status === 0 || xhr.status >= 200 && xhr.status < 300 || xhr.status === 304) {
|
|
44
|
-
|
|
45
|
-
// IE 11 does not support responseType 'json'
|
|
46
|
-
if (env.responseType === 'json' && isString(xhr.response)) {
|
|
47
|
-
xhr = assign(copyXhr(xhr), {response: JSON.parse(xhr.response)});
|
|
48
|
-
}
|
|
49
|
-
|
|
40
|
+
if (xhr.status === 0 || (xhr.status >= 200 && xhr.status < 300) || xhr.status === 304) {
|
|
50
41
|
resolve(xhr);
|
|
51
|
-
|
|
52
42
|
} else {
|
|
53
|
-
reject(
|
|
54
|
-
xhr,
|
|
55
|
-
|
|
56
|
-
|
|
43
|
+
reject(
|
|
44
|
+
assign(Error(xhr.statusText), {
|
|
45
|
+
xhr,
|
|
46
|
+
status: xhr.status,
|
|
47
|
+
})
|
|
48
|
+
);
|
|
57
49
|
}
|
|
58
|
-
|
|
59
50
|
});
|
|
60
51
|
|
|
61
|
-
on(xhr, 'error', () => reject(assign(Error('Network Error'), {xhr})));
|
|
62
|
-
on(xhr, 'timeout', () => reject(assign(Error('Network Timeout'), {xhr})));
|
|
52
|
+
on(xhr, 'error', () => reject(assign(Error('Network Error'), { xhr })));
|
|
53
|
+
on(xhr, 'timeout', () => reject(assign(Error('Network Timeout'), { xhr })));
|
|
63
54
|
|
|
64
55
|
xhr.send(env.data);
|
|
65
56
|
});
|
|
66
57
|
}
|
|
67
58
|
|
|
68
59
|
export function getImage(src, srcset, sizes) {
|
|
69
|
-
|
|
70
60
|
return new Promise((resolve, reject) => {
|
|
71
61
|
const img = new Image();
|
|
72
62
|
|
|
73
|
-
img.onerror = e => reject(e);
|
|
63
|
+
img.onerror = (e) => reject(e);
|
|
74
64
|
img.onload = () => resolve(img);
|
|
75
65
|
|
|
76
66
|
sizes && (img.sizes = sizes);
|
|
77
67
|
srcset && (img.srcset = srcset);
|
|
78
68
|
img.src = src;
|
|
79
69
|
});
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function copyXhr(source) {
|
|
84
|
-
const target = {};
|
|
85
|
-
for (const key in source) {
|
|
86
|
-
target[key] = source[key];
|
|
87
|
-
}
|
|
88
|
-
return target;
|
|
89
70
|
}
|
package/src/js/util/animation.js
CHANGED
|
@@ -1,49 +1,52 @@
|
|
|
1
|
-
import {attr} from './attr';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {addClass, hasClass, removeClass, removeClasses} from './class';
|
|
1
|
+
import { attr } from './attr';
|
|
2
|
+
import { once, trigger } from './event';
|
|
3
|
+
import { css, propName } from './style';
|
|
4
|
+
import { startsWith, toNodes } from './lang';
|
|
5
|
+
import { addClass, hasClass, removeClass, removeClasses } from './class';
|
|
7
6
|
|
|
8
7
|
export function transition(element, props, duration = 400, timing = 'linear') {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
8
|
+
return Promise.all(
|
|
9
|
+
toNodes(element).map(
|
|
10
|
+
(element) =>
|
|
11
|
+
new Promise((resolve, reject) => {
|
|
12
|
+
for (const name in props) {
|
|
13
|
+
const value = css(element, name);
|
|
14
|
+
if (value === '') {
|
|
15
|
+
css(element, name, value);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const timer = setTimeout(() => trigger(element, 'transitionend'), duration);
|
|
20
|
+
|
|
21
|
+
once(
|
|
22
|
+
element,
|
|
23
|
+
'transitionend transitioncanceled',
|
|
24
|
+
({ type }) => {
|
|
25
|
+
clearTimeout(timer);
|
|
26
|
+
removeClass(element, 'uk-transition');
|
|
27
|
+
css(element, {
|
|
28
|
+
transitionProperty: '',
|
|
29
|
+
transitionDuration: '',
|
|
30
|
+
transitionTimingFunction: '',
|
|
31
|
+
});
|
|
32
|
+
type === 'transitioncanceled' ? reject() : resolve(element);
|
|
33
|
+
},
|
|
34
|
+
{ self: true }
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
addClass(element, 'uk-transition');
|
|
38
|
+
css(element, {
|
|
39
|
+
transitionProperty: Object.keys(props).map(propName).join(','),
|
|
40
|
+
transitionDuration: `${duration}ms`,
|
|
41
|
+
transitionTimingFunction: timing,
|
|
42
|
+
...props,
|
|
43
|
+
});
|
|
44
|
+
})
|
|
45
|
+
)
|
|
46
|
+
);
|
|
43
47
|
}
|
|
44
48
|
|
|
45
49
|
export const Transition = {
|
|
46
|
-
|
|
47
50
|
start: transition,
|
|
48
51
|
|
|
49
52
|
stop(element) {
|
|
@@ -57,47 +60,47 @@ export const Transition = {
|
|
|
57
60
|
|
|
58
61
|
inProgress(element) {
|
|
59
62
|
return hasClass(element, 'uk-transition');
|
|
60
|
-
}
|
|
61
|
-
|
|
63
|
+
},
|
|
62
64
|
};
|
|
63
65
|
|
|
64
66
|
const animationPrefix = 'uk-animation-';
|
|
65
67
|
|
|
66
68
|
export function animate(element, animation, duration = 200, origin, out) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
69
|
+
return Promise.all(
|
|
70
|
+
toNodes(element).map(
|
|
71
|
+
(element) =>
|
|
72
|
+
new Promise((resolve, reject) => {
|
|
73
|
+
trigger(element, 'animationcanceled');
|
|
74
|
+
const timer = setTimeout(() => trigger(element, 'animationend'), duration);
|
|
75
|
+
|
|
76
|
+
once(
|
|
77
|
+
element,
|
|
78
|
+
'animationend animationcanceled',
|
|
79
|
+
({ type }) => {
|
|
80
|
+
clearTimeout(timer);
|
|
81
|
+
|
|
82
|
+
type === 'animationcanceled' ? reject() : resolve(element);
|
|
83
|
+
|
|
84
|
+
css(element, 'animationDuration', '');
|
|
85
|
+
removeClasses(element, `${animationPrefix}\\S*`);
|
|
86
|
+
},
|
|
87
|
+
{ self: true }
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
css(element, 'animationDuration', `${duration}ms`);
|
|
91
|
+
addClass(element, animation, animationPrefix + (out ? 'leave' : 'enter'));
|
|
92
|
+
|
|
93
|
+
if (startsWith(animation, animationPrefix)) {
|
|
94
|
+
origin && addClass(element, `uk-transform-origin-${origin}`);
|
|
95
|
+
out && addClass(element, `${animationPrefix}reverse`);
|
|
96
|
+
}
|
|
97
|
+
})
|
|
98
|
+
)
|
|
99
|
+
);
|
|
96
100
|
}
|
|
97
101
|
|
|
98
102
|
const inProgress = new RegExp(`${animationPrefix}(enter|leave)`);
|
|
99
103
|
export const Animation = {
|
|
100
|
-
|
|
101
104
|
in: animate,
|
|
102
105
|
|
|
103
106
|
out(element, animation, duration, origin) {
|
|
@@ -110,6 +113,5 @@ export const Animation = {
|
|
|
110
113
|
|
|
111
114
|
cancel(element) {
|
|
112
115
|
trigger(element, 'animationcanceled');
|
|
113
|
-
}
|
|
114
|
-
|
|
116
|
+
},
|
|
115
117
|
};
|
package/src/js/util/attr.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {isFunction, isObject, isUndefined, toNode, toNodes} from './lang';
|
|
1
|
+
import { isFunction, isObject, isUndefined, toNode, toNodes } from './lang';
|
|
2
2
|
|
|
3
3
|
export function attr(element, name, value) {
|
|
4
|
-
|
|
5
4
|
if (isObject(name)) {
|
|
6
5
|
for (const key in name) {
|
|
7
6
|
attr(element, key, name[key]);
|
|
@@ -10,42 +9,39 @@ export function attr(element, name, value) {
|
|
|
10
9
|
}
|
|
11
10
|
|
|
12
11
|
if (isUndefined(value)) {
|
|
13
|
-
|
|
14
|
-
return element && element.getAttribute(name);
|
|
12
|
+
return toNode(element)?.getAttribute(name);
|
|
15
13
|
} else {
|
|
16
|
-
toNodes(element)
|
|
17
|
-
|
|
14
|
+
for (const el of toNodes(element)) {
|
|
18
15
|
if (isFunction(value)) {
|
|
19
|
-
value = value.call(
|
|
16
|
+
value = value.call(el, attr(el, name));
|
|
20
17
|
}
|
|
21
18
|
|
|
22
19
|
if (value === null) {
|
|
23
|
-
removeAttr(
|
|
20
|
+
removeAttr(el, name);
|
|
24
21
|
} else {
|
|
25
|
-
|
|
22
|
+
el.setAttribute(name, value);
|
|
26
23
|
}
|
|
27
|
-
}
|
|
24
|
+
}
|
|
28
25
|
}
|
|
29
|
-
|
|
30
26
|
}
|
|
31
27
|
|
|
32
28
|
export function hasAttr(element, name) {
|
|
33
|
-
return toNodes(element).some(element => element.hasAttribute(name));
|
|
29
|
+
return toNodes(element).some((element) => element.hasAttribute(name));
|
|
34
30
|
}
|
|
35
31
|
|
|
36
32
|
export function removeAttr(element, name) {
|
|
37
|
-
|
|
38
|
-
name.split(' ')
|
|
39
|
-
|
|
40
|
-
element.
|
|
41
|
-
|
|
42
|
-
|
|
33
|
+
const elements = toNodes(element);
|
|
34
|
+
for (const attribute of name.split(' ')) {
|
|
35
|
+
for (const element of elements) {
|
|
36
|
+
element.removeAttribute(attribute);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
43
39
|
}
|
|
44
40
|
|
|
45
41
|
export function data(element, attribute) {
|
|
46
|
-
for (
|
|
47
|
-
if (hasAttr(element,
|
|
48
|
-
return attr(element,
|
|
42
|
+
for (const name of [attribute, `data-${attribute}`]) {
|
|
43
|
+
if (hasAttr(element, name)) {
|
|
44
|
+
return attr(element, name);
|
|
49
45
|
}
|
|
50
46
|
}
|
|
51
47
|
}
|