@apolitical/component-library 5.3.7-SW.0 → 5.4.0-beta.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.
@@ -148,25 +148,3 @@ export interface IndividualCarouselProps extends BaseCarouselProps {
148
148
  /** The types for each card, from Contentful */
149
149
  cardTypes: CardContentType[];
150
150
  }
151
- export interface NarrowCardType {
152
- /** The image to use */
153
- banner?: ResponsiveImageType;
154
- /** The title of the narrow card */
155
- title?: string;
156
- /** The primary text */
157
- text?: string;
158
- /** The URL the card should point to */
159
- slug?: string | null;
160
- /** Is the content private */
161
- isPrivate?: boolean;
162
- }
163
- export interface NarrowCardProps {
164
- /** The element that will render around the content */
165
- element?: 'li' | 'div';
166
- /** The card data, from Contentful */
167
- card: NarrowCardType;
168
- /** Additional classes */
169
- className?: string;
170
- /** Context for the Google Tag Manager event */
171
- gtmContext?: string;
172
- }
package/cards/index.d.ts CHANGED
@@ -2,4 +2,3 @@ export * from './card';
2
2
  export * from './card-block';
3
3
  export * from './carousel';
4
4
  export * from './cards.types';
5
- export * from './narrow-card';
@@ -1,4 +1,3 @@
1
1
  export * from './card';
2
2
  export * from './carousel';
3
3
  export * from './mocks.helpers';
4
- export * from './narrow-card';
@@ -1,5 +1,5 @@
1
- import { type ListMembers, ClickMentionFallback } from '../../../form';
2
- import { DiscussionCreateContentFunction, IDiscussionContent, IListMemberData, IMentions } from './../../discussion';
1
+ import type { IEnrichedUrlData } from '../../../navigation';
2
+ import { DiscussionCreateContentFunction, IDiscussionContent, IListMemberData, IMentions, IDiscussionFormFns } from './../../discussion';
3
3
  import { ICategory } from '../../shared';
4
4
  export interface IDiscussionFormMeta {
5
5
  /** Whether the form data is still loading */
@@ -36,6 +36,24 @@ export interface IDiscussionFormMeta {
36
36
  /** Whether the success message should show on a successful submit */
37
37
  showSuccessMessage?: boolean;
38
38
  }
39
+ interface IDiscussionFormFunctions extends IDiscussionFormFns {
40
+ onChange?: (args: {
41
+ [key: string]: string | boolean;
42
+ }) => void;
43
+ create: DiscussionCreateContentFunction;
44
+ handleSaveEdit?: (({ title, body }: {
45
+ title: string;
46
+ body: string;
47
+ }) => Promise<void>) | (() => void);
48
+ handleCancel?: () => void;
49
+ callback?: (args: void) => void;
50
+ onMention?: (value?: IListMemberData) => void;
51
+ props?: {
52
+ create: {
53
+ projectNames: ['questions-answers'];
54
+ };
55
+ };
56
+ }
39
57
  export interface IDiscussionForm {
40
58
  /** A unique ID for the form */
41
59
  id?: string;
@@ -68,33 +86,25 @@ export interface IDiscussionForm {
68
86
  error?: false | string;
69
87
  };
70
88
  /** The functions that are passed in to handle the functionality */
71
- functions: {
72
- onChange?: (args: {
73
- [key: string]: string | boolean;
74
- }) => void;
75
- create: DiscussionCreateContentFunction;
76
- handleSaveEdit?: (({ title, body }: {
77
- title: string;
78
- body: string;
79
- }) => Promise<void>) | (() => void);
80
- handleCancel?: () => void;
81
- callback?: (args: void) => void;
82
- onMention?: (value?: IListMemberData) => void;
83
- listMembers?: ListMembers;
84
- clickMentionFallback?: ClickMentionFallback;
85
- props?: {
86
- create: {
87
- projectNames: ['questions-answers'];
88
- };
89
- };
90
- };
89
+ functions: IDiscussionFormFunctions;
91
90
  /** Data to be passed into the rich text editor */
92
91
  data?: {
93
92
  /** Mentions data */
94
93
  mentions?: IMentions;
94
+ /** Optional data about the first link inside the post */
95
+ link?: false | IEnrichedUrlData;
95
96
  };
96
97
  /** The context for GTM */
97
98
  gtmContext?: string;
98
99
  /** The language to use for the text */
99
100
  locale?: string;
100
101
  }
102
+ export interface IDiscussionFormState {
103
+ title: string;
104
+ body: string;
105
+ categories: string[] | string;
106
+ data: {
107
+ link?: false | IEnrichedUrlData;
108
+ };
109
+ }
110
+ export {};
@@ -1,6 +1,5 @@
1
1
  import React from 'react';
2
- import { ClickMentionFallback, type ListMembers } from '../../../form';
3
- import { DiscussionCreateContentFunction, DiscussionCreateLikeFunction, DiscussionDeleteLikeFunction, DiscussionListLikesFunction } from '../../discussion';
2
+ import { DiscussionCreateContentFunction, DiscussionCreateLikeFunction, DiscussionDeleteLikeFunction, DiscussionListLikesFunction, IDiscussionFormFns } from '../../discussion';
4
3
  import type { IForceHide, IFullDiscussionContent } from '../../shared/interfaces';
5
4
  import { IBadgesOption } from '../../../user/badges';
6
5
  export interface IPostContent extends IFullDiscussionContent {
@@ -46,12 +45,7 @@ export interface IDiscussionPostProps {
46
45
  /** Open comments on a post */
47
46
  openComments?: () => void;
48
47
  };
49
- mentions: {
50
- /** Get data to hydrate mentions */
51
- listMembers: ListMembers;
52
- /** Function to call when clicking mention fallback */
53
- clickMentionFallback: ClickMentionFallback;
54
- };
48
+ form: IDiscussionFormFns;
55
49
  pins?: {
56
50
  /** Pin the post */
57
51
  createPin?: () => void;
@@ -77,7 +77,7 @@ declare namespace _default {
77
77
  namespace comments {
78
78
  function openComments(): void;
79
79
  }
80
- namespace mentions {
80
+ namespace form {
81
81
  function listMembers(): Promise<never[]>;
82
82
  function clickMentionFallback(): void;
83
83
  }
@@ -1,8 +1,8 @@
1
1
  /// <reference types="react" />
2
2
  import { type IProfileFormProps } from '../../../form';
3
- import type { IMentionsFns } from '../../../discussion/discussion.d';
4
- import type { IQueryFns } from './cache';
5
3
  import type { ILikesFeedQueryFns } from '../../../discussion/feeds/likes-feed';
4
+ import type { IDiscussionFormFns } from '../../../discussion/discussion.d';
5
+ import { type IQueryFns } from './cache';
6
6
  interface Props {
7
7
  /** The base path, used for slugs */
8
8
  basePath: string;
@@ -21,8 +21,8 @@ interface Props {
21
21
  functions: {
22
22
  /** Query functions for the activities */
23
23
  activities: IQueryFns;
24
- /** Query functions for the mentions */
25
- mentions: IMentionsFns;
24
+ /** Query functions for the form, including mentions */
25
+ form: IDiscussionFormFns;
26
26
  /** Function to join the community */
27
27
  join: () => Promise<void>;
28
28
  /** Function to leave the community */
@@ -1,11 +1,11 @@
1
1
  /// <reference types="react" />
2
- import type { IMentionsFns } from '../../../../discussion/discussion.d';
3
- import type { IQueryFns } from './../cache';
2
+ import type { IDiscussionFormFns } from '../../../../discussion/discussion.d';
4
3
  import { ILikesFeedQueryFns } from '../../../../discussion/feeds/likes-feed';
4
+ import { type IQueryFns } from './../cache';
5
5
  interface NestedRepliesFunctions {
6
6
  /** Functions for the replies query */
7
7
  reactions: IQueryFns;
8
- mentions: IMentionsFns;
8
+ form: IDiscussionFormFns;
9
9
  /** Functions for the likes query */
10
10
  likes: ILikesFeedQueryFns;
11
11
  }
@@ -1,15 +1,15 @@
1
1
  /// <reference types="react" />
2
2
  import { type IProfileFormProps } from '../../../form';
3
- import type { IMentionsFns } from './../../discussion';
4
- import { type IQueryFns } from './cache';
5
3
  import { ILikesFeedQueryFns } from '../../../discussion/feeds/likes-feed';
4
+ import type { IDiscussionFormFns } from './../../discussion';
5
+ import { type IQueryFns } from './cache';
6
6
  interface RepliesFunctions {
7
7
  /** Functions for the replies query */
8
8
  reactions: IQueryFns;
9
9
  /** Functions for the likes query */
10
10
  likes: ILikesFeedQueryFns;
11
11
  /** Query functions for the mentions */
12
- mentions: IMentionsFns;
12
+ form: IDiscussionFormFns;
13
13
  /** Function to join the community */
14
14
  join: () => Promise<void>;
15
15
  /** Function to leave the community */
@@ -3,3 +3,4 @@ export * from './feeds';
3
3
  export * from './discussion.helpers';
4
4
  export * from './sections';
5
5
  export type { IActivity, IFullDiscussionContent, IListMemberData, IMentionData, IMentions, IReaction, IUser, } from './shared/interfaces';
6
+ export type { IDiscussionFormFns } from './discussion.d';
@@ -1,9 +1,8 @@
1
1
  /// <reference types="react" />
2
2
  import { type IProfileFormProps } from '../../../form';
3
- import { type IRepliesFeedQueryFns } from '../../../discussion/feeds';
4
- import type { IMentionsFns } from './../../discussion.d';
3
+ import { type IRepliesFeedQueryFns, type ILikesFeedQueryFns } from '../../../discussion/feeds';
4
+ import type { IDiscussionFormFns } from './../../discussion.d';
5
5
  import { type IQueryFns } from './cache';
6
- import type { ILikesFeedQueryFns } from '../../../discussion/feeds/likes-feed';
7
6
  interface IActivitySectionQueryFns extends IQueryFns {
8
7
  remove: () => Promise<void>;
9
8
  }
@@ -17,7 +16,7 @@ export interface IActivitySectionProps {
17
16
  activities: IActivitySectionQueryFns;
18
17
  reactions: IRepliesFeedQueryFns;
19
18
  likes: ILikesFeedQueryFns;
20
- mentions: IMentionsFns;
19
+ form: IDiscussionFormFns;
21
20
  join: () => Promise<void>;
22
21
  leave: () => Promise<void>;
23
22
  };
@@ -1,5 +1,6 @@
1
1
  import { MemberProps, MemberDetailsProps } from '../../../user';
2
2
  import type { ListMembers, ClickMentionFallback } from '../../../form';
3
+ import type { IEnrichedUrlData } from '../../../navigation';
3
4
  export type IDiscussionContentType = 'answer' | 'post' | 'response' | 'reply' | 'question';
4
5
  export interface IDiscussionContent {
5
6
  /** The type of content */
@@ -38,8 +39,13 @@ export interface IFullDiscussionContent extends IDiscussionContent {
38
39
  canLike?: boolean;
39
40
  /** The number of comments the post has */
40
41
  comments?: number;
41
- /** Details of users mentioned in the content */
42
- mentions?: IMentions;
42
+ /** Extra data, to show in the content */
43
+ data?: {
44
+ /** Details of users mentioned in the content */
45
+ mentions?: IMentions;
46
+ /** Link metadata, to show an enriched url for the first link in the post */
47
+ link?: false | IEnrichedUrlData;
48
+ };
43
49
  /** If the content has been edited */
44
50
  isEdited?: boolean;
45
51
  /** The URL to use for reporting context, etc. */
@@ -1,7 +1,15 @@
1
1
  import { BaseElement, BaseText, Descendant, Point, Range } from 'slate';
2
- import type { IListMemberData, IMentions } from '../../../discussion';
2
+ import type { IListMemberData, IMentions, IDiscussionFormFns } from '../../../discussion';
3
3
  import type { MemberDetailsProps } from '../../../user';
4
4
  import type { IEnrichedUrlData } from '../../../navigation';
5
+ interface IRTEFunctions extends IDiscussionFormFns {
6
+ /** An optional event handler, called when the rich text editor is changed */
7
+ onChange?: (value: string, data?: false | IEnrichedUrlData) => void;
8
+ /** An optional function to call when a mention is inserted */
9
+ onMention?: (value?: IListMemberData) => void;
10
+ /** An optional event handler, called when the rich text editor reports an error */
11
+ reportError?: ReportError;
12
+ }
5
13
  export interface IRTEProps {
6
14
  /** The id of the rich text editor */
7
15
  id?: string;
@@ -17,20 +25,7 @@ export interface IRTEProps {
17
25
  isInOverlay?: false | 'string';
18
26
  };
19
27
  /** Optional functions */
20
- functions?: {
21
- /** An optional function to get a filtered list of members when the user starts typing a mention */
22
- listMembers?: ListMembers;
23
- /** An optional function to call when the user clicks the mention fallback, e.g. to show an invite modal */
24
- clickMentionFallback?: ClickMentionFallback;
25
- /** An optional function to get a preview of a link */
26
- getLinkPreview?: (url: string) => Promise<IEnrichedUrlData>;
27
- /** An optional event handler, called when the rich text editor is changed */
28
- onChange?: (value: string) => void;
29
- /** An optional function to call when a mention is inserted */
30
- onMention?: (value?: IListMemberData) => void;
31
- /** An optional event handler, called when the rich text editor reports an error */
32
- reportError?: ReportError;
33
- };
28
+ functions?: IRTEFunctions;
34
29
  /** Optional autoFocus */
35
30
  autoFocus?: boolean;
36
31
  /** Optional aria invalid */
@@ -135,3 +130,4 @@ export interface IMentionPopOver {
135
130
  position: Range | null;
136
131
  numberOfUsers: number | null;
137
132
  }
133
+ export {};