@thinkpixellab-public/px-vue 3.0.32 → 3.0.34

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.
@@ -289,10 +289,6 @@ export default {
289
289
  this.cleanup = autoUpdate(reference, popup, () =>
290
290
  this.updatePosition(reference, popup)
291
291
  );
292
- } else {
293
- console.warn(
294
- 'Cannot autoupdate float because no reference was provided.'
295
- );
296
292
  }
297
293
  }
298
294
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thinkpixellab-public/px-vue",
3
- "version": "3.0.32",
3
+ "version": "3.0.34",
4
4
  "description": "General purpose Vue components and helpers that can be used across projects.",
5
5
  "author": "Pixel Lab",
6
6
  "license": "MIT",
package/plugins/common.js CHANGED
@@ -5,7 +5,15 @@
5
5
 
6
6
  import bem from '../utils/bem';
7
7
  import isServer from '../utils/isServer.js';
8
- import { cssPx, cssEm, cssPcnt, cssUrl, cssVar } from '../utils/cssStr.js';
8
+ import {
9
+ cssPx,
10
+ cssEm,
11
+ cssPcnt,
12
+ cssUrl,
13
+ cssVar,
14
+ cssUnitFallback,
15
+ cssEmFallback,
16
+ } from '../utils/cssStr.js';
9
17
  import aspect from './filters/aspect.js';
10
18
  import kebab from './filters/kebab.js';
11
19
  import slug from './filters/slug.js';
@@ -22,6 +30,8 @@ export default {
22
30
  Vue.prototype.cssPcnt = cssPcnt;
23
31
  Vue.prototype.cssUrl = cssUrl;
24
32
  Vue.prototype.cssVar = cssVar;
33
+ Vue.prototype.cssUnitFallback = cssUnitFallback;
34
+ Vue.prototype.cssEmFallback = cssEmFallback;
25
35
 
26
36
  // filters
27
37
  // note: filters can be called as methods with something like
package/utils/cssStr.js CHANGED
@@ -58,4 +58,29 @@ function cssVar(val) {
58
58
  return null;
59
59
  }
60
60
 
61
- export { cssPx, cssEm, cssPcnt, cssUrl, cssVar };
61
+ /*
62
+ Add the specified unit if no other unit is specified.
63
+
64
+ cssUnitFallback('10px', 'em) => '10px'
65
+ cssUnitFallback('10', 'em') => '10em'
66
+ cssUnitFallback(10, 'em') => '10em'
67
+ */
68
+ function cssUnitFallback(val, fallback) {
69
+ if (!val) {
70
+ return val;
71
+ }
72
+
73
+ val = val.toString().trim();
74
+ const num = typeof val == 'number' ? val : parseFloat(val.toString().trim());
75
+ const unit = val.replace(/[0-9]/g, '').trim() || fallback;
76
+ return `${num}${unit}`;
77
+ }
78
+
79
+ /*
80
+ Ems version of cssUnitFallback
81
+ */
82
+ function cssEmFallback(val) {
83
+ return cssUnitFallback(val, 'em');
84
+ }
85
+
86
+ export { cssPx, cssEm, cssPcnt, cssUrl, cssVar, cssUnitFallback, cssEmFallback };