@apolitical/component-library 4.4.0 → 4.5.0-beta.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.
- package/discussion/components/add-post/add-post.d.ts +3 -1
- package/discussion/components/discussion-form-card/discussion-form-card.d.ts +14 -0
- package/discussion/components/discussion-form-card/index.d.ts +1 -0
- package/discussion/components/form/components/guidelines/guidelines.d.ts +13 -0
- package/discussion/components/form/components/guidelines/index.d.ts +1 -0
- package/discussion/components/form/components/index.d.ts +2 -0
- package/discussion/components/form/components/label/index.d.ts +1 -0
- package/discussion/components/form/components/label/label.d.ts +13 -0
- package/discussion/components/form/form.d.ts +100 -64
- package/discussion/components/form/index.d.ts +1 -1
- package/discussion/components/index.d.ts +1 -0
- package/discussion/sections/activity-section/cache/hooks/edit/edit.hook.d.ts +2 -1
- package/form/components/form/components/fields/checkbox/checkbox.d.ts +1 -1
- package/form/components/form/components/fields/input/input.d.ts +1 -1
- package/form/components/form/form.d.ts +1 -1
- package/form/components/form/form.types.d.ts +9 -1
- package/form/components/form/index.d.ts +1 -0
- package/form/components/rich-text-editor/helpers/transform/transform.d.ts +1 -1
- package/helpers/intl.d.ts +6 -0
- package/helpers/urls.d.ts +1 -0
- package/index.js +54 -52
- package/index.mjs +23502 -23304
- package/modals/discussion-form-modal/discussion-form-modal.d.ts +13 -0
- package/modals/discussion-form-modal/index.d.ts +1 -0
- package/modals/index.d.ts +1 -0
- package/package.json +1 -1
- package/style.css +1 -1
- package/styles/base/_overlays.scss +8 -0
- package/styles/base/_text.scss +1 -1
- package/styles/variables/colors/theme/_discussion.scss +4 -0
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { IDiscussionForm } from '../../../discussion/components/form';
|
|
2
|
+
import { type IDiscussionForm } from '../../../discussion/components/form';
|
|
3
3
|
interface Props {
|
|
4
|
+
/** Whether the form should be displayed as a card */
|
|
5
|
+
isCard?: boolean;
|
|
4
6
|
/** Props for the form - this uses everything the `DiscussionForm` component does */
|
|
5
7
|
form: IDiscussionForm;
|
|
6
8
|
/** Details about what a user needs to have to be able to access the form */
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type IDiscussionForm } from './../form';
|
|
2
|
+
interface Props {
|
|
3
|
+
/** Force elements to show */
|
|
4
|
+
forceShow?: {
|
|
5
|
+
/** Force the modal to show, e.g. when there's a parameter in the url */
|
|
6
|
+
modal?: boolean;
|
|
7
|
+
};
|
|
8
|
+
/** Props for the DiscussionForm component */
|
|
9
|
+
form: IDiscussionForm;
|
|
10
|
+
/** Additional classes */
|
|
11
|
+
className?: string;
|
|
12
|
+
}
|
|
13
|
+
declare const DiscussionFormCard: ({ forceShow, form, className }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export default DiscussionFormCard;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as DiscussionFormCard } from './discussion-form-card';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IDiscussionContentType } from './../../../../discussion.d';
|
|
2
|
+
interface Props {
|
|
3
|
+
/** The internationalisation path for the guidelines */
|
|
4
|
+
intlPath: string;
|
|
5
|
+
/** Whether to show the guidelines */
|
|
6
|
+
showGuidelines: boolean;
|
|
7
|
+
/** The content type */
|
|
8
|
+
type: IDiscussionContentType;
|
|
9
|
+
/** The Google Tag Manager context */
|
|
10
|
+
gtmContext: string;
|
|
11
|
+
}
|
|
12
|
+
declare const Guidelines: ({ intlPath, showGuidelines, type, gtmContext }: Props) => import("react/jsx-runtime").JSX.Element | null;
|
|
13
|
+
export default Guidelines;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Guidelines } from './guidelines';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Label } from './label';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IDiscussionContentType } from './../../../../discussion.d';
|
|
2
|
+
interface Props {
|
|
3
|
+
/** The ID of the form */
|
|
4
|
+
formID: string;
|
|
5
|
+
/** The internationalisation path for the label */
|
|
6
|
+
intlPath: string;
|
|
7
|
+
/** Whether the label should show visually */
|
|
8
|
+
showLabel: boolean;
|
|
9
|
+
/** The content type */
|
|
10
|
+
type: IDiscussionContentType;
|
|
11
|
+
}
|
|
12
|
+
declare const Label: ({ formID, intlPath, showLabel, type }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export default Label;
|
|
@@ -1,66 +1,102 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
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 should be autofocused. (It will always be autofocused when `isEditing`. */
|
|
19
|
+
isAutoFocused?: boolean;
|
|
20
|
+
|
|
21
|
+
/** Whether we're editing or creating */
|
|
22
|
+
isEditing: false | { text?: string };
|
|
23
|
+
|
|
24
|
+
/** Whether the form has a title field */
|
|
25
|
+
hasTitleField?: false | { text?: string };
|
|
26
|
+
|
|
27
|
+
/** Whether the form is prepopulated with text (different to isEditing, as we want different buttons and text to show */
|
|
28
|
+
isPrepopulated: false | { text?: string };
|
|
29
|
+
|
|
30
|
+
/** Whether title text should show above the form */
|
|
31
|
+
showTitle?: boolean;
|
|
32
|
+
|
|
33
|
+
/** Whether the community guidelines text should show beneath the form */
|
|
34
|
+
showGuidelines?: boolean;
|
|
35
|
+
|
|
36
|
+
/** Whether to show a divider before the buttons */
|
|
37
|
+
showDivider?: boolean;
|
|
38
|
+
|
|
39
|
+
/** Whether the success message should show on a successful submit */
|
|
40
|
+
showSuccessMessage?: boolean;
|
|
41
|
+
}
|
|
42
|
+
|
|
3
43
|
export interface IDiscussionForm {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
listMembers?: ListMembers;
|
|
49
|
-
props?: {
|
|
50
|
-
create: {
|
|
51
|
-
projectNames: ['questions-answers'];
|
|
52
|
-
};
|
|
53
|
-
};
|
|
44
|
+
/** A unique ID for the form */
|
|
45
|
+
id?: string;
|
|
46
|
+
|
|
47
|
+
/** Information about the content being created/edited */
|
|
48
|
+
content: IDiscussionContent;
|
|
49
|
+
|
|
50
|
+
/** If the user has permission to interact with the form, e.g. if they're a member of the community */
|
|
51
|
+
userHasPermissions?: boolean;
|
|
52
|
+
|
|
53
|
+
/** Information about the form */
|
|
54
|
+
meta?: IDiscussionFormMeta;
|
|
55
|
+
|
|
56
|
+
/** The placeholder text - this defaults to the intl text */
|
|
57
|
+
placeholder?: string;
|
|
58
|
+
|
|
59
|
+
/** The maximum number of characters */
|
|
60
|
+
maxLength?: number;
|
|
61
|
+
|
|
62
|
+
/** The buttons at the bottom of the form */
|
|
63
|
+
buttons?: {
|
|
64
|
+
/** Text for the cancel button */
|
|
65
|
+
cancel?: string;
|
|
66
|
+
/** Text for the submit button */
|
|
67
|
+
submit?: string;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/** Force elements on the form to show, regardless of the form state */
|
|
71
|
+
forceShow?: {
|
|
72
|
+
/** If the cancel button should always show */
|
|
73
|
+
cancel?: boolean;
|
|
74
|
+
/** If an error, created externally, should always show */
|
|
75
|
+
error?: false | string;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
/** The functions that are passed in to handle the functionality */
|
|
79
|
+
functions: {
|
|
80
|
+
create: DiscussionCreateContentFunction;
|
|
81
|
+
handleSaveEdit?: (({ title: string, body: string }) => Promise<void>) | (() => void);
|
|
82
|
+
handleCancel?: () => void;
|
|
83
|
+
callback?: (args: void) => void;
|
|
84
|
+
listMembers?: ListMembers;
|
|
85
|
+
|
|
86
|
+
props?: {
|
|
87
|
+
create: { projectNames: ['questions-answers'] };
|
|
54
88
|
};
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
/** Data to be passed into the rich text editor */
|
|
92
|
+
data?: {
|
|
93
|
+
/** Mentions data */
|
|
94
|
+
mentions?: IMentions;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
/** The context for GTM */
|
|
98
|
+
gtmContext?: string;
|
|
99
|
+
|
|
100
|
+
/** The language to use for the text */
|
|
101
|
+
locale?: string;
|
|
102
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type { IDiscussionForm } from './form';
|
|
1
|
+
export type { IDiscussionForm, IDiscussionFormMeta } from './form.d';
|
|
2
2
|
export { default as DiscussionForm } from './form';
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { IMutationContext } from '../../../../../../discussion/shared';
|
|
2
2
|
import type { ICache } from '../..';
|
|
3
3
|
interface IEditVars {
|
|
4
|
+
title?: string;
|
|
4
5
|
content: string;
|
|
5
6
|
}
|
|
6
|
-
export declare function useEditActivity({ mutationFn, mutationHandlers: { mutate: mutateWrapper, error: onError
|
|
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>;
|
|
7
8
|
export {};
|
|
@@ -30,7 +30,7 @@ export declare const Checkbox: ({ className, disabled, element, functions: allFu
|
|
|
30
30
|
options?: import("../../../form.types").IFieldOption[] | undefined;
|
|
31
31
|
placeholder?: string | undefined;
|
|
32
32
|
props?: {
|
|
33
|
-
[key: string]: string | boolean | object | React.RefObject<any> | (() => void);
|
|
33
|
+
[key: string]: string | number | boolean | object | React.RefObject<any> | (() => void);
|
|
34
34
|
} | undefined;
|
|
35
35
|
required?: boolean | undefined;
|
|
36
36
|
submitOnEnter?: boolean | undefined;
|
|
@@ -38,7 +38,7 @@ export declare const Input: ({ className, element, id, inputRef: ref, functions,
|
|
|
38
38
|
} | undefined;
|
|
39
39
|
options?: import("../../../form.types").IFieldOption[] | undefined;
|
|
40
40
|
props?: {
|
|
41
|
-
[key: string]: string | boolean | object | React.RefObject<any> | (() => void);
|
|
41
|
+
[key: string]: string | number | boolean | object | React.RefObject<any> | (() => void);
|
|
42
42
|
} | undefined;
|
|
43
43
|
required?: boolean | undefined;
|
|
44
44
|
shownValue?: InputValues | undefined;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { IFormProps } from './form.types';
|
|
2
|
-
declare const Form: ({ element, fields, className, id: formId, formRef: ref, intlPath, button, secondaryActionButton, meta, gtm, functions: { onSuccess, onCancel, onCatch, onFailure, }, ...props }: IFormProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
2
|
+
declare const Form: ({ element, fields, className, id: formId, formRef: ref, intlPath, button, secondaryActionButton, meta, children, gtm, functions: { onSuccess, onCancel, onCatch, onFailure, }, ...props }: IFormProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
3
3
|
export default Form;
|
|
@@ -142,7 +142,7 @@ export interface IField {
|
|
|
142
142
|
placeholder?: string;
|
|
143
143
|
/** Additional props to be passed to the field */
|
|
144
144
|
props?: {
|
|
145
|
-
[key: string]: string | boolean | object | (() => void) | React.RefObject<any>;
|
|
145
|
+
[key: string]: string | boolean | number | object | (() => void) | React.RefObject<any>;
|
|
146
146
|
};
|
|
147
147
|
/** Whether the field is required */
|
|
148
148
|
required?: boolean;
|
|
@@ -166,6 +166,8 @@ export interface FormButtonPropsType extends ButtonPropsType {
|
|
|
166
166
|
customOnSubmit?: React.ReactNode | false;
|
|
167
167
|
/** The text to show on the button */
|
|
168
168
|
text?: string;
|
|
169
|
+
/** Whether the `text` should replace the `submitting` state of the button */
|
|
170
|
+
overwriteSubmittingText?: boolean;
|
|
169
171
|
/** The option to not have the submit button at all */
|
|
170
172
|
hideButton?: boolean;
|
|
171
173
|
}
|
|
@@ -208,6 +210,8 @@ export interface IFormProps {
|
|
|
208
210
|
meta?: {
|
|
209
211
|
/** Whether the form should reset after submission */
|
|
210
212
|
shouldReset?: boolean;
|
|
213
|
+
/** Whether the form should hide after submission */
|
|
214
|
+
shouldHide?: boolean;
|
|
211
215
|
/** Whether the form should show required labels */
|
|
212
216
|
showRequiredLabels?: boolean;
|
|
213
217
|
/** Whether the form should show success message*/
|
|
@@ -215,6 +219,10 @@ export interface IFormProps {
|
|
|
215
219
|
/** Whether the form should show cancel button */
|
|
216
220
|
shouldShowCancelButton?: boolean;
|
|
217
221
|
};
|
|
222
|
+
/** Optional children */
|
|
223
|
+
children?: React.ReactNode;
|
|
224
|
+
/** An ID for jest tests */
|
|
225
|
+
'data-testid'?: string;
|
|
218
226
|
}
|
|
219
227
|
export interface IFieldWrapper extends IField {
|
|
220
228
|
/** The error to show */
|
|
@@ -11,9 +11,9 @@ export default function transform<T extends InputNodeTypes>(node: MdastNode, opt
|
|
|
11
11
|
url?: string | undefined;
|
|
12
12
|
position?: any;
|
|
13
13
|
checked?: any;
|
|
14
|
+
lang?: string | undefined;
|
|
14
15
|
ordered?: boolean | undefined;
|
|
15
16
|
depth?: 1 | 2 | 3 | 4 | 6 | 5 | undefined;
|
|
16
|
-
lang?: string | undefined;
|
|
17
17
|
spread?: any;
|
|
18
18
|
indent?: any;
|
|
19
19
|
text: string | undefined;
|
package/helpers/intl.d.ts
CHANGED
|
@@ -110,9 +110,13 @@ export declare const checkIntlPathExists: (path: string, language?: {
|
|
|
110
110
|
discussion_reply: string;
|
|
111
111
|
discussion_report_subject: string;
|
|
112
112
|
discussion_report_body: string;
|
|
113
|
+
discussionFormCard_placeholder: string;
|
|
113
114
|
discussion_form_title: string;
|
|
115
|
+
discussion_form_titleField_label: string;
|
|
116
|
+
discussion_form_titleField_error: string;
|
|
114
117
|
discussion_form_placeholder: string;
|
|
115
118
|
discussion_form_label: string;
|
|
119
|
+
discussion_form_label_action: string;
|
|
116
120
|
discussion_form_explainer: string;
|
|
117
121
|
discussion_form_success: string;
|
|
118
122
|
discussion_form_post: string;
|
|
@@ -370,6 +374,8 @@ export declare const checkIntlPathExists: (path: string, language?: {
|
|
|
370
374
|
loadingBlock_almostDone: string;
|
|
371
375
|
loadingBlock_complete: string;
|
|
372
376
|
progressBar: string;
|
|
377
|
+
discussionPostModal_title: string;
|
|
378
|
+
discussionPostModal_cta: string;
|
|
373
379
|
inviteModal_title: string;
|
|
374
380
|
inviteModal_formTitle: string;
|
|
375
381
|
inviteModal_formLabel: string;
|
package/helpers/urls.d.ts
CHANGED