@v-c/util 1.0.2 → 1.0.3

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.
@@ -65,9 +65,19 @@ function getAttrStyleAndClass(attrs, options) {
65
65
  restAttrs: pureAttrs(attrs, options)
66
66
  };
67
67
  }
68
+ function getStylePxValue(value) {
69
+ if (typeof value === "number") return `${value}px`;
70
+ else if (typeof value === "string") {
71
+ const trimed = value.trim();
72
+ if (Number.isNaN(Number(trimed))) return trimed;
73
+ else return `${Number(trimed)}px`;
74
+ }
75
+ return value;
76
+ }
68
77
  exports.filterEmpty = filterEmpty;
69
78
  exports.flattenChildren = flattenChildren;
70
79
  exports.getAttrStyleAndClass = getAttrStyleAndClass;
80
+ exports.getStylePxValue = getStylePxValue;
71
81
  exports.isEmptyElement = isEmptyElement;
72
82
  exports.pureAttrs = pureAttrs;
73
83
  exports.removeUndefined = removeUndefined;
@@ -19,3 +19,4 @@ export declare function getAttrStyleAndClass(attrs: Record<string, any>, options
19
19
  style: any;
20
20
  restAttrs: Record<string, any>;
21
21
  };
22
+ export declare function getStylePxValue(value: number | string | undefined | null): string;
@@ -65,4 +65,13 @@ function getAttrStyleAndClass(attrs, options) {
65
65
  restAttrs: pureAttrs(attrs, options)
66
66
  };
67
67
  }
68
- export { filterEmpty, flattenChildren, getAttrStyleAndClass, isEmptyElement, pureAttrs, removeUndefined, skipFlattenKey, toPropsRefs };
68
+ function getStylePxValue(value) {
69
+ if (typeof value === "number") return `${value}px`;
70
+ else if (typeof value === "string") {
71
+ const trimed = value.trim();
72
+ if (Number.isNaN(Number(trimed))) return trimed;
73
+ else return `${Number(trimed)}px`;
74
+ }
75
+ return value;
76
+ }
77
+ export { filterEmpty, flattenChildren, getAttrStyleAndClass, getStylePxValue, isEmptyElement, pureAttrs, removeUndefined, skipFlattenKey, toPropsRefs };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@v-c/util",
3
3
  "type": "module",
4
- "version": "1.0.2",
4
+ "version": "1.0.3",
5
5
  "description": "Vue3 components utils",
6
6
  "publishConfig": {
7
7
  "access": "public"