react-confetti-burst 1.0.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/LICENSE +21 -0
- package/README.md +303 -0
- package/dist/cjs/components.d.ts +219 -0
- package/dist/cjs/components.d.ts.map +1 -0
- package/dist/cjs/components.js +341 -0
- package/dist/cjs/components.js.map +1 -0
- package/dist/cjs/confetti-engine.d.ts +122 -0
- package/dist/cjs/confetti-engine.d.ts.map +1 -0
- package/dist/cjs/confetti-engine.js +589 -0
- package/dist/cjs/confetti-engine.js.map +1 -0
- package/dist/cjs/confetti.d.ts +50 -0
- package/dist/cjs/confetti.d.ts.map +1 -0
- package/dist/cjs/confetti.js +446 -0
- package/dist/cjs/confetti.js.map +1 -0
- package/dist/cjs/constants.d.ts +147 -0
- package/dist/cjs/constants.d.ts.map +1 -0
- package/dist/cjs/constants.js +609 -0
- package/dist/cjs/constants.js.map +1 -0
- package/dist/cjs/hooks.d.ts +94 -0
- package/dist/cjs/hooks.d.ts.map +1 -0
- package/dist/cjs/hooks.js +225 -0
- package/dist/cjs/hooks.js.map +1 -0
- package/dist/cjs/index.d.ts +34 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +180 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/particle.d.ts +50 -0
- package/dist/cjs/particle.d.ts.map +1 -0
- package/dist/cjs/particle.js +475 -0
- package/dist/cjs/particle.js.map +1 -0
- package/dist/cjs/shapes.d.ts +190 -0
- package/dist/cjs/shapes.d.ts.map +1 -0
- package/dist/cjs/shapes.js +272 -0
- package/dist/cjs/shapes.js.map +1 -0
- package/dist/cjs/types.d.ts +720 -0
- package/dist/cjs/types.d.ts.map +1 -0
- package/dist/cjs/types.js +25 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/cjs/utils.d.ts +90 -0
- package/dist/cjs/utils.d.ts.map +1 -0
- package/dist/cjs/utils.js +330 -0
- package/dist/cjs/utils.js.map +1 -0
- package/dist/esm/components.js +334 -0
- package/dist/esm/components.js.map +1 -0
- package/dist/esm/confetti-engine.js +581 -0
- package/dist/esm/confetti-engine.js.map +1 -0
- package/dist/esm/confetti.js +443 -0
- package/dist/esm/confetti.js.map +1 -0
- package/dist/esm/constants.js +605 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/hooks.js +218 -0
- package/dist/esm/hooks.js.map +1 -0
- package/dist/esm/index.js +146 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/particle.js +465 -0
- package/dist/esm/particle.js.map +1 -0
- package/dist/esm/shapes.js +265 -0
- package/dist/esm/shapes.js.map +1 -0
- package/dist/esm/types.js +24 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/utils.js +309 -0
- package/dist/esm/utils.js.map +1 -0
- package/dist/types/components.d.ts +219 -0
- package/dist/types/components.d.ts.map +1 -0
- package/dist/types/confetti-engine.d.ts +122 -0
- package/dist/types/confetti-engine.d.ts.map +1 -0
- package/dist/types/confetti.d.ts +50 -0
- package/dist/types/confetti.d.ts.map +1 -0
- package/dist/types/constants.d.ts +147 -0
- package/dist/types/constants.d.ts.map +1 -0
- package/dist/types/hooks.d.ts +94 -0
- package/dist/types/hooks.d.ts.map +1 -0
- package/dist/types/index.d.ts +34 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/particle.d.ts +50 -0
- package/dist/types/particle.d.ts.map +1 -0
- package/dist/types/shapes.d.ts +190 -0
- package/dist/types/shapes.d.ts.map +1 -0
- package/dist/types/types.d.ts +720 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/utils.d.ts +90 -0
- package/dist/types/utils.d.ts.map +1 -0
- package/package.json +73 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
# react-confetti-burst 🎉
|
|
2
|
+
|
|
3
|
+
A high-performance, zero-dependency React confetti component with directional bursts using the native Canvas API.
|
|
4
|
+
|
|
5
|
+
[](https://badge.fury.io/js/react-confetti-burst)
|
|
6
|
+
[](https://www.typescriptlang.org/)
|
|
7
|
+
[](https://bundlephobia.com/package/react-confetti-burst)
|
|
8
|
+
[](https://opensource.org/licenses/MIT)
|
|
9
|
+
|
|
10
|
+
## Features
|
|
11
|
+
|
|
12
|
+
- 🚀 **Zero dependencies** - Pure React + Canvas API
|
|
13
|
+
- 🎯 **Directional bursts** - Up, down, left, right, radial, or custom angles
|
|
14
|
+
- ⚡ **High performance** - Optimized canvas rendering
|
|
15
|
+
- 📦 **Tiny bundle** - Minimal footprint
|
|
16
|
+
- 🔷 **TypeScript first** - Full type safety built-in
|
|
17
|
+
- ♿ **Accessible** - Respects `prefers-reduced-motion`
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install react-confetti-burst
|
|
23
|
+
# or
|
|
24
|
+
yarn add react-confetti-burst
|
|
25
|
+
# or
|
|
26
|
+
pnpm add react-confetti-burst
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Quick Start
|
|
30
|
+
|
|
31
|
+
### The Simplest Way - ConfettiButton
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
import { ConfettiButton } from 'react-confetti-burst';
|
|
35
|
+
|
|
36
|
+
function App() {
|
|
37
|
+
return (
|
|
38
|
+
<ConfettiButton>
|
|
39
|
+
Click me! 🎉
|
|
40
|
+
</ConfettiButton>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Using the Hook - useConfetti
|
|
46
|
+
|
|
47
|
+
```tsx
|
|
48
|
+
import { useConfetti } from 'react-confetti-burst';
|
|
49
|
+
|
|
50
|
+
function App() {
|
|
51
|
+
const { fire } = useConfetti();
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<button onClick={(e) => fire({ x: e.clientX, y: e.clientY })}>
|
|
55
|
+
Celebrate!
|
|
56
|
+
</button>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Functional API - confetti()
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
import { confetti } from 'react-confetti-burst';
|
|
65
|
+
|
|
66
|
+
// Basic burst from center
|
|
67
|
+
confetti();
|
|
68
|
+
|
|
69
|
+
// With options
|
|
70
|
+
confetti({
|
|
71
|
+
particleCount: 100,
|
|
72
|
+
spread: 70,
|
|
73
|
+
origin: { x: 0.5, y: 0.5 }
|
|
74
|
+
});
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## API Reference
|
|
78
|
+
|
|
79
|
+
### Components
|
|
80
|
+
|
|
81
|
+
#### `<ConfettiButton>`
|
|
82
|
+
|
|
83
|
+
A button that automatically fires confetti on click.
|
|
84
|
+
|
|
85
|
+
```tsx
|
|
86
|
+
import { ConfettiButton } from 'react-confetti-burst';
|
|
87
|
+
|
|
88
|
+
<ConfettiButton
|
|
89
|
+
confettiOptions={{
|
|
90
|
+
particleCount: 50,
|
|
91
|
+
spread: 60,
|
|
92
|
+
colors: ['#ff6b6b', '#4ecdc4', '#ffe66d'],
|
|
93
|
+
}}
|
|
94
|
+
>
|
|
95
|
+
Click me!
|
|
96
|
+
</ConfettiButton>
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
**Props:**
|
|
100
|
+
- `confettiOptions?: ConfettiBurstOptions` - Configuration for the confetti burst
|
|
101
|
+
- `fireOnClick?: boolean` - Whether to fire on click (default: `true`)
|
|
102
|
+
- All standard button HTML attributes
|
|
103
|
+
|
|
104
|
+
#### `<ConfettiBurst>`
|
|
105
|
+
|
|
106
|
+
Declarative component for conditional confetti.
|
|
107
|
+
|
|
108
|
+
```tsx
|
|
109
|
+
import { ConfettiBurst } from 'react-confetti-burst';
|
|
110
|
+
|
|
111
|
+
<ConfettiBurst
|
|
112
|
+
active={showConfetti}
|
|
113
|
+
origin={{ x: 500, y: 300 }}
|
|
114
|
+
options={{ particleCount: 50 }}
|
|
115
|
+
onComplete={() => setShowConfetti(false)}
|
|
116
|
+
/>
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Hooks
|
|
120
|
+
|
|
121
|
+
#### `useConfetti()`
|
|
122
|
+
|
|
123
|
+
The main hook for programmatic confetti control.
|
|
124
|
+
|
|
125
|
+
```tsx
|
|
126
|
+
import { useConfetti } from 'react-confetti-burst';
|
|
127
|
+
|
|
128
|
+
function App() {
|
|
129
|
+
const { fire, fireFromElement, isActive, stopAll } = useConfetti();
|
|
130
|
+
|
|
131
|
+
// Fire from a specific point
|
|
132
|
+
const handleClick = (e: React.MouseEvent) => {
|
|
133
|
+
fire({ x: e.clientX, y: e.clientY }, {
|
|
134
|
+
particleCount: 50,
|
|
135
|
+
direction: { direction: 'up', spread: 45 },
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
// Fire from an element's center
|
|
140
|
+
const buttonRef = useRef<HTMLButtonElement>(null);
|
|
141
|
+
const handleButtonClick = () => {
|
|
142
|
+
fireFromElement(buttonRef.current);
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
return (
|
|
146
|
+
<>
|
|
147
|
+
<div onClick={handleClick}>Click anywhere</div>
|
|
148
|
+
<button ref={buttonRef} onClick={handleButtonClick}>
|
|
149
|
+
Fire from me!
|
|
150
|
+
</button>
|
|
151
|
+
{isActive && <p>Animation running...</p>}
|
|
152
|
+
<button onClick={stopAll}>Stop All</button>
|
|
153
|
+
</>
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
**Returns:**
|
|
159
|
+
- `fire(origin, options?)` - Fire confetti from a point `{ x, y }`
|
|
160
|
+
- `fireFromElement(element, options?)` - Fire from an element's center
|
|
161
|
+
- `isActive` - Boolean indicating if any animation is running
|
|
162
|
+
- `stopAll()` - Stop all active animations
|
|
163
|
+
|
|
164
|
+
### Functional API
|
|
165
|
+
|
|
166
|
+
#### `confetti(options?)`
|
|
167
|
+
|
|
168
|
+
Fire confetti imperatively from anywhere in your code.
|
|
169
|
+
|
|
170
|
+
```tsx
|
|
171
|
+
import { confetti } from 'react-confetti-burst';
|
|
172
|
+
|
|
173
|
+
// Simple burst
|
|
174
|
+
confetti();
|
|
175
|
+
|
|
176
|
+
// Customized burst
|
|
177
|
+
confetti({
|
|
178
|
+
particleCount: 100,
|
|
179
|
+
spread: 70,
|
|
180
|
+
origin: { x: 0.5, y: 0.5 },
|
|
181
|
+
colors: ['#ff0000', '#00ff00', '#0000ff'],
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
// Directional burst
|
|
185
|
+
confetti({
|
|
186
|
+
particleCount: 50,
|
|
187
|
+
direction: {
|
|
188
|
+
direction: 'up',
|
|
189
|
+
spread: 45,
|
|
190
|
+
velocity: [20, 40],
|
|
191
|
+
},
|
|
192
|
+
});
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## Configuration Options
|
|
196
|
+
|
|
197
|
+
```typescript
|
|
198
|
+
interface ConfettiBurstOptions {
|
|
199
|
+
// Number of particles (default: 50)
|
|
200
|
+
particleCount?: number;
|
|
201
|
+
|
|
202
|
+
// Direction configuration
|
|
203
|
+
direction?: {
|
|
204
|
+
direction?: 'up' | 'down' | 'left' | 'right' | 'radial' | 'custom';
|
|
205
|
+
angle?: number; // For 'custom' direction (degrees)
|
|
206
|
+
spread?: number; // Spread angle (default: 45)
|
|
207
|
+
velocity?: [number, number]; // Min/max velocity
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
// Particle appearance
|
|
211
|
+
particle?: {
|
|
212
|
+
size?: [number, number]; // Min/max size
|
|
213
|
+
colors?: string[]; // Array of colors
|
|
214
|
+
shapes?: ('square' | 'circle' | 'star' | 'triangle')[];
|
|
215
|
+
opacity?: [number, number]; // Min/max opacity
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
// Physics
|
|
219
|
+
physics?: {
|
|
220
|
+
gravity?: number; // Gravity strength (default: 0.5)
|
|
221
|
+
friction?: number; // Air friction (default: 0.99)
|
|
222
|
+
wind?: number; // Horizontal wind force
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
// Lifecycle callbacks
|
|
226
|
+
onStart?: () => void;
|
|
227
|
+
onComplete?: () => void;
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
## Examples
|
|
232
|
+
|
|
233
|
+
### Directional Bursts
|
|
234
|
+
|
|
235
|
+
```tsx
|
|
236
|
+
import { useConfetti } from 'react-confetti-burst';
|
|
237
|
+
|
|
238
|
+
function DirectionalExample() {
|
|
239
|
+
const { fire } = useConfetti();
|
|
240
|
+
|
|
241
|
+
const fireUp = () => fire({ x: 400, y: 500 }, {
|
|
242
|
+
direction: { direction: 'up', spread: 30 },
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
const fireRadial = () => fire({ x: 400, y: 300 }, {
|
|
246
|
+
direction: { direction: 'radial' },
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
return (
|
|
250
|
+
<>
|
|
251
|
+
<button onClick={fireUp}>Fire Up ⬆️</button>
|
|
252
|
+
<button onClick={fireRadial}>Radial Burst 💥</button>
|
|
253
|
+
</>
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
### Custom Colors
|
|
259
|
+
|
|
260
|
+
```tsx
|
|
261
|
+
<ConfettiButton
|
|
262
|
+
confettiOptions={{
|
|
263
|
+
particle: {
|
|
264
|
+
colors: ['#FFD700', '#FF6B6B', '#4ECDC4', '#45B7D1'],
|
|
265
|
+
},
|
|
266
|
+
}}
|
|
267
|
+
>
|
|
268
|
+
Golden Burst ✨
|
|
269
|
+
</ConfettiButton>
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### Form Submission Success
|
|
273
|
+
|
|
274
|
+
```tsx
|
|
275
|
+
import { confetti } from 'react-confetti-burst';
|
|
276
|
+
|
|
277
|
+
async function handleSubmit(data: FormData) {
|
|
278
|
+
const response = await submitForm(data);
|
|
279
|
+
|
|
280
|
+
if (response.success) {
|
|
281
|
+
confetti({
|
|
282
|
+
particleCount: 100,
|
|
283
|
+
spread: 70,
|
|
284
|
+
origin: { x: 0.5, y: 0.6 },
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
## Browser Support
|
|
291
|
+
|
|
292
|
+
- Chrome 60+
|
|
293
|
+
- Firefox 55+
|
|
294
|
+
- Safari 11+
|
|
295
|
+
- Edge 79+
|
|
296
|
+
|
|
297
|
+
## License
|
|
298
|
+
|
|
299
|
+
MIT © [Your Name]
|
|
300
|
+
|
|
301
|
+
## Contributing
|
|
302
|
+
|
|
303
|
+
Contributions are welcome! Please read our contributing guidelines before submitting a PR.
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React components for confetti animations
|
|
3
|
+
*
|
|
4
|
+
* Provides declarative components for easy integration of confetti
|
|
5
|
+
* effects into React applications.
|
|
6
|
+
*/
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import type { ConfettiBurstProps, ConfettiButtonProps, ExplosionHandle, BurstOrigin } from './types';
|
|
9
|
+
/**
|
|
10
|
+
* Declarative confetti component that fires when active prop changes
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* const [celebrate, setCelebrate] = useState(false);
|
|
15
|
+
*
|
|
16
|
+
* return (
|
|
17
|
+
* <>
|
|
18
|
+
* <ConfettiBurst
|
|
19
|
+
* active={celebrate}
|
|
20
|
+
* origin={{ x: 500, y: 300 }}
|
|
21
|
+
* onComplete={() => setCelebrate(false)}
|
|
22
|
+
* />
|
|
23
|
+
* <button onClick={() => setCelebrate(true)}>
|
|
24
|
+
* Celebrate!
|
|
25
|
+
* </button>
|
|
26
|
+
* </>
|
|
27
|
+
* );
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare function ConfettiBurst({ active, origin, triggerRef, options, onComplete, }: ConfettiBurstProps): null;
|
|
31
|
+
/**
|
|
32
|
+
* Handle type for ConfettiTrigger ref
|
|
33
|
+
*/
|
|
34
|
+
export interface ConfettiTriggerHandle {
|
|
35
|
+
fire: () => ExplosionHandle | null;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Invisible trigger component that fires confetti from its position
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```tsx
|
|
42
|
+
* const triggerRef = useRef<ConfettiTriggerHandle>(null);
|
|
43
|
+
*
|
|
44
|
+
* return (
|
|
45
|
+
* <div style={{ position: 'relative' }}>
|
|
46
|
+
* <ConfettiTrigger ref={triggerRef} options={{ particleCount: 100 }} />
|
|
47
|
+
* <button onClick={() => triggerRef.current?.fire()}>
|
|
48
|
+
* Fire!
|
|
49
|
+
* </button>
|
|
50
|
+
* </div>
|
|
51
|
+
* );
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export declare const ConfettiTrigger: React.ForwardRefExoticComponent<{
|
|
55
|
+
options?: ConfettiBurstProps["options"];
|
|
56
|
+
style?: React.CSSProperties;
|
|
57
|
+
} & React.RefAttributes<ConfettiTriggerHandle>>;
|
|
58
|
+
/**
|
|
59
|
+
* Button component that automatically fires confetti on click
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```tsx
|
|
63
|
+
* <ConfettiButton
|
|
64
|
+
* confettiOptions={{
|
|
65
|
+
* particleCount: 30,
|
|
66
|
+
* direction: { direction: 'up' }
|
|
67
|
+
* }}
|
|
68
|
+
* >
|
|
69
|
+
* Submit
|
|
70
|
+
* </ConfettiButton>
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export declare const ConfettiButton: React.ForwardRefExoticComponent<ConfettiButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
74
|
+
/**
|
|
75
|
+
* Props for ConfettiOnMount component
|
|
76
|
+
*/
|
|
77
|
+
interface ConfettiOnMountProps {
|
|
78
|
+
origin?: BurstOrigin;
|
|
79
|
+
options?: ConfettiBurstProps['options'];
|
|
80
|
+
onComplete?: () => void;
|
|
81
|
+
delay?: number;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Component that fires confetti when mounted
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```tsx
|
|
88
|
+
* // Fire confetti when a success page loads
|
|
89
|
+
* function SuccessPage() {
|
|
90
|
+
* return (
|
|
91
|
+
* <div>
|
|
92
|
+
* <ConfettiOnMount
|
|
93
|
+
* origin={{ x: window.innerWidth / 2, y: window.innerHeight / 3 }}
|
|
94
|
+
* options={{ particleCount: 100 }}
|
|
95
|
+
* />
|
|
96
|
+
* <h1>Success!</h1>
|
|
97
|
+
* </div>
|
|
98
|
+
* );
|
|
99
|
+
* }
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
export declare function ConfettiOnMount({ origin, options, onComplete, delay, }: ConfettiOnMountProps): null;
|
|
103
|
+
/**
|
|
104
|
+
* Props for ConfettiCannon component
|
|
105
|
+
*/
|
|
106
|
+
interface ConfettiCannonProps {
|
|
107
|
+
/** Position from left (percentage or pixels) */
|
|
108
|
+
left?: number | string;
|
|
109
|
+
/** Position from top (percentage or pixels) */
|
|
110
|
+
top?: number | string;
|
|
111
|
+
/** Angle in degrees (0 = right, 90 = up) */
|
|
112
|
+
angle?: number;
|
|
113
|
+
/** Confetti options */
|
|
114
|
+
options?: ConfettiBurstProps['options'];
|
|
115
|
+
/** When true, fires the cannon */
|
|
116
|
+
fire?: boolean;
|
|
117
|
+
/** Callback when animation completes */
|
|
118
|
+
onComplete?: () => void;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Positioned cannon component for directional confetti bursts
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```tsx
|
|
125
|
+
* <ConfettiCannon
|
|
126
|
+
* left="10%"
|
|
127
|
+
* top="80%"
|
|
128
|
+
* angle={60}
|
|
129
|
+
* fire={shouldFire}
|
|
130
|
+
* options={{ particleCount: 50 }}
|
|
131
|
+
* />
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
export declare function ConfettiCannon({ left, top, angle, options, fire: shouldFire, onComplete, }: ConfettiCannonProps): null;
|
|
135
|
+
/**
|
|
136
|
+
* React-confetti compatible Confetti component
|
|
137
|
+
*
|
|
138
|
+
* This component provides a drop-in replacement for react-confetti
|
|
139
|
+
* with continuous confetti that falls from the top of the screen.
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```tsx
|
|
143
|
+
* // Basic usage - continuous confetti
|
|
144
|
+
* <Confetti />
|
|
145
|
+
*
|
|
146
|
+
* // With options
|
|
147
|
+
* <Confetti
|
|
148
|
+
* width={window.innerWidth}
|
|
149
|
+
* height={window.innerHeight}
|
|
150
|
+
* numberOfPieces={200}
|
|
151
|
+
* recycle={true}
|
|
152
|
+
* run={true}
|
|
153
|
+
* />
|
|
154
|
+
*
|
|
155
|
+
* // With custom draw function
|
|
156
|
+
* <Confetti
|
|
157
|
+
* drawShape={ctx => {
|
|
158
|
+
* ctx.beginPath();
|
|
159
|
+
* ctx.arc(0, 0, 5, 0, Math.PI * 2);
|
|
160
|
+
* ctx.fill();
|
|
161
|
+
* }}
|
|
162
|
+
* />
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
165
|
+
export interface ConfettiComponentProps {
|
|
166
|
+
/** Width of the canvas in pixels (default: window.innerWidth) */
|
|
167
|
+
width?: number;
|
|
168
|
+
/** Height of the canvas in pixels (default: window.innerHeight) */
|
|
169
|
+
height?: number;
|
|
170
|
+
/** Number of confetti pieces (default: 200) */
|
|
171
|
+
numberOfPieces?: number;
|
|
172
|
+
/** Spawn area for confetti pieces */
|
|
173
|
+
confettiSource?: {
|
|
174
|
+
x: number;
|
|
175
|
+
y: number;
|
|
176
|
+
w?: number;
|
|
177
|
+
h?: number;
|
|
178
|
+
};
|
|
179
|
+
/** Initial horizontal velocity range (default: [4, 10]) */
|
|
180
|
+
initialVelocityX?: number | {
|
|
181
|
+
min: number;
|
|
182
|
+
max: number;
|
|
183
|
+
};
|
|
184
|
+
/** Initial vertical velocity range (default: [10, 30]) */
|
|
185
|
+
initialVelocityY?: number | {
|
|
186
|
+
min: number;
|
|
187
|
+
max: number;
|
|
188
|
+
};
|
|
189
|
+
/** Whether to recycle confetti (default: true) */
|
|
190
|
+
recycle?: boolean;
|
|
191
|
+
/** Whether the animation is running (default: true) */
|
|
192
|
+
run?: boolean;
|
|
193
|
+
/** Gravity value (default: 0.3) */
|
|
194
|
+
gravity?: number;
|
|
195
|
+
/** Wind value (default: 0) */
|
|
196
|
+
wind?: number;
|
|
197
|
+
/** Opacity of confetti pieces (0-1, default: 1) */
|
|
198
|
+
opacity?: number;
|
|
199
|
+
/** Custom draw function */
|
|
200
|
+
drawShape?: (ctx: CanvasRenderingContext2D) => void;
|
|
201
|
+
/** Tween duration when recycle changes (ms) */
|
|
202
|
+
tweenDuration?: number;
|
|
203
|
+
/** Array of colors */
|
|
204
|
+
colors?: string[];
|
|
205
|
+
/** Callback when confetti is created */
|
|
206
|
+
onConfettiComplete?: (confetti: any) => void;
|
|
207
|
+
/** Frame rate limit */
|
|
208
|
+
frameRate?: number;
|
|
209
|
+
/** Z-index of the canvas */
|
|
210
|
+
style?: React.CSSProperties;
|
|
211
|
+
/** Class name for the canvas */
|
|
212
|
+
className?: string;
|
|
213
|
+
}
|
|
214
|
+
export declare function Confetti({ width, height, numberOfPieces, confettiSource, initialVelocityX, initialVelocityY, recycle, run, gravity, wind, opacity, drawShape, tweenDuration, colors, onConfettiComplete, frameRate, }: ConfettiComponentProps): null;
|
|
215
|
+
export declare namespace Confetti {
|
|
216
|
+
var displayName: string;
|
|
217
|
+
}
|
|
218
|
+
export {};
|
|
219
|
+
//# sourceMappingURL=components.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../src/components.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAMN,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EACV,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,WAAW,EACZ,MAAM,SAAS,CAAC;AAIjB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,aAAa,CAAC,EAC5B,MAAM,EACN,MAAM,EACN,UAAU,EACV,OAAO,EACP,UAAU,GACX,EAAE,kBAAkB,GAAG,IAAI,CAgC3B;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC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