@plumeria/core 0.9.8 → 0.9.10

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.
package/README.md CHANGED
@@ -67,6 +67,42 @@ const styles = css.create({
67
67
  });
68
68
  ```
69
69
 
70
+ ### `css.createComposite()`
71
+
72
+ Creates modifier classes for a base style:
73
+
74
+ ```ts
75
+ const styles = css.create({
76
+ flexBox: {
77
+ display: 'flex',
78
+ flexDirection: 'column',
79
+ justifyContent: 'center',
80
+ },
81
+ });
82
+
83
+ const composed = css.createComposite(styles.flexBox, {
84
+ hover: {
85
+ [css.pseudo.hover]: {
86
+ scale: 1.5,
87
+ },
88
+ },
89
+ active: {
90
+ [css.pseudo.active]: {
91
+ color: css.color.gray,
92
+ },
93
+ },
94
+ });
95
+ ```
96
+
97
+ This produces named modifier classes based on the base style.
98
+ You can use them like this:
99
+
100
+ ```jsx
101
+ <div className={composed.hover} />
102
+ ```
103
+
104
+ Automatically generates all modifier variants while keeping the base style clean.
105
+
70
106
  ### `css.global()`
71
107
 
72
108
  Define global styles:
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ import { CSSHTML, CSSProperties, CreateKeyframes, CreateStyle, CreateStyleType,
3
3
  //#region src/css.d.ts
4
4
  declare class css {
5
5
  static create<const T extends Record<string, CSSProperties>>(object: CreateStyleType<T>): ReturnType<T>;
6
+ static createComposite<const T extends Record<string, CSSProperties>>(className: string, object: T): ReturnType<T>;
6
7
  static global(object: CSSHTML): void;
7
8
  static keyframes(object: CreateKeyframes): string;
8
9
  static defineConsts<const T extends CreateValues>(object: T): T;
package/dist/index.js CHANGED
@@ -19,6 +19,12 @@ function create(object) {
19
19
  });
20
20
  return Object.freeze(object);
21
21
  }
22
+ function createComposite(className, object) {
23
+ const composed = create(object);
24
+ const result = {};
25
+ for (const key in composed) result[key] = `${className} ${composed[key]}`;
26
+ return result;
27
+ }
22
28
  function global(object) {
23
29
  const base36Hash = (0, zss_engine.genBase36Hash)(object, 8);
24
30
  const { styleSheet } = (0, zss_engine.transpiler)(object, void 0, "--global");
@@ -70,6 +76,9 @@ var css = class {
70
76
  static create(object) {
71
77
  return create(object);
72
78
  }
79
+ static createComposite(className, object) {
80
+ return createComposite(className, object);
81
+ }
73
82
  static global(object) {
74
83
  return global(object);
75
84
  }
package/dist/index.mjs CHANGED
@@ -18,6 +18,12 @@ function create(object) {
18
18
  });
19
19
  return Object.freeze(object);
20
20
  }
21
+ function createComposite(className, object) {
22
+ const composed = create(object);
23
+ const result = {};
24
+ for (const key in composed) result[key] = `${className} ${composed[key]}`;
25
+ return result;
26
+ }
21
27
  function global(object) {
22
28
  const base36Hash = genBase36Hash(object, 8);
23
29
  const { styleSheet } = transpiler(object, void 0, "--global");
@@ -69,6 +75,9 @@ var css = class {
69
75
  static create(object) {
70
76
  return create(object);
71
77
  }
78
+ static createComposite(className, object) {
79
+ return createComposite(className, object);
80
+ }
72
81
  static global(object) {
73
82
  return global(object);
74
83
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plumeria/core",
3
- "version": "0.9.8",
3
+ "version": "0.9.10",
4
4
  "description": "Zero-runtime, expressive CSS-in-JS library for TypeScript.",
5
5
  "keywords": [
6
6
  "css",
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "./processors": {
29
29
  "types": "./dist/processors/css.d.ts",
30
- "import": "./dist/procesmsors/css.mjs",
30
+ "import": "./dist/processors/css.mjs",
31
31
  "default": "./dist/processors/css.js"
32
32
  }
33
33
  },