@apolitical/component-library 6.6.0-SW.0 → 6.6.0-SW.1

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.
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import type { IDiscussionForm } from '../../../discussion/components/form';
3
- import { ICategory } from '../../shared';
3
+ import { type ICategory } from '../../shared';
4
4
  interface Props {
5
5
  /** Whether the form should be displayed as a card */
6
6
  isCard?: boolean;
@@ -23,6 +23,8 @@ interface Props {
23
23
  /** The text to show when the user is not a member of the community */
24
24
  notMemberStateText?: string;
25
25
  };
26
+ /** The locale of the page */
27
+ locale?: string;
26
28
  }
27
29
  declare const AddPost: React.FC<Props>;
28
30
  export default AddPost;
@@ -0,0 +1,24 @@
1
+ import type { IMutationContext } from '../../../../../../discussion/shared';
2
+ import type { ICache, ICacheItem } from '../..';
3
+ import { ResultsVisibility } from '../../../../../../polls';
4
+ interface ICreatePollVars {
5
+ title: {
6
+ [key: string]: string;
7
+ };
8
+ options: {
9
+ position: number;
10
+ description: {
11
+ [key: string]: string;
12
+ };
13
+ }[];
14
+ settings: {
15
+ show_remove_vote?: boolean;
16
+ allow_multiple_votes?: boolean;
17
+ deadline_at?: string;
18
+ hide_participants?: boolean;
19
+ number_of_winners?: number;
20
+ results_visibility?: ResultsVisibility;
21
+ };
22
+ }
23
+ export declare function useCreatePoll({ mutationFn, mutationHandlers: { mutate: mutateWrapper, error: onError }, queryClient, queryKey, user, }: IMutationContext<ICacheItem, Error, ICreatePollVars, ICache>): import("@tanstack/react-query/build/legacy/types").UseMutateFunction<import('../../../../../../discussion/shared').IActivity, Error, ICreatePollVars, ICache>;
24
+ export {};
@@ -0,0 +1 @@
1
+ export * from './create-poll.hook';
@@ -1,4 +1,5 @@
1
1
  export * from './create';
2
+ export * from './create-poll';
2
3
  export * from './create-vote';
3
4
  export * from './edit';
4
5
  export * from './feed';
@@ -20,9 +20,12 @@ export interface IActivitySectionProps {
20
20
  form: IDiscussionFormFns;
21
21
  join: () => Promise<void>;
22
22
  leave: () => Promise<void>;
23
+ polls: IQueryFns;
23
24
  };
24
25
  profile: IProfileFormProps;
25
26
  categories?: ICategory[];
27
+ /** The locale of the page */
28
+ locale?: string;
26
29
  }
27
30
  declare const ActivitySection: React.FC<IActivitySectionProps>;
28
31
  export default ActivitySection;
@@ -1,2 +1,2 @@
1
- import type { ReactionsRecords, DefaultGenerics } from 'getstream';
2
- export declare function checkIfUserHasVoted(activityType: string, latestReactions: ReactionsRecords<DefaultGenerics> | undefined): boolean;
1
+ import { IActivity } from '../../shared';
2
+ export declare function hasUserVoted(activity: IActivity): boolean;
@@ -0,0 +1,7 @@
1
+ import type { IMutationContext } from '../../../../../../discussion/shared';
2
+ import type { ICache, ICacheSubitem } from '../..';
3
+ interface ICreateVoteVars {
4
+ reactionId: string;
5
+ }
6
+ export declare function useCreateVote({ mutationFn, mutationHandlers: { mutate: mutateWrapper, error: onError }, queryClient, queryKey, user, }: IMutationContext<ICacheSubitem, Error, ICreateVoteVars, ICache>): import("@tanstack/react-query/build/legacy/types").UseMutateFunction<import('../../../../../../discussion/shared').IReaction, Error, ICreateVoteVars, import('../../../../../../discussion/shared').IActivity>;
7
+ export {};
@@ -0,0 +1 @@
1
+ export * from './create-vote.hook';
@@ -1,7 +1,9 @@
1
+ export * from './create-vote';
1
2
  export * from './edit';
3
+ export * from './like';
4
+ export * from './pin';
2
5
  export * from './read';
6
+ export * from './remove-vote';
3
7
  export * from './section';
4
- export * from './like';
5
8
  export * from './unlike';
6
- export * from './pin';
7
9
  export * from './unpin';
@@ -0,0 +1 @@
1
+ export * from './remove-vote.hook';
@@ -0,0 +1,7 @@
1
+ import type { IMutationContext } from '../../../../../../discussion/shared';
2
+ import type { ICache } from '../..';
3
+ interface IRemoveVoteVars {
4
+ reactionId: string;
5
+ }
6
+ export declare function useRemoveVote({ mutationFn, mutationHandlers: { mutate: mutateWrapper, error: onError }, user, }: IMutationContext<unknown, Error, IRemoveVoteVars, ICache>): import("@tanstack/react-query/build/legacy/types").UseMutateFunction<unknown, Error, IRemoveVoteVars, import('../../../../../../discussion/shared').IActivity>;
7
+ export {};
@@ -28,6 +28,11 @@ export declare const mockFunctions: {
28
28
  listMembers: jest.Mock<any, any, any>;
29
29
  clickMentionFallback: jest.Mock<any, any, any>;
30
30
  };
31
+ polls: {
32
+ createVote: jest.Mock<any, any, any>;
33
+ removeVote: jest.Mock<any, any, any>;
34
+ removePoll: jest.Mock<any, any, any>;
35
+ };
31
36
  join: jest.Mock<any, any, any>;
32
37
  leave: jest.Mock<any, any, any>;
33
38
  };
@@ -1,14 +1,47 @@
1
1
  import type { IUserContext } from '../../../context';
2
2
  import type { IActivity, IReaction } from '..';
3
+ import { ActivityType } from '../../../discussion/shared';
4
+ import { ResultsVisibility } from '../../../polls';
3
5
  interface IPrepareActivityArgs {
4
6
  title?: string;
5
7
  content?: string;
6
8
  categories?: string;
7
9
  }
10
+ interface IPreparePollActivityArgs {
11
+ title?: {
12
+ [key: string]: string;
13
+ };
14
+ options: {
15
+ position: number;
16
+ description: {
17
+ [key: string]: string;
18
+ };
19
+ }[];
20
+ settings: {
21
+ show_remove_vote?: boolean;
22
+ allow_multiple_votes?: boolean;
23
+ deadline_at?: string;
24
+ hide_participants?: boolean;
25
+ number_of_winners?: number;
26
+ results_visibility?: ResultsVisibility;
27
+ };
28
+ user: IUserContext;
29
+ correctActivityId?: string;
30
+ }
8
31
  interface IEnrichActivityArgs {
9
32
  activity: IActivity | Partial<IActivity>;
10
33
  user: IUserContext;
11
34
  }
35
+ interface IEnrichPollActivityArgs {
36
+ activity: IActivity | Partial<IActivity>;
37
+ options: {
38
+ position: number;
39
+ description: {
40
+ [key: string]: string;
41
+ };
42
+ }[];
43
+ user: IUserContext;
44
+ }
12
45
  interface IIncrementActivityLikesArgs {
13
46
  activity: IActivity;
14
47
  reaction?: IReaction;
@@ -24,9 +57,19 @@ export declare function prepareActivity({ title, content, categories }: IPrepare
24
57
  categories: string[];
25
58
  id: string;
26
59
  time: string;
27
- verb: string;
60
+ verb: ActivityType;
61
+ };
62
+ export declare function preparePollActivity({ title, options, settings, user, correctActivityId, }: IPreparePollActivityArgs): {
63
+ title: {
64
+ [key: string]: string;
65
+ } | undefined;
66
+ content: string;
67
+ id: string;
68
+ time: string;
69
+ verb: ActivityType;
28
70
  };
29
71
  export declare function enrichActivity({ activity, user }: IEnrichActivityArgs): IActivity;
72
+ export declare function enrichPollActivity({ activity, options, user }: IEnrichPollActivityArgs): IActivity;
30
73
  export declare function incrementActivityLikes({ activity, reaction, }: IIncrementActivityLikesArgs): void;
31
74
  export declare function decrementActivityLikes({ activity, user }: IDecrementActivityLikesArgs): void;
32
75
  export declare function incrementActivityPins({ activity, reaction, }: IIncrementActivityLikesArgs): void;
@@ -18,7 +18,13 @@ export declare function buildEmptyCacheWithItem<ICacheItem>(item: ICacheItem): {
18
18
  }[];
19
19
  pageParams: string[];
20
20
  };
21
- export declare function addItem<ICacheItem extends ICacheItemBase>(item: ICacheItem, cache?: ICache<ICacheItem>, opts?: IAdditionOptions): ICache<ICacheItem>;
21
+ export declare function addItem<ICacheItem extends ICacheItemBase>(item: ICacheItem, cache?: ICache<ICacheItem>, opts?: IAdditionOptions): {
22
+ pages: {
23
+ next: string;
24
+ results: ICacheItem[];
25
+ }[];
26
+ pageParams: string[];
27
+ };
22
28
  export declare function findItem<ICacheItem extends ICacheItemBase>(itemId: string, cache?: ICache<ICacheItem>): ICacheItem | undefined;
23
29
  export declare function removeItem<ICacheItem extends ICacheItemBase>(itemId: string, cache: ICache<ICacheItem>): ICache<ICacheItem>;
24
30
  export declare function flattenCache<ICacheItem extends ICacheItemBase>(cache?: ICache<ICacheItem>): ICacheItem[];
@@ -1,23 +1,46 @@
1
1
  import type { IPollOption } from '../../../polls';
2
2
  import { type IActivity } from '../interfaces/activity.interface';
3
3
  import type { IUserContext } from '../../../context';
4
- import { ICache } from './cache.helper';
5
4
  import { ICacheItem } from '../../feeds/activities-feed/cache';
6
5
  interface IPreparePollVoteArgs {
7
6
  activity: IActivity;
8
7
  reactionId: string;
9
8
  user?: IUserContext;
10
9
  }
10
+ interface IPreparePollOptionArgs {
11
+ position: number;
12
+ description: {
13
+ [key: string]: string;
14
+ };
15
+ user?: IUserContext;
16
+ }
17
+ interface IEnrichPollArgs {
18
+ activity: IActivity;
19
+ activityId: string;
20
+ }
11
21
  interface IEnrichPollVoteArgs extends IPreparePollVoteArgs {
12
22
  correctReactionId: string;
13
23
  }
14
24
  interface IRemovePollVoteArgs {
15
- cache: ICache<ICacheItem>;
16
- activityId: string;
25
+ activity: IActivity;
17
26
  reactionId: string;
18
27
  }
19
28
  export declare const getActivityPollOptions: (pollOption: ICacheItem, locale?: string) => IPollOption[];
20
29
  export declare function preparePollVote({ activity, reactionId, user }: IPreparePollVoteArgs): void;
21
30
  export declare function enrichPollVote({ activity, reactionId, correctReactionId, user, }: IEnrichPollVoteArgs): void;
22
- export declare function removePollVote({ cache, activityId, reactionId }: IRemovePollVoteArgs): ICache<IActivity>;
31
+ export declare function removePollVote({ activity, reactionId }: IRemovePollVoteArgs): void;
32
+ export declare function enrichPoll({ activity, activityId }: IEnrichPollArgs): void;
33
+ export declare function preparePollOption({ position, description }: IPreparePollOptionArgs, user?: IUserContext): {
34
+ created_at: string;
35
+ updated_at: string;
36
+ id: string;
37
+ kind: string;
38
+ data: {
39
+ description: {
40
+ [key: string]: string;
41
+ };
42
+ position: number;
43
+ };
44
+ parent: string;
45
+ } | undefined;
23
46
  export {};
@@ -1,15 +1,19 @@
1
+ import { IUserContext } from '../../../context';
1
2
  export declare function buildEmptyReactionsForActivity(): {
2
3
  latest_reactions: {
3
4
  like: never[];
4
5
  reply: never[];
6
+ 'poll-option': never[];
5
7
  };
6
8
  reaction_counts: {
7
9
  like: number;
8
10
  reply: number;
11
+ 'poll-option': number;
9
12
  };
10
13
  own_reactions: {
11
14
  like: never[];
12
15
  reply: never[];
16
+ 'poll-option': never[];
13
17
  };
14
18
  };
15
19
  export declare function buildEmptyReactionsForReply(): {
@@ -26,3 +30,37 @@ export declare function buildEmptyReactionsForReply(): {
26
30
  reply: never[];
27
31
  };
28
32
  };
33
+ export declare function buildReactionsForPollActivity(options: {
34
+ position: number;
35
+ description: {
36
+ [key: string]: string;
37
+ };
38
+ }[], user: IUserContext): {
39
+ latest_reactions: {
40
+ like: never[];
41
+ reply: never[];
42
+ 'poll-option': ({
43
+ created_at: string;
44
+ updated_at: string;
45
+ id: string;
46
+ kind: string;
47
+ data: {
48
+ description: {
49
+ [key: string]: string;
50
+ };
51
+ position: number;
52
+ };
53
+ parent: string;
54
+ } | undefined)[];
55
+ };
56
+ reaction_counts: {
57
+ like: number;
58
+ reply: number;
59
+ 'poll-option': number;
60
+ };
61
+ own_reactions: {
62
+ like: never[];
63
+ reply: never[];
64
+ 'poll-option': never[];
65
+ };
66
+ };