uikit 3.11.2-dev.c08a5b5f0 → 3.11.2-dev.d8c101f07
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 -15
- 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 +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 +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 +722 -852
- 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 +609 -834
- 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 +5244 -6600
- 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 +8041 -9907
- 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 +65 -82
- 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-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 +75 -64
- package/src/js/components/slideshow-parallax.js +1 -1
- package/src/js/components/slideshow.js +8 -44
- 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 +133 -152
- 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 +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 +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 +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 +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 +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 +81 -121
- package/src/js/util/mouse.js +19 -17
- package/src/js/util/options.js +32 -46
- 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/image.html +37 -33
- 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/tests/images/test.avif +0 -0
- package/tests/images/test.webp +0 -0
package/src/js/core/img.js
CHANGED
|
@@ -1,216 +1,195 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import {
|
|
2
|
+
createEvent,
|
|
3
|
+
css,
|
|
4
|
+
Dimensions,
|
|
5
|
+
escape,
|
|
6
|
+
getImage,
|
|
7
|
+
includes,
|
|
8
|
+
isUndefined,
|
|
9
|
+
queryAll,
|
|
10
|
+
startsWith,
|
|
11
|
+
toFloat,
|
|
12
|
+
toPx,
|
|
13
|
+
trigger,
|
|
14
|
+
} from 'uikit-util';
|
|
5
15
|
|
|
6
16
|
export default {
|
|
7
|
-
|
|
8
17
|
args: 'dataSrc',
|
|
9
18
|
|
|
10
19
|
props: {
|
|
11
20
|
dataSrc: String,
|
|
12
|
-
|
|
21
|
+
dataSrcset: Boolean,
|
|
22
|
+
sizes: String,
|
|
23
|
+
width: Number,
|
|
24
|
+
height: Number,
|
|
13
25
|
offsetTop: String,
|
|
14
26
|
offsetLeft: String,
|
|
15
27
|
target: String,
|
|
16
|
-
loading: String
|
|
17
28
|
},
|
|
18
29
|
|
|
19
30
|
data: {
|
|
20
31
|
dataSrc: '',
|
|
21
|
-
|
|
32
|
+
dataSrcset: false,
|
|
33
|
+
sizes: false,
|
|
34
|
+
width: false,
|
|
35
|
+
height: false,
|
|
22
36
|
offsetTop: '50vh',
|
|
23
37
|
offsetLeft: '50vw',
|
|
24
38
|
target: false,
|
|
25
|
-
loading: 'lazy'
|
|
26
39
|
},
|
|
27
40
|
|
|
28
41
|
computed: {
|
|
42
|
+
cacheKey({ dataSrc }) {
|
|
43
|
+
return `${this.$name}.${dataSrc}`;
|
|
44
|
+
},
|
|
29
45
|
|
|
30
|
-
|
|
46
|
+
width({ width, dataWidth }) {
|
|
47
|
+
return width || dataWidth;
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
height({ height, dataHeight }) {
|
|
51
|
+
return height || dataHeight;
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
sizes({ sizes, dataSizes }) {
|
|
55
|
+
return sizes || dataSizes;
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
isImg(_, $el) {
|
|
59
|
+
return isImg($el);
|
|
60
|
+
},
|
|
31
61
|
|
|
32
|
-
|
|
62
|
+
target: {
|
|
63
|
+
get({ target }) {
|
|
33
64
|
return [this.$el, ...queryAll(target, this.$el)];
|
|
34
65
|
},
|
|
35
66
|
|
|
36
67
|
watch() {
|
|
37
68
|
this.observe();
|
|
38
|
-
}
|
|
69
|
+
},
|
|
70
|
+
},
|
|
39
71
|
|
|
40
|
-
}
|
|
72
|
+
offsetTop({ offsetTop }) {
|
|
73
|
+
return toPx(offsetTop, 'height');
|
|
74
|
+
},
|
|
41
75
|
|
|
76
|
+
offsetLeft({ offsetLeft }) {
|
|
77
|
+
return toPx(offsetLeft, 'width');
|
|
78
|
+
},
|
|
42
79
|
},
|
|
43
80
|
|
|
44
81
|
connected() {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
this.load();
|
|
82
|
+
if (!window.IntersectionObserver) {
|
|
83
|
+
setSrcAttrs(this.$el, this.dataSrc, this.dataSrcset, this.sizes);
|
|
48
84
|
return;
|
|
49
85
|
}
|
|
50
86
|
|
|
51
|
-
if (
|
|
52
|
-
this.$el.
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if (this.target.length === 1) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
87
|
+
if (storage[this.cacheKey]) {
|
|
88
|
+
setSrcAttrs(this.$el, storage[this.cacheKey], this.dataSrcset, this.sizes);
|
|
89
|
+
} else if (this.isImg && this.width && this.height) {
|
|
90
|
+
setSrcAttrs(this.$el, getPlaceholderImage(this.width, this.height, this.sizes));
|
|
58
91
|
}
|
|
59
92
|
|
|
60
|
-
|
|
93
|
+
this.observer = new IntersectionObserver(this.load, {
|
|
94
|
+
rootMargin: `${this.offsetTop}px ${this.offsetLeft}px`,
|
|
95
|
+
});
|
|
61
96
|
|
|
62
|
-
|
|
63
|
-
this.observer = new IntersectionObserver(entries => {
|
|
64
|
-
if (entries.some(entry => entry.isIntersecting)) {
|
|
65
|
-
this.load();
|
|
66
|
-
this.observer.disconnect();
|
|
67
|
-
}
|
|
68
|
-
}, {rootMargin});
|
|
69
|
-
this.observe();
|
|
97
|
+
requestAnimationFrame(this.observe);
|
|
70
98
|
},
|
|
71
99
|
|
|
72
100
|
disconnected() {
|
|
73
|
-
|
|
74
|
-
if (this._data.image) {
|
|
75
|
-
this._data.image.onload = '';
|
|
76
|
-
}
|
|
77
|
-
|
|
78
101
|
this.observer && this.observer.disconnect();
|
|
79
102
|
},
|
|
80
103
|
|
|
81
104
|
update: {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if (!this.observer || isImg(this.$el)) {
|
|
105
|
+
read({ image }) {
|
|
106
|
+
if (!this.observer) {
|
|
85
107
|
return false;
|
|
86
108
|
}
|
|
87
|
-
const srcset = data(this.$el, 'data-srcset');
|
|
88
|
-
if (srcset && window.devicePixelRatio !== 1) {
|
|
89
109
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
css(this.$el, 'backgroundSize', `${store.bgSize}px`);
|
|
94
|
-
}
|
|
110
|
+
if (!image && document.readyState === 'complete') {
|
|
111
|
+
this.load(this.observer.takeRecords());
|
|
112
|
+
}
|
|
95
113
|
|
|
114
|
+
if (this.isImg) {
|
|
115
|
+
return false;
|
|
96
116
|
}
|
|
97
117
|
|
|
118
|
+
image &&
|
|
119
|
+
image.then(
|
|
120
|
+
(img) => img && img.currentSrc !== '' && setSrcAttrs(this.$el, currentSrc(img))
|
|
121
|
+
);
|
|
98
122
|
},
|
|
99
123
|
|
|
100
|
-
|
|
124
|
+
write(data) {
|
|
125
|
+
if (this.dataSrcset && window.devicePixelRatio !== 1) {
|
|
126
|
+
const bgSize = css(this.$el, 'backgroundSize');
|
|
127
|
+
if (bgSize.match(/^(auto\s?)+$/) || toFloat(bgSize) === data.bgSize) {
|
|
128
|
+
data.bgSize = getSourceSize(this.dataSrcset, this.sizes);
|
|
129
|
+
css(this.$el, 'backgroundSize', `${data.bgSize}px`);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
},
|
|
101
133
|
|
|
134
|
+
events: ['resize'],
|
|
102
135
|
},
|
|
103
136
|
|
|
104
137
|
methods: {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
if (
|
|
108
|
-
|
|
138
|
+
load(entries) {
|
|
139
|
+
// Old chromium based browsers (UC Browser) did not implement `isIntersecting`
|
|
140
|
+
if (
|
|
141
|
+
!entries.some((entry) => isUndefined(entry.isIntersecting) || entry.isIntersecting)
|
|
142
|
+
) {
|
|
143
|
+
return;
|
|
109
144
|
}
|
|
110
145
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
this
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
)
|
|
146
|
+
this._data.image = getImage(this.dataSrc, this.dataSrcset, this.sizes).then(
|
|
147
|
+
(img) => {
|
|
148
|
+
setSrcAttrs(this.$el, currentSrc(img), img.srcset, img.sizes);
|
|
149
|
+
storage[this.cacheKey] = currentSrc(img);
|
|
150
|
+
return img;
|
|
151
|
+
},
|
|
152
|
+
(e) => trigger(this.$el, new e.constructor(e.type, e))
|
|
153
|
+
);
|
|
118
154
|
|
|
119
|
-
|
|
120
|
-
setSrcAttrs(this.$el, image.currentSrc);
|
|
121
|
-
return this.image = image;
|
|
155
|
+
this.observer.disconnect();
|
|
122
156
|
},
|
|
123
157
|
|
|
124
158
|
observe() {
|
|
125
159
|
if (this._connected && !this._data.image) {
|
|
126
|
-
|
|
160
|
+
for (const el of this.target) {
|
|
161
|
+
this.observer.observe(el);
|
|
162
|
+
}
|
|
127
163
|
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
|
|
164
|
+
},
|
|
165
|
+
},
|
|
132
166
|
};
|
|
133
167
|
|
|
134
|
-
function setSrcAttrs(el, src) {
|
|
135
|
-
|
|
168
|
+
function setSrcAttrs(el, src, srcset, sizes) {
|
|
136
169
|
if (isImg(el)) {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
170
|
+
const set = (prop, val) => val && val !== el[prop] && (el[prop] = val);
|
|
171
|
+
set('sizes', sizes);
|
|
172
|
+
set('srcset', srcset);
|
|
173
|
+
set('src', src);
|
|
142
174
|
} else if (src) {
|
|
143
|
-
|
|
144
175
|
const change = !includes(el.style.backgroundImage, src);
|
|
145
176
|
if (change) {
|
|
146
177
|
css(el, 'backgroundImage', `url(${escape(src)})`);
|
|
147
178
|
trigger(el, createEvent('load', false));
|
|
148
179
|
}
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
const srcProps = ['data-src', 'data-srcset', 'sizes'];
|
|
155
|
-
function setSourceProps(sourceEl, targetEl) {
|
|
156
|
-
srcProps.forEach(prop => {
|
|
157
|
-
const value = data(sourceEl, prop);
|
|
158
|
-
if (value) {
|
|
159
|
-
attr(targetEl, prop.replace(/^(data-)+/, ''), value);
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
function getImageFromElement(el, src, sources) {
|
|
165
|
-
|
|
166
|
-
if (!src) {
|
|
167
|
-
return false;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
const img = new Image();
|
|
171
|
-
|
|
172
|
-
wrapInPicture(img, sources);
|
|
173
|
-
setSourceProps(el, img);
|
|
174
|
-
img.onload = () => setSrcAttrs(el, img.currentSrc);
|
|
175
|
-
attr(img, 'src', src);
|
|
176
|
-
return img;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
function wrapInPicture(img, sources) {
|
|
180
|
-
|
|
181
|
-
sources = parseSources(sources);
|
|
182
|
-
|
|
183
|
-
if (sources.length) {
|
|
184
|
-
const picture = fragment('<picture>');
|
|
185
|
-
sources.forEach(attrs => {
|
|
186
|
-
const source = fragment('<source>');
|
|
187
|
-
attr(source, attrs);
|
|
188
|
-
append(picture, source);
|
|
189
|
-
});
|
|
190
|
-
append(picture, img);
|
|
191
180
|
}
|
|
192
181
|
}
|
|
193
182
|
|
|
194
|
-
function
|
|
195
|
-
if (
|
|
196
|
-
|
|
183
|
+
function getPlaceholderImage(width, height, sizes) {
|
|
184
|
+
if (sizes) {
|
|
185
|
+
({ width, height } = Dimensions.ratio(
|
|
186
|
+
{ width, height },
|
|
187
|
+
'width',
|
|
188
|
+
toPx(sizesToPixel(sizes))
|
|
189
|
+
));
|
|
197
190
|
}
|
|
198
191
|
|
|
199
|
-
|
|
200
|
-
try {
|
|
201
|
-
sources = JSON.parse(sources);
|
|
202
|
-
} catch (e) {
|
|
203
|
-
sources = [];
|
|
204
|
-
}
|
|
205
|
-
} else {
|
|
206
|
-
sources = parseOptions(sources);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
if (!isArray(sources)) {
|
|
210
|
-
sources = [sources];
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
return sources.filter(source => !isEmpty(source));
|
|
192
|
+
return `data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}"></svg>`;
|
|
214
193
|
}
|
|
215
194
|
|
|
216
195
|
const sizesRe = /\s*(.*?)\s*(\w+|calc\(.*?\))\s*(?:,|$)/g;
|
|
@@ -234,11 +213,11 @@ const additionRe = /[+-]?(\d+)/g;
|
|
|
234
213
|
function evaluateSize(size) {
|
|
235
214
|
return startsWith(size, 'calc')
|
|
236
215
|
? size
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
216
|
+
.slice(5, -1)
|
|
217
|
+
.replace(sizeRe, (size) => toPx(size))
|
|
218
|
+
.replace(/ /g, '')
|
|
219
|
+
.match(additionRe)
|
|
220
|
+
.reduce((a, b) => a + +b, 0)
|
|
242
221
|
: size;
|
|
243
222
|
}
|
|
244
223
|
|
|
@@ -247,23 +226,25 @@ function getSourceSize(srcset, sizes) {
|
|
|
247
226
|
const srcSize = toPx(sizesToPixel(sizes));
|
|
248
227
|
const descriptors = (srcset.match(srcSetRe) || []).map(toFloat).sort((a, b) => a - b);
|
|
249
228
|
|
|
250
|
-
return descriptors.filter(size => size >= srcSize)[0] || descriptors.pop() || '';
|
|
229
|
+
return descriptors.filter((size) => size >= srcSize)[0] || descriptors.pop() || '';
|
|
251
230
|
}
|
|
252
231
|
|
|
253
|
-
function
|
|
254
|
-
|
|
255
|
-
attr(el, 'src', 'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg"></svg>');
|
|
256
|
-
}
|
|
232
|
+
function isImg(el) {
|
|
233
|
+
return el.tagName === 'IMG';
|
|
257
234
|
}
|
|
258
235
|
|
|
259
|
-
function
|
|
260
|
-
return
|
|
236
|
+
function currentSrc(el) {
|
|
237
|
+
return el.currentSrc || el.src;
|
|
261
238
|
}
|
|
262
239
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
}
|
|
240
|
+
const key = '__test__';
|
|
241
|
+
let storage;
|
|
266
242
|
|
|
267
|
-
|
|
268
|
-
|
|
243
|
+
// workaround for Safari's private browsing mode and accessing sessionStorage in Blink
|
|
244
|
+
try {
|
|
245
|
+
storage = window.sessionStorage || {};
|
|
246
|
+
storage[key] = 1;
|
|
247
|
+
delete storage[key];
|
|
248
|
+
} catch (e) {
|
|
249
|
+
storage = {};
|
|
269
250
|
}
|
package/src/js/core/index.js
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
export {default as Accordion} from './accordion';
|
|
2
|
-
export {default as Alert} from './alert';
|
|
3
|
-
export {default as Cover} from './cover';
|
|
4
|
-
export {default as Drop, default as Dropdown} from './drop';
|
|
5
|
-
export {default as FormCustom} from './form-custom';
|
|
6
|
-
export {default as Gif} from './gif';
|
|
7
|
-
export {default as Grid} from './grid';
|
|
8
|
-
export {default as HeightMatch} from './height-match';
|
|
9
|
-
export {default as HeightViewport} from './height-viewport';
|
|
10
|
-
export {default as Icon} from './icon';
|
|
11
|
-
export {default as Img} from './img';
|
|
12
|
-
export {default as Leader} from './leader';
|
|
13
|
-
export {default as Margin} from './margin';
|
|
14
|
-
export {default as Modal} from './modal';
|
|
15
|
-
export {default as Nav} from './nav';
|
|
16
|
-
export {default as Navbar} from './navbar';
|
|
17
|
-
export {default as Offcanvas} from './offcanvas';
|
|
18
|
-
export {default as OverflowAuto} from './overflow-auto';
|
|
19
|
-
export {default as Responsive} from './responsive';
|
|
20
|
-
export {default as Scroll} from './scroll';
|
|
21
|
-
export {default as Scrollspy} from './scrollspy';
|
|
22
|
-
export {default as ScrollspyNav} from './scrollspy-nav';
|
|
23
|
-
export {default as Sticky} from './sticky';
|
|
24
|
-
export {default as Svg} from './svg';
|
|
25
|
-
export {default as Switcher} from './switcher';
|
|
26
|
-
export {default as Tab} from './tab';
|
|
27
|
-
export {default as Toggle} from './toggle';
|
|
28
|
-
export {default as Video} from './video';
|
|
1
|
+
export { default as Accordion } from './accordion';
|
|
2
|
+
export { default as Alert } from './alert';
|
|
3
|
+
export { default as Cover } from './cover';
|
|
4
|
+
export { default as Drop, default as Dropdown } from './drop';
|
|
5
|
+
export { default as FormCustom } from './form-custom';
|
|
6
|
+
export { default as Gif } from './gif';
|
|
7
|
+
export { default as Grid } from './grid';
|
|
8
|
+
export { default as HeightMatch } from './height-match';
|
|
9
|
+
export { default as HeightViewport } from './height-viewport';
|
|
10
|
+
export { default as Icon } from './icon';
|
|
11
|
+
export { default as Img } from './img';
|
|
12
|
+
export { default as Leader } from './leader';
|
|
13
|
+
export { default as Margin } from './margin';
|
|
14
|
+
export { default as Modal } from './modal';
|
|
15
|
+
export { default as Nav } from './nav';
|
|
16
|
+
export { default as Navbar } from './navbar';
|
|
17
|
+
export { default as Offcanvas } from './offcanvas';
|
|
18
|
+
export { default as OverflowAuto } from './overflow-auto';
|
|
19
|
+
export { default as Responsive } from './responsive';
|
|
20
|
+
export { default as Scroll } from './scroll';
|
|
21
|
+
export { default as Scrollspy } from './scrollspy';
|
|
22
|
+
export { default as ScrollspyNav } from './scrollspy-nav';
|
|
23
|
+
export { default as Sticky } from './sticky';
|
|
24
|
+
export { default as Svg } from './svg';
|
|
25
|
+
export { default as Switcher } from './switcher';
|
|
26
|
+
export { default as Tab } from './tab';
|
|
27
|
+
export { default as Toggle } from './toggle';
|
|
28
|
+
export { default as Video } from './video';
|
|
29
29
|
|
|
30
30
|
// Icon components
|
|
31
|
-
export {Close} from './icon';
|
|
32
|
-
export {Spinner} from './icon';
|
|
33
|
-
export {Slidenav as SlidenavNext} from './icon';
|
|
34
|
-
export {Slidenav as SlidenavPrevious} from './icon';
|
|
35
|
-
export {Search as SearchIcon} from './icon';
|
|
36
|
-
export {IconComponent as Marker} from './icon';
|
|
37
|
-
export {IconComponent as NavbarToggleIcon} from './icon';
|
|
38
|
-
export {IconComponent as OverlayIcon} from './icon';
|
|
39
|
-
export {IconComponent as PaginationNext} from './icon';
|
|
40
|
-
export {IconComponent as PaginationPrevious} from './icon';
|
|
41
|
-
export {IconComponent as Totop} from './icon';
|
|
31
|
+
export { Close } from './icon';
|
|
32
|
+
export { Spinner } from './icon';
|
|
33
|
+
export { Slidenav as SlidenavNext } from './icon';
|
|
34
|
+
export { Slidenav as SlidenavPrevious } from './icon';
|
|
35
|
+
export { Search as SearchIcon } from './icon';
|
|
36
|
+
export { IconComponent as Marker } from './icon';
|
|
37
|
+
export { IconComponent as NavbarToggleIcon } from './icon';
|
|
38
|
+
export { IconComponent as OverlayIcon } from './icon';
|
|
39
|
+
export { IconComponent as PaginationNext } from './icon';
|
|
40
|
+
export { IconComponent as PaginationPrevious } from './icon';
|
|
41
|
+
export { IconComponent as Totop } from './icon';
|
package/src/js/core/leader.js
CHANGED
|
@@ -1,28 +1,25 @@
|
|
|
1
1
|
import Class from '../mixin/class';
|
|
2
2
|
import Media from '../mixin/media';
|
|
3
|
-
import {attr, getCssVar, toggleClass, unwrap, wrapInner} from 'uikit-util';
|
|
3
|
+
import { attr, getCssVar, toggleClass, unwrap, wrapInner } from 'uikit-util';
|
|
4
4
|
|
|
5
5
|
export default {
|
|
6
|
-
|
|
7
6
|
mixins: [Class, Media],
|
|
8
7
|
|
|
9
8
|
props: {
|
|
10
|
-
fill: String
|
|
9
|
+
fill: String,
|
|
11
10
|
},
|
|
12
11
|
|
|
13
12
|
data: {
|
|
14
13
|
fill: '',
|
|
15
14
|
clsWrapper: 'uk-leader-fill',
|
|
16
15
|
clsHide: 'uk-leader-hide',
|
|
17
|
-
attrFill: 'data-fill'
|
|
16
|
+
attrFill: 'data-fill',
|
|
18
17
|
},
|
|
19
18
|
|
|
20
19
|
computed: {
|
|
21
|
-
|
|
22
|
-
fill({fill}) {
|
|
20
|
+
fill({ fill }) {
|
|
23
21
|
return fill || getCssVar('leader-fill-content');
|
|
24
|
-
}
|
|
25
|
-
|
|
22
|
+
},
|
|
26
23
|
},
|
|
27
24
|
|
|
28
25
|
connected() {
|
|
@@ -34,9 +31,7 @@ export default {
|
|
|
34
31
|
},
|
|
35
32
|
|
|
36
33
|
update: {
|
|
37
|
-
|
|
38
|
-
read({changed, width}) {
|
|
39
|
-
|
|
34
|
+
read({ changed, width }) {
|
|
40
35
|
const prev = width;
|
|
41
36
|
|
|
42
37
|
width = Math.floor(this.$el.offsetWidth / 2);
|
|
@@ -45,23 +40,19 @@ export default {
|
|
|
45
40
|
width,
|
|
46
41
|
fill: this.fill,
|
|
47
42
|
changed: changed || prev !== width,
|
|
48
|
-
hide: !this.matchMedia
|
|
43
|
+
hide: !this.matchMedia,
|
|
49
44
|
};
|
|
50
45
|
},
|
|
51
46
|
|
|
52
47
|
write(data) {
|
|
53
|
-
|
|
54
48
|
toggleClass(this.wrapper, this.clsHide, data.hide);
|
|
55
49
|
|
|
56
50
|
if (data.changed) {
|
|
57
51
|
data.changed = false;
|
|
58
52
|
attr(this.wrapper, this.attrFill, new Array(data.width).join(data.fill));
|
|
59
53
|
}
|
|
60
|
-
|
|
61
54
|
},
|
|
62
55
|
|
|
63
|
-
events: ['resize']
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
56
|
+
events: ['resize'],
|
|
57
|
+
},
|
|
67
58
|
};
|
package/src/js/core/margin.js
CHANGED
|
@@ -1,42 +1,37 @@
|
|
|
1
|
-
import {isRtl, isVisible, offsetPosition, toggleClass} from 'uikit-util';
|
|
1
|
+
import { isRtl, isVisible, offsetPosition, toggleClass } from 'uikit-util';
|
|
2
2
|
|
|
3
3
|
export default {
|
|
4
|
-
|
|
5
4
|
props: {
|
|
6
5
|
margin: String,
|
|
7
|
-
firstColumn: Boolean
|
|
6
|
+
firstColumn: Boolean,
|
|
8
7
|
},
|
|
9
8
|
|
|
10
9
|
data: {
|
|
11
10
|
margin: 'uk-margin-small-top',
|
|
12
|
-
firstColumn: 'uk-first-column'
|
|
11
|
+
firstColumn: 'uk-first-column',
|
|
13
12
|
},
|
|
14
13
|
|
|
15
14
|
update: {
|
|
16
|
-
|
|
17
15
|
read() {
|
|
18
|
-
|
|
19
16
|
const rows = getRows(this.$el.children);
|
|
20
17
|
|
|
21
18
|
return {
|
|
22
19
|
rows,
|
|
23
|
-
columns: getColumns(rows)
|
|
20
|
+
columns: getColumns(rows),
|
|
24
21
|
};
|
|
25
22
|
},
|
|
26
23
|
|
|
27
|
-
write({columns, rows}) {
|
|
28
|
-
for (
|
|
29
|
-
for (
|
|
30
|
-
toggleClass(
|
|
31
|
-
toggleClass(
|
|
24
|
+
write({ columns, rows }) {
|
|
25
|
+
for (const row of rows) {
|
|
26
|
+
for (const column of row) {
|
|
27
|
+
toggleClass(column, this.margin, rows[0] !== row);
|
|
28
|
+
toggleClass(column, this.firstColumn, !!~columns[0].indexOf(column));
|
|
32
29
|
}
|
|
33
30
|
}
|
|
34
31
|
},
|
|
35
32
|
|
|
36
|
-
events: ['resize']
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
33
|
+
events: ['resize'],
|
|
34
|
+
},
|
|
40
35
|
};
|
|
41
36
|
|
|
42
37
|
export function getRows(items) {
|
|
@@ -44,38 +39,30 @@ export function getRows(items) {
|
|
|
44
39
|
}
|
|
45
40
|
|
|
46
41
|
function getColumns(rows) {
|
|
47
|
-
|
|
48
42
|
const columns = [];
|
|
49
43
|
|
|
50
|
-
for (
|
|
51
|
-
const sorted = sortBy(
|
|
44
|
+
for (const row of rows) {
|
|
45
|
+
const sorted = sortBy(row, 'left', 'right');
|
|
52
46
|
for (let j = 0; j < sorted.length; j++) {
|
|
53
|
-
columns[j] =
|
|
47
|
+
columns[j] = columns[j] ? columns[j].concat(sorted[j]) : sorted[j];
|
|
54
48
|
}
|
|
55
49
|
}
|
|
56
50
|
|
|
57
|
-
return isRtl
|
|
58
|
-
? columns.reverse()
|
|
59
|
-
: columns;
|
|
51
|
+
return isRtl ? columns.reverse() : columns;
|
|
60
52
|
}
|
|
61
53
|
|
|
62
54
|
function sortBy(items, startProp, endProp) {
|
|
63
|
-
|
|
64
55
|
const sorted = [[]];
|
|
65
56
|
|
|
66
|
-
for (
|
|
67
|
-
|
|
68
|
-
const el = items[i];
|
|
69
|
-
|
|
57
|
+
for (const el of items) {
|
|
70
58
|
if (!isVisible(el)) {
|
|
71
59
|
continue;
|
|
72
60
|
}
|
|
73
61
|
|
|
74
62
|
let dim = getOffset(el);
|
|
75
63
|
|
|
76
|
-
for (let
|
|
77
|
-
|
|
78
|
-
const current = sorted[j];
|
|
64
|
+
for (let i = sorted.length - 1; i >= 0; i--) {
|
|
65
|
+
const current = sorted[i];
|
|
79
66
|
|
|
80
67
|
if (!current[0]) {
|
|
81
68
|
current.push(el);
|
|
@@ -100,21 +87,18 @@ function sortBy(items, startProp, endProp) {
|
|
|
100
87
|
break;
|
|
101
88
|
}
|
|
102
89
|
|
|
103
|
-
if (
|
|
90
|
+
if (i === 0) {
|
|
104
91
|
sorted.unshift([el]);
|
|
105
92
|
break;
|
|
106
93
|
}
|
|
107
|
-
|
|
108
94
|
}
|
|
109
|
-
|
|
110
95
|
}
|
|
111
96
|
|
|
112
97
|
return sorted;
|
|
113
98
|
}
|
|
114
99
|
|
|
115
100
|
function getOffset(element, offset = false) {
|
|
116
|
-
|
|
117
|
-
let {offsetTop, offsetLeft, offsetHeight, offsetWidth} = element;
|
|
101
|
+
let { offsetTop, offsetLeft, offsetHeight, offsetWidth } = element;
|
|
118
102
|
|
|
119
103
|
if (offset) {
|
|
120
104
|
[offsetTop, offsetLeft] = offsetPosition(element);
|
|
@@ -124,6 +108,6 @@ function getOffset(element, offset = false) {
|
|
|
124
108
|
top: offsetTop,
|
|
125
109
|
left: offsetLeft,
|
|
126
110
|
bottom: offsetTop + offsetHeight,
|
|
127
|
-
right: offsetLeft + offsetWidth
|
|
111
|
+
right: offsetLeft + offsetWidth,
|
|
128
112
|
};
|
|
129
113
|
}
|