react-achievements 3.4.2 → 3.6.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 +354 -21
- package/dist/index.d.ts +210 -2
- package/dist/index.js +915 -185
- package/dist/index.js.map +1 -1
- package/dist/types/core/components/BadgesButton.d.ts +18 -3
- package/dist/types/core/components/BadgesModal.d.ts +4 -1
- package/dist/types/core/hooks/useWindowSize.d.ts +16 -0
- package/dist/types/core/types.d.ts +6 -0
- package/dist/types/core/ui/BuiltInConfetti.d.ts +7 -0
- package/dist/types/core/ui/BuiltInModal.d.ts +7 -0
- package/dist/types/core/ui/BuiltInNotification.d.ts +7 -0
- package/dist/types/core/ui/LegacyWrappers.d.ts +21 -0
- package/dist/types/core/ui/interfaces.d.ts +131 -0
- package/dist/types/core/ui/legacyDetector.d.ts +40 -0
- package/dist/types/core/ui/themes.d.ts +14 -0
- package/dist/types/hooks/useSimpleAchievements.d.ts +5 -0
- package/dist/types/index.d.ts +6 -1
- package/dist/types/providers/AchievementProvider.d.ts +15 -2
- package/package.json +15 -1
- package/dist/assets/defaultIcons.d.ts +0 -81
- package/dist/badges.d.ts +0 -8
- package/dist/components/Achievement.d.ts +0 -10
- package/dist/components/AchievementModal.d.ts +0 -12
- package/dist/components/Badge.d.ts +0 -9
- package/dist/components/BadgesButton.d.ts +0 -14
- package/dist/components/BadgesModal.d.ts +0 -12
- package/dist/components/ConfettiWrapper.d.ts +0 -6
- package/dist/components/Progress.d.ts +0 -6
- package/dist/context/AchievementContext.d.ts +0 -21
- package/dist/defaultStyles.d.ts +0 -19
- package/dist/hooks/useAchievement.d.ts +0 -8
- package/dist/hooks/useAchievementState.d.ts +0 -4
- package/dist/index.cjs.js +0 -2428
- package/dist/index.esm.js +0 -2403
- package/dist/levels.d.ts +0 -7
- package/dist/providers/AchievementProvider.d.ts +0 -12
- package/dist/redux/achievementSlice.d.ts +0 -30
- package/dist/redux/notificationSlice.d.ts +0 -7
- package/dist/redux/store.d.ts +0 -15
- package/dist/stories/Button.d.ts +0 -28
- package/dist/stories/Button.stories.d.ts +0 -23
- package/dist/stories/Header.d.ts +0 -13
- package/dist/stories/Header.stories.d.ts +0 -18
- package/dist/stories/Page.d.ts +0 -3
- package/dist/stories/Page.stories.d.ts +0 -12
- package/dist/types/core/context/AchievementContext.d.ts +0 -5
- package/dist/types/stories/Button.d.ts +0 -16
- package/dist/types/stories/Button.stories.d.ts +0 -23
- package/dist/types/stories/Header.d.ts +0 -13
- package/dist/types/stories/Header.stories.d.ts +0 -18
- package/dist/types/stories/Page.d.ts +0 -3
- package/dist/types/stories/Page.stories.d.ts +0 -12
- package/dist/types.d.ts +0 -37
- package/dist/utils/EventEmitter.d.ts +0 -6
package/dist/levels.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import 'react-toastify/dist/ReactToastify.css';
|
|
3
|
-
import { AchievementProviderProps, AchievementMetrics } from '../types';
|
|
4
|
-
export interface AchievementContextType {
|
|
5
|
-
updateMetrics: (newMetrics: AchievementMetrics | ((prevMetrics: AchievementMetrics) => AchievementMetrics)) => void;
|
|
6
|
-
unlockedAchievements: string[];
|
|
7
|
-
resetStorage: () => void;
|
|
8
|
-
}
|
|
9
|
-
export declare const AchievementContext: React.Context<AchievementContextType | undefined>;
|
|
10
|
-
export declare const useAchievementContext: () => AchievementContextType;
|
|
11
|
-
declare const AchievementProvider: React.FC<AchievementProviderProps>;
|
|
12
|
-
export { AchievementProvider };
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { PayloadAction } from '@reduxjs/toolkit';
|
|
2
|
-
import { InitialAchievementMetrics, AchievementMetrics, SerializedAchievementConfiguration } from '../types';
|
|
3
|
-
export interface AchievementState {
|
|
4
|
-
config: SerializedAchievementConfiguration;
|
|
5
|
-
metrics: AchievementMetrics;
|
|
6
|
-
unlockedAchievements: string[];
|
|
7
|
-
previouslyAwardedAchievements: string[];
|
|
8
|
-
storageKey: string | null;
|
|
9
|
-
}
|
|
10
|
-
export declare const achievementSlice: import("@reduxjs/toolkit").Slice<AchievementState, {
|
|
11
|
-
initialize: (state: import("immer/dist/internal").WritableDraft<AchievementState>, action: PayloadAction<{
|
|
12
|
-
config: SerializedAchievementConfiguration;
|
|
13
|
-
initialState?: InitialAchievementMetrics & {
|
|
14
|
-
previouslyAwardedAchievements?: string[];
|
|
15
|
-
};
|
|
16
|
-
storageKey: string;
|
|
17
|
-
}>) => void;
|
|
18
|
-
setMetrics: (state: import("immer/dist/internal").WritableDraft<AchievementState>, action: PayloadAction<AchievementMetrics>) => void;
|
|
19
|
-
markAchievementAsAwarded: (state: import("immer/dist/internal").WritableDraft<AchievementState>, action: PayloadAction<string>) => void;
|
|
20
|
-
resetAchievements: (state: import("immer/dist/internal").WritableDraft<AchievementState>) => void;
|
|
21
|
-
}, "achievements">;
|
|
22
|
-
export declare const initialize: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
23
|
-
config: SerializedAchievementConfiguration;
|
|
24
|
-
initialState?: InitialAchievementMetrics & {
|
|
25
|
-
previouslyAwardedAchievements?: string[];
|
|
26
|
-
};
|
|
27
|
-
storageKey: string;
|
|
28
|
-
}, "achievements/initialize">, setMetrics: import("@reduxjs/toolkit").ActionCreatorWithPayload<AchievementMetrics, "achievements/setMetrics">, resetAchievements: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"achievements/resetAchievements">, markAchievementAsAwarded: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "achievements/markAchievementAsAwarded">;
|
|
29
|
-
declare const _default: import("@reduxjs/toolkit").Reducer<AchievementState>;
|
|
30
|
-
export default _default;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { AchievementDetails } from '../types';
|
|
2
|
-
export interface NotificationState {
|
|
3
|
-
notifications: AchievementDetails[];
|
|
4
|
-
}
|
|
5
|
-
export declare const addNotification: import("@reduxjs/toolkit").ActionCreatorWithPayload<AchievementDetails, "notifications/addNotification">, clearNotifications: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"notifications/clearNotifications">;
|
|
6
|
-
declare const _default: import("@reduxjs/toolkit").Reducer<NotificationState>;
|
|
7
|
-
export default _default;
|
package/dist/redux/store.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { AchievementState } from './achievementSlice';
|
|
2
|
-
import { NotificationState } from './notificationSlice';
|
|
3
|
-
export interface RootState {
|
|
4
|
-
achievements: AchievementState;
|
|
5
|
-
notifications: NotificationState;
|
|
6
|
-
}
|
|
7
|
-
declare const store: import("@reduxjs/toolkit/dist/configureStore").ToolkitStore<{
|
|
8
|
-
achievements: AchievementState;
|
|
9
|
-
notifications: NotificationState;
|
|
10
|
-
}, import("@reduxjs/toolkit").AnyAction, [import("@reduxjs/toolkit").ThunkMiddleware<{
|
|
11
|
-
achievements: AchievementState;
|
|
12
|
-
notifications: NotificationState;
|
|
13
|
-
}, import("@reduxjs/toolkit").AnyAction>]>;
|
|
14
|
-
export type AppDispatch = typeof store.dispatch;
|
|
15
|
-
export default store;
|
package/dist/stories/Button.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import './button.css';
|
|
3
|
-
export interface ButtonProps {
|
|
4
|
-
/**
|
|
5
|
-
* Is this the principal call to action on the page?
|
|
6
|
-
*/
|
|
7
|
-
primary?: boolean;
|
|
8
|
-
/**
|
|
9
|
-
* What background color to use
|
|
10
|
-
*/
|
|
11
|
-
backgroundColor?: string;
|
|
12
|
-
/**
|
|
13
|
-
* How large should the button be?
|
|
14
|
-
*/
|
|
15
|
-
size?: 'small' | 'medium' | 'large';
|
|
16
|
-
/**
|
|
17
|
-
* Button contents
|
|
18
|
-
*/
|
|
19
|
-
label: string;
|
|
20
|
-
/**
|
|
21
|
-
* Optional click handler
|
|
22
|
-
*/
|
|
23
|
-
onClick?: () => void;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Primary UI component for user interaction
|
|
27
|
-
*/
|
|
28
|
-
export declare const Button: ({ primary, size, backgroundColor, label, ...props }: ButtonProps) => React.JSX.Element;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { StoryObj } from '@storybook/react';
|
|
2
|
-
declare const meta: {
|
|
3
|
-
title: string;
|
|
4
|
-
component: ({ primary, size, backgroundColor, label, ...props }: import("./Button").ButtonProps) => import("react").JSX.Element;
|
|
5
|
-
parameters: {
|
|
6
|
-
layout: string;
|
|
7
|
-
};
|
|
8
|
-
tags: string[];
|
|
9
|
-
argTypes: {
|
|
10
|
-
backgroundColor: {
|
|
11
|
-
control: "color";
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
args: {
|
|
15
|
-
onClick: import("@vitest/spy").Mock<[], void>;
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
export default meta;
|
|
19
|
-
type Story = StoryObj<typeof meta>;
|
|
20
|
-
export declare const Primary: Story;
|
|
21
|
-
export declare const Secondary: Story;
|
|
22
|
-
export declare const Large: Story;
|
|
23
|
-
export declare const Small: Story;
|
package/dist/stories/Header.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import './header.css';
|
|
3
|
-
type User = {
|
|
4
|
-
name: string;
|
|
5
|
-
};
|
|
6
|
-
export interface HeaderProps {
|
|
7
|
-
user?: User;
|
|
8
|
-
onLogin?: () => void;
|
|
9
|
-
onLogout?: () => void;
|
|
10
|
-
onCreateAccount?: () => void;
|
|
11
|
-
}
|
|
12
|
-
export declare const Header: ({ user, onLogin, onLogout, onCreateAccount }: HeaderProps) => React.JSX.Element;
|
|
13
|
-
export {};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { StoryObj } from '@storybook/react';
|
|
2
|
-
declare const meta: {
|
|
3
|
-
title: string;
|
|
4
|
-
component: ({ user, onLogin, onLogout, onCreateAccount }: import("./Header").HeaderProps) => import("react").JSX.Element;
|
|
5
|
-
tags: string[];
|
|
6
|
-
parameters: {
|
|
7
|
-
layout: string;
|
|
8
|
-
};
|
|
9
|
-
args: {
|
|
10
|
-
onLogin: import("@vitest/spy").Mock<[], void>;
|
|
11
|
-
onLogout: import("@vitest/spy").Mock<[], void>;
|
|
12
|
-
onCreateAccount: import("@vitest/spy").Mock<[], void>;
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
export default meta;
|
|
16
|
-
type Story = StoryObj<typeof meta>;
|
|
17
|
-
export declare const LoggedIn: Story;
|
|
18
|
-
export declare const LoggedOut: Story;
|
package/dist/stories/Page.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { StoryObj } from '@storybook/react';
|
|
2
|
-
declare const meta: {
|
|
3
|
-
title: string;
|
|
4
|
-
component: import("react").FC<{}>;
|
|
5
|
-
parameters: {
|
|
6
|
-
layout: string;
|
|
7
|
-
};
|
|
8
|
-
};
|
|
9
|
-
export default meta;
|
|
10
|
-
type Story = StoryObj<typeof meta>;
|
|
11
|
-
export declare const LoggedOut: Story;
|
|
12
|
-
export declare const LoggedIn: Story;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import 'react-toastify/dist/ReactToastify.css';
|
|
3
|
-
import { AchievementContextValue, AchievementProviderProps } from '../types';
|
|
4
|
-
export declare const useAchievementContext: () => AchievementContextValue;
|
|
5
|
-
export declare const AchievementProvider: React.FC<AchievementProviderProps>;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import './button.css';
|
|
3
|
-
export interface ButtonProps {
|
|
4
|
-
/** Is this the principal call to action on the page? */
|
|
5
|
-
primary?: boolean;
|
|
6
|
-
/** What background color to use */
|
|
7
|
-
backgroundColor?: string;
|
|
8
|
-
/** How large should the button be? */
|
|
9
|
-
size?: 'small' | 'medium' | 'large';
|
|
10
|
-
/** Button contents */
|
|
11
|
-
label: string;
|
|
12
|
-
/** Optional click handler */
|
|
13
|
-
onClick?: () => void;
|
|
14
|
-
}
|
|
15
|
-
/** Primary UI component for user interaction */
|
|
16
|
-
export declare const Button: ({ primary, size, backgroundColor, label, ...props }: ButtonProps) => React.JSX.Element;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { StoryObj } from '@storybook/react';
|
|
2
|
-
declare const meta: {
|
|
3
|
-
title: string;
|
|
4
|
-
component: ({ primary, size, backgroundColor, label, ...props }: import("./Button").ButtonProps) => import("react").JSX.Element;
|
|
5
|
-
parameters: {
|
|
6
|
-
layout: string;
|
|
7
|
-
};
|
|
8
|
-
tags: string[];
|
|
9
|
-
argTypes: {
|
|
10
|
-
backgroundColor: {
|
|
11
|
-
control: "color";
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
args: {
|
|
15
|
-
onClick: import("@vitest/spy").Mock<(...args: any[]) => any>;
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
export default meta;
|
|
19
|
-
type Story = StoryObj<typeof meta>;
|
|
20
|
-
export declare const Primary: Story;
|
|
21
|
-
export declare const Secondary: Story;
|
|
22
|
-
export declare const Large: Story;
|
|
23
|
-
export declare const Small: Story;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import './header.css';
|
|
3
|
-
type User = {
|
|
4
|
-
name: string;
|
|
5
|
-
};
|
|
6
|
-
export interface HeaderProps {
|
|
7
|
-
user?: User;
|
|
8
|
-
onLogin?: () => void;
|
|
9
|
-
onLogout?: () => void;
|
|
10
|
-
onCreateAccount?: () => void;
|
|
11
|
-
}
|
|
12
|
-
export declare const Header: ({ user, onLogin, onLogout, onCreateAccount }: HeaderProps) => React.JSX.Element;
|
|
13
|
-
export {};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { StoryObj } from '@storybook/react';
|
|
2
|
-
declare const meta: {
|
|
3
|
-
title: string;
|
|
4
|
-
component: ({ user, onLogin, onLogout, onCreateAccount }: import("./Header").HeaderProps) => import("react").JSX.Element;
|
|
5
|
-
tags: string[];
|
|
6
|
-
parameters: {
|
|
7
|
-
layout: string;
|
|
8
|
-
};
|
|
9
|
-
args: {
|
|
10
|
-
onLogin: import("@vitest/spy").Mock<(...args: any[]) => any>;
|
|
11
|
-
onLogout: import("@vitest/spy").Mock<(...args: any[]) => any>;
|
|
12
|
-
onCreateAccount: import("@vitest/spy").Mock<(...args: any[]) => any>;
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
export default meta;
|
|
16
|
-
type Story = StoryObj<typeof meta>;
|
|
17
|
-
export declare const LoggedIn: Story;
|
|
18
|
-
export declare const LoggedOut: Story;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { StoryObj } from '@storybook/react';
|
|
2
|
-
declare const meta: {
|
|
3
|
-
title: string;
|
|
4
|
-
component: import("react").FC<{}>;
|
|
5
|
-
parameters: {
|
|
6
|
-
layout: string;
|
|
7
|
-
};
|
|
8
|
-
};
|
|
9
|
-
export default meta;
|
|
10
|
-
type Story = StoryObj<typeof meta>;
|
|
11
|
-
export declare const LoggedOut: Story;
|
|
12
|
-
export declare const LoggedIn: Story;
|
package/dist/types.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Styles } from "./defaultStyles";
|
|
2
|
-
export type AchievementMetricValue = number | string | boolean | Date;
|
|
3
|
-
export interface AchievementDetails {
|
|
4
|
-
achievementId: string;
|
|
5
|
-
achievementTitle: string;
|
|
6
|
-
achievementDescription: string;
|
|
7
|
-
achievementIconKey?: string;
|
|
8
|
-
}
|
|
9
|
-
export type AchievementIconRecord = Record<string, string>;
|
|
10
|
-
export interface AchievementConfiguration {
|
|
11
|
-
[metricName: string]: Array<AchievementUnlockCondition<AchievementMetricValue>>;
|
|
12
|
-
}
|
|
13
|
-
export type InitialAchievementMetrics = Record<string, AchievementMetricValue | AchievementMetricValue[] | undefined>;
|
|
14
|
-
export type AchievementMetrics = Record<string, AchievementMetricValue[]>;
|
|
15
|
-
export interface AchievementProviderProps {
|
|
16
|
-
children: React.ReactNode;
|
|
17
|
-
config: AchievementConfiguration;
|
|
18
|
-
initialState?: InitialAchievementMetrics & {
|
|
19
|
-
previouslyAwardedAchievements?: string[];
|
|
20
|
-
};
|
|
21
|
-
storageKey?: string;
|
|
22
|
-
badgesButtonPosition?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
23
|
-
styles?: Partial<Styles>;
|
|
24
|
-
icons?: Record<string, string>;
|
|
25
|
-
}
|
|
26
|
-
export interface AchievementUnlockCondition<T extends AchievementMetricValue> {
|
|
27
|
-
isConditionMet: (value: T) => boolean;
|
|
28
|
-
achievementDetails: AchievementDetails;
|
|
29
|
-
}
|
|
30
|
-
export interface SerializedAchievementUnlockCondition {
|
|
31
|
-
achievementDetails: AchievementDetails;
|
|
32
|
-
conditionType: 'number' | 'string' | 'boolean' | 'date';
|
|
33
|
-
conditionValue: any;
|
|
34
|
-
}
|
|
35
|
-
export interface SerializedAchievementConfiguration {
|
|
36
|
-
[metricName: string]: SerializedAchievementUnlockCondition[];
|
|
37
|
-
}
|