UNPKG

1.77 kBTypeScriptView Raw
1import { SheetConfig, Sheet, SheetInit } from 'twind';
2
3/**
4 * [[include:src/sheets/README.md]]
5 *
6 * @packageDocumentation
7 * @module twind/sheets
8 */
9
10/**
11 * Creates an sheet which inserts style rules through the Document Object Model.
12 */
13declare const domSheet: ({ nonce, target, }?: SheetConfig<HTMLStyleElement>) => Sheet<HTMLStyleElement>;
14/**
15 * Allows to reset and snaphot the current state of an sheet and
16 * in extension the internal mutable state (caches, ...) of `tw`.
17 */
18interface Storage {
19 /**
20 * Register a function that should be called to create a new state.
21 */
22 init: SheetInit;
23 /**
24 * Creates a snapshot of the current state, invokes all init callbacks to create a fresh state
25 * and returns the snaphot.
26 */
27 reset: (snapshot?: unknown[] | undefined) => unknown[];
28}
29/**
30 * A sheet that collects styles into an array.
31 */
32interface VirtualSheet extends Sheet<string[]>, Storage {
33 init: SheetInit;
34}
35/**
36 * Creates an sheet which collects style rules into an array.
37 */
38declare const virtualSheet: () => VirtualSheet;
39interface StyleTagProperties {
40 id: string;
41 textContent: string;
42}
43interface HasTarget {
44 readonly target: readonly string[];
45}
46declare type StyleTagSheet = HasTarget | readonly string[];
47/**
48 * Transforms css rules into `<style>` tag properties.
49 */
50declare const getStyleTagProperties: (sheet: StyleTagSheet) => StyleTagProperties;
51/**
52 * Transforms css rules into a `<style>` tag string.
53 */
54declare const getStyleTag: (sheet: StyleTagSheet, attributes?: Record<string, string> | undefined) => string;
55
56export { HasTarget, Storage, StyleTagProperties, StyleTagSheet, VirtualSheet, domSheet, getStyleTag, getStyleTagProperties, virtualSheet };
57//# sourceMappingURL=sheets.d.ts.map