@apolitical/component-library 6.4.1 → 6.5.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.
@@ -0,0 +1,2 @@
1
+ export declare const MAX_POLL_OPTIONS = 5;
2
+ export declare const MIN_POLL_OPTIONS = 2;
@@ -1,3 +1,3 @@
1
1
  import { IDiscussionForm } from './form.type';
2
- declare const DiscussionForm: ({ id, parentId, content, userHasPermissions, meta, placeholder, maxLength, buttons, forceShow, isCommunity, functions, data, gtmContext, }: IDiscussionForm) => import("react/jsx-runtime").JSX.Element;
2
+ declare const DiscussionForm: ({ id, parentId, content, userHasPermissions, meta, placeholder, maxLength, buttons, forceShow, functions, data, gtmContext, }: IDiscussionForm) => import("react/jsx-runtime").JSX.Element;
3
3
  export default DiscussionForm;
@@ -0,0 +1,4 @@
1
+ import type { IFormValues } from '../../../form';
2
+ import type { IRTEValues } from './form.type';
3
+ import { ITransformedPollData } from './../../shared';
4
+ export declare const transformPollData: (data: IRTEValues & IFormValues) => ITransformedPollData;
@@ -1,6 +1,9 @@
1
1
  import type { IEnrichedUrlData } from '../../../navigation';
2
- import { IDiscussionContent, IMentions } from './../../discussion';
3
- import { ICategory, IDiscussionFormFunctions } from '../../shared';
2
+ import type { ICategory, IDiscussionFormFunctions, IDiscussionContent, IMentions } from '../../shared';
3
+ interface IPollData {
4
+ options: string[];
5
+ multipleAnswers: boolean;
6
+ }
4
7
  export interface IDiscussionFormMeta {
5
8
  /** Whether the form data is still loading */
6
9
  isLoading?: boolean;
@@ -14,11 +17,14 @@ export interface IDiscussionFormMeta {
14
17
  isEditing: false | {
15
18
  categories?: string[] | string;
16
19
  text?: string;
20
+ poll?: IPollData;
17
21
  };
18
22
  /** Whether the form has a title field */
19
23
  hasTitleField?: false | {
20
24
  text?: string;
21
25
  };
26
+ /** If the form can be pre-populated; this is not allowed outside communities at the moment */
27
+ canBePrepopulated?: boolean;
22
28
  /** Whether the form is prepopulated with text (different to isEditing, as we want different buttons and text to show */
23
29
  isPrepopulated: false | {
24
30
  text?: string;
@@ -58,8 +64,6 @@ export interface IDiscussionForm {
58
64
  /** Text for the submit button */
59
65
  submit?: string;
60
66
  };
61
- /** If the form is used within a Community */
62
- isCommunity?: boolean;
63
67
  /** Force elements on the form to show, regardless of the form state */
64
68
  forceShow?: {
65
69
  /** If the cancel button should always show */
@@ -81,11 +85,15 @@ export interface IDiscussionForm {
81
85
  /** The language to use for the text */
82
86
  locale?: string;
83
87
  }
84
- export interface IDiscussionFormState {
85
- title: string;
86
- body: string;
87
- categories: string[] | string;
88
- data: {
88
+ export interface IRTEValues {
89
+ body?: string;
90
+ data?: {
89
91
  link?: false | IEnrichedUrlData;
90
92
  };
91
93
  }
94
+ export interface IDiscussionFormState {
95
+ status: false | 'submitting' | 'submitted';
96
+ title: string;
97
+ polls: number;
98
+ }
99
+ export {};
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { IMemberComponentProps } from '../../../user';
3
3
  import { DiscussionCreateContentFunction, DiscussionCreateLikeFunction, DiscussionDeleteLikeFunction, DiscussionListLikesFunction, IDiscussionFormFns } from '../../discussion';
4
- import type { IForceHide, IFullDiscussionContent } from '../../shared/interfaces';
4
+ import { type IForceHide, type IFullDiscussionContent } from '../../shared/interfaces';
5
5
  import { IBadgesOption } from '../../../user/badges';
6
6
  export interface IPostContent extends IFullDiscussionContent {
7
7
  /** The post body */
@@ -216,3 +216,7 @@ export namespace question {
216
216
  let createdAt_5: string;
217
217
  export { createdAt_5 as createdAt };
218
218
  }
219
+ export const postCategories: {
220
+ name: string;
221
+ slug: string;
222
+ }[];
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { type IProfileFormProps } from '../../../form';
3
- import { type IRepliesFeedQueryFns, type ILikesFeedQueryFns } from '../../../discussion/feeds';
3
+ import { type ILikesFeedQueryFns, type IRepliesFeedQueryFns } from '../../../discussion/feeds';
4
4
  import type { IDiscussionFormFns } from './../../discussion.d';
5
5
  import { type IQueryFns } from './cache';
6
6
  import { ICategory } from '../../shared';
@@ -3,10 +3,18 @@ import type { ListMembers, ClickMentionFallback } from '../../../form';
3
3
  import type { IEnrichedUrlData } from '../../../navigation';
4
4
  import type { ICategory } from './community.category.interface';
5
5
  import type { IDiscussionFormFns } from '../../discussion';
6
- export type IDiscussionContentType = 'answer' | 'post' | 'response' | 'reply' | 'question';
6
+ export declare enum DiscussionContentType {
7
+ Answer = "answer",
8
+ Poll = "poll",
9
+ Post = "post",
10
+ Response = "response",
11
+ Reply = "reply",
12
+ Question = "question"
13
+ }
14
+ export type IDiscussionContentType = DiscussionContentType.Answer | DiscussionContentType.Poll | DiscussionContentType.Post | DiscussionContentType.Response | DiscussionContentType.Reply | DiscussionContentType.Question;
7
15
  export interface IDiscussionContent {
8
16
  /** The type of content */
9
- type: IDiscussionContentType;
17
+ type: IDiscussionContentType | undefined;
10
18
  /** The slugs we're dealing with - used in functions */
11
19
  slugs: {
12
20
  question?: string;
@@ -92,15 +100,21 @@ export interface IConversation {
92
100
  prepopulateForm?: string;
93
101
  mentionData?: IListMemberData;
94
102
  }
103
+ export interface ITransformedPollData {
104
+ [key: string]: string | number | {
105
+ [key: string]: string | number;
106
+ } | {
107
+ [key: string]: string | number;
108
+ }[];
109
+ }
95
110
  export interface IDiscussionFormFunctions extends IDiscussionFormFns {
96
111
  onChange?: (args: {
97
- [key: string]: string | boolean;
112
+ [key: string]: string | string[] | boolean;
98
113
  }) => void;
99
114
  create: DiscussionCreateContentFunction;
100
- handleSaveEdit?: (({ title, body }: {
101
- title: string;
102
- body: string;
103
- }) => Promise<void>) | (() => void);
115
+ createPoll?: (args: ITransformedPollData) => void;
116
+ handleSaveEdit?: // eslint-disable-next-line @typescript-eslint/no-explicit-any
117
+ ((args: any) => Promise<void>) | (() => void);
104
118
  handleCancel?: () => void;
105
119
  callback?: (args: void) => void;
106
120
  onMention?: (value?: IListMemberData) => void;
@@ -268,5 +268,7 @@ export interface IFieldWrapper extends IField {
268
268
  setFields: React.Dispatch<React.SetStateAction<IField[]>>;
269
269
  dispatch: React.Dispatch<IFormReducerAction>;
270
270
  };
271
+ /** Optional siblings to render alongside component */
272
+ siblings?: React.ReactNode;
271
273
  }
272
274
  export {};
package/helpers/intl.d.ts CHANGED
@@ -137,6 +137,12 @@ export declare const checkIntlPathExists: (path: string, language?: {
137
137
  discussion_form_titleField_label: string;
138
138
  discussion_form_titleField_placeholder: string;
139
139
  discussion_form_titleField_error: string;
140
+ discussion_form_question_label: string;
141
+ discussion_form_question_placeholder: string;
142
+ discussion_form_option_label: string;
143
+ discussion_form_option_placeholder: string;
144
+ discussion_form_option_cta: string;
145
+ discussion_form_multiplePollAnswers: string;
140
146
  discussion_form_placeholder: string;
141
147
  discussion_form_label: string;
142
148
  discussion_form_label_action: string;
@@ -236,6 +242,7 @@ export declare const checkIntlPathExists: (path: string, language?: {
236
242
  form_multipleInputs_label: string;
237
243
  form_multipleInputs_filledInCount: string;
238
244
  form_multipleInputs_filledInCount_aria: string;
245
+ form_multipleInputs_remove: string;
239
246
  inviteForm_email_placeholder: string;
240
247
  inviteForm_title: string;
241
248
  inviteForm_label: string;
@@ -279,7 +286,6 @@ export declare const checkIntlPathExists: (path: string, language?: {
279
286
  profileImageChange_error: string;
280
287
  publishArticleForm_title_label: string;
281
288
  publishArticleForm_title_placeholder: string;
282
- publishArticleForm_title_error: string;
283
289
  publishArticleForm_subtitle_label: string;
284
290
  publishArticleForm_subtitle_placeholder: string;
285
291
  publishArticleForm_body_label: string;