@thinkpixellab-public/px-vue 3.0.74 → 3.0.76

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.
@@ -30,7 +30,12 @@ ar
30
30
  </slot>
31
31
  </button>
32
32
 
33
- <div :class="bem('scroller', { disabled })" ref="scroller" @scroll="updateScrollArrows">
33
+ <div
34
+ :class="bem('scroller', { disabled })"
35
+ ref="scroller"
36
+ @scroll="updateScrollArrows"
37
+ data-no-drag
38
+ >
34
39
  <slot />
35
40
  </div>
36
41
 
@@ -18,7 +18,7 @@ export default {
18
18
  variantValue() {
19
19
  return (
20
20
  (this.variantBase ? `${this.variantBase} ` : '') +
21
- (this.variant ?? this.variantDefault)
21
+ (this.variant !== 'default' ? this.variant : this.variantDefault)
22
22
  );
23
23
  },
24
24
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thinkpixellab-public/px-vue",
3
- "version": "3.0.74",
3
+ "version": "3.0.76",
4
4
  "description": "General purpose Vue components and helpers that can be used across projects.",
5
5
  "author": "Pixel Lab",
6
6
  "license": "MIT",
@@ -14,7 +14,7 @@
14
14
  "dependencies": {
15
15
  "@floating-ui/dom": "^1.0.1",
16
16
  "@popperjs/core": "^2.11.5",
17
- "@thinkpixellab-public/px-styles": "^3.7.8",
17
+ "@thinkpixellab-public/px-styles": "^3.7.9",
18
18
  "@thinkpixellab-public/px-vue-tester": "^2.0.0",
19
19
  "@thinkpixellab-public/vue-resize-directive": "^1.2.2",
20
20
  "body-scroll-lock": "^3.1.5",
package/utils/cssStr.js CHANGED
@@ -58,6 +58,18 @@ function cssVar(val) {
58
58
  return null;
59
59
  }
60
60
 
61
+ /*
62
+ Extract the number from a css value
63
+ cssNum('10px') => 10
64
+ cssNum(10) => 10
65
+ cssNum('auto') => 0
66
+ cssNum('auto', null) => null
67
+ */
68
+ function cssNum(val, nanValue = 0) {
69
+ const num = parseFloat(val);
70
+ return isNaN(num) ? nanValue : num;
71
+ }
72
+
61
73
  /*
62
74
  Extract the unit from a css value
63
75
  cssUnit('10px') => 'px'
@@ -81,16 +93,16 @@ function cssUnit(val) {
81
93
  return '';
82
94
  }
83
95
 
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;
96
+ /**
97
+ * Scales a css value while leaving the unit intact.
98
+ * @param {string} val The css value to scale
99
+ * @example
100
+ * cssUnitScale('10px', 2) => '20px'
101
+ */
102
+ function cssUnitScale(val, scaler) {
103
+ const unit = cssUnit(val);
104
+ const num = cssNum(val);
105
+ return `${num * scaler}${unit}`;
94
106
  }
95
107
 
96
108
  /*
@@ -183,16 +195,16 @@ function cssUnitFallback(val, fallback, allowNumberless = false) {
183
195
  return `${num}${unit}`;
184
196
  }
185
197
 
186
- /*
187
- Ems version of cssUnitFallback
188
- */
198
+ /**
199
+ * Ems version of cssUnitFallback
200
+ */
189
201
  function cssEmFallback(val, allowNumberless = false) {
190
202
  return cssUnitFallback(val, 'em', allowNumberless);
191
203
  }
192
204
 
193
- /*
194
- Px version of cssUnitFallback
195
- */
205
+ /**
206
+ * Px version of cssUnitFallback
207
+ */
196
208
  function cssPxFallback(val, allowNumberless = false) {
197
209
  return cssUnitFallback(val, 'px', allowNumberless);
198
210
  }
@@ -206,6 +218,7 @@ export {
206
218
  cssAspect,
207
219
  cssNum,
208
220
  cssUnit,
221
+ cssUnitScale,
209
222
  cssUnitFallback,
210
223
  cssEmFallback,
211
224
  cssPxFallback,
package/utils/utils.js CHANGED
@@ -13,6 +13,20 @@ export default {
13
13
  return Math.min(Math.max(value, min), max);
14
14
  },
15
15
 
16
+ /**
17
+ * Ensure that a value is an array. If the value isn't an array, wrap it. If the value is null
18
+ * or undefined, an empty array is returned (0 and false will be wrapped).
19
+ *
20
+ * @param {*} value Any array or non-array value.
21
+ * @return {*} An array.
22
+ */
23
+ ensureArray: function (value) {
24
+ if (value === null || value === undefined) {
25
+ return [];
26
+ }
27
+ return Array.isArray(value) ? value : [value];
28
+ },
29
+
16
30
  /**
17
31
  * Safely gets an item from an array, otherwise returns a fallback value.
18
32
  * @param {*} arr The array.
@@ -29,6 +43,7 @@ export default {
29
43
  }
30
44
  return fallback;
31
45
  },
46
+
32
47
  /**
33
48
  * Method for calculating a safe index into an array for a given starting point and offset.
34
49
  * Offset can be very large or negative.
@@ -148,6 +163,26 @@ export default {
148
163
  return arrA.filter(value => arrB.includes(value));
149
164
  },
150
165
 
166
+ /**
167
+ * Returns true if the two arrays have any common items.
168
+ * @param {*} arr1 The first array
169
+ * @param {*} arr2 The second array
170
+ * @return True if the arrays have any common items
171
+ */
172
+ arrayHasCommonItem(arr1, arr2) {
173
+ if (!arr1 || !arr2) {
174
+ return false;
175
+ }
176
+
177
+ for (let i = 0; i < arr1.length; i++) {
178
+ if (arr2.indexOf(arr1[i]) > -1) {
179
+ return true;
180
+ }
181
+ }
182
+
183
+ return false;
184
+ },
185
+
151
186
  /**
152
187
  * Returns an object representing the current query string parameters.
153
188
  */