uikit 3.13.2-dev.13a8eb3ff → 3.13.2-dev.696f00752

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.
Files changed (64) hide show
  1. package/.eslintrc.json +9 -0
  2. package/CHANGELOG.md +11 -0
  3. package/dist/css/uikit-core-rtl.css +15 -63
  4. package/dist/css/uikit-core-rtl.min.css +1 -1
  5. package/dist/css/uikit-core.css +15 -63
  6. package/dist/css/uikit-core.min.css +1 -1
  7. package/dist/css/uikit-rtl.css +15 -63
  8. package/dist/css/uikit-rtl.min.css +1 -1
  9. package/dist/css/uikit.css +15 -63
  10. package/dist/css/uikit.min.css +1 -1
  11. package/dist/js/components/countdown.js +1 -1
  12. package/dist/js/components/countdown.min.js +1 -1
  13. package/dist/js/components/filter.js +1 -1
  14. package/dist/js/components/filter.min.js +1 -1
  15. package/dist/js/components/lightbox-panel.js +1 -1
  16. package/dist/js/components/lightbox-panel.min.js +1 -1
  17. package/dist/js/components/lightbox.js +1 -1
  18. package/dist/js/components/lightbox.min.js +1 -1
  19. package/dist/js/components/notification.js +1 -1
  20. package/dist/js/components/notification.min.js +1 -1
  21. package/dist/js/components/parallax.js +1 -1
  22. package/dist/js/components/parallax.min.js +1 -1
  23. package/dist/js/components/slider-parallax.js +1 -1
  24. package/dist/js/components/slider-parallax.min.js +1 -1
  25. package/dist/js/components/slider.js +1 -1
  26. package/dist/js/components/slider.min.js +1 -1
  27. package/dist/js/components/slideshow-parallax.js +1 -1
  28. package/dist/js/components/slideshow-parallax.min.js +1 -1
  29. package/dist/js/components/slideshow.js +1 -1
  30. package/dist/js/components/slideshow.min.js +1 -1
  31. package/dist/js/components/sortable.js +1 -1
  32. package/dist/js/components/sortable.min.js +1 -1
  33. package/dist/js/components/tooltip.js +60 -31
  34. package/dist/js/components/tooltip.min.js +1 -1
  35. package/dist/js/components/upload.js +1 -1
  36. package/dist/js/components/upload.min.js +1 -1
  37. package/dist/js/uikit-core.js +207 -185
  38. package/dist/js/uikit-core.min.js +1 -1
  39. package/dist/js/uikit-icons.js +1 -1
  40. package/dist/js/uikit-icons.min.js +1 -1
  41. package/dist/js/uikit.js +209 -188
  42. package/dist/js/uikit.min.js +1 -1
  43. package/package.json +1 -1
  44. package/src/js/components/tooltip.js +2 -3
  45. package/src/js/core/drop.js +7 -10
  46. package/src/js/core/navbar.js +10 -5
  47. package/src/js/core/sticky.js +1 -1
  48. package/src/js/mixin/media.js +4 -4
  49. package/src/js/mixin/position.js +53 -24
  50. package/src/js/util/dimensions.js +2 -2
  51. package/src/js/util/position.js +125 -129
  52. package/src/js/util/style.js +13 -19
  53. package/src/less/components/drop.less +3 -11
  54. package/src/less/components/dropdown.less +3 -11
  55. package/src/less/components/navbar.less +11 -12
  56. package/src/less/components/tooltip.less +2 -11
  57. package/src/scss/components/drop.scss +3 -11
  58. package/src/scss/components/dropdown.scss +3 -11
  59. package/src/scss/components/navbar.scss +11 -12
  60. package/src/scss/components/tooltip.scss +2 -11
  61. package/src/scss/variables-theme.scss +5 -4
  62. package/src/scss/variables.scss +5 -4
  63. package/tests/drop.html +1 -1
  64. package/tests/position.html +38 -39
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "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": "3.13.2-dev.13a8eb3ff",
5
+ "version": "3.13.2-dev.696f00752",
6
6
  "main": "dist/js/uikit.js",
7
7
  "style": "dist/css/uikit.css",
8
8
  "sideEffects": [
@@ -35,7 +35,6 @@ export default {
35
35
  animation: ['uk-animation-scale-up'],
36
36
  duration: 100,
37
37
  cls: 'uk-active',
38
- clsPos: 'uk-tooltip',
39
38
  },
40
39
 
41
40
  beforeConnect() {
@@ -91,8 +90,8 @@ export default {
91
90
  _show() {
92
91
  this.tooltip = append(
93
92
  this.container,
94
- `<div class="${this.clsPos}">
95
- <div class="${this.clsPos}-inner">${this.title}</div>
93
+ `<div class="uk-${this.$options.name}">
94
+ <div class="uk-${this.$options.name}-inner">${this.title}</div>
96
95
  </div>`
97
96
  );
98
97
 
@@ -63,7 +63,7 @@ export default {
63
63
  },
64
64
 
65
65
  connected() {
66
- this.clsPos = this.clsDrop = this.$props.clsDrop || `uk-${this.$options.name}`;
66
+ this.clsDrop = this.$props.clsDrop || `uk-${this.$options.name}`;
67
67
  addClass(this.$el, this.clsDrop);
68
68
 
69
69
  if (this.toggle && !this.target) {
@@ -129,7 +129,7 @@ export default {
129
129
  if (this.isToggled()) {
130
130
  this.hide(false);
131
131
  } else {
132
- this.show(toggle.$el, false);
132
+ this.show(toggle?.$el, false);
133
133
  }
134
134
  },
135
135
  },
@@ -141,7 +141,7 @@ export default {
141
141
 
142
142
  handler(e, toggle) {
143
143
  e.preventDefault();
144
- this.show(toggle.$el);
144
+ this.show(toggle?.$el);
145
145
  },
146
146
  },
147
147
 
@@ -352,23 +352,20 @@ export default {
352
352
  },
353
353
 
354
354
  position() {
355
- const boundary = this.boundary === true ? window : query(this.boundary, this.$el);
355
+ const boundary = query(this.boundary, this.$el) || window;
356
356
  removeClass(this.$el, `${this.clsDrop}-stack`);
357
357
  toggleClass(this.$el, `${this.clsDrop}-boundary`, this.boundaryAlign);
358
358
 
359
359
  const boundaryOffset = offset(boundary);
360
- const alignTo = this.boundaryAlign ? boundaryOffset : offset(this.target);
360
+ const targetOffset = offset(this.target);
361
+ const alignTo = this.boundaryAlign ? boundaryOffset : targetOffset;
361
362
 
362
363
  if (this.align === 'justify') {
363
364
  const prop = this.getAxis() === 'y' ? 'width' : 'height';
364
365
  css(this.$el, prop, alignTo[prop]);
365
366
  } else if (
366
- boundary &&
367
367
  this.$el.offsetWidth >
368
- Math.max(
369
- boundaryOffset.right - alignTo.left,
370
- alignTo.right - boundaryOffset.left
371
- )
368
+ Math.max(boundaryOffset.right - alignTo.left, alignTo.right - boundaryOffset.left)
372
369
  ) {
373
370
  addClass(this.$el, `${this.clsDrop}-stack`);
374
371
  }
@@ -16,6 +16,7 @@ import {
16
16
  isVisible,
17
17
  matches,
18
18
  noop,
19
+ offset,
19
20
  once,
20
21
  parent,
21
22
  query,
@@ -274,10 +275,16 @@ export default {
274
275
  return this.dropbar;
275
276
  },
276
277
 
277
- handler() {
278
+ handler(_, { $el }) {
279
+ if (!hasClass($el, this.clsDrop)) {
280
+ return;
281
+ }
282
+
278
283
  if (!parent(this.dropbar)) {
279
284
  after(this.dropbarAnchor || this.$el, this.dropbar);
280
285
  }
286
+
287
+ addClass($el, `${this.clsDrop}-dropbar`);
281
288
  },
282
289
  },
283
290
 
@@ -297,12 +304,10 @@ export default {
297
304
  return;
298
305
  }
299
306
 
300
- this.clsDrop && addClass($el, `${this.clsDrop}-dropbar`);
301
-
302
307
  if (dir === 'bottom') {
303
308
  this.transitionTo(
304
- $el.offsetHeight +
305
- toFloat(css($el, 'marginTop')) +
309
+ offset($el).bottom -
310
+ offset(this.dropbar).top +
306
311
  toFloat(css($el, 'marginBottom')),
307
312
  $el
308
313
  );
@@ -14,6 +14,7 @@ import {
14
14
  height as getHeight,
15
15
  offset as getOffset,
16
16
  getScrollingElement,
17
+ intersectRect,
17
18
  isString,
18
19
  isVisible,
19
20
  noop,
@@ -29,7 +30,6 @@ import {
29
30
  toPx,
30
31
  trigger,
31
32
  within,
32
- intersectRect,
33
33
  } from 'uikit-util';
34
34
 
35
35
  export default {
@@ -1,12 +1,12 @@
1
1
  import {
2
+ createEvent,
2
3
  getCssVar,
4
+ isNumeric,
3
5
  isString,
4
6
  on,
5
- trigger,
6
- toFloat,
7
7
  startsWith,
8
- isNumeric,
9
- createEvent,
8
+ toFloat,
9
+ trigger,
10
10
  } from 'uikit-util';
11
11
 
12
12
  export default {
@@ -1,12 +1,13 @@
1
1
  import {
2
2
  $,
3
3
  flipPosition,
4
+ getCssVar,
4
5
  offset as getOffset,
6
+ includes,
5
7
  isNumeric,
6
8
  isRtl,
7
9
  positionAt,
8
- removeClasses,
9
- toggleClass,
10
+ toPx,
10
11
  } from 'uikit-util';
11
12
 
12
13
  export default {
@@ -14,14 +15,12 @@ export default {
14
15
  pos: String,
15
16
  offset: null,
16
17
  flip: Boolean,
17
- clsPos: String,
18
18
  },
19
19
 
20
20
  data: {
21
21
  pos: `bottom-${isRtl ? 'right' : 'left'}`,
22
22
  flip: true,
23
23
  offset: false,
24
- clsPos: '',
25
24
  },
26
25
 
27
26
  connected() {
@@ -32,13 +31,11 @@ export default {
32
31
 
33
32
  methods: {
34
33
  positionAt(element, target, boundary) {
35
- removeClasses(element, `${this.clsPos}-(top|bottom|left|right)(-[a-z]+)?`);
36
-
37
- let { offset } = this;
38
34
  const axis = this.getAxis();
39
35
  const dir = this.pos[0];
40
36
  const align = this.pos[1];
41
37
 
38
+ let { offset } = this;
42
39
  if (!isNumeric(offset)) {
43
40
  const node = $(offset);
44
41
  offset = node
@@ -46,28 +43,60 @@ export default {
46
43
  getOffset(target)[axis === 'x' ? 'right' : 'bottom']
47
44
  : 0;
48
45
  }
46
+ offset += toPx(getCssVar('position-margin-offset', element));
49
47
 
50
- const { x, y } = positionAt(
51
- element,
52
- target,
53
- axis === 'x' ? `${flipPosition(dir)} ${align}` : `${align} ${flipPosition(dir)}`,
54
- axis === 'x' ? `${dir} ${align}` : `${align} ${dir}`,
55
- axis === 'x'
56
- ? `${dir === 'left' ? -offset : offset}`
57
- : ` ${dir === 'top' ? -offset : offset}`,
58
- null,
59
- this.flip,
60
- boundary
61
- ).target;
62
-
63
- this.dir = axis === 'x' ? x : y;
64
- this.align = axis === 'x' ? y : x;
48
+ positionAt(element, target, {
49
+ boundary,
50
+ flip: this.flip,
51
+ attach: {
52
+ element: axis === 'x' ? [flipPosition(dir), align] : [align, flipPosition(dir)],
53
+ target: axis === 'x' ? [dir, align] : [align, dir],
54
+ },
55
+ offset:
56
+ axis === 'x'
57
+ ? [dir === 'left' ? -offset : +offset, 0]
58
+ : [0, dir === 'top' ? -offset : +offset],
59
+ });
65
60
 
66
- toggleClass(element, `${this.clsPos}-${this.dir}-${this.align}`, this.offset === false);
61
+ [this.dir, this.align] = getAlignment(element, target);
62
+ console.log(this.dir, this.align);
67
63
  },
68
64
 
69
65
  getAxis() {
70
- return this.dir === 'top' || this.dir === 'bottom' ? 'y' : 'x';
66
+ return includes(['top', 'bottom'], this.dir) ? 'y' : 'x';
71
67
  },
72
68
  },
73
69
  };
70
+
71
+ function getAlignment(el, target) {
72
+ const elOffset = getOffset(el);
73
+ const targetOffset = getOffset(target);
74
+ const properties = [
75
+ ['left', 'right'],
76
+ ['top', 'bottom'],
77
+ ];
78
+
79
+ let dir;
80
+ for (const props of properties) {
81
+ if (elOffset[props[0]] > targetOffset[props[1]]) {
82
+ dir = props[1];
83
+ break;
84
+ }
85
+ if (elOffset[props[1]] < targetOffset[props[0]]) {
86
+ dir = props[0];
87
+ break;
88
+ }
89
+ }
90
+
91
+ let align;
92
+ const props = includes(properties[0], dir) ? properties[1] : properties[0];
93
+ if (elOffset[props[0]] === targetOffset[props[0]]) {
94
+ align = props[0];
95
+ } else if (elOffset[props[1]] === targetOffset[props[1]]) {
96
+ align = props[1];
97
+ } else {
98
+ align = 'center';
99
+ }
100
+
101
+ return [dir, align];
102
+ }
@@ -41,8 +41,8 @@ export function offset(element, coordinates) {
41
41
  const offsetBy = { height: scrollY, width: scrollX };
42
42
 
43
43
  for (const dir in dirs) {
44
- for (const i in dirs[dir]) {
45
- currentOffset[dirs[dir][i]] += offsetBy[dir];
44
+ for (const prop of dirs[dir]) {
45
+ currentOffset[prop] += offsetBy[dir];
46
46
  }
47
47
  }
48
48
  }
@@ -1,156 +1,152 @@
1
1
  import { offset } from './dimensions';
2
- import { each, endsWith, includes, toFloat } from './lang';
2
+ import { clamp, includes } from './lang';
3
3
  import { getViewport, scrollParents } from './viewport';
4
4
 
5
- const dirs = {
6
- width: ['x', 'left', 'right'],
7
- height: ['y', 'top', 'bottom'],
8
- };
9
-
10
- export function positionAt(
11
- element,
12
- target,
13
- elAttach,
14
- targetAttach,
15
- elOffset,
16
- targetOffset,
17
- flip,
18
- boundary
19
- ) {
20
- elAttach = getPos(elAttach);
21
- targetAttach = getPos(targetAttach);
22
-
23
- const flipped = { element: elAttach, target: targetAttach };
24
-
25
- if (!element || !target) {
26
- return flipped;
5
+ const dirs = [
6
+ ['width', 'x', 'left', 'right'],
7
+ ['height', 'y', 'top', 'bottom'],
8
+ ];
9
+
10
+ export function positionAt(element, target, options) {
11
+ options = {
12
+ attach: {
13
+ element: ['left', 'top'],
14
+ target: ['left', 'top'],
15
+ ...options.attach,
16
+ },
17
+ offset: [0, 0],
18
+ ...options,
19
+ };
20
+
21
+ const dim = options.flip
22
+ ? attachToWithFlip(element, target, options)
23
+ : attachTo(element, target, options);
24
+
25
+ offset(element, dim);
26
+ }
27
+
28
+ function attachTo(element, target, options) {
29
+ let { attach, offset: offsetBy } = {
30
+ attach: {
31
+ element: ['left', 'top'],
32
+ target: ['left', 'top'],
33
+ ...options.attach,
34
+ },
35
+ offset: [0, 0],
36
+ ...options,
37
+ };
38
+
39
+ const position = offset(element);
40
+ const targetOffset = offset(target);
41
+ for (const i in dirs) {
42
+ const [prop, dir, start, end] = dirs[i];
43
+ position[start] = position[dir] =
44
+ targetOffset[start] +
45
+ moveBy(attach.target[i], end, targetOffset[prop]) -
46
+ moveBy(attach.element[i], end, position[prop]) +
47
+ +offsetBy[i];
48
+ position[end] = position[start] + position[prop];
27
49
  }
50
+ return position;
51
+ }
28
52
 
29
- const dim = offset(element);
53
+ function attachToWithFlip(element, target, options) {
54
+ const position = attachTo(element, target, options);
30
55
  const targetDim = offset(target);
31
- const position = targetDim;
56
+ const viewports = scrollParents(element).map(getViewport);
57
+
58
+ let {
59
+ flip,
60
+ attach: { element: elAttach, target: targetAttach },
61
+ offset: elOffset,
62
+ boundary,
63
+ viewport,
64
+ } = options;
32
65
 
33
- moveTo(position, elAttach, dim, -1);
34
- moveTo(position, targetAttach, targetDim, 1);
66
+ viewports.push(viewport);
35
67
 
36
- elOffset = getOffsets(elOffset, dim.width, dim.height);
37
- targetOffset = getOffsets(targetOffset, targetDim.width, targetDim.height);
68
+ for (const i in dirs) {
69
+ const [prop, dir, start, end] = dirs[i];
38
70
 
39
- elOffset['x'] += targetOffset['x'];
40
- elOffset['y'] += targetOffset['y'];
71
+ if (flip !== true && !includes(flip, dir)) {
72
+ continue;
73
+ }
41
74
 
42
- position.left += elOffset['x'];
43
- position.top += elOffset['y'];
75
+ const willFlip =
76
+ !intersectLine(position, targetDim, i) && intersectLine(position, targetDim, 1 - i);
44
77
 
45
- if (flip) {
46
- let boundaries = scrollParents(element).map(getViewport);
78
+ viewport = getIntersectionArea(...viewports, willFlip ? null : boundary);
79
+ const isInStartBoundary = position[start] >= viewport[start];
80
+ const isInEndBoundary = position[end] <= viewport[end];
47
81
 
48
- if (boundary && !includes(boundaries, boundary)) {
49
- boundaries.unshift(boundary);
82
+ if (isInStartBoundary && isInEndBoundary) {
83
+ continue;
50
84
  }
51
85
 
52
- boundaries = boundaries.map((el) => offset(el));
86
+ let offsetBy;
53
87
 
54
- each(dirs, ([dir, align, alignFlip], prop) => {
55
- if (!(flip === true || includes(flip, dir))) {
56
- return;
88
+ // Flip
89
+ if (willFlip) {
90
+ if (
91
+ (elAttach[i] === end && isInStartBoundary) ||
92
+ (elAttach[i] === start && isInEndBoundary)
93
+ ) {
94
+ continue;
57
95
  }
58
96
 
59
- boundaries.some((boundary) => {
60
- const elemOffset =
61
- elAttach[dir] === align
62
- ? -dim[prop]
63
- : elAttach[dir] === alignFlip
64
- ? dim[prop]
65
- : 0;
66
-
67
- const targetOffset =
68
- targetAttach[dir] === align
69
- ? targetDim[prop]
70
- : targetAttach[dir] === alignFlip
71
- ? -targetDim[prop]
72
- : 0;
73
-
74
- if (
75
- position[align] < boundary[align] ||
76
- position[align] + dim[prop] > boundary[alignFlip]
77
- ) {
78
- const centerOffset = dim[prop] / 2;
79
- const centerTargetOffset =
80
- targetAttach[dir] === 'center' ? -targetDim[prop] / 2 : 0;
81
-
82
- return (
83
- (elAttach[dir] === 'center' &&
84
- (apply(centerOffset, centerTargetOffset) ||
85
- apply(-centerOffset, -centerTargetOffset))) ||
86
- apply(elemOffset, targetOffset)
87
- );
88
- }
89
-
90
- function apply(elemOffset, targetOffset) {
91
- const newVal = toFloat(
92
- (position[align] + elemOffset + targetOffset - elOffset[dir] * 2).toFixed(4)
93
- );
94
-
95
- if (newVal >= boundary[align] && newVal + dim[prop] <= boundary[alignFlip]) {
96
- position[align] = newVal;
97
-
98
- for (const el of ['element', 'target']) {
99
- if (elemOffset) {
100
- flipped[el][dir] =
101
- flipped[el][dir] === dirs[prop][1]
102
- ? dirs[prop][2]
103
- : dirs[prop][1];
104
- }
105
- }
106
-
107
- return true;
108
- }
109
- }
110
- });
111
- });
112
- }
97
+ offsetBy =
98
+ (elAttach[i] === start
99
+ ? -position[prop]
100
+ : elAttach[i] === end
101
+ ? position[prop]
102
+ : 0) +
103
+ (targetAttach[i] === start
104
+ ? targetDim[prop]
105
+ : targetAttach[i] === end
106
+ ? -targetDim[prop]
107
+ : 0) -
108
+ elOffset[i] * 2;
109
+
110
+ // Move
111
+ } else {
112
+ offsetBy =
113
+ clamp(
114
+ clamp(position[start], viewport[start], viewport[end] - position[prop]),
115
+ targetDim[start] - position[prop] + elOffset[i],
116
+ targetDim[end] - elOffset[i]
117
+ ) - position[start];
118
+ }
113
119
 
114
- offset(element, position);
120
+ position[start] = position[dir] = position[start] + offsetBy;
121
+ position[end] += offsetBy;
122
+ }
115
123
 
116
- return flipped;
124
+ return position;
117
125
  }
118
126
 
119
- function moveTo(position, attach, dim, factor) {
120
- each(dirs, ([dir, align, alignFlip], prop) => {
121
- if (attach[dir] === alignFlip) {
122
- position[align] += dim[prop] * factor;
123
- } else if (attach[dir] === 'center') {
124
- position[align] += (dim[prop] * factor) / 2;
125
- }
126
- });
127
+ function moveBy(start, end, dim) {
128
+ return start === 'center' ? dim / 2 : start === end ? dim : 0;
127
129
  }
128
130
 
129
- function getPos(pos) {
130
- const x = /left|center|right/;
131
- const y = /top|center|bottom/;
132
-
133
- pos = (pos || '').split(' ');
134
-
135
- if (pos.length === 1) {
136
- pos = x.test(pos[0])
137
- ? pos.concat('center')
138
- : y.test(pos[0])
139
- ? ['center'].concat(pos)
140
- : ['center', 'center'];
131
+ function getIntersectionArea(...elements) {
132
+ let intersection;
133
+ for (const el of elements.filter(Boolean)) {
134
+ const rect = offset(el);
135
+ if (!intersection) {
136
+ intersection = rect;
137
+ continue;
138
+ }
139
+ for (const prop of ['left', 'top']) {
140
+ intersection[prop] = Math.max(rect[prop], intersection[prop]);
141
+ }
142
+ for (const prop of ['right', 'bottom']) {
143
+ intersection[prop] = Math.min(rect[prop], intersection[prop]);
144
+ }
141
145
  }
142
-
143
- return {
144
- x: x.test(pos[0]) ? pos[0] : 'center',
145
- y: y.test(pos[1]) ? pos[1] : 'center',
146
- };
146
+ return intersection;
147
147
  }
148
148
 
149
- function getOffsets(offsets, width, height) {
150
- const [x, y] = (offsets || '').split(' ');
151
-
152
- return {
153
- x: x ? toFloat(x) * (endsWith(x, '%') ? width / 100 : 1) : 0,
154
- y: y ? toFloat(y) * (endsWith(y, '%') ? height / 100 : 1) : 0,
155
- };
149
+ function intersectLine(dimA, dimB, dir) {
150
+ const [, , start, end] = dirs[dir];
151
+ return dimA[end] > dimB[start] && dimB[end] > dimA[start];
156
152
  }
@@ -9,7 +9,6 @@ import {
9
9
  isUndefined,
10
10
  memoize,
11
11
  toNodes,
12
- toWindow,
13
12
  } from './lang';
14
13
 
15
14
  const cssNumber = {
@@ -37,21 +36,22 @@ export function css(element, property, value, priority = '') {
37
36
  property = propName(property);
38
37
 
39
38
  if (isUndefined(value)) {
40
- return getStyle(element, property);
41
- } else if (!value && !isNumber(value)) {
42
- element.style.removeProperty(property);
39
+ return getComputedStyle(element).getPropertyValue(property);
43
40
  } else {
44
41
  element.style.setProperty(
45
42
  property,
46
- isNumeric(value) && !cssNumber[property] ? `${value}px` : value,
43
+ isNumeric(value) && !cssNumber[property]
44
+ ? `${value}px`
45
+ : value || isNumber(value)
46
+ ? value
47
+ : '',
47
48
  priority
48
49
  );
49
50
  }
50
51
  } else if (isArray(property)) {
51
- const styles = getStyles(element);
52
52
  const props = {};
53
53
  for (const prop of property) {
54
- props[prop] = styles[propName(prop)];
54
+ props[prop] = css(element, prop);
55
55
  }
56
56
  return props;
57
57
  } else if (isObject(property)) {
@@ -62,19 +62,9 @@ export function css(element, property, value, priority = '') {
62
62
  return elements[0];
63
63
  }
64
64
 
65
- function getStyles(element, pseudoElt) {
66
- return toWindow(element).getComputedStyle(element, pseudoElt);
67
- }
68
-
69
- function getStyle(element, property, pseudoElt) {
70
- return getStyles(element, pseudoElt)[property];
71
- }
72
-
73
65
  const propertyRe = /^\s*(["'])?(.*?)\1\s*$/;
74
- export function getCssVar(name) {
75
- return getStyles(document.documentElement)
76
- .getPropertyValue(`--uk-${name}`)
77
- .replace(propertyRe, '$2');
66
+ export function getCssVar(name, element = document.documentElement) {
67
+ return css(element, `--uk-${name}`).replace(propertyRe, '$2');
78
68
  }
79
69
 
80
70
  // https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-setproperty
@@ -83,6 +73,10 @@ export const propName = memoize((name) => vendorPropName(name));
83
73
  const cssPrefixes = ['webkit', 'moz'];
84
74
 
85
75
  function vendorPropName(name) {
76
+ if (name[0] === '-') {
77
+ return name;
78
+ }
79
+
86
80
  name = hyphenate(name);
87
81
 
88
82
  const { style } = document.documentElement;