@pantoken/css 0.3.10 → 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.
package/dist/index.d.mts CHANGED
@@ -1,9 +1,29 @@
1
- import { PantokenPlugin, PropertyRule, Token } from "@pantoken/model";
1
+ import { BOUNDARY_ATTR, BOUNDARY_CLASS, COLOR_ATTR, SCHEME_ATTR, THEME_ATTR, colorClass, schemeClass, schemeScopeSelector, schemeScopeSelectors, themeClass, themeScopeSelector, themeScopeSelectors } from "@pantoken/utils";
2
+ import { PantokenPlugin, PropertyRule, Theme, Token } from "@pantoken/model";
2
3
  //#region src/to-css.d.ts
4
+ /**
5
+ * Which half of the sheet to emit.
6
+ *
7
+ * `@property` registrations are document-global — the last registration of a given name wins for the
8
+ * whole document — so two full sheets on one page fight over every concrete token. Emitting
9
+ * registrations once (`"properties"`) and each theme as declarations only (`"declarations"`) lets
10
+ * several themes coexist.
11
+ */
12
+ type CssEmitTarget = "all" | "properties" | "declarations";
3
13
  /** Options for {@link toCss}. */
4
14
  interface ToCssOptions {
5
15
  /** The selector scoped declarations are emitted under (default `":root"`). */
6
16
  scope?: string;
17
+ /** Plain cascade layer name wrapping the declarations (no `@` prefix). Omit to skip the wrapper. */
18
+ layer?: string;
19
+ /** Which half of the sheet to emit (default `"all"`). */
20
+ emit?: CssEmitTarget;
21
+ /**
22
+ * Emit every token as a declaration rather than routing concrete tokens to `@property`. Required
23
+ * for a theme block that can nest inside another theme's subtree: an incomplete block would
24
+ * inherit the enclosing theme's values for the tokens it omits.
25
+ */
26
+ declareAll?: boolean;
7
27
  /** Plugins whose `css` hooks run after the base CSS is built (default: none). */
8
28
  plugins?: readonly PantokenPlugin[];
9
29
  }
@@ -89,6 +109,97 @@ export declare function buildCssFile({ comments, scope, properties, sections, in
89
109
  inherits?: boolean;
90
110
  }): string;
91
111
  //#endregion
112
+ //#region src/theme-variants.d.ts
113
+ /** The light branch of a `light-dark()` value, or `null` when the value isn't one. */
114
+ export declare function lightBranch(value: string): string | null;
115
+ /** The dark branch of a `light-dark()` value, or `null` when the value isn't one. */
116
+ export declare function darkBranch(value: string): string | null;
117
+ /** A color scheme a scope can be pinned to. */
118
+ type Scheme = "light" | "dark";
119
+ /**
120
+ * The tokens whose value actually changes when a theme is pinned to `scheme` — i.e. the ones written
121
+ * with `light-dark()`. This is the minimal forcing block for `[data-pantoken-scheme]`.
122
+ */
123
+ export declare function schemeOverrideTokens(theme: Theme, scheme: Scheme): Token[];
124
+ /** Build a theme token set with optional icon removal and light/dark collapse. */
125
+ export declare function themedTokens(theme: Theme, options?: {
126
+ includeIcons?: boolean;
127
+ lightOnly?: boolean;
128
+ scheme?: Scheme;
129
+ }): Token[];
130
+ //#endregion
131
+ //#region src/scoped.d.ts
132
+ /** Cascade layers this module emits into, in ascending precedence order. */
133
+ export declare const LAYERS: readonly string[];
134
+ /** The `@layer` statement that fixes layer precedence. Must come before any layered rule. */
135
+ export declare const layerOrderCss: () => string;
136
+ /** Options shared by the scoped emitters. */
137
+ interface ScopedCssOptions {
138
+ /** Drop the `--instui-icon-*` glyph tokens (default `false`). */
139
+ includeIcons?: boolean;
140
+ /** Plugins whose `css` hooks run after the base CSS is built. */
141
+ plugins?: readonly PantokenPlugin[];
142
+ }
143
+ /**
144
+ * The document-global `@property` registrations, with no declarations. Load this once per document;
145
+ * every theme sheet below is declarations only, so loading a second theme cannot clobber it.
146
+ */
147
+ export declare function propertiesCss(theme: Theme, options?: ScopedCssOptions): string;
148
+ /**
149
+ * One theme's complete token set, scoped to any element carrying `data-pantoken-theme="<theme>"` or
150
+ * the equivalent `.--pantoken-theme-<theme>` class.
151
+ *
152
+ * Every token is emitted as a declaration — including the concrete ones that would normally become
153
+ * `@property` initial-values — because an initial-value is document-global and cannot vary per scope.
154
+ */
155
+ export declare function scopedThemeCss(theme: Theme, options?: ScopedCssOptions): string;
156
+ /**
157
+ * Pin a subtree's color scheme.
158
+ *
159
+ * `color-scheme` is an ordinary inherited property, so one rule keyed to the scope attribute (or its
160
+ * class twin) resolves every `light-dark()` token below it. No token needs flattening: this sheet is
161
+ * a couple of hundred bytes, not the ~87kb an explicit per-token override table would cost.
162
+ */
163
+ export declare function scopedSchemeCss(scheme: Scheme): string;
164
+ /**
165
+ * The light and dark scheme pins, as a standalone sheet. Theme-independent — the scheme only decides
166
+ * which branch of `light-dark()` wins, which the browser does for us.
167
+ *
168
+ * @example
169
+ * ```ts
170
+ * import { schemesCss } from "@pantoken/css";
171
+ *
172
+ * schemesCss();
173
+ * ```
174
+ */
175
+ export declare function schemesCss(): string;
176
+ /** Options for {@link multiScopeCss}. */
177
+ interface MultiScopeCssOptions extends ScopedCssOptions {
178
+ /** Themes to emit scope blocks for. */
179
+ themes: readonly Theme[];
180
+ /** The theme whose concrete tokens back the one-time `@property` registrations. */
181
+ defaultTheme: Theme;
182
+ /** Include the light/dark `color-scheme` pins (default `true`; see {@link schemesCss}). */
183
+ schemes?: boolean;
184
+ }
185
+ /**
186
+ * The complete multi-scope sheet: layer order, one set of `@property` registrations, a shared base
187
+ * block, a token block per theme, and the light/dark `color-scheme` pins.
188
+ *
189
+ * Tokens are partitioned by whether their value actually varies across `themes`. Invariant tokens go
190
+ * in the shared base block once; varying tokens are repeated in full in *every* theme block. That
191
+ * second half is what makes nesting safe — a theme block that omitted a varying token would inherit
192
+ * the enclosing scope's value for it.
193
+ *
194
+ * @example
195
+ * ```ts
196
+ * import { multiScopeCss } from "@pantoken/css";
197
+ *
198
+ * multiScopeCss({ themes: ["rebrand", "canvas"], defaultTheme: "rebrand" });
199
+ * ```
200
+ */
201
+ export declare function multiScopeCss(options: MultiScopeCssOptions): string;
202
+ //#endregion
92
203
  //#region src/index.d.ts
93
204
  /**
94
205
  * The ready-made `rebrand` stylesheet string (typed: concrete tokens as `@property` registrations).
@@ -116,4 +227,4 @@ export declare const css: string;
116
227
  */
117
228
  export declare const leanCss: string;
118
229
  //#endregion
119
- export { type CssSection, type ToCssOptions, css as default };
230
+ export { BOUNDARY_ATTR, BOUNDARY_CLASS, COLOR_ATTR, type CssEmitTarget, type CssSection, type MultiScopeCssOptions, SCHEME_ATTR, type Scheme, type ScopedCssOptions, THEME_ATTR, type ToCssOptions, colorClass, css as default, schemeClass, schemeScopeSelector, schemeScopeSelectors, themeClass, themeScopeSelector, themeScopeSelectors };
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { i as buildCssFile, n as leanCss, r as toCss, t as css } from "./src-YRQrYIS8.mjs";
2
- export { buildCssFile, css, css as default, leanCss, toCss };
1
+ import { C as buildCssFile, D as themedTokens, E as schemeOverrideTokens, S as toCss, T as lightBranch, _ as scopedSchemeCss, a as COLOR_ATTR, b as themeScopeSelector, c as THEME_ATTR, d as multiScopeCss, f as propertiesCss, g as schemesCss, h as schemeScopeSelectors, i as BOUNDARY_CLASS, l as colorClass, m as schemeScopeSelector, n as leanCss, o as LAYERS, p as schemeClass, r as BOUNDARY_ATTR, s as SCHEME_ATTR, t as css, u as layerOrderCss, v as scopedThemeCss, w as darkBranch, x as themeScopeSelectors, y as themeClass } from "./src-h17qjVzD.mjs";
2
+ export { BOUNDARY_ATTR, BOUNDARY_CLASS, COLOR_ATTR, LAYERS, SCHEME_ATTR, THEME_ATTR, buildCssFile, colorClass, css, css as default, darkBranch, layerOrderCss, leanCss, lightBranch, multiScopeCss, propertiesCss, schemeClass, schemeOverrideTokens, schemeScopeSelector, schemeScopeSelectors, schemesCss, scopedSchemeCss, scopedThemeCss, themeClass, themeScopeSelector, themeScopeSelectors, themedTokens, toCss };
package/dist/inject.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { t as css } from "./src-YRQrYIS8.mjs";
1
+ import { t as css } from "./src-h17qjVzD.mjs";
2
2
  //#region src/inject.ts
3
3
  /**
4
4
  * `@pantoken/css/inject` — a DOM side-effect entry. Importing it injects the pantoken stylesheet