fancy-ui-svelte 0.5.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +98 -74
  2. package/dist/fancy-ui/dock/index.d.ts +1 -1
  3. package/dist/fancy-ui/dock/index.js +0 -1
  4. package/dist/fancy-ui/editorial-engine/EditorialEngine.svelte +181 -0
  5. package/dist/fancy-ui/editorial-engine/EditorialEngine.svelte.d.ts +26 -0
  6. package/dist/fancy-ui/editorial-engine/README.md +56 -0
  7. package/dist/fancy-ui/editorial-engine/engine.d.ts +7 -0
  8. package/dist/fancy-ui/editorial-engine/engine.js +581 -0
  9. package/dist/fancy-ui/editorial-engine/index.d.ts +2 -0
  10. package/dist/fancy-ui/editorial-engine/index.js +1 -0
  11. package/dist/fancy-ui/frosted-glass/FrostedGlass.svelte +202 -0
  12. package/dist/fancy-ui/frosted-glass/FrostedGlass.svelte.d.ts +20 -0
  13. package/dist/fancy-ui/frosted-glass/FrostedGlass.test.d.ts +1 -0
  14. package/dist/fancy-ui/frosted-glass/FrostedGlass.test.js +48 -0
  15. package/dist/fancy-ui/frosted-glass/README.md +59 -0
  16. package/dist/fancy-ui/frosted-glass/index.d.ts +1 -0
  17. package/dist/fancy-ui/frosted-glass/index.js +1 -0
  18. package/dist/fancy-ui/index.d.ts +5 -0
  19. package/dist/fancy-ui/index.js +5 -0
  20. package/dist/fancy-ui/line-reveal/LineReveal.svelte +168 -0
  21. package/dist/fancy-ui/line-reveal/LineReveal.svelte.d.ts +33 -0
  22. package/dist/fancy-ui/line-reveal/README.md +42 -0
  23. package/dist/fancy-ui/line-reveal/index.d.ts +2 -0
  24. package/dist/fancy-ui/line-reveal/index.js +1 -0
  25. package/dist/fancy-ui/noise-reveal/NoiseReveal.svelte +323 -0
  26. package/dist/fancy-ui/noise-reveal/NoiseReveal.svelte.d.ts +19 -0
  27. package/dist/fancy-ui/noise-reveal/NoiseReveal.test.d.ts +1 -0
  28. package/dist/fancy-ui/noise-reveal/NoiseReveal.test.js +123 -0
  29. package/dist/fancy-ui/noise-reveal/index.d.ts +2 -0
  30. package/dist/fancy-ui/noise-reveal/index.js +1 -0
  31. package/dist/fancy-ui/registry.js +196 -11
  32. package/dist/fancy-ui/themes.d.ts +38 -0
  33. package/dist/fancy-ui/themes.js +356 -0
  34. package/dist/types.d.ts +2 -0
  35. package/dist/utils/animation.d.ts +109 -0
  36. package/dist/utils/animation.js +198 -0
  37. package/dist/utils/color.d.ts +128 -0
  38. package/dist/utils/color.js +314 -0
  39. package/dist/utils/geometry.d.ts +125 -0
  40. package/dist/utils/geometry.js +250 -0
  41. package/dist/utils/index.d.ts +8 -0
  42. package/dist/utils/index.js +39 -0
  43. package/package.json +13 -3
@@ -0,0 +1,109 @@
1
+ /**
2
+ * Animation Utilities
3
+ *
4
+ * Helpers for creating smooth animations, spring physics, and easing functions.
5
+ * Used across many FancyUI components for consistent animation behavior.
6
+ */
7
+ export interface SpringConfig {
8
+ /** Stiffness of the spring (default: 100) */
9
+ stiffness: number;
10
+ /** Damping ratio (default: 10) */
11
+ damping: number;
12
+ /** Mass of the object (default: 1) */
13
+ mass: number;
14
+ }
15
+ export interface AnimationOptions {
16
+ /** Duration in milliseconds */
17
+ duration: number;
18
+ /** Easing function */
19
+ easing?: (t: number) => number;
20
+ /** Delay before starting in milliseconds */
21
+ delay?: number;
22
+ }
23
+ /**
24
+ * Pre-configured spring settings for common use cases
25
+ */
26
+ export declare const springPresets: Record<string, SpringConfig>;
27
+ /**
28
+ * Linear easing (no easing)
29
+ */
30
+ export declare function linear(t: number): number;
31
+ /**
32
+ * Ease in (accelerating)
33
+ */
34
+ export declare function easeIn(t: number): number;
35
+ /**
36
+ * Ease out (decelerating)
37
+ */
38
+ export declare function easeOut(t: number): number;
39
+ /**
40
+ * Ease in-out (accelerate then decelerate)
41
+ */
42
+ export declare function easeInOut(t: number): number;
43
+ /**
44
+ * Cubic ease in
45
+ */
46
+ export declare function easeInCubic(t: number): number;
47
+ /**
48
+ * Cubic ease out
49
+ */
50
+ export declare function easeOutCubic(t: number): number;
51
+ /**
52
+ * Cubic ease in-out
53
+ */
54
+ export declare function easeInOutCubic(t: number): number;
55
+ /**
56
+ * Bounce ease out
57
+ */
58
+ export declare function easeOutBounce(t: number): number;
59
+ /**
60
+ * Elastic ease out
61
+ */
62
+ export declare function easeOutElastic(t: number): number;
63
+ /**
64
+ * Back ease out (overshoots then settles)
65
+ */
66
+ export declare function easeOutBack(t: number): number;
67
+ /**
68
+ * Interpolate between two values
69
+ */
70
+ export declare function lerp(start: number, end: number, t: number): number;
71
+ /**
72
+ * Clamp a value between min and max
73
+ */
74
+ export declare function clamp(value: number, min: number, max: number): number;
75
+ /**
76
+ * Map a value from one range to another
77
+ */
78
+ export declare function mapRange(value: number, inMin: number, inMax: number, outMin: number, outMax: number): number;
79
+ /**
80
+ * Calculate spring physics for a single step
81
+ */
82
+ export declare function springStep(current: number, target: number, velocity: number, config: SpringConfig, deltaTime: number): {
83
+ position: number;
84
+ velocity: number;
85
+ };
86
+ /**
87
+ * Check if a spring animation is at rest
88
+ */
89
+ export declare function isSpringAtRest(current: number, target: number, velocity: number, threshold?: number): boolean;
90
+ /**
91
+ * Create a staggered delay for list animations
92
+ */
93
+ export declare function staggerDelay(index: number, baseDelay?: number): number;
94
+ /**
95
+ * Calculate animation progress based on elapsed time
96
+ */
97
+ export declare function getProgress(elapsed: number, duration: number): number;
98
+ /**
99
+ * Get duration value from CSS custom property or fallback
100
+ */
101
+ export declare function getDurationFromCSS(property: "--animation-fast" | "--animation-normal" | "--animation-slow" | "--animation-slower", fallback?: number): number;
102
+ /**
103
+ * Debounce an animation frame callback
104
+ */
105
+ export declare function rafDebounce<T extends (...args: unknown[]) => void>(fn: T): T;
106
+ /**
107
+ * Throttle function calls to animation frames
108
+ */
109
+ export declare function rafThrottle<T extends (...args: unknown[]) => void>(fn: T): T;
@@ -0,0 +1,198 @@
1
+ /**
2
+ * Animation Utilities
3
+ *
4
+ * Helpers for creating smooth animations, spring physics, and easing functions.
5
+ * Used across many FancyUI components for consistent animation behavior.
6
+ */
7
+ // =============================================================================
8
+ // Spring Presets
9
+ // =============================================================================
10
+ /**
11
+ * Pre-configured spring settings for common use cases
12
+ */
13
+ export const springPresets = {
14
+ /** Default balanced spring */
15
+ default: { stiffness: 100, damping: 10, mass: 1 },
16
+ /** Gentle, slow spring */
17
+ gentle: { stiffness: 50, damping: 14, mass: 1 },
18
+ /** Wobbly, bouncy spring */
19
+ wobbly: { stiffness: 180, damping: 12, mass: 1 },
20
+ /** Stiff, snappy spring */
21
+ stiff: { stiffness: 210, damping: 20, mass: 1 },
22
+ /** Very slow, heavy spring */
23
+ slow: { stiffness: 50, damping: 20, mass: 1 },
24
+ /** Quick, responsive spring */
25
+ quick: { stiffness: 300, damping: 25, mass: 1 },
26
+ };
27
+ // =============================================================================
28
+ // Easing Functions
29
+ // =============================================================================
30
+ /**
31
+ * Linear easing (no easing)
32
+ */
33
+ export function linear(t) {
34
+ return t;
35
+ }
36
+ /**
37
+ * Ease in (accelerating)
38
+ */
39
+ export function easeIn(t) {
40
+ return t * t;
41
+ }
42
+ /**
43
+ * Ease out (decelerating)
44
+ */
45
+ export function easeOut(t) {
46
+ return t * (2 - t);
47
+ }
48
+ /**
49
+ * Ease in-out (accelerate then decelerate)
50
+ */
51
+ export function easeInOut(t) {
52
+ return t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t;
53
+ }
54
+ /**
55
+ * Cubic ease in
56
+ */
57
+ export function easeInCubic(t) {
58
+ return t * t * t;
59
+ }
60
+ /**
61
+ * Cubic ease out
62
+ */
63
+ export function easeOutCubic(t) {
64
+ return 1 - Math.pow(1 - t, 3);
65
+ }
66
+ /**
67
+ * Cubic ease in-out
68
+ */
69
+ export function easeInOutCubic(t) {
70
+ return t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2;
71
+ }
72
+ /**
73
+ * Bounce ease out
74
+ */
75
+ export function easeOutBounce(t) {
76
+ const n1 = 7.5625;
77
+ const d1 = 2.75;
78
+ if (t < 1 / d1) {
79
+ return n1 * t * t;
80
+ }
81
+ else if (t < 2 / d1) {
82
+ return n1 * (t -= 1.5 / d1) * t + 0.75;
83
+ }
84
+ else if (t < 2.5 / d1) {
85
+ return n1 * (t -= 2.25 / d1) * t + 0.9375;
86
+ }
87
+ else {
88
+ return n1 * (t -= 2.625 / d1) * t + 0.984375;
89
+ }
90
+ }
91
+ /**
92
+ * Elastic ease out
93
+ */
94
+ export function easeOutElastic(t) {
95
+ const c4 = (2 * Math.PI) / 3;
96
+ return t === 0 ? 0 : t === 1 ? 1 : Math.pow(2, -10 * t) * Math.sin((t * 10 - 0.75) * c4) + 1;
97
+ }
98
+ /**
99
+ * Back ease out (overshoots then settles)
100
+ */
101
+ export function easeOutBack(t) {
102
+ const c1 = 1.70158;
103
+ const c3 = c1 + 1;
104
+ return 1 + c3 * Math.pow(t - 1, 3) + c1 * Math.pow(t - 1, 2);
105
+ }
106
+ // =============================================================================
107
+ // Animation Helpers
108
+ // =============================================================================
109
+ /**
110
+ * Interpolate between two values
111
+ */
112
+ export function lerp(start, end, t) {
113
+ return start + (end - start) * t;
114
+ }
115
+ /**
116
+ * Clamp a value between min and max
117
+ */
118
+ export function clamp(value, min, max) {
119
+ return Math.min(Math.max(value, min), max);
120
+ }
121
+ /**
122
+ * Map a value from one range to another
123
+ */
124
+ export function mapRange(value, inMin, inMax, outMin, outMax) {
125
+ return ((value - inMin) * (outMax - outMin)) / (inMax - inMin) + outMin;
126
+ }
127
+ /**
128
+ * Calculate spring physics for a single step
129
+ */
130
+ export function springStep(current, target, velocity, config, deltaTime) {
131
+ const { stiffness, damping, mass } = config;
132
+ // Spring force: F = -kx - cv
133
+ const springForce = -stiffness * (current - target);
134
+ const dampingForce = -damping * velocity;
135
+ const acceleration = (springForce + dampingForce) / mass;
136
+ const newVelocity = velocity + acceleration * deltaTime;
137
+ const newPosition = current + newVelocity * deltaTime;
138
+ return { position: newPosition, velocity: newVelocity };
139
+ }
140
+ /**
141
+ * Check if a spring animation is at rest
142
+ */
143
+ export function isSpringAtRest(current, target, velocity, threshold = 0.001) {
144
+ return Math.abs(current - target) < threshold && Math.abs(velocity) < threshold;
145
+ }
146
+ /**
147
+ * Create a staggered delay for list animations
148
+ */
149
+ export function staggerDelay(index, baseDelay = 50) {
150
+ return index * baseDelay;
151
+ }
152
+ /**
153
+ * Calculate animation progress based on elapsed time
154
+ */
155
+ export function getProgress(elapsed, duration) {
156
+ return clamp(elapsed / duration, 0, 1);
157
+ }
158
+ /**
159
+ * Get duration value from CSS custom property or fallback
160
+ */
161
+ export function getDurationFromCSS(property, fallback = 300) {
162
+ if (typeof window === "undefined")
163
+ return fallback;
164
+ const value = getComputedStyle(document.documentElement).getPropertyValue(property).trim();
165
+ const parsed = parseInt(value, 10);
166
+ return isNaN(parsed) ? fallback : parsed;
167
+ }
168
+ /**
169
+ * Debounce an animation frame callback
170
+ */
171
+ export function rafDebounce(fn) {
172
+ let frameId = null;
173
+ return ((...args) => {
174
+ if (frameId !== null) {
175
+ cancelAnimationFrame(frameId);
176
+ }
177
+ frameId = requestAnimationFrame(() => {
178
+ fn(...args);
179
+ frameId = null;
180
+ });
181
+ });
182
+ }
183
+ /**
184
+ * Throttle function calls to animation frames
185
+ */
186
+ export function rafThrottle(fn) {
187
+ let frameId = null;
188
+ let lastArgs = null;
189
+ return ((...args) => {
190
+ lastArgs = args;
191
+ if (frameId === null) {
192
+ frameId = requestAnimationFrame(() => {
193
+ fn(...lastArgs);
194
+ frameId = null;
195
+ });
196
+ }
197
+ });
198
+ }
@@ -0,0 +1,128 @@
1
+ /**
2
+ * Color Utilities
3
+ *
4
+ * Helpers for color manipulation, gradients, and OKLCH color space operations.
5
+ * Supports dynamic color effects in beam, glow, and gradient components.
6
+ */
7
+ export interface RGB {
8
+ r: number;
9
+ g: number;
10
+ b: number;
11
+ }
12
+ export interface HSL {
13
+ h: number;
14
+ s: number;
15
+ l: number;
16
+ }
17
+ export interface OKLCH {
18
+ l: number;
19
+ c: number;
20
+ h: number;
21
+ }
22
+ export interface RGBA extends RGB {
23
+ a: number;
24
+ }
25
+ /**
26
+ * Parse a hex color to RGB
27
+ */
28
+ export declare function hexToRgb(hex: string): RGB | null;
29
+ /**
30
+ * Convert RGB to hex
31
+ */
32
+ export declare function rgbToHex(rgb: RGB): string;
33
+ /**
34
+ * Parse an HSL string to HSL object
35
+ */
36
+ export declare function parseHsl(hsl: string): HSL | null;
37
+ /**
38
+ * Convert HSL to CSS string
39
+ */
40
+ export declare function hslToString(hsl: HSL): string;
41
+ /**
42
+ * Parse an OKLCH string to OKLCH object
43
+ */
44
+ export declare function parseOklch(oklch: string): OKLCH | null;
45
+ /**
46
+ * Convert OKLCH to CSS string
47
+ */
48
+ export declare function oklchToString(oklch: OKLCH): string;
49
+ /**
50
+ * Convert RGB to HSL
51
+ */
52
+ export declare function rgbToHsl(rgb: RGB): HSL;
53
+ /**
54
+ * Convert HSL to RGB
55
+ */
56
+ export declare function hslToRgb(hsl: HSL): RGB;
57
+ /**
58
+ * Lighten a color by a percentage
59
+ */
60
+ export declare function lighten(hsl: HSL, amount: number): HSL;
61
+ /**
62
+ * Darken a color by a percentage
63
+ */
64
+ export declare function darken(hsl: HSL, amount: number): HSL;
65
+ /**
66
+ * Saturate a color by a percentage
67
+ */
68
+ export declare function saturate(hsl: HSL, amount: number): HSL;
69
+ /**
70
+ * Desaturate a color by a percentage
71
+ */
72
+ export declare function desaturate(hsl: HSL, amount: number): HSL;
73
+ /**
74
+ * Shift hue by degrees
75
+ */
76
+ export declare function shiftHue(hsl: HSL, degrees: number): HSL;
77
+ /**
78
+ * Get complementary color
79
+ */
80
+ export declare function complementary(hsl: HSL): HSL;
81
+ /**
82
+ * Interpolate between two colors
83
+ */
84
+ export declare function interpolateColor(from: HSL, to: HSL, t: number): HSL;
85
+ /**
86
+ * Generate a linear gradient CSS string
87
+ */
88
+ export declare function linearGradient(angle: number, ...colors: string[]): string;
89
+ /**
90
+ * Generate a radial gradient CSS string
91
+ */
92
+ export declare function radialGradient(shape: "circle" | "ellipse", ...colors: string[]): string;
93
+ /**
94
+ * Generate a conic gradient CSS string
95
+ */
96
+ export declare function conicGradient(fromAngle: number, ...colors: string[]): string;
97
+ /**
98
+ * Generate rainbow gradient colors
99
+ */
100
+ export declare function getRainbowColors(count?: number): HSL[];
101
+ /**
102
+ * Generate a gradient from theme CSS variables
103
+ */
104
+ export declare function getThemeGradient(startVar: string, endVar: string, angle?: number): string;
105
+ /**
106
+ * Get a CSS variable value
107
+ */
108
+ export declare function getCssVariable(name: string): string;
109
+ /**
110
+ * Set a CSS variable
111
+ */
112
+ export declare function setCssVariable(name: string, value: string): void;
113
+ /**
114
+ * Generate a random color
115
+ */
116
+ export declare function randomColor(): HSL;
117
+ /**
118
+ * Check if a color is light or dark
119
+ */
120
+ export declare function isLightColor(hsl: HSL): boolean;
121
+ /**
122
+ * Get contrasting text color (black or white)
123
+ */
124
+ export declare function getContrastColor(hsl: HSL): "black" | "white";
125
+ /**
126
+ * Add alpha to a color string
127
+ */
128
+ export declare function withAlpha(color: string, alpha: number): string;