@frankenstyle/uikit 0.0.1 → 0.0.3
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/.prettierignore +0 -1
- package/CHANGELOG.md +62 -0
- package/README.md +0 -1
- package/build/publishDev.js +2 -3
- package/build/release.js +12 -7
- package/build/util.js +6 -6
- package/dist/css/uikit-rtl.css +105 -92
- package/dist/css/uikit-rtl.min.css +1 -1
- package/dist/css/uikit.css +105 -92
- package/dist/css/uikit.min.css +1 -1
- package/dist/js/components/countdown.js +1 -1
- package/dist/js/components/countdown.min.js +1 -1
- package/dist/js/components/filter.js +1 -1
- package/dist/js/components/filter.min.js +1 -1
- package/dist/js/components/lightbox-panel.js +35 -30
- package/dist/js/components/lightbox-panel.min.js +1 -1
- package/dist/js/components/lightbox.js +35 -30
- package/dist/js/components/lightbox.min.js +1 -1
- package/dist/js/components/notification.js +2 -2
- package/dist/js/components/notification.min.js +1 -1
- package/dist/js/components/parallax.js +1 -7
- package/dist/js/components/parallax.min.js +1 -1
- package/dist/js/components/slider-parallax.js +1 -7
- package/dist/js/components/slider-parallax.min.js +1 -1
- package/dist/js/components/slider.js +41 -42
- package/dist/js/components/slider.min.js +1 -1
- package/dist/js/components/slideshow-parallax.js +1 -7
- package/dist/js/components/slideshow-parallax.min.js +1 -1
- package/dist/js/components/slideshow.js +34 -35
- package/dist/js/components/slideshow.min.js +1 -1
- package/dist/js/components/sortable.js +5 -6
- package/dist/js/components/sortable.min.js +1 -1
- package/dist/js/components/tooltip.js +2 -2
- package/dist/js/components/tooltip.min.js +1 -1
- package/dist/js/components/upload.js +1 -1
- package/dist/js/components/upload.min.js +1 -1
- package/dist/js/uikit-core.js +123 -70
- package/dist/js/uikit-core.min.js +1 -1
- package/dist/js/uikit-icons.js +1 -1
- package/dist/js/uikit-icons.min.js +1 -1
- package/dist/js/uikit.js +131 -74
- package/dist/js/uikit.min.js +1 -1
- package/package.json +23 -24
- package/src/images/components/accordion-icon.svg +20 -0
- package/src/js/components/internal/slider-transitioner.js +1 -1
- package/src/js/components/slider.js +6 -7
- package/src/js/components/sortable.js +5 -6
- package/src/js/core/accordion.js +14 -10
- package/src/js/core/drop.js +8 -1
- package/src/js/core/height-viewport.js +12 -1
- package/src/js/core/icon.js +4 -2
- package/src/js/core/index.js +1 -0
- package/src/js/core/modal.js +5 -5
- package/src/js/core/overflow-fade.js +83 -8
- package/src/js/mixin/slider-drag.js +21 -14
- package/src/js/mixin/slider-nav.js +16 -18
- package/src/js/util/attr.js +1 -5
- package/src/less/components/accordion.less +110 -46
- package/src/less/components/card.less +1 -1
- package/src/less/components/form.less +10 -7
- package/src/less/components/lightbox.less +0 -5
- package/src/less/components/nav.less +1 -1
- package/src/less/components/overlay.less +2 -2
- package/src/less/components/utility.less +7 -4
- package/src/less/theme/accordion.less +31 -38
- package/src/scss/components/accordion.scss +77 -30
- package/src/scss/components/form.scss +4 -4
- package/src/scss/components/lightbox.scss +0 -5
- package/src/scss/components/nav.scss +1 -1
- package/src/scss/components/utility.scss +7 -4
- package/src/scss/mixins-theme.scss +39 -23
- package/src/scss/mixins.scss +38 -15
- package/src/scss/variables-theme.scss +20 -18
- package/src/scss/variables.scss +18 -14
- package/tests/accordion.html +76 -17
- package/tests/card.html +87 -1
- package/tests/height-viewport.html +12 -3
- package/tests/index.html +7 -7
- package/tests/navbar.html +1 -1
- package/tests/overlay.html +181 -13
- package/tests/parallax.html +1 -1
- package/tests/position.html +16 -16
- package/tests/sticky.html +2 -2
- package/tests/tab.html +1 -1
- package/tests/thumbnav.html +2 -2
- package/tests/toggle.html +2 -2
- package/tests/transition.html +19 -19
- package/tests/upload.html +2 -2
- package/src/images/backgrounds/accordion-close.svg +0 -4
- package/src/images/backgrounds/accordion-open.svg +0 -3
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@frankenstyle/uikit",
|
|
3
3
|
"title": "UIkit",
|
|
4
4
|
"description": "UIkit is a lightweight and modular front-end framework for developing fast and powerful web interfaces.",
|
|
5
|
-
"version": "0.0.
|
|
5
|
+
"version": "0.0.3",
|
|
6
6
|
"main": "dist/js/uikit.js",
|
|
7
7
|
"style": "dist/css/uikit.css",
|
|
8
8
|
"sideEffects": [
|
|
@@ -31,35 +31,34 @@
|
|
|
31
31
|
"url": "https://github.com/uikit/uikit/issues"
|
|
32
32
|
},
|
|
33
33
|
"homepage": "https://getuikit.com",
|
|
34
|
-
"packageManager": "pnpm@10.
|
|
34
|
+
"packageManager": "pnpm@10.27.0",
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@eslint/js": "^9.
|
|
37
|
-
"@rollup/plugin-alias": "^
|
|
38
|
-
"@rollup/plugin-replace": "^6.0.
|
|
36
|
+
"@eslint/js": "^9.39.2",
|
|
37
|
+
"@rollup/plugin-alias": "^6.0.0",
|
|
38
|
+
"@rollup/plugin-replace": "^6.0.3",
|
|
39
39
|
"archiver": "^7.0.1",
|
|
40
|
-
"camelcase": "^
|
|
40
|
+
"camelcase": "^9.0.0",
|
|
41
41
|
"chokidar-cli": "^3.0.0",
|
|
42
42
|
"clean-css": "^5.3.3",
|
|
43
|
-
"
|
|
44
|
-
"esbuild": "^0.
|
|
45
|
-
"eslint": "^9.
|
|
46
|
-
"eslint-config-prettier": "^10.
|
|
47
|
-
"execa": "^9.
|
|
48
|
-
"fs-extra": "^11.3.
|
|
49
|
-
"glob": "^
|
|
50
|
-
"globals": "^
|
|
51
|
-
"inquirer": "^
|
|
52
|
-
"less": "^4.
|
|
43
|
+
"date-fns": "^4.1.0",
|
|
44
|
+
"esbuild": "^0.27.2",
|
|
45
|
+
"eslint": "^9.39.2",
|
|
46
|
+
"eslint-config-prettier": "^10.1.8",
|
|
47
|
+
"execa": "^9.6.1",
|
|
48
|
+
"fs-extra": "^11.3.2",
|
|
49
|
+
"glob": "^13.0.0",
|
|
50
|
+
"globals": "^17.0.0",
|
|
51
|
+
"inquirer": "^13.1.0",
|
|
52
|
+
"less": "^4.5.1",
|
|
53
53
|
"minimist": "^1.2.8",
|
|
54
54
|
"number-precision": "^1.6.0",
|
|
55
|
-
"p-limit": "^7.
|
|
56
|
-
"prettier": "^3.
|
|
57
|
-
"prettier-plugin-organize-imports": "^4.
|
|
58
|
-
"rollup": "^4.
|
|
59
|
-
"rollup-plugin-esbuild": "^6.
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"semver": "^7.7.1",
|
|
55
|
+
"p-limit": "^7.2.0",
|
|
56
|
+
"prettier": "^3.7.4",
|
|
57
|
+
"prettier-plugin-organize-imports": "^4.3.0",
|
|
58
|
+
"rollup": "^4.53.5",
|
|
59
|
+
"rollup-plugin-esbuild": "^6.2.1",
|
|
60
|
+
"rtlcss": "^4.3.0",
|
|
61
|
+
"semver": "^7.7.3",
|
|
63
62
|
"strip-css-comments": "^5.0.0",
|
|
64
63
|
"svgo": "^4.0.0"
|
|
65
64
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 13 13">
|
|
2
|
+
<style>
|
|
3
|
+
|
|
4
|
+
.uk-accordion-icon svg > [class*='line-'] {
|
|
5
|
+
transition: 0.2s ease-out;
|
|
6
|
+
transition-property: transform, opacity;
|
|
7
|
+
transform-origin: center;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
[aria-expanded="true"] .uk-accordion-icon svg > .line-1 {
|
|
11
|
+
transform: rotate(-45deg);
|
|
12
|
+
opacity: 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
[aria-expanded="true"] .uk-accordion-icon svg > .line-2 { transform: rotate(90deg); }
|
|
16
|
+
|
|
17
|
+
</style>
|
|
18
|
+
<rect class="line-1" fill="#000" width="13" height="1" x="0" y="6" />
|
|
19
|
+
<rect class="line-2" fill="#000" width="1" height="13" x="6" y="0" />
|
|
20
|
+
</svg>
|
|
@@ -160,7 +160,7 @@ export function getWidth(list, index) {
|
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
function centerEl(el, list) {
|
|
163
|
-
return dimensions(list).width
|
|
163
|
+
return (dimensions(list).width - dimensions(el).width) / 2;
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
function getElLeft(el, list) {
|
|
@@ -98,7 +98,7 @@ export default {
|
|
|
98
98
|
width / 2
|
|
99
99
|
) {
|
|
100
100
|
sets.push(i);
|
|
101
|
-
left = width
|
|
101
|
+
left = (width - slideWidth) / 2;
|
|
102
102
|
}
|
|
103
103
|
} else if (left === 0) {
|
|
104
104
|
sets.push(Math.min(i, this.maxIndex));
|
|
@@ -228,7 +228,7 @@ export default {
|
|
|
228
228
|
}
|
|
229
229
|
|
|
230
230
|
const next = this.slides[index];
|
|
231
|
-
let width = dimensions(this.list).width
|
|
231
|
+
let width = (dimensions(this.list).width - dimensions(next).width) / 2;
|
|
232
232
|
let j = 0;
|
|
233
233
|
|
|
234
234
|
while (width > 0) {
|
|
@@ -290,7 +290,7 @@ export default {
|
|
|
290
290
|
const left = -width;
|
|
291
291
|
const right = width * 2;
|
|
292
292
|
const slideWidth = dimensions(this.slides[this.index]).width;
|
|
293
|
-
const slideLeft = this.center ? width
|
|
293
|
+
const slideLeft = this.center ? (width - slideWidth) / 2 : 0;
|
|
294
294
|
const slides = new Set();
|
|
295
295
|
for (const i of [-1, 1]) {
|
|
296
296
|
let currentLeft = slideLeft + (i > 0 ? slideWidth : 0);
|
|
@@ -308,7 +308,7 @@ export default {
|
|
|
308
308
|
let index = -1;
|
|
309
309
|
const scrollDist = this.center
|
|
310
310
|
? getWidth(this.list) -
|
|
311
|
-
(dimensions(this.slides[0]).width
|
|
311
|
+
(dimensions(this.slides[0]).width + dimensions(last(this.slides)).width) / 2
|
|
312
312
|
: getWidth(this.list, this.maxIndex);
|
|
313
313
|
|
|
314
314
|
let dist = percent * scrollDist;
|
|
@@ -317,7 +317,7 @@ export default {
|
|
|
317
317
|
do {
|
|
318
318
|
const slideWidth = dimensions(this.slides[++index]).width;
|
|
319
319
|
const slideDist = this.center
|
|
320
|
-
? slideWidth
|
|
320
|
+
? (slideWidth + dimensions(this.slides[index + 1]).width) / 2
|
|
321
321
|
: slideWidth;
|
|
322
322
|
slidePercent = (dist / slideDist) % 1;
|
|
323
323
|
dist -= slideDist;
|
|
@@ -363,8 +363,7 @@ function isFinite(list, center) {
|
|
|
363
363
|
}
|
|
364
364
|
diff = Math.max(
|
|
365
365
|
diff,
|
|
366
|
-
slideWidth / 2
|
|
367
|
-
dimensions(slides[getIndex(+index + i, slides)]).width / 2 -
|
|
366
|
+
(slideWidth + dimensions(slides[getIndex(+index + i, slides)]).width) / 2 -
|
|
368
367
|
(left - listHalf),
|
|
369
368
|
);
|
|
370
369
|
}
|
|
@@ -142,8 +142,7 @@ export default {
|
|
|
142
142
|
sortable.target,
|
|
143
143
|
target,
|
|
144
144
|
placeholder,
|
|
145
|
-
x,
|
|
146
|
-
y,
|
|
145
|
+
{ x, y },
|
|
147
146
|
sortable === previous && data.moved !== target,
|
|
148
147
|
);
|
|
149
148
|
|
|
@@ -365,7 +364,7 @@ function findTarget(items, point) {
|
|
|
365
364
|
return items[findIndex(items, (item) => pointInRect(point, dimensions(item)))];
|
|
366
365
|
}
|
|
367
366
|
|
|
368
|
-
function findInsertTarget(list, target, placeholder,
|
|
367
|
+
function findInsertTarget(list, target, placeholder, point, sameList) {
|
|
369
368
|
if (!children(list).length) {
|
|
370
369
|
return;
|
|
371
370
|
}
|
|
@@ -373,7 +372,7 @@ function findInsertTarget(list, target, placeholder, x, y, sameList) {
|
|
|
373
372
|
const rect = dimensions(target);
|
|
374
373
|
if (!sameList) {
|
|
375
374
|
if (!isHorizontal(list, placeholder)) {
|
|
376
|
-
return y < rect.top + rect.height / 2 ? target : target.nextElementSibling;
|
|
375
|
+
return point.y < rect.top + rect.height / 2 ? target : target.nextElementSibling;
|
|
377
376
|
}
|
|
378
377
|
|
|
379
378
|
return target;
|
|
@@ -386,8 +385,8 @@ function findInsertTarget(list, target, placeholder, x, y, sameList) {
|
|
|
386
385
|
);
|
|
387
386
|
|
|
388
387
|
const [pointerPos, lengthProp, startProp, endProp] = sameRow
|
|
389
|
-
? [x, 'width', 'left', 'right']
|
|
390
|
-
: [y, 'height', 'top', 'bottom'];
|
|
388
|
+
? [point.x, 'width', 'left', 'right']
|
|
389
|
+
: [point.y, 'height', 'top', 'bottom'];
|
|
391
390
|
|
|
392
391
|
const diff =
|
|
393
392
|
placeholderRect[lengthProp] < rect[lengthProp]
|
package/src/js/core/accordion.js
CHANGED
|
@@ -47,8 +47,8 @@ export default {
|
|
|
47
47
|
collapsible: true,
|
|
48
48
|
multiple: false,
|
|
49
49
|
clsOpen: 'uk-open',
|
|
50
|
-
toggle: '
|
|
51
|
-
content: '
|
|
50
|
+
toggle: '.uk-accordion-title',
|
|
51
|
+
content: '.uk-accordion-content',
|
|
52
52
|
offset: 0,
|
|
53
53
|
},
|
|
54
54
|
|
|
@@ -104,21 +104,25 @@ export default {
|
|
|
104
104
|
|
|
105
105
|
delegate: ({ targets, $props }) => `${targets} ${$props.toggle}`,
|
|
106
106
|
|
|
107
|
-
|
|
107
|
+
handler(e) {
|
|
108
108
|
if (e.type === 'keydown' && e.keyCode !== keyMap.SPACE) {
|
|
109
109
|
return;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
+
const item = index(this.toggles, e.current);
|
|
113
|
+
|
|
114
|
+
if (item === -1) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
|
|
112
118
|
maybeDefaultPreventClick(e);
|
|
113
119
|
|
|
114
|
-
|
|
115
|
-
this.
|
|
116
|
-
await this.toggle(index(this.toggles, e.current));
|
|
117
|
-
this._off();
|
|
120
|
+
const off = keepScrollPosition(e.target);
|
|
121
|
+
this.toggle(item).finally(off);
|
|
118
122
|
},
|
|
119
123
|
},
|
|
120
124
|
{
|
|
121
|
-
name: 'shown hidden',
|
|
125
|
+
name: 'show hide shown hidden',
|
|
122
126
|
|
|
123
127
|
self: true,
|
|
124
128
|
|
|
@@ -170,7 +174,7 @@ export default {
|
|
|
170
174
|
}
|
|
171
175
|
|
|
172
176
|
if (!this.collapsible && activeItems.length < 2 && includes(activeItems, item)) {
|
|
173
|
-
|
|
177
|
+
items = [];
|
|
174
178
|
}
|
|
175
179
|
|
|
176
180
|
return Promise.all(
|
|
@@ -214,7 +218,7 @@ async function transition(el, show, { content, duration, velocity, transition })
|
|
|
214
218
|
dimensions(content).height;
|
|
215
219
|
|
|
216
220
|
const percent = currentHeight / endHeight;
|
|
217
|
-
duration = (velocity * endHeight + duration) * (show ? 1 - percent : percent);
|
|
221
|
+
duration = endHeight ? (velocity * endHeight + duration) * (show ? 1 - percent : percent) : 0;
|
|
218
222
|
css(wrapper, 'height', currentHeight);
|
|
219
223
|
|
|
220
224
|
await Transition.start(wrapper, { height: show ? endHeight : 0 }, duration, transition);
|
package/src/js/core/drop.js
CHANGED
|
@@ -338,6 +338,9 @@ export default {
|
|
|
338
338
|
append(this.container, this.$el);
|
|
339
339
|
}
|
|
340
340
|
|
|
341
|
+
// Mark enter early so isToggled() detects show when using delayShow
|
|
342
|
+
addClass(this.$el, this.clsEnter);
|
|
343
|
+
|
|
341
344
|
this.showTimer = setTimeout(
|
|
342
345
|
() => this.toggleElement(this.$el, true),
|
|
343
346
|
(delay && this.delayShow) || 0,
|
|
@@ -345,7 +348,11 @@ export default {
|
|
|
345
348
|
},
|
|
346
349
|
|
|
347
350
|
hide(delay = true, animate = true) {
|
|
348
|
-
const hide = () =>
|
|
351
|
+
const hide = () => {
|
|
352
|
+
// Ensure enter class is removed if show is canceled early
|
|
353
|
+
removeClass(this.$el, this.clsEnter);
|
|
354
|
+
this.toggleElement(this.$el, false, this.animateOut && animate);
|
|
355
|
+
};
|
|
349
356
|
|
|
350
357
|
this.clearTimers();
|
|
351
358
|
|
|
@@ -14,8 +14,11 @@ import {
|
|
|
14
14
|
toFloat,
|
|
15
15
|
} from 'uikit-util';
|
|
16
16
|
import { resize, viewport } from '../api/observables';
|
|
17
|
+
import Media from '../mixin/media';
|
|
17
18
|
|
|
18
19
|
export default {
|
|
20
|
+
mixins: [Media],
|
|
21
|
+
|
|
19
22
|
props: {
|
|
20
23
|
expand: Boolean,
|
|
21
24
|
offsetTop: Boolean,
|
|
@@ -44,6 +47,10 @@ export default {
|
|
|
44
47
|
return false;
|
|
45
48
|
}
|
|
46
49
|
|
|
50
|
+
if (!this.matchMedia) {
|
|
51
|
+
return { minHeight: false };
|
|
52
|
+
}
|
|
53
|
+
|
|
47
54
|
let minHeight = '';
|
|
48
55
|
const box = boxModelAdjust(this.$el, 'height', 'content-box');
|
|
49
56
|
|
|
@@ -90,7 +97,11 @@ export default {
|
|
|
90
97
|
},
|
|
91
98
|
|
|
92
99
|
write({ minHeight }) {
|
|
93
|
-
css(
|
|
100
|
+
css(
|
|
101
|
+
this.$el,
|
|
102
|
+
this.property,
|
|
103
|
+
minHeight === false ? '' : `max(${this.min || 0}px, ${minHeight})`,
|
|
104
|
+
);
|
|
94
105
|
},
|
|
95
106
|
|
|
96
107
|
events: ['resize'],
|
package/src/js/core/icon.js
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
isTag,
|
|
14
14
|
swap,
|
|
15
15
|
} from 'uikit-util';
|
|
16
|
+
import accordionIcon from '../../images/components/accordion-icon.svg';
|
|
16
17
|
import closeIcon from '../../images/components/close-icon.svg';
|
|
17
18
|
import closeLarge from '../../images/components/close-large.svg';
|
|
18
19
|
import dropParentIcon from '../../images/components/drop-parent-icon.svg';
|
|
@@ -31,15 +32,16 @@ import slidenavNextLarge from '../../images/components/slidenav-next-large.svg';
|
|
|
31
32
|
import slidenavNext from '../../images/components/slidenav-next.svg';
|
|
32
33
|
import slidenavPreviousLarge from '../../images/components/slidenav-previous-large.svg';
|
|
33
34
|
import slidenavPrevious from '../../images/components/slidenav-previous.svg';
|
|
34
|
-
import spinner from '../../images/components/spinner.svg';
|
|
35
35
|
import totop from '../../images/components/totop.svg';
|
|
36
36
|
import I18n from '../mixin/i18n';
|
|
37
37
|
import Svg, { parseSVG } from '../mixin/svg';
|
|
38
38
|
|
|
39
39
|
const icons = {
|
|
40
|
-
spinner
|
|
40
|
+
spinner:
|
|
41
|
+
'<svg width="30" height="30" viewBox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"><circle fill="none" stroke="#000" cx="15" cy="15" r="14" /></svg>',
|
|
41
42
|
totop,
|
|
42
43
|
marker,
|
|
44
|
+
'accordion-icon': accordionIcon,
|
|
43
45
|
'close-icon': closeIcon,
|
|
44
46
|
'close-large': closeLarge,
|
|
45
47
|
'drop-parent-icon': dropParentIcon,
|
package/src/js/core/index.js
CHANGED
package/src/js/core/modal.js
CHANGED
|
@@ -96,7 +96,7 @@ function install({ modal }) {
|
|
|
96
96
|
isString(message) ? message : html(message)
|
|
97
97
|
}</div>
|
|
98
98
|
<div class="uk-modal-footer uk-text-right">
|
|
99
|
-
<button class="uk-
|
|
99
|
+
<button class="uk-button uk-button-primary uk-modal-close" type="button" autofocus>${
|
|
100
100
|
i18n.ok
|
|
101
101
|
}</button>
|
|
102
102
|
</div>`,
|
|
@@ -109,10 +109,10 @@ function install({ modal }) {
|
|
|
109
109
|
({ i18n }) => `<form>
|
|
110
110
|
<div class="uk-modal-body">${isString(message) ? message : html(message)}</div>
|
|
111
111
|
<div class="uk-modal-footer uk-text-right">
|
|
112
|
-
<button class="uk-
|
|
112
|
+
<button class="uk-button uk-button-default uk-modal-close" type="button">${
|
|
113
113
|
i18n.cancel
|
|
114
114
|
}</button>
|
|
115
|
-
<button class="uk-
|
|
115
|
+
<button class="uk-button uk-button-primary" autofocus>${i18n.ok}</button>
|
|
116
116
|
</div>
|
|
117
117
|
</form>`,
|
|
118
118
|
options,
|
|
@@ -128,10 +128,10 @@ function install({ modal }) {
|
|
|
128
128
|
<input class="uk-input" autofocus>
|
|
129
129
|
</div>
|
|
130
130
|
<div class="uk-modal-footer uk-text-right">
|
|
131
|
-
<button class="uk-
|
|
131
|
+
<button class="uk-button uk-button-default uk-modal-close" type="button">${
|
|
132
132
|
i18n.cancel
|
|
133
133
|
}</button>
|
|
134
|
-
<button class="uk-
|
|
134
|
+
<button class="uk-button uk-button-primary">${i18n.ok}</button>
|
|
135
135
|
</div>
|
|
136
136
|
</form>`,
|
|
137
137
|
options,
|
|
@@ -1,22 +1,45 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
children,
|
|
3
|
+
clamp,
|
|
4
|
+
css,
|
|
5
|
+
getEventPos,
|
|
6
|
+
hasClass,
|
|
7
|
+
isInput,
|
|
8
|
+
isTouch,
|
|
9
|
+
on,
|
|
10
|
+
pointerCancel,
|
|
11
|
+
pointerDown,
|
|
12
|
+
pointerMove,
|
|
13
|
+
pointerUp,
|
|
14
|
+
selInput,
|
|
15
|
+
toggleClass,
|
|
16
|
+
} from 'uikit-util';
|
|
2
17
|
import { mutation, resize } from '../api/observables';
|
|
3
18
|
|
|
4
19
|
export default {
|
|
5
20
|
data: {
|
|
21
|
+
threshold: 5,
|
|
6
22
|
fadeDuration: 0.05,
|
|
7
23
|
},
|
|
8
24
|
|
|
9
|
-
events:
|
|
10
|
-
|
|
25
|
+
events: [
|
|
26
|
+
{
|
|
27
|
+
name: 'scroll',
|
|
11
28
|
|
|
12
|
-
|
|
29
|
+
self: true,
|
|
13
30
|
|
|
14
|
-
|
|
31
|
+
passive: true,
|
|
15
32
|
|
|
16
|
-
|
|
17
|
-
|
|
33
|
+
handler() {
|
|
34
|
+
this.$emit();
|
|
35
|
+
},
|
|
18
36
|
},
|
|
19
|
-
|
|
37
|
+
{
|
|
38
|
+
name: pointerDown,
|
|
39
|
+
|
|
40
|
+
handler: handleMouseDrag,
|
|
41
|
+
},
|
|
42
|
+
],
|
|
20
43
|
|
|
21
44
|
observe: [
|
|
22
45
|
mutation({
|
|
@@ -65,3 +88,55 @@ export default {
|
|
|
65
88
|
events: ['resize'],
|
|
66
89
|
},
|
|
67
90
|
};
|
|
91
|
+
|
|
92
|
+
function handleMouseDrag(e) {
|
|
93
|
+
const { target, button, defaultPrevented } = e;
|
|
94
|
+
|
|
95
|
+
if (
|
|
96
|
+
defaultPrevented ||
|
|
97
|
+
button > 0 ||
|
|
98
|
+
isTouch(e) ||
|
|
99
|
+
target.closest(selInput) ||
|
|
100
|
+
isInput(target)
|
|
101
|
+
) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
e.preventDefault();
|
|
106
|
+
|
|
107
|
+
const pointerOptions = { passive: false, capture: true };
|
|
108
|
+
const { $el: el, threshold, $options } = this;
|
|
109
|
+
let started;
|
|
110
|
+
|
|
111
|
+
const off = on(document, pointerMove, move(e), pointerOptions);
|
|
112
|
+
on(document, [pointerUp, pointerCancel], end, { capture: true, once: true });
|
|
113
|
+
|
|
114
|
+
function move(e) {
|
|
115
|
+
let origin = getEventPos(e);
|
|
116
|
+
let pos = origin;
|
|
117
|
+
let lastPos = pos;
|
|
118
|
+
|
|
119
|
+
return function (e) {
|
|
120
|
+
lastPos = pos;
|
|
121
|
+
pos = getEventPos(e);
|
|
122
|
+
|
|
123
|
+
const isVertical = hasClass(el, `${$options.id}-vertical`);
|
|
124
|
+
const prop = isVertical ? 'y' : 'x';
|
|
125
|
+
|
|
126
|
+
started ||= Math.abs(pos[prop] - origin[prop]) > threshold;
|
|
127
|
+
|
|
128
|
+
if (started) {
|
|
129
|
+
const delta = lastPos[prop] - pos[prop];
|
|
130
|
+
el[isVertical ? 'scrollTop' : 'scrollLeft'] += delta;
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function end() {
|
|
136
|
+
off();
|
|
137
|
+
|
|
138
|
+
if (started) {
|
|
139
|
+
setTimeout(on(el, 'click', (e) => e.preventDefault(), pointerOptions));
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
css,
|
|
3
3
|
getEventPos,
|
|
4
4
|
includes,
|
|
5
|
+
isEqual,
|
|
5
6
|
isRtl,
|
|
6
7
|
isTouch,
|
|
7
8
|
noop,
|
|
@@ -13,7 +14,6 @@ import {
|
|
|
13
14
|
} from 'uikit-util';
|
|
14
15
|
|
|
15
16
|
const pointerOptions = { passive: false, capture: true };
|
|
16
|
-
const pointerUpOptions = { passive: true, capture: true };
|
|
17
17
|
const pointerDown = 'touchstart mousedown';
|
|
18
18
|
const pointerMove = 'touchmove mousemove';
|
|
19
19
|
const pointerUp = 'touchend touchcancel mouseup click input scroll';
|
|
@@ -26,15 +26,20 @@ export default {
|
|
|
26
26
|
data: {
|
|
27
27
|
draggable: true,
|
|
28
28
|
threshold: 10,
|
|
29
|
+
angleThreshold: 45,
|
|
29
30
|
},
|
|
30
31
|
|
|
31
32
|
created() {
|
|
32
33
|
for (const key of ['start', 'move', 'end']) {
|
|
33
34
|
const fn = this[key];
|
|
34
35
|
this[key] = (e) => {
|
|
35
|
-
const pos = getEventPos(e)
|
|
36
|
+
const pos = getEventPos(e);
|
|
36
37
|
|
|
37
|
-
|
|
38
|
+
if (isRtl) {
|
|
39
|
+
pos.x = -pos.x;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
this.prevPos = isEqual(pos, this.pos) ? this.prevPos : this.pos;
|
|
38
43
|
this.pos = pos;
|
|
39
44
|
|
|
40
45
|
fn(e);
|
|
@@ -89,7 +94,7 @@ export default {
|
|
|
89
94
|
|
|
90
95
|
if (this._transitioner) {
|
|
91
96
|
this.percent = this._transitioner.percent();
|
|
92
|
-
this.drag += this._transitioner.getDistance() * this.percent * this.dir;
|
|
97
|
+
this.drag.x += this._transitioner.getDistance() * this.percent * this.dir;
|
|
93
98
|
|
|
94
99
|
this._transitioner.cancel();
|
|
95
100
|
this._transitioner.translate(this.percent);
|
|
@@ -104,17 +109,17 @@ export default {
|
|
|
104
109
|
on(document, pointerMove, this.move, pointerOptions);
|
|
105
110
|
|
|
106
111
|
// 'input' event is triggered by video controls
|
|
107
|
-
on(document, pointerUp, this.end,
|
|
112
|
+
on(document, pointerUp, this.end, { passive: true, capture: true, once: true });
|
|
108
113
|
|
|
109
114
|
css(this.list, 'userSelect', 'none');
|
|
110
115
|
},
|
|
111
116
|
|
|
112
117
|
move(e) {
|
|
113
|
-
const distance = this.pos - this.drag;
|
|
114
|
-
|
|
118
|
+
const distance = this.pos.x - this.drag.x;
|
|
115
119
|
if (
|
|
116
120
|
distance === 0 ||
|
|
117
|
-
this.
|
|
121
|
+
(!this.dragging && getAngle(this.pos, this.drag) > this.angleThreshold) ||
|
|
122
|
+
this.prevPos.x === this.pos.x ||
|
|
118
123
|
(!this.dragging && Math.abs(distance) < this.threshold)
|
|
119
124
|
) {
|
|
120
125
|
return;
|
|
@@ -131,7 +136,7 @@ export default {
|
|
|
131
136
|
let width = getDistance.call(this, prevIndex, nextIndex);
|
|
132
137
|
|
|
133
138
|
while (nextIndex !== prevIndex && dis > width) {
|
|
134
|
-
this.drag -= width * this.dir;
|
|
139
|
+
this.drag.x -= width * this.dir;
|
|
135
140
|
|
|
136
141
|
prevIndex = nextIndex;
|
|
137
142
|
dis -= width;
|
|
@@ -181,7 +186,6 @@ export default {
|
|
|
181
186
|
|
|
182
187
|
end() {
|
|
183
188
|
off(document, pointerMove, this.move, pointerOptions);
|
|
184
|
-
off(document, pointerUp, this.end, pointerUpOptions);
|
|
185
189
|
|
|
186
190
|
if (this.dragging) {
|
|
187
191
|
setTimeout(on(this.list, 'click', (e) => e.preventDefault(), pointerOptions));
|
|
@@ -194,15 +198,14 @@ export default {
|
|
|
194
198
|
this._show(false, this.index, true);
|
|
195
199
|
this._transitioner = null;
|
|
196
200
|
} else {
|
|
197
|
-
const dirChange =
|
|
198
|
-
(isRtl ? this.dir * (isRtl ? 1 : -1) : this.dir) < 0 ===
|
|
199
|
-
this.prevPos > this.pos;
|
|
200
|
-
this.index = dirChange ? this.index : this.prevIndex;
|
|
201
|
+
const dirChange = this.dir < 0 === this.prevPos.x > this.pos.x;
|
|
201
202
|
|
|
202
203
|
if (dirChange) {
|
|
203
204
|
trigger(this.slides[this.prevIndex], 'itemhidden', [this]);
|
|
204
205
|
trigger(this.slides[this.index], 'itemshown', [this]);
|
|
205
206
|
this.percent = 1 - this.percent;
|
|
207
|
+
} else {
|
|
208
|
+
this.index = this.prevIndex;
|
|
206
209
|
}
|
|
207
210
|
|
|
208
211
|
this.show(
|
|
@@ -234,3 +237,7 @@ function hasSelectableText(el) {
|
|
|
234
237
|
toArray(el.childNodes).some((el) => el.nodeType === 3 && el.textContent.trim())
|
|
235
238
|
);
|
|
236
239
|
}
|
|
240
|
+
|
|
241
|
+
function getAngle(pos1, pos2) {
|
|
242
|
+
return (Math.atan2(Math.abs(pos2.y - pos1.y), Math.abs(pos2.x - pos1.x)) * 180) / Math.PI;
|
|
243
|
+
}
|
|
@@ -24,7 +24,6 @@ export default {
|
|
|
24
24
|
previous: 'Previous slide',
|
|
25
25
|
slideX: 'Slide %s',
|
|
26
26
|
slideLabel: '%s of %s',
|
|
27
|
-
role: 'String',
|
|
28
27
|
},
|
|
29
28
|
|
|
30
29
|
data: {
|
|
@@ -33,10 +32,10 @@ export default {
|
|
|
33
32
|
},
|
|
34
33
|
|
|
35
34
|
computed: {
|
|
36
|
-
nav: ({ selNav }, $el) =>
|
|
35
|
+
nav: ({ selNav }, $el) => $$(selNav, $el),
|
|
37
36
|
|
|
38
37
|
navChildren() {
|
|
39
|
-
return
|
|
38
|
+
return this.nav.map((nav) => children(nav)).flat();
|
|
40
39
|
},
|
|
41
40
|
|
|
42
41
|
selNavItem: ({ attrItem }) => `[${attrItem}],[data-${attrItem}]`,
|
|
@@ -109,9 +108,9 @@ export default {
|
|
|
109
108
|
slides(slides) {
|
|
110
109
|
slides.forEach((slide, i) =>
|
|
111
110
|
attr(slide, {
|
|
112
|
-
role: this.nav ? 'tabpanel' : 'group',
|
|
111
|
+
role: this.nav.length ? 'tabpanel' : 'group',
|
|
113
112
|
'aria-label': this.t('slideLabel', i + 1, this.length),
|
|
114
|
-
'aria-roledescription': this.nav ? null : 'slide',
|
|
113
|
+
'aria-roledescription': this.nav.length ? null : 'slide',
|
|
115
114
|
}),
|
|
116
115
|
);
|
|
117
116
|
|
|
@@ -229,19 +228,18 @@ export default {
|
|
|
229
228
|
},
|
|
230
229
|
|
|
231
230
|
padNavitems() {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
html(this.nav, children);
|
|
231
|
+
for (const nav of this.nav) {
|
|
232
|
+
const navChildren = children(nav);
|
|
233
|
+
const navItems = [];
|
|
234
|
+
for (let i = 0; i < this.length; i++) {
|
|
235
|
+
const attr = `${this.attrItem}="${i}"`;
|
|
236
|
+
navItems[i] =
|
|
237
|
+
navChildren.findLast((el) => el.matches(`[${attr}]`)) ||
|
|
238
|
+
$(`<li ${attr}><a href></a></li>`);
|
|
239
|
+
}
|
|
240
|
+
if (!isEqual(navItems, navChildren)) {
|
|
241
|
+
html(this.nav, navItems);
|
|
242
|
+
}
|
|
245
243
|
}
|
|
246
244
|
},
|
|
247
245
|
},
|