@compiled/react
Version:
A familiar and performant compile time CSS-in-JS library for React.
50 lines (49 loc) • 1.8 kB
TypeScript
import type { Bucket, StyleSheetOpts } from './types.js';
/**
* Ordered style buckets using their short pseudo name.
*
* This is very bare-bones, with no support for nesting, like styles in
* `@media` queries, pseudo-selectors mixed with shorthand properties, etc.
*
* If changes are needed to the pseudo-selectors, make sure that it aligns with the
* definition in `packages/css/src/utils/style-ordering.ts`.
*/
export declare const styleBucketOrdering: Bucket[];
/**
* Gets the bucket depending on the sheet.
* This function makes assumptions as to the form of the input class name.
*
* Input:
*
* ```
* "._a1234567:hover{ color: red; }"
* ```
*
* Output:
*
* ```
* "h"
* ```
*
* @param sheet styles for which we are getting the bucket
*/
export declare const getStyleBucketName: (sheet: string) => Bucket;
/**
* Used to move styles to the head of the application during runtime.
* When `opts.container` is provided, styles are inserted into that container
* instead of `document.head` — useful for Shadow DOM rendering.
*
* @param css string
* @param opts StyleSheetOpts
*/
export default function insertRule(css: string, opts: StyleSheetOpts): void;
/**
* Inserts a non-atomic CSS rule (generated by `cssMapScoped`) into the catch-all style
* bucket, bypassing the shorthand bucket sorting logic in `getStyleBucketName`.
*
* Non-atomic rules contain multiple declarations per selector and must preserve their
* source order relative to each other. The shorthand bucket logic is designed for
* single-declaration atomic rules only — applying it to multi-declaration non-atomic
* rules would sort them by their first property, breaking the intended CSS cascade.
*/
export declare function insertNonAtomicRule(css: string, opts: StyleSheetOpts): void;