@apolitical/component-library 4.5.0-beta.8 → 4.5.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.
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { type IDiscussionForm } from '../../../discussion/components/form';
2
+ import type { IDiscussionForm } from '../../../discussion/components/form';
3
3
  interface Props {
4
4
  /** Whether the form should be displayed as a card */
5
5
  isCard?: boolean;
@@ -9,5 +9,5 @@ interface Props {
9
9
  /** The Google Tag Manager context */
10
10
  gtmContext: string;
11
11
  }
12
- declare const Guidelines: ({ intlPath, showGuidelines, type, gtmContext }: Props) => import("react/jsx-runtime").JSX.Element | null;
12
+ declare const Guidelines: ({ intlPath, showGuidelines, type, gtmContext }: Props) => import("react/jsx-runtime").JSX.Element;
13
13
  export default Guidelines;
@@ -1,108 +1,3 @@
1
- import {
2
- type ListMembers,
3
- } from '@/components/form';
4
-
5
- import {
6
- DiscussionCreateContentFunction,
7
- IDiscussionContent,
8
- IMentions,
9
- } from './../../discussion';
10
-
11
- export interface IDiscussionFormMeta {
12
- /** Whether the form data is still loading */
13
- isLoading?: boolean;
14
-
15
- /** Whether the form is in a wrapper or not - used for styling */
16
- isInWrapper?: boolean;
17
-
18
- /** Whether the form is in a modal or not - used to handle portals */
19
- isInOverlay?: false | string;
20
-
21
- /** Whether the form should be autofocused. (It will always be autofocused when `isEditing`. */
22
- isAutoFocused?: boolean;
23
-
24
- /** Whether we're editing or creating */
25
- isEditing: false | { text?: string };
26
-
27
- /** Whether the form has a title field */
28
- hasTitleField?: false | { text?: string };
29
-
30
- /** Whether the form is prepopulated with text (different to isEditing, as we want different buttons and text to show */
31
- isPrepopulated: false | { text?: string };
32
-
33
- /** Whether title text should show above the form */
34
- showTitle?: boolean;
35
-
36
- /** Whether the community guidelines text should show beneath the form */
37
- showGuidelines?: boolean;
38
-
39
- /** Whether to show a divider before the buttons */
40
- showDivider?: boolean;
41
-
42
- /** Whether the success message should show on a successful submit */
43
- showSuccessMessage?: boolean;
44
- }
45
-
46
- export interface IDiscussionForm {
47
- /** A unique ID for the form */
48
- id?: string;
49
-
50
- /** Information about the content being created/edited */
51
- content: IDiscussionContent;
52
-
53
- /** If the user has permission to interact with the form, e.g. if they're a member of the community */
54
- userHasPermissions?: boolean;
55
-
56
- /** Information about the form */
57
- meta?: IDiscussionFormMeta;
58
-
59
- /** The placeholder text - this defaults to the intl text */
60
- placeholder?: string;
61
-
62
- /** The maximum number of characters */
63
- maxLength?: number;
64
-
65
- /** The buttons at the bottom of the form */
66
- buttons?: {
67
- /** Text for the cancel button */
68
- cancel?: string;
69
- /** Text for the submit button */
70
- submit?: string;
71
- };
72
-
73
- /** If the form is used within a Community */
74
- isCommunity?: boolean;
75
-
76
- /** Force elements on the form to show, regardless of the form state */
77
- forceShow?: {
78
- /** If the cancel button should always show */
79
- cancel?: boolean;
80
- /** If an error, created externally, should always show */
81
- error?: false | string;
82
- };
83
-
84
- /** The functions that are passed in to handle the functionality */
85
- functions: {
86
- create: DiscussionCreateContentFunction;
87
- handleSaveEdit?: (({ title: string, body: string }) => Promise<void>) | (() => void);
88
- handleCancel?: () => void;
89
- callback?: (args: void) => void;
90
- listMembers?: ListMembers;
91
-
92
- props?: {
93
- create: { projectNames: ['questions-answers'] };
94
- };
95
- };
96
-
97
- /** Data to be passed into the rich text editor */
98
- data?: {
99
- /** Mentions data */
100
- mentions?: IMentions;
101
- };
102
-
103
- /** The context for GTM */
104
- gtmContext?: string;
105
-
106
- /** The language to use for the text */
107
- locale?: string;
108
- }
1
+ import { IDiscussionForm } from './form.type';
2
+ declare const DiscussionForm: ({ id, content, userHasPermissions, meta, placeholder, maxLength, buttons, forceShow, isCommunity, functions, data, gtmContext, }: IDiscussionForm) => import("react/jsx-runtime").JSX.Element;
3
+ export default DiscussionForm;
@@ -0,0 +1,87 @@
1
+ import { type ListMembers } from '../../../form';
2
+ import { DiscussionCreateContentFunction, IDiscussionContent, IMentions } from './../../discussion';
3
+ export interface IDiscussionFormMeta {
4
+ /** Whether the form data is still loading */
5
+ isLoading?: boolean;
6
+ /** Whether the form is in a wrapper or not - used for styling */
7
+ isInWrapper?: boolean;
8
+ /** Whether the form is in a modal or not - used to handle portals */
9
+ isInOverlay?: false | string;
10
+ /** Whether the form should be autofocused. (It will always be autofocused when `isEditing`. */
11
+ isAutoFocused?: boolean;
12
+ /** Whether we're editing or creating */
13
+ isEditing: false | {
14
+ text?: string;
15
+ };
16
+ /** Whether the form has a title field */
17
+ hasTitleField?: false | {
18
+ text?: string;
19
+ };
20
+ /** Whether the form is prepopulated with text (different to isEditing, as we want different buttons and text to show */
21
+ isPrepopulated: false | {
22
+ text?: string;
23
+ };
24
+ /** Whether title text should show above the form */
25
+ showTitle?: boolean;
26
+ /** Whether the community guidelines text should show beneath the form */
27
+ showGuidelines?: boolean;
28
+ /** Whether to show a divider before the buttons */
29
+ showDivider?: boolean;
30
+ /** Whether the success message should show on a successful submit */
31
+ showSuccessMessage?: boolean;
32
+ }
33
+ export interface IDiscussionForm {
34
+ /** A unique ID for the form */
35
+ id?: string;
36
+ /** Information about the content being created/edited */
37
+ content: IDiscussionContent;
38
+ /** If the user has permission to interact with the form, e.g. if they're a member of the community */
39
+ userHasPermissions?: boolean;
40
+ /** Information about the form */
41
+ meta?: IDiscussionFormMeta;
42
+ /** The placeholder text - this defaults to the intl text */
43
+ placeholder?: string;
44
+ /** The maximum number of characters */
45
+ maxLength?: number;
46
+ /** The buttons at the bottom of the form */
47
+ buttons?: {
48
+ /** Text for the cancel button */
49
+ cancel?: string;
50
+ /** Text for the submit button */
51
+ submit?: string;
52
+ };
53
+ /** If the form is used within a Community */
54
+ isCommunity?: boolean;
55
+ /** Force elements on the form to show, regardless of the form state */
56
+ forceShow?: {
57
+ /** If the cancel button should always show */
58
+ cancel?: boolean;
59
+ /** If an error, created externally, should always show */
60
+ error?: false | string;
61
+ };
62
+ /** The functions that are passed in to handle the functionality */
63
+ functions: {
64
+ create: DiscussionCreateContentFunction;
65
+ handleSaveEdit?: (({ title, body }: {
66
+ title: string;
67
+ body: string;
68
+ }) => Promise<void>) | (() => void);
69
+ handleCancel?: () => void;
70
+ callback?: (args: void) => void;
71
+ listMembers?: ListMembers;
72
+ props?: {
73
+ create: {
74
+ projectNames: ['questions-answers'];
75
+ };
76
+ };
77
+ };
78
+ /** Data to be passed into the rich text editor */
79
+ data?: {
80
+ /** Mentions data */
81
+ mentions?: IMentions;
82
+ };
83
+ /** The context for GTM */
84
+ gtmContext?: string;
85
+ /** The language to use for the text */
86
+ locale?: string;
87
+ }
@@ -1,2 +1,2 @@
1
- export type { IDiscussionForm, IDiscussionFormMeta } from './form.d';
1
+ export type { IDiscussionForm, IDiscussionFormMeta } from './form.type';
2
2
  export { default as DiscussionForm } from './form';
@@ -2,7 +2,7 @@ import type { IMutationContext } from '../../../../../../discussion/shared';
2
2
  import type { ICache, ICacheItem } from '../..';
3
3
  interface ICreateVars {
4
4
  title?: string;
5
- content: string;
5
+ content?: string;
6
6
  }
7
7
  export declare function useCreateActivity({ mutationFn, mutationHandlers: { mutate: mutateWrapper, error: onError }, queryClient, queryKey, user, }: IMutationContext<ICacheItem, Error, ICreateVars, ICache>): import("@tanstack/react-query/build/legacy/types").UseMutateFunction<import('../../../../../../discussion/shared').IActivity, Error, ICreateVars, ICache>;
8
8
  export {};
@@ -2,7 +2,7 @@ import type { IMutationContext } from '../../../../../../discussion/shared';
2
2
  import type { ICache } from '../..';
3
3
  interface IEditVars {
4
4
  title?: string;
5
- content: string;
5
+ content?: string;
6
6
  }
7
7
  export declare function useEditActivity({ mutationFn, mutationHandlers: { mutate: mutateWrapper, error: onError }, }: IMutationContext<ICache, Error, IEditVars, ICache>): import("@tanstack/react-query/build/legacy/types").UseMutateFunction<import('../../../../../../discussion/shared').IActivity, Error, IEditVars, import('../../../../../../discussion/shared').IActivity>;
8
8
  export {};
@@ -2,7 +2,7 @@ import type { IUserContext } from '../../../context';
2
2
  import type { IActivity, IReaction } from '..';
3
3
  interface IPrepareActivityArgs {
4
4
  title?: string;
5
- content: string;
5
+ content?: string;
6
6
  }
7
7
  interface IEnrichActivityArgs {
8
8
  activity: IActivity | Partial<IActivity>;
@@ -19,7 +19,7 @@ interface IDecrementActivityLikesArgs {
19
19
  }
20
20
  export declare function prepareActivity({ title, content }: IPrepareActivityArgs): {
21
21
  title: string | undefined;
22
- content: string;
22
+ content: string | undefined;
23
23
  id: string;
24
24
  time: string;
25
25
  verb: string;