@stamprally/ui 0.10.0 → 0.11.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/dist/index.d.cts CHANGED
@@ -1,43 +1,82 @@
1
- import { PublicSpotItem, PublicCheckInCondition, LocaleDictionary, PublicRallyConfig, StampRallyClient, CheckInOptions, CheckInResult, ClaimOptions, ClaimResult, RallyConfig, StampRallyState, StampRallyProgress } from '@stamprally/core';
2
- import { ComponentType, CSSProperties, ReactElement } from 'react';
1
+ import { PublicSpotItem, PublicCheckInCondition, LocaleDictionary, PublicRallyConfig, UserRallyState, PublicReward, RewardState, ClaimOptions, ClaimResult, CheckInResult, StampRallyClient, CheckInOptions, RallyConfig, StampRallyState, StampRallyProgress } from '@stamprally/core';
2
+ import { ComponentType, CSSProperties, ReactNode, ReactElement } from 'react';
3
3
 
4
+ type ViewerClassName = "root" | "header" | "card" | "condition" | "slot" | "badge" | "modal" | "button" | "action" | "feedback" | "reward" | "footer";
5
+ type ViewerStyle = CSSProperties & {
6
+ readonly [key: `--${string}`]: string | number | undefined;
7
+ };
8
+ type ViewerStyles = Partial<Record<ViewerClassName, ViewerStyle>>;
9
+ type ViewerClassNames = Partial<Record<ViewerClassName, string>>;
10
+ type SpotStatus = "locked" | "available" | "claimed" | "verifying" | "error";
4
11
  interface ConditionRendererProps<TLocale extends string = string> {
5
12
  readonly spot: PublicSpotItem<TLocale>;
6
13
  readonly condition: PublicCheckInCondition;
7
14
  readonly locale: TLocale;
8
15
  readonly dictionary?: LocaleDictionary<TLocale>;
9
16
  readonly disabled: boolean;
17
+ readonly classNames?: ViewerClassNames;
18
+ readonly styles?: ViewerStyles;
10
19
  readonly onSubmit: (proof: unknown) => void | Promise<unknown>;
11
20
  }
12
21
  type ConditionRenderer<TLocale extends string = string> = ComponentType<ConditionRendererProps<TLocale>>;
13
- type ViewerClassName = "root" | "condition" | "action" | "feedback" | "reward";
14
- type ViewerStyle = CSSProperties & {
15
- readonly [key: `--${string}`]: string | number | undefined;
16
- };
22
+ interface SpotCardProps<TLocale extends string = string> {
23
+ readonly spot: PublicSpotItem<TLocale>;
24
+ readonly state: UserRallyState;
25
+ readonly status: SpotStatus;
26
+ readonly locale: TLocale;
27
+ readonly dictionary?: LocaleDictionary<TLocale>;
28
+ readonly children: ReactNode;
29
+ }
30
+ interface RewardCardProps<TLocale extends string = string> {
31
+ readonly reward: PublicReward<TLocale>;
32
+ readonly state: RewardState | undefined;
33
+ readonly locale: TLocale;
34
+ readonly dictionary?: LocaleDictionary<TLocale>;
35
+ readonly onClaim: ((rewardId: string, options?: ClaimOptions) => Promise<ClaimResult>) | undefined;
36
+ }
37
+ interface RallyViewerSlots<TLocale extends string = string> {
38
+ readonly headerSlot?: ReactNode | ((props: {
39
+ readonly config: PublicRallyConfig<TLocale>;
40
+ readonly state: UserRallyState;
41
+ }) => ReactNode);
42
+ readonly footerSlot?: ReactNode;
43
+ readonly renderSpotCard?: (props: SpotCardProps<TLocale>) => ReactNode;
44
+ readonly renderRewardCard?: (props: RewardCardProps<TLocale>) => ReactNode;
45
+ readonly renderStatusBadge?: (props: {
46
+ readonly status: SpotStatus;
47
+ }) => ReactNode;
48
+ readonly renderVerifyingState?: () => ReactNode;
49
+ readonly renderSuccessFeedback?: (result: CheckInResult) => ReactNode;
50
+ readonly renderErrorFeedback?: (error: string) => ReactNode;
51
+ }
17
52
  interface RallyViewerAdapter<TLocale extends string = string> {
18
53
  readonly config: PublicRallyConfig<TLocale>;
19
54
  readonly onCheckIn: (spotId: string, proof: unknown, options?: CheckInOptions) => Promise<CheckInResult>;
20
55
  readonly onClaimReward?: (rewardId: string, options?: ClaimOptions) => Promise<ClaimResult>;
21
56
  }
22
- interface RallyViewerProps<TLocale extends string = string> {
57
+ interface RallyViewerProps<TLocale extends string = string> extends RallyViewerSlots<TLocale> {
23
58
  readonly config?: PublicRallyConfig<TLocale>;
24
59
  readonly client?: StampRallyClient;
25
60
  readonly adapter?: RallyViewerAdapter<TLocale>;
26
61
  readonly locale: TLocale;
27
62
  readonly dictionary?: LocaleDictionary<TLocale>;
28
- readonly classNames?: Partial<Record<ViewerClassName, string>>;
63
+ readonly classNames?: ViewerClassNames;
64
+ readonly styles?: ViewerStyles;
29
65
  readonly style?: ViewerStyle;
30
66
  readonly customConditionRenderers?: Partial<Record<PublicCheckInCondition["type"], ConditionRenderer<TLocale>>>;
31
67
  }
32
- declare function RallyViewer<TLocale extends string = string>({ config: providedConfig, client, adapter, locale, dictionary, classNames, style, customConditionRenderers, }: RallyViewerProps<TLocale>): ReactElement;
33
- interface StampSheetProps<TLocale extends string = string> {
68
+ declare function RallyViewer<TLocale extends string = string>({ config: providedConfig, client, adapter, locale, dictionary, classNames, styles, style, customConditionRenderers, headerSlot, footerSlot, renderSpotCard, renderRewardCard, renderStatusBadge, renderVerifyingState, renderSuccessFeedback, renderErrorFeedback, }: RallyViewerProps<TLocale>): ReactElement;
69
+ interface StampSheetProps<TLocale extends string = string> extends RallyViewerSlots<TLocale> {
34
70
  readonly config: RallyConfig<TLocale>;
35
71
  readonly state?: StampRallyState | null;
36
72
  readonly title?: string;
37
73
  readonly progress?: StampRallyProgress;
38
74
  readonly locale?: TLocale;
39
75
  readonly dictionary?: LocaleDictionary<TLocale>;
76
+ readonly classNames?: ViewerClassNames;
77
+ readonly styles?: ViewerStyles;
78
+ readonly style?: ViewerStyle;
40
79
  }
41
- declare function StampSheet<TLocale extends string = string>({ config, state, title, progress, locale, dictionary, }: StampSheetProps<TLocale>): ReactElement;
80
+ declare function StampSheet<TLocale extends string = string>({ config, state, title, progress, locale, dictionary, classNames, styles, style, headerSlot, footerSlot, renderSpotCard, renderStatusBadge, }: StampSheetProps<TLocale>): ReactElement;
42
81
 
43
- export { type ConditionRenderer, type ConditionRendererProps, RallyViewer, type RallyViewerAdapter, type RallyViewerProps, StampSheet, type StampSheetProps, type ViewerClassName, type ViewerStyle };
82
+ export { type ConditionRenderer, type ConditionRendererProps, RallyViewer, type RallyViewerAdapter, type RallyViewerProps, type RallyViewerSlots, type RewardCardProps, type SpotCardProps, type SpotStatus, StampSheet, type StampSheetProps, type ViewerClassName, type ViewerClassNames, type ViewerStyle, type ViewerStyles };
package/dist/index.d.ts CHANGED
@@ -1,43 +1,82 @@
1
- import { PublicSpotItem, PublicCheckInCondition, LocaleDictionary, PublicRallyConfig, StampRallyClient, CheckInOptions, CheckInResult, ClaimOptions, ClaimResult, RallyConfig, StampRallyState, StampRallyProgress } from '@stamprally/core';
2
- import { ComponentType, CSSProperties, ReactElement } from 'react';
1
+ import { PublicSpotItem, PublicCheckInCondition, LocaleDictionary, PublicRallyConfig, UserRallyState, PublicReward, RewardState, ClaimOptions, ClaimResult, CheckInResult, StampRallyClient, CheckInOptions, RallyConfig, StampRallyState, StampRallyProgress } from '@stamprally/core';
2
+ import { ComponentType, CSSProperties, ReactNode, ReactElement } from 'react';
3
3
 
4
+ type ViewerClassName = "root" | "header" | "card" | "condition" | "slot" | "badge" | "modal" | "button" | "action" | "feedback" | "reward" | "footer";
5
+ type ViewerStyle = CSSProperties & {
6
+ readonly [key: `--${string}`]: string | number | undefined;
7
+ };
8
+ type ViewerStyles = Partial<Record<ViewerClassName, ViewerStyle>>;
9
+ type ViewerClassNames = Partial<Record<ViewerClassName, string>>;
10
+ type SpotStatus = "locked" | "available" | "claimed" | "verifying" | "error";
4
11
  interface ConditionRendererProps<TLocale extends string = string> {
5
12
  readonly spot: PublicSpotItem<TLocale>;
6
13
  readonly condition: PublicCheckInCondition;
7
14
  readonly locale: TLocale;
8
15
  readonly dictionary?: LocaleDictionary<TLocale>;
9
16
  readonly disabled: boolean;
17
+ readonly classNames?: ViewerClassNames;
18
+ readonly styles?: ViewerStyles;
10
19
  readonly onSubmit: (proof: unknown) => void | Promise<unknown>;
11
20
  }
12
21
  type ConditionRenderer<TLocale extends string = string> = ComponentType<ConditionRendererProps<TLocale>>;
13
- type ViewerClassName = "root" | "condition" | "action" | "feedback" | "reward";
14
- type ViewerStyle = CSSProperties & {
15
- readonly [key: `--${string}`]: string | number | undefined;
16
- };
22
+ interface SpotCardProps<TLocale extends string = string> {
23
+ readonly spot: PublicSpotItem<TLocale>;
24
+ readonly state: UserRallyState;
25
+ readonly status: SpotStatus;
26
+ readonly locale: TLocale;
27
+ readonly dictionary?: LocaleDictionary<TLocale>;
28
+ readonly children: ReactNode;
29
+ }
30
+ interface RewardCardProps<TLocale extends string = string> {
31
+ readonly reward: PublicReward<TLocale>;
32
+ readonly state: RewardState | undefined;
33
+ readonly locale: TLocale;
34
+ readonly dictionary?: LocaleDictionary<TLocale>;
35
+ readonly onClaim: ((rewardId: string, options?: ClaimOptions) => Promise<ClaimResult>) | undefined;
36
+ }
37
+ interface RallyViewerSlots<TLocale extends string = string> {
38
+ readonly headerSlot?: ReactNode | ((props: {
39
+ readonly config: PublicRallyConfig<TLocale>;
40
+ readonly state: UserRallyState;
41
+ }) => ReactNode);
42
+ readonly footerSlot?: ReactNode;
43
+ readonly renderSpotCard?: (props: SpotCardProps<TLocale>) => ReactNode;
44
+ readonly renderRewardCard?: (props: RewardCardProps<TLocale>) => ReactNode;
45
+ readonly renderStatusBadge?: (props: {
46
+ readonly status: SpotStatus;
47
+ }) => ReactNode;
48
+ readonly renderVerifyingState?: () => ReactNode;
49
+ readonly renderSuccessFeedback?: (result: CheckInResult) => ReactNode;
50
+ readonly renderErrorFeedback?: (error: string) => ReactNode;
51
+ }
17
52
  interface RallyViewerAdapter<TLocale extends string = string> {
18
53
  readonly config: PublicRallyConfig<TLocale>;
19
54
  readonly onCheckIn: (spotId: string, proof: unknown, options?: CheckInOptions) => Promise<CheckInResult>;
20
55
  readonly onClaimReward?: (rewardId: string, options?: ClaimOptions) => Promise<ClaimResult>;
21
56
  }
22
- interface RallyViewerProps<TLocale extends string = string> {
57
+ interface RallyViewerProps<TLocale extends string = string> extends RallyViewerSlots<TLocale> {
23
58
  readonly config?: PublicRallyConfig<TLocale>;
24
59
  readonly client?: StampRallyClient;
25
60
  readonly adapter?: RallyViewerAdapter<TLocale>;
26
61
  readonly locale: TLocale;
27
62
  readonly dictionary?: LocaleDictionary<TLocale>;
28
- readonly classNames?: Partial<Record<ViewerClassName, string>>;
63
+ readonly classNames?: ViewerClassNames;
64
+ readonly styles?: ViewerStyles;
29
65
  readonly style?: ViewerStyle;
30
66
  readonly customConditionRenderers?: Partial<Record<PublicCheckInCondition["type"], ConditionRenderer<TLocale>>>;
31
67
  }
32
- declare function RallyViewer<TLocale extends string = string>({ config: providedConfig, client, adapter, locale, dictionary, classNames, style, customConditionRenderers, }: RallyViewerProps<TLocale>): ReactElement;
33
- interface StampSheetProps<TLocale extends string = string> {
68
+ declare function RallyViewer<TLocale extends string = string>({ config: providedConfig, client, adapter, locale, dictionary, classNames, styles, style, customConditionRenderers, headerSlot, footerSlot, renderSpotCard, renderRewardCard, renderStatusBadge, renderVerifyingState, renderSuccessFeedback, renderErrorFeedback, }: RallyViewerProps<TLocale>): ReactElement;
69
+ interface StampSheetProps<TLocale extends string = string> extends RallyViewerSlots<TLocale> {
34
70
  readonly config: RallyConfig<TLocale>;
35
71
  readonly state?: StampRallyState | null;
36
72
  readonly title?: string;
37
73
  readonly progress?: StampRallyProgress;
38
74
  readonly locale?: TLocale;
39
75
  readonly dictionary?: LocaleDictionary<TLocale>;
76
+ readonly classNames?: ViewerClassNames;
77
+ readonly styles?: ViewerStyles;
78
+ readonly style?: ViewerStyle;
40
79
  }
41
- declare function StampSheet<TLocale extends string = string>({ config, state, title, progress, locale, dictionary, }: StampSheetProps<TLocale>): ReactElement;
80
+ declare function StampSheet<TLocale extends string = string>({ config, state, title, progress, locale, dictionary, classNames, styles, style, headerSlot, footerSlot, renderSpotCard, renderStatusBadge, }: StampSheetProps<TLocale>): ReactElement;
42
81
 
43
- export { type ConditionRenderer, type ConditionRendererProps, RallyViewer, type RallyViewerAdapter, type RallyViewerProps, StampSheet, type StampSheetProps, type ViewerClassName, type ViewerStyle };
82
+ export { type ConditionRenderer, type ConditionRendererProps, RallyViewer, type RallyViewerAdapter, type RallyViewerProps, type RallyViewerSlots, type RewardCardProps, type SpotCardProps, type SpotStatus, StampSheet, type StampSheetProps, type ViewerClassName, type ViewerClassNames, type ViewerStyle, type ViewerStyles };