tailwind-to-style 3.2.2 → 3.3.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/README.md +486 -21
- package/dist/className/index.cjs +11020 -0
- package/dist/className/index.esm.js +11015 -0
- package/dist/className/index.esm.js.map +1 -0
- package/dist/core/tws.cjs +1 -1
- package/dist/core/tws.esm.js +1 -1
- package/dist/core/tws.esm.js.map +1 -1
- package/dist/core/twsx.cjs +558 -362
- package/dist/core/twsx.esm.js +558 -362
- package/dist/core/twsx.esm.js.map +1 -1
- package/dist/core/twsxVariants.cjs +561 -364
- package/dist/core/twsxVariants.esm.js +561 -364
- package/dist/core/twsxVariants.esm.js.map +1 -1
- package/dist/cx.cjs +1 -1
- package/dist/cx.esm.js +1 -1
- package/dist/index.cjs +3677 -607
- package/dist/index.d.ts +989 -0
- package/dist/index.esm.js +3660 -608
- package/dist/index.esm.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/utils/index.cjs +94 -27
- package/dist/utils/index.esm.js +94 -27
- package/dist/utils/index.esm.js.map +1 -1
- package/package.json +6 -1
- package/types/className/index.d.ts +41 -0
- package/types/index.d.ts +989 -0
package/types/index.d.ts
CHANGED
|
@@ -256,6 +256,104 @@ export interface VariantsDefinition {
|
|
|
256
256
|
[variantName: string]: VariantOptions;
|
|
257
257
|
}
|
|
258
258
|
|
|
259
|
+
// ============================================================================
|
|
260
|
+
// Type Inference Utilities
|
|
261
|
+
// ============================================================================
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Infer variant props from a variant function or config.
|
|
265
|
+
* Use this when you need to type component props based on your variants.
|
|
266
|
+
*
|
|
267
|
+
* @example
|
|
268
|
+
* const button = twsxVariants('.btn', {
|
|
269
|
+
* variants: {
|
|
270
|
+
* size: { sm: 'text-sm', lg: 'text-lg' },
|
|
271
|
+
* variant: { primary: 'bg-blue-500', secondary: 'bg-gray-200' }
|
|
272
|
+
* }
|
|
273
|
+
* });
|
|
274
|
+
*
|
|
275
|
+
* // Extract props type
|
|
276
|
+
* type ButtonProps = InferVariantProps<typeof button>;
|
|
277
|
+
* // Result: { size?: 'sm' | 'lg'; variant?: 'primary' | 'secondary' }
|
|
278
|
+
*/
|
|
279
|
+
export type InferVariantProps<T> = T extends VariantFunction<infer V>
|
|
280
|
+
? VariantProps<V>
|
|
281
|
+
: T extends TwsxClassNameVariantFunction<infer V>
|
|
282
|
+
? TwsxClassNameVariantProps<V>
|
|
283
|
+
: T extends TwsxVariantsConfig<infer V>
|
|
284
|
+
? VariantProps<V>
|
|
285
|
+
: T extends TwsxClassNameVariantsConfig<infer V>
|
|
286
|
+
? TwsxClassNameVariantProps<V>
|
|
287
|
+
: never;
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Infer slot names from a slots function.
|
|
291
|
+
*
|
|
292
|
+
* @example
|
|
293
|
+
* const card = twsxClassName({
|
|
294
|
+
* slots: { root: 'card', header: 'card-header', body: 'card-body' },
|
|
295
|
+
* variants: {}
|
|
296
|
+
* });
|
|
297
|
+
*
|
|
298
|
+
* type CardSlots = InferSlotNames<typeof card>;
|
|
299
|
+
* // Result: 'root' | 'header' | 'body'
|
|
300
|
+
*/
|
|
301
|
+
export type InferSlotNames<T> = T extends TwsxClassNameSlotsFunction<infer S, any>
|
|
302
|
+
? keyof S
|
|
303
|
+
: never;
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Extract variant names from a variants definition.
|
|
307
|
+
*
|
|
308
|
+
* @example
|
|
309
|
+
* const config = {
|
|
310
|
+
* variants: { size: { sm: '...', lg: '...' }, variant: { primary: '...' } }
|
|
311
|
+
* };
|
|
312
|
+
* type VariantNames = ExtractVariantNames<typeof config>;
|
|
313
|
+
* // Result: 'size' | 'variant'
|
|
314
|
+
*/
|
|
315
|
+
export type ExtractVariantNames<T extends { variants?: VariantsDefinition }> =
|
|
316
|
+
T['variants'] extends VariantsDefinition ? keyof T['variants'] : never;
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Extract variant options for a specific variant.
|
|
320
|
+
*
|
|
321
|
+
* @example
|
|
322
|
+
* const config = {
|
|
323
|
+
* variants: { size: { sm: '...', md: '...', lg: '...' } }
|
|
324
|
+
* };
|
|
325
|
+
* type SizeOptions = ExtractVariantOptions<typeof config, 'size'>;
|
|
326
|
+
* // Result: 'sm' | 'md' | 'lg'
|
|
327
|
+
*/
|
|
328
|
+
export type ExtractVariantOptions<
|
|
329
|
+
T extends { variants?: VariantsDefinition },
|
|
330
|
+
K extends keyof NonNullable<T['variants']>
|
|
331
|
+
> = T['variants'] extends VariantsDefinition
|
|
332
|
+
? keyof T['variants'][K]
|
|
333
|
+
: never;
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Make all variant props required.
|
|
337
|
+
* Useful when you want to enforce all variants are specified.
|
|
338
|
+
*/
|
|
339
|
+
export type RequiredVariantProps<V extends VariantsDefinition> = {
|
|
340
|
+
[K in keyof V]: keyof V[K];
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Pick only specific variants from props.
|
|
345
|
+
*/
|
|
346
|
+
export type PickVariantProps<V extends VariantsDefinition, K extends keyof V> = {
|
|
347
|
+
[P in K]?: keyof V[P];
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Omit specific variants from props.
|
|
352
|
+
*/
|
|
353
|
+
export type OmitVariantProps<V extends VariantsDefinition, K extends keyof V> = {
|
|
354
|
+
[P in Exclude<keyof V, K>]?: keyof V[P];
|
|
355
|
+
};
|
|
356
|
+
|
|
259
357
|
/** * Compound variant definition - strict typing for better autocomplete
|
|
260
358
|
*/
|
|
261
359
|
export interface CompoundVariant<V extends VariantsDefinition = VariantsDefinition> {
|
|
@@ -369,14 +467,905 @@ export function twsxVariants(
|
|
|
369
467
|
*/
|
|
370
468
|
export const performanceUtils: PerformanceUtils;
|
|
371
469
|
|
|
470
|
+
// ============================================================================
|
|
471
|
+
// twsxClassName - Advanced Unified CSS-in-JS API
|
|
472
|
+
// ============================================================================
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* Pseudo-class shorthands for twsxClassName
|
|
476
|
+
*/
|
|
477
|
+
export type PseudoShorthand =
|
|
478
|
+
| "hover" | "focus" | "active" | "disabled" | "visited" | "checked"
|
|
479
|
+
| "required" | "invalid" | "valid" | "empty" | "enabled" | "indeterminate"
|
|
480
|
+
| "focus-within" | "focus-visible" | "first" | "last" | "odd" | "even"
|
|
481
|
+
| "first-of-type" | "last-of-type" | "only" | "only-of-type"
|
|
482
|
+
| "placeholder" | "before" | "after" | "selection" | "marker" | "file" | "backdrop"
|
|
483
|
+
// Dark/Light mode
|
|
484
|
+
| "dark" | "light"
|
|
485
|
+
// Motion preferences
|
|
486
|
+
| "motion-safe" | "motion-reduce"
|
|
487
|
+
// Print
|
|
488
|
+
| "print"
|
|
489
|
+
// Contrast
|
|
490
|
+
| "contrast-more" | "contrast-less"
|
|
491
|
+
// Orientation
|
|
492
|
+
| "portrait" | "landscape";
|
|
493
|
+
|
|
494
|
+
/**
|
|
495
|
+
* Group/Peer state shorthands
|
|
496
|
+
*/
|
|
497
|
+
export type GroupPeerState =
|
|
498
|
+
| "group-hover" | "group-focus" | "group-active" | "group-focus-within"
|
|
499
|
+
| "group-focus-visible" | "group-disabled" | "group-checked" | "group-invalid" | "group-required"
|
|
500
|
+
| "peer-hover" | "peer-focus" | "peer-active" | "peer-focus-within"
|
|
501
|
+
| "peer-focus-visible" | "peer-disabled" | "peer-checked" | "peer-invalid"
|
|
502
|
+
| "peer-required" | "peer-placeholder-shown";
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* Responsive breakpoint shorthands
|
|
506
|
+
*/
|
|
507
|
+
export type ResponsiveBreakpoint = "sm" | "md" | "lg" | "xl" | "2xl";
|
|
508
|
+
|
|
509
|
+
/**
|
|
510
|
+
* Animation preset names
|
|
511
|
+
*/
|
|
512
|
+
export type AnimationPreset =
|
|
513
|
+
| "fadeIn" | "fadeOut" | "slideInUp" | "slideInDown" | "slideInLeft" | "slideInRight"
|
|
514
|
+
| "scaleIn" | "scaleOut" | "bounce" | "pulse" | "spin" | "ping" | "shake";
|
|
515
|
+
|
|
516
|
+
/**
|
|
517
|
+
* Custom animation configuration
|
|
518
|
+
*/
|
|
519
|
+
export interface AnimationConfig {
|
|
520
|
+
keyframes: Record<string, string>;
|
|
521
|
+
duration?: string;
|
|
522
|
+
timing?: string;
|
|
523
|
+
delay?: string;
|
|
524
|
+
iteration?: string | number;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* Design tokens structure
|
|
529
|
+
*/
|
|
530
|
+
export interface DesignTokens {
|
|
531
|
+
colors?: Record<string, string | Record<string, string>>;
|
|
532
|
+
spacing?: Record<string, string>;
|
|
533
|
+
fontSize?: Record<string, string>;
|
|
534
|
+
fontWeight?: Record<string, string>;
|
|
535
|
+
borderRadius?: Record<string, string>;
|
|
536
|
+
shadow?: Record<string, string>;
|
|
537
|
+
animation?: Record<string, AnimationConfig>;
|
|
538
|
+
custom?: Record<string, string>;
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
/**
|
|
542
|
+
* Theme tokens
|
|
543
|
+
*/
|
|
544
|
+
export interface ThemeTokens {
|
|
545
|
+
[key: string]: string | Record<string, string>;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* Basic twsxClassName config (returns className string)
|
|
550
|
+
*/
|
|
551
|
+
export interface TwsxClassNameBasicConfig {
|
|
552
|
+
/** Base Tailwind classes */
|
|
553
|
+
_?: string;
|
|
554
|
+
/** Component name (for readable className) */
|
|
555
|
+
name?: string;
|
|
556
|
+
/** Custom prefix (default: "twsx") */
|
|
557
|
+
prefix?: string;
|
|
558
|
+
/** Include hash in className (default: true) */
|
|
559
|
+
hash?: boolean;
|
|
560
|
+
/** Hash length (default: 8) */
|
|
561
|
+
hashLength?: number;
|
|
562
|
+
/** Auto-inject CSS to DOM (default: true) */
|
|
563
|
+
inject?: boolean;
|
|
564
|
+
/** Extend from another twsxClassName config */
|
|
565
|
+
extend?: TwsxClassNameVariantFunction<any> | TwsxClassNameBasicConfig;
|
|
566
|
+
/** Animation preset or custom config */
|
|
567
|
+
animation?: AnimationPreset | AnimationConfig;
|
|
568
|
+
/** Enter transition classes */
|
|
569
|
+
enter?: string;
|
|
570
|
+
/** Enter from state */
|
|
571
|
+
enterFrom?: string;
|
|
572
|
+
/** Enter to state */
|
|
573
|
+
enterTo?: string;
|
|
574
|
+
/** Exit/leave transition classes */
|
|
575
|
+
exit?: string;
|
|
576
|
+
/** Leave from state */
|
|
577
|
+
leaveFrom?: string;
|
|
578
|
+
/** Leave to state */
|
|
579
|
+
leaveTo?: string;
|
|
580
|
+
/** Pseudo-class shorthands, responsive, and custom selectors */
|
|
581
|
+
[key: string]: string | TwsxClassNameBasicConfig | AnimationPreset | AnimationConfig | boolean | number | undefined | any;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
/**
|
|
585
|
+
* Variant value - string classes or nested object with pseudo states
|
|
586
|
+
*/
|
|
587
|
+
export type TwsxClassNameVariantValue = string | {
|
|
588
|
+
_?: string;
|
|
589
|
+
[key: string]: string | undefined;
|
|
590
|
+
};
|
|
591
|
+
|
|
592
|
+
/**
|
|
593
|
+
* Variants definition for twsxClassName
|
|
594
|
+
*/
|
|
595
|
+
export interface TwsxClassNameVariantsDefinition {
|
|
596
|
+
[variantName: string]: {
|
|
597
|
+
[optionKey: string]: TwsxClassNameVariantValue;
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
/**
|
|
602
|
+
* Compound variant for twsxClassName
|
|
603
|
+
*/
|
|
604
|
+
export interface TwsxClassNameCompoundVariant<V extends TwsxClassNameVariantsDefinition = TwsxClassNameVariantsDefinition> {
|
|
605
|
+
class?: string;
|
|
606
|
+
className?: string;
|
|
607
|
+
[K: string]: string | string[] | boolean | undefined;
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
/**
|
|
611
|
+
* Responsive variant value - allows different values per breakpoint
|
|
612
|
+
*/
|
|
613
|
+
export type ResponsiveVariantValue<T> = T | {
|
|
614
|
+
initial?: T;
|
|
615
|
+
sm?: T;
|
|
616
|
+
md?: T;
|
|
617
|
+
lg?: T;
|
|
618
|
+
xl?: T;
|
|
619
|
+
"2xl"?: T;
|
|
620
|
+
};
|
|
621
|
+
|
|
622
|
+
/**
|
|
623
|
+
* twsxClassName variants config
|
|
624
|
+
*/
|
|
625
|
+
export interface TwsxClassNameVariantsConfig<V extends TwsxClassNameVariantsDefinition = TwsxClassNameVariantsDefinition> {
|
|
626
|
+
/** Component name */
|
|
627
|
+
name?: string;
|
|
628
|
+
/** Custom prefix */
|
|
629
|
+
prefix?: string;
|
|
630
|
+
/** Include hash */
|
|
631
|
+
hash?: boolean;
|
|
632
|
+
/** Hash length */
|
|
633
|
+
hashLength?: number;
|
|
634
|
+
/** Auto-inject CSS */
|
|
635
|
+
inject?: boolean;
|
|
636
|
+
/** Extend from another config */
|
|
637
|
+
extend?: TwsxClassNameVariantFunction<any> | TwsxClassNameVariantsConfig<any>;
|
|
638
|
+
/** Base Tailwind classes or nested object */
|
|
639
|
+
base?: string | { _?: string; [key: string]: string | undefined };
|
|
640
|
+
/** Variant definitions */
|
|
641
|
+
variants: V;
|
|
642
|
+
/** Compound variants */
|
|
643
|
+
compoundVariants?: TwsxClassNameCompoundVariant<V>[];
|
|
644
|
+
/** Default variant values */
|
|
645
|
+
defaultVariants?: { [K in keyof V]?: keyof V[K] | boolean };
|
|
646
|
+
/** Enable responsive variants for specified variant keys */
|
|
647
|
+
responsiveVariants?: (keyof V)[];
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
/**
|
|
651
|
+
* Slots definition for multi-part components
|
|
652
|
+
*/
|
|
653
|
+
export interface TwsxClassNameSlotsDefinition {
|
|
654
|
+
[slotName: string]: string | { _?: string; [key: string]: string | undefined };
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
/**
|
|
658
|
+
* twsxClassName slots config
|
|
659
|
+
*/
|
|
660
|
+
export interface TwsxClassNameSlotsConfig<
|
|
661
|
+
S extends TwsxClassNameSlotsDefinition = TwsxClassNameSlotsDefinition,
|
|
662
|
+
V extends TwsxClassNameVariantsDefinition = TwsxClassNameVariantsDefinition
|
|
663
|
+
> {
|
|
664
|
+
/** Component name */
|
|
665
|
+
name?: string;
|
|
666
|
+
/** Custom prefix */
|
|
667
|
+
prefix?: string;
|
|
668
|
+
/** Include hash */
|
|
669
|
+
hash?: boolean;
|
|
670
|
+
/** Hash length */
|
|
671
|
+
hashLength?: number;
|
|
672
|
+
/** Auto-inject CSS */
|
|
673
|
+
inject?: boolean;
|
|
674
|
+
/** Extend from another config */
|
|
675
|
+
extend?: TwsxClassNameSlotsFunction<any, any>;
|
|
676
|
+
/** Slot definitions */
|
|
677
|
+
slots: S;
|
|
678
|
+
/** Variant definitions (with slot-specific styles) */
|
|
679
|
+
variants?: V;
|
|
680
|
+
/** Compound variants */
|
|
681
|
+
compoundVariants?: TwsxClassNameCompoundVariant<V>[];
|
|
682
|
+
/** Default variant values */
|
|
683
|
+
defaultVariants?: { [K in keyof V]?: keyof V[K] | boolean };
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
/**
|
|
687
|
+
* Variant props with responsive support
|
|
688
|
+
*/
|
|
689
|
+
export type TwsxClassNameVariantProps<V extends TwsxClassNameVariantsDefinition> = {
|
|
690
|
+
[K in keyof V]?: keyof V[K] | boolean | ResponsiveVariantValue<keyof V[K]>;
|
|
691
|
+
};
|
|
692
|
+
|
|
693
|
+
/**
|
|
694
|
+
* Variant selector function return type
|
|
695
|
+
*/
|
|
696
|
+
export interface TwsxClassNameVariantFunction<V extends TwsxClassNameVariantsDefinition> {
|
|
697
|
+
(props?: TwsxClassNameVariantProps<V>): string;
|
|
698
|
+
/** Merge with additional classes */
|
|
699
|
+
merge(props?: TwsxClassNameVariantProps<V>, ...additionalClasses: ClassValue[]): string;
|
|
700
|
+
merge(...additionalClasses: ClassValue[]): string;
|
|
701
|
+
/** Get raw config */
|
|
702
|
+
raw(): TwsxClassNameVariantsConfig<V>;
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
/**
|
|
706
|
+
* Slots generator function return type
|
|
707
|
+
*/
|
|
708
|
+
export interface TwsxClassNameSlotsFunction<
|
|
709
|
+
S extends TwsxClassNameSlotsDefinition,
|
|
710
|
+
V extends TwsxClassNameVariantsDefinition
|
|
711
|
+
> {
|
|
712
|
+
(props?: TwsxClassNameVariantProps<V>): { [K in keyof S]: string };
|
|
713
|
+
/** Merge with additional classes per slot */
|
|
714
|
+
merge(props?: TwsxClassNameVariantProps<V>, slotOverrides?: Partial<{ [K in keyof S]: string }>): { [K in keyof S]: string };
|
|
715
|
+
/** Get raw config */
|
|
716
|
+
raw(): TwsxClassNameSlotsConfig<S, V>;
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
/**
|
|
720
|
+
* Global configuration options
|
|
721
|
+
*/
|
|
722
|
+
export interface TwsxClassNameGlobalConfig {
|
|
723
|
+
/** Default prefix (default: "twsx") */
|
|
724
|
+
prefix?: string;
|
|
725
|
+
/** Include hash by default (default: true) */
|
|
726
|
+
hash?: boolean;
|
|
727
|
+
/** Default hash length (default: 8) */
|
|
728
|
+
hashLength?: number;
|
|
729
|
+
/** Auto-inject CSS by default (default: true) */
|
|
730
|
+
inject?: boolean;
|
|
731
|
+
/** Deduplication (default: true) */
|
|
732
|
+
deduplicate?: boolean;
|
|
733
|
+
/** Custom breakpoints */
|
|
734
|
+
breakpoints?: Record<string, string>;
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
/**
|
|
738
|
+
* Unified CSS-in-JS API with smart mode detection.
|
|
739
|
+
*
|
|
740
|
+
* @example
|
|
741
|
+
* // Basic mode - returns className string
|
|
742
|
+
* const btn = twsxClassName({ _: 'bg-blue-500 p-4', hover: 'bg-blue-600' })
|
|
743
|
+
*
|
|
744
|
+
* // With dark mode
|
|
745
|
+
* const card = twsxClassName({ _: 'bg-white', dark: 'bg-gray-900' })
|
|
746
|
+
*
|
|
747
|
+
* // With group/peer states
|
|
748
|
+
* const icon = twsxClassName({ _: 'opacity-0', 'group-hover': 'opacity-100' })
|
|
749
|
+
*
|
|
750
|
+
* // Variants mode with boolean variants
|
|
751
|
+
* const btn = twsxClassName({
|
|
752
|
+
* base: 'px-4 py-2',
|
|
753
|
+
* variants: {
|
|
754
|
+
* disabled: { true: 'opacity-50', false: '' }
|
|
755
|
+
* }
|
|
756
|
+
* })
|
|
757
|
+
* btn({ disabled: true })
|
|
758
|
+
*
|
|
759
|
+
* // Responsive variants
|
|
760
|
+
* const btn = twsxClassName({
|
|
761
|
+
* variants: { size: { sm: '...', lg: '...' } },
|
|
762
|
+
* responsiveVariants: ['size']
|
|
763
|
+
* })
|
|
764
|
+
* btn({ size: { initial: 'sm', md: 'lg' } })
|
|
765
|
+
*
|
|
766
|
+
* // With design tokens
|
|
767
|
+
* twsxClassName.defineTokens({ colors: { primary: '#3b82f6' } })
|
|
768
|
+
* const btn = twsxClassName({ _: 'bg-$colors.primary' })
|
|
769
|
+
*
|
|
770
|
+
* // Extend existing config
|
|
771
|
+
* const primaryBtn = twsxClassName.extend(btn, { _: 'text-white' })
|
|
772
|
+
*/
|
|
773
|
+
export function twsxClassName(config: TwsxClassNameBasicConfig): string;
|
|
774
|
+
export function twsxClassName(name: string, config: TwsxClassNameBasicConfig): string;
|
|
775
|
+
export function twsxClassName<V extends TwsxClassNameVariantsDefinition>(
|
|
776
|
+
config: TwsxClassNameVariantsConfig<V>
|
|
777
|
+
): TwsxClassNameVariantFunction<V>;
|
|
778
|
+
export function twsxClassName<
|
|
779
|
+
S extends TwsxClassNameSlotsDefinition,
|
|
780
|
+
V extends TwsxClassNameVariantsDefinition
|
|
781
|
+
>(
|
|
782
|
+
config: TwsxClassNameSlotsConfig<S, V>
|
|
783
|
+
): TwsxClassNameSlotsFunction<S, V>;
|
|
784
|
+
|
|
785
|
+
export namespace twsxClassName {
|
|
786
|
+
/**
|
|
787
|
+
* Configure global settings
|
|
788
|
+
*/
|
|
789
|
+
function config(options: TwsxClassNameGlobalConfig): TwsxClassNameGlobalConfig;
|
|
790
|
+
|
|
791
|
+
/**
|
|
792
|
+
* Get current configuration
|
|
793
|
+
*/
|
|
794
|
+
function getConfig(): TwsxClassNameGlobalConfig;
|
|
795
|
+
|
|
796
|
+
/**
|
|
797
|
+
* Extend an existing twsxClassName config
|
|
798
|
+
*/
|
|
799
|
+
function extend<V extends TwsxClassNameVariantsDefinition>(
|
|
800
|
+
base: TwsxClassNameVariantFunction<V> | TwsxClassNameVariantsConfig<V>,
|
|
801
|
+
extension: Partial<TwsxClassNameVariantsConfig<V>>
|
|
802
|
+
): TwsxClassNameVariantFunction<V>;
|
|
803
|
+
|
|
804
|
+
/**
|
|
805
|
+
* Define design tokens
|
|
806
|
+
*/
|
|
807
|
+
function defineTokens(tokens: DesignTokens): DesignTokens;
|
|
808
|
+
|
|
809
|
+
/**
|
|
810
|
+
* Get all defined tokens
|
|
811
|
+
*/
|
|
812
|
+
function getTokens(): DesignTokens;
|
|
813
|
+
|
|
814
|
+
/**
|
|
815
|
+
* Set a single token value
|
|
816
|
+
*/
|
|
817
|
+
function setToken(path: string, value: string): void;
|
|
818
|
+
|
|
819
|
+
/**
|
|
820
|
+
* Create a named theme
|
|
821
|
+
*/
|
|
822
|
+
function createTheme(name: string, tokens: ThemeTokens): ThemeTokens;
|
|
823
|
+
|
|
824
|
+
/**
|
|
825
|
+
* Set the active theme
|
|
826
|
+
*/
|
|
827
|
+
function setTheme(name: string): string;
|
|
828
|
+
|
|
829
|
+
/**
|
|
830
|
+
* Get the active theme name
|
|
831
|
+
*/
|
|
832
|
+
function getTheme(): string;
|
|
833
|
+
|
|
834
|
+
/**
|
|
835
|
+
* Get all defined themes
|
|
836
|
+
*/
|
|
837
|
+
function getThemes(): Record<string, ThemeTokens>;
|
|
838
|
+
|
|
839
|
+
/**
|
|
840
|
+
* Define a custom animation preset
|
|
841
|
+
*/
|
|
842
|
+
function defineAnimation(name: string, animation: AnimationConfig): void;
|
|
843
|
+
|
|
844
|
+
/**
|
|
845
|
+
* Get all animation presets
|
|
846
|
+
*/
|
|
847
|
+
function getAnimations(): Record<string, AnimationConfig>;
|
|
848
|
+
|
|
849
|
+
/**
|
|
850
|
+
* Clear all caches
|
|
851
|
+
*/
|
|
852
|
+
function clearCache(): void;
|
|
853
|
+
|
|
854
|
+
/**
|
|
855
|
+
* Get cache statistics
|
|
856
|
+
*/
|
|
857
|
+
function getCacheStats(): {
|
|
858
|
+
classNameCacheSize: number;
|
|
859
|
+
cssCacheSize: number;
|
|
860
|
+
styleRegistrySize: number;
|
|
861
|
+
};
|
|
862
|
+
|
|
863
|
+
/**
|
|
864
|
+
* Get generated CSS for a className (useful for SSR)
|
|
865
|
+
*/
|
|
866
|
+
function getCSS(className: string): string;
|
|
867
|
+
|
|
868
|
+
/**
|
|
869
|
+
* Get all generated CSS (useful for SSR)
|
|
870
|
+
*/
|
|
871
|
+
function getAllCSS(): string;
|
|
872
|
+
|
|
873
|
+
/**
|
|
874
|
+
* Extract CSS as a style tag string (for SSR)
|
|
875
|
+
*/
|
|
876
|
+
function extractCSS(): string;
|
|
877
|
+
|
|
878
|
+
/**
|
|
879
|
+
* Merge multiple class values (alias for cx)
|
|
880
|
+
*/
|
|
881
|
+
function merge(...args: ClassValue[]): string;
|
|
882
|
+
|
|
883
|
+
/**
|
|
884
|
+
* Compose multiple configs into one
|
|
885
|
+
*/
|
|
886
|
+
function compose<V extends TwsxClassNameVariantsDefinition>(
|
|
887
|
+
...configs: (TwsxClassNameVariantFunction<any> | TwsxClassNameVariantsConfig<any>)[]
|
|
888
|
+
): TwsxClassNameVariantsConfig<V>;
|
|
889
|
+
|
|
890
|
+
/**
|
|
891
|
+
* Atomic CSS class generator.
|
|
892
|
+
* Generates reusable atomic CSS classes from Tailwind utilities.
|
|
893
|
+
* Unlike tws() which returns inline styles, tw() returns class names
|
|
894
|
+
* with auto-injected CSS that supports pseudo-classes and responsive.
|
|
895
|
+
*
|
|
896
|
+
* @example
|
|
897
|
+
* tw('flex gap-3')
|
|
898
|
+
* // → "tw-flex tw-gap-3"
|
|
899
|
+
*
|
|
900
|
+
* tw('hover:bg-blue-500 md:flex-row')
|
|
901
|
+
* // → "tw-hover-bg-blue-500 tw-md-flex-row"
|
|
902
|
+
*
|
|
903
|
+
* // Usage in templates
|
|
904
|
+
* <div class="${tw('flex gap-3 hover:bg-gray-100')}">
|
|
905
|
+
*/
|
|
906
|
+
function tw(classString: string): string;
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
// ============================================================================
|
|
910
|
+
// tw() - Atomic CSS Class Generator (standalone export)
|
|
911
|
+
// ============================================================================
|
|
912
|
+
|
|
913
|
+
/**
|
|
914
|
+
* Atomic CSS class generator.
|
|
915
|
+
* Generates reusable atomic CSS classes from Tailwind utilities.
|
|
916
|
+
* Unlike tws() which returns inline styles, tw() returns class names
|
|
917
|
+
* with auto-injected CSS that supports pseudo-classes and responsive breakpoints.
|
|
918
|
+
*
|
|
919
|
+
* @param classString - Space-separated Tailwind utility classes
|
|
920
|
+
* @returns Space-separated atomic class names (e.g., "tw-flex tw-gap-3")
|
|
921
|
+
*
|
|
922
|
+
* @example
|
|
923
|
+
* // Basic usage
|
|
924
|
+
* tw('flex gap-3 items-center')
|
|
925
|
+
* // → "tw-flex tw-gap-3 tw-items-center"
|
|
926
|
+
*
|
|
927
|
+
* // With pseudo-classes (unlike tws, these work!)
|
|
928
|
+
* tw('bg-gray-100 hover:bg-gray-200 focus:ring-2')
|
|
929
|
+
* // → "tw-bg-gray-100 tw-hover-bg-gray-200 tw-focus-ring-2"
|
|
930
|
+
*
|
|
931
|
+
* // With responsive breakpoints
|
|
932
|
+
* tw('flex flex-col md:flex-row lg:gap-8')
|
|
933
|
+
* // → "tw-flex tw-flex-col tw-md-flex-row tw-lg-gap-8"
|
|
934
|
+
*
|
|
935
|
+
* // Combined modifiers
|
|
936
|
+
* tw('md:hover:bg-blue-500')
|
|
937
|
+
* // → "tw-md-hover-bg-blue-500"
|
|
938
|
+
*
|
|
939
|
+
* // In HTML/JSX
|
|
940
|
+
* <div class={tw('flex gap-3 hover:bg-gray-100')}>...</div>
|
|
941
|
+
*/
|
|
942
|
+
export function tw(classString: string): string;
|
|
943
|
+
|
|
944
|
+
// ============================================================================
|
|
945
|
+
// SSR Collector (Modern API)
|
|
946
|
+
// ============================================================================
|
|
947
|
+
|
|
948
|
+
/**
|
|
949
|
+
* SSR Collector options
|
|
950
|
+
*/
|
|
951
|
+
export interface SSRCollectorOptions {
|
|
952
|
+
/** Enable CSS deduplication (default: true) */
|
|
953
|
+
dedupe?: boolean;
|
|
954
|
+
/** Enable CSS minification (default: false) */
|
|
955
|
+
minify?: boolean;
|
|
956
|
+
/** Sort CSS by specificity (default: true) */
|
|
957
|
+
sort?: boolean;
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
/**
|
|
961
|
+
* Extract options for SSR
|
|
962
|
+
*/
|
|
963
|
+
export interface SSRExtractOptions {
|
|
964
|
+
/** Style tag ID (default: "twsx-ssr") */
|
|
965
|
+
id?: string;
|
|
966
|
+
/** CSP nonce value */
|
|
967
|
+
nonce?: string;
|
|
968
|
+
/** Minify output CSS */
|
|
969
|
+
minify?: boolean;
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
/**
|
|
973
|
+
* Critical CSS extraction result
|
|
974
|
+
*/
|
|
975
|
+
export interface SSRCriticalResult {
|
|
976
|
+
/** Critical CSS wrapped in style tag */
|
|
977
|
+
critical: string;
|
|
978
|
+
/** Remaining non-critical CSS */
|
|
979
|
+
rest: string;
|
|
980
|
+
/** Extraction statistics */
|
|
981
|
+
stats: {
|
|
982
|
+
criticalSize: number;
|
|
983
|
+
criticalCount: number;
|
|
984
|
+
totalCount: number;
|
|
985
|
+
};
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
/**
|
|
989
|
+
* SSR statistics
|
|
990
|
+
*/
|
|
991
|
+
export interface SSRStats {
|
|
992
|
+
ruleCount: number;
|
|
993
|
+
uniqueCount: number;
|
|
994
|
+
totalSize: number;
|
|
995
|
+
minifiedSize: number;
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
/**
|
|
999
|
+
* SSR Collector instance
|
|
1000
|
+
*/
|
|
1001
|
+
export interface SSRCollector {
|
|
1002
|
+
/** Check if currently collecting */
|
|
1003
|
+
readonly isCollecting: boolean;
|
|
1004
|
+
/** Get collected CSS rule count */
|
|
1005
|
+
readonly count: number;
|
|
1006
|
+
/** Get unique CSS rule count */
|
|
1007
|
+
readonly uniqueCount: number;
|
|
1008
|
+
|
|
1009
|
+
/** Peek at collected CSS without stopping */
|
|
1010
|
+
peek(): string;
|
|
1011
|
+
/** Extract CSS as raw string and stop collecting */
|
|
1012
|
+
extractRaw(options?: { shouldMinify?: boolean }): string;
|
|
1013
|
+
/** Extract CSS wrapped in <style> tag and stop collecting */
|
|
1014
|
+
extract(options?: SSRExtractOptions): string;
|
|
1015
|
+
/** Extract critical CSS (above-the-fold) */
|
|
1016
|
+
extractCritical(options?: { maxSize?: number; nonce?: string; id?: string }): SSRCriticalResult;
|
|
1017
|
+
/** Clear collected CSS and optionally restart */
|
|
1018
|
+
clear(restart?: boolean): void;
|
|
1019
|
+
/** Get collection statistics */
|
|
1020
|
+
getStats(): SSRStats;
|
|
1021
|
+
/** @internal Add CSS to collection */
|
|
1022
|
+
_collect(css: string): void;
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
/**
|
|
1026
|
+
* Create an SSR collector for collecting CSS during server-side rendering.
|
|
1027
|
+
*
|
|
1028
|
+
* @example
|
|
1029
|
+
* const ssr = createSSRCollector({ dedupe: true, minify: true })
|
|
1030
|
+
* const html = renderToString(<App />)
|
|
1031
|
+
* const css = ssr.extract()
|
|
1032
|
+
*
|
|
1033
|
+
* // With critical CSS extraction
|
|
1034
|
+
* const { critical, rest } = ssr.extractCritical({ maxSize: 14000 })
|
|
1035
|
+
*/
|
|
1036
|
+
export function createSSRCollector(options?: SSRCollectorOptions): SSRCollector;
|
|
1037
|
+
|
|
1038
|
+
// ============================================================================
|
|
1039
|
+
// Animation System (Unified API)
|
|
1040
|
+
// ============================================================================
|
|
1041
|
+
|
|
1042
|
+
/**
|
|
1043
|
+
* Animation keyframe definition
|
|
1044
|
+
*/
|
|
1045
|
+
export interface AnimationKeyframe {
|
|
1046
|
+
[property: string]: string | number;
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
/**
|
|
1050
|
+
* Animation options (Web Animations API compatible)
|
|
1051
|
+
*/
|
|
1052
|
+
export interface AnimationOptions {
|
|
1053
|
+
duration?: number;
|
|
1054
|
+
easing?: string;
|
|
1055
|
+
delay?: number;
|
|
1056
|
+
iterations?: number | "infinite";
|
|
1057
|
+
fill?: "none" | "forwards" | "backwards" | "both" | "auto";
|
|
1058
|
+
direction?: "normal" | "reverse" | "alternate" | "alternate-reverse";
|
|
1059
|
+
/** Called when animation starts */
|
|
1060
|
+
onStart?: (animation: Animation) => void;
|
|
1061
|
+
/** Called when animation completes */
|
|
1062
|
+
onComplete?: (animation: Animation) => void;
|
|
1063
|
+
/** Called when animation is cancelled */
|
|
1064
|
+
onCancel?: (animation: Animation) => void;
|
|
1065
|
+
/** Custom animation ID */
|
|
1066
|
+
id?: string;
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
/**
|
|
1070
|
+
* Animation preset configuration
|
|
1071
|
+
*/
|
|
1072
|
+
export interface AnimationPresetConfig {
|
|
1073
|
+
keyframes: AnimationKeyframe[];
|
|
1074
|
+
options: AnimationOptions;
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
/**
|
|
1078
|
+
* Animation controller returned by animate()
|
|
1079
|
+
*/
|
|
1080
|
+
export interface AnimationController {
|
|
1081
|
+
/** Animation ID */
|
|
1082
|
+
readonly id: string | null;
|
|
1083
|
+
/** Native Animation object */
|
|
1084
|
+
readonly animation: Animation | null;
|
|
1085
|
+
/** Current play state */
|
|
1086
|
+
readonly playState: AnimationPlayState;
|
|
1087
|
+
/** Current time in milliseconds */
|
|
1088
|
+
currentTime: number;
|
|
1089
|
+
/** Promise that resolves when animation finishes */
|
|
1090
|
+
readonly finished: Promise<Animation>;
|
|
1091
|
+
/** Whether animation is pending */
|
|
1092
|
+
readonly pending: boolean;
|
|
1093
|
+
|
|
1094
|
+
/** Play the animation */
|
|
1095
|
+
play(): AnimationController;
|
|
1096
|
+
/** Pause the animation */
|
|
1097
|
+
pause(): AnimationController;
|
|
1098
|
+
/** Cancel the animation */
|
|
1099
|
+
cancel(): AnimationController;
|
|
1100
|
+
/** Finish the animation immediately */
|
|
1101
|
+
finish(): AnimationController;
|
|
1102
|
+
/** Reverse the animation */
|
|
1103
|
+
reverse(): AnimationController;
|
|
1104
|
+
/** Seek to specific progress (0-1) */
|
|
1105
|
+
seek(progress: number): AnimationController;
|
|
1106
|
+
/** Set playback speed */
|
|
1107
|
+
setSpeed(rate: number): AnimationController;
|
|
1108
|
+
/** Replay animation from start */
|
|
1109
|
+
replay(): AnimationController;
|
|
1110
|
+
/** Promise interface */
|
|
1111
|
+
then<T>(resolve?: (value: Animation) => T, reject?: (reason: any) => T): Promise<T>;
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
/**
|
|
1115
|
+
* Chain controller for sequential animations
|
|
1116
|
+
*/
|
|
1117
|
+
export interface ChainController {
|
|
1118
|
+
/** Current step index */
|
|
1119
|
+
readonly currentStep: number;
|
|
1120
|
+
/** Total number of steps */
|
|
1121
|
+
readonly totalSteps: number;
|
|
1122
|
+
/** Progress (0-1) */
|
|
1123
|
+
readonly progress: number;
|
|
1124
|
+
/** Cancel the chain */
|
|
1125
|
+
cancel(): void;
|
|
1126
|
+
/** Promise that resolves when chain completes */
|
|
1127
|
+
readonly finished: Promise<void>;
|
|
1128
|
+
then<T>(resolve?: () => T, reject?: (reason: any) => T): Promise<T>;
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
/**
|
|
1132
|
+
* Stagger controller for parallel staggered animations
|
|
1133
|
+
*/
|
|
1134
|
+
export interface StaggerController {
|
|
1135
|
+
/** Individual animation controllers */
|
|
1136
|
+
readonly controllers: AnimationController[];
|
|
1137
|
+
/** Number of elements */
|
|
1138
|
+
readonly count: number;
|
|
1139
|
+
/** Cancel all animations */
|
|
1140
|
+
cancelAll(): StaggerController;
|
|
1141
|
+
/** Pause all animations */
|
|
1142
|
+
pauseAll(): StaggerController;
|
|
1143
|
+
/** Play all animations */
|
|
1144
|
+
playAll(): StaggerController;
|
|
1145
|
+
/** Reverse all animations */
|
|
1146
|
+
reverseAll(): StaggerController;
|
|
1147
|
+
/** Set speed for all animations */
|
|
1148
|
+
setSpeedAll(rate: number): StaggerController;
|
|
1149
|
+
/** Wait for all animations to complete */
|
|
1150
|
+
waitAll(): Promise<void>;
|
|
1151
|
+
then<T>(resolve?: () => T, reject?: (reason: any) => T): Promise<T>;
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1154
|
+
/**
|
|
1155
|
+
* Stagger options
|
|
1156
|
+
*/
|
|
1157
|
+
export interface StaggerOptions extends AnimationOptions {
|
|
1158
|
+
/** Delay between each element (default: 50ms) */
|
|
1159
|
+
delay?: number;
|
|
1160
|
+
/** Direction to start stagger */
|
|
1161
|
+
from?: "start" | "end" | "center" | "random";
|
|
1162
|
+
/** Called for each element */
|
|
1163
|
+
onEach?: (index: number, element: HTMLElement) => void;
|
|
1164
|
+
/** Called when all animations complete */
|
|
1165
|
+
onAllComplete?: () => void;
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
/**
|
|
1169
|
+
* Chain animation item
|
|
1170
|
+
*/
|
|
1171
|
+
export type ChainAnimationItem =
|
|
1172
|
+
| string
|
|
1173
|
+
| { name: string; delay?: number; options?: AnimationOptions };
|
|
1174
|
+
|
|
1175
|
+
/**
|
|
1176
|
+
* Animation preset names
|
|
1177
|
+
*/
|
|
1178
|
+
export type AnimationPresetName =
|
|
1179
|
+
| "fadeIn" | "fadeOut"
|
|
1180
|
+
| "slideUp" | "slideDown" | "slideLeft" | "slideRight"
|
|
1181
|
+
| "zoomIn" | "zoomOut"
|
|
1182
|
+
| "bounce" | "shake" | "pulse" | "spin"
|
|
1183
|
+
| "flipX" | "flipY"
|
|
1184
|
+
| "enterScale" | "exitScale"
|
|
1185
|
+
| "wiggle" | "heartbeat";
|
|
1186
|
+
|
|
1187
|
+
/**
|
|
1188
|
+
* Easing preset names
|
|
1189
|
+
*/
|
|
1190
|
+
export type EasingPresetName =
|
|
1191
|
+
| "linear" | "ease" | "easeIn" | "easeOut" | "easeInOut"
|
|
1192
|
+
| "spring" | "springLight" | "springMedium" | "springHeavy"
|
|
1193
|
+
| "smooth" | "smoothIn" | "smoothOut"
|
|
1194
|
+
| "bounce" | "elastic"
|
|
1195
|
+
| "anticipate" | "overshoot";
|
|
1196
|
+
|
|
1197
|
+
/**
|
|
1198
|
+
* Animation presets object
|
|
1199
|
+
*/
|
|
1200
|
+
export const ANIMATION_PRESETS: Record<AnimationPresetName, AnimationPresetConfig>;
|
|
1201
|
+
|
|
1202
|
+
/**
|
|
1203
|
+
* Easing presets object
|
|
1204
|
+
*/
|
|
1205
|
+
export const EASING: Record<EasingPresetName, string>;
|
|
1206
|
+
|
|
1207
|
+
/**
|
|
1208
|
+
* Apply animation to an element
|
|
1209
|
+
*
|
|
1210
|
+
* @example
|
|
1211
|
+
* // Using preset
|
|
1212
|
+
* const ctrl = animate(element, 'fadeIn')
|
|
1213
|
+
*
|
|
1214
|
+
* // With options
|
|
1215
|
+
* animate(element, 'slideUp', { duration: 600, easing: 'spring' })
|
|
1216
|
+
*
|
|
1217
|
+
* // With callbacks
|
|
1218
|
+
* animate(element, 'bounce', {
|
|
1219
|
+
* onComplete: () => console.log('done!')
|
|
1220
|
+
* })
|
|
1221
|
+
*
|
|
1222
|
+
* // Control animation
|
|
1223
|
+
* ctrl.pause()
|
|
1224
|
+
* ctrl.reverse()
|
|
1225
|
+
* await ctrl.finished
|
|
1226
|
+
*/
|
|
1227
|
+
export function animate(
|
|
1228
|
+
element: HTMLElement,
|
|
1229
|
+
animation: AnimationPresetName | { keyframes: AnimationKeyframe[]; options?: AnimationOptions },
|
|
1230
|
+
options?: AnimationOptions
|
|
1231
|
+
): AnimationController;
|
|
1232
|
+
|
|
1233
|
+
/**
|
|
1234
|
+
* Chain multiple animations sequentially
|
|
1235
|
+
*
|
|
1236
|
+
* @example
|
|
1237
|
+
* await chain(element, ['fadeIn', 'pulse', 'fadeOut'])
|
|
1238
|
+
*
|
|
1239
|
+
* // With delays
|
|
1240
|
+
* chain(element, [
|
|
1241
|
+
* 'fadeIn',
|
|
1242
|
+
* { name: 'pulse', delay: 100 },
|
|
1243
|
+
* 'fadeOut'
|
|
1244
|
+
* ])
|
|
1245
|
+
*/
|
|
1246
|
+
export function chain(
|
|
1247
|
+
element: HTMLElement,
|
|
1248
|
+
animations: ChainAnimationItem[],
|
|
1249
|
+
options?: { onStepComplete?: (step: number, name: string) => void; onComplete?: () => void; onCancel?: (step: number) => void }
|
|
1250
|
+
): ChainController;
|
|
1251
|
+
|
|
1252
|
+
/**
|
|
1253
|
+
* Apply staggered animation to multiple elements
|
|
1254
|
+
*
|
|
1255
|
+
* @example
|
|
1256
|
+
* // Basic stagger
|
|
1257
|
+
* stagger(listItems, 'slideUp', { delay: 50 })
|
|
1258
|
+
*
|
|
1259
|
+
* // Wait for all
|
|
1260
|
+
* await stagger(items, 'fadeIn').waitAll()
|
|
1261
|
+
*
|
|
1262
|
+
* // From center
|
|
1263
|
+
* stagger(items, 'zoomIn', { from: 'center' })
|
|
1264
|
+
*/
|
|
1265
|
+
export function stagger(
|
|
1266
|
+
elements: HTMLElement[] | NodeListOf<HTMLElement>,
|
|
1267
|
+
animation: AnimationPresetName | { keyframes: AnimationKeyframe[]; options?: AnimationOptions },
|
|
1268
|
+
options?: StaggerOptions
|
|
1269
|
+
): StaggerController;
|
|
1270
|
+
|
|
1271
|
+
/**
|
|
1272
|
+
* Run multiple animations in parallel
|
|
1273
|
+
*
|
|
1274
|
+
* @example
|
|
1275
|
+
* await parallel([
|
|
1276
|
+
* { element: el1, animation: 'fadeIn' },
|
|
1277
|
+
* { element: el2, animation: 'slideUp' }
|
|
1278
|
+
* ])
|
|
1279
|
+
*/
|
|
1280
|
+
export function parallel(
|
|
1281
|
+
configs: Array<{ element: HTMLElement; animation: AnimationPresetName | AnimationPresetConfig; options?: AnimationOptions }>
|
|
1282
|
+
): Promise<AnimationController[]>;
|
|
1283
|
+
|
|
1284
|
+
/**
|
|
1285
|
+
* Apply CSS transition to element
|
|
1286
|
+
*
|
|
1287
|
+
* @example
|
|
1288
|
+
* await transition(element, { opacity: 0, transform: 'scale(0.9)' }, { duration: 300 })
|
|
1289
|
+
*/
|
|
1290
|
+
export function transition(
|
|
1291
|
+
element: HTMLElement,
|
|
1292
|
+
properties: Record<string, string | number>,
|
|
1293
|
+
options?: { duration?: number; easing?: string; delay?: number }
|
|
1294
|
+
): Promise<void>;
|
|
1295
|
+
|
|
1296
|
+
/**
|
|
1297
|
+
* Create CSS keyframes and return animation CSS value
|
|
1298
|
+
*
|
|
1299
|
+
* @example
|
|
1300
|
+
* const animation = createKeyframes('myAnim', {
|
|
1301
|
+
* '0%': { opacity: 0 },
|
|
1302
|
+
* '100%': { opacity: 1 }
|
|
1303
|
+
* })
|
|
1304
|
+
* // → "myAnim 500ms ease-out forwards"
|
|
1305
|
+
*/
|
|
1306
|
+
export function createKeyframes(
|
|
1307
|
+
name: string,
|
|
1308
|
+
frames: Record<string, Record<string, string | number>>,
|
|
1309
|
+
options?: { duration?: number; easing?: string; fill?: string; iterations?: number | "infinite"; inject?: boolean }
|
|
1310
|
+
): string;
|
|
1311
|
+
|
|
1312
|
+
/**
|
|
1313
|
+
* Clear all injected keyframes from document
|
|
1314
|
+
*/
|
|
1315
|
+
export function clearKeyframes(): void;
|
|
1316
|
+
|
|
1317
|
+
/**
|
|
1318
|
+
* Cancel all active animations
|
|
1319
|
+
*/
|
|
1320
|
+
export function cancelAllAnimations(): void;
|
|
1321
|
+
|
|
1322
|
+
/**
|
|
1323
|
+
* Get count of currently active animations
|
|
1324
|
+
*/
|
|
1325
|
+
export function getActiveAnimationCount(): number;
|
|
1326
|
+
|
|
1327
|
+
/**
|
|
1328
|
+
* Register a custom animation preset
|
|
1329
|
+
*
|
|
1330
|
+
* @example
|
|
1331
|
+
* registerPreset('myFade', {
|
|
1332
|
+
* keyframes: [{ opacity: 0 }, { opacity: 1 }],
|
|
1333
|
+
* options: { duration: 400 }
|
|
1334
|
+
* })
|
|
1335
|
+
*/
|
|
1336
|
+
export function registerPreset(name: string, config: AnimationPresetConfig): void;
|
|
1337
|
+
|
|
1338
|
+
/**
|
|
1339
|
+
* Get all available preset names
|
|
1340
|
+
*/
|
|
1341
|
+
export function getPresetNames(): string[];
|
|
1342
|
+
|
|
1343
|
+
/**
|
|
1344
|
+
* Check if Web Animations API is supported
|
|
1345
|
+
*/
|
|
1346
|
+
export function isAnimationSupported(): boolean;
|
|
1347
|
+
|
|
372
1348
|
// Default export (if needed)
|
|
373
1349
|
declare const tailwindToStyle: {
|
|
374
1350
|
tws: typeof tws;
|
|
375
1351
|
twsx: typeof twsx;
|
|
376
1352
|
twsxVariants: typeof twsxVariants;
|
|
1353
|
+
twsxClassName: typeof twsxClassName;
|
|
1354
|
+
tw: typeof tw;
|
|
377
1355
|
debouncedTws: typeof debouncedTws;
|
|
378
1356
|
debouncedTwsx: typeof debouncedTwsx;
|
|
379
1357
|
performanceUtils: typeof performanceUtils;
|
|
1358
|
+
// SSR
|
|
1359
|
+
createSSRCollector: typeof createSSRCollector;
|
|
1360
|
+
// Animation
|
|
1361
|
+
animate: typeof animate;
|
|
1362
|
+
chain: typeof chain;
|
|
1363
|
+
stagger: typeof stagger;
|
|
1364
|
+
parallel: typeof parallel;
|
|
1365
|
+
transition: typeof transition;
|
|
1366
|
+
createKeyframes: typeof createKeyframes;
|
|
1367
|
+
ANIMATION_PRESETS: typeof ANIMATION_PRESETS;
|
|
1368
|
+
EASING: typeof EASING;
|
|
380
1369
|
};
|
|
381
1370
|
|
|
382
1371
|
export default tailwindToStyle;
|