@molecule/app-styling 1.0.7 → 1.0.8

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
@@ -3,7 +3,7 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
3
3
  Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
4
4
  Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
5
5
  To change this document, edit the module-level JSDoc in src/index.ts.
6
- Generated: 2026-11-08T06:24:47.822Z
6
+ Generated: 2026-12-01T17:08:16.278Z
7
7
  -->
8
8
 
9
9
  # @molecule/app-styling
@@ -88,10 +88,23 @@ type ClassMerger = (className: string) => string
88
88
 
89
89
  #### `themeToCSS(theme)`
90
90
 
91
- Maps a molecule theme to CSS custom properties.
91
+ Maps a Molecule theme to CSS custom properties. Each scale can use string or
92
+ numeric token names. Token values must be strings or numbers.
92
93
 
93
94
  ```typescript
94
- function themeToCSS(theme: ThemeLike): Record<string, string>
95
+ function themeToCSS<
96
+ Color extends TokenKey,
97
+ Spacing extends TokenKey,
98
+ FontSize extends TokenKey,
99
+ Radius extends TokenKey,
100
+ Shadow extends TokenKey,
101
+ >(theme: {
102
+ colors: Tokens<Color>
103
+ spacing: Tokens<Spacing>
104
+ typography: { fontSize: Tokens<FontSize> }
105
+ borderRadius: Tokens<Radius>
106
+ shadows: Tokens<Shadow>
107
+ }): Record<string, string>
95
108
  ```
96
109
 
97
110
  - `theme` — A theme object with colors, spacing, typography, borderRadius, and shadows.
package/dist/theme.d.ts CHANGED
@@ -3,31 +3,34 @@
3
3
  *
4
4
  * @module
5
5
  */
6
+ type TokenKey = string | number;
7
+ /** A token scale can use named keys declared by an interface, such as ThemeColors. */
8
+ type Tokens<Key extends TokenKey> = Record<Key, string | number>;
6
9
  /**
7
- * Minimal theme shape required by themeToCSS().
8
- * Structurally compatible with Theme from `@molecule/app-theme`.
9
- */
10
- interface ThemeLike {
11
- colors: Record<string, string | number>;
12
- spacing: Record<string, string | number>;
13
- typography: {
14
- fontSize: Record<string, string | number>;
15
- };
16
- borderRadius: Record<string, string | number>;
17
- shadows: Record<string, string | number>;
18
- }
19
- /**
20
- * Maps a molecule theme to CSS custom properties.
10
+ * Maps a Molecule theme to CSS custom properties. Each scale can use string or
11
+ * numeric token names. Token values must be strings or numbers.
21
12
  *
22
13
  * @example
23
14
  * ```typescript
24
- * const cssVars = themeToCSS(theme)
25
- * // Use in style attribute or inject into :root
15
+ * import { lightTheme } from '@molecule/app-theme'
16
+ * import { themeToCSS } from '@molecule/app-styling'
17
+ *
18
+ * for (const [name, value] of Object.entries(themeToCSS(lightTheme))) {
19
+ * document.documentElement.style.setProperty(name, value)
20
+ * }
26
21
  * ```
27
22
  *
28
23
  * @param theme - A theme object with colors, spacing, typography, borderRadius, and shadows.
29
24
  * @returns A flat record of CSS custom properties (e.g. `{ '--color-primary': '#3b82f6' }`).
30
25
  */
31
- export declare const themeToCSS: (theme: ThemeLike) => Record<string, string>;
26
+ export declare const themeToCSS: <Color extends TokenKey, Spacing extends TokenKey, FontSize extends TokenKey, Radius extends TokenKey, Shadow extends TokenKey>(theme: {
27
+ colors: Tokens<Color>;
28
+ spacing: Tokens<Spacing>;
29
+ typography: {
30
+ fontSize: Tokens<FontSize>;
31
+ };
32
+ borderRadius: Tokens<Radius>;
33
+ shadows: Tokens<Shadow>;
34
+ }) => Record<string, string>;
32
35
  export {};
33
36
  //# sourceMappingURL=theme.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../src/theme.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;GAGG;AACH,UAAU,SAAS;IACjB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAA;IACvC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAA;IACxC,UAAU,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAA;KAAE,CAAA;IACzD,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAA;IAC7C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAA;CACzC;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,UAAU,GAAI,OAAO,SAAS,KAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CA6BlE,CAAA"}
1
+ {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../src/theme.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,KAAK,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAA;AAE/B,sFAAsF;AACtF,KAAK,MAAM,CAAC,GAAG,SAAS,QAAQ,IAAI,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,CAAA;AAEhE;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,UAAU,GACrB,KAAK,SAAS,QAAQ,EACtB,OAAO,SAAS,QAAQ,EACxB,QAAQ,SAAS,QAAQ,EACzB,MAAM,SAAS,QAAQ,EACvB,MAAM,SAAS,QAAQ,EACvB,OAAO;IACP,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,CAAA;IACrB,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,CAAA;IACxB,UAAU,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAA;KAAE,CAAA;IAC1C,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;IAC5B,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;CACxB,KAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CA6BxB,CAAA"}
package/dist/theme.js CHANGED
@@ -5,12 +5,17 @@
5
5
  */
6
6
  import { camelToKebab } from './utilities.js';
7
7
  /**
8
- * Maps a molecule theme to CSS custom properties.
8
+ * Maps a Molecule theme to CSS custom properties. Each scale can use string or
9
+ * numeric token names. Token values must be strings or numbers.
9
10
  *
10
11
  * @example
11
12
  * ```typescript
12
- * const cssVars = themeToCSS(theme)
13
- * // Use in style attribute or inject into :root
13
+ * import { lightTheme } from '@molecule/app-theme'
14
+ * import { themeToCSS } from '@molecule/app-styling'
15
+ *
16
+ * for (const [name, value] of Object.entries(themeToCSS(lightTheme))) {
17
+ * document.documentElement.style.setProperty(name, value)
18
+ * }
14
19
  * ```
15
20
  *
16
21
  * @param theme - A theme object with colors, spacing, typography, borderRadius, and shadows.
package/dist/theme.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"theme.js","sourceRoot":"","sources":["../src/theme.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAc7C;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAgB,EAA0B,EAAE;IACrE,MAAM,IAAI,GAA2B,EAAE,CAAA;IAEvC,SAAS;IACT,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;QACxD,IAAI,CAAC,WAAW,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;IACtD,CAAC;IAED,UAAU;IACV,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;QACzD,IAAI,CAAC,aAAa,GAAG,EAAE,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;IAC1C,CAAC;IAED,aAAa;IACb,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE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AAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;IAC1C,CAAC;IAED,aAAa;IACb,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QACrE,IAAI,CAAC,eAAe,GAAG,EAAE,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;IAC5C,CAAC;IAED,gBAAgB;IAChB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE,CAAC;QAC9D,IAAI,CAAC,YAAY,GAAG,EAAE,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;IACzC,CAAC;IAED,UAAU;IACV,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;QACzD,IAAI,CAAC,YAAY,GAAG,EAAE,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;IACzC,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/app-styling",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "Framework-agnostic class name merging, variant generation, and theme conversion",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",