@apolitical/component-library 6.3.4 → 6.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.
Files changed (44) hide show
  1. package/discussion/components/form/form.type.d.ts +21 -2
  2. package/discussion/components/form/index.d.ts +1 -1
  3. package/discussion/feeds/replies-feed/cache/hooks/feed/index.d.ts +0 -1
  4. package/discussion/feeds/replies-feed/mocks/index.d.ts +0 -1
  5. package/discussion/feeds/replies-feed/{components/nested-replies-feed → nested-replies-feed}/nested-replies-feed.d.ts +3 -3
  6. package/discussion/feeds/replies-feed/replies-feed.d.ts +2 -4
  7. package/discussion/sections/activity-section/mocks/activity-section.mock.d.ts +39 -45
  8. package/discussion/sections/activity-section/mocks/index.d.ts +0 -1
  9. package/discussion/shared/interfaces/discussion.interface.d.ts +1 -20
  10. package/form/components/character-limit/character-limit.helpers.d.ts +2 -2
  11. package/form/components/form/components/field-wrapper/field-wrapper.d.ts +1 -1
  12. package/form/components/form/components/fields/checkbox/checkbox.d.ts +6 -0
  13. package/form/components/form/components/fields/index.d.ts +1 -0
  14. package/form/components/form/components/fields/input/input.d.ts +7 -2
  15. package/form/components/form/components/fields/multiple-inputs/index.d.ts +1 -0
  16. package/form/components/form/components/fields/multiple-inputs/multiple-inputs.d.ts +3 -0
  17. package/form/components/form/form.helpers.d.ts +2 -0
  18. package/form/components/form/form.types.d.ts +28 -7
  19. package/helpers/intl.d.ts +3 -1
  20. package/index.js +44 -44
  21. package/index.mjs +7353 -7275
  22. package/package.json +1 -1
  23. package/style.css +1 -1
  24. package/styles/base/form/_labels.scss +2 -1
  25. package/styles/variables/colors/theme/_form.scss +1 -0
  26. package/discussion/feeds/replies-feed/cache/hooks/feed/parse-replies/index.d.ts +0 -1
  27. package/discussion/feeds/replies-feed/cache/hooks/feed/parse-replies/mocks/index.d.ts +0 -2
  28. package/discussion/feeds/replies-feed/cache/hooks/feed/parse-replies/mocks/replies.mock.d.ts +0 -2
  29. package/discussion/feeds/replies-feed/cache/hooks/feed/parse-replies/mocks/user.mock.d.ts +0 -4
  30. package/discussion/feeds/replies-feed/cache/hooks/feed/parse-replies/parse-replies.d.ts +0 -28
  31. package/discussion/feeds/replies-feed/components/add-reply-form/add-reply-form.d.ts +0 -16
  32. package/discussion/feeds/replies-feed/components/add-reply-form/index.d.ts +0 -1
  33. package/discussion/feeds/replies-feed/components/index.d.ts +0 -3
  34. package/discussion/feeds/replies-feed/components/load-more-replies-button/index.d.ts +0 -1
  35. package/discussion/feeds/replies-feed/components/load-more-replies-button/load-more-replies-button.d.ts +0 -13
  36. package/discussion/feeds/replies-feed/components/reply-item/index.d.ts +0 -1
  37. package/discussion/feeds/replies-feed/components/reply-item/reply-item.d.ts +0 -43
  38. package/discussion/feeds/replies-feed/mocks/parsed-replies-feed.mock.d.ts +0 -13
  39. package/discussion/sections/activity-section/activity-section.helpers.d.ts +0 -2
  40. package/discussion/sections/activity-section/activity-section.mock.d.ts +0 -103
  41. package/discussion/sections/activity-section/mocks/activity-functions.mock.d.ts +0 -46
  42. /package/discussion/feeds/replies-feed/{components/nested-replies-feed → nested-replies-feed}/index.d.ts +0 -0
  43. /package/discussion/feeds/replies-feed/{components/nested-replies-feed → nested-replies-feed}/mocks/index.d.ts +0 -0
  44. /package/discussion/feeds/replies-feed/{components/nested-replies-feed → nested-replies-feed}/mocks/nested-replies-feed.mock.d.ts +0 -0
@@ -1,6 +1,6 @@
1
1
  import type { IEnrichedUrlData } from '../../../navigation';
2
- import { IDiscussionContent, IMentions } from './../../discussion';
3
- import { ICategory, IDiscussionFormFunctions } from '../../shared';
2
+ import { DiscussionCreateContentFunction, IDiscussionContent, IListMemberData, IMentions, IDiscussionFormFns } from './../../discussion';
3
+ import { ICategory } from '../../shared';
4
4
  export interface IDiscussionFormMeta {
5
5
  /** Whether the form data is still loading */
6
6
  isLoading?: boolean;
@@ -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;
@@ -89,3 +107,4 @@ export interface IDiscussionFormState {
89
107
  link?: false | IEnrichedUrlData;
90
108
  };
91
109
  }
110
+ export {};
@@ -1,2 +1,2 @@
1
- export type { IDiscussionForm, IDiscussionFormMeta, } from './form.type';
1
+ export type { IDiscussionForm, IDiscussionFormMeta } from './form.type';
2
2
  export { default as DiscussionForm } from './form';
@@ -1,2 +1 @@
1
1
  export * from './feed.hook';
2
- export type { IParsedReplies } from './parse-replies';
@@ -1,2 +1 @@
1
- export * from './parsed-replies-feed.mock';
2
1
  export * from './replies-feed.mock';
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
- import type { IDiscussionFormFns } from '../../../../../discussion/discussion.d';
3
- import { ILikesFeedQueryFns } from '../../../../../discussion/feeds/likes-feed';
4
- import { type IQueryFns } from '../../cache';
2
+ import type { IDiscussionFormFns } from '../../../../discussion/discussion.d';
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;
@@ -1,12 +1,12 @@
1
1
  /// <reference types="react" />
2
2
  import { type IProfileFormProps } from '../../../form';
3
3
  import { ILikesFeedQueryFns } from '../../../discussion/feeds/likes-feed';
4
- import type { IDiscussionFormFns } from '../../discussion';
4
+ import type { IDiscussionFormFns } from './../../discussion';
5
5
  import { type IQueryFns } from './cache';
6
6
  interface RepliesFunctions {
7
7
  /** Functions for the replies query */
8
8
  reactions: IQueryFns;
9
- /** Functions for likes query */
9
+ /** Functions for the likes query */
10
10
  likes: ILikesFeedQueryFns;
11
11
  /** Query functions for the mentions */
12
12
  form: IDiscussionFormFns;
@@ -30,8 +30,6 @@ interface Props {
30
30
  functions: RepliesFunctions;
31
31
  /** Props to pass into the profile form */
32
32
  profile: IProfileFormProps;
33
- /** Whether to show the replies */
34
- showReplies: boolean;
35
33
  }
36
34
  declare const RepliesFeed: React.FC<Props>;
37
35
  export default RepliesFeed;
@@ -1,52 +1,46 @@
1
1
  export declare const activitySectionMock: {
2
- POST: {
3
- actor: {
4
- created_at: string;
5
- updated_at: string;
6
- id: string;
7
- data: {
8
- jobTitle: string;
9
- name: string;
10
- organization: string;
11
- location: {
12
- en: string;
13
- };
14
- badges: {
15
- communities: {
16
- 'community-slug': string[];
17
- };
2
+ actor: {
3
+ created_at: string;
4
+ updated_at: string;
5
+ id: string;
6
+ data: {
7
+ jobTitle: string;
8
+ name: string;
9
+ organization: string;
10
+ location: {
11
+ en: string;
12
+ };
13
+ badges: {
14
+ communities: {
15
+ 'community-slug': string[];
18
16
  };
19
17
  };
20
18
  };
21
- categories: never[];
22
- content: string;
23
- feed_id: string;
24
- foreign_id: string;
25
- id: string;
26
- latest_reactions: {
27
- like: never[];
28
- reply: never[];
29
- };
30
- latest_reactions_extra: {
31
- like: never[];
32
- reply: never[];
33
- };
34
- object: string;
35
- origin: null;
36
- own_reactions: {
37
- like: never[];
38
- reply: never[];
39
- };
40
- reaction_counts: {
41
- like: number;
42
- reply: number;
43
- };
44
- target: string;
45
- time: string;
46
- verb: string;
47
19
  };
48
- POLL: {
49
- total_replies: number;
50
- verb: string;
20
+ categories: string[];
21
+ content: string;
22
+ feed_id: string;
23
+ foreign_id: string;
24
+ id: string;
25
+ latest_reactions: {
26
+ like: never[];
27
+ reply: never[];
28
+ };
29
+ latest_reactions_extra: {
30
+ like: never[];
31
+ reply: never[];
32
+ };
33
+ object: string;
34
+ origin: null;
35
+ own_reactions: {
36
+ like: never[];
37
+ reply: never[];
38
+ };
39
+ reaction_counts: {
40
+ like: number;
41
+ reply: number;
51
42
  };
43
+ target: string;
44
+ time: string;
45
+ verb: string;
52
46
  };
@@ -1,3 +1,2 @@
1
1
  export { repliesFeedMock } from '../../../feeds/replies-feed';
2
- export * from './activity-functions.mock';
3
2
  export * from './activity-section.mock';
@@ -1,8 +1,7 @@
1
1
  import { MemberProps, MemberDetailsProps } from '../../../user';
2
2
  import type { ListMembers, ClickMentionFallback } from '../../../form';
3
3
  import type { IEnrichedUrlData } from '../../../navigation';
4
- import type { ICategory } from './community.category.interface';
5
- import type { IDiscussionFormFns } from '../../discussion';
4
+ import { ICategory } from './community.category.interface';
6
5
  export type IDiscussionContentType = 'answer' | 'post' | 'response' | 'reply' | 'question';
7
6
  export interface IDiscussionContent {
8
7
  /** The type of content */
@@ -92,21 +91,3 @@ export interface IConversation {
92
91
  prepopulateForm?: string;
93
92
  mentionData?: IListMemberData;
94
93
  }
95
- export interface IDiscussionFormFunctions extends IDiscussionFormFns {
96
- onChange?: (args: {
97
- [key: string]: string | boolean;
98
- }) => void;
99
- create: DiscussionCreateContentFunction;
100
- handleSaveEdit?: (({ title, body }: {
101
- title: string;
102
- body: string;
103
- }) => Promise<void>) | (() => void);
104
- handleCancel?: () => void;
105
- callback?: (args: void) => void;
106
- onMention?: (value?: IListMemberData) => void;
107
- props?: {
108
- create: {
109
- projectNames: ['questions-answers'];
110
- };
111
- };
112
- }
@@ -1,5 +1,5 @@
1
- import { FieldOnChange, IFieldFunctions } from '../../../form/components/form/form.types';
1
+ import { IFieldFunctions } from '../../../form/components/form/form.types';
2
2
  export declare const getValueLength: (value: string | number | boolean | null | undefined) => number;
3
- export declare const getCharacterLimitProps: (limit: number, onChange?: FieldOnChange | null) => {
3
+ export declare const getCharacterLimitProps: (limit: number, functions: IFieldFunctions) => {
4
4
  [key: string]: number | IFieldFunctions;
5
5
  };
@@ -1,3 +1,3 @@
1
1
  import { IFieldWrapper } from '../../form.types';
2
- declare const FieldWrapper: ({ id, intlPath, className, error, functions, limit, showRequiredLabels, type, validation, value, submitOnEnter, ...props }: IFieldWrapper) => import("react/jsx-runtime").JSX.Element;
2
+ declare const FieldWrapper: (fieldWrapperProps: IFieldWrapper) => import("react/jsx-runtime").JSX.Element;
3
3
  export default FieldWrapper;
@@ -27,6 +27,12 @@ export declare const Checkbox: ({ className, disabled, element, functions: allFu
27
27
  topbar?: boolean | undefined;
28
28
  submitSection?: boolean | undefined;
29
29
  } | undefined;
30
+ multipleInputs?: {
31
+ showCount?: boolean | undefined;
32
+ label?: string | undefined;
33
+ maxInputs: number;
34
+ hasButton?: false | import("../../../../../..").ButtonPropsType | undefined;
35
+ } | undefined;
30
36
  name?: string | undefined;
31
37
  options?: import("../../../form.types").IFieldOption[] | undefined;
32
38
  placeholder?: string | undefined;
@@ -2,5 +2,6 @@ export * from './input';
2
2
  export * from './input-autocomplete';
3
3
  export * from './checkbox';
4
4
  export * from './dropdown-menu';
5
+ export * from './multiple-inputs';
5
6
  export * from './multiple-options';
6
7
  export * from './password';
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { IField, InputTypes, InputValues } from '../../../form.types';
3
- export declare const Input: ({ className, element, id, inputRef: ref, functions, name, placeholder, type, value, autoFocus, ...props }: IField) => React.DOMElement<{
3
+ export declare const Input: ({ className, element, id, inputRef: ref, functions, name, placeholder, type, value, autoFocus, label, ...props }: IField) => React.DOMElement<{
4
4
  onChange: (e: React.FormEvent<HTMLInputElement>) => void;
5
5
  onMultiSelectSubmit?: ((arg1: import("../../../form.types").FormValues) => void) | undefined;
6
6
  onBlur?: (() => void) | undefined;
@@ -35,13 +35,18 @@ export declare const Input: ({ className, element, id, inputRef: ref, functions,
35
35
  } | undefined;
36
36
  initialValue?: import("../../../form.types").FormValues;
37
37
  intlPath?: string | false | undefined;
38
- label?: React.ReactNode;
39
38
  limit?: number | undefined;
40
39
  multiSelect?: boolean | undefined;
41
40
  multiSelectOptions?: {
42
41
  topbar?: boolean | undefined;
43
42
  submitSection?: boolean | undefined;
44
43
  } | undefined;
44
+ multipleInputs?: {
45
+ showCount?: boolean | undefined;
46
+ label?: string | undefined;
47
+ maxInputs: number;
48
+ hasButton?: false | import("../../../../../..").ButtonPropsType | undefined;
49
+ } | undefined;
45
50
  options?: import("../../../form.types").IFieldOption[] | undefined;
46
51
  props?: {
47
52
  [key: string]: string | number | boolean | object | React.RefObject<any> | (() => void);
@@ -0,0 +1 @@
1
+ export { default as MultipleInputs } from './multiple-inputs';
@@ -0,0 +1,3 @@
1
+ import type { IFieldWrapper } from '../../../form.types';
2
+ export declare const MultipleInputs: ({ id, label: legend, limit, value, placeholder, functions, error: allFormErrors, multipleInputs, validation, fieldData, type, ...props }: IFieldWrapper) => import("react/jsx-runtime").JSX.Element;
3
+ export default MultipleInputs;
@@ -0,0 +1,2 @@
1
+ import type { InputValues } from './form.types';
2
+ export declare const showError: (type: string, value: InputValues) => boolean;
@@ -5,10 +5,12 @@ import { IntlShape } from 'react-intl';
5
5
  export type InputValues = string | number | boolean | null;
6
6
  export type MultipleInputValues = InputValues[];
7
7
  export type FormValues = InputValues | MultipleInputValues | undefined;
8
- export type InputTypes = 'text' | 'textarea' | 'email' | 'url' | 'checkbox' | 'select' | 'radio' | 'password' | 'autocomplete' | 'number';
8
+ export type InputTypes = 'text' | 'textarea' | 'email' | 'url' | 'checkbox' | 'checkboxes' | 'select' | 'radio' | 'password' | 'autocomplete' | 'number' | 'multiple-inputs';
9
9
  export interface ILabel {
10
10
  /** The element to be used, defaulting to `label` */
11
11
  element?: string;
12
+ /** Optional class for the label */
13
+ className?: string;
12
14
  /** The ID of the input to be labelled */
13
15
  htmlFor?: string;
14
16
  }
@@ -41,13 +43,14 @@ export interface IFormPayload {
41
43
  /** Function to call when something fails */
42
44
  onFailure?: (arg: IFormValues, arg2?: FormValues) => void;
43
45
  }
46
+ interface IFormErrors {
47
+ [key: string]: (() => void) | FormValues;
48
+ }
44
49
  export interface IFormReducerAction extends IReducerAction<IFormPayload> {
45
50
  }
46
51
  export interface IFormReducerState {
47
52
  'custom-validation'?: string | boolean;
48
- errors?: {
49
- [key: string]: (() => void) | FormValues;
50
- };
53
+ errors?: IFormErrors;
51
54
  formSubmitted: boolean;
52
55
  isSubmitting: boolean;
53
56
  values?: IFormValues;
@@ -132,7 +135,7 @@ export interface IField {
132
135
  /** The internationalisation path for the field */
133
136
  intlPath?: string | false;
134
137
  /** The label for the field */
135
- label?: string | React.ReactNode;
138
+ label?: string | React.ReactNode | false;
136
139
  /** An optional character limit, for textareas */
137
140
  limit?: number;
138
141
  /** Whether the field can have multiple values, for checkboxes */
@@ -144,6 +147,17 @@ export interface IField {
144
147
  /** Whether to display the submit button in the dropdown - this allows the user to submit the dropdown only */
145
148
  submitSection?: boolean;
146
149
  };
150
+ /** Props for the inputs rendered in a `multiple` field */
151
+ multipleInputs?: {
152
+ /** Whether or not to show the number of filled in inputs in the legend */
153
+ showCount?: boolean;
154
+ /** The template text for each label */
155
+ label?: string;
156
+ /** How many inputs can be added in total */
157
+ maxInputs: number;
158
+ /** Whether to add options with a button */
159
+ hasButton?: false | ButtonPropsType;
160
+ };
147
161
  /** The name of the field */
148
162
  name?: string;
149
163
  /** The options for the field, for checkboxes and dropdowns */
@@ -161,7 +175,7 @@ export interface IField {
161
175
  /** Whether hitting enter on the field should submit the form */
162
176
  submitOnEnter?: boolean;
163
177
  /** The type of the input */
164
- type?: InputTypes | 'checkboxes';
178
+ type?: InputTypes;
165
179
  /** The validation for the field */
166
180
  validation?: IFieldValidation[];
167
181
  /** The value of the field */
@@ -239,9 +253,16 @@ export interface IFormProps {
239
253
  }
240
254
  export interface IFieldWrapper extends IField {
241
255
  /** The error to show */
242
- error: string;
256
+ error: string | IFormErrors | undefined;
243
257
  /** Whether the field wrapper should show required labels */
244
258
  showRequiredLabels?: boolean;
245
259
  /** The value of the field */
246
260
  value?: FormValues;
261
+ /** The setter to amend the fields to validate; this is needed for multiple inputs, to give each input its own error handling */
262
+ fieldData?: {
263
+ fields: IField[];
264
+ setFields: React.Dispatch<React.SetStateAction<IField[]>>;
265
+ dispatch: React.Dispatch<IFormReducerAction>;
266
+ };
247
267
  }
268
+ export {};
package/helpers/intl.d.ts CHANGED
@@ -233,6 +233,9 @@ export declare const checkIntlPathExists: (path: string, language?: {
233
233
  form_submitting: string;
234
234
  form_submitted: string;
235
235
  form_success: string;
236
+ form_multipleInputs_label: string;
237
+ form_multipleInputs_filledInCount: string;
238
+ form_multipleInputs_filledInCount_aria: string;
236
239
  inviteForm_email_placeholder: string;
237
240
  inviteForm_title: string;
238
241
  inviteForm_label: string;
@@ -351,7 +354,6 @@ export declare const checkIntlPathExists: (path: string, language?: {
351
354
  poll_num_votes: string;
352
355
  poll_remove_vote_button: string;
353
356
  poll_aria_votes: string;
354
- replies_feed_missing_polls_vote_message: string;
355
357
  tableOfContents: string;
356
358
  timeToComplete_hours: string;
357
359
  timeToComplete_hours_short: string;