react-achievements 3.9.1 → 4.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/README.md +148 -101
- package/dist/headless.cjs +317 -0
- package/dist/headless.cjs.map +1 -0
- package/dist/headless.d.ts +176 -0
- package/dist/headless.esm.js +222 -0
- package/dist/headless.esm.js.map +1 -0
- package/dist/index.cjs +839 -881
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +163 -153
- package/dist/index.esm.js +835 -883
- package/dist/index.esm.js.map +1 -1
- package/dist/web.cjs +1416 -0
- package/dist/web.cjs.map +1 -0
- package/dist/web.d.ts +534 -0
- package/dist/web.esm.js +1306 -0
- package/dist/web.esm.js.map +1 -0
- package/package.json +13 -28
- package/dist/types/__mocks__/confetti-wrapper.d.ts +0 -5
- package/dist/types/__mocks__/react-confetti.d.ts +0 -3
- package/dist/types/__mocks__/react-toastify.d.ts +0 -13
- package/dist/types/core/components/BadgesButton.d.ts +0 -25
- package/dist/types/core/components/BadgesButtonWithModal.d.ts +0 -53
- package/dist/types/core/components/BadgesModal.d.ts +0 -14
- package/dist/types/core/components/ConfettiWrapper.d.ts +0 -6
- package/dist/types/core/errors/AchievementErrors.d.ts +0 -55
- package/dist/types/core/hooks/useWindowSize.d.ts +0 -16
- package/dist/types/core/icons/defaultIcons.d.ts +0 -8
- package/dist/types/core/storage/AsyncStorageAdapter.d.ts +0 -48
- package/dist/types/core/storage/IndexedDBStorage.d.ts +0 -29
- package/dist/types/core/storage/LocalStorage.d.ts +0 -16
- package/dist/types/core/storage/MemoryStorage.d.ts +0 -11
- package/dist/types/core/storage/OfflineQueueStorage.d.ts +0 -42
- package/dist/types/core/storage/RestApiStorage.d.ts +0 -20
- package/dist/types/core/styles/defaultStyles.d.ts +0 -2
- package/dist/types/core/types.d.ts +0 -115
- package/dist/types/core/ui/BuiltInConfetti.d.ts +0 -7
- package/dist/types/core/ui/BuiltInModal.d.ts +0 -7
- package/dist/types/core/ui/BuiltInNotification.d.ts +0 -7
- package/dist/types/core/ui/LegacyWrappers.d.ts +0 -21
- package/dist/types/core/ui/interfaces.d.ts +0 -127
- package/dist/types/core/ui/legacyDetector.d.ts +0 -40
- package/dist/types/core/ui/themes.d.ts +0 -14
- package/dist/types/core/utils/configNormalizer.d.ts +0 -3
- package/dist/types/core/utils/dataExport.d.ts +0 -34
- package/dist/types/core/utils/dataImport.d.ts +0 -50
- package/dist/types/hooks/useAchievementEngine.d.ts +0 -36
- package/dist/types/hooks/useAchievements.d.ts +0 -1
- package/dist/types/hooks/useSimpleAchievements.d.ts +0 -63
- package/dist/types/index.d.ts +0 -36
- package/dist/types/providers/AchievementProvider.d.ts +0 -47
- package/dist/types/setupTests.d.ts +0 -1
- package/dist/types/utils/achievementHelpers.d.ts +0 -135
package/dist/web.d.ts
ADDED
|
@@ -0,0 +1,534 @@
|
|
|
1
|
+
import React$1 from 'react';
|
|
2
|
+
import * as achievements_engine from 'achievements-engine';
|
|
3
|
+
import { AchievementWithStatus as AchievementWithStatus$1, ImportOptions, ImportResult, AchievementEngine, AchievementConfigurationType as AchievementConfigurationType$1, AchievementStorage as AchievementStorage$1, AsyncAchievementStorage as AsyncAchievementStorage$1, StorageType, RestApiStorageConfig, EventMapping, AchievementError } from 'achievements-engine';
|
|
4
|
+
export { AchievementBuilder, AchievementEngine, AchievementEngineApi, AchievementError, AchievementUnlockedEvent, AsyncStorageAdapter, AwardDetails, ConfigurationError, EngineConfig, EngineEvent, ErrorEvent, EventMapping, ExportedData, ImportOptions, ImportResult, ImportValidationError, IndexedDBStorage, LocalStorage, MemoryStorage, MetricUpdatedEvent, MetricUpdater, OfflineQueueStorage, RestApiStorage, RestApiStorageConfig, StateChangedEvent, StorageError, StorageQuotaError, StorageType, SyncError, UnsubscribeFn, createConfigHash, exportAchievementData, importAchievementData, isAchievementError, isRecoverableError, isSimpleConfig, normalizeAchievements } from 'achievements-engine';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Notification component interface
|
|
8
|
+
* Displays achievement unlock notifications
|
|
9
|
+
*/
|
|
10
|
+
interface NotificationProps {
|
|
11
|
+
achievement: AchievementWithStatus;
|
|
12
|
+
onClose?: () => void;
|
|
13
|
+
duration?: number;
|
|
14
|
+
position?: NotificationPosition;
|
|
15
|
+
theme?: string;
|
|
16
|
+
icons?: Record<string, string>;
|
|
17
|
+
/**
|
|
18
|
+
* Position in the active notification stack.
|
|
19
|
+
* Built-in notifications use this to avoid overlap when multiple
|
|
20
|
+
* achievements unlock from the same update.
|
|
21
|
+
*/
|
|
22
|
+
stackIndex?: number;
|
|
23
|
+
}
|
|
24
|
+
type NotificationComponent = React$1.FC<NotificationProps>;
|
|
25
|
+
/**
|
|
26
|
+
* Modal component interface
|
|
27
|
+
* Displays list of achievements (locked/unlocked)
|
|
28
|
+
*/
|
|
29
|
+
interface ModalProps {
|
|
30
|
+
isOpen: boolean;
|
|
31
|
+
onClose: () => void;
|
|
32
|
+
achievements: AchievementWithStatus[];
|
|
33
|
+
icons?: Record<string, string>;
|
|
34
|
+
theme?: string;
|
|
35
|
+
}
|
|
36
|
+
type ModalComponent = React$1.FC<ModalProps>;
|
|
37
|
+
/**
|
|
38
|
+
* Confetti component interface
|
|
39
|
+
* Displays celebration animation
|
|
40
|
+
*/
|
|
41
|
+
interface ConfettiProps {
|
|
42
|
+
show: boolean;
|
|
43
|
+
duration?: number;
|
|
44
|
+
particleCount?: number;
|
|
45
|
+
colors?: string[];
|
|
46
|
+
}
|
|
47
|
+
type ConfettiComponent = React$1.FC<ConfettiProps>;
|
|
48
|
+
/**
|
|
49
|
+
* Notification positioning options
|
|
50
|
+
*/
|
|
51
|
+
type NotificationPosition = 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';
|
|
52
|
+
/**
|
|
53
|
+
* Theme configuration interface
|
|
54
|
+
* Defines styling for all UI components
|
|
55
|
+
*/
|
|
56
|
+
interface ThemeConfig {
|
|
57
|
+
name: string;
|
|
58
|
+
notification: {
|
|
59
|
+
background: string;
|
|
60
|
+
textColor: string;
|
|
61
|
+
accentColor: string;
|
|
62
|
+
borderRadius: string;
|
|
63
|
+
boxShadow: string;
|
|
64
|
+
fontSize?: {
|
|
65
|
+
header?: string;
|
|
66
|
+
title?: string;
|
|
67
|
+
description?: string;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
modal: {
|
|
71
|
+
overlayColor: string;
|
|
72
|
+
background: string;
|
|
73
|
+
textColor: string;
|
|
74
|
+
accentColor: string;
|
|
75
|
+
borderRadius: string;
|
|
76
|
+
headerFontSize?: string;
|
|
77
|
+
achievementCardBorderRadius?: string;
|
|
78
|
+
achievementLayout?: 'horizontal' | 'badge';
|
|
79
|
+
};
|
|
80
|
+
confetti: {
|
|
81
|
+
colors: string[];
|
|
82
|
+
particleCount: number;
|
|
83
|
+
shapes?: ('circle' | 'square')[];
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* UI Configuration for AchievementProvider
|
|
88
|
+
* Allows customization of all UI components
|
|
89
|
+
*/
|
|
90
|
+
interface UIConfig {
|
|
91
|
+
/**
|
|
92
|
+
* Custom notification component
|
|
93
|
+
* If not provided, uses the built-in notification component.
|
|
94
|
+
*/
|
|
95
|
+
NotificationComponent?: NotificationComponent;
|
|
96
|
+
/**
|
|
97
|
+
* Custom modal component used by AchievementsWidget and AchievementsModal.
|
|
98
|
+
* If not provided, uses the built-in AchievementsModal implementation.
|
|
99
|
+
*/
|
|
100
|
+
ModalComponent?: ModalComponent;
|
|
101
|
+
/**
|
|
102
|
+
* Custom confetti component
|
|
103
|
+
* If not provided, uses the built-in confetti component.
|
|
104
|
+
*/
|
|
105
|
+
ConfettiComponent?: ConfettiComponent;
|
|
106
|
+
/**
|
|
107
|
+
* Built-in theme name.
|
|
108
|
+
* Built-in themes: 'modern' (default), 'minimal', 'gamified'
|
|
109
|
+
*/
|
|
110
|
+
theme?: string;
|
|
111
|
+
/**
|
|
112
|
+
* Notification positioning
|
|
113
|
+
* @default 'top-center'
|
|
114
|
+
*/
|
|
115
|
+
notificationPosition?: NotificationPosition;
|
|
116
|
+
/**
|
|
117
|
+
* Enable/disable notifications
|
|
118
|
+
* @default true
|
|
119
|
+
*/
|
|
120
|
+
enableNotifications?: boolean;
|
|
121
|
+
/**
|
|
122
|
+
* Enable/disable confetti animations
|
|
123
|
+
* @default true
|
|
124
|
+
*/
|
|
125
|
+
enableConfetti?: boolean;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
type AchievementMetricValue = number | string | boolean | Date | null | undefined;
|
|
129
|
+
type AchievementMetricArrayValue = AchievementMetricValue | AchievementMetricValue[];
|
|
130
|
+
interface AchievementMetrics {
|
|
131
|
+
[key: string]: AchievementMetricValue[];
|
|
132
|
+
}
|
|
133
|
+
interface AchievementDetails {
|
|
134
|
+
achievementId: string;
|
|
135
|
+
achievementTitle: string;
|
|
136
|
+
achievementDescription: string;
|
|
137
|
+
achievementIconKey?: string;
|
|
138
|
+
}
|
|
139
|
+
interface AchievementWithStatus extends AchievementDetails {
|
|
140
|
+
isUnlocked: boolean;
|
|
141
|
+
}
|
|
142
|
+
interface AchievementCondition {
|
|
143
|
+
isConditionMet: (value: AchievementMetricArrayValue, state: AchievementState) => boolean;
|
|
144
|
+
achievementDetails: AchievementDetails | AchievementWithStatus;
|
|
145
|
+
}
|
|
146
|
+
interface AchievementConfiguration {
|
|
147
|
+
[key: string]: AchievementCondition[];
|
|
148
|
+
}
|
|
149
|
+
interface SimpleAchievementDetails {
|
|
150
|
+
title: string;
|
|
151
|
+
description?: string;
|
|
152
|
+
icon?: string;
|
|
153
|
+
}
|
|
154
|
+
interface CustomAchievementDetails extends SimpleAchievementDetails {
|
|
155
|
+
condition: (metrics: Record<string, any>) => boolean;
|
|
156
|
+
}
|
|
157
|
+
interface SimpleAchievementConfig {
|
|
158
|
+
[metric: string]: {
|
|
159
|
+
[threshold: string]: SimpleAchievementDetails | CustomAchievementDetails;
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
type AchievementConfigurationType = AchievementConfiguration | SimpleAchievementConfig;
|
|
163
|
+
interface InitialAchievementMetrics {
|
|
164
|
+
[key: string]: AchievementMetricValue;
|
|
165
|
+
}
|
|
166
|
+
interface AchievementState {
|
|
167
|
+
metrics: AchievementMetrics;
|
|
168
|
+
unlockedAchievements: string[];
|
|
169
|
+
}
|
|
170
|
+
interface AchievementStorage {
|
|
171
|
+
getMetrics(): AchievementMetrics;
|
|
172
|
+
setMetrics(metrics: AchievementMetrics): void;
|
|
173
|
+
getUnlockedAchievements(): string[];
|
|
174
|
+
setUnlockedAchievements(achievements: string[]): void;
|
|
175
|
+
clear(): void;
|
|
176
|
+
}
|
|
177
|
+
interface AsyncAchievementStorage {
|
|
178
|
+
getMetrics(): Promise<AchievementMetrics>;
|
|
179
|
+
setMetrics(metrics: AchievementMetrics): Promise<void>;
|
|
180
|
+
getUnlockedAchievements(): Promise<string[]>;
|
|
181
|
+
setUnlockedAchievements(achievements: string[]): Promise<void>;
|
|
182
|
+
clear(): Promise<void>;
|
|
183
|
+
}
|
|
184
|
+
type AnyAchievementStorage = AchievementStorage | AsyncAchievementStorage;
|
|
185
|
+
declare function isAsyncStorage(storage: AnyAchievementStorage): storage is AsyncAchievementStorage;
|
|
186
|
+
/**
|
|
187
|
+
* @deprecated This type is outdated and will be removed in 4.2.
|
|
188
|
+
* Use AchievementContextType from 'react-achievements' instead.
|
|
189
|
+
*
|
|
190
|
+
* This legacy interface does not include the 'engine' property.
|
|
191
|
+
*
|
|
192
|
+
* @example
|
|
193
|
+
* ```typescript
|
|
194
|
+
* // Old (deprecated)
|
|
195
|
+
* import { AchievementContextValue } from 'react-achievements';
|
|
196
|
+
*
|
|
197
|
+
* // New (recommended)
|
|
198
|
+
* import { AchievementContextType } from 'react-achievements';
|
|
199
|
+
* ```
|
|
200
|
+
*/
|
|
201
|
+
interface AchievementContextValue {
|
|
202
|
+
updateMetrics: (metrics: AchievementMetrics | ((prev: AchievementMetrics) => AchievementMetrics)) => void;
|
|
203
|
+
unlockedAchievements: string[];
|
|
204
|
+
resetStorage: () => void;
|
|
205
|
+
}
|
|
206
|
+
interface StylesProps {
|
|
207
|
+
badgesButton?: React.CSSProperties;
|
|
208
|
+
badgesModal?: {
|
|
209
|
+
overlay?: React.CSSProperties;
|
|
210
|
+
content?: React.CSSProperties;
|
|
211
|
+
header?: React.CSSProperties;
|
|
212
|
+
closeButton?: React.CSSProperties;
|
|
213
|
+
achievementList?: React.CSSProperties;
|
|
214
|
+
achievementItem?: React.CSSProperties;
|
|
215
|
+
achievementTitle?: React.CSSProperties;
|
|
216
|
+
achievementDescription?: React.CSSProperties;
|
|
217
|
+
achievementIcon?: React.CSSProperties;
|
|
218
|
+
lockIcon?: React.CSSProperties;
|
|
219
|
+
lockedAchievementItem?: React.CSSProperties;
|
|
220
|
+
};
|
|
221
|
+
levelProgress?: {
|
|
222
|
+
container?: React.CSSProperties;
|
|
223
|
+
header?: React.CSSProperties;
|
|
224
|
+
levelLabel?: React.CSSProperties;
|
|
225
|
+
valueText?: React.CSSProperties;
|
|
226
|
+
progressTrack?: React.CSSProperties;
|
|
227
|
+
progressBar?: React.CSSProperties;
|
|
228
|
+
progressText?: React.CSSProperties;
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
interface AchievementContextType {
|
|
233
|
+
update: (metrics: Record<string, any>) => void;
|
|
234
|
+
achievements: {
|
|
235
|
+
unlocked: string[];
|
|
236
|
+
all: Record<string, AchievementWithStatus$1>;
|
|
237
|
+
};
|
|
238
|
+
reset: () => void;
|
|
239
|
+
getState: () => {
|
|
240
|
+
metrics: Record<string, any>;
|
|
241
|
+
unlocked: string[];
|
|
242
|
+
};
|
|
243
|
+
exportData: () => string;
|
|
244
|
+
importData: (jsonString: string, options?: ImportOptions) => ImportResult;
|
|
245
|
+
getAllAchievements: () => AchievementWithStatus$1[];
|
|
246
|
+
engine: AchievementEngine;
|
|
247
|
+
icons: Record<string, string>;
|
|
248
|
+
/**
|
|
249
|
+
* @deprecated Use provider props or the presence of an injected engine directly.
|
|
250
|
+
* This compatibility flag will be removed in 4.2.
|
|
251
|
+
*/
|
|
252
|
+
_isLegacyPattern: boolean;
|
|
253
|
+
}
|
|
254
|
+
declare const AchievementContext: React$1.Context<AchievementContextType | undefined>;
|
|
255
|
+
interface AchievementProviderProps {
|
|
256
|
+
achievements?: AchievementConfigurationType$1;
|
|
257
|
+
storage?: AchievementStorage$1 | AsyncAchievementStorage$1 | StorageType;
|
|
258
|
+
restApiConfig?: RestApiStorageConfig;
|
|
259
|
+
eventMapping?: EventMapping;
|
|
260
|
+
engine?: AchievementEngine;
|
|
261
|
+
children: React$1.ReactNode;
|
|
262
|
+
icons?: Record<string, string>;
|
|
263
|
+
onError?: (error: AchievementError) => void;
|
|
264
|
+
/**
|
|
265
|
+
* @deprecated Built-in UI is the default in the web provider. This prop is a
|
|
266
|
+
* no-op and will be removed in 4.2.
|
|
267
|
+
*/
|
|
268
|
+
useBuiltInUI?: boolean;
|
|
269
|
+
}
|
|
270
|
+
declare const AchievementProvider$1: React$1.FC<AchievementProviderProps>;
|
|
271
|
+
|
|
272
|
+
interface AchievementsListRenderItemProps {
|
|
273
|
+
achievement: AchievementWithStatus;
|
|
274
|
+
isLocked: boolean;
|
|
275
|
+
icon: string;
|
|
276
|
+
index: number;
|
|
277
|
+
}
|
|
278
|
+
interface AchievementsListProps {
|
|
279
|
+
achievements?: AchievementWithStatus[];
|
|
280
|
+
showLocked?: boolean;
|
|
281
|
+
showUnlockConditions?: boolean;
|
|
282
|
+
icons?: Record<string, string>;
|
|
283
|
+
styles?: StylesProps['badgesModal'];
|
|
284
|
+
emptyState?: React$1.ReactNode;
|
|
285
|
+
className?: string;
|
|
286
|
+
renderAchievement?: (props: AchievementsListRenderItemProps) => React$1.ReactNode;
|
|
287
|
+
}
|
|
288
|
+
declare const AchievementsList: React$1.FC<AchievementsListProps>;
|
|
289
|
+
|
|
290
|
+
type AchievementsWidgetPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
291
|
+
type AchievementsWidgetPlacement = 'fixed' | 'inline';
|
|
292
|
+
interface AchievementsWidgetTriggerButtonProps extends React$1.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
293
|
+
'data-placement': AchievementsWidgetPlacement;
|
|
294
|
+
'data-testid': string;
|
|
295
|
+
}
|
|
296
|
+
interface AchievementsWidgetTriggerProps {
|
|
297
|
+
open: () => void;
|
|
298
|
+
label: string;
|
|
299
|
+
unlockedCount: number;
|
|
300
|
+
totalCount: number;
|
|
301
|
+
unlockedAchievements: AchievementWithStatus[];
|
|
302
|
+
allAchievements: AchievementWithStatus[];
|
|
303
|
+
buttonProps: AchievementsWidgetTriggerButtonProps;
|
|
304
|
+
}
|
|
305
|
+
interface AchievementsWidgetProps {
|
|
306
|
+
position?: AchievementsWidgetPosition;
|
|
307
|
+
placement?: AchievementsWidgetPlacement;
|
|
308
|
+
showAllAchievements?: boolean;
|
|
309
|
+
showUnlockConditions?: boolean;
|
|
310
|
+
showCount?: boolean;
|
|
311
|
+
icons?: Record<string, string>;
|
|
312
|
+
theme?: string;
|
|
313
|
+
label?: string;
|
|
314
|
+
icon?: React$1.ReactNode;
|
|
315
|
+
triggerClassName?: string;
|
|
316
|
+
renderTrigger?: (props: AchievementsWidgetTriggerProps) => React$1.ReactNode;
|
|
317
|
+
buttonStyles?: React$1.CSSProperties;
|
|
318
|
+
modalStyles?: StylesProps['badgesModal'];
|
|
319
|
+
modalTitle?: React$1.ReactNode;
|
|
320
|
+
emptyState?: React$1.ReactNode;
|
|
321
|
+
renderAchievement?: AchievementsListProps['renderAchievement'];
|
|
322
|
+
}
|
|
323
|
+
declare const AchievementsWidget: React$1.FC<AchievementsWidgetProps>;
|
|
324
|
+
|
|
325
|
+
interface AchievementsModalProps {
|
|
326
|
+
isOpen: boolean;
|
|
327
|
+
onClose: () => void;
|
|
328
|
+
achievements?: AchievementWithStatus[];
|
|
329
|
+
title?: React$1.ReactNode;
|
|
330
|
+
styles?: StylesProps['badgesModal'];
|
|
331
|
+
icons?: Record<string, string>;
|
|
332
|
+
showLocked?: boolean;
|
|
333
|
+
showUnlockConditions?: boolean;
|
|
334
|
+
emptyState?: React$1.ReactNode;
|
|
335
|
+
renderAchievement?: AchievementsListProps['renderAchievement'];
|
|
336
|
+
theme?: string;
|
|
337
|
+
}
|
|
338
|
+
declare const AchievementsModal: React$1.FC<AchievementsModalProps>;
|
|
339
|
+
|
|
340
|
+
interface BadgesButtonProps {
|
|
341
|
+
onClick: () => void;
|
|
342
|
+
/**
|
|
343
|
+
* Position for fixed placement mode
|
|
344
|
+
* Only used when placement='fixed'
|
|
345
|
+
*/
|
|
346
|
+
position?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
347
|
+
/**
|
|
348
|
+
* Placement mode
|
|
349
|
+
* - 'fixed': Traditional floating button with fixed positioning
|
|
350
|
+
* - 'inline': Regular component that can be placed in drawers, nav bars, etc.
|
|
351
|
+
* @default 'fixed'
|
|
352
|
+
*/
|
|
353
|
+
placement?: 'fixed' | 'inline';
|
|
354
|
+
styles?: React$1.CSSProperties;
|
|
355
|
+
unlockedAchievements: AchievementDetails[];
|
|
356
|
+
/**
|
|
357
|
+
* Theme name for styling (matches notification/modal theme)
|
|
358
|
+
* @default 'modern'
|
|
359
|
+
*/
|
|
360
|
+
theme?: string;
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* @deprecated Use `AchievementsWidget` for new integrations. This v3
|
|
364
|
+
* compatibility wrapper will be removed in 4.2.
|
|
365
|
+
*/
|
|
366
|
+
declare const BadgesButton: React$1.FC<BadgesButtonProps>;
|
|
367
|
+
|
|
368
|
+
interface BadgesModalProps {
|
|
369
|
+
isOpen: boolean;
|
|
370
|
+
onClose: () => void;
|
|
371
|
+
achievements: AchievementDetails[];
|
|
372
|
+
styles?: StylesProps['badgesModal'];
|
|
373
|
+
icons?: Record<string, string>;
|
|
374
|
+
showAllAchievements?: boolean;
|
|
375
|
+
showUnlockConditions?: boolean;
|
|
376
|
+
allAchievements?: AchievementWithStatus[];
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* @deprecated Use `AchievementsModal`, `AchievementsWidget`, or
|
|
380
|
+
* `AchievementsList` for new integrations. This v3 compatibility wrapper will
|
|
381
|
+
* be removed in 4.2.
|
|
382
|
+
*/
|
|
383
|
+
declare const BadgesModal: React$1.FC<BadgesModalProps>;
|
|
384
|
+
|
|
385
|
+
interface BadgesButtonWithModalProps {
|
|
386
|
+
unlockedAchievements: AchievementDetails[];
|
|
387
|
+
position?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
388
|
+
placement?: 'fixed' | 'inline';
|
|
389
|
+
showAllAchievements?: boolean;
|
|
390
|
+
allAchievements?: AchievementWithStatus[];
|
|
391
|
+
showUnlockConditions?: boolean;
|
|
392
|
+
icons?: Record<string, string>;
|
|
393
|
+
theme?: string;
|
|
394
|
+
buttonStyles?: React$1.CSSProperties;
|
|
395
|
+
modalStyles?: StylesProps['badgesModal'];
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* @deprecated Use `AchievementsWidget` for new integrations. This v3
|
|
399
|
+
* compatibility wrapper will be removed in 4.2.
|
|
400
|
+
*/
|
|
401
|
+
declare const BadgesButtonWithModal: React$1.FC<BadgesButtonWithModalProps>;
|
|
402
|
+
|
|
403
|
+
interface ConfettiWrapperProps {
|
|
404
|
+
show: boolean;
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* @deprecated Use the provider `ui.ConfettiComponent` option or the built-in
|
|
408
|
+
* confetti default. This v3 compatibility wrapper will be removed in 4.2.
|
|
409
|
+
*/
|
|
410
|
+
declare const ConfettiWrapper: React$1.FC<ConfettiWrapperProps>;
|
|
411
|
+
|
|
412
|
+
interface LevelProgressProps {
|
|
413
|
+
level: number | string;
|
|
414
|
+
currentXP: number;
|
|
415
|
+
nextLevelXP: number;
|
|
416
|
+
label?: string;
|
|
417
|
+
valueLabel?: string;
|
|
418
|
+
showValues?: boolean;
|
|
419
|
+
showPercent?: boolean;
|
|
420
|
+
theme?: string;
|
|
421
|
+
styles?: StylesProps['levelProgress'];
|
|
422
|
+
className?: string;
|
|
423
|
+
}
|
|
424
|
+
declare const LevelProgress: React$1.FC<LevelProgressProps>;
|
|
425
|
+
|
|
426
|
+
interface WebAchievementProviderProps extends AchievementProviderProps {
|
|
427
|
+
icons?: Record<string, string>;
|
|
428
|
+
ui?: UIConfig;
|
|
429
|
+
/**
|
|
430
|
+
* @deprecated Built-in UI is the default in v4. This prop is a no-op and will
|
|
431
|
+
* be removed in 4.2.
|
|
432
|
+
*/
|
|
433
|
+
useBuiltInUI?: boolean;
|
|
434
|
+
}
|
|
435
|
+
declare const AchievementProvider: React$1.FC<WebAchievementProviderProps>;
|
|
436
|
+
|
|
437
|
+
declare const useAchievements: () => AchievementContextType;
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* A simplified hook for achievement tracking.
|
|
441
|
+
* Provides the v4 happy path for direct metric updates plus explicit state names.
|
|
442
|
+
*/
|
|
443
|
+
declare const useSimpleAchievements: () => {
|
|
444
|
+
track: (metric: string, value: any) => void;
|
|
445
|
+
increment: (metric: string, amount?: number) => void;
|
|
446
|
+
trackMultiple: (metrics: Record<string, any>) => void;
|
|
447
|
+
unlockedIds: string[];
|
|
448
|
+
unlockedAchievements: achievements_engine.AchievementWithStatus[];
|
|
449
|
+
allAchievements: achievements_engine.AchievementWithStatus[];
|
|
450
|
+
unlockedCount: number;
|
|
451
|
+
totalCount: number;
|
|
452
|
+
metrics: Record<string, any>;
|
|
453
|
+
reset: () => void;
|
|
454
|
+
getState: () => {
|
|
455
|
+
metrics: Record<string, any>;
|
|
456
|
+
unlocked: string[];
|
|
457
|
+
};
|
|
458
|
+
exportData: () => string;
|
|
459
|
+
importData: (jsonString: string, options?: achievements_engine.ImportOptions) => achievements_engine.ImportResult;
|
|
460
|
+
getAllAchievements: () => achievements_engine.AchievementWithStatus[];
|
|
461
|
+
/**
|
|
462
|
+
* @deprecated Use `unlockedIds` instead. This alias will be removed in 4.2.
|
|
463
|
+
*/
|
|
464
|
+
unlocked: string[];
|
|
465
|
+
/**
|
|
466
|
+
* @deprecated Use `allAchievements` instead. This alias will be removed in 4.2.
|
|
467
|
+
*/
|
|
468
|
+
all: achievements_engine.AchievementWithStatus[];
|
|
469
|
+
};
|
|
470
|
+
|
|
471
|
+
declare const useAchievementState: () => {
|
|
472
|
+
unlockedIds: string[];
|
|
473
|
+
unlockedAchievements: achievements_engine.AchievementWithStatus[];
|
|
474
|
+
allAchievements: achievements_engine.AchievementWithStatus[];
|
|
475
|
+
unlockedCount: number;
|
|
476
|
+
totalCount: number;
|
|
477
|
+
metrics: Record<string, any>;
|
|
478
|
+
};
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* Access the active AchievementEngine instance.
|
|
482
|
+
*
|
|
483
|
+
* In v4 this works with both provider-created engines (`achievements` prop) and
|
|
484
|
+
* injected engines (`engine` prop).
|
|
485
|
+
*/
|
|
486
|
+
declare const useAchievementEngine: () => AchievementEngine;
|
|
487
|
+
|
|
488
|
+
declare const defaultStyles: Required<StylesProps>;
|
|
489
|
+
|
|
490
|
+
declare const defaultAchievementIcons: {
|
|
491
|
+
default: string;
|
|
492
|
+
loading: string;
|
|
493
|
+
error: string;
|
|
494
|
+
success: string;
|
|
495
|
+
trophy: string;
|
|
496
|
+
star: string;
|
|
497
|
+
};
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* Built-in notification component
|
|
501
|
+
* Modern, theme-aware achievement notification with smooth animations
|
|
502
|
+
*/
|
|
503
|
+
declare const BuiltInNotification: React$1.FC<NotificationProps>;
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* Built-in modal component
|
|
507
|
+
* Modern, theme-aware achievement modal with smooth animations
|
|
508
|
+
*/
|
|
509
|
+
declare const BuiltInModal: React$1.FC<ModalProps>;
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* Built-in confetti component
|
|
513
|
+
* Lightweight CSS-based confetti animation
|
|
514
|
+
*/
|
|
515
|
+
declare const BuiltInConfetti: React$1.FC<ConfettiProps>;
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* Hook to track window dimensions
|
|
519
|
+
* Replacement for react-use's useWindowSize
|
|
520
|
+
*
|
|
521
|
+
* @returns Object with width and height properties
|
|
522
|
+
*
|
|
523
|
+
* @example
|
|
524
|
+
* ```tsx
|
|
525
|
+
* const { width, height } = useWindowSize();
|
|
526
|
+
* console.log(`Window size: ${width}x${height}`);
|
|
527
|
+
* ```
|
|
528
|
+
*/
|
|
529
|
+
declare function useWindowSize(): {
|
|
530
|
+
width: number;
|
|
531
|
+
height: number;
|
|
532
|
+
};
|
|
533
|
+
|
|
534
|
+
export { AchievementCondition, AchievementConfiguration, AchievementConfigurationType, AchievementContext, AchievementContextType, AchievementContextValue, AchievementDetails, AchievementMetricArrayValue, AchievementMetricValue, AchievementMetrics, AchievementProvider, WebAchievementProviderProps as AchievementProviderProps, AchievementState, AchievementStorage, AchievementWithStatus, AchievementsList, AchievementsListProps, AchievementsListRenderItemProps, AchievementsModal, AchievementsModalProps, AchievementsWidget, AchievementsWidgetPlacement, AchievementsWidgetPosition, AchievementsWidgetProps, AchievementsWidgetTriggerButtonProps, AchievementsWidgetTriggerProps, AnyAchievementStorage, AsyncAchievementStorage, BadgesButton, BadgesButtonWithModal, BadgesModal, BuiltInConfetti, BuiltInModal, BuiltInNotification, ConfettiComponent, ConfettiProps, ConfettiWrapper, CustomAchievementDetails, AchievementProvider$1 as HeadlessAchievementProvider, InitialAchievementMetrics, LevelProgress, ModalComponent, ModalProps, NotificationComponent, NotificationPosition, NotificationProps, SimpleAchievementConfig, SimpleAchievementDetails, StylesProps, ThemeConfig, UIConfig, defaultAchievementIcons, defaultStyles, isAsyncStorage, useAchievementEngine, useAchievementState, useAchievements, useSimpleAchievements, useWindowSize };
|