@awc-ui/theme 1.0.0-beta

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 AWC UI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # @awc-ui/theme
2
+
3
+ Material Design 3 theme generation for [AWC UI](https://www.npmjs.com/package/@awc-ui/core): compute full MD3 color schemes from a seed color (via Google's [`@material/material-color-utilities`](https://www.npmjs.com/package/@material/material-color-utilities)), emit them as CSS custom properties, and apply them at runtime.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @awc-ui/theme
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ Generate and apply a theme in the browser:
14
+
15
+ ```ts
16
+ import { computeTheme, applyThemeStylesheet } from '@awc-ui/theme';
17
+
18
+ const theme = computeTheme({ primaryHex: '#6750A4' });
19
+ applyThemeStylesheet(theme); // injects the --md-sys-* custom properties
20
+ ```
21
+
22
+ Or generate static CSS at build time / server-side:
23
+
24
+ ```ts
25
+ import { computeTheme, generateCss } from '@awc-ui/theme';
26
+
27
+ const css = generateCss(computeTheme({ primaryHex: '#6750A4' }));
28
+ // write `css` to a file and ship it instead of computing in the browser
29
+ ```
30
+
31
+ ### Off-main-thread
32
+
33
+ Heavy palette computation can run in a Web Worker — the package ships a ready-made worker entry:
34
+
35
+ ```ts
36
+ // Vite
37
+ import ThemeWorker from '@awc-ui/theme/worker?worker';
38
+ const worker = new ThemeWorker();
39
+ ```
40
+
41
+ The worker bundle is self-contained (dependencies inlined), so it also works with a plain `new Worker(url, { type: 'module' })`.
42
+
43
+ ## Docs
44
+
45
+ Theming guides and the interactive theme generator: **[awc-ui.dev](https://awc-ui.dev/theming/overview/)**.
46
+
47
+ ## License
48
+
49
+ MIT
@@ -0,0 +1,8 @@
1
+ /** Set all 15 --md-sys-typescale-*-font-family tokens on an element. */
2
+ export declare function applyFontFamily(element: HTMLElement, fontFamily: string): void;
3
+ /**
4
+ * Inject or update a Google Fonts stylesheet for common font choices.
5
+ * Custom font family strings are applied via CSS vars only (no network fetch).
6
+ */
7
+ export declare function loadGoogleFont(fontFamily: string): void;
8
+ //# sourceMappingURL=apply-font.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apply-font.d.ts","sourceRoot":"","sources":["../src/apply-font.ts"],"names":[],"mappings":"AAmBA,wEAAwE;AACxE,wBAAgB,eAAe,CAAC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CAK9E;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAevD"}
@@ -0,0 +1,8 @@
1
+ import { type RoleMap, type ThemeComputeResult } from './types';
2
+ /** Apply generated MD3 color role tokens as inline CSS custom properties on an element. */
3
+ export declare function applyThemeRoles(element: HTMLElement, roles: RoleMap): void;
4
+ /** Remove inline MD3 color role overrides so stylesheet / data-theme tokens can apply. */
5
+ export declare function clearThemeRoles(element: HTMLElement): void;
6
+ /** Inject or update a stylesheet with light (:root) and dark ([data-theme="dark"]) role tokens. */
7
+ export declare function applyThemeStylesheet(theme: ThemeComputeResult, styleId?: string): void;
8
+ //# sourceMappingURL=apply-theme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apply-theme.d.ts","sourceRoot":"","sources":["../src/apply-theme.ts"],"names":[],"mappings":"AAEA,OAAO,EAAa,KAAK,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE3E,2FAA2F;AAC3F,wBAAgB,eAAe,CAAC,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAI1E;AAED,0FAA0F;AAC1F,wBAAgB,eAAe,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,CAI1D;AAED,mGAAmG;AACnG,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,kBAAkB,EACzB,OAAO,SAAyB,GAC/B,IAAI,CAQN"}
@@ -0,0 +1,4 @@
1
+ import { type ThemeComputeRequest, type ThemeComputeResult } from './types';
2
+ /** Generate MD3 tonal palettes and role-mapped tokens for light and dark mode. */
3
+ export declare function computeTheme(req: ThemeComputeRequest): ThemeComputeResult;
4
+ //# sourceMappingURL=compute-theme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compute-theme.d.ts","sourceRoot":"","sources":["../src/compute-theme.ts"],"names":[],"mappings":"AAQA,OAAO,EAKL,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACxB,MAAM,SAAS,CAAC;AAuBjB,kFAAkF;AAClF,wBAAgB,YAAY,CAAC,GAAG,EAAE,mBAAmB,GAAG,kBAAkB,CA8DzE"}
@@ -0,0 +1,4 @@
1
+ import type { ThemeComputeResult } from './types';
2
+ /** Format a computed theme as a drop-in CSS file overriding @awc-ui/tokens defaults. */
3
+ export declare function generateCss(result: ThemeComputeResult): string;
4
+ //# sourceMappingURL=generate-css.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-css.d.ts","sourceRoot":"","sources":["../src/generate-css.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD,wFAAwF;AACxF,wBAAgB,WAAW,CAAC,MAAM,EAAE,kBAAkB,GAAG,MAAM,CA+B9D"}
@@ -0,0 +1,8 @@
1
+ export { computeTheme } from './compute-theme';
2
+ export { applyThemeRoles, applyThemeStylesheet, clearThemeRoles } from './apply-theme';
3
+ export { applyFontFamily, loadGoogleFont } from './apply-font';
4
+ export { generateCss } from './generate-css';
5
+ export { tokenName } from './token-name';
6
+ export { ROLE_KEYS, DEFAULT_SEED_COLORS, DEFAULT_FONT_FAMILY, TYPESCALE_SLOTS, } from './types';
7
+ export type { PaletteKey, RoleKey, RoleMap, ThemeComputeRequest, ThemeComputeResult, ThemeWorkerRequest, ThemeWorkerResponse, } from './types';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACvF,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EACL,SAAS,EACT,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,GAChB,MAAM,SAAS,CAAC;AACjB,YAAY,EACV,UAAU,EACV,OAAO,EACP,OAAO,EACP,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,SAAS,CAAC"}