nitrowind 0.0.0-stage → 0.1.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.
Files changed (155) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/LICENSE +21 -0
  3. package/README.md +44 -2
  4. package/css.d.ts +6 -0
  5. package/dist/color.d.ts +24 -0
  6. package/dist/color.d.ts.map +1 -0
  7. package/dist/color.js +158 -0
  8. package/dist/color.js.map +1 -0
  9. package/dist/core.d.ts +121 -0
  10. package/dist/core.d.ts.map +1 -0
  11. package/dist/core.js +1026 -0
  12. package/dist/core.js.map +1 -0
  13. package/dist/css/compile.d.ts +18 -0
  14. package/dist/css/compile.d.ts.map +1 -0
  15. package/dist/css/compile.js +1018 -0
  16. package/dist/css/compile.js.map +1 -0
  17. package/dist/css/declarations.d.ts +18 -0
  18. package/dist/css/declarations.d.ts.map +1 -0
  19. package/dist/css/declarations.js +1173 -0
  20. package/dist/css/declarations.js.map +1 -0
  21. package/dist/css/index.d.ts +7 -0
  22. package/dist/css/index.d.ts.map +1 -0
  23. package/dist/css/index.js +7 -0
  24. package/dist/css/index.js.map +1 -0
  25. package/dist/css/parser.d.ts +9 -0
  26. package/dist/css/parser.d.ts.map +1 -0
  27. package/dist/css/parser.js +188 -0
  28. package/dist/css/parser.js.map +1 -0
  29. package/dist/css/tokenizer.d.ts +14 -0
  30. package/dist/css/tokenizer.d.ts.map +1 -0
  31. package/dist/css/tokenizer.js +200 -0
  32. package/dist/css/tokenizer.js.map +1 -0
  33. package/dist/css/types.d.ts +128 -0
  34. package/dist/css/types.d.ts.map +1 -0
  35. package/dist/css/types.js +19 -0
  36. package/dist/css/types.js.map +1 -0
  37. package/dist/css/values.d.ts +37 -0
  38. package/dist/css/values.d.ts.map +1 -0
  39. package/dist/css/values.js +343 -0
  40. package/dist/css/values.js.map +1 -0
  41. package/dist/environment.d.ts +5 -0
  42. package/dist/environment.d.ts.map +1 -0
  43. package/dist/environment.js +99 -0
  44. package/dist/environment.js.map +1 -0
  45. package/dist/hooks.d.ts +22 -0
  46. package/dist/hooks.d.ts.map +1 -0
  47. package/dist/hooks.js +140 -0
  48. package/dist/hooks.js.map +1 -0
  49. package/dist/index.d.ts +26 -0
  50. package/dist/index.d.ts.map +1 -0
  51. package/dist/index.js +16 -0
  52. package/dist/index.js.map +1 -0
  53. package/dist/jsx-dev-runtime.d.ts +17 -0
  54. package/dist/jsx-dev-runtime.d.ts.map +1 -0
  55. package/dist/jsx-dev-runtime.js +12 -0
  56. package/dist/jsx-dev-runtime.js.map +1 -0
  57. package/dist/jsx-namespace.d.ts +29 -0
  58. package/dist/jsx-namespace.d.ts.map +1 -0
  59. package/dist/jsx-namespace.js +2 -0
  60. package/dist/jsx-namespace.js.map +1 -0
  61. package/dist/jsx-runtime.d.ts +22 -0
  62. package/dist/jsx-runtime.d.ts.map +1 -0
  63. package/dist/jsx-runtime.js +21 -0
  64. package/dist/jsx-runtime.js.map +1 -0
  65. package/dist/math.d.ts +50 -0
  66. package/dist/math.d.ts.map +1 -0
  67. package/dist/math.js +442 -0
  68. package/dist/math.js.map +1 -0
  69. package/dist/plugin.d.ts +45 -0
  70. package/dist/plugin.d.ts.map +1 -0
  71. package/dist/plugin.js +172 -0
  72. package/dist/plugin.js.map +1 -0
  73. package/dist/props.d.ts +29 -0
  74. package/dist/props.d.ts.map +1 -0
  75. package/dist/props.js +163 -0
  76. package/dist/props.js.map +1 -0
  77. package/dist/scope.d.ts +99 -0
  78. package/dist/scope.d.ts.map +1 -0
  79. package/dist/scope.js +228 -0
  80. package/dist/scope.js.map +1 -0
  81. package/dist/store.d.ts +18 -0
  82. package/dist/store.d.ts.map +1 -0
  83. package/dist/store.js +244 -0
  84. package/dist/store.js.map +1 -0
  85. package/dist/tokens/index.d.ts +12 -0
  86. package/dist/tokens/index.d.ts.map +1 -0
  87. package/dist/tokens/index.js +237 -0
  88. package/dist/tokens/index.js.map +1 -0
  89. package/dist/tokens/tailwind.generated.d.ts +3 -0
  90. package/dist/tokens/tailwind.generated.d.ts.map +1 -0
  91. package/dist/tokens/tailwind.generated.js +610 -0
  92. package/dist/tokens/tailwind.generated.js.map +1 -0
  93. package/dist/tokens/types.d.ts +95 -0
  94. package/dist/tokens/types.d.ts.map +1 -0
  95. package/dist/tokens/types.js +2 -0
  96. package/dist/tokens/types.js.map +1 -0
  97. package/dist/transform.d.ts +22 -0
  98. package/dist/transform.d.ts.map +1 -0
  99. package/dist/transform.js +79 -0
  100. package/dist/transform.js.map +1 -0
  101. package/dist/transition.d.ts +7 -0
  102. package/dist/transition.d.ts.map +1 -0
  103. package/dist/transition.js +355 -0
  104. package/dist/transition.js.map +1 -0
  105. package/dist/types.d.ts +214 -0
  106. package/dist/types.d.ts.map +1 -0
  107. package/dist/types.js +2 -0
  108. package/dist/types.js.map +1 -0
  109. package/dist/utilities.d.ts +109 -0
  110. package/dist/utilities.d.ts.map +1 -0
  111. package/dist/utilities.js +2000 -0
  112. package/dist/utilities.js.map +1 -0
  113. package/dist/variables.d.ts +65 -0
  114. package/dist/variables.d.ts.map +1 -0
  115. package/dist/variables.js +408 -0
  116. package/dist/variables.js.map +1 -0
  117. package/dist/version.d.ts +3 -0
  118. package/dist/version.d.ts.map +1 -0
  119. package/dist/version.js +3 -0
  120. package/dist/version.js.map +1 -0
  121. package/dist/withNitroWind.d.ts +11 -0
  122. package/dist/withNitroWind.d.ts.map +1 -0
  123. package/dist/withNitroWind.js +27 -0
  124. package/dist/withNitroWind.js.map +1 -0
  125. package/package.json +89 -4
  126. package/src/color.ts +164 -0
  127. package/src/core.ts +1248 -0
  128. package/src/css/compile.ts +1198 -0
  129. package/src/css/declarations.ts +1141 -0
  130. package/src/css/index.ts +22 -0
  131. package/src/css/parser.ts +196 -0
  132. package/src/css/tokenizer.ts +227 -0
  133. package/src/css/types.ts +178 -0
  134. package/src/css/values.ts +330 -0
  135. package/src/environment.ts +112 -0
  136. package/src/hooks.ts +190 -0
  137. package/src/index.ts +61 -0
  138. package/src/jsx-dev-runtime.ts +43 -0
  139. package/src/jsx-namespace.ts +23 -0
  140. package/src/jsx-runtime.ts +39 -0
  141. package/src/math.ts +488 -0
  142. package/src/plugin.ts +230 -0
  143. package/src/props.ts +173 -0
  144. package/src/scope.ts +331 -0
  145. package/src/store.ts +288 -0
  146. package/src/tokens/index.ts +252 -0
  147. package/src/tokens/tailwind.generated.ts +613 -0
  148. package/src/tokens/types.ts +99 -0
  149. package/src/transform.ts +115 -0
  150. package/src/transition.ts +414 -0
  151. package/src/types.ts +248 -0
  152. package/src/utilities.ts +1992 -0
  153. package/src/variables.ts +509 -0
  154. package/src/version.ts +2 -0
  155. package/src/withNitroWind.ts +36 -0
@@ -0,0 +1,214 @@
1
+ import type { EdgeInsets, ImageStyleProps, LayoutLength, StyleProps, TextProps, ViewProps } from 'nitro-ui-renderer';
2
+ export type { EdgeInsets, LayoutLength };
3
+ /** NitroUI's `layout` prop. */
4
+ export type LayoutProps = NonNullable<ViewProps['layout']>;
5
+ /** NitroUI's `style` prop, including the `View`-only and `Image`-only keys. */
6
+ export type StyleOutput = StyleProps & Pick<ImageStyleProps, 'tintColor' | 'filter'>;
7
+ /** Typography props that live directly on NitroUI's `Text`. */
8
+ export type TextOutput = Pick<TextProps, 'color' | 'fontSize' | 'fontWeight' | 'lineHeight' | 'textAlign' | 'numberOfLines' | 'ellipsizeMode'>;
9
+ /** What a class string compiles to. Empty groups are omitted. */
10
+ export interface ResolvedClasses {
11
+ layout?: LayoutProps;
12
+ style?: StyleOutput;
13
+ text?: TextOutput;
14
+ }
15
+ /** Describes how a `*ClassName` prop maps its compiled classes onto target component props. */
16
+ export interface ClassNameTargetMap {
17
+ /** Target prop name to receive `resolved.layout` (shallow-merged, explicit wins). */
18
+ readonly layout?: string;
19
+ /** Target prop name to receive `resolved.style` (shallow-merged, explicit wins). */
20
+ readonly style?: string;
21
+ /** When true, `resolved.text` properties are spread onto top-level props (explicit wins). */
22
+ readonly text?: boolean;
23
+ /** Target prop name to receive `Partial<EdgeInsets>` extracted from padding utilities (shallow-merged, explicit wins). */
24
+ readonly edgeInsets?: string;
25
+ }
26
+ /** Custom mapper function that turns compiled classes into props to merge onto the wrapped component. */
27
+ export type ClassNamePropMapper = (resolved: ResolvedClasses) => Record<string, unknown>;
28
+ /**
29
+ * Target for a `*ClassName` prop in `withNitroWind(Component, propMapping)`:
30
+ * - `'layout'` or `'style'`: merges the matching group into that prop.
31
+ * - Any other string: merges `{ ...resolved.layout, ...resolved.style }` into that target prop.
32
+ * - `ClassNameTargetMap`: maps `layout`, `style`, `text`, and/or `edgeInsets` to explicit prop names.
33
+ * - `ClassNamePropMapper`: custom function returning props to merge (explicit props win).
34
+ */
35
+ export type PropMappingTarget = string | ClassNameTargetMap | ClassNamePropMapper;
36
+ /** Maps `*ClassName` prop names to their target prop specifications. */
37
+ export type PropMapping = Readonly<Record<string, PropMappingTarget>>;
38
+ /** Props of a component wrapped with `withNitroWind(Component, propMapping)`. */
39
+ export type WithNitroWindProps<P, K extends string = never> = P & {
40
+ /** Tailwind classes, compiled by NitroWind into `layout` and `style` props. */
41
+ className?: string;
42
+ } & Partial<Record<K, string>>;
43
+ export type ColorScheme = 'light' | 'dark';
44
+ export type Platform = 'ios' | 'android';
45
+ /**
46
+ * Augment this interface via module declaration merging to type custom theme names:
47
+ * ```ts
48
+ * declare module 'nitrowind' {
49
+ * interface NitroWindThemes {
50
+ * premium: true
51
+ * ocean: true
52
+ * }
53
+ * }
54
+ * ```
55
+ */
56
+ export interface NitroWindThemes {
57
+ }
58
+ export type BuiltInThemeName = 'light' | 'dark';
59
+ export type ThemeName = BuiltInThemeName | (keyof NitroWindThemes & string);
60
+ export type ThemePreference = ThemeName | 'system';
61
+ /**
62
+ * Augment this interface via module declaration merging to type custom CSS variable names:
63
+ * ```ts
64
+ * declare module 'nitrowind' {
65
+ * interface NitroWindVariables {
66
+ * '--brand': string
67
+ * '--radius-card': number | string
68
+ * }
69
+ * }
70
+ * ```
71
+ */
72
+ export interface NitroWindVariables {
73
+ }
74
+ export type CSSVariableValue = string | number;
75
+ export type CSSVariableName = (keyof NitroWindVariables & `--${string}`) | (`--${string}` & {});
76
+ export type CSSVariables = {
77
+ [K in keyof NitroWindVariables]?: CSSVariableValue;
78
+ } & {
79
+ [K: `--${string}`]: CSSVariableValue | undefined;
80
+ };
81
+ /** Options for `updateCSSVariables(variables, options)`. */
82
+ export interface UpdateCSSVariablesOptions {
83
+ /** Theme to update. Omit to update the shared layer. */
84
+ readonly theme?: ThemeName;
85
+ }
86
+ /** Registration options for a named theme. */
87
+ export interface ThemeDefinition {
88
+ readonly colorScheme: ColorScheme;
89
+ readonly variables?: Readonly<CSSVariables>;
90
+ }
91
+ /** Snapshot of the active theme, its color scheme, and the configured preference. */
92
+ export interface ThemeState {
93
+ readonly theme: ThemeName;
94
+ readonly colorScheme: ColorScheme;
95
+ readonly preference: ThemePreference;
96
+ }
97
+ /** The environment that variants such as `dark:`, `ios:`, `<theme>:`, `md:`, `portrait:` and `motion-reduce:` are matched against. */
98
+ export interface ResolveContext {
99
+ theme?: ThemeName | (string & {});
100
+ colorScheme?: ColorScheme;
101
+ platform?: Platform;
102
+ reducedMotion?: boolean;
103
+ viewport?: ViewportSize;
104
+ /** The merged variables of the enclosing variable scopes inside the nearest `ScopedTheme`. They win over the theme's and the shared layer's values. */
105
+ variables?: Readonly<CSSVariables>;
106
+ /**
107
+ * The merged variables of variable scopes outside the nearest `ScopedTheme`.
108
+ * The theme's own values win over these; variables not declared by the theme inherit from here
109
+ * before falling back to the shared layer.
110
+ */
111
+ outerVariables?: Readonly<CSSVariables>;
112
+ }
113
+ /** What to do with a class NitroWind can't map onto NitroUI. */
114
+ export type UnknownClassBehavior = 'warn' | 'ignore' | 'throw';
115
+ /** Which context channels a class string depends on. */
116
+ export interface ClassDependencies {
117
+ readonly colorScheme: boolean;
118
+ readonly themes: readonly string[];
119
+ readonly reducedMotion: boolean;
120
+ /** Sorted unique breakpoint widths (in points) tested by this class string. */
121
+ readonly breakpoints: readonly number[];
122
+ /** Sorted unique CSS variable names read by this class string. */
123
+ readonly variables: readonly string[];
124
+ readonly orientation: boolean;
125
+ /** True when the class string uses viewport-relative units (`vw`/`vh`) or `*-screen` sizing. */
126
+ readonly viewport: boolean;
127
+ }
128
+ export interface ViewportSize {
129
+ readonly width: number;
130
+ readonly height: number;
131
+ }
132
+ export type Unsubscribe = () => void;
133
+ export type ThemeTransitionStyle = 'fade' | 'circle' | 'slide' | 'blur';
134
+ export type ThemeTransitionDirection = 'left' | 'right';
135
+ /** Transition values accepted by `setTheme` and `configure({ transition })`. */
136
+ export type ThemeTransition = ThemeTransitionStyle | false;
137
+ /** A point in root-view coordinates (points on iOS, dp on Android). */
138
+ export interface ThemeTransitionPoint {
139
+ readonly x: number;
140
+ readonly y: number;
141
+ }
142
+ /** A NitroUI `View` (or any object exposing `getFrameInWindow`) whose center is used as a transition origin. */
143
+ export interface ThemeTransitionOriginView {
144
+ getFrameInWindow(): {
145
+ readonly x: number;
146
+ readonly y: number;
147
+ readonly width: number;
148
+ readonly height: number;
149
+ };
150
+ }
151
+ /** Origin for a `'circle'` theme transition: a point in root-view points, or a NitroUI `View`. */
152
+ export type ThemeTransitionOrigin = ThemeTransitionPoint | ThemeTransitionOriginView;
153
+ /** Default transition settings for `configure({ transition })`. */
154
+ export interface ThemeTransitionConfig {
155
+ /** Default transition style. Defaults to `false` (no animation). */
156
+ readonly style?: ThemeTransition;
157
+ /** Default transition duration in milliseconds. Defaults to `400`. */
158
+ readonly duration?: number;
159
+ }
160
+ /** Per-call options for `setTheme(preference, options)`. */
161
+ export interface SetThemeOptions {
162
+ /** Override the configured transition style (`'fade' | 'circle' | 'slide' | 'blur'` or `false` for instant). */
163
+ readonly transition?: ThemeTransition;
164
+ /** Override the configured transition duration in milliseconds. */
165
+ readonly duration?: number;
166
+ /** Starting point for `'circle'` transitions: a root-view point or a NitroUI `View` (uses its center). */
167
+ readonly origin?: ThemeTransitionOrigin;
168
+ /** Slide direction for `'slide'` transitions (`'left'` or `'right'`). Defaults to `'left'`. */
169
+ readonly direction?: ThemeTransitionDirection;
170
+ }
171
+ export interface CaptureCoverOptions {
172
+ readonly style: ThemeTransitionStyle;
173
+ readonly duration: number;
174
+ readonly origin?: ThemeTransitionPoint;
175
+ readonly direction?: ThemeTransitionDirection;
176
+ }
177
+ /** Optional native capabilities provided by `nitrowind-native`. */
178
+ export interface NitroWindNative {
179
+ /** Package version of `nitrowind-native`, checked against `nitrowind` in development. */
180
+ readonly version: string;
181
+ /** Whether the user has enabled "reduce motion" in OS settings. */
182
+ getReducedMotion(): boolean;
183
+ /** Subscribes to changes in the OS "reduce motion" setting. */
184
+ subscribeReducedMotion(listener: (reducedMotion: boolean) => void): Unsubscribe;
185
+ /** Captures the current screen into a native cover overlay before a theme switch. */
186
+ captureCover?(options: CaptureCoverOptions): boolean | Promise<boolean>;
187
+ /** Animates the native cover overlay away and removes it. */
188
+ finishCover?(): Promise<void>;
189
+ /** Immediately removes any active native cover overlay. */
190
+ cancelCover?(): void;
191
+ /** Reports whether a native cover overlay is currently on screen. */
192
+ isCoverActive?(): boolean;
193
+ }
194
+ /** Platform and runtime signals injected into a NitroWind instance. */
195
+ export interface NitroWindEnvironment {
196
+ readonly platform: Platform;
197
+ getColorScheme(): ColorScheme;
198
+ setColorScheme(colorScheme: ColorScheme | 'auto'): void;
199
+ subscribeColorScheme(listener: (colorScheme: ColorScheme) => void): Unsubscribe;
200
+ getViewportSize(): ViewportSize | undefined;
201
+ subscribeViewportSize(listener: (size: ViewportSize) => void): Unsubscribe;
202
+ /** Optional React hook called by the render wrapper to bind to the host root view controller. */
203
+ readonly useRoot?: () => void;
204
+ /** Optional frame scheduler used to wait for commit + paint before animating a cover away. */
205
+ readonly scheduleFrame?: (callback: () => void) => Unsubscribe;
206
+ /**
207
+ * Optional safety timeout (ms) before a stuck transition cover is removed automatically. Defaults to `1000`.
208
+ * It applies to each step: the capture, the re-render and scheme change, and the first frame in the new theme.
209
+ * The finish animation gets its duration plus this timeout.
210
+ */
211
+ readonly transitionTimeoutMs?: number;
212
+ readonly native?: NitroWindNative;
213
+ }
214
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAEpH,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,CAAA;AAExC,+BAA+B;AAC/B,MAAM,MAAM,WAAW,GAAG,WAAW,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAA;AAE1D,+EAA+E;AAC/E,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,IAAI,CAAC,eAAe,EAAE,WAAW,GAAG,QAAQ,CAAC,CAAA;AAEpF,+DAA+D;AAC/D,MAAM,MAAM,UAAU,GAAG,IAAI,CAC3B,SAAS,EACT,OAAO,GAAG,UAAU,GAAG,YAAY,GAAG,YAAY,GAAG,WAAW,GAAG,eAAe,GAAG,eAAe,CACrG,CAAA;AAED,iEAAiE;AACjE,MAAM,WAAW,eAAe;IAC9B,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,KAAK,CAAC,EAAE,WAAW,CAAA;IACnB,IAAI,CAAC,EAAE,UAAU,CAAA;CAClB;AAED,+FAA+F;AAC/F,MAAM,WAAW,kBAAkB;IACjC,qFAAqF;IACrF,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACxB,oFAAoF;IACpF,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IACvB,6FAA6F;IAC7F,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAA;IACvB,0HAA0H;IAC1H,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAC7B;AAED,yGAAyG;AACzG,MAAM,MAAM,mBAAmB,GAAG,CAAC,Q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G,IAAI,CAAA;IACvD,oBAAoB,CAAC,QAAQ,EAAE,CAAC,WAAW,EAAE,WAAW,KAAK,IAAI,GAAG,WAAW,CAAA;IAC/E,eAAe,IAAI,YAAY,GAAG,SAAS,CAAA;IAC3C,qBAAqB,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,IAAI,GAAG,WAAW,CAAA;IAC1E,iGAAiG;IACjG,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IAC7B,8FAA8F;IAC9F,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,WAAW,CAAA;IAC9D;;;;OAIG;IACH,QAAQ,CAAC,mBAAmB,CAAC,EAAE,MAAM,CAAA;IACrC,QAAQ,CAAC,MAAM,CAAC,EAAE,eAAe,CAAA;CAClC"}
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,109 @@
1
+ /**
2
+ * The table of Tailwind utilities NitroWind understands, and how each one maps
3
+ * onto NitroUI's `layout`, `style` and `Text` props.
4
+ */
5
+ import type { Corner } from 'nitro-ui-renderer';
6
+ import { type PackedColor } from './color';
7
+ import type { TokenBoxShadow, TokenDropShadow, Tokens } from './tokens/types';
8
+ import type { ViewportSize } from './types';
9
+ type Bag = Record<string, unknown>;
10
+ export interface VariableError {
11
+ readonly kind: 'missing' | 'cycle' | 'calc' | 'invalid';
12
+ readonly variable?: string;
13
+ readonly value?: string;
14
+ readonly expected?: string;
15
+ readonly reason?: string;
16
+ }
17
+ export interface VariableResolver {
18
+ expand(expr: string): {
19
+ readonly value: string;
20
+ readonly variables: readonly string[];
21
+ } | null;
22
+ /**
23
+ * Looks up a single CSS variable by name if it is currently defined.
24
+ * Returns `null` without reporting an error when the variable does not exist;
25
+ * reports cycle/calc errors if it exists and fails to expand.
26
+ */
27
+ tryVariable(name: string): {
28
+ readonly value: string;
29
+ readonly variables: readonly string[];
30
+ } | null;
31
+ reportError(error: VariableError): void;
32
+ hasError(): boolean;
33
+ isMissingViewport?(): boolean;
34
+ }
35
+ /** Mutable state collected while applying the classes of one class string. */
36
+ export interface Draft {
37
+ layout: Bag;
38
+ style: Bag;
39
+ text: Bag;
40
+ /** Corners named by side-specific `rounded-t-*` style classes. */
41
+ corners?: Set<Corner>;
42
+ gradient?: {
43
+ start?: {
44
+ x: number;
45
+ y: number;
46
+ };
47
+ end?: {
48
+ x: number;
49
+ y: number;
50
+ };
51
+ from?: PackedColor;
52
+ via?: PackedColor;
53
+ to?: PackedColor;
54
+ };
55
+ shadow?: TokenBoxShadow[];
56
+ insetShadow?: TokenBoxShadow[];
57
+ shadowColor?: {
58
+ color: PackedColor;
59
+ explicitAlpha: boolean;
60
+ };
61
+ insetShadowColor?: {
62
+ color: PackedColor;
63
+ explicitAlpha: boolean;
64
+ };
65
+ dropShadow?: TokenDropShadow[];
66
+ /** Line height from `leading-*` or `text-lg/7`. It wins over a font size's default line height. */
67
+ leading?: Leading;
68
+ /** The default line height of the last `text-<size>` class. */
69
+ sizeLineHeight?: number;
70
+ }
71
+ export declare function createDraft(): Draft;
72
+ type Handler = (value: string, draft: Draft, tokens: Tokens, negative: boolean, vars?: VariableResolver, viewport?: ViewportSize) => boolean;
73
+ export type Leading = {
74
+ points: number;
75
+ } | {
76
+ multiplier: number;
77
+ };
78
+ type Static = (draft: Draft) => void;
79
+ /** Classes that take no value. */
80
+ export declare const staticUtilities: Record<string, Static>;
81
+ /** Classes that take a value, keyed by prefix (`p` in `p-4`). The empty value is the bare class (`rounded`). */
82
+ export declare const functionalUtilities: Record<string, Handler>;
83
+ /**
84
+ * Extracts all CSS variable names a utility depends on:
85
+ * - explicit `var(--x)` / `(--x)` references (including opacity/leading modifiers),
86
+ * - variables referenced by matching config tokens (e.g. `tokens.extend.colors.primary = 'var(--x)'`),
87
+ * - implicit namespace variables (`--color-*`, `--radius-*`, `--text-*`, `--font-weight-*`,
88
+ * `--leading-*`, `--shadow-*`) when a token lookup finds nothing in `tokens`.
89
+ */
90
+ export declare function extractUtilityVariableNames(utility: string, tokens: Tokens): string[];
91
+ /** Returns true when `utility` directly references viewport dimensions (`*-screen` or `vw`/`vh`). */
92
+ export declare function utilityUsesViewport(utility: string): boolean;
93
+ /**
94
+ * Applies one utility (no variants) to the draft. Returns false when the class is unknown.
95
+ */
96
+ export declare function applyUtility(utility: string, draft: Draft, tokens: Tokens, vars?: VariableResolver, viewport?: ViewportSize): boolean;
97
+ /** Turns the draft into NitroUI props, resolving classes that depend on each other. */
98
+ export declare function finalizeDraft(draft: Draft): void;
99
+ export interface UtilityConflict {
100
+ readonly group: string;
101
+ readonly overrides?: readonly string[];
102
+ }
103
+ /**
104
+ * Classifies one utility (without variants or `!`) into its conflict group and
105
+ * any sub-groups it overrides, or returns `null` for unknown/unrecognized tokens.
106
+ */
107
+ export declare function classifyUtility(utility: string, tokens: Tokens): UtilityConflict | null;
108
+ export {};
109
+ //# sourceMappingURL=utilities.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../src/utilities.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAiB,KAAK,WAAW,EAAyB,MAAM,SAAS,CAAA;AAEhF,OAAO,KAAK,EAAmB,cAAc,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAC9F,OAAO,KAAK,EAAgB,YAAY,EAAE,MAAM,SAAS,CAAA;AAGzD,KAAK,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAKlC,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,SA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