react-confetti-burst 1.0.4 → 1.0.6

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.
@@ -710,6 +710,18 @@ export interface ConfettiButtonProps extends React$1.ButtonHTMLAttributes<HTMLBu
710
710
  /** Children elements */
711
711
  readonly children: React$1.ReactNode;
712
712
  }
713
+ /**
714
+ * Preset configuration names
715
+ */
716
+ export type PresetName = "default" | "celebration" | "firework" | "snow" | "rain" | "sparkle" | "confetti" | "emoji" | "hearts" | "stars" | "money" | "pride" | "christmas" | "halloween" | "newYear" | "birthday";
717
+ /**
718
+ * Preset configuration
719
+ */
720
+ export interface PresetConfig {
721
+ readonly name: PresetName;
722
+ readonly options: ConfettiBurstOptions;
723
+ readonly description: string;
724
+ }
713
725
  /**
714
726
  * Default vibrant color palette for confetti particles
715
727
  * Designed for high visibility on both light and dark backgrounds
@@ -742,6 +754,16 @@ export declare const DIRECTION_ANGLES: Record<Exclude<BurstDirection, "custom" |
742
754
  * Easing functions for smooth animations
743
755
  */
744
756
  export declare const EASING_FUNCTIONS: Record<EasingPreset, EasingFunction>;
757
+ /**
758
+ * Sets the maximum particle pool size.
759
+ * Call before creating any ConfettiEngine instances.
760
+ * @param size - Maximum number of particles to pool (default: 500)
761
+ */
762
+ export declare function setMaxPoolSize(size: number): void;
763
+ /**
764
+ * Gets the current maximum particle pool size.
765
+ */
766
+ export declare function getMaxPoolSize(): number;
745
767
  /**
746
768
  * Main confetti engine class
747
769
  */
@@ -900,11 +922,19 @@ export declare function ConfettiBurst({ active, origin, triggerRef, options, onC
900
922
  */
901
923
  export declare const ConfettiButton: React$1.ForwardRefExoticComponent<ConfettiButtonProps & React$1.RefAttributes<HTMLButtonElement>>;
902
924
  /**
903
- * Generates a random number within a range
925
+ * Generates a random number within a range (inclusive min, exclusive max)
926
+ * @param min - Minimum value (inclusive)
927
+ * @param max - Maximum value (exclusive)
928
+ * @returns Random number in [min, max)
929
+ * @example randomInRange(5, 15) // e.g. 8.342
904
930
  */
905
931
  export declare function randomInRange(min: number, max: number): number;
906
932
  /**
907
- * Generates a random integer within a range (inclusive)
933
+ * Generates a random integer within a range (inclusive on both ends)
934
+ * @param min - Minimum integer value (inclusive)
935
+ * @param max - Maximum integer value (inclusive)
936
+ * @returns Random integer in [min, max]
937
+ * @example randomInt(1, 6) // e.g. 3
908
938
  */
909
939
  export declare function randomInt(min: number, max: number): number;
910
940
  /**
@@ -913,18 +943,34 @@ export declare function randomInt(min: number, max: number): number;
913
943
  export declare function randomFromArray<T>(array: readonly T[]): T;
914
944
  /**
915
945
  * Clamps a value between min and max
946
+ * @param value - Value to clamp
947
+ * @param min - Minimum bound
948
+ * @param max - Maximum bound
949
+ * @returns Clamped value in [min, max]
950
+ * @example clamp(15, 0, 10) // 10
916
951
  */
917
952
  export declare function clamp(value: number, min: number, max: number): number;
918
953
  /**
919
954
  * Linear interpolation between two values
955
+ * @param start - Start value (t=0)
956
+ * @param end - End value (t=1)
957
+ * @param t - Interpolation factor, clamped to [0, 1]
958
+ * @returns Interpolated value
959
+ * @example lerp(0, 100, 0.5) // 50
920
960
  */
921
961
  export declare function lerp(start: number, end: number, t: number): number;
922
962
  /**
923
963
  * Converts degrees to radians
964
+ * @param degrees - Angle in degrees
965
+ * @returns Angle in radians
966
+ * @example degToRad(180) // Math.PI
924
967
  */
925
968
  export declare function degToRad(degrees: number): number;
926
969
  /**
927
970
  * Converts radians to degrees
971
+ * @param radians - Angle in radians
972
+ * @returns Angle in degrees
973
+ * @example radToDeg(Math.PI) // 180
928
974
  */
929
975
  export declare function radToDeg(radians: number): number;
930
976
  /**
@@ -996,6 +1042,280 @@ export declare namespace confetti {
996
1042
  var destroyAll: () => void;
997
1043
  var getShapes: () => string[];
998
1044
  }
1045
+ /**
1046
+ * Color palettes for presets
1047
+ */
1048
+ export declare const COLOR_PALETTES: {
1049
+ readonly rainbow: readonly string[];
1050
+ readonly pride: readonly [
1051
+ "#E40303",
1052
+ "#FF8C00",
1053
+ "#FFED00",
1054
+ "#008026",
1055
+ "#24408E",
1056
+ "#732982"
1057
+ ];
1058
+ readonly christmas: readonly [
1059
+ "#C41E3A",
1060
+ "#165B33",
1061
+ "#FFD700",
1062
+ "#FFFFFF",
1063
+ "#BB2528"
1064
+ ];
1065
+ readonly halloween: readonly [
1066
+ "#FF6600",
1067
+ "#000000",
1068
+ "#8B008B",
1069
+ "#00FF00",
1070
+ "#FFD700"
1071
+ ];
1072
+ readonly pastel: readonly [
1073
+ "#FFB3BA",
1074
+ "#FFDFBA",
1075
+ "#FFFFBA",
1076
+ "#BAFFC9",
1077
+ "#BAE1FF"
1078
+ ];
1079
+ readonly neon: readonly [
1080
+ "#FF00FF",
1081
+ "#00FFFF",
1082
+ "#FF0080",
1083
+ "#80FF00",
1084
+ "#FF8000"
1085
+ ];
1086
+ readonly gold: readonly [
1087
+ "#FFD700",
1088
+ "#DAA520",
1089
+ "#B8860B",
1090
+ "#FFC125",
1091
+ "#FFDF00"
1092
+ ];
1093
+ readonly silver: readonly [
1094
+ "#C0C0C0",
1095
+ "#A8A8A8",
1096
+ "#D3D3D3",
1097
+ "#DCDCDC",
1098
+ "#E8E8E8"
1099
+ ];
1100
+ readonly hearts: readonly [
1101
+ "#FF69B4",
1102
+ "#FF1493",
1103
+ "#FF007F",
1104
+ "#DC143C",
1105
+ "#FFB6C1"
1106
+ ];
1107
+ readonly ocean: readonly [
1108
+ "#006994",
1109
+ "#00CED1",
1110
+ "#20B2AA",
1111
+ "#48D1CC",
1112
+ "#87CEEB"
1113
+ ];
1114
+ };
1115
+ /**
1116
+ * Emoji sets for presets
1117
+ */
1118
+ export declare const EMOJI_SETS: {
1119
+ readonly celebration: readonly [
1120
+ "\uD83C\uDF89",
1121
+ "\uD83C\uDF8A",
1122
+ "\uD83E\uDD73",
1123
+ "\u2728",
1124
+ "\uD83C\uDF88"
1125
+ ];
1126
+ readonly hearts: readonly [
1127
+ "\u2764\uFE0F",
1128
+ "\uD83D\uDC95",
1129
+ "\uD83D\uDC96",
1130
+ "\uD83D\uDC97",
1131
+ "\uD83D\uDC93",
1132
+ "\uD83D\uDC98"
1133
+ ];
1134
+ readonly stars: readonly [
1135
+ "\u2B50",
1136
+ "\uD83C\uDF1F",
1137
+ "\u2728",
1138
+ "\uD83D\uDCAB",
1139
+ "\u26A1"
1140
+ ];
1141
+ readonly money: readonly [
1142
+ "\uD83D\uDCB0",
1143
+ "\uD83D\uDCB5",
1144
+ "\uD83D\uDCB8",
1145
+ "\uD83E\uDD11",
1146
+ "\uD83D\uDC8E"
1147
+ ];
1148
+ readonly christmas: readonly [
1149
+ "\uD83C\uDF84",
1150
+ "\uD83C\uDF85",
1151
+ "\uD83C\uDF81",
1152
+ "\u2744\uFE0F",
1153
+ "\u2B50"
1154
+ ];
1155
+ readonly halloween: readonly [
1156
+ "\uD83C\uDF83",
1157
+ "\uD83D\uDC7B",
1158
+ "\uD83E\uDD87",
1159
+ "\uD83D\uDD77\uFE0F",
1160
+ "\uD83D\uDC80"
1161
+ ];
1162
+ readonly birthday: readonly [
1163
+ "\uD83C\uDF82",
1164
+ "\uD83C\uDF81",
1165
+ "\uD83C\uDF88",
1166
+ "\uD83C\uDF89",
1167
+ "\uD83E\uDD73"
1168
+ ];
1169
+ readonly food: readonly [
1170
+ "\uD83C\uDF55",
1171
+ "\uD83C\uDF54",
1172
+ "\uD83C\uDF5F",
1173
+ "\uD83C\uDF2D",
1174
+ "\uD83C\uDF7F"
1175
+ ];
1176
+ };
1177
+ /**
1178
+ * Preset configurations for quick setup
1179
+ */
1180
+ export declare const PRESETS: Record<PresetName, PresetConfig>;
1181
+ /**
1182
+ * Get a preset configuration by name
1183
+ */
1184
+ export declare function getPreset(name: PresetName): PresetConfig;
1185
+ /**
1186
+ * Get all available preset names
1187
+ */
1188
+ export declare function getPresetNames(): readonly PresetName[];
1189
+ /**
1190
+ * Options for creating a shape from an SVG path
1191
+ */
1192
+ export interface ShapeFromPathOptions {
1193
+ /** SVG path string (d attribute) */
1194
+ readonly path: string;
1195
+ /** Optional 2D transformation matrix [a, b, c, d, e, f] */
1196
+ readonly matrix?: readonly number[];
1197
+ /** Fill color (optional, will use particle color if not set) */
1198
+ readonly fillColor?: string;
1199
+ /** Stroke color (optional) */
1200
+ readonly strokeColor?: string;
1201
+ /** Stroke width (optional) */
1202
+ readonly strokeWidth?: number;
1203
+ }
1204
+ /**
1205
+ * Options for creating a shape from text/emoji
1206
+ */
1207
+ export interface ShapeFromTextOptions {
1208
+ /** Text or emoji to render */
1209
+ readonly text: string;
1210
+ /** Scale factor for the text size. Default: 1 */
1211
+ readonly scalar?: number;
1212
+ /** Text color (optional, will use particle color if not set) */
1213
+ readonly color?: string;
1214
+ /** Font family. Default: 'serif' */
1215
+ readonly fontFamily?: string;
1216
+ /** Font weight. Default: 'normal' */
1217
+ readonly fontWeight?: string | number;
1218
+ /** Font style. Default: 'normal' */
1219
+ readonly fontStyle?: "normal" | "italic" | "oblique";
1220
+ }
1221
+ /**
1222
+ * Create a custom shape from an SVG path string.
1223
+ *
1224
+ * This is compatible with canvas-confetti's shapeFromPath function.
1225
+ *
1226
+ * @example
1227
+ * ```typescript
1228
+ * // Simple star shape
1229
+ * const star = shapeFromPath({
1230
+ * path: 'M0,-1 L0.588,0.809 L-0.951,-0.309 L0.951,-0.309 L-0.588,0.809 Z'
1231
+ * });
1232
+ *
1233
+ * // With transformation matrix
1234
+ * const scaledStar = shapeFromPath({
1235
+ * path: 'M0,-1 L0.588,0.809 L-0.951,-0.309 L0.951,-0.309 L-0.588,0.809 Z',
1236
+ * matrix: [2, 0, 0, 2, 0, 0] // Scale 2x
1237
+ * });
1238
+ *
1239
+ * // Usage with confetti
1240
+ * fire({ x: 0.5, y: 0.5 }, {
1241
+ * particle: { shapes: [star, 'circle'] }
1242
+ * });
1243
+ * ```
1244
+ *
1245
+ * @param options - Shape configuration options
1246
+ * @returns PathShape object for use in confetti configuration
1247
+ */
1248
+ export declare function shapeFromPath(options: ShapeFromPathOptions): PathShape;
1249
+ /**
1250
+ * Create a custom shape from text or an emoji.
1251
+ *
1252
+ * This is compatible with canvas-confetti's shapeFromText function.
1253
+ *
1254
+ * @example
1255
+ * ```typescript
1256
+ * // Emoji confetti
1257
+ * const heart = shapeFromText({ text: '❤️' });
1258
+ * const party = shapeFromText({ text: '🎉', scalar: 2 });
1259
+ *
1260
+ * // Custom text
1261
+ * const yay = shapeFromText({
1262
+ * text: 'YAY',
1263
+ * fontFamily: 'Impact',
1264
+ * color: '#ff0000'
1265
+ * });
1266
+ *
1267
+ * // Usage with confetti
1268
+ * fire({ x: 0.5, y: 0.5 }, {
1269
+ * particle: { shapes: [heart, party, yay] }
1270
+ * });
1271
+ * ```
1272
+ *
1273
+ * @param options - Text shape configuration options
1274
+ * @returns TextShape object for use in confetti configuration
1275
+ */
1276
+ export declare function shapeFromText(options: ShapeFromTextOptions): TextShape;
1277
+ /**
1278
+ * Create a bitmap shape from an image URL or HTMLImageElement.
1279
+ *
1280
+ * @example
1281
+ * ```typescript
1282
+ * const logo = await shapeFromImage({
1283
+ * src: '/logo.png',
1284
+ * width: 32,
1285
+ * height: 32
1286
+ * });
1287
+ *
1288
+ * fire({ x: 0.5, y: 0.5 }, {
1289
+ * particle: { shapes: [logo] }
1290
+ * });
1291
+ * ```
1292
+ *
1293
+ * @param options - Image shape configuration options
1294
+ * @returns Promise resolving to a custom shape
1295
+ */
1296
+ export declare function shapeFromImage(options: {
1297
+ readonly src: string | HTMLImageElement;
1298
+ readonly width?: number;
1299
+ readonly height?: number;
1300
+ readonly scalar?: number;
1301
+ }): Promise<CustomShape>;
1302
+ /**
1303
+ * Create multiple shapes from an array of emoji.
1304
+ *
1305
+ * @example
1306
+ * ```typescript
1307
+ * const partyEmoji = shapesFromEmoji(['🎉', '🎊', '✨', '🥳']);
1308
+ *
1309
+ * fire({ x: 0.5, y: 0.5 }, {
1310
+ * particle: { shapes: partyEmoji }
1311
+ * });
1312
+ * ```
1313
+ *
1314
+ * @param emojis - Array of emoji strings
1315
+ * @param options - Optional common options for all emoji
1316
+ * @returns Array of TextShape objects
1317
+ */
1318
+ export declare function shapesFromEmoji(emojis: readonly string[], options?: Omit<ShapeFromTextOptions, "text">): TextShape[];
999
1319
 
1000
1320
  export {
1001
1321
  confetti as default,
package/package.json CHANGED
@@ -1,83 +1,105 @@
1
- {
2
- "name": "react-confetti-burst",
3
- "version": "1.0.4",
4
- "description": "A high-performance, zero-dependency React confetti component with directional bursts using Canvas API",
5
- "main": "dist/cjs/index.js",
6
- "module": "dist/esm/index.js",
7
- "types": "dist/types/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "types": "./dist/types/index.d.ts",
11
- "require": "./dist/cjs/index.js",
12
- "import": "./dist/esm/index.js"
13
- }
14
- },
15
- "sideEffects": false,
16
- "files": [
17
- "dist/cjs/index.js",
18
- "dist/esm/index.js",
19
- "dist/types/index.d.ts"
20
- ],
21
- "scripts": {
22
- "build": "npm run clean && npm run build:bundle && npm run build:types",
23
- "build:bundle": "node build.js",
24
- "build:types": "dts-bundle-generator -o dist/types/index.d.ts src/index.ts --no-banner --no-check",
25
- "build:types:fallback": "tsc -p tsconfig.json --emitDeclarationOnly --declaration --declarationDir dist/types",
26
- "build:dev": "npm run build:cjs && npm run build:esm && npm run build:types:fallback",
27
- "build:cjs": "tsc -p tsconfig.json",
28
- "build:esm": "tsc -p tsconfig.esm.json",
29
- "clean": "node -e \"fs.rmSync('dist',{recursive:true,force:true})\"",
30
- "test": "jest",
31
- "test:watch": "jest --watch",
32
- "test:coverage": "jest --coverage",
33
- "lint": "eslint src --ext .ts,.tsx",
34
- "typecheck": "tsc --noEmit",
35
- "prepublishOnly": "npm run build",
36
- "size": "node -e \"const f=require('fs');const e=f.statSync('dist/esm/index.js').size;const c=f.statSync('dist/cjs/index.js').size;console.log('ESM:',(e/1024).toFixed(2)+'KB','CJS:',(c/1024).toFixed(2)+'KB','Total:',((e+c)/1024).toFixed(2)+'KB')\""
37
- },
38
- "keywords": [
39
- "react",
40
- "confetti",
41
- "canvas",
42
- "animation",
43
- "celebration",
44
- "burst",
45
- "directional",
46
- "particles",
47
- "typescript",
48
- "zero-dependencies"
49
- ],
50
- "author": "",
51
- "license": "MIT",
52
- "repository": {
53
- "type": "git",
54
- "url": ""
55
- },
56
- "bugs": {
57
- "url": ""
58
- },
59
- "homepage": "",
60
- "peerDependencies": {
61
- "react": ">=17.0.0",
62
- "react-dom": ">=17.0.0"
63
- },
64
- "devDependencies": {
65
- "@testing-library/jest-dom": "^6.9.1",
66
- "@testing-library/react": "^14.0.0",
67
- "@types/jest": "^29.5.0",
68
- "@types/react": "^18.2.0",
69
- "@types/react-dom": "^18.2.0",
70
- "dts-bundle-generator": "^9.5.1",
71
- "esbuild": "^0.27.2",
72
- "jest": "^29.7.0",
73
- "jest-environment-jsdom": "^29.7.0",
74
- "react": "^18.2.0",
75
- "react-dom": "^18.2.0",
76
- "terser": "^5.44.1",
77
- "ts-jest": "^29.1.0",
78
- "typescript": "^5.3.0"
79
- },
80
- "engines": {
81
- "node": ">=18.0.0"
82
- }
83
- }
1
+ {
2
+ "name": "react-confetti-burst",
3
+ "version": "1.0.6",
4
+ "description": "A high-performance, zero-dependency React confetti component with directional bursts using Canvas API",
5
+ "main": "dist/cjs/index.js",
6
+ "module": "dist/esm/index.js",
7
+ "types": "dist/types/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/types/index.d.ts",
11
+ "require": "./dist/cjs/index.js",
12
+ "import": "./dist/esm/index.js"
13
+ },
14
+ "./browser": "./dist/confetti.browser.js"
15
+ },
16
+ "browser": "dist/confetti.browser.js",
17
+ "sideEffects": false,
18
+ "files": [
19
+ "dist/cjs/index.js",
20
+ "dist/esm/index.js",
21
+ "dist/confetti.browser.js",
22
+ "dist/types/index.d.ts",
23
+ "README.md",
24
+ "LICENSE",
25
+ "CONTRIBUTING.md"
26
+ ],
27
+ "scripts": {
28
+ "build": "npm run clean && npm run build:bundle && npm run build:types",
29
+ "build:bundle": "node build.js",
30
+ "build:types": "dts-bundle-generator -o dist/types/index.d.ts src/index.ts --no-banner --no-check",
31
+ "build:types:fallback": "tsc -p tsconfig.json --emitDeclarationOnly --declaration --declarationDir dist/types",
32
+ "build:dev": "npm run build:cjs && npm run build:esm && npm run build:types:fallback",
33
+ "build:cjs": "tsc -p tsconfig.json",
34
+ "build:esm": "tsc -p tsconfig.esm.json",
35
+ "clean": "node -e \"fs.rmSync('dist',{recursive:true,force:true})\"",
36
+ "test": "jest",
37
+ "test:watch": "jest --watch",
38
+ "test:coverage": "jest --coverage",
39
+ "lint": "eslint src",
40
+ "typecheck": "tsc --noEmit",
41
+ "prepare": "husky",
42
+ "prepublishOnly": "npm run build",
43
+ "size": "node -e \"const f=require('fs');const e=f.statSync('dist/esm/index.js').size;const c=f.statSync('dist/cjs/index.js').size;console.log('ESM:',(e/1024).toFixed(2)+'KB','CJS:',(c/1024).toFixed(2)+'KB','Total:',((e+c)/1024).toFixed(2)+'KB')\""
44
+ },
45
+ "keywords": [
46
+ "react",
47
+ "confetti",
48
+ "canvas",
49
+ "animation",
50
+ "celebration",
51
+ "burst",
52
+ "directional",
53
+ "particles",
54
+ "typescript",
55
+ "zero-dependencies"
56
+ ],
57
+ "author": "",
58
+ "license": "MIT",
59
+ "repository": {
60
+ "type": "git",
61
+ "url": ""
62
+ },
63
+ "bugs": {
64
+ "url": ""
65
+ },
66
+ "homepage": "",
67
+ "peerDependencies": {
68
+ "react": ">=17.0.0",
69
+ "react-dom": ">=17.0.0"
70
+ },
71
+ "devDependencies": {
72
+ "@testing-library/jest-dom": "^6.9.1",
73
+ "@testing-library/react": "^14.0.0",
74
+ "@types/jest": "^29.5.0",
75
+ "@types/react": "^18.2.0",
76
+ "@types/react-dom": "^18.2.0",
77
+ "@typescript-eslint/eslint-plugin": "^8.57.1",
78
+ "@typescript-eslint/parser": "^8.57.1",
79
+ "dts-bundle-generator": "^9.5.1",
80
+ "esbuild": "^0.27.2",
81
+ "eslint": "^9.39.4",
82
+ "eslint-plugin-react-hooks": "^7.0.1",
83
+ "husky": "^9.1.7",
84
+ "jest": "^29.7.0",
85
+ "jest-environment-jsdom": "^29.7.0",
86
+ "lint-staged": "^16.4.0",
87
+ "react": "^18.2.0",
88
+ "react-dom": "^18.2.0",
89
+ "terser": "^5.44.1",
90
+ "ts-jest": "^29.1.0",
91
+ "typescript": "^5.3.0"
92
+ },
93
+ "engines": {
94
+ "node": ">=18.0.0"
95
+ },
96
+ "lint-staged": {
97
+ "src/**/*.{ts,tsx}": [
98
+ "eslint --fix"
99
+ ]
100
+ },
101
+ "overrides": {
102
+ "@tootallnate/once": "3.0.1",
103
+ "minimatch": ">=3.1.4"
104
+ }
105
+ }