@thinkpixellab-public/px-vue 3.0.37 → 3.0.39

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.
@@ -7,14 +7,14 @@
7
7
  <!-- html -->
8
8
  <component
9
9
  v-if="hasHtml"
10
- :class="bem('inner', { html: true })"
10
+ :class="[bem('inner', { html: true }), innerClass]"
11
11
  :is="innerTag"
12
12
  ref="text"
13
13
  v-html="html"
14
14
  />
15
15
 
16
16
  <!-- slot -->
17
- <component v-else :class="bem('inner')" :is="innerTag" ref="text">
17
+ <component v-else :class="[bem('inner'), innerClass]" :is="innerTag" ref="text">
18
18
  <slot />
19
19
  </component>
20
20
  </component>
@@ -35,6 +35,9 @@ export default {
35
35
  // the inner tag element
36
36
  innerTag: { type: String, default: 'span' },
37
37
 
38
+ // the inner tag element
39
+ innerClass: { type: String, default: null },
40
+
38
41
  // html that gets set on the inner tag element
39
42
  html: { type: String, default: null },
40
43
 
@@ -91,6 +94,12 @@ export default {
91
94
  }
92
95
  return /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
93
96
  },
97
+ isHeadless() {
98
+ if (isServer()) {
99
+ return false;
100
+ }
101
+ return /HeadlessChrome/i.test(navigator.userAgent);
102
+ },
94
103
  },
95
104
  watch: {
96
105
  enabled() {
@@ -110,7 +119,7 @@ export default {
110
119
  return;
111
120
  }
112
121
 
113
- if (this.isSafari) {
122
+ if (this.isSafari || this.isHeadless) {
114
123
  this.balanced = true;
115
124
  return;
116
125
  }
@@ -109,8 +109,8 @@ You can define a template using space notation like this:
109
109
  :key="spaceIndex"
110
110
  >
111
111
  <div
112
- v-for="(item, cardIndex) in space.cards"
113
- :key="cardIndex"
112
+ v-for="item in space.cards"
113
+ :key="getItemKey(item)"
114
114
  :class="bem('card')"
115
115
  :ref="cardRefFromItem(item)"
116
116
  >
@@ -273,6 +273,13 @@ export default {
273
273
  document.removeEventListener('keydown', this.onKey);
274
274
  }
275
275
 
276
+ if (nv) {
277
+ let reference = this.getReferenceElement();
278
+ let popup = this.$refs.popup;
279
+
280
+ this.updatePosition(reference, popup);
281
+ }
282
+
276
283
  // delayed actions (settimeout seems to work but $nextTick doesn't)
277
284
 
278
285
  setTimeout(() => {
@@ -100,8 +100,8 @@ export default {
100
100
  },
101
101
  methods: {
102
102
  transform(svg) {
103
- if (!svg) {
104
- return;
103
+ if (!svg?.viewBox) {
104
+ return svg;
105
105
  }
106
106
  // only a valid viewbox if it has both width/height
107
107
  let viewBox =
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thinkpixellab-public/px-vue",
3
- "version": "3.0.37",
3
+ "version": "3.0.39",
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/utils/cssStr.js CHANGED
@@ -58,6 +58,41 @@ function cssVar(val) {
58
58
  return null;
59
59
  }
60
60
 
61
+ /*
62
+ Extract the unit from a css value
63
+ cssUnit('10px') => 'px'
64
+ cssUnit(10) => ''
65
+ */
66
+ function cssUnit(val) {
67
+ if (!val) {
68
+ return '';
69
+ }
70
+ const allowedUnits = ['em', 'px', '%', 'rem', 'vw', 'vh', 'ex', 'ch', 'vmin', 'vmax'];
71
+
72
+ val = val
73
+ .toString()
74
+ .replace(/[0-9]|-|\./g, '')
75
+ .trim();
76
+
77
+ if (allowedUnits.includes(val)) {
78
+ return val;
79
+ }
80
+
81
+ return '';
82
+ }
83
+
84
+ /*
85
+ Extract the number from a css value
86
+ cssNum('10px') => 10
87
+ cssNum(10) => 10
88
+ cssNum('auto') => 0
89
+ cssNum('auto', null) => null
90
+ */
91
+ function cssNum(val, nanValue = 0) {
92
+ const num = parseFloat(val);
93
+ return isNaN(num) ? nanValue : num;
94
+ }
95
+
61
96
  /*
62
97
  Add the specified unit if no other unit is specified.
63
98
 
@@ -98,4 +133,4 @@ function cssEmFallback(val, allowNumberless = false) {
98
133
  return cssUnitFallback(val, 'em', allowNumberless);
99
134
  }
100
135
 
101
- export { cssPx, cssEm, cssPcnt, cssUrl, cssVar, cssUnitFallback, cssEmFallback };
136
+ export { cssPx, cssEm, cssPcnt, cssUrl, cssVar, cssNum, cssUnit, cssUnitFallback, cssEmFallback };
package/utils/variants.js CHANGED
@@ -3,6 +3,10 @@
3
3
  * (e.g. 'rounded shadow-lg' becomes ['rounded', 'shadow-lg'])
4
4
  */
5
5
  const stringToVariants = str => {
6
+ if (!str) {
7
+ return [];
8
+ }
9
+
6
10
  if (typeof str != 'string') {
7
11
  str = str + '';
8
12
  }