@apolitical/component-library 5.2.2 → 5.3.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.
Files changed (41) hide show
  1. package/discussion/components/add-post/add-post.d.ts +3 -0
  2. package/discussion/components/form/form.type.d.ts +5 -0
  3. package/discussion/components/post/post.d.ts +6 -1
  4. package/discussion/feeds/activities-feed/activities-feed.d.ts +5 -0
  5. package/discussion/feeds/activities-feed/cache/hooks/list/list.hook.d.ts +5 -2
  6. package/discussion/feeds/activities-feed/mocks/activities-feed.mock.d.ts +4 -0
  7. package/discussion/sections/activity-section/activity-section.d.ts +4 -0
  8. package/discussion/sections/activity-section/mocks/activity-section.mock.d.ts +1 -0
  9. package/discussion/shared/helpers/activity.helper.d.ts +3 -1
  10. package/discussion/shared/interfaces/activity.interface.d.ts +1 -0
  11. package/discussion/shared/interfaces/community.category.interface.d.ts +4 -0
  12. package/discussion/shared/interfaces/discussion.interface.d.ts +2 -0
  13. package/discussion/shared/interfaces/index.d.ts +1 -0
  14. package/form/components/form/components/fields/checkbox/checkbox.d.ts +2 -2
  15. package/form/components/form/components/fields/input/input.d.ts +5 -0
  16. package/form/components/form/components/fields/multiple-options/multiple-options.d.ts +1 -1
  17. package/form/components/form/form.types.d.ts +8 -0
  18. package/form/components/rich-text-editor/components/context/context.d.ts +5 -0
  19. package/form/components/rich-text-editor/helpers/handle-text/handle-text.d.ts +1 -0
  20. package/form/components/rich-text-editor/helpers/transform/transform.d.ts +1 -1
  21. package/form/components/rich-text-editor/plugins/index.d.ts +1 -0
  22. package/form/components/rich-text-editor/plugins/with-link-removal-listener/index.d.ts +1 -0
  23. package/form/components/rich-text-editor/plugins/with-link-removal-listener/with-link-removal-listener.d.ts +6 -0
  24. package/form/components/rich-text-editor/rich-text-editor.d.ts +2 -42
  25. package/form/components/rich-text-editor/rich-text-editor.types.d.ts +65 -2
  26. package/helpers/intl.d.ts +5 -0
  27. package/index.js +49 -49
  28. package/index.mjs +7079 -6876
  29. package/navigation/enriched-url/enriched-url.d.ts +26 -20
  30. package/navigation/enriched-url/index.d.ts +1 -1
  31. package/navigation/filters/filters.d.ts +5 -1
  32. package/package.json +1 -1
  33. package/sections/full-width-section/full-width-section.d.ts +0 -2
  34. package/style.css +1 -1
  35. package/styles/base/_accessibility.scss +1 -0
  36. package/styles/base/_text.scss +1 -1
  37. package/styles/mixins/_styles.scss +0 -3
  38. package/styles/variables/colors/_colors.scss +0 -2
  39. package/styles/variables/colors/theme/_base.scss +1 -2
  40. package/styles/variables/colors/theme/_layout.scss +2 -2
  41. package/styles/variables/colors/theme/_navigation.scss +6 -4
@@ -1,5 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import type { IDiscussionForm } from '../../../discussion/components/form';
3
+ import { ICategory } from '../../shared';
3
4
  interface Props {
4
5
  /** Whether the form should be displayed as a card */
5
6
  isCard?: boolean;
@@ -7,6 +8,8 @@ interface Props {
7
8
  parentId?: string;
8
9
  /** Props for the form - this uses everything the `DiscussionForm` component does */
9
10
  form: IDiscussionForm;
11
+ /** The categories to show in the form */
12
+ categories?: ICategory[];
10
13
  /** Details about what a user needs to have to be able to access the form */
11
14
  membershipRequiredToPost: {
12
15
  /** Whether the user needs to be a member of the community to post */
@@ -1,5 +1,6 @@
1
1
  import { type ListMembers, ClickMentionFallback } from '../../../form';
2
2
  import { DiscussionCreateContentFunction, IDiscussionContent, IListMemberData, IMentions } from './../../discussion';
3
+ import { ICategory } from '../../shared';
3
4
  export interface IDiscussionFormMeta {
4
5
  /** Whether the form data is still loading */
5
6
  isLoading?: boolean;
@@ -23,6 +24,10 @@ export interface IDiscussionFormMeta {
23
24
  };
24
25
  /** Whether title text should show above the form */
25
26
  showTitle?: boolean;
27
+ /** What category options should be made available for the form */
28
+ postCategories?: ICategory[];
29
+ /** Whether the post type should show */
30
+ showPostType?: boolean;
26
31
  /** Whether the community guidelines text should show beneath the form */
27
32
  showGuidelines?: boolean;
28
33
  /** Whether to show a divider before the buttons */
@@ -87,10 +87,15 @@ export interface IDiscussionPostProps {
87
87
  isCommunity?: boolean;
88
88
  /** Whether to show badges and the scope of the badge */
89
89
  badges?: IBadgesOption;
90
+ /** Categories for the community */
91
+ categories?: {
92
+ name: string;
93
+ slug: string;
94
+ }[];
90
95
  /** The base path, used for slugs */
91
96
  basePath: string;
92
97
  /** The ID of the parent, used for slugs */
93
98
  parentId: string;
94
99
  }
95
- declare const Post: ({ element, content, userHasPermissions, userHasOwnerPermissions, isLoading, originalAuthorId, forceHide, functions, links, className, gtmContext, children, isTruncated, styling: { showShareLinkButton, showMoreMenuButton }, setFocus, isCommunity, badges, basePath, parentId, }: IDiscussionPostProps) => import("react/jsx-runtime").JSX.Element;
100
+ declare const Post: ({ element, content, userHasPermissions, userHasOwnerPermissions, isLoading, originalAuthorId, forceHide, functions, links, className, gtmContext, children, isTruncated, styling: { showShareLinkButton, showMoreMenuButton }, setFocus, isCommunity, badges, categories, basePath, parentId, }: IDiscussionPostProps) => import("react/jsx-runtime").JSX.Element;
96
101
  export default Post;
@@ -12,6 +12,11 @@ interface Props {
12
12
  isMember: boolean;
13
13
  /** Whether the user is an owner of the community */
14
14
  isOwner: boolean;
15
+ /** The categories for the community */
16
+ categories: {
17
+ name: string;
18
+ slug: string;
19
+ }[];
15
20
  /** Functions for the activities query */
16
21
  functions: {
17
22
  /** Query functions for the activities */
@@ -3,9 +3,12 @@ import type { ICache, ICachePage } from '../..';
3
3
  export interface IListActivitiesArgs {
4
4
  queryFn: (_: unknown) => Promise<ICachePage>;
5
5
  queryKey: QueryKey;
6
- rankingMethod?: string;
6
+ filterOption?: {
7
+ id: string;
8
+ type: string;
9
+ };
7
10
  }
8
- export declare function useListActivities({ queryFn, queryKey, rankingMethod, }: IListActivitiesArgs): {
11
+ export declare function useListActivities({ queryFn, queryKey, filterOption, }: IListActivitiesArgs): {
9
12
  activities: import('../../../../../../discussion/shared').IActivity[];
10
13
  error: Error | null;
11
14
  isLoading: boolean;
@@ -16,6 +16,7 @@ export declare const activitiesFeedMock: {
16
16
  };
17
17
  };
18
18
  title: string;
19
+ categories: string[];
19
20
  content: string;
20
21
  feed_id: string;
21
22
  foreign_id: string;
@@ -124,6 +125,7 @@ export declare const activitiesFeedMock: {
124
125
  };
125
126
  };
126
127
  title: string;
128
+ categories: string[];
127
129
  content: string;
128
130
  feed_id: string;
129
131
  foreign_id: string;
@@ -155,6 +157,7 @@ export declare const activitiesFeedMock: {
155
157
  badges?: undefined;
156
158
  };
157
159
  };
160
+ categories: string[];
158
161
  content: string;
159
162
  feed_id: string;
160
163
  foreign_id: string;
@@ -229,6 +232,7 @@ export declare const activitiesFeedMock: {
229
232
  target: string;
230
233
  time: string;
231
234
  verb: string;
235
+ categories?: undefined;
232
236
  })[];
233
237
  next: string;
234
238
  duration: string;
@@ -22,6 +22,10 @@ export interface IActivitySectionProps {
22
22
  leave: () => Promise<void>;
23
23
  };
24
24
  profile: IProfileFormProps;
25
+ categories?: {
26
+ name: string;
27
+ slug: string;
28
+ }[];
25
29
  }
26
30
  declare const ActivitySection: React.FC<IActivitySectionProps>;
27
31
  export default ActivitySection;
@@ -17,6 +17,7 @@ export declare const activitySectionMock: {
17
17
  };
18
18
  };
19
19
  };
20
+ categories: string[];
20
21
  content: string;
21
22
  feed_id: string;
22
23
  foreign_id: string;
@@ -3,6 +3,7 @@ import type { IActivity, IReaction } from '..';
3
3
  interface IPrepareActivityArgs {
4
4
  title?: string;
5
5
  content?: string;
6
+ categories?: string;
6
7
  }
7
8
  interface IEnrichActivityArgs {
8
9
  activity: IActivity | Partial<IActivity>;
@@ -17,9 +18,10 @@ interface IDecrementActivityLikesArgs {
17
18
  activity: IActivity;
18
19
  user?: IUserContext;
19
20
  }
20
- export declare function prepareActivity({ title, content }: IPrepareActivityArgs): {
21
+ export declare function prepareActivity({ title, content, categories }: IPrepareActivityArgs): {
21
22
  title: string | undefined;
22
23
  content: string | undefined;
24
+ categories: string[];
23
25
  id: string;
24
26
  time: string;
25
27
  verb: string;
@@ -1,6 +1,7 @@
1
1
  import type { FlatActivityEnriched } from 'getstream';
2
2
  export interface IActivity extends FlatActivityEnriched {
3
3
  content: string;
4
+ categories?: string[];
4
5
  feed_id?: string;
5
6
  title: string;
6
7
  total_replies?: number;
@@ -0,0 +1,4 @@
1
+ export interface ICategory {
2
+ name: string;
3
+ slug: string;
4
+ }
@@ -24,6 +24,8 @@ export interface IFullDiscussionContent extends IDiscussionContent {
24
24
  body?: string;
25
25
  /** The author of the post */
26
26
  author: MemberProps;
27
+ /** The post categories */
28
+ categories?: string[];
27
29
  createdAt: Date | string;
28
30
  /** The number of likes to display */
29
31
  likes?: number;
@@ -1,4 +1,5 @@
1
1
  export * from './activity.interface';
2
+ export * from './community.category.interface';
2
3
  export * from './context.interface';
3
4
  export * from './discussion.interface';
4
5
  export * from './reaction.interface';
@@ -1,11 +1,11 @@
1
1
  import React from 'react';
2
2
  import { IField } from '../../../form.types';
3
- export declare const Checkbox: ({ className, disabled, element, functions: allFunctions, id, inputRef: ref, intlPath, label, shownValue: value, type, value: isChecked, ...props }: IField) => React.DOMElement<{
3
+ export declare const Checkbox: ({ className, disabled, element, functions: allFunctions, id, inputRef: ref, intlPath, label, shownValue: value, type, value: isChecked, accessibilityOptions: { checkboxes: { navigateWithArrowKeys } }, ...props }: IField) => React.DOMElement<{
4
4
  onMultiSelectSubmit?: ((arg1: import("../../../form.types").FormValues) => void) | undefined;
5
5
  onBlur?: (() => void) | undefined;
6
6
  onFocus?: (() => void) | undefined;
7
7
  onKeyInput?: (<T>(arg1: import("../../../form.types").FormValues) => Promise<T>) | undefined;
8
- onKeyDown?: ((e: React.KeyboardEvent<HTMLElement>) => void) | undefined;
8
+ onKeyDown: ((e: React.KeyboardEvent<HTMLElement>) => void) | undefined;
9
9
  submitForm?: ((arg: import("../../../form.types").IFormValues) => void) | undefined;
10
10
  'aria-describedby'?: string | undefined;
11
11
  'aria-errormessage'?: string | undefined;
@@ -15,6 +15,11 @@ export declare const Input: ({ className, element, id, inputRef: ref, functions,
15
15
  value: InputValues;
16
16
  placeholder: string | undefined;
17
17
  autoFocus: boolean | undefined;
18
+ accessibilityOptions?: {
19
+ checkboxes?: {
20
+ navigateWithArrowKeys?: boolean | undefined;
21
+ } | undefined;
22
+ } | undefined;
18
23
  'aria-describedby'?: string | undefined;
19
24
  'aria-errormessage'?: string | undefined;
20
25
  'aria-invalid'?: boolean | undefined;
@@ -1,3 +1,3 @@
1
1
  import { IField } from '../../../form.types';
2
- export declare const MultipleOptions: ({ className, functions, intlPath, id: groupId, label, multiSelect, name, options, required, type, value, ...props }: IField) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const MultipleOptions: ({ className, functions, intlPath, id: groupId, label, multiSelect, name, options, required, type, value, accessibilityOptions, ...props }: IField) => import("react/jsx-runtime").JSX.Element;
3
3
  export default MultipleOptions;
@@ -82,6 +82,14 @@ export interface IFieldFunctions {
82
82
  submitForm?: (arg: IFormValues) => void;
83
83
  }
84
84
  export interface IField {
85
+ /** Additional accessibility configuration */
86
+ accessibilityOptions?: {
87
+ /** Additional options for checkboxes */
88
+ checkboxes?: {
89
+ /** Whether the field should be navigable with arrow keys */
90
+ navigateWithArrowKeys?: boolean;
91
+ };
92
+ };
85
93
  /** Optional ID of the element which describes this field, for screen readers */
86
94
  'aria-describedby'?: string;
87
95
  /** Optional ID of the element which provides an error message for this field */
@@ -1,6 +1,7 @@
1
1
  import { Dispatch } from 'react';
2
2
  import { Point } from 'slate';
3
3
  import { IListMemberData } from '../../../../../discussion';
4
+ import type { IEnrichedUrlData } from '../../../../../navigation';
4
5
  import { ReportError, IMentionPopOver } from './../../rich-text-editor.types';
5
6
  declare const RichTextEditorContext: import("react").Context<{
6
7
  /** The id of the editor */
@@ -19,8 +20,12 @@ declare const RichTextEditorContext: import("react").Context<{
19
20
  lastAnchor: Point | null;
20
21
  /** Whether the editor is inside a modal, used to handle portals for focus trap */
21
22
  isInOverlay?: string | false | undefined;
23
+ /** The data for the first link, to be displayed in the EnrichedUrl component. `undefined` is not set, `false` will not show the enriched url. (For cases where the user has manually removed it.) */
24
+ enrichedUrl?: IEnrichedUrlData | false | undefined;
22
25
  /** An optional function to call when a mention is inserted */
23
26
  onMention?: ((value?: IListMemberData) => void) | undefined;
27
+ /** The function to get metadata about a link */
28
+ getLinkPreview?: ((url: string) => Promise<IEnrichedUrlData>) | undefined;
24
29
  /** The function to update the state */
25
30
  dispatch: Dispatch<any>;
26
31
  /** The function to report an error */
@@ -1,3 +1,4 @@
1
1
  import { BaseEditor } from 'slate';
2
2
  export declare const getSelectedText: (editor: BaseEditor) => string | null;
3
3
  export declare const getAllText: (editor: BaseEditor) => string;
4
+ export declare const firstLinkData: (editor: BaseEditor) => string | null;
@@ -12,8 +12,8 @@ export default function transform<T extends InputNodeTypes>(node: MdastNode, opt
12
12
  position?: any;
13
13
  ordered?: boolean | undefined;
14
14
  checked?: any;
15
- depth?: 1 | 2 | 3 | 4 | 5 | 6 | undefined;
16
15
  lang?: string | undefined;
16
+ depth?: 1 | 2 | 3 | 4 | 5 | 6 | undefined;
17
17
  spread?: any;
18
18
  indent?: any;
19
19
  text: string | undefined;
@@ -1,3 +1,4 @@
1
+ export * from './with-link-removal-listener';
1
2
  export * from './with-linlines';
2
3
  export * from './with-mentions';
3
4
  export * from './without-empty-links';
@@ -0,0 +1 @@
1
+ export { default as withLinkRemovalListener } from './with-link-removal-listener';
@@ -0,0 +1,6 @@
1
+ import { BaseEditor } from 'slate';
2
+ import { HistoryEditor } from 'slate-history';
3
+ import { ReactEditor } from 'slate-react';
4
+ import { ReportError } from './../../rich-text-editor.types';
5
+ declare const withLinkRemovalListener: (editor: BaseEditor & ReactEditor & HistoryEditor, reportError: ReportError) => BaseEditor & ReactEditor & HistoryEditor;
6
+ export default withLinkRemovalListener;
@@ -1,43 +1,3 @@
1
- import type { IMentions, IListMemberData } from '../../../discussion/discussion';
2
- import { ListMembers, ReportError, ClickMentionFallback } from './rich-text-editor.types';
3
- interface Props {
4
- /** The id of the rich text editor */
5
- id?: string;
6
- /** The default value of the rich text editor */
7
- value?: string;
8
- /** The placeholder text of the rich text editor */
9
- placeholder?: string;
10
- /** The maximum length of the rich text editor */
11
- maxLength?: number;
12
- /** Information about the rich text editor */
13
- meta?: {
14
- /** Whether the rich text editor is inside a modal */
15
- isInOverlay?: false | 'string';
16
- };
17
- /** Optional functions */
18
- functions?: {
19
- /** An optional function to get a filtered list of members when the user starts typing a mention */
20
- listMembers?: ListMembers;
21
- /** An optional function to call when the user clicks the mention fallback, e.g. to show an invite modal */
22
- clickMentionFallback?: ClickMentionFallback;
23
- /** An optional event handler, called when the rich text editor is changed */
24
- onChange?: (value: string) => void;
25
- /** An optional function to call when a mention is inserted */
26
- onMention?: (value?: IListMemberData) => void;
27
- /** An optional event handler, called when the rich text editor reports an error */
28
- reportError?: ReportError;
29
- };
30
- /** Optional autoFocus */
31
- autoFocus?: boolean;
32
- /** Optional aria invalid */
33
- 'aria-invalid'?: boolean;
34
- /** Optional aria error message */
35
- 'aria-errormessage'?: string;
36
- /** Optional data for the editor */
37
- data?: {
38
- /** Optional mentions */
39
- mentions?: IMentions;
40
- };
41
- }
42
- declare const RichTextEditor: ({ id, value, placeholder, maxLength, meta, functions, autoFocus, data, ...props }: Props) => import("react/jsx-runtime").JSX.Element;
1
+ import { IRTEProps } from './rich-text-editor.types';
2
+ declare const RichTextEditor: ({ id, value, placeholder, maxLength, meta, functions, autoFocus, data, ...props }: IRTEProps) => import("react/jsx-runtime").JSX.Element;
43
3
  export default RichTextEditor;
@@ -1,6 +1,69 @@
1
- import { BaseElement, BaseText, Descendant, Range } from 'slate';
2
- import type { IListMemberData } from '../../../discussion';
1
+ import { BaseElement, BaseText, Descendant, Point, Range } from 'slate';
2
+ import type { IListMemberData, IMentions } from '../../../discussion';
3
3
  import type { MemberDetailsProps } from '../../../user';
4
+ import type { IEnrichedUrlData } from '../../../navigation';
5
+ export interface IRTEProps {
6
+ /** The id of the rich text editor */
7
+ id?: string;
8
+ /** The default value of the rich text editor */
9
+ value?: string;
10
+ /** The placeholder text of the rich text editor */
11
+ placeholder?: string;
12
+ /** The maximum length of the rich text editor */
13
+ maxLength?: number;
14
+ /** Information about the rich text editor */
15
+ meta?: {
16
+ /** Whether the rich text editor is inside a modal */
17
+ isInOverlay?: false | 'string';
18
+ };
19
+ /** 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
+ };
34
+ /** Optional autoFocus */
35
+ autoFocus?: boolean;
36
+ /** Optional aria invalid */
37
+ 'aria-invalid'?: boolean;
38
+ /** Optional aria error message */
39
+ 'aria-errormessage'?: string;
40
+ /** Optional data for the editor */
41
+ data?: {
42
+ /** Optional mentions */
43
+ mentions?: IMentions;
44
+ /** Optional data about the first link, to be displayed in the EnrichedUrl component */
45
+ link?: IEnrichedUrlData;
46
+ };
47
+ }
48
+ export interface IRTEInitialState {
49
+ editorKey: string | null;
50
+ originalValue: string | null;
51
+ initialValue: Descendant[] | null;
52
+ tabbableOption: string;
53
+ openTooltip: string | null;
54
+ showLinkEditor: boolean;
55
+ mentionPopover: IMentionPopOver;
56
+ lastAnchor: Point | null;
57
+ stringValue: string;
58
+ lastKey: string | null;
59
+ hasInteracted: boolean;
60
+ hasLoaded: boolean;
61
+ enrichedUrl: IEnrichedUrlData | false | undefined;
62
+ }
63
+ export interface IRTEReducer {
64
+ type: keyof IRTEInitialState;
65
+ value: any;
66
+ }
4
67
  export declare enum Formatting {
5
68
  blockquote = "block_quote",
6
69
  bold = "bold",
package/helpers/intl.d.ts CHANGED
@@ -127,6 +127,8 @@ export declare const checkIntlPathExists: (path: string, language?: {
127
127
  discussionFormCard_overlay_text: string;
128
128
  discussionFormCard_overlay_cta_discard: string;
129
129
  discussionFormCard_overlay_cta_continue: string;
130
+ discussion_form_postType_label: string;
131
+ 'discussion_form__postType_no-category': string;
130
132
  discussion_form_title: string;
131
133
  discussion_form_titleField_label: string;
132
134
  discussion_form_titleField_placeholder: string;
@@ -286,6 +288,9 @@ export declare const checkIntlPathExists: (path: string, language?: {
286
288
  richTextEditor_link_edit: string;
287
289
  richTextEditor_link_remove: string;
288
290
  richTextEditor_link_button: string;
291
+ richTextEditor_link_enrichedUrl_aria: string;
292
+ richTextEditor_link_enrichedUrl_aria_fallback: string;
293
+ richTextEditor_link_enrichedUrl_aria_live: string;
289
294
  richTextEditor_ol_list: string;
290
295
  richTextEditor_ul_list: string;
291
296
  richTextEditor_block_quote: string;