@just-web/css 0.3.0 → 0.4.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.
@@ -0,0 +1,19 @@
1
+ import type { CSSProperties } from './css-properties.ts';
2
+ /**
3
+ * Converts React-style CSS properties to DOM style properties.
4
+ * This function handles both standard CSS properties and custom properties,
5
+ * ensuring proper formatting for DOM style application.
6
+ *
7
+ * @param style - React-style CSS properties object
8
+ * @returns CSSStyleDeclaration compatible object for DOM style application
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * const domStyle = toDOMStyle({
13
+ * backgroundColor: 'red',
14
+ * '--custom-color': '#ff0000'
15
+ * })
16
+ * element.style = domStyle
17
+ * ```
18
+ */
19
+ export declare function toDOMStyle(style: CSSProperties | undefined): Partial<CSSStyleDeclaration> | undefined;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.toDOMStyle = toDOMStyle;
7
+ function toDOMStyle(style) {
8
+ if (style === void 0) return void 0;
9
+ const result = {};
10
+ for (const [key, value] of Object.entries(style)) {
11
+ result[key.startsWith("--") ? key : key.replace(/[A-Z]/g, match => `-${match.toLowerCase()}`)] = value;
12
+ }
13
+ return result;
14
+ }
package/cjs/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './css-properties/css-properties.ts';
2
+ export * from './css-properties/to_dom_style.ts';
2
3
  export * from './props/class-name.ts';
3
4
  export * from './props/style.ts';
4
5
  export * from './theme/class-name.ts';
package/cjs/index.js CHANGED
@@ -14,6 +14,17 @@ Object.keys(_cssProperties).forEach(function (key) {
14
14
  }
15
15
  });
16
16
  });
17
+ var _to_dom_style = require("./css-properties/to_dom_style.ts");
18
+ Object.keys(_to_dom_style).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _to_dom_style[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _to_dom_style[key];
25
+ }
26
+ });
27
+ });
17
28
  var _className = require("./props/class-name.ts");
18
29
  Object.keys(_className).forEach(function (key) {
19
30
  if (key === "default" || key === "__esModule") return;
@@ -0,0 +1,20 @@
1
+ import type { CSSProperties } from './css-properties.ts';
2
+ /**
3
+ * Converts React-style CSS properties to DOM style properties.
4
+ * This function handles both standard CSS properties and custom properties,
5
+ * ensuring proper formatting for DOM style application.
6
+ *
7
+ * @param style - React-style CSS properties object
8
+ * @returns CSSStyleDeclaration compatible object for DOM style application
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * const domStyle = toDOMStyle({
13
+ * backgroundColor: 'red',
14
+ * '--custom-color': '#ff0000'
15
+ * })
16
+ * element.style = domStyle
17
+ * ```
18
+ */
19
+ export declare function toDOMStyle(style: CSSProperties | undefined): Partial<CSSStyleDeclaration> | undefined;
20
+ //# sourceMappingURL=to_dom_style.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"to_dom_style.d.ts","sourceRoot":"","sources":["../../src/css-properties/to_dom_style.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAExD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,aAAa,GAAG,SAAS,GAAG,OAAO,CAAC,mBAAmB,CAAC,GAAG,SAAS,CAUrG"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Converts React-style CSS properties to DOM style properties.
3
+ * This function handles both standard CSS properties and custom properties,
4
+ * ensuring proper formatting for DOM style application.
5
+ *
6
+ * @param style - React-style CSS properties object
7
+ * @returns CSSStyleDeclaration compatible object for DOM style application
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * const domStyle = toDOMStyle({
12
+ * backgroundColor: 'red',
13
+ * '--custom-color': '#ff0000'
14
+ * })
15
+ * element.style = domStyle
16
+ * ```
17
+ */
18
+ export function toDOMStyle(style) {
19
+ if (style === undefined)
20
+ return undefined;
21
+ const result = {};
22
+ for (const [key, value] of Object.entries(style)) {
23
+ result[key.startsWith('--') ? key : key.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`)] = value;
24
+ }
25
+ return result;
26
+ }
27
+ //# sourceMappingURL=to_dom_style.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"to_dom_style.js","sourceRoot":"","sources":["../../src/css-properties/to_dom_style.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,UAAU,CAAC,KAAgC;IAC1D,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAA;IAEzC,MAAM,MAAM,GAAG,EAAS,CAAA;IAExB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAClD,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,GAAG,KAAK,CAAA;IACzG,CAAC;IAED,OAAO,MAAM,CAAA;AACd,CAAC"}
package/esm/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './css-properties/css-properties.ts';
2
+ export * from './css-properties/to_dom_style.ts';
2
3
  export * from './props/class-name.ts';
3
4
  export * from './props/style.ts';
4
5
  export * from './theme/class-name.ts';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oCAAoC,CAAA;AAClD,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,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,4 +1,5 @@
1
1
  export * from "./css-properties/css-properties.js";
2
+ export * from "./css-properties/to_dom_style.js";
2
3
  export * from "./props/class-name.js";
3
4
  export * from "./props/style.js";
4
5
  export * from "./theme/class-name.js";
package/esm/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oCAAoC,CAAA;AAClD,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,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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@just-web/css",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "CSS types and utilities",
5
5
  "type": "module",
6
6
  "exports": {
@@ -0,0 +1,30 @@
1
+ import type { CSSProperties } from './css-properties.ts'
2
+
3
+ /**
4
+ * Converts React-style CSS properties to DOM style properties.
5
+ * This function handles both standard CSS properties and custom properties,
6
+ * ensuring proper formatting for DOM style application.
7
+ *
8
+ * @param style - React-style CSS properties object
9
+ * @returns CSSStyleDeclaration compatible object for DOM style application
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * const domStyle = toDOMStyle({
14
+ * backgroundColor: 'red',
15
+ * '--custom-color': '#ff0000'
16
+ * })
17
+ * element.style = domStyle
18
+ * ```
19
+ */
20
+ export function toDOMStyle(style: CSSProperties | undefined): Partial<CSSStyleDeclaration> | undefined {
21
+ if (style === undefined) return undefined
22
+
23
+ const result = {} as any
24
+
25
+ for (const [key, value] of Object.entries(style)) {
26
+ result[key.startsWith('--') ? key : key.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`)] = value
27
+ }
28
+
29
+ return result
30
+ }
package/src/index.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './css-properties/css-properties.ts'
2
+ export * from './css-properties/to_dom_style.ts'
2
3
  export * from './props/class-name.ts'
3
4
  export * from './props/style.ts'
4
5
  export * from './theme/class-name.ts'