@apolitical/component-library 4.0.6 → 4.1.0-beta.10
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/accessibility/visually-hidden/visually-hidden.d.ts +19 -1
- package/discussion/components/form/form.d.ts +3 -6
- package/discussion/components/likes/likes.d.ts +7 -1
- package/form/components/form/components/field-wrapper/field-wrapper.d.ts +1 -1
- package/form/components/form/components/fields/checkbox/checkbox.d.ts +4 -0
- package/form/components/form/components/fields/input/input.d.ts +4 -0
- package/form/components/form/form.d.ts +1 -1
- package/form/components/form/form.types.d.ts +11 -1
- package/form/components/index.d.ts +1 -0
- package/form/components/rich-text-editor/components/context/context.d.ts +19 -0
- package/form/components/rich-text-editor/components/context/index.d.ts +1 -0
- package/form/components/rich-text-editor/components/editor/element/element.d.ts +3 -0
- package/form/components/rich-text-editor/components/editor/element/index.d.ts +1 -0
- package/form/components/rich-text-editor/components/editor/index.d.ts +2 -0
- package/form/components/rich-text-editor/components/editor/leaf/index.d.ts +1 -0
- package/form/components/rich-text-editor/components/editor/leaf/leaf.d.ts +3 -0
- package/form/components/rich-text-editor/components/index.d.ts +3 -0
- package/form/components/rich-text-editor/components/toolbar/components/block-option/block-option.d.ts +3 -0
- package/form/components/rich-text-editor/components/toolbar/components/block-option/block-option.helpers.d.ts +3 -0
- package/form/components/rich-text-editor/components/toolbar/components/block-option/index.d.ts +2 -0
- package/form/components/rich-text-editor/components/toolbar/components/index.d.ts +4 -0
- package/form/components/rich-text-editor/components/toolbar/components/link-editor/index.d.ts +2 -0
- package/form/components/rich-text-editor/components/toolbar/components/link-editor/link-editor.d.ts +2 -0
- package/form/components/rich-text-editor/components/toolbar/components/link-editor/link-editor.helpers.d.ts +5 -0
- package/form/components/rich-text-editor/components/toolbar/components/link-option/index.d.ts +1 -0
- package/form/components/rich-text-editor/components/toolbar/components/link-option/link-option.d.ts +2 -0
- package/form/components/rich-text-editor/components/toolbar/components/mark-option/index.d.ts +2 -0
- package/form/components/rich-text-editor/components/toolbar/components/mark-option/mark-option.d.ts +3 -0
- package/form/components/rich-text-editor/components/toolbar/components/mark-option/mark-option.helpers.d.ts +5 -0
- package/form/components/rich-text-editor/components/toolbar/components/option/index.d.ts +1 -0
- package/form/components/rich-text-editor/components/toolbar/components/option/option.d.ts +15 -0
- package/form/components/rich-text-editor/components/toolbar/index.d.ts +3 -0
- package/form/components/rich-text-editor/components/toolbar/toolbar.d.ts +4 -0
- package/form/components/rich-text-editor/components/toolbar/toolbar.data.d.ts +3 -0
- package/form/components/rich-text-editor/helpers/ast-types/ast-types.d.ts +156 -0
- package/form/components/rich-text-editor/helpers/ast-types/index.d.ts +1 -0
- package/form/components/rich-text-editor/helpers/deserialize/deserialize.d.ts +3 -0
- package/form/components/rich-text-editor/helpers/deserialize/index.d.ts +1 -0
- package/form/components/rich-text-editor/helpers/helpers.data.d.ts +97 -0
- package/form/components/rich-text-editor/helpers/hot-keys/hot-keys.d.ts +4 -0
- package/form/components/rich-text-editor/helpers/hot-keys/index.d.ts +1 -0
- package/form/components/rich-text-editor/helpers/index.d.ts +5 -0
- package/form/components/rich-text-editor/helpers/serialize/do-serialize.d.ts +3 -0
- package/form/components/rich-text-editor/helpers/serialize/index.d.ts +2 -0
- package/form/components/rich-text-editor/helpers/serialize/serialize.d.ts +8 -0
- package/form/components/rich-text-editor/helpers/transform/index.d.ts +1 -0
- package/form/components/rich-text-editor/helpers/transform/transform.d.ts +21 -0
- package/form/components/rich-text-editor/hooks/index.d.ts +2 -0
- package/form/components/rich-text-editor/hooks/use-positioned-element/index.d.ts +1 -0
- package/form/components/rich-text-editor/hooks/use-positioned-element/use-positioned-element.d.ts +4 -0
- package/form/components/rich-text-editor/hooks/use-selected-link/index.d.ts +1 -0
- package/form/components/rich-text-editor/hooks/use-selected-link/use-selected-link.d.ts +6 -0
- package/form/components/rich-text-editor/index.d.ts +1 -0
- package/form/components/rich-text-editor/plugins/index.d.ts +1 -0
- package/form/components/rich-text-editor/plugins/with-linlines/index.d.ts +1 -0
- package/form/components/rich-text-editor/plugins/with-linlines/with-inlines.d.ts +5 -0
- package/form/components/rich-text-editor/rich-text-editor.d.ts +18 -0
- package/form/components/rich-text-editor/rich-text-editor.types.d.ts +24 -0
- package/general/buttons/button/button.d.ts +7 -1
- package/general/buttons/button-wrapper/button-wrapper.d.ts +5 -1
- package/general/index.d.ts +1 -0
- package/general/link/link.d.ts +6 -0
- package/general/portal/index.d.ts +1 -0
- package/general/portal/portal.d.ts +5 -0
- package/general/tooltip/tooltip.d.ts +27 -1
- package/helpers/intl.d.ts +17 -0
- package/helpers/validation.d.ts +1 -1
- package/index.js +116 -21
- package/index.mjs +19386 -5809
- package/package.json +11 -3
- package/style.css +1 -1
- package/styles/base/_accessibility.scss +5 -0
- package/styles/base/_links.scss +12 -3
- package/styles/base/form/_fields.scss +1 -1
- package/styles/variables/colors/theme/_form.scss +10 -0
- package/testing/__mocks__/remark-parse.d.ts +2 -0
- package/testing/__mocks__/unified.d.ts +6 -0
- package/text/markdown-text/components/span/span.d.ts +2 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BlockType, LeafType, NodeTypes } from './../ast-types';
|
|
2
|
+
interface Options {
|
|
3
|
+
nodeTypes: NodeTypes;
|
|
4
|
+
listDepth?: number;
|
|
5
|
+
ignoreParagraphNewline?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export default function serialize(chunk: BlockType | LeafType, opts?: Options): string | undefined;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as transform } from './transform';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { BlockQuoteNode, CodeBlockNode, HeadingNode, ImageNode, InputNodeTypes, ItalicNode, LinkNode, ListItemNode, ListNode, MdastNode, OptionType, ParagraphNode, ThematicBreakNode } from './../ast-types';
|
|
2
|
+
export default function transform<T extends InputNodeTypes>(node: MdastNode, opts?: OptionType<T>): CodeBlockNode<T> | HeadingNode<T> | ListNode<T> | ListItemNode<T> | ParagraphNode<T> | LinkNode<T> | ImageNode<T> | BlockQuoteNode<T> | ThematicBreakNode<T> | ItalicNode<T> | {
|
|
3
|
+
type: string;
|
|
4
|
+
children: {
|
|
5
|
+
text: string;
|
|
6
|
+
}[];
|
|
7
|
+
} | {
|
|
8
|
+
value?: string | undefined;
|
|
9
|
+
position?: any;
|
|
10
|
+
url?: string | undefined;
|
|
11
|
+
alt?: string | undefined;
|
|
12
|
+
checked?: any;
|
|
13
|
+
ordered?: boolean | undefined;
|
|
14
|
+
depth?: 1 | 2 | 3 | 4 | 5 | 6 | undefined;
|
|
15
|
+
lang?: string | undefined;
|
|
16
|
+
spread?: any;
|
|
17
|
+
indent?: any;
|
|
18
|
+
text: string | undefined;
|
|
19
|
+
type?: undefined;
|
|
20
|
+
children?: undefined;
|
|
21
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as usePositionedElement } from './use-positioned-element';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as useSelectedLink } from './use-selected-link';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as RichTextEditor } from './rich-text-editor';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './with-linlines';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as withInlines } from './with-inlines';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { BaseEditor } from 'slate';
|
|
2
|
+
import { HistoryEditor } from 'slate-history';
|
|
3
|
+
import { ReactEditor } from 'slate-react';
|
|
4
|
+
declare const withInlines: (editor: BaseEditor & ReactEditor & HistoryEditor, id: string) => BaseEditor & ReactEditor & HistoryEditor;
|
|
5
|
+
export default withInlines;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
/** The id of the rich text editor */
|
|
3
|
+
id?: string;
|
|
4
|
+
/** The default value of the rich text editor */
|
|
5
|
+
value?: string;
|
|
6
|
+
/** The placeholder text of the rich text editor */
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
/** An optional event handler, called when the rich text editor is changed */
|
|
9
|
+
onChange?: (value: string) => void;
|
|
10
|
+
/** Optional autoFocus */
|
|
11
|
+
autoFocus?: boolean;
|
|
12
|
+
/** Optional aria invalid */
|
|
13
|
+
'aria-invalid'?: boolean;
|
|
14
|
+
/** Optional aria error message */
|
|
15
|
+
'aria-errormessage'?: string;
|
|
16
|
+
}
|
|
17
|
+
declare const RichTextEditor: ({ id, value, placeholder, onChange, autoFocus, ...props }: Props) => import("react/jsx-runtime").JSX.Element | null;
|
|
18
|
+
export default RichTextEditor;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { BaseElement, BaseText, Descendant } from 'slate';
|
|
2
|
+
export interface BaseProps {
|
|
3
|
+
className?: string;
|
|
4
|
+
[key: string]: unknown;
|
|
5
|
+
}
|
|
6
|
+
export type BlockOptionType = 'block_quote' | 'link' | 'list_item' | 'ol_list' | 'ul_list' | 'paragraph' | 'span';
|
|
7
|
+
export interface TypeElement extends BaseElement {
|
|
8
|
+
type: BlockOptionType;
|
|
9
|
+
}
|
|
10
|
+
export type MarkOptionType = 'bold' | 'italic' | 'strikeThrough';
|
|
11
|
+
export interface TypeText extends BaseText {
|
|
12
|
+
bold?: boolean;
|
|
13
|
+
italic?: boolean;
|
|
14
|
+
strikeThrough?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export type OptionTypes = {
|
|
17
|
+
format: BlockOptionType | MarkOptionType;
|
|
18
|
+
hasDivider?: boolean;
|
|
19
|
+
};
|
|
20
|
+
export type LinkElement = {
|
|
21
|
+
type: 'link';
|
|
22
|
+
link: string;
|
|
23
|
+
children: Descendant[];
|
|
24
|
+
};
|
|
@@ -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;
|
|
@@ -3,10 +3,14 @@ import { ButtonPropsType } from './../button';
|
|
|
3
3
|
interface Props {
|
|
4
4
|
/** The props for each button */
|
|
5
5
|
buttons: ButtonPropsType[];
|
|
6
|
+
/** Optional props for each button's wrapper */
|
|
7
|
+
wrappers?: {
|
|
8
|
+
className?: string;
|
|
9
|
+
}[];
|
|
6
10
|
/** Additional classes */
|
|
7
11
|
className?: string;
|
|
8
12
|
}
|
|
9
|
-
declare const ButtonWrapper: ({ buttons, className, ...props }: Props) => React.DetailedReactHTMLElement<{
|
|
13
|
+
declare const ButtonWrapper: ({ buttons, wrappers, className, ...props }: Props) => React.DetailedReactHTMLElement<{
|
|
10
14
|
children: JSX.Element[];
|
|
11
15
|
className: string;
|
|
12
16
|
}, HTMLElement>;
|
package/general/index.d.ts
CHANGED
package/general/link/link.d.ts
CHANGED
|
@@ -10,12 +10,18 @@ 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;
|
|
15
|
+
/** Function to be called when key is pressed */
|
|
16
|
+
onKeyDown?: ((e?: React.KeyboardEvent<HTMLElement>) => void) | undefined;
|
|
13
17
|
/** GTM event context */
|
|
14
18
|
gtmContext?: string;
|
|
15
19
|
/** GTM event type */
|
|
16
20
|
gtmType?: string;
|
|
17
21
|
/** Target for link */
|
|
18
22
|
target?: '_blank' | '_self' | '_parent' | '_top';
|
|
23
|
+
/** The tab index of the link, e.g. in case we're setting up event handlers to move the focus on arrow press and want to remove the default tabability of the link */
|
|
24
|
+
tabIndex?: number;
|
|
19
25
|
/** Whether link should be disabled */
|
|
20
26
|
disabled?: boolean;
|
|
21
27
|
/** An ARIA label for the link */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Portal } from './portal';
|
|
@@ -1,11 +1,37 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
interface Props {
|
|
3
|
+
/** Optional styling */
|
|
4
|
+
styling?: {
|
|
5
|
+
/** Whether the tooltip has extra padding */
|
|
6
|
+
extraPadding?: boolean;
|
|
7
|
+
/** Whether the tooltip has a pointer */
|
|
8
|
+
hasPointer?: false | 'top' | 'bottom';
|
|
9
|
+
/** Whether the tooltip has a form */
|
|
10
|
+
hasForm?: boolean;
|
|
11
|
+
};
|
|
3
12
|
/** If the tooltip is open or not */
|
|
4
13
|
isOpen?: boolean;
|
|
5
14
|
/** If the content is loading or not */
|
|
6
15
|
isLoading?: boolean;
|
|
7
16
|
/** The content to show in the tooltip */
|
|
8
17
|
children?: React.ReactNode | JSX.Element | string;
|
|
18
|
+
/** Additional classes */
|
|
19
|
+
className?: string;
|
|
20
|
+
/** Optional functions */
|
|
21
|
+
functions?: {
|
|
22
|
+
onBlur?: () => void;
|
|
23
|
+
};
|
|
24
|
+
/** Optional callbacks */
|
|
25
|
+
callbacks?: {
|
|
26
|
+
/** The callback to fire when the tooltip is opened */
|
|
27
|
+
onOpen?: () => void;
|
|
28
|
+
/** The callback to fire when the tooltip is closed */
|
|
29
|
+
onClose?: () => void;
|
|
30
|
+
};
|
|
31
|
+
/** Whether the tooltip is hidden from screen readers or not */
|
|
32
|
+
'aria-hidden'?: boolean;
|
|
33
|
+
/** The id of the tooltip */
|
|
34
|
+
id?: string;
|
|
9
35
|
}
|
|
10
|
-
declare const Tooltip:
|
|
36
|
+
declare const Tooltip: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLElement | null>>;
|
|
11
37
|
export default Tooltip;
|
package/helpers/intl.d.ts
CHANGED
|
@@ -132,6 +132,7 @@ export declare const checkIntlPathExists: (path: string, language?: {
|
|
|
132
132
|
discussion_likes_more: string;
|
|
133
133
|
discussion_likes_like: string;
|
|
134
134
|
discussion_likes_unlike: string;
|
|
135
|
+
discussion_likes_show: string;
|
|
135
136
|
discussion_moreMenu_edit: string;
|
|
136
137
|
discussion_moreMenu_delete: string;
|
|
137
138
|
discussion_moreMenu_report: string;
|
|
@@ -219,6 +220,22 @@ export declare const checkIntlPathExists: (path: string, language?: {
|
|
|
219
220
|
ratings_low: string;
|
|
220
221
|
ratings_high: string;
|
|
221
222
|
ratings_success: string;
|
|
223
|
+
richTextEditor_placeholder: string;
|
|
224
|
+
richTextEditor_toolbar: string;
|
|
225
|
+
richTextEditor_bold: string;
|
|
226
|
+
richTextEditor_italic: string;
|
|
227
|
+
richTextEditor_strikeThrough: string;
|
|
228
|
+
richTextEditor_link: string;
|
|
229
|
+
richTextEditor_link_placeholder: string;
|
|
230
|
+
richTextEditor_link_error_required: string;
|
|
231
|
+
richTextEditor_link_open: string;
|
|
232
|
+
richTextEditor_link_open_text: string;
|
|
233
|
+
richTextEditor_link_edit: string;
|
|
234
|
+
richTextEditor_link_remove: string;
|
|
235
|
+
richTextEditor_link_button: string;
|
|
236
|
+
richTextEditor_ol_list: string;
|
|
237
|
+
richTextEditor_ul_list: string;
|
|
238
|
+
richTextEditor_block_quote: string;
|
|
222
239
|
search_label: string;
|
|
223
240
|
search_placeholder: string;
|
|
224
241
|
search_clear: string;
|
package/helpers/validation.d.ts
CHANGED