@stacksjs/components 0.2.92 → 0.2.94
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/dist/{Sidebar-yb115a2w.stx → Sidebar-4hn7vw4n.stx} +18 -0
- package/dist/index.js +5 -5
- package/package.json +5 -6
- package/src/components/CodeBlock.stx +0 -54
- package/src/components/Footer.stx +0 -66
- package/src/components/Hero.stx +0 -25
- package/src/components/Installation.stx +0 -37
- package/src/components/index.ts +0 -4
- package/src/composables/index.ts +0 -4
- package/src/composables/useCopyCode.ts +0 -73
- package/src/composables/useDarkMode.ts +0 -100
- package/src/composables/useSEO.ts +0 -230
- package/src/composables/utilities/index.ts +0 -7
- package/src/composables/utilities/useClickOutside.ts +0 -72
- package/src/composables/utilities/useFocusTrap.ts +0 -159
- package/src/composables/utilities/useKeyboard.ts +0 -124
- package/src/composables/utilities/useLocalStorage.ts +0 -132
- package/src/composables/utilities/useMediaQuery.ts +0 -118
- package/src/index.ts +0 -99
- package/src/stx.d.ts +0 -4
- package/src/ui/accordion/Accordion.stx +0 -146
- package/src/ui/accordion/AccordionItem.stx +0 -37
- package/src/ui/accordion/index.ts +0 -47
- package/src/ui/audio/Audio.stx +0 -50
- package/src/ui/audio/README.md +0 -41
- package/src/ui/audio/index.ts +0 -13
- package/src/ui/auth/Login.stx +0 -161
- package/src/ui/auth/README.md +0 -142
- package/src/ui/auth/Signup.stx +0 -159
- package/src/ui/auth/TwoFactorChallenge.stx +0 -111
- package/src/ui/auth/index.ts +0 -32
- package/src/ui/avatar/Avatar.stx +0 -77
- package/src/ui/avatar/index.ts +0 -12
- package/src/ui/badge/Badge.stx +0 -62
- package/src/ui/badge/index.ts +0 -10
- package/src/ui/breadcrumb/Breadcrumb.stx +0 -79
- package/src/ui/breadcrumb/index.ts +0 -15
- package/src/ui/button/Button.stx +0 -74
- package/src/ui/button/README.md +0 -80
- package/src/ui/button/index.ts +0 -85
- package/src/ui/calendar/Calendar.stx +0 -189
- package/src/ui/calendar/README.md +0 -254
- package/src/ui/calendar/index.ts +0 -14
- package/src/ui/card/Card.stx +0 -68
- package/src/ui/card/index.ts +0 -13
- package/src/ui/checkbox/Checkbox.stx +0 -86
- package/src/ui/checkbox/index.ts +0 -16
- package/src/ui/combobox/Combobox.stx +0 -96
- package/src/ui/combobox/ComboboxButton.stx +0 -25
- package/src/ui/combobox/ComboboxInput.stx +0 -32
- package/src/ui/combobox/ComboboxOption.stx +0 -49
- package/src/ui/combobox/ComboboxOptions.stx +0 -16
- package/src/ui/combobox/README.md +0 -150
- package/src/ui/combobox/index.ts +0 -40
- package/src/ui/command-palette/CommandPalette.stx +0 -81
- package/src/ui/command-palette/CommandPaletteItem.stx +0 -27
- package/src/ui/command-palette/README.md +0 -42
- package/src/ui/command-palette/index.ts +0 -15
- package/src/ui/dialog/Dialog.stx +0 -41
- package/src/ui/dialog/DialogBackdrop.stx +0 -9
- package/src/ui/dialog/DialogDescription.stx +0 -11
- package/src/ui/dialog/DialogPanel.stx +0 -16
- package/src/ui/dialog/DialogTitle.stx +0 -11
- package/src/ui/dialog/README.md +0 -121
- package/src/ui/dialog/index.ts +0 -32
- package/src/ui/drawer/Drawer.stx +0 -120
- package/src/ui/drawer/README.md +0 -90
- package/src/ui/drawer/index.ts +0 -9
- package/src/ui/dropdown/Dropdown.stx +0 -82
- package/src/ui/dropdown/DropdownButton.stx +0 -29
- package/src/ui/dropdown/DropdownItem.stx +0 -35
- package/src/ui/dropdown/DropdownItems.stx +0 -18
- package/src/ui/dropdown/README.md +0 -114
- package/src/ui/dropdown/index.ts +0 -29
- package/src/ui/form/Form.stx +0 -95
- package/src/ui/form/index.ts +0 -67
- package/src/ui/heatmap/Heatmap.stx +0 -294
- package/src/ui/image/Image.stx +0 -165
- package/src/ui/image/README.md +0 -164
- package/src/ui/image/index.ts +0 -22
- package/src/ui/input/EmailInput.stx +0 -30
- package/src/ui/input/NumberInput.stx +0 -126
- package/src/ui/input/PasswordInput.stx +0 -143
- package/src/ui/input/SearchInput.stx +0 -44
- package/src/ui/input/TextInput.stx +0 -132
- package/src/ui/input/index.ts +0 -180
- package/src/ui/listbox/Listbox.stx +0 -101
- package/src/ui/listbox/ListboxButton.stx +0 -28
- package/src/ui/listbox/ListboxLabel.stx +0 -11
- package/src/ui/listbox/ListboxOption.stx +0 -49
- package/src/ui/listbox/ListboxOptions.stx +0 -16
- package/src/ui/listbox/README.md +0 -135
- package/src/ui/listbox/index.ts +0 -39
- package/src/ui/navigator/Navigator.stx +0 -113
- package/src/ui/navigator/README.md +0 -352
- package/src/ui/navigator/index.ts +0 -20
- package/src/ui/notification/Notification.stx +0 -117
- package/src/ui/notification/README.md +0 -114
- package/src/ui/notification/index.ts +0 -12
- package/src/ui/pagination/Pagination.stx +0 -150
- package/src/ui/pagination/index.ts +0 -11
- package/src/ui/payment/Checkout.stx +0 -31
- package/src/ui/payment/DefaultPaymentMethod.stx +0 -62
- package/src/ui/payment/PaymentMethods.stx +0 -104
- package/src/ui/payment/README.md +0 -345
- package/src/ui/payment/SubscriptionCheckout.stx +0 -323
- package/src/ui/payment/index.ts +0 -59
- package/src/ui/popover/Popover.stx +0 -60
- package/src/ui/popover/PopoverButton.stx +0 -29
- package/src/ui/popover/PopoverPanel.stx +0 -23
- package/src/ui/popover/README.md +0 -91
- package/src/ui/popover/index.ts +0 -22
- package/src/ui/portal/Portal.stx +0 -57
- package/src/ui/portal/index.ts +0 -6
- package/src/ui/progress/Progress.stx +0 -131
- package/src/ui/progress/index.ts +0 -12
- package/src/ui/radio/Radio.stx +0 -77
- package/src/ui/radio/index.ts +0 -15
- package/src/ui/radio-group/README.md +0 -139
- package/src/ui/radio-group/RadioGroup.stx +0 -60
- package/src/ui/radio-group/RadioGroupDescription.stx +0 -11
- package/src/ui/radio-group/RadioGroupLabel.stx +0 -11
- package/src/ui/radio-group/RadioGroupOption.stx +0 -58
- package/src/ui/radio-group/index.ts +0 -30
- package/src/ui/select/README.md +0 -180
- package/src/ui/select/Select.stx +0 -82
- package/src/ui/select/index.ts +0 -21
- package/src/ui/sidebar/Sidebar.stx +0 -458
- package/src/ui/sidebar/SidebarFooter.stx +0 -71
- package/src/ui/sidebar/SidebarHeader.stx +0 -103
- package/src/ui/sidebar/SidebarItem.stx +0 -86
- package/src/ui/sidebar/SidebarSection.stx +0 -83
- package/src/ui/sidebar/index.ts +0 -153
- package/src/ui/sidebar/themes.ts +0 -240
- package/src/ui/skeleton/Skeleton.stx +0 -48
- package/src/ui/skeleton/index.ts +0 -11
- package/src/ui/spinner/Spinner.stx +0 -109
- package/src/ui/spinner/index.ts +0 -9
- package/src/ui/stepper/README.md +0 -36
- package/src/ui/stepper/Stepper.stx +0 -17
- package/src/ui/stepper/StepperStep.stx +0 -57
- package/src/ui/stepper/index.ts +0 -19
- package/src/ui/storage/README.md +0 -193
- package/src/ui/storage/index.ts +0 -347
- package/src/ui/switch/README.md +0 -114
- package/src/ui/switch/Switch.stx +0 -72
- package/src/ui/switch/index.ts +0 -10
- package/src/ui/table/README.md +0 -39
- package/src/ui/table/Table.stx +0 -14
- package/src/ui/table/TableBody.stx +0 -10
- package/src/ui/table/TableCell.stx +0 -10
- package/src/ui/table/TableHead.stx +0 -10
- package/src/ui/table/TableHeader.stx +0 -20
- package/src/ui/table/TableRow.stx +0 -11
- package/src/ui/table/index.ts +0 -35
- package/src/ui/tabs/TabPanel.stx +0 -25
- package/src/ui/tabs/Tabs.stx +0 -202
- package/src/ui/tabs/index.ts +0 -50
- package/src/ui/teleport/Teleport.stx +0 -65
- package/src/ui/teleport/index.ts +0 -7
- package/src/ui/textarea/Textarea.stx +0 -108
- package/src/ui/textarea/index.ts +0 -20
- package/src/ui/tooltip/Tooltip.stx +0 -71
- package/src/ui/tooltip/index.ts +0 -10
- package/src/ui/transition/README.md +0 -30
- package/src/ui/transition/Transition.stx +0 -102
- package/src/ui/transition/index.ts +0 -25
- package/src/ui/video/README.md +0 -47
- package/src/ui/video/Video.stx +0 -45
- package/src/ui/video/index.ts +0 -16
- package/src/ui/virtual-list/VirtualList.stx +0 -67
- package/src/ui/virtual-list/index.ts +0 -10
- package/src/ui/virtual-table/VirtualTable.stx +0 -103
- package/src/ui/virtual-table/index.ts +0 -21
- package/src/utils/PROP_VALIDATION.md +0 -458
- package/src/utils/THEME_SYSTEM.md +0 -702
- package/src/utils/accessibility.ts +0 -841
- package/src/utils/animation/easing.ts +0 -368
- package/src/utils/animation/helpers.ts +0 -223
- package/src/utils/animation/index.ts +0 -5
- package/src/utils/animation/keyframes.ts +0 -230
- package/src/utils/error-handling.ts +0 -475
- package/src/utils/highlighter.ts +0 -93
- package/src/utils/i18n.ts +0 -634
- package/src/utils/keep-alive.ts +0 -819
- package/src/utils/lazy-loading.ts +0 -530
- package/src/utils/prop-validation.ts +0 -478
- package/src/utils/theme.ts +0 -626
|
@@ -1,368 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Easing functions for smooth animations
|
|
3
|
-
*
|
|
4
|
-
* All easing functions follow the signature:
|
|
5
|
-
* @param t - Current time (0 to duration)
|
|
6
|
-
* @param b - Start value
|
|
7
|
-
* @param c - Change in value (end - start)
|
|
8
|
-
* @param d - Duration
|
|
9
|
-
* @returns Current value at time t
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```ts
|
|
13
|
-
* import { Easing } from '@stacksjs/components'
|
|
14
|
-
*
|
|
15
|
-
* const value = Easing.easeInOutCubic(currentTime, startValue, changeInValue, duration)
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Easing function type signature
|
|
21
|
-
*/
|
|
22
|
-
export type EasingFunction = (_t: number, _b: number, _c: number, _d: number) => number
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Linear easing - no acceleration
|
|
26
|
-
*/
|
|
27
|
-
export const linear: EasingFunction = (t, b, c, d) => {
|
|
28
|
-
return (c * t) / d + b
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Quadratic ease-in - accelerating from zero velocity
|
|
33
|
-
*/
|
|
34
|
-
export const easeInQuad: EasingFunction = (t, b, c, d) => {
|
|
35
|
-
t /= d
|
|
36
|
-
return c * t * t + b
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Quadratic ease-out - decelerating to zero velocity
|
|
41
|
-
*/
|
|
42
|
-
export const easeOutQuad: EasingFunction = (t, b, c, d) => {
|
|
43
|
-
t /= d
|
|
44
|
-
return -c * t * (t - 2) + b
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Quadratic ease-in-out - acceleration until halfway, then deceleration
|
|
49
|
-
*/
|
|
50
|
-
export const easeInOutQuad: EasingFunction = (t, b, c, d) => {
|
|
51
|
-
t /= d / 2
|
|
52
|
-
if (t < 1)
|
|
53
|
-
return (c / 2) * t * t + b
|
|
54
|
-
t--
|
|
55
|
-
return (-c / 2) * (t * (t - 2) - 1) + b
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Cubic
|
|
59
|
-
export const easeInCubic: EasingFunction = (t, b, c, d) => {
|
|
60
|
-
t /= d
|
|
61
|
-
return c * t * t * t + b
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export const easeOutCubic: EasingFunction = (t, b, c, d) => {
|
|
65
|
-
t /= d
|
|
66
|
-
t--
|
|
67
|
-
return c * (t * t * t + 1) + b
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export const easeInOutCubic: EasingFunction = (t, b, c, d) => {
|
|
71
|
-
t /= d / 2
|
|
72
|
-
if (t < 1)
|
|
73
|
-
return (c / 2) * t * t * t + b
|
|
74
|
-
t -= 2
|
|
75
|
-
return (c / 2) * (t * t * t + 2) + b
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Quartic
|
|
79
|
-
export const easeInQuart: EasingFunction = (t, b, c, d) => {
|
|
80
|
-
t /= d
|
|
81
|
-
return c * t * t * t * t + b
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export const easeOutQuart: EasingFunction = (t, b, c, d) => {
|
|
85
|
-
t /= d
|
|
86
|
-
t--
|
|
87
|
-
return -c * (t * t * t * t - 1) + b
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export const easeInOutQuart: EasingFunction = (t, b, c, d) => {
|
|
91
|
-
t /= d / 2
|
|
92
|
-
if (t < 1)
|
|
93
|
-
return (c / 2) * t * t * t * t + b
|
|
94
|
-
t -= 2
|
|
95
|
-
return (-c / 2) * (t * t * t * t - 2) + b
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// Quintic
|
|
99
|
-
export const easeInQuint: EasingFunction = (t, b, c, d) => {
|
|
100
|
-
t /= d
|
|
101
|
-
return c * t * t * t * t * t + b
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export const easeOutQuint: EasingFunction = (t, b, c, d) => {
|
|
105
|
-
t /= d
|
|
106
|
-
t--
|
|
107
|
-
return c * (t * t * t * t * t + 1) + b
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export const easeInOutQuint: EasingFunction = (t, b, c, d) => {
|
|
111
|
-
t /= d / 2
|
|
112
|
-
if (t < 1)
|
|
113
|
-
return (c / 2) * t * t * t * t * t + b
|
|
114
|
-
t -= 2
|
|
115
|
-
return (c / 2) * (t * t * t * t * t + 2) + b
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// Sinusoidal
|
|
119
|
-
export const easeInSine: EasingFunction = (t, b, c, d) => {
|
|
120
|
-
return -c * Math.cos((t / d) * (Math.PI / 2)) + c + b
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
export const easeOutSine: EasingFunction = (t, b, c, d) => {
|
|
124
|
-
return c * Math.sin((t / d) * (Math.PI / 2)) + b
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
export const easeInOutSine: EasingFunction = (t, b, c, d) => {
|
|
128
|
-
return (-c / 2) * (Math.cos((Math.PI * t) / d) - 1) + b
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// Exponential
|
|
132
|
-
export const easeInExpo: EasingFunction = (t, b, c, d) => {
|
|
133
|
-
return t === 0 ? b : c * 2 ** (10 * (t / d - 1)) + b
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
export const easeOutExpo: EasingFunction = (t, b, c, d) => {
|
|
137
|
-
return t === d ? b + c : c * (-(2 ** ((-10 * t) / d)) + 1) + b
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
export const easeInOutExpo: EasingFunction = (t, b, c, d) => {
|
|
141
|
-
if (t === 0)
|
|
142
|
-
return b
|
|
143
|
-
if (t === d)
|
|
144
|
-
return b + c
|
|
145
|
-
t /= d / 2
|
|
146
|
-
if (t < 1)
|
|
147
|
-
return (c / 2) * 2 ** (10 * (t - 1)) + b
|
|
148
|
-
t--
|
|
149
|
-
return (c / 2) * (-(2 ** (-10 * t)) + 2) + b
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
// Circular
|
|
153
|
-
export const easeInCirc: EasingFunction = (t, b, c, d) => {
|
|
154
|
-
t /= d
|
|
155
|
-
return -c * (Math.sqrt(1 - t * t) - 1) + b
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
export const easeOutCirc: EasingFunction = (t, b, c, d) => {
|
|
159
|
-
t /= d
|
|
160
|
-
t--
|
|
161
|
-
return c * Math.sqrt(1 - t * t) + b
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
export const easeInOutCirc: EasingFunction = (t, b, c, d) => {
|
|
165
|
-
t /= d / 2
|
|
166
|
-
if (t < 1)
|
|
167
|
-
return (-c / 2) * (Math.sqrt(1 - t * t) - 1) + b
|
|
168
|
-
t -= 2
|
|
169
|
-
return (c / 2) * (Math.sqrt(1 - t * t) + 1) + b
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
// Elastic
|
|
173
|
-
export const easeInElastic: EasingFunction = (t, b, c, d) => {
|
|
174
|
-
let s = 1.70158
|
|
175
|
-
let p = 0
|
|
176
|
-
let a = c
|
|
177
|
-
if (t === 0)
|
|
178
|
-
return b
|
|
179
|
-
t /= d
|
|
180
|
-
if (t === 1)
|
|
181
|
-
return b + c
|
|
182
|
-
if (!p)
|
|
183
|
-
p = d * 0.3
|
|
184
|
-
if (a < Math.abs(c)) {
|
|
185
|
-
a = c
|
|
186
|
-
s = p / 4
|
|
187
|
-
}
|
|
188
|
-
else {
|
|
189
|
-
s = (p / (2 * Math.PI)) * Math.asin(c / a)
|
|
190
|
-
}
|
|
191
|
-
t -= 1
|
|
192
|
-
return -(a * 2 ** (10 * t) * Math.sin(((t * d - s) * (2 * Math.PI)) / p)) + b
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
export const easeOutElastic: EasingFunction = (t, b, c, d) => {
|
|
196
|
-
let s = 1.70158
|
|
197
|
-
let p = 0
|
|
198
|
-
let a = c
|
|
199
|
-
if (t === 0)
|
|
200
|
-
return b
|
|
201
|
-
t /= d
|
|
202
|
-
if (t === 1)
|
|
203
|
-
return b + c
|
|
204
|
-
if (!p)
|
|
205
|
-
p = d * 0.3
|
|
206
|
-
if (a < Math.abs(c)) {
|
|
207
|
-
a = c
|
|
208
|
-
s = p / 4
|
|
209
|
-
}
|
|
210
|
-
else {
|
|
211
|
-
s = (p / (2 * Math.PI)) * Math.asin(c / a)
|
|
212
|
-
}
|
|
213
|
-
return a * 2 ** (-10 * t) * Math.sin(((t * d - s) * (2 * Math.PI)) / p) + c + b
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
export const easeInOutElastic: EasingFunction = (t, b, c, d) => {
|
|
217
|
-
let s = 1.70158
|
|
218
|
-
let p = 0
|
|
219
|
-
let a = c
|
|
220
|
-
if (t === 0)
|
|
221
|
-
return b
|
|
222
|
-
t /= d / 2
|
|
223
|
-
if (t === 2)
|
|
224
|
-
return b + c
|
|
225
|
-
if (!p)
|
|
226
|
-
p = d * (0.3 * 1.5)
|
|
227
|
-
if (a < Math.abs(c)) {
|
|
228
|
-
a = c
|
|
229
|
-
s = p / 4
|
|
230
|
-
}
|
|
231
|
-
else {
|
|
232
|
-
s = (p / (2 * Math.PI)) * Math.asin(c / a)
|
|
233
|
-
}
|
|
234
|
-
if (t < 1) {
|
|
235
|
-
t -= 1
|
|
236
|
-
return -0.5 * (a * 2 ** (10 * t) * Math.sin(((t * d - s) * (2 * Math.PI)) / p)) + b
|
|
237
|
-
}
|
|
238
|
-
t -= 1
|
|
239
|
-
return a * 2 ** (-10 * t) * Math.sin(((t * d - s) * (2 * Math.PI)) / p) * 0.5 + c + b
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
// Back
|
|
243
|
-
export const easeInBack: EasingFunction = (t, b, c, d) => {
|
|
244
|
-
const s = 1.70158
|
|
245
|
-
t /= d
|
|
246
|
-
return c * t * t * ((s + 1) * t - s) + b
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
export const easeOutBack: EasingFunction = (t, b, c, d) => {
|
|
250
|
-
const s = 1.70158
|
|
251
|
-
t /= d
|
|
252
|
-
t--
|
|
253
|
-
return c * (t * t * ((s + 1) * t + s) + 1) + b
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
export const easeInOutBack: EasingFunction = (t, b, c, d) => {
|
|
257
|
-
let s = 1.70158
|
|
258
|
-
t /= d / 2
|
|
259
|
-
if (t < 1) {
|
|
260
|
-
s *= 1.525
|
|
261
|
-
return (c / 2) * (t * t * ((s + 1) * t - s)) + b
|
|
262
|
-
}
|
|
263
|
-
t -= 2
|
|
264
|
-
s *= 1.525
|
|
265
|
-
return (c / 2) * (t * t * ((s + 1) * t + s) + 2) + b
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
// Bounce
|
|
269
|
-
export const easeOutBounce: EasingFunction = (t, b, c, d) => {
|
|
270
|
-
t /= d
|
|
271
|
-
if (t < 1 / 2.75) {
|
|
272
|
-
return c * (7.5625 * t * t) + b
|
|
273
|
-
}
|
|
274
|
-
else if (t < 2 / 2.75) {
|
|
275
|
-
t -= 1.5 / 2.75
|
|
276
|
-
return c * (7.5625 * t * t + 0.75) + b
|
|
277
|
-
}
|
|
278
|
-
else if (t < 2.5 / 2.75) {
|
|
279
|
-
t -= 2.25 / 2.75
|
|
280
|
-
return c * (7.5625 * t * t + 0.9375) + b
|
|
281
|
-
}
|
|
282
|
-
else {
|
|
283
|
-
t -= 2.625 / 2.75
|
|
284
|
-
return c * (7.5625 * t * t + 0.984375) + b
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
export const easeInBounce: EasingFunction = (t, b, c, d) => {
|
|
289
|
-
return c - easeOutBounce(d - t, 0, c, d) + b
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
export const easeInOutBounce: EasingFunction = (t, b, c, d) => {
|
|
293
|
-
if (t < d / 2)
|
|
294
|
-
return easeInBounce(t * 2, 0, c, d) * 0.5 + b
|
|
295
|
-
return easeOutBounce(t * 2 - d, 0, c, d) * 0.5 + c * 0.5 + b
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
/**
|
|
299
|
-
* Object containing all easing functions
|
|
300
|
-
*
|
|
301
|
-
* Available easings: Linear, Quad, Cubic, Quart, Quint, Sine, Expo, Circ, Elastic, Back, Bounce
|
|
302
|
-
* Each with In, Out, InOut variants (except Linear)
|
|
303
|
-
*/
|
|
304
|
-
export const Easing: {
|
|
305
|
-
linear: EasingFunction
|
|
306
|
-
easeInQuad: EasingFunction
|
|
307
|
-
easeOutQuad: EasingFunction
|
|
308
|
-
easeInOutQuad: EasingFunction
|
|
309
|
-
easeInCubic: EasingFunction
|
|
310
|
-
easeOutCubic: EasingFunction
|
|
311
|
-
easeInOutCubic: EasingFunction
|
|
312
|
-
easeInQuart: EasingFunction
|
|
313
|
-
easeOutQuart: EasingFunction
|
|
314
|
-
easeInOutQuart: EasingFunction
|
|
315
|
-
easeInQuint: EasingFunction
|
|
316
|
-
easeOutQuint: EasingFunction
|
|
317
|
-
easeInOutQuint: EasingFunction
|
|
318
|
-
easeInSine: EasingFunction
|
|
319
|
-
easeOutSine: EasingFunction
|
|
320
|
-
easeInOutSine: EasingFunction
|
|
321
|
-
easeInExpo: EasingFunction
|
|
322
|
-
easeOutExpo: EasingFunction
|
|
323
|
-
easeInOutExpo: EasingFunction
|
|
324
|
-
easeInCirc: EasingFunction
|
|
325
|
-
easeOutCirc: EasingFunction
|
|
326
|
-
easeInOutCirc: EasingFunction
|
|
327
|
-
easeInElastic: EasingFunction
|
|
328
|
-
easeOutElastic: EasingFunction
|
|
329
|
-
easeInOutElastic: EasingFunction
|
|
330
|
-
easeInBack: EasingFunction
|
|
331
|
-
easeOutBack: EasingFunction
|
|
332
|
-
easeInOutBack: EasingFunction
|
|
333
|
-
easeInBounce: EasingFunction
|
|
334
|
-
easeOutBounce: EasingFunction
|
|
335
|
-
easeInOutBounce: EasingFunction
|
|
336
|
-
} = {
|
|
337
|
-
linear,
|
|
338
|
-
easeInQuad,
|
|
339
|
-
easeOutQuad,
|
|
340
|
-
easeInOutQuad,
|
|
341
|
-
easeInCubic,
|
|
342
|
-
easeOutCubic,
|
|
343
|
-
easeInOutCubic,
|
|
344
|
-
easeInQuart,
|
|
345
|
-
easeOutQuart,
|
|
346
|
-
easeInOutQuart,
|
|
347
|
-
easeInQuint,
|
|
348
|
-
easeOutQuint,
|
|
349
|
-
easeInOutQuint,
|
|
350
|
-
easeInSine,
|
|
351
|
-
easeOutSine,
|
|
352
|
-
easeInOutSine,
|
|
353
|
-
easeInExpo,
|
|
354
|
-
easeOutExpo,
|
|
355
|
-
easeInOutExpo,
|
|
356
|
-
easeInCirc,
|
|
357
|
-
easeOutCirc,
|
|
358
|
-
easeInOutCirc,
|
|
359
|
-
easeInElastic,
|
|
360
|
-
easeOutElastic,
|
|
361
|
-
easeInOutElastic,
|
|
362
|
-
easeInBack,
|
|
363
|
-
easeOutBack,
|
|
364
|
-
easeInOutBack,
|
|
365
|
-
easeInBounce,
|
|
366
|
-
easeOutBounce,
|
|
367
|
-
easeInOutBounce,
|
|
368
|
-
}
|
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CSS Animation helper utilities
|
|
3
|
-
*
|
|
4
|
-
* @example
|
|
5
|
-
* ```ts
|
|
6
|
-
* import { applyAnimation, staggerAnimation } from '@stacksjs/components'
|
|
7
|
-
*
|
|
8
|
-
* // Apply animation
|
|
9
|
-
* applyAnimation(element, 'fade-in', { duration: '300ms' })
|
|
10
|
-
*
|
|
11
|
-
* // Stagger multiple elements
|
|
12
|
-
* staggerAnimation(elements, 'slide-in', { stagger: 100 })
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* CSS animation configuration options
|
|
18
|
-
*/
|
|
19
|
-
export interface CSSAnimationOptions {
|
|
20
|
-
/** Animation duration (e.g., '300ms', '1s') */
|
|
21
|
-
duration?: string
|
|
22
|
-
/** Timing function, e.g. 'ease', 'linear', 'cubic-bezier(...)' */
|
|
23
|
-
timing?: string
|
|
24
|
-
/** Delay before animation (e.g., '100ms') */
|
|
25
|
-
delay?: string
|
|
26
|
-
/** Number of iterations (e.g., '1', 'infinite') */
|
|
27
|
-
iteration?: string
|
|
28
|
-
/** Animation direction */
|
|
29
|
-
direction?: string
|
|
30
|
-
/** Fill mode */
|
|
31
|
-
fill?: string
|
|
32
|
-
/** Play state */
|
|
33
|
-
playState?: string
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Generate CSS animation string
|
|
38
|
-
*
|
|
39
|
-
* @param name - Animation name
|
|
40
|
-
* @param options - Animation options
|
|
41
|
-
* @returns CSS animation string
|
|
42
|
-
*/
|
|
43
|
-
export function cssAnimation(name: string, options: CSSAnimationOptions = {}): string {
|
|
44
|
-
const {
|
|
45
|
-
duration = '1s',
|
|
46
|
-
timing = 'ease',
|
|
47
|
-
delay = '0s',
|
|
48
|
-
iteration = '1',
|
|
49
|
-
direction = 'normal',
|
|
50
|
-
fill = 'both',
|
|
51
|
-
playState = 'running',
|
|
52
|
-
} = options
|
|
53
|
-
|
|
54
|
-
return `${name} ${duration} ${timing} ${delay} ${iteration} ${direction} ${fill} ${playState}`
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Apply CSS animation to an element
|
|
59
|
-
*
|
|
60
|
-
* @param element - Target element
|
|
61
|
-
* @param animationName - Name of CSS animation
|
|
62
|
-
* @param options - Animation options
|
|
63
|
-
*/
|
|
64
|
-
export function applyAnimation(
|
|
65
|
-
element: HTMLElement,
|
|
66
|
-
animationName: string,
|
|
67
|
-
options: CSSAnimationOptions = {},
|
|
68
|
-
): void {
|
|
69
|
-
element.style.animation = cssAnimation(animationName, options)
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Remove animation from an element
|
|
74
|
-
*
|
|
75
|
-
* @param element - Target element
|
|
76
|
-
*/
|
|
77
|
-
export function removeAnimation(element: HTMLElement): void {
|
|
78
|
-
element.style.animation = ''
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Wait for animation to complete
|
|
83
|
-
*
|
|
84
|
-
* @param element - Target element
|
|
85
|
-
* @returns Promise that resolves when animation ends
|
|
86
|
-
*/
|
|
87
|
-
export function waitForAnimation(element: HTMLElement): Promise<void> {
|
|
88
|
-
return new Promise((resolve) => {
|
|
89
|
-
const handleAnimationEnd = () => {
|
|
90
|
-
element.removeEventListener('animationend', handleAnimationEnd)
|
|
91
|
-
resolve()
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
element.addEventListener('animationend', handleAnimationEnd)
|
|
95
|
-
})
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Stagger animations across multiple elements
|
|
100
|
-
*
|
|
101
|
-
* @param elements - Array of elements to animate
|
|
102
|
-
* @param animationName - Name of CSS animation
|
|
103
|
-
* @param options - Animation options with stagger delay in ms
|
|
104
|
-
*/
|
|
105
|
-
export function staggerAnimation(
|
|
106
|
-
elements: HTMLElement[],
|
|
107
|
-
animationName: string,
|
|
108
|
-
options: CSSAnimationOptions & { stagger?: number } = {},
|
|
109
|
-
): void {
|
|
110
|
-
const { stagger = 100, ...animationOptions } = options
|
|
111
|
-
|
|
112
|
-
elements.forEach((element, index) => {
|
|
113
|
-
const delay = `${index * stagger}ms`
|
|
114
|
-
applyAnimation(element, animationName, {
|
|
115
|
-
...animationOptions,
|
|
116
|
-
delay,
|
|
117
|
-
})
|
|
118
|
-
})
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Run animations in sequence
|
|
123
|
-
*
|
|
124
|
-
* @param element - Target element
|
|
125
|
-
* @param animations - Array of animations to run in order
|
|
126
|
-
* @returns Promise that resolves when all animations complete
|
|
127
|
-
*/
|
|
128
|
-
export async function sequenceAnimations(
|
|
129
|
-
element: HTMLElement,
|
|
130
|
-
animations: Array<{ name: string, options?: CSSAnimationOptions }>,
|
|
131
|
-
): Promise<void> {
|
|
132
|
-
for (const animation of animations) {
|
|
133
|
-
applyAnimation(element, animation.name, animation.options)
|
|
134
|
-
await waitForAnimation(element)
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Predefined CSS animation class names (compatible with Tailwind/headwind)
|
|
140
|
-
*/
|
|
141
|
-
export const AnimationClasses = {
|
|
142
|
-
// Fade
|
|
143
|
-
fadeIn: 'animate-fade-in',
|
|
144
|
-
fadeOut: 'animate-fade-out',
|
|
145
|
-
|
|
146
|
-
// Slide
|
|
147
|
-
slideInUp: 'animate-slide-in-up',
|
|
148
|
-
slideInDown: 'animate-slide-in-down',
|
|
149
|
-
slideInLeft: 'animate-slide-in-left',
|
|
150
|
-
slideInRight: 'animate-slide-in-right',
|
|
151
|
-
|
|
152
|
-
// Zoom
|
|
153
|
-
zoomIn: 'animate-zoom-in',
|
|
154
|
-
zoomOut: 'animate-zoom-out',
|
|
155
|
-
|
|
156
|
-
// Bounce
|
|
157
|
-
bounce: 'animate-bounce',
|
|
158
|
-
|
|
159
|
-
// Spin
|
|
160
|
-
spin: 'animate-spin',
|
|
161
|
-
|
|
162
|
-
// Ping
|
|
163
|
-
ping: 'animate-ping',
|
|
164
|
-
|
|
165
|
-
// Pulse
|
|
166
|
-
pulse: 'animate-pulse',
|
|
167
|
-
} as const
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Add animation class with automatic removal
|
|
171
|
-
*
|
|
172
|
-
* @param element - Target element
|
|
173
|
-
* @param animationClass - CSS class name
|
|
174
|
-
* @param duration - Duration in milliseconds before removing class
|
|
175
|
-
* @returns Promise that resolves when animation completes
|
|
176
|
-
*/
|
|
177
|
-
export function animateWithClass(
|
|
178
|
-
element: HTMLElement,
|
|
179
|
-
animationClass: string,
|
|
180
|
-
duration = 1000,
|
|
181
|
-
): Promise<void> {
|
|
182
|
-
return new Promise((resolve) => {
|
|
183
|
-
element.classList.add(animationClass)
|
|
184
|
-
|
|
185
|
-
setTimeout(() => {
|
|
186
|
-
element.classList.remove(animationClass)
|
|
187
|
-
resolve()
|
|
188
|
-
}, duration)
|
|
189
|
-
})
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* Create custom CSS @keyframes rule dynamically
|
|
194
|
-
*
|
|
195
|
-
* @param name - Animation name
|
|
196
|
-
* @param frames - Keyframe definitions (percentage -> styles)
|
|
197
|
-
*
|
|
198
|
-
* @example
|
|
199
|
-
* ```ts
|
|
200
|
-
* createKeyframes('custom-fade', {
|
|
201
|
-
* '0%': { opacity: '0' },
|
|
202
|
-
* '100%': { opacity: '1' }
|
|
203
|
-
* })
|
|
204
|
-
* ```
|
|
205
|
-
*/
|
|
206
|
-
export function createKeyframes(name: string, frames: Record<string, Record<string, string>>): void {
|
|
207
|
-
const keyframesRule = `
|
|
208
|
-
@keyframes ${name} {
|
|
209
|
-
${Object.entries(frames)
|
|
210
|
-
.map(([percentage, styles]) => {
|
|
211
|
-
const styleString = Object.entries(styles)
|
|
212
|
-
.map(([prop, value]) => `${prop}: ${value};`)
|
|
213
|
-
.join(' ')
|
|
214
|
-
return `${percentage} { ${styleString} }`
|
|
215
|
-
})
|
|
216
|
-
.join('\n')}
|
|
217
|
-
}
|
|
218
|
-
`
|
|
219
|
-
|
|
220
|
-
const styleSheet = document.createElement('style')
|
|
221
|
-
styleSheet.textContent = keyframesRule
|
|
222
|
-
document.head.appendChild(styleSheet)
|
|
223
|
-
}
|