@aurora-ds/theme 3.3.0 → 3.5.0-dev
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/README.md +640 -79
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +230 -8
- package/dist/index.d.ts +230 -8
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -111,8 +111,31 @@ declare const ThemeProvider: ({ theme, disableTransitionsOnChange, transitionDur
|
|
|
111
111
|
*/
|
|
112
112
|
declare const useTheme: () => _InternalTheme;
|
|
113
113
|
|
|
114
|
-
/**
|
|
115
|
-
|
|
114
|
+
/**
|
|
115
|
+
* A responsive value: either a raw CSS value, or an object whose keys are
|
|
116
|
+
* the breakpoint names declared on `theme.breakpoints` (plus the special
|
|
117
|
+
* `base` key for the unmediated value).
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```ts
|
|
121
|
+
* padding: { base: 8, md: 16, lg: 24 }
|
|
122
|
+
* color: { base: 'red', md: 'blue' }
|
|
123
|
+
* ```
|
|
124
|
+
*
|
|
125
|
+
* The breakpoint keys are intentionally typed as a free `string` index so
|
|
126
|
+
* that any user-defined breakpoint (e.g. `desktop`, `wide`, `phone`) is
|
|
127
|
+
* accepted without coupling the type to a hardcoded list.
|
|
128
|
+
*/
|
|
129
|
+
type ResponsiveValue<T> = T | {
|
|
130
|
+
base?: T;
|
|
131
|
+
[breakpoint: string]: T | undefined;
|
|
132
|
+
};
|
|
133
|
+
/** Maps a CSSProperties-like object so each value can also be a {@link ResponsiveValue}. */
|
|
134
|
+
type ResponsiveCSSProperties = {
|
|
135
|
+
[K in keyof CSSProperties]?: CSSProperties[K] | ResponsiveValue<CSSProperties[K]>;
|
|
136
|
+
};
|
|
137
|
+
/** CSS properties with support for pseudo-classes, media/container queries, complex selectors and responsive token values. */
|
|
138
|
+
type StyleWithPseudos = ResponsiveCSSProperties & {
|
|
116
139
|
[key: `:${string}`]: CSSProperties;
|
|
117
140
|
[key: `@media ${string}`]: CSSProperties;
|
|
118
141
|
[key: `@container ${string}`]: CSSProperties;
|
|
@@ -131,6 +154,27 @@ type FontFaceOptions = {
|
|
|
131
154
|
unicodeRange?: string;
|
|
132
155
|
};
|
|
133
156
|
|
|
157
|
+
/**
|
|
158
|
+
* Options for {@link createStyles}.
|
|
159
|
+
*/
|
|
160
|
+
type CreateStylesOptions = {
|
|
161
|
+
/**
|
|
162
|
+
* Explicit, stable module id used to namespace generated class names.
|
|
163
|
+
*
|
|
164
|
+
* **Strongly recommended in production** to avoid relying on
|
|
165
|
+
* `Error().stack` parsing, which is fragile across engines and
|
|
166
|
+
* unreliable after minification. When provided, this id is used as-is
|
|
167
|
+
* (after kebab-casing) and guarantees deterministic class names across
|
|
168
|
+
* builds, SSR ↔ CSR boundaries and HMR cycles.
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* ```ts
|
|
172
|
+
* // Button.styles.ts
|
|
173
|
+
* export const styles = createStyles((theme) => ({ ... }), { id: 'button' })
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
id?: string;
|
|
177
|
+
};
|
|
134
178
|
/**
|
|
135
179
|
* Creates styles with theme support. Type is inferred from ThemeRegistry.
|
|
136
180
|
* Supports pseudo-classes, media queries, and complex selectors.
|
|
@@ -139,6 +183,8 @@ type FontFaceOptions = {
|
|
|
139
183
|
* Theme values are automatically updated when ThemeProvider's theme changes.
|
|
140
184
|
*
|
|
141
185
|
* @param stylesOrCreator - Static styles object or function that receives theme
|
|
186
|
+
* @param options - Optional configuration. Pass `{ id }` to opt-out of stack-trace based
|
|
187
|
+
* module identification (recommended for production / SSR setups).
|
|
142
188
|
*
|
|
143
189
|
* @example
|
|
144
190
|
* ```tsx
|
|
@@ -149,13 +195,116 @@ type FontFaceOptions = {
|
|
|
149
195
|
* }
|
|
150
196
|
* }))
|
|
151
197
|
*
|
|
152
|
-
* //
|
|
153
|
-
*
|
|
154
|
-
* return <div className={styles.root}>Hello</div>
|
|
155
|
-
* }
|
|
198
|
+
* // Or with an explicit id (recommended in production):
|
|
199
|
+
* const styles = createStyles((theme) => ({ ... }), { id: 'my-component' })
|
|
156
200
|
* ```
|
|
157
201
|
*/
|
|
158
|
-
declare const createStyles: <T extends Record<string, StyleWithPseudos | StyleFunction> = Record<string, StyleWithPseudos | StyleFunction>>(stylesOrCreator: T | ((theme: _InternalTheme) => T)) => { [K in keyof T]: T[K] extends (...args: infer TArgs) => StyleWithPseudos ? (...args: TArgs) => string : string; };
|
|
202
|
+
declare const createStyles: <T extends Record<string, StyleWithPseudos | StyleFunction> = Record<string, StyleWithPseudos | StyleFunction>>(stylesOrCreator: T | ((theme: _InternalTheme) => T), options?: CreateStylesOptions) => { [K in keyof T]: T[K] extends (...args: infer TArgs) => StyleWithPseudos ? (...args: TArgs) => string : string; };
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* A group of variant values (e.g. `{ sm: {...}, md: {...}, lg: {...} }`).
|
|
206
|
+
* @internal
|
|
207
|
+
*/
|
|
208
|
+
type VariantValues = Record<string, StyleWithPseudos>;
|
|
209
|
+
/**
|
|
210
|
+
* A map of variant groups (e.g. `{ size: {...}, color: {...} }`).
|
|
211
|
+
* @internal
|
|
212
|
+
*/
|
|
213
|
+
type VariantGroups = Record<string, VariantValues>;
|
|
214
|
+
/**
|
|
215
|
+
* Props accepted by a variant function. Each key matches a variant group,
|
|
216
|
+
* each value must be one of the declared variant values. All keys are
|
|
217
|
+
* optional — missing keys fall back to `defaultVariants`.
|
|
218
|
+
*/
|
|
219
|
+
type VariantProps<V extends VariantGroups> = {
|
|
220
|
+
[K in keyof V]?: keyof V[K];
|
|
221
|
+
};
|
|
222
|
+
/**
|
|
223
|
+
* Compound variant definition: applies extra styles when ALL listed
|
|
224
|
+
* variant conditions match.
|
|
225
|
+
*/
|
|
226
|
+
type CompoundVariant<V extends VariantGroups> = VariantProps<V> & {
|
|
227
|
+
styles: StyleWithPseudos;
|
|
228
|
+
};
|
|
229
|
+
/**
|
|
230
|
+
* Configuration object for {@link createVariants}.
|
|
231
|
+
*/
|
|
232
|
+
type CreateVariantsConfig<V extends VariantGroups> = {
|
|
233
|
+
/** Always-applied base styles. */
|
|
234
|
+
base?: StyleWithPseudos;
|
|
235
|
+
/** Variant groups (e.g. `size`, `variant`, `intent`). */
|
|
236
|
+
variants?: V;
|
|
237
|
+
/** Default value picked when a prop is omitted. */
|
|
238
|
+
defaultVariants?: VariantProps<V>;
|
|
239
|
+
/**
|
|
240
|
+
* Extra styles applied when ALL listed conditions match.
|
|
241
|
+
*
|
|
242
|
+
* @example
|
|
243
|
+
* ```ts
|
|
244
|
+
* compoundVariants: [
|
|
245
|
+
* { size: 'sm', variant: 'ghost', styles: { fontSize: 10 } }
|
|
246
|
+
* ]
|
|
247
|
+
* ```
|
|
248
|
+
*/
|
|
249
|
+
compoundVariants?: CompoundVariant<V>[];
|
|
250
|
+
};
|
|
251
|
+
/**
|
|
252
|
+
* Function returned by {@link createVariants}. Given partial variant props
|
|
253
|
+
* (all optional thanks to `defaultVariants`), it returns a single
|
|
254
|
+
* space-separated class name string ready to drop on a DOM node. Falsy
|
|
255
|
+
* extra class names can be appended via the second `className` argument.
|
|
256
|
+
*/
|
|
257
|
+
type VariantFn<V extends VariantGroups> = (props?: VariantProps<V>, className?: string | false | null | undefined) => string;
|
|
258
|
+
/**
|
|
259
|
+
* Builds variant-aware components without any wrapper React component.
|
|
260
|
+
*
|
|
261
|
+
* Inspired by `cva` (class-variance-authority) and Stitches, but built
|
|
262
|
+
* directly on top of {@link createStyles} so it benefits from the same
|
|
263
|
+
* theming, HMR, SSR and per-module stylesheet behavior.
|
|
264
|
+
*
|
|
265
|
+
* The returned function is a pure className builder — it has zero
|
|
266
|
+
* runtime cost beyond a few string concatenations and Map lookups.
|
|
267
|
+
*
|
|
268
|
+
* @param configOrCreator - Static config object, or a function receiving the theme.
|
|
269
|
+
* @param options - Optional `{ id }` namespacing (recommended in production, see {@link createStyles}).
|
|
270
|
+
*
|
|
271
|
+
* @example
|
|
272
|
+
* ```ts
|
|
273
|
+
* // Button.styles.ts
|
|
274
|
+
* import { createVariants } from '@aurora-ds/theme'
|
|
275
|
+
*
|
|
276
|
+
* export const button = createVariants((theme) => ({
|
|
277
|
+
* base: {
|
|
278
|
+
* display: 'inline-flex',
|
|
279
|
+
* alignItems: 'center',
|
|
280
|
+
* borderRadius: theme.radius.md,
|
|
281
|
+
* cursor: 'pointer',
|
|
282
|
+
* },
|
|
283
|
+
* variants: {
|
|
284
|
+
* size: {
|
|
285
|
+
* sm: { padding: theme.spacing.xs, fontSize: 12 },
|
|
286
|
+
* md: { padding: theme.spacing.sm, fontSize: 14 },
|
|
287
|
+
* lg: { padding: theme.spacing.md, fontSize: 16 },
|
|
288
|
+
* },
|
|
289
|
+
* variant: {
|
|
290
|
+
* primary: { backgroundColor: theme.colors.primary, color: 'white' },
|
|
291
|
+
* ghost: { backgroundColor: 'transparent', color: theme.colors.text },
|
|
292
|
+
* },
|
|
293
|
+
* },
|
|
294
|
+
* defaultVariants: { size: 'md', variant: 'primary' },
|
|
295
|
+
* compoundVariants: [
|
|
296
|
+
* { size: 'sm', variant: 'ghost', styles: { fontWeight: 600 } }
|
|
297
|
+
* ],
|
|
298
|
+
* }), { id: 'button' })
|
|
299
|
+
*
|
|
300
|
+
* // Usage
|
|
301
|
+
* <button className={button({ size: 'lg' })} />
|
|
302
|
+
* <button className={button({ variant: 'ghost' }, props.className)} />
|
|
303
|
+
* ```
|
|
304
|
+
*/
|
|
305
|
+
declare const createVariants: <V extends VariantGroups>(configOrCreator: CreateVariantsConfig<V> | ((theme: _InternalTheme) => CreateVariantsConfig<V>), options?: {
|
|
306
|
+
id?: string;
|
|
307
|
+
}) => VariantFn<V>;
|
|
159
308
|
|
|
160
309
|
/** Creates and injects a @keyframes rule, returns the animation name */
|
|
161
310
|
declare const keyframes: (frames: Record<string, CSSProperties>) => string;
|
|
@@ -173,6 +322,79 @@ declare const cssVariables: <T extends Record<string, string | number>>(variable
|
|
|
173
322
|
inject?: boolean;
|
|
174
323
|
}) => { [K in keyof T]: string; };
|
|
175
324
|
|
|
325
|
+
/**
|
|
326
|
+
* A block accepted by {@link globalStyles}. Same shape as
|
|
327
|
+
* {@link StyleWithPseudos} but additionally allows arbitrary string keys
|
|
328
|
+
* so that nested at-rules (e.g. `@media`) can declare their own child
|
|
329
|
+
* selectors (`body`, `*`, `.foo`, …).
|
|
330
|
+
*/
|
|
331
|
+
type GlobalStyleBlock = StyleWithPseudos & {
|
|
332
|
+
[selector: string]: unknown;
|
|
333
|
+
};
|
|
334
|
+
/**
|
|
335
|
+
* Injects global, top-level CSS rules. Each key is a CSS selector
|
|
336
|
+
* (`body`, `*`, `:root`, `.foo > .bar`, `@media (...)`, etc.) and each
|
|
337
|
+
* value supports the same nested-pseudo / `&` / at-rule syntax as
|
|
338
|
+
* {@link createStyles}.
|
|
339
|
+
*
|
|
340
|
+
* Rules are written into the shared global Aurora stylesheet and persist
|
|
341
|
+
* for the lifetime of the document. Calling `globalStyles` multiple times
|
|
342
|
+
* appends new rules — it is the caller's responsibility to call it once
|
|
343
|
+
* (typically at app bootstrap) per logical block.
|
|
344
|
+
*
|
|
345
|
+
* @example
|
|
346
|
+
* ```ts
|
|
347
|
+
* globalStyles({
|
|
348
|
+
* 'html, body': {
|
|
349
|
+
* margin: 0,
|
|
350
|
+
* padding: 0,
|
|
351
|
+
* fontFamily: 'system-ui, sans-serif',
|
|
352
|
+
* },
|
|
353
|
+
* 'a': {
|
|
354
|
+
* color: 'inherit',
|
|
355
|
+
* ':hover': { textDecoration: 'underline' },
|
|
356
|
+
* },
|
|
357
|
+
* '@media (prefers-reduced-motion: reduce)': {
|
|
358
|
+
* '*': { animation: 'none', transition: 'none' },
|
|
359
|
+
* },
|
|
360
|
+
* })
|
|
361
|
+
* ```
|
|
362
|
+
*/
|
|
363
|
+
declare const globalStyles: (rules: Record<string, GlobalStyleBlock>) => void;
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Accepted argument types for {@link cx}.
|
|
367
|
+
*
|
|
368
|
+
* - Strings are kept (when truthy).
|
|
369
|
+
* - `false`, `null`, `undefined` and empty strings are skipped, allowing
|
|
370
|
+
* conditional patterns like `cx(styles.base, isActive && styles.active)`.
|
|
371
|
+
*/
|
|
372
|
+
type CxArg = string | false | null | undefined;
|
|
373
|
+
/**
|
|
374
|
+
* Conditionally joins class names into a single space-separated string.
|
|
375
|
+
*
|
|
376
|
+
* Lightweight, dependency-free alternative to `clsx` / `classnames` tailored
|
|
377
|
+
* for usage with {@link createStyles}. Falsy values are filtered out so you
|
|
378
|
+
* can compose variants inline.
|
|
379
|
+
*
|
|
380
|
+
* @example
|
|
381
|
+
* ```tsx
|
|
382
|
+
* import { cx } from '@aurora-ds/theme'
|
|
383
|
+
*
|
|
384
|
+
* <button
|
|
385
|
+
* className={cx(
|
|
386
|
+
* styles.base,
|
|
387
|
+
* styles[size],
|
|
388
|
+
* styles[variant],
|
|
389
|
+
* fullWidth && styles.fullWidth,
|
|
390
|
+
* loading && styles.loading,
|
|
391
|
+
* className,
|
|
392
|
+
* )}
|
|
393
|
+
* />
|
|
394
|
+
* ```
|
|
395
|
+
*/
|
|
396
|
+
declare const cx: (...args: CxArg[]) => string;
|
|
397
|
+
|
|
176
398
|
/** SSR: Returns all collected CSS rules as a single string */
|
|
177
399
|
declare const getSSRStyles: () => string;
|
|
178
400
|
/** SSR: Returns styles wrapped in a style tag */
|
|
@@ -182,4 +404,4 @@ declare const clearSSRRules: () => void;
|
|
|
182
404
|
/** SSR: Returns raw CSS rules as an array */
|
|
183
405
|
declare const getSSRRulesArray: () => string[];
|
|
184
406
|
|
|
185
|
-
export { type FontFaceOptions, type StyleWithPseudos, ThemeProvider, type ThemeRegistry, clearSSRRules, colors, createStyles, createTheme, cssVar, cssVariables, fontFace, getSSRRulesArray, getSSRStyleTag, getSSRStyles, injectCssVariables, keyframes, useTheme };
|
|
407
|
+
export { type CompoundVariant, type CreateStylesOptions, type CreateVariantsConfig, type CxArg, type FontFaceOptions, type GlobalStyleBlock, type ResponsiveCSSProperties, type ResponsiveValue, type StyleWithPseudos, ThemeProvider, type ThemeRegistry, type VariantFn, type VariantProps, clearSSRRules, colors, createStyles, createTheme, createVariants, cssVar, cssVariables, cx, fontFace, getSSRRulesArray, getSSRStyleTag, getSSRStyles, globalStyles, injectCssVariables, keyframes, useTheme };
|
package/dist/index.d.ts
CHANGED
|
@@ -111,8 +111,31 @@ declare const ThemeProvider: ({ theme, disableTransitionsOnChange, transitionDur
|
|
|
111
111
|
*/
|
|
112
112
|
declare const useTheme: () => _InternalTheme;
|
|
113
113
|
|
|
114
|
-
/**
|
|
115
|
-
|
|
114
|
+
/**
|
|
115
|
+
* A responsive value: either a raw CSS value, or an object whose keys are
|
|
116
|
+
* the breakpoint names declared on `theme.breakpoints` (plus the special
|
|
117
|
+
* `base` key for the unmediated value).
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```ts
|
|
121
|
+
* padding: { base: 8, md: 16, lg: 24 }
|
|
122
|
+
* color: { base: 'red', md: 'blue' }
|
|
123
|
+
* ```
|
|
124
|
+
*
|
|
125
|
+
* The breakpoint keys are intentionally typed as a free `string` index so
|
|
126
|
+
* that any user-defined breakpoint (e.g. `desktop`, `wide`, `phone`) is
|
|
127
|
+
* accepted without coupling the type to a hardcoded list.
|
|
128
|
+
*/
|
|
129
|
+
type ResponsiveValue<T> = T | {
|
|
130
|
+
base?: T;
|
|
131
|
+
[breakpoint: string]: T | undefined;
|
|
132
|
+
};
|
|
133
|
+
/** Maps a CSSProperties-like object so each value can also be a {@link ResponsiveValue}. */
|
|
134
|
+
type ResponsiveCSSProperties = {
|
|
135
|
+
[K in keyof CSSProperties]?: CSSProperties[K] | ResponsiveValue<CSSProperties[K]>;
|
|
136
|
+
};
|
|
137
|
+
/** CSS properties with support for pseudo-classes, media/container queries, complex selectors and responsive token values. */
|
|
138
|
+
type StyleWithPseudos = ResponsiveCSSProperties & {
|
|
116
139
|
[key: `:${string}`]: CSSProperties;
|
|
117
140
|
[key: `@media ${string}`]: CSSProperties;
|
|
118
141
|
[key: `@container ${string}`]: CSSProperties;
|
|
@@ -131,6 +154,27 @@ type FontFaceOptions = {
|
|
|
131
154
|
unicodeRange?: string;
|
|
132
155
|
};
|
|
133
156
|
|
|
157
|
+
/**
|
|
158
|
+
* Options for {@link createStyles}.
|
|
159
|
+
*/
|
|
160
|
+
type CreateStylesOptions = {
|
|
161
|
+
/**
|
|
162
|
+
* Explicit, stable module id used to namespace generated class names.
|
|
163
|
+
*
|
|
164
|
+
* **Strongly recommended in production** to avoid relying on
|
|
165
|
+
* `Error().stack` parsing, which is fragile across engines and
|
|
166
|
+
* unreliable after minification. When provided, this id is used as-is
|
|
167
|
+
* (after kebab-casing) and guarantees deterministic class names across
|
|
168
|
+
* builds, SSR ↔ CSR boundaries and HMR cycles.
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* ```ts
|
|
172
|
+
* // Button.styles.ts
|
|
173
|
+
* export const styles = createStyles((theme) => ({ ... }), { id: 'button' })
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
id?: string;
|
|
177
|
+
};
|
|
134
178
|
/**
|
|
135
179
|
* Creates styles with theme support. Type is inferred from ThemeRegistry.
|
|
136
180
|
* Supports pseudo-classes, media queries, and complex selectors.
|
|
@@ -139,6 +183,8 @@ type FontFaceOptions = {
|
|
|
139
183
|
* Theme values are automatically updated when ThemeProvider's theme changes.
|
|
140
184
|
*
|
|
141
185
|
* @param stylesOrCreator - Static styles object or function that receives theme
|
|
186
|
+
* @param options - Optional configuration. Pass `{ id }` to opt-out of stack-trace based
|
|
187
|
+
* module identification (recommended for production / SSR setups).
|
|
142
188
|
*
|
|
143
189
|
* @example
|
|
144
190
|
* ```tsx
|
|
@@ -149,13 +195,116 @@ type FontFaceOptions = {
|
|
|
149
195
|
* }
|
|
150
196
|
* }))
|
|
151
197
|
*
|
|
152
|
-
* //
|
|
153
|
-
*
|
|
154
|
-
* return <div className={styles.root}>Hello</div>
|
|
155
|
-
* }
|
|
198
|
+
* // Or with an explicit id (recommended in production):
|
|
199
|
+
* const styles = createStyles((theme) => ({ ... }), { id: 'my-component' })
|
|
156
200
|
* ```
|
|
157
201
|
*/
|
|
158
|
-
declare const createStyles: <T extends Record<string, StyleWithPseudos | StyleFunction> = Record<string, StyleWithPseudos | StyleFunction>>(stylesOrCreator: T | ((theme: _InternalTheme) => T)) => { [K in keyof T]: T[K] extends (...args: infer TArgs) => StyleWithPseudos ? (...args: TArgs) => string : string; };
|
|
202
|
+
declare const createStyles: <T extends Record<string, StyleWithPseudos | StyleFunction> = Record<string, StyleWithPseudos | StyleFunction>>(stylesOrCreator: T | ((theme: _InternalTheme) => T), options?: CreateStylesOptions) => { [K in keyof T]: T[K] extends (...args: infer TArgs) => StyleWithPseudos ? (...args: TArgs) => string : string; };
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* A group of variant values (e.g. `{ sm: {...}, md: {...}, lg: {...} }`).
|
|
206
|
+
* @internal
|
|
207
|
+
*/
|
|
208
|
+
type VariantValues = Record<string, StyleWithPseudos>;
|
|
209
|
+
/**
|
|
210
|
+
* A map of variant groups (e.g. `{ size: {...}, color: {...} }`).
|
|
211
|
+
* @internal
|
|
212
|
+
*/
|
|
213
|
+
type VariantGroups = Record<string, VariantValues>;
|
|
214
|
+
/**
|
|
215
|
+
* Props accepted by a variant function. Each key matches a variant group,
|
|
216
|
+
* each value must be one of the declared variant values. All keys are
|
|
217
|
+
* optional — missing keys fall back to `defaultVariants`.
|
|
218
|
+
*/
|
|
219
|
+
type VariantProps<V extends VariantGroups> = {
|
|
220
|
+
[K in keyof V]?: keyof V[K];
|
|
221
|
+
};
|
|
222
|
+
/**
|
|
223
|
+
* Compound variant definition: applies extra styles when ALL listed
|
|
224
|
+
* variant conditions match.
|
|
225
|
+
*/
|
|
226
|
+
type CompoundVariant<V extends VariantGroups> = VariantProps<V> & {
|
|
227
|
+
styles: StyleWithPseudos;
|
|
228
|
+
};
|
|
229
|
+
/**
|
|
230
|
+
* Configuration object for {@link createVariants}.
|
|
231
|
+
*/
|
|
232
|
+
type CreateVariantsConfig<V extends VariantGroups> = {
|
|
233
|
+
/** Always-applied base styles. */
|
|
234
|
+
base?: StyleWithPseudos;
|
|
235
|
+
/** Variant groups (e.g. `size`, `variant`, `intent`). */
|
|
236
|
+
variants?: V;
|
|
237
|
+
/** Default value picked when a prop is omitted. */
|
|
238
|
+
defaultVariants?: VariantProps<V>;
|
|
239
|
+
/**
|
|
240
|
+
* Extra styles applied when ALL listed conditions match.
|
|
241
|
+
*
|
|
242
|
+
* @example
|
|
243
|
+
* ```ts
|
|
244
|
+
* compoundVariants: [
|
|
245
|
+
* { size: 'sm', variant: 'ghost', styles: { fontSize: 10 } }
|
|
246
|
+
* ]
|
|
247
|
+
* ```
|
|
248
|
+
*/
|
|
249
|
+
compoundVariants?: CompoundVariant<V>[];
|
|
250
|
+
};
|
|
251
|
+
/**
|
|
252
|
+
* Function returned by {@link createVariants}. Given partial variant props
|
|
253
|
+
* (all optional thanks to `defaultVariants`), it returns a single
|
|
254
|
+
* space-separated class name string ready to drop on a DOM node. Falsy
|
|
255
|
+
* extra class names can be appended via the second `className` argument.
|
|
256
|
+
*/
|
|
257
|
+
type VariantFn<V extends VariantGroups> = (props?: VariantProps<V>, className?: string | false | null | undefined) => string;
|
|
258
|
+
/**
|
|
259
|
+
* Builds variant-aware components without any wrapper React component.
|
|
260
|
+
*
|
|
261
|
+
* Inspired by `cva` (class-variance-authority) and Stitches, but built
|
|
262
|
+
* directly on top of {@link createStyles} so it benefits from the same
|
|
263
|
+
* theming, HMR, SSR and per-module stylesheet behavior.
|
|
264
|
+
*
|
|
265
|
+
* The returned function is a pure className builder — it has zero
|
|
266
|
+
* runtime cost beyond a few string concatenations and Map lookups.
|
|
267
|
+
*
|
|
268
|
+
* @param configOrCreator - Static config object, or a function receiving the theme.
|
|
269
|
+
* @param options - Optional `{ id }` namespacing (recommended in production, see {@link createStyles}).
|
|
270
|
+
*
|
|
271
|
+
* @example
|
|
272
|
+
* ```ts
|
|
273
|
+
* // Button.styles.ts
|
|
274
|
+
* import { createVariants } from '@aurora-ds/theme'
|
|
275
|
+
*
|
|
276
|
+
* export const button = createVariants((theme) => ({
|
|
277
|
+
* base: {
|
|
278
|
+
* display: 'inline-flex',
|
|
279
|
+
* alignItems: 'center',
|
|
280
|
+
* borderRadius: theme.radius.md,
|
|
281
|
+
* cursor: 'pointer',
|
|
282
|
+
* },
|
|
283
|
+
* variants: {
|
|
284
|
+
* size: {
|
|
285
|
+
* sm: { padding: theme.spacing.xs, fontSize: 12 },
|
|
286
|
+
* md: { padding: theme.spacing.sm, fontSize: 14 },
|
|
287
|
+
* lg: { padding: theme.spacing.md, fontSize: 16 },
|
|
288
|
+
* },
|
|
289
|
+
* variant: {
|
|
290
|
+
* primary: { backgroundColor: theme.colors.primary, color: 'white' },
|
|
291
|
+
* ghost: { backgroundColor: 'transparent', color: theme.colors.text },
|
|
292
|
+
* },
|
|
293
|
+
* },
|
|
294
|
+
* defaultVariants: { size: 'md', variant: 'primary' },
|
|
295
|
+
* compoundVariants: [
|
|
296
|
+
* { size: 'sm', variant: 'ghost', styles: { fontWeight: 600 } }
|
|
297
|
+
* ],
|
|
298
|
+
* }), { id: 'button' })
|
|
299
|
+
*
|
|
300
|
+
* // Usage
|
|
301
|
+
* <button className={button({ size: 'lg' })} />
|
|
302
|
+
* <button className={button({ variant: 'ghost' }, props.className)} />
|
|
303
|
+
* ```
|
|
304
|
+
*/
|
|
305
|
+
declare const createVariants: <V extends VariantGroups>(configOrCreator: CreateVariantsConfig<V> | ((theme: _InternalTheme) => CreateVariantsConfig<V>), options?: {
|
|
306
|
+
id?: string;
|
|
307
|
+
}) => VariantFn<V>;
|
|
159
308
|
|
|
160
309
|
/** Creates and injects a @keyframes rule, returns the animation name */
|
|
161
310
|
declare const keyframes: (frames: Record<string, CSSProperties>) => string;
|
|
@@ -173,6 +322,79 @@ declare const cssVariables: <T extends Record<string, string | number>>(variable
|
|
|
173
322
|
inject?: boolean;
|
|
174
323
|
}) => { [K in keyof T]: string; };
|
|
175
324
|
|
|
325
|
+
/**
|
|
326
|
+
* A block accepted by {@link globalStyles}. Same shape as
|
|
327
|
+
* {@link StyleWithPseudos} but additionally allows arbitrary string keys
|
|
328
|
+
* so that nested at-rules (e.g. `@media`) can declare their own child
|
|
329
|
+
* selectors (`body`, `*`, `.foo`, …).
|
|
330
|
+
*/
|
|
331
|
+
type GlobalStyleBlock = StyleWithPseudos & {
|
|
332
|
+
[selector: string]: unknown;
|
|
333
|
+
};
|
|
334
|
+
/**
|
|
335
|
+
* Injects global, top-level CSS rules. Each key is a CSS selector
|
|
336
|
+
* (`body`, `*`, `:root`, `.foo > .bar`, `@media (...)`, etc.) and each
|
|
337
|
+
* value supports the same nested-pseudo / `&` / at-rule syntax as
|
|
338
|
+
* {@link createStyles}.
|
|
339
|
+
*
|
|
340
|
+
* Rules are written into the shared global Aurora stylesheet and persist
|
|
341
|
+
* for the lifetime of the document. Calling `globalStyles` multiple times
|
|
342
|
+
* appends new rules — it is the caller's responsibility to call it once
|
|
343
|
+
* (typically at app bootstrap) per logical block.
|
|
344
|
+
*
|
|
345
|
+
* @example
|
|
346
|
+
* ```ts
|
|
347
|
+
* globalStyles({
|
|
348
|
+
* 'html, body': {
|
|
349
|
+
* margin: 0,
|
|
350
|
+
* padding: 0,
|
|
351
|
+
* fontFamily: 'system-ui, sans-serif',
|
|
352
|
+
* },
|
|
353
|
+
* 'a': {
|
|
354
|
+
* color: 'inherit',
|
|
355
|
+
* ':hover': { textDecoration: 'underline' },
|
|
356
|
+
* },
|
|
357
|
+
* '@media (prefers-reduced-motion: reduce)': {
|
|
358
|
+
* '*': { animation: 'none', transition: 'none' },
|
|
359
|
+
* },
|
|
360
|
+
* })
|
|
361
|
+
* ```
|
|
362
|
+
*/
|
|
363
|
+
declare const globalStyles: (rules: Record<string, GlobalStyleBlock>) => void;
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Accepted argument types for {@link cx}.
|
|
367
|
+
*
|
|
368
|
+
* - Strings are kept (when truthy).
|
|
369
|
+
* - `false`, `null`, `undefined` and empty strings are skipped, allowing
|
|
370
|
+
* conditional patterns like `cx(styles.base, isActive && styles.active)`.
|
|
371
|
+
*/
|
|
372
|
+
type CxArg = string | false | null | undefined;
|
|
373
|
+
/**
|
|
374
|
+
* Conditionally joins class names into a single space-separated string.
|
|
375
|
+
*
|
|
376
|
+
* Lightweight, dependency-free alternative to `clsx` / `classnames` tailored
|
|
377
|
+
* for usage with {@link createStyles}. Falsy values are filtered out so you
|
|
378
|
+
* can compose variants inline.
|
|
379
|
+
*
|
|
380
|
+
* @example
|
|
381
|
+
* ```tsx
|
|
382
|
+
* import { cx } from '@aurora-ds/theme'
|
|
383
|
+
*
|
|
384
|
+
* <button
|
|
385
|
+
* className={cx(
|
|
386
|
+
* styles.base,
|
|
387
|
+
* styles[size],
|
|
388
|
+
* styles[variant],
|
|
389
|
+
* fullWidth && styles.fullWidth,
|
|
390
|
+
* loading && styles.loading,
|
|
391
|
+
* className,
|
|
392
|
+
* )}
|
|
393
|
+
* />
|
|
394
|
+
* ```
|
|
395
|
+
*/
|
|
396
|
+
declare const cx: (...args: CxArg[]) => string;
|
|
397
|
+
|
|
176
398
|
/** SSR: Returns all collected CSS rules as a single string */
|
|
177
399
|
declare const getSSRStyles: () => string;
|
|
178
400
|
/** SSR: Returns styles wrapped in a style tag */
|
|
@@ -182,4 +404,4 @@ declare const clearSSRRules: () => void;
|
|
|
182
404
|
/** SSR: Returns raw CSS rules as an array */
|
|
183
405
|
declare const getSSRRulesArray: () => string[];
|
|
184
406
|
|
|
185
|
-
export { type FontFaceOptions, type StyleWithPseudos, ThemeProvider, type ThemeRegistry, clearSSRRules, colors, createStyles, createTheme, cssVar, cssVariables, fontFace, getSSRRulesArray, getSSRStyleTag, getSSRStyles, injectCssVariables, keyframes, useTheme };
|
|
407
|
+
export { type CompoundVariant, type CreateStylesOptions, type CreateVariantsConfig, type CxArg, type FontFaceOptions, type GlobalStyleBlock, type ResponsiveCSSProperties, type ResponsiveValue, type StyleWithPseudos, ThemeProvider, type ThemeRegistry, type VariantFn, type VariantProps, clearSSRRules, colors, createStyles, createTheme, createVariants, cssVar, cssVariables, cx, fontFace, getSSRRulesArray, getSSRStyleTag, getSSRStyles, globalStyles, injectCssVariables, keyframes, useTheme };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {createContext,useRef,useMemo,useLayoutEffect,useContext}from'react';import {jsx}from'react/jsx-runtime';var L=e=>e;var N={25:"#fffdfb",50:"#fffbeb",100:"#fef3c7",200:"#fde68a",300:"#fcd34d",400:"#fbbf24",500:"#f59e0b",600:"#d97706",700:"#b45309",800:"#92400e",900:"#78350f",950:"#451a03"};var j={25:"#f5f8ff",50:"#eff6ff",100:"#dbeafe",200:"#bfdbfe",300:"#93c5fd",400:"#60a5fa",500:"#3b82f6",600:"#2563eb",700:"#1d4ed8",800:"#1e40af",900:"#1e3a8a",950:"#172554"};var V={25:"#f3fefe",50:"#ecfeff",100:"#cffafe",200:"#a5f3fc",300:"#67e8f9",400:"#22d3ee",500:"#06b6d4",600:"#0891b2",700:"#0e7490",800:"#155e75",900:"#164e63",950:"#083344"};var W={25:"#f5fefc",50:"#ecfdf5",100:"#d1fae5",200:"#a7f3d0",300:"#6ee7b7",400:"#34d399",500:"#10b981",600:"#059669",700:"#047857",800:"#065f46",900:"#064e3b",950:"#022c22"};var z={25:"#fef5ff",50:"#fdf4ff",100:"#fae8ff",200:"#f5d0fe",300:"#f0abfc",400:"#e879f9",500:"#d946ef",600:"#c026d3",700:"#a21caf",800:"#86198f",900:"#701a75",950:"#4a044e"};var O={25:"#fcfcfc",50:"#fafafa",100:"#f4f4f5",200:"#e4e4e7",300:"#d4d4d8",400:"#a1a1aa",500:"#71717a",600:"#52525b",700:"#3f3f46",800:"#27272a",900:"#18181b",950:"#09090b"};var D={25:"#f6fef9",50:"#f0fdf4",100:"#dcfce7",200:"#bbf7d0",300:"#86efac",400:"#4ade80",500:"#22c55e",600:"#16a34a",700:"#15803d",800:"#166534",900:"#14532d",950:"#052e16"};var B={25:"#f5f7ff",50:"#eef2ff",100:"#e0e7ff",200:"#c7d2fe",300:"#a5b4fc",400:"#818cf8",500:"#6366f1",600:"#4f46e5",700:"#4338ca",800:"#3730a3",900:"#312e81",950:"#1e1b4b"};var H={25:"#fbfef8",50:"#f7fee7",100:"#ecfccb",200:"#d9f99d",300:"#bef264",400:"#a3e635",500:"#84cc16",600:"#65a30d",700:"#4d7c0f",800:"#3f6212",900:"#365314",950:"#1a2e05"};var Z={25:"#fffcfa",50:"#fff7ed",100:"#ffedd5",200:"#fed7aa",300:"#fdba74",400:"#fb923c",500:"#f97316",600:"#ea580c",700:"#c2410c",800:"#9a3412",900:"#7c2d12",950:"#431407"};var G={25:"#fef5f9",50:"#fdf2f8",100:"#fce7f3",200:"#fbcfe8",300:"#f9a8d4",400:"#f472b6",500:"#ec4899",600:"#db2777",700:"#be185d",800:"#9d174d",900:"#831843",950:"#500724"};var J={25:"#faf5ff",50:"#faf5ff",100:"#f3e8ff",200:"#e9d5ff",300:"#d8b4fe",400:"#c084fc",500:"#a855f7",600:"#9333ea",700:"#7e22ce",800:"#6b21a8",900:"#581c87",950:"#3b0764"};var U={25:"#fffbfb",50:"#fef2f2",100:"#fee2e2",200:"#fecaca",300:"#fca5a5",400:"#f87171",500:"#ef4444",600:"#dc2626",700:"#b91c1c",800:"#991b1b",900:"#7f1d1d",950:"#450a0a"};var Y={25:"#fff5f6",50:"#fff1f2",100:"#ffe4e6",200:"#fecdd3",300:"#fda4af",400:"#fb7185",500:"#f43f5e",600:"#e11d48",700:"#be123c",800:"#9f1239",900:"#881337",950:"#4c0519"};var q={25:"#fcfcfd",50:"#f8fafc",100:"#f1f5f9",200:"#e2e8f0",300:"#cbd5e1",400:"#94a3b8",500:"#64748b",600:"#475569",700:"#334155",800:"#1e293b",900:"#0f172a",950:"#020617"};var X={25:"#fcfcfb",50:"#fafaf9",100:"#f5f5f4",200:"#e7e5e4",300:"#d6d3d1",400:"#a8a29e",500:"#78716c",600:"#57534e",700:"#44403c",800:"#292524",900:"#1c1917",950:"#0c0a09"};var Q={25:"#f4fefe",50:"#f0fdfa",100:"#ccfbf1",200:"#99f6e4",300:"#5eead4",400:"#2dd4bf",500:"#14b8a6",600:"#0d9488",700:"#0f766e",800:"#115e59",900:"#134e4a",950:"#042f2e"};var ee={25:"#f8f5ff",50:"#f5f3ff",100:"#ede9fe",200:"#ddd6fe",300:"#c4b5fd",400:"#a78bfa",500:"#8b5cf6",600:"#7c3aed",700:"#6d28d9",800:"#5b21b6",900:"#4c1d95",950:"#2e1065"};var te={25:"#fefef9",50:"#fefce8",100:"#fef9c3",200:"#fef08a",300:"#fde047",400:"#facc15",500:"#eab308",600:"#ca8a04",700:"#a16207",800:"#854d0e",900:"#713f12",950:"#422006"};var _e={gray:O,slate:q,stone:X,red:U,orange:Z,amber:N,yellow:te,lime:H,green:D,emerald:W,teal:Q,cyan:V,blue:j,indigo:B,violet:ee,purple:J,fuchsia:z,pink:G,rose:Y,white:"#ffffff",black:"#000000",transparent:"transparent",current:"currentColor"};var h=typeof document>"u",re=null,g=null,$=[],oe=new Map([["backgroundColor","background-color"],["borderRadius","border-radius"],["fontSize","font-size"],["fontWeight","font-weight"],["lineHeight","line-height"],["marginTop","margin-top"],["marginBottom","margin-bottom"],["marginLeft","margin-left"],["marginRight","margin-right"],["paddingTop","padding-top"],["paddingBottom","padding-bottom"],["paddingLeft","padding-left"],["paddingRight","padding-right"],["textAlign","text-align"],["justifyContent","justify-content"],["alignItems","align-items"],["flexDirection","flex-direction"],["flexWrap","flex-wrap"],["boxShadow","box-shadow"],["zIndex","z-index"]]),w=new Set,I=new Set,C=new Map,x=new Map,c=null,ke=new Set(["animationIterationCount","columnCount","fillOpacity","flexGrow","flexShrink","fontWeight","lineHeight","opacity","order","orphans","widows","zIndex","zoom"]),T=new Map,R=new Map;if(!h){let e=document.getElementById("aurora-styles");if(e)g=e.sheet;else {let t=document.createElement("style");t.id="aurora-styles",document.head.appendChild(t),g=t.sheet;}}var k=e=>{let t=re;return re=e,t};var u=e=>{if(h)$.push(e);else if(g)try{g.insertRule(e,g.cssRules.length);}catch{}},fe=e=>{if(h)return null;let t=T.get(e);if(t){let o=t.cssRules.length;for(let f=o-1;f>=0;f--)t.deleteRule(f);R.delete(e);let s=C.get(e);s&&(s.forEach(f=>w.delete(f)),s.clear());let a=x.get(e);return a&&(a.forEach(f=>I.delete(f)),a.clear()),t}let r=document.createElement("style");r.id=`aurora-mod-${e}`,r.setAttribute("data-aurora-module",e),document.head.appendChild(r);let n=r.sheet;return T.set(e,n),n},p=(e,t)=>{if(h)$.push(t);else if(e)try{e.insertRule(t,e.cssRules.length);}catch{}},ne=/&/g,A=(e,t,r)=>{let n="",o=`.${t}`;for(let s in e){let a=e[s],f=s.charCodeAt(0);if(f===64){let i=S(a);i&&p(r,`${s}{${o}{${i}}}`);}else if(f===38){let i=S(a);i&&(ne.lastIndex=0,p(r,`${s.replace(ne,o)}{${i}}`));}else if(f===58){let i=S(a);i&&p(r,`${o}${s}{${i}}`);}else a!=null&&typeof a!="object"&&(n+=`${l(s)}:${ie(s,a)};`);}return n&&p(r,`${o}{${n}}`),t},Ae=500,ae=(e,t)=>{let r=R.get(e);return r||(r=new Set,R.set(e,r)),r.has(t)?true:(r.size>=Ae||r.add(t),false)},l=e=>{let t=oe.get(e);return t||(t=e.replace(/([A-Z])/g,"-$1").toLowerCase(),oe.set(e,t)),t},se=new Map,v=e=>{let t=se.get(e);return t||(t=e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").toLowerCase(),se.set(e,t)),t},Fe=/expression\s*\(|javascript\s*:|data\s*:\s*text\/html|behavior\s*:|@import|<\s*\/?\s*style/i,Pe=e=>{let t=e.replace(/\0/g,"");return Fe.test(t)?"unset":t},ie=(e,t)=>{if(typeof t=="number")return ke.has(e)?String(t):`${t}px`;let r=String(t);return r.charCodeAt(0)===118&&r.startsWith("var(--")?r:Pe(r)},S=e=>{let t="";for(let r in e){let n=e[r];n!=null&&typeof n!="object"&&(t+=`${l(r)}:${ie(r,n)};`);}return t};var ce=e=>{let t=e.length;if(t===0)return "";if(t===1){let r=e[0];if(r===void 0)return "u";if(r===null)return "n";if(typeof r=="string"||typeof r=="number"||typeof r=="boolean")return String(r)}if(t<=4){let r="";for(let n=0;n<t;n++){let o=e[n],s=typeof o;if(o===void 0)r+=n?"|u":"u";else if(o===null)r+=n?"|n":"n";else if(s==="string"||s==="number"||s==="boolean")r+=n?"|"+o:String(o);else return JSON.stringify(e)}return r}return JSON.stringify(e)},le=e=>{let t=e.charCodeAt(0);if(e.length<20){if(t>=97&&t<=122||t>=65&&t<=90){let r=true;for(let n=1;n<e.length;n++){let o=e.charCodeAt(n);if(!(o>=97&&o<=122||o>=65&&o<=90||o>=48&&o<=57)){r=false;break}}if(r)return v(e)}else if(t===45||t>=48&&t<=57){let r=true;for(let n=1;n<e.length;n++)if(e.charCodeAt(n)<48||e.charCodeAt(n)>57){r=false;break}if(r)return e}}return E(e)},E=e=>{let t=5381,r=e.length;for(let n=0;n<r;n++)t=(t<<5)+t^e.charCodeAt(n);return (t>>>0).toString(36)},F=(e,t=null)=>{c=e?{name:e,sheet:t}:null;},de=e=>w.has(e),ue=e=>{if(w.add(e),c){let t=C.get(c.name);t||(t=new Set,C.set(c.name,t)),t.add(e);}},me=e=>`aurora-kf-${E(e)}`,pe=e=>{c?.sheet?p(c.sheet,e):u(e);},ge=e=>I.has(e),Se=e=>{if(I.add(e),c){let t=x.get(c.name);t||(t=new Set,x.set(c.name,t)),t.add(e);}},he=e=>{c?.sheet?p(c.sheet,e):u(e);},P=()=>$,ye=()=>{$=[],w.clear(),I.clear(),C.clear(),x.clear(),c=null,h||T.forEach((e,t)=>{let r=document.getElementById(`aurora-mod-${t}`);r&&r.remove();}),T.clear(),R.clear();};var K=typeof document>"u",Ce="aurora-theme-variables",xe="aurora-theme-transition",y="aurora-disable-transitions",b="aurora-force-transitions",Te=false,je=()=>{Te||K||(u(`.${y} *,.${y} *::before,.${y} *::after{transition:none!important}`),Te=true);},Ve=e=>{if(K)return;let t=document.getElementById(xe);t||(t=document.createElement("style"),t.id=xe,document.head.appendChild(t)),t.textContent=`.${b} *,.${b} *::before,.${b} *::after{transition:color ${e}ms,background-color ${e}ms,border-color ${e}ms,fill ${e}ms,stroke ${e}ms!important}`;},Re=createContext(void 0),$e=(e,t="theme")=>{let r="";for(let n in e){let o=e[n],s=`${t}-${l(n)}`;o&&typeof o=="object"&&!Array.isArray(o)?r+=$e(o,s):o!=null&&(r+=`--${s}:${o};`);}return r},We=({theme:e,disableTransitionsOnChange:t=true,transitionDuration:r,children:n})=>{let o=k(()=>e),s=useRef(true),a=useMemo(()=>$e(e),[e]);return useLayoutEffect(()=>{if(K)return;let f=!s.current,i=r!==void 0&&r>0,m=t&&!i&&f;m&&(je(),document.documentElement.classList.add(y)),i&&f&&(Ve(r),document.documentElement.classList.add(b));let d=document.getElementById(Ce);if(d||(d=document.createElement("style"),d.id=Ce,document.head.appendChild(d)),d.textContent=`:root{${a}}`,m&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{document.documentElement.classList.remove(y);});}),i&&f){let Ee=setTimeout(()=>{document.documentElement.classList.remove(b);},r);return s.current=false,()=>{clearTimeout(Ee);}}s.current=false;},[a,t,r]),useLayoutEffect(()=>()=>{k(o);},[o]),jsx(Re.Provider,{value:e,children:n})},ze=()=>{let e=useContext(Re);if(!e)throw new Error("useTheme must be used within a ThemeProvider");return e};var M=new Map,De=0,Be=()=>{let e=new Error().stack||"",t=e.match(/([A-Za-z0-9_]+)\.styles\.[tj]s/);if(!t?.[1])return `s${(De++).toString(36)}`;let r=v(t[1]),o=e.match(/(?:at\s+.*?\(|at\s+)((?:[A-Za-z]:)?[^\s)]+\.styles\.[tj]s)/)?.[1]||"",s=M.get(r);if(s===o)return r;if(!s)return M.set(r,o),r;let a=`${r}-${E(o)}`;return M.set(a,o),a},_=null,He=()=>{if(_)return _;let e=t=>{let r=()=>`var(--theme-${t})`;return new Proxy(r,{get(n,o){if(o===Symbol.toPrimitive)return r;if(typeof o!="string")return;if(o==="toString"||o==="valueOf")return r;let s=l(o),a=t?`${t}-${s}`:s;return e(a)},apply(){return r()}})};return _=e(""),_},we=(e,t,r)=>{let n={};for(let o in e){let s=e[o];if(s){let a=`${t}-${v(o)}`;typeof s=="function"?n[o]=(...f)=>{let i=ce(f),m=`${a}-${le(i)}`;if(!ae(t,m)){let d=s(...f);A(d,m,r);}return m}:(A(s,a,r),n[o]=a);}}return n},Ze=e=>{let t=Be(),r=fe(t);F(t,r);try{if(typeof e=="function"){let n=He(),o=e(n);return we(o,t,r)}return we(e,t,r)}finally{F(null);}};var Ge=e=>{let t="";for(let n in e)t+=`${n}{${S(e[n])}}`;let r=me(t);return de(t)||(pe(`@keyframes ${r}{${t}}`),ue(t)),r};var Je=e=>{let{fontFamily:t,src:r,fontStyle:n="normal",fontWeight:o=400,fontDisplay:s="swap",unicodeRange:a}=e,f=`font-family:"${t}";`;return f+=`src:${r};`,f+=`font-style:${n};`,f+=`font-weight:${o};`,f+=`font-display:${s};`,a&&(f+=`unicode-range:${a};`),ge(f)||(he(`@font-face{${f}}`),Se(f)),t};var Ie=(e,t)=>{let r="";for(let n in e){let o=e[n],s=l(n);o&&typeof o=="object"?r+=Ie(o,`${t}-${s}`):o!=null&&(r+=`--${t}-${s}:${o};`);}return r},Ue=(e,t="theme")=>{let r=Ie(e,t);u(`:root{${r}}`);},Ye=(e,t)=>{let r=`--theme-${e.replace(/\./g,"-")}`;return t?`var(${r}, ${t})`:`var(${r})`},qe=(e,t={})=>{let{prefix:r="",inject:n=false}=t,o={},s="";for(let a in e){let f=l(a),i=r?`--${r}-${f}`:`--${f}`;o[a]=`var(${i})`,n&&(s+=`${i}:${e[a]};`);}return n&&s&&u(`:root{${s}}`),o};var ve=()=>P().join(""),Xe=()=>{let e=ve();return e?`<style id="aurora-styles">${e}</style>`:""},Qe=()=>{ye();},et=()=>[...P()];export{We as ThemeProvider,Qe as clearSSRRules,_e as colors,Ze as createStyles,L as createTheme,Ye as cssVar,qe as cssVariables,Je as fontFace,et as getSSRRulesArray,Xe as getSSRStyleTag,ve as getSSRStyles,Ue as injectCssVariables,Ge as keyframes,ze as useTheme};//# sourceMappingURL=index.js.map
|
|
1
|
+
import*as Ae from'react';import {createContext,useRef,useMemo,useLayoutEffect,useContext}from'react';import {jsx}from'react/jsx-runtime';var z=e=>e;var H={25:"#fffdfb",50:"#fffbeb",100:"#fef3c7",200:"#fde68a",300:"#fcd34d",400:"#fbbf24",500:"#f59e0b",600:"#d97706",700:"#b45309",800:"#92400e",900:"#78350f",950:"#451a03"};var Z={25:"#f5f8ff",50:"#eff6ff",100:"#dbeafe",200:"#bfdbfe",300:"#93c5fd",400:"#60a5fa",500:"#3b82f6",600:"#2563eb",700:"#1d4ed8",800:"#1e40af",900:"#1e3a8a",950:"#172554"};var J={25:"#f3fefe",50:"#ecfeff",100:"#cffafe",200:"#a5f3fc",300:"#67e8f9",400:"#22d3ee",500:"#06b6d4",600:"#0891b2",700:"#0e7490",800:"#155e75",900:"#164e63",950:"#083344"};var U={25:"#f5fefc",50:"#ecfdf5",100:"#d1fae5",200:"#a7f3d0",300:"#6ee7b7",400:"#34d399",500:"#10b981",600:"#059669",700:"#047857",800:"#065f46",900:"#064e3b",950:"#022c22"};var Y={25:"#fef5ff",50:"#fdf4ff",100:"#fae8ff",200:"#f5d0fe",300:"#f0abfc",400:"#e879f9",500:"#d946ef",600:"#c026d3",700:"#a21caf",800:"#86198f",900:"#701a75",950:"#4a044e"};var X={25:"#fcfcfc",50:"#fafafa",100:"#f4f4f5",200:"#e4e4e7",300:"#d4d4d8",400:"#a1a1aa",500:"#71717a",600:"#52525b",700:"#3f3f46",800:"#27272a",900:"#18181b",950:"#09090b"};var q={25:"#f6fef9",50:"#f0fdf4",100:"#dcfce7",200:"#bbf7d0",300:"#86efac",400:"#4ade80",500:"#22c55e",600:"#16a34a",700:"#15803d",800:"#166534",900:"#14532d",950:"#052e16"};var Q={25:"#f5f7ff",50:"#eef2ff",100:"#e0e7ff",200:"#c7d2fe",300:"#a5b4fc",400:"#818cf8",500:"#6366f1",600:"#4f46e5",700:"#4338ca",800:"#3730a3",900:"#312e81",950:"#1e1b4b"};var ee={25:"#fbfef8",50:"#f7fee7",100:"#ecfccb",200:"#d9f99d",300:"#bef264",400:"#a3e635",500:"#84cc16",600:"#65a30d",700:"#4d7c0f",800:"#3f6212",900:"#365314",950:"#1a2e05"};var te={25:"#fffcfa",50:"#fff7ed",100:"#ffedd5",200:"#fed7aa",300:"#fdba74",400:"#fb923c",500:"#f97316",600:"#ea580c",700:"#c2410c",800:"#9a3412",900:"#7c2d12",950:"#431407"};var ne={25:"#fef5f9",50:"#fdf2f8",100:"#fce7f3",200:"#fbcfe8",300:"#f9a8d4",400:"#f472b6",500:"#ec4899",600:"#db2777",700:"#be185d",800:"#9d174d",900:"#831843",950:"#500724"};var re={25:"#faf5ff",50:"#faf5ff",100:"#f3e8ff",200:"#e9d5ff",300:"#d8b4fe",400:"#c084fc",500:"#a855f7",600:"#9333ea",700:"#7e22ce",800:"#6b21a8",900:"#581c87",950:"#3b0764"};var oe={25:"#fffbfb",50:"#fef2f2",100:"#fee2e2",200:"#fecaca",300:"#fca5a5",400:"#f87171",500:"#ef4444",600:"#dc2626",700:"#b91c1c",800:"#991b1b",900:"#7f1d1d",950:"#450a0a"};var se={25:"#fff5f6",50:"#fff1f2",100:"#ffe4e6",200:"#fecdd3",300:"#fda4af",400:"#fb7185",500:"#f43f5e",600:"#e11d48",700:"#be123c",800:"#9f1239",900:"#881337",950:"#4c0519"};var ie={25:"#fcfcfd",50:"#f8fafc",100:"#f1f5f9",200:"#e2e8f0",300:"#cbd5e1",400:"#94a3b8",500:"#64748b",600:"#475569",700:"#334155",800:"#1e293b",900:"#0f172a",950:"#020617"};var ae={25:"#fcfcfb",50:"#fafaf9",100:"#f5f5f4",200:"#e7e5e4",300:"#d6d3d1",400:"#a8a29e",500:"#78716c",600:"#57534e",700:"#44403c",800:"#292524",900:"#1c1917",950:"#0c0a09"};var fe={25:"#f4fefe",50:"#f0fdfa",100:"#ccfbf1",200:"#99f6e4",300:"#5eead4",400:"#2dd4bf",500:"#14b8a6",600:"#0d9488",700:"#0f766e",800:"#115e59",900:"#134e4a",950:"#042f2e"};var ce={25:"#f8f5ff",50:"#f5f3ff",100:"#ede9fe",200:"#ddd6fe",300:"#c4b5fd",400:"#a78bfa",500:"#8b5cf6",600:"#7c3aed",700:"#6d28d9",800:"#5b21b6",900:"#4c1d95",950:"#2e1065"};var le={25:"#fefef9",50:"#fefce8",100:"#fef9c3",200:"#fef08a",300:"#fde047",400:"#facc15",500:"#eab308",600:"#ca8a04",700:"#a16207",800:"#854d0e",900:"#713f12",950:"#422006"};var Be={gray:X,slate:ie,stone:ae,red:oe,orange:te,amber:H,yellow:le,lime:ee,green:q,emerald:U,teal:fe,cyan:J,blue:Z,indigo:Q,violet:ce,purple:re,fuchsia:Y,pink:ne,rose:se,white:"#ffffff",black:"#000000",transparent:"transparent",current:"currentColor"};var $=typeof document>"u",Ge=typeof process<"u"&&typeof process.env<"u"&&process.env.NODE_ENV!=="production",ge=(e,...t)=>{Ge&&console.warn(`[aurora-ds] ${e}`,...t);},ue=null,x=null,_=[],de=new Map([["backgroundColor","background-color"],["borderRadius","border-radius"],["fontSize","font-size"],["fontWeight","font-weight"],["lineHeight","line-height"],["marginTop","margin-top"],["marginBottom","margin-bottom"],["marginLeft","margin-left"],["marginRight","margin-right"],["paddingTop","padding-top"],["paddingBottom","padding-bottom"],["paddingLeft","padding-left"],["paddingRight","padding-right"],["textAlign","text-align"],["justifyContent","justify-content"],["alignItems","align-items"],["flexDirection","flex-direction"],["flexWrap","flex-wrap"],["boxShadow","box-shadow"],["zIndex","z-index"]]),A=new Set,F=new Set,w=new Map,v=new Map,m=null,ze=new Set(["animationIterationCount","columnCount","fillOpacity","flexGrow","flexShrink","fontWeight","lineHeight","opacity","order","orphans","widows","zIndex","zoom"]),I=new Map,E=new Map;if(!$){let e=document.getElementById("aurora-styles");if(e)x=e.sheet;else {let t=document.createElement("style");t.id="aurora-styles",document.head.appendChild(t),x=t.sheet;}}var j=e=>{let t=ue;return ue=e,t};var g=e=>{if($)_.push(e);else if(x)try{x.insertRule(e,x.cssRules.length);}catch(t){ge("Failed to insert CSS rule:",e,t);}},Se=e=>{if($)return null;let t=I.get(e);if(t){let r=t.cssRules.length;for(let i=r-1;i>=0;i--)t.deleteRule(i);E.delete(e);let s=w.get(e);s&&(s.forEach(i=>A.delete(i)),s.clear());let a=v.get(e);return a&&(a.forEach(i=>F.delete(i)),a.clear()),t}let n=document.createElement("style");n.id=`aurora-mod-${e}`,n.setAttribute("data-aurora-module",e),document.head.appendChild(n);let o=n.sheet;return I.set(e,o),o},y=(e,t)=>{if($)_.push(t);else if(e)try{e.insertRule(t,e.cssRules.length);}catch(n){ge("Failed to insert module CSS rule:",t,n);}},R=new Map,ye=e=>{if(R.clear(),!!e)for(let t in e){let n=e[t];n!=null&&R.set(t,typeof n=="number"?`${n}px`:String(n));}},He=e=>{if(!e||typeof e!="object"||Array.isArray(e)||R.size===0)return false;let t=false;for(let n in e){if(n==="base"){t=true;continue}if(!R.has(n))return false;t=true;}return t},me=/&/g,N=(e,t,n)=>{let o="",r=`.${t}`;for(let s in e){let a=e[s],i=s.charCodeAt(0);if(i===64){let f=S(a);f&&y(n,`${s}{${r}{${f}}}`);}else if(i===38){let f=S(a);f&&(me.lastIndex=0,y(n,`${s.replace(me,r)}{${f}}`));}else if(i===58){let f=S(a);f&&y(n,`${r}${s}{${f}}`);}else if(a!=null&&typeof a=="object"&&He(a)){let f=a,l=p(s);"base"in f&&f.base!=null&&(o+=`${l}:${b(s,f.base)};`);for(let[c,d]of R){if(!(c in f))continue;let u=f[c];u!=null&&y(n,`@media (min-width:${d}){${r}{${l}:${b(s,u)};}}`);}}else a!=null&&typeof a!="object"&&(o+=`${p(s)}:${b(s,a)};`);}return o&&y(n,`${r}{${o}}`),t},Ze=500,he=(e,t)=>{let n=E.get(e);return n||(n=new Set,E.set(e,n)),n.has(t)?true:(n.size>=Ze||n.add(t),false)},p=e=>{let t=de.get(e);return t||(t=e.replace(/([A-Z])/g,"-$1").toLowerCase(),de.set(e,t)),t},pe=new Map,T=e=>{let t=pe.get(e);return t||(t=e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").toLowerCase(),pe.set(e,t)),t},Je=/expression\s*\(|javascript\s*:|data\s*:\s*text\/html|behavior\s*:|@import|<\s*\/?\s*style/i,Ue=e=>{let t=e.replace(/\0/g,"");return Je.test(t)?"unset":t},b=(e,t)=>{if(typeof t=="number")return ze.has(e)?String(t):`${t}px`;let n=String(t);return n.charCodeAt(0)===118&&n.startsWith("var(--")?n:Ue(n)},S=e=>{let t="";for(let n in e){let o=e[n];o!=null&&typeof o!="object"&&(t+=`${p(n)}:${b(n,o)};`);}return t};var Ye=4,P=(e,t=0)=>{if(e===null||typeof e!="object"||t>=Ye)return JSON.stringify(e);if(Array.isArray(e))return "["+e.map(r=>P(r,t+1)).join(",")+"]";let n=Object.keys(e).sort(),o=[];for(let r of n){let s=e[r];s!==void 0&&o.push(JSON.stringify(r)+":"+P(s,t+1));}return "{"+o.join(",")+"}"},be=e=>{let t=e.length;if(t===0)return "";if(t===1){let n=e[0];if(n===void 0)return "u";if(n===null)return "n";if(typeof n=="string"||typeof n=="number"||typeof n=="boolean")return String(n)}if(t<=4){let n="";for(let o=0;o<t;o++){let r=e[o],s=typeof r;if(r===void 0)n+=o?"|u":"u";else if(r===null)n+=o?"|n":"n";else if(s==="string"||s==="number"||s==="boolean")n+=o?"|"+r:String(r);else return P(e)}return n}return P(e)},Ce=e=>{let t=e.charCodeAt(0);if(e.length<20){if(t>=97&&t<=122||t>=65&&t<=90){let n=true;for(let o=1;o<e.length;o++){let r=e.charCodeAt(o);if(!(r>=97&&r<=122||r>=65&&r<=90||r>=48&&r<=57)){n=false;break}}if(n)return T(e)}else if(t===45||t>=48&&t<=57){let n=true;for(let o=1;o<e.length;o++)if(e.charCodeAt(o)<48||e.charCodeAt(o)>57){n=false;break}if(n)return e}}return K(e)},K=e=>{let t=5381,n=e.length;for(let o=0;o<n;o++)t=(t<<5)+t^e.charCodeAt(o);return (t>>>0).toString(36)},W=(e,t=null)=>{m=e?{name:e,sheet:t}:null;},xe=e=>A.has(e),Re=e=>{if(A.add(e),m){let t=w.get(m.name);t||(t=new Set,w.set(m.name,t)),t.add(e);}},$e=e=>`aurora-kf-${K(e)}`,Te=e=>{m?.sheet?y(m.sheet,e):g(e);},Ve=e=>F.has(e),ke=e=>{if(F.add(e),m){let t=v.get(m.name);t||(t=new Set,v.set(m.name,t)),t.add(e);}},we=e=>{m?.sheet?y(m.sheet,e):g(e);},L=()=>_,ve=()=>{_=[],A.clear(),F.clear(),w.clear(),v.clear(),m=null,$||I.forEach((e,t)=>{let n=document.getElementById(`aurora-mod-${t}`);n&&n.remove();}),I.clear(),E.clear();};var O=typeof document>"u",Ee="aurora-theme-variables",Pe="aurora-theme-transition",V="aurora-disable-transitions",k="aurora-force-transitions",et=Ae.useInsertionEffect??useLayoutEffect,_e=false,tt=()=>{_e||O||(g(`.${V} *,.${V} *::before,.${V} *::after{transition:none!important}`),_e=true);},nt=e=>{if(O)return;let t=document.getElementById(Pe);t||(t=document.createElement("style"),t.id=Pe,document.head.appendChild(t)),t.textContent=`.${k} *,.${k} *::before,.${k} *::after{transition:color ${e}ms,background-color ${e}ms,border-color ${e}ms,fill ${e}ms,stroke ${e}ms!important}`;},Ke=createContext(void 0),Me=(e,t="theme")=>{let n="";for(let o in e){let r=e[o],s=`${t}-${p(o)}`;r&&typeof r=="object"&&!Array.isArray(r)?n+=Me(r,s):r!=null&&(n+=`--${s}:${r};`);}return n},rt=({theme:e,disableTransitionsOnChange:t=true,transitionDuration:n,children:o})=>{let r=j(()=>e),s=useRef(true),a=useRef(null),i=e.breakpoints;ye(i);let f=useMemo(()=>Me(e),[e]);return et(()=>{if(O)return;let l=!s.current,c=n!==void 0&&n>0,d=t&&!c&&l;d&&(tt(),document.documentElement.classList.add(V)),c&&l&&(nt(n),document.documentElement.classList.add(k));let u=document.getElementById(Ee);u||(u=document.createElement("style"),u.id=Ee,document.head.appendChild(u));let h=`:root{${f}}`;if(a.current!==h&&(u.textContent=h,a.current=h),d&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{document.documentElement.classList.remove(V);});}),c&&l){let C=setTimeout(()=>{document.documentElement.classList.remove(k);},n);return s.current=false,()=>{clearTimeout(C);}}s.current=false;},[f,t,n]),useLayoutEffect(()=>()=>{j(r);},[r]),jsx(Ke.Provider,{value:e,children:o})},ot=()=>{let e=useContext(Ke);if(!e)throw new Error("useTheme must be used within a ThemeProvider");return e};var D=new Map,it=0,at=()=>{let e=new Error().stack||"",t=e.match(/([A-Za-z0-9_]+)\.styles\.[tj]s/);if(!t?.[1])return `s${(it++).toString(36)}`;let n=T(t[1]),r=e.match(/(?:at\s+.*?\(|at\s+)((?:[A-Za-z]:)?[^\s)]+\.styles\.[tj]s)/)?.[1]||"",s=D.get(n);if(s===r)return n;if(!s)return D.set(n,r),n;let a=`${n}-${K(r)}`;return D.set(a,r),a},M=null,ft=()=>{if(M)return M;let e=t=>{let n=()=>`var(--theme-${t})`;return new Proxy(n,{get(o,r){if(r===Symbol.toPrimitive)return n;if(typeof r!="string")return;if(r==="toString"||r==="valueOf")return n;let s=p(r),a=t?`${t}-${s}`:s;return e(a)},apply(){return n()}})};return M=e(""),M},je=(e,t,n)=>{let o={};for(let r in e){let s=e[r];if(s){let a=`${t}-${T(r)}`;typeof s=="function"?o[r]=(...i)=>{let f=be(i),l=`${a}-${Ce(f)}`;if(!he(t,l)){let c=s(...i);N(c,l,n);}return l}:(N(s,a,n),o[r]=a);}}return o},B=(e,t)=>{let n=t?.id?T(t.id):at(),o=Se(n);W(n,o);try{if(typeof e=="function"){let r=ft(),s=e(r);return je(s,n,o)}return je(e,n,o)}finally{W(null);}};var G=(...e)=>{let t="";for(let n=0;n<e.length;n++){let o=e[n];o&&(t=t?t+" "+o:o);}return t};var Ne="compound-",ct=(e,t)=>{let n={},o=[],r=i=>{let f=typeof e=="function"?e(i):e;n=f.defaultVariants??{},o=f.compoundVariants??[];let l={};if(f.base&&(l.base=f.base),f.variants)for(let c in f.variants){let d=f.variants[c];for(let u in d)l[`${c}--${u}`]=d[u];}if(f.compoundVariants)for(let c=0;c<f.compoundVariants.length;c++)l[`${Ne}${c}`]=f.compoundVariants[c].styles;return l},s=B((i=>r(i)),t),a=s.base;return (i,f)=>{let l={...n,...i??{}},c=[a];for(let d in l){let u=l[d];u==null||u===false||c.push(s[`${d}--${String(u)}`]);}for(let d=0;d<o.length;d++){let u=o[d],h=true;for(let C in u)if(C!=="styles"&&l[C]!==u[C]){h=false;break}h&&c.push(s[`${Ne}${d}`]);}return f&&c.push(f),G(...c)}};var lt=e=>{let t="";for(let o in e)t+=`${o}{${S(e[o])}}`;let n=$e(t);return xe(t)||(Te(`@keyframes ${n}{${t}}`),Re(t)),n};var ut=e=>{let{fontFamily:t,src:n,fontStyle:o="normal",fontWeight:r=400,fontDisplay:s="swap",unicodeRange:a}=e,i=`font-family:"${t}";`;return i+=`src:${n};`,i+=`font-style:${o};`,i+=`font-weight:${r};`,i+=`font-display:${s};`,a&&(i+=`unicode-range:${a};`),Ve(i)||(we(`@font-face{${i}}`),ke(i)),t};var We=(e,t)=>{let n="";for(let o in e){let r=e[o],s=p(o);r&&typeof r=="object"?n+=We(r,`${t}-${s}`):r!=null&&(n+=`--${t}-${s}:${r};`);}return n},dt=(e,t="theme")=>{let n=We(e,t);g(`:root{${n}}`);},mt=(e,t)=>{let n=`--theme-${e.replace(/\./g,"-")}`;return t?`var(${n}, ${t})`:`var(${n})`},pt=(e,t={})=>{let{prefix:n="",inject:o=false}=t,r={},s="";for(let a in e){let i=p(a),f=n?`--${n}-${i}`:`--${i}`;r[a]=`var(${f})`,o&&(s+=`${f}:${e[a]};`);}return o&&s&&g(`:root{${s}}`),r};var Le=/&/g,Oe=(e,t)=>{let n=[],o="";for(let r in t){let s=t[r],a=r.charCodeAt(0);if(a===64){let i=S(s);i&&n.push(`${r}{${e}{${i}}}`);}else if(a===38){let i=S(s);i&&(Le.lastIndex=0,n.push(`${r.replace(Le,e)}{${i}}`));}else if(a===58){let i=S(s);i&&n.push(`${e}${r}{${i}}`);}else s!=null&&typeof s!="object"&&(o+=`${p(r)}:${b(r,s)};`);}return o&&n.unshift(`${e}{${o}}`),n},gt=e=>{for(let t in e){let n=e[t];if(!n)continue;if(t.charCodeAt(0)===64){let s="";for(let a in n){let i=n[a];if(i&&typeof i=="object"){let f=Oe(a,i);s+=f.join("");}}s&&g(`${t}{${s}}`);continue}let r=Oe(t,n);for(let s=0;s<r.length;s++)g(r[s]);}};var De=()=>L().join(""),St=()=>{let e=De();return e?`<style id="aurora-styles">${e}</style>`:""},yt=()=>{ve();},ht=()=>[...L()];export{rt as ThemeProvider,yt as clearSSRRules,Be as colors,B as createStyles,z as createTheme,ct as createVariants,mt as cssVar,pt as cssVariables,G as cx,ut as fontFace,ht as getSSRRulesArray,St as getSSRStyleTag,De as getSSRStyles,gt as globalStyles,dt as injectCssVariables,lt as keyframes,ot as useTheme};//# sourceMappingURL=index.js.map
|
|
2
2
|
//# sourceMappingURL=index.js.map
|