@thinkpixellab-public/px-vue 3.0.76 → 3.0.78

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.
@@ -171,6 +171,15 @@ export default {
171
171
  // like flip but for the start/end direction
172
172
  shift: { default: true },
173
173
 
174
+ /**
175
+ * When true, the popup will be sized to the reference elemement, allowed values are:
176
+ * - "width" - size the width to the width of the reference element
177
+ * - "minWidth" - size the minWidth to the width of the reference element
178
+ * - "height" - (not implemented) size the height to the height of the reference element
179
+ * - "minHeight" - (not implemented) size the height to the height of the reference element
180
+ */
181
+ sizeToReference: { type: String, default: null },
182
+
174
183
  // uses the size middleware to keep the float on screen, resizing when necessary
175
184
  sizeToView: { default: false },
176
185
  sizeToViewPadding: { type: Number, default: 10 },
@@ -489,6 +498,21 @@ export default {
489
498
  );
490
499
  }
491
500
 
501
+ if (this.sizeToReference) {
502
+ const elementProp = this.sizeToReference;
503
+ const referenceProp = 'width';
504
+
505
+ middleware.push(
506
+ size({
507
+ apply({ rects, elements }) {
508
+ const assignValue = {};
509
+ assignValue[elementProp] = `${rects.reference[referenceProp]}px`;
510
+ Object.assign(elements.floating.style, assignValue);
511
+ },
512
+ })
513
+ );
514
+ }
515
+
492
516
  if (this.placement && this.$refs.popup && reference) {
493
517
  computePosition(reference, this.$refs.popup, {
494
518
  placement: this.placement,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thinkpixellab-public/px-vue",
3
- "version": "3.0.76",
3
+ "version": "3.0.78",
4
4
  "description": "General purpose Vue components and helpers that can be used across projects.",
5
5
  "author": "Pixel Lab",
6
6
  "license": "MIT",
@@ -36,3 +36,4 @@ const getFontFromElement = element => {
36
36
  };
37
37
 
38
38
  export default textWidth;
39
+ export { getFontFromElement };
package/utils/utils.js CHANGED
@@ -183,6 +183,22 @@ export default {
183
183
  return false;
184
184
  },
185
185
 
186
+ /**
187
+ * Returns a version with only values that past the test defined in filterFunction.
188
+ *
189
+ * @param {object} obj
190
+ * @param {functintion} filterFunction
191
+ * @return {object}
192
+ */
193
+ filterObject(obj, filterFunction) {
194
+ return Object.keys(obj)
195
+ .filter(key => filterFunction(obj[key], key))
196
+ .reduce((result, key) => {
197
+ result[key] = obj[key];
198
+ return result;
199
+ }, {});
200
+ },
201
+
186
202
  /**
187
203
  * Returns an object representing the current query string parameters.
188
204
  */