@apolitical/component-library 4.1.0-beta.0 → 4.1.0-beta.3

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,4 +1,3 @@
1
- import React from 'react';
2
1
  import { DiscussionCreateContentFunction, IDiscussionContent } from './../../discussion';
3
2
  export interface IDiscussionForm {
4
3
  /** Information about the content being created/edited */
@@ -20,8 +19,6 @@ export interface IDiscussionForm {
20
19
  /** Whether the success message should show on a successful submit */
21
20
  showSuccessMessage?: boolean;
22
21
  };
23
- /** The `ref` for the input, if we need to have control over it in the parent */
24
- editorRef?: React.MutableRefObject<string | null>;
25
22
  /** The placeholder text - this defaults to the intl text */
26
23
  placeholder?: string;
27
24
  /** The maximum number of characters */
@@ -50,5 +47,5 @@ export interface IDiscussionForm {
50
47
  /** The language to use for the text */
51
48
  locale?: string;
52
49
  }
53
- declare const Form: ({ content, userHasPermissions, meta, editorRef, placeholder, maxLength, forceShow, functions, gtmContext, }: IDiscussionForm) => import("react/jsx-runtime").JSX.Element;
50
+ declare const Form: ({ content, userHasPermissions, meta, placeholder, maxLength, forceShow, functions, gtmContext, }: IDiscussionForm) => import("react/jsx-runtime").JSX.Element;
54
51
  export default Form;
@@ -1,3 +1,4 @@
1
+ import React from 'react';
1
2
  import { MemberProps } from '../../../user';
2
3
  import { IDiscussionContent } from './../../discussion';
3
4
  interface Props {
@@ -25,5 +26,11 @@ interface Props {
25
26
  /** The language to use for the text */
26
27
  locale?: string;
27
28
  }
28
- declare const Likes: ({ element, likes, peopleWhoLiked, isShort, userLiked, content, canLike, functions: { createLike, deleteLike }, }: Props) => import("react/jsx-runtime").JSX.Element;
29
+ declare const Likes: ({ element, likes, peopleWhoLiked, isShort, userLiked, content, canLike, functions: { createLike, deleteLike }, }: Props) => React.DetailedReactHTMLElement<{
30
+ className: string;
31
+ onKeyDown: (e: React.KeyboardEvent<HTMLElement>) => void;
32
+ onMouseEnter: () => void;
33
+ onMouseLeave: () => void;
34
+ onBlur: () => void;
35
+ }, HTMLElement>;
29
36
  export default Likes;
@@ -1,3 +1,3 @@
1
1
  import { IFormProps } from './form.types';
2
- declare const Form: ({ 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, gtm, functions: { onSuccess, onCancel, onCatch, onFailure, }, ...props }: IFormProps) => import("react/jsx-runtime").JSX.Element | null;
3
3
  export default Form;
@@ -174,6 +174,8 @@ export interface IFormProps {
174
174
  secondaryActionButton?: FormCancelButtonPropsType;
175
175
  /** The classes to add to the form */
176
176
  className?: string;
177
+ /** The type of element to render. This is in case we need to render a separate form inside the first, e.g. rendering the link form on the rich text editor inside the discussion form. */
178
+ element?: 'form' | 'fieldset';
177
179
  /** The fields to render in the form */
178
180
  fields: IField[];
179
181
  /** An optional `ref` for the form, in case we need to interact with it in another file */
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import { Dispatch } from 'react';
2
2
  import { Point } from 'slate';
3
3
  declare const RichTextEditorContext: import("react").Context<{
4
4
  /** The id of the editor */
@@ -9,15 +9,11 @@ declare const RichTextEditorContext: import("react").Context<{
9
9
  setFocus: (option: string | null) => void;
10
10
  /** The tooltip that is currently open */
11
11
  openTooltip: string | null;
12
- /** The function to set the open tooltip */
13
- setOpenTooltip: (option: string | null) => void;
14
12
  /** Whether the link editor is open */
15
13
  showLinkEditor: boolean;
16
- /** The function to set the link editor */
17
- setShowLinkEditor: (open: boolean) => void;
18
14
  /** The last anchor point (used for Slate to know where the cursor is) */
19
15
  lastAnchor: Point | null;
20
- /** The function to set the last anchor */
21
- setLastAnchor: (anchor: Point | null) => void;
16
+ /** The function to update the state */
17
+ dispatch: Dispatch<any>;
22
18
  }>;
23
19
  export default RichTextEditorContext;
@@ -1,4 +1,3 @@
1
- import React from 'react';
2
1
  interface Props {
3
2
  /** The id of the rich text editor */
4
3
  id?: string;
@@ -15,5 +14,5 @@ interface Props {
15
14
  /** Optional aria error message */
16
15
  'aria-errormessage'?: string;
17
16
  }
18
- declare const RichTextEditor: React.ForwardRefExoticComponent<Props & React.RefAttributes<string | null>>;
17
+ declare const RichTextEditor: ({ id, value, placeholder, onChange, autoFocus, ...props }: Props) => import("react/jsx-runtime").JSX.Element | null;
19
18
  export default RichTextEditor;
@@ -28,6 +28,12 @@ export interface ButtonPropsType {
28
28
  element?: string;
29
29
  /** The function the button should run when clicked */
30
30
  onClick?: false | ((e: React.MouseEvent<HTMLElement>) => void);
31
+ /** An optional function to call on focus */
32
+ onFocus?: () => void;
33
+ /** An optional function to call on blur */
34
+ onBlur?: () => void;
35
+ /** An optional function to call on keydown */
36
+ onKeyDown?: (e: React.KeyboardEvent<HTMLElement>) => void;
31
37
  /** Additional classes to add to the button */
32
38
  className?: string;
33
39
  /** `disabled` is usually true or false, but we will want nuance in some places, for example the ability
@@ -61,6 +67,6 @@ export interface ButtonPropsType {
61
67
  'data-testid'?: string;
62
68
  }
63
69
  declare const Button: ({ variant, size, styling, icon, href, element, onClick, className, disabled, screenreaderText, children, ...rest }: ButtonPropsType) => React.DOMElement<{
64
- [key: string]: string | boolean | addClasses.ArgumentArray | ((e: React.MouseEvent<HTMLElement>) => void) | React.RefObject<HTMLButtonElement>;
70
+ [key: string]: string | boolean | addClasses.ArgumentArray | (() => void) | ((e: React.KeyboardEvent<HTMLElement>) => void) | ((e: React.MouseEvent<HTMLElement>) => void) | React.RefObject<HTMLButtonElement>;
65
71
  }, Element>;
66
72
  export default Button;
@@ -10,6 +10,8 @@ interface Props {
10
10
  className?: string;
11
11
  /** Function to be called when clicked */
12
12
  onClick?: ((e?: React.MouseEvent<HTMLElement>) => void) | undefined;
13
+ /** Function to be called when focused */
14
+ onFocus?: ((e?: React.FocusEvent<HTMLElement>) => void) | undefined;
13
15
  /** GTM event context */
14
16
  gtmContext?: string;
15
17
  /** GTM event type */
@@ -30,6 +30,8 @@ interface Props {
30
30
  };
31
31
  /** Whether the tooltip is hidden from screen readers or not */
32
32
  'aria-hidden'?: boolean;
33
+ /** The id of the tooltip */
34
+ id?: string;
33
35
  }
34
36
  declare const Tooltip: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLElement | null>>;
35
37
  export default Tooltip;