@just-web/css 0.6.0 → 0.7.0

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.
Files changed (38) hide show
  1. package/cjs/convertors/px_2_num.d.ts +15 -0
  2. package/cjs/convertors/px_2_num.js +9 -0
  3. package/cjs/convertors/px_2_rem.d.ts +1 -1
  4. package/cjs/convertors/px_2_rem.js +1 -1
  5. package/cjs/convertors/rem_2_px.d.ts +1 -1
  6. package/cjs/convertors/rem_2_px.js +1 -1
  7. package/cjs/index.d.ts +1 -0
  8. package/cjs/index.js +11 -0
  9. package/cjs/props/class-name.d.ts +2 -2
  10. package/cjs/props/style.d.ts +2 -2
  11. package/cjs/utils/prefers-color-scheme.d.ts +1 -1
  12. package/esm/convertors/px_2_num.d.ts +16 -0
  13. package/esm/convertors/px_2_num.d.ts.map +1 -0
  14. package/esm/convertors/px_2_num.js +18 -0
  15. package/esm/convertors/px_2_num.js.map +1 -0
  16. package/esm/convertors/px_2_rem.d.ts +1 -1
  17. package/esm/convertors/px_2_rem.d.ts.map +1 -1
  18. package/esm/convertors/px_2_rem.js +1 -1
  19. package/esm/convertors/px_2_rem.js.map +1 -1
  20. package/esm/convertors/rem_2_px.d.ts +1 -1
  21. package/esm/convertors/rem_2_px.d.ts.map +1 -1
  22. package/esm/convertors/rem_2_px.js +1 -1
  23. package/esm/convertors/rem_2_px.js.map +1 -1
  24. package/esm/index.d.ts +1 -0
  25. package/esm/index.d.ts.map +1 -1
  26. package/esm/index.js +1 -0
  27. package/esm/index.js.map +1 -1
  28. package/esm/props/class-name.d.ts +2 -2
  29. package/esm/props/class-name.d.ts.map +1 -1
  30. package/esm/props/style.d.ts +2 -2
  31. package/esm/props/style.d.ts.map +1 -1
  32. package/package.json +13 -21
  33. package/src/convertors/px_2_num.ts +17 -0
  34. package/src/convertors/px_2_rem.ts +5 -2
  35. package/src/convertors/rem_2_px.ts +5 -2
  36. package/src/index.ts +1 -0
  37. package/src/props/class-name.ts +1 -1
  38. package/src/props/style.ts +1 -1
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Converts pixel values to numbers.
3
+ *
4
+ * @param px - The pixel value to convert. Can be a number or string (e.g. '16px' or '16')
5
+ * @returns The numeric value
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * px2num(16) // 16
10
+ * px2num('32px') // 32
11
+ * px2num('12.5px') // 12.5
12
+ * px2num('0px') // 0
13
+ * ```
14
+ */
15
+ export declare function px2num(px: number | string | undefined): number;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.px2num = px2num;
7
+ function px2num(px) {
8
+ return typeof px === "string" ? Number.parseFloat(px.replace(/px$/, "")) : Number(px);
9
+ }
@@ -18,4 +18,4 @@
18
18
  export declare function px2rem(px: number | string, options?: {
19
19
  base?: number | undefined;
20
20
  precision?: number | undefined;
21
- }): string;
21
+ }): number;
@@ -13,5 +13,5 @@ function px2rem(px, options) {
13
13
  px = px.replace(/px$/, "");
14
14
  px = Number.parseFloat(px);
15
15
  }
16
- return (px / base).toFixed(precision);
16
+ return Number((px / base).toFixed(precision));
17
17
  }
@@ -18,4 +18,4 @@
18
18
  export declare function rem2px(rem: number | string, options?: {
19
19
  base?: number | undefined;
20
20
  precision?: number | undefined;
21
- }): string;
21
+ }): number;
@@ -13,5 +13,5 @@ function rem2px(rem, options) {
13
13
  rem = rem.replace(/rem$/, "");
14
14
  rem = Number.parseFloat(rem);
15
15
  }
16
- return (rem * base).toFixed(precision);
16
+ return Number((rem * base).toFixed(precision));
17
17
  }
package/cjs/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export * from './convertors/px_2_num.ts';
1
2
  export * from './convertors/px_2_rem.ts';
2
3
  export * from './convertors/rem_2_px.ts';
3
4
  export * from './css-properties/css-properties.ts';
package/cjs/index.js CHANGED
@@ -3,6 +3,17 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ var _px_2_num = require("./convertors/px_2_num.ts");
7
+ Object.keys(_px_2_num).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _px_2_num[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _px_2_num[key];
14
+ }
15
+ });
16
+ });
6
17
  var _px_2_rem = require("./convertors/px_2_rem.ts");
7
18
  Object.keys(_px_2_rem).forEach(function (key) {
8
19
  if (key === "default" || key === "__esModule") return;
@@ -6,6 +6,6 @@
6
6
  * Interface for component props that include a className property.
7
7
  * The className property accepts a string value for CSS class names.
8
8
  */
9
- export interface ClassNameProps {
9
+ export type ClassNameProps = {
10
10
  className?: string | undefined;
11
- }
11
+ };
@@ -2,6 +2,6 @@ import type { CSSProperties } from '../css-properties/css-properties.ts';
2
2
  /**
3
3
  * Interface for component props that include a style property.
4
4
  */
5
- export interface StyleProps {
5
+ export type StyleProps = {
6
6
  style?: CSSProperties | undefined;
7
- }
7
+ };
@@ -30,4 +30,4 @@ export declare function observePrefersColorScheme<T extends string>(themes: Reco
30
30
  * // Returns 'light', 'dark', or null
31
31
  * ```
32
32
  */
33
- export declare function getPrefersColorTheme<T extends string>(...themes: T[]): any;
33
+ export declare function getPrefersColorTheme<T extends string>(...themes: T[]): T | null;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Converts pixel values to numbers.
3
+ *
4
+ * @param px - The pixel value to convert. Can be a number or string (e.g. '16px' or '16')
5
+ * @returns The numeric value
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * px2num(16) // 16
10
+ * px2num('32px') // 32
11
+ * px2num('12.5px') // 12.5
12
+ * px2num('0px') // 0
13
+ * ```
14
+ */
15
+ export declare function px2num(px: number | string | undefined): number;
16
+ //# sourceMappingURL=px_2_num.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"px_2_num.d.ts","sourceRoot":"","sources":["../../src/convertors/px_2_num.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,CAE9D"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Converts pixel values to numbers.
3
+ *
4
+ * @param px - The pixel value to convert. Can be a number or string (e.g. '16px' or '16')
5
+ * @returns The numeric value
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * px2num(16) // 16
10
+ * px2num('32px') // 32
11
+ * px2num('12.5px') // 12.5
12
+ * px2num('0px') // 0
13
+ * ```
14
+ */
15
+ export function px2num(px) {
16
+ return typeof px === 'string' ? Number.parseFloat(px.replace(/px$/, '')) : Number(px);
17
+ }
18
+ //# sourceMappingURL=px_2_num.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"px_2_num.js","sourceRoot":"","sources":["../../src/convertors/px_2_num.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,MAAM,CAAC,EAA+B;IACrD,OAAO,OAAO,EAAE,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;AACtF,CAAC"}
@@ -18,5 +18,5 @@
18
18
  export declare function px2rem(px: number | string, options?: {
19
19
  base?: number | undefined;
20
20
  precision?: number | undefined;
21
- }): string;
21
+ }): number;
22
22
  //# sourceMappingURL=px_2_rem.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"px_2_rem.d.ts","sourceRoot":"","sources":["../../src/convertors/px_2_rem.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,OAAO,CAAC,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,UASlH"}
1
+ {"version":3,"file":"px_2_rem.d.ts","sourceRoot":"","sources":["../../src/convertors/px_2_rem.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,MAAM,CACrB,EAAE,EAAE,MAAM,GAAG,MAAM,EACnB,OAAO,CAAC,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,GACrE,MAAM,CASR"}
@@ -21,6 +21,6 @@ export function px2rem(px, options) {
21
21
  px = px.replace(/px$/, '');
22
22
  px = Number.parseFloat(px);
23
23
  }
24
- return (px / base).toFixed(precision);
24
+ return Number((px / base).toFixed(precision));
25
25
  }
26
26
  //# sourceMappingURL=px_2_rem.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"px_2_rem.js","sourceRoot":"","sources":["../../src/convertors/px_2_rem.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,MAAM,CAAC,EAAmB,EAAE,OAAuE;IAClH,MAAM,EAAE,IAAI,GAAG,EAAE,EAAE,SAAS,GAAG,CAAC,EAAE,GAAG,OAAO,IAAI,EAAE,CAAA;IAElD,IAAI,OAAO,EAAE,KAAK,QAAQ,EAAE,CAAC;QAC5B,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;QAC1B,EAAE,GAAG,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC,CAAA;IAC3B,CAAC;IAED,OAAO,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;AACtC,CAAC"}
1
+ {"version":3,"file":"px_2_rem.js","sourceRoot":"","sources":["../../src/convertors/px_2_rem.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,MAAM,CACrB,EAAmB,EACnB,OAAuE;IAEvE,MAAM,EAAE,IAAI,GAAG,EAAE,EAAE,SAAS,GAAG,CAAC,EAAE,GAAG,OAAO,IAAI,EAAE,CAAA;IAElD,IAAI,OAAO,EAAE,KAAK,QAAQ,EAAE,CAAC;QAC5B,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;QAC1B,EAAE,GAAG,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC,CAAA;IAC3B,CAAC;IAED,OAAO,MAAM,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAA;AAC9C,CAAC"}
@@ -18,5 +18,5 @@
18
18
  export declare function rem2px(rem: number | string, options?: {
19
19
  base?: number | undefined;
20
20
  precision?: number | undefined;
21
- }): string;
21
+ }): number;
22
22
  //# sourceMappingURL=rem_2_px.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rem_2_px.d.ts","sourceRoot":"","sources":["../../src/convertors/rem_2_px.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,OAAO,CAAC,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,UASnH"}
1
+ {"version":3,"file":"rem_2_px.d.ts","sourceRoot":"","sources":["../../src/convertors/rem_2_px.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,MAAM,CACrB,GAAG,EAAE,MAAM,GAAG,MAAM,EACpB,OAAO,CAAC,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,GACrE,MAAM,CASR"}
@@ -21,6 +21,6 @@ export function rem2px(rem, options) {
21
21
  rem = rem.replace(/rem$/, '');
22
22
  rem = Number.parseFloat(rem);
23
23
  }
24
- return (rem * base).toFixed(precision);
24
+ return Number((rem * base).toFixed(precision));
25
25
  }
26
26
  //# sourceMappingURL=rem_2_px.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"rem_2_px.js","sourceRoot":"","sources":["../../src/convertors/rem_2_px.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,MAAM,CAAC,GAAoB,EAAE,OAAuE;IACnH,MAAM,EAAE,IAAI,GAAG,EAAE,EAAE,SAAS,GAAG,CAAC,EAAE,GAAG,OAAO,IAAI,EAAE,CAAA;IAElD,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC7B,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;QAC7B,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;IAC7B,CAAC;IAED,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;AACvC,CAAC"}
1
+ {"version":3,"file":"rem_2_px.js","sourceRoot":"","sources":["../../src/convertors/rem_2_px.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,MAAM,CACrB,GAAoB,EACpB,OAAuE;IAEvE,MAAM,EAAE,IAAI,GAAG,EAAE,EAAE,SAAS,GAAG,CAAC,EAAE,GAAG,OAAO,IAAI,EAAE,CAAA;IAElD,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC7B,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;QAC7B,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;IAC7B,CAAC;IAED,OAAO,MAAM,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAA;AAC/C,CAAC"}
package/esm/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export * from './convertors/px_2_num.ts';
1
2
  export * from './convertors/px_2_rem.ts';
2
3
  export * from './convertors/rem_2_px.ts';
3
4
  export * from './css-properties/css-properties.ts';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAA;AACxC,cAAc,0BAA0B,CAAA;AACxC,cAAc,oCAAoC,CAAA;AAClD,cAAc,kCAAkC,CAAA;AAChD,cAAc,uBAAuB,CAAA;AACrC,cAAc,kBAAkB,CAAA;AAChC,cAAc,uBAAuB,CAAA;AACrC,cAAc,2BAA2B,CAAA;AACzC,cAAc,sBAAsB,CAAA;AACpC,cAAc,2BAA2B,CAAA;AACzC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,iCAAiC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAA;AACxC,cAAc,0BAA0B,CAAA;AACxC,cAAc,0BAA0B,CAAA;AACxC,cAAc,oCAAoC,CAAA;AAClD,cAAc,kCAAkC,CAAA;AAChD,cAAc,uBAAuB,CAAA;AACrC,cAAc,kBAAkB,CAAA;AAChC,cAAc,uBAAuB,CAAA;AACrC,cAAc,2BAA2B,CAAA;AACzC,cAAc,sBAAsB,CAAA;AACpC,cAAc,2BAA2B,CAAA;AACzC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,iCAAiC,CAAA"}
package/esm/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ export * from "./convertors/px_2_num.js";
1
2
  export * from "./convertors/px_2_rem.js";
2
3
  export * from "./convertors/rem_2_px.js";
3
4
  export * from "./css-properties/css-properties.js";
package/esm/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAA;AACxC,cAAc,0BAA0B,CAAA;AACxC,cAAc,oCAAoC,CAAA;AAClD,cAAc,kCAAkC,CAAA;AAChD,cAAc,uBAAuB,CAAA;AACrC,cAAc,kBAAkB,CAAA;AAChC,cAAc,uBAAuB,CAAA;AACrC,cAAc,2BAA2B,CAAA;AACzC,cAAc,sBAAsB,CAAA;AACpC,cAAc,2BAA2B,CAAA;AACzC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,iCAAiC,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAA;AACxC,cAAc,0BAA0B,CAAA;AACxC,cAAc,0BAA0B,CAAA;AACxC,cAAc,oCAAoC,CAAA;AAClD,cAAc,kCAAkC,CAAA;AAChD,cAAc,uBAAuB,CAAA;AACrC,cAAc,kBAAkB,CAAA;AAChC,cAAc,uBAAuB,CAAA;AACrC,cAAc,2BAA2B,CAAA;AACzC,cAAc,sBAAsB,CAAA;AACpC,cAAc,2BAA2B,CAAA;AACzC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,iCAAiC,CAAA"}
@@ -6,7 +6,7 @@
6
6
  * Interface for component props that include a className property.
7
7
  * The className property accepts a string value for CSS class names.
8
8
  */
9
- export interface ClassNameProps {
9
+ export type ClassNameProps = {
10
10
  className?: string | undefined;
11
- }
11
+ };
12
12
  //# sourceMappingURL=class-name.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"class-name.d.ts","sourceRoot":"","sources":["../../src/props/class-name.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC9B,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC9B"}
1
+ {"version":3,"file":"class-name.d.ts","sourceRoot":"","sources":["../../src/props/class-name.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG;IAC5B,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC9B,CAAA"}
@@ -2,7 +2,7 @@ import type { CSSProperties } from '../css-properties/css-properties.ts';
2
2
  /**
3
3
  * Interface for component props that include a style property.
4
4
  */
5
- export interface StyleProps {
5
+ export type StyleProps = {
6
6
  style?: CSSProperties | undefined;
7
- }
7
+ };
8
8
  //# sourceMappingURL=style.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../src/props/style.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAA;AAExE;;GAEG;AACH,MAAM,WAAW,UAAU;IAC1B,KAAK,CAAC,EAAE,aAAa,GAAG,SAAS,CAAA;CACjC"}
1
+ {"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../src/props/style.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAA;AAExE;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACxB,KAAK,CAAC,EAAE,aAAa,GAAG,SAAS,CAAA;CACjC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@just-web/css",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "CSS types and utilities",
5
5
  "type": "module",
6
6
  "exports": {
@@ -24,38 +24,30 @@
24
24
  "type-plus": "8.0.0-beta.7"
25
25
  },
26
26
  "devDependencies": {
27
- "@repobuddy/storybook": "^0.12.0",
27
+ "@repobuddy/storybook": "^1.0.0",
28
28
  "@repobuddy/vitest": "^1.2.2",
29
- "@storybook/addon-essentials": "^8.6.12",
30
- "@storybook/addon-storysource": "^8.6.12",
31
- "@storybook/blocks": "^8.6.12",
32
- "@storybook/experimental-addon-test": "^8.6.12",
33
- "@storybook/manager-api": "^8.6.12",
34
- "@storybook/preview-api": "^8.6.12",
35
- "@storybook/react": "^8.6.12",
36
- "@storybook/react-vite": "^8.6.12",
37
- "@storybook/test": "^8.6.12",
38
- "@storybook/theming": "^8.6.12",
29
+ "@storybook/addon-docs": "^9.0.3",
30
+ "@storybook/addon-vitest": "9.0.3",
31
+ "@storybook/react-vite": "^9.0.3",
39
32
  "@tailwindcss/cli": "^4.1.6",
40
33
  "@tailwindcss/vite": "^4.1.6",
41
- "@vitest/browser": "^3.1.3",
42
- "@vitest/coverage-v8": "^3.1.3",
34
+ "@vitest/browser": "^3.2.4",
35
+ "@vitest/coverage-v8": "^3.2.4",
43
36
  "dedent": "^1.6.0",
44
37
  "ncp": "^2.0.0",
45
- "playwright": "^1.52.0",
46
38
  "react": "^18.3.1",
47
39
  "react-dom": "^18.3.1",
48
40
  "rimraf": "^6.0.1",
49
- "storybook": "^8.6.12",
50
- "storybook-addon-code-editor": "^4.1.1",
51
- "storybook-addon-tag-badges": "^1.4.0",
52
- "storybook-addon-vis": "^0.19.4",
53
- "storybook-dark-mode": "^4.0.2",
41
+ "storybook": "^9.0.3",
42
+ "storybook-addon-code-editor": "^5.0.0",
43
+ "storybook-addon-tag-badges": "^2.0.0",
44
+ "storybook-addon-vis": "^2.1.0",
45
+ "storybook-dark-mode2": "^5.0.2",
54
46
  "tailwindcss": "^4.1.6",
55
47
  "typescript": "^5.8.3",
56
48
  "unbuild": "^3.5.0",
57
49
  "vite": "^6.3.5",
58
- "vitest": "^3.1.3",
50
+ "vitest": "^3.2.4",
59
51
  "vitest-browser-react": "^0.1.1",
60
52
  "@tools/typescript": "^0.0.1"
61
53
  },
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Converts pixel values to numbers.
3
+ *
4
+ * @param px - The pixel value to convert. Can be a number or string (e.g. '16px' or '16')
5
+ * @returns The numeric value
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * px2num(16) // 16
10
+ * px2num('32px') // 32
11
+ * px2num('12.5px') // 12.5
12
+ * px2num('0px') // 0
13
+ * ```
14
+ */
15
+ export function px2num(px: number | string | undefined): number {
16
+ return typeof px === 'string' ? Number.parseFloat(px.replace(/px$/, '')) : Number(px)
17
+ }
@@ -15,7 +15,10 @@
15
15
  * px2rem(13, { precision: 2 }) // '0.81'
16
16
  * ```
17
17
  */
18
- export function px2rem(px: number | string, options?: { base?: number | undefined; precision?: number | undefined }) {
18
+ export function px2rem(
19
+ px: number | string,
20
+ options?: { base?: number | undefined; precision?: number | undefined },
21
+ ): number {
19
22
  const { base = 16, precision = 4 } = options ?? {}
20
23
 
21
24
  if (typeof px === 'string') {
@@ -23,5 +26,5 @@ export function px2rem(px: number | string, options?: { base?: number | undefine
23
26
  px = Number.parseFloat(px)
24
27
  }
25
28
 
26
- return (px / base).toFixed(precision)
29
+ return Number((px / base).toFixed(precision))
27
30
  }
@@ -15,7 +15,10 @@
15
15
  * rem2px(0.8125, { precision: 2 }) // '13.00'
16
16
  * ```
17
17
  */
18
- export function rem2px(rem: number | string, options?: { base?: number | undefined; precision?: number | undefined }) {
18
+ export function rem2px(
19
+ rem: number | string,
20
+ options?: { base?: number | undefined; precision?: number | undefined },
21
+ ): number {
19
22
  const { base = 16, precision = 4 } = options ?? {}
20
23
 
21
24
  if (typeof rem === 'string') {
@@ -23,5 +26,5 @@ export function rem2px(rem: number | string, options?: { base?: number | undefin
23
26
  rem = Number.parseFloat(rem)
24
27
  }
25
28
 
26
- return (rem * base).toFixed(precision)
29
+ return Number((rem * base).toFixed(precision))
27
30
  }
package/src/index.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export * from './convertors/px_2_num.ts'
1
2
  export * from './convertors/px_2_rem.ts'
2
3
  export * from './convertors/rem_2_px.ts'
3
4
  export * from './css-properties/css-properties.ts'
@@ -7,6 +7,6 @@
7
7
  * Interface for component props that include a className property.
8
8
  * The className property accepts a string value for CSS class names.
9
9
  */
10
- export interface ClassNameProps {
10
+ export type ClassNameProps = {
11
11
  className?: string | undefined
12
12
  }
@@ -3,6 +3,6 @@ import type { CSSProperties } from '../css-properties/css-properties.ts'
3
3
  /**
4
4
  * Interface for component props that include a style property.
5
5
  */
6
- export interface StyleProps {
6
+ export type StyleProps = {
7
7
  style?: CSSProperties | undefined
8
8
  }