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

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 (29) hide show
  1. package/accessibility/visually-hidden/visually-hidden.d.ts +18 -0
  2. package/discussion/components/likes/likes.d.ts +0 -1
  3. package/form/components/rich-text-editor/components/context/context.d.ts +2 -0
  4. package/form/components/rich-text-editor/components/toolbar/components/block-option/index.d.ts +1 -0
  5. package/form/components/rich-text-editor/components/toolbar/components/link-editor/link-editor.helpers.d.ts +2 -2
  6. package/form/components/rich-text-editor/components/toolbar/components/mark-option/mark-option.helpers.d.ts +2 -0
  7. package/form/components/rich-text-editor/components/toolbar/index.d.ts +1 -1
  8. package/form/components/rich-text-editor/helpers/ast-types/ast-types.d.ts +156 -0
  9. package/form/components/rich-text-editor/helpers/ast-types/index.d.ts +1 -0
  10. package/form/components/rich-text-editor/helpers/deserialize/deserialize.d.ts +3 -0
  11. package/form/components/rich-text-editor/helpers/deserialize/index.d.ts +1 -0
  12. package/form/components/rich-text-editor/helpers/hot-keys/hot-keys.d.ts +4 -0
  13. package/form/components/rich-text-editor/helpers/hot-keys/index.d.ts +1 -0
  14. package/form/components/rich-text-editor/helpers/index.d.ts +5 -0
  15. package/form/components/rich-text-editor/helpers/serialize/index.d.ts +1 -0
  16. package/form/components/rich-text-editor/helpers/serialize/serialize.d.ts +8 -0
  17. package/form/components/rich-text-editor/helpers/transform/index.d.ts +1 -0
  18. package/form/components/rich-text-editor/helpers/transform/transform.d.ts +21 -0
  19. package/form/components/rich-text-editor/plugins/with-linlines/with-inlines.d.ts +1 -1
  20. package/general/link/link.d.ts +4 -0
  21. package/helpers/intl.d.ts +1 -0
  22. package/index.js +54 -58
  23. package/index.mjs +6033 -5913
  24. package/package.json +1 -2
  25. package/style.css +1 -1
  26. package/styles/base/_links.scss +12 -3
  27. package/styles/base/buttons/_icons.scss +2 -0
  28. package/text/markdown-text/components/span/span.d.ts +2 -1
  29. package/form/components/rich-text-editor/rich-text-editor.helpers.d.ts +0 -5
@@ -8,21 +8,39 @@ interface Props {
8
8
  children: React.ReactNode | JSX.Element | string;
9
9
  /** An `href`, for links */
10
10
  href?: string;
11
+ /** An `onBlur`, for buttons */
12
+ onBlur?: (e: React.FocusEvent) => void;
11
13
  /** An `onClick`, for buttons */
12
14
  onClick?: (e: React.MouseEvent) => void;
15
+ /** An `onFocus`, for buttons */
16
+ onFocus?: (e: React.FocusEvent) => void;
17
+ /** An `onKeyDown`, for buttons */
18
+ onKeyDown?: (e: React.KeyboardEvent) => void;
13
19
  /** `for`, for labels */
14
20
  htmlFor?: string;
15
21
  /** Additional classes */
16
22
  className?: string;
23
+ /** Additional aria props */
24
+ 'aria-expanded'?: boolean;
25
+ 'aria-controls'?: string;
17
26
  }
18
27
  declare const _default: React.MemoExoticComponent<({ element, showOnFocus, children, className, ...props }: Props) => React.DetailedReactHTMLElement<{
19
28
  className: string;
20
29
  children: React.ReactNode | JSX.Element;
21
30
  /** An `href`, for links */
22
31
  href?: string | undefined;
32
+ /** An `onBlur`, for buttons */
33
+ onBlur?: ((e: React.FocusEvent<Element, Element>) => void) | undefined;
23
34
  /** An `onClick`, for buttons */
24
35
  onClick?: ((e: React.MouseEvent<Element, MouseEvent>) => void) | undefined;
36
+ /** An `onFocus`, for buttons */
37
+ onFocus?: ((e: React.FocusEvent<Element, Element>) => void) | undefined;
38
+ /** An `onKeyDown`, for buttons */
39
+ onKeyDown?: ((e: React.KeyboardEvent<Element>) => void) | undefined;
25
40
  /** `for`, for labels */
26
41
  htmlFor?: string | undefined;
42
+ /** Additional aria props */
43
+ 'aria-expanded'?: boolean | undefined;
44
+ 'aria-controls'?: string | undefined;
27
45
  }, HTMLElement>>;
28
46
  export default _default;
@@ -31,6 +31,5 @@ declare const Likes: ({ element, likes, peopleWhoLiked, isShort, userLiked, cont
31
31
  onKeyDown: (e: React.KeyboardEvent<HTMLElement>) => void;
32
32
  onMouseEnter: () => void;
33
33
  onMouseLeave: () => void;
34
- onBlur: () => void;
35
34
  }, HTMLElement>;
36
35
  export default Likes;
@@ -13,6 +13,8 @@ declare const RichTextEditorContext: import("react").Context<{
13
13
  showLinkEditor: boolean;
14
14
  /** The last anchor point (used for Slate to know where the cursor is) */
15
15
  lastAnchor: Point | null;
16
+ /** The current selection */
17
+ domSelection: Selection | null;
16
18
  /** The function to update the state */
17
19
  dispatch: Dispatch<any>;
18
20
  }>;
@@ -1 +1,2 @@
1
1
  export { default as BlockOption } from './block-option';
2
+ export * from './block-option.helpers';
@@ -1,5 +1,5 @@
1
1
  import { BaseEditor } from 'slate';
2
2
  export declare const isLinkActive: (editor: BaseEditor) => boolean;
3
- export declare const insertLink: (editor: BaseEditor, url: string) => void;
4
- export declare const wrapLink: (editor: BaseEditor, url: string) => void;
3
+ export declare const insertLink: (editor: BaseEditor, url: string, id: string) => void;
4
+ export declare const wrapLink: (editor: BaseEditor, url: string, id: string) => void;
5
5
  export declare const unwrapLink: (editor: BaseEditor) => void;
@@ -1,3 +1,5 @@
1
1
  import { BaseEditor } from 'slate';
2
+ import { MarkOptionType } from '../../../../../../../form/components/rich-text-editor/rich-text-editor.types';
3
+ export declare const isMarkOptionType: (value: string) => value is MarkOptionType;
2
4
  export declare const isMarkActive: (editor: BaseEditor, format: string) => boolean;
3
5
  export declare const toggleMark: (editor: BaseEditor, format: string) => void;
@@ -1,3 +1,3 @@
1
1
  export { default as Toolbar } from './toolbar';
2
2
  export * from './toolbar.data';
3
- export { toggleMark, wrapLink } from './components';
3
+ export { isMarkOptionType, toggleBlock, toggleMark, wrapLink } from './components';
@@ -0,0 +1,156 @@
1
+ export interface NodeTypes {
2
+ paragraph: string;
3
+ block_quote: string;
4
+ code_block: string;
5
+ link: string;
6
+ ul_list: string;
7
+ ol_list: string;
8
+ listItem: string;
9
+ heading: {
10
+ 1: string;
11
+ 2: string;
12
+ 3: string;
13
+ 4: string;
14
+ 5: string;
15
+ 6: string;
16
+ };
17
+ emphasis_mark: string;
18
+ strong_mark: string;
19
+ delete_mark: string;
20
+ inline_code_mark: string;
21
+ thematic_break: string;
22
+ image: string;
23
+ }
24
+ export type MdastNodeType = 'paragraph' | 'heading' | 'list' | 'listItem' | 'link' | 'image' | 'blockquote' | 'code' | 'html' | 'emphasis' | 'strong' | 'delete' | 'inlineCode' | 'thematicBreak' | 'text';
25
+ export declare const defaultNodeTypes: NodeTypes;
26
+ export interface LeafType {
27
+ text: string;
28
+ strikeThrough?: boolean;
29
+ bold?: boolean;
30
+ italic?: boolean;
31
+ code?: boolean;
32
+ parentType?: string;
33
+ }
34
+ export interface BlockType {
35
+ type: string;
36
+ parentType?: string;
37
+ link?: string;
38
+ caption?: string;
39
+ language?: string;
40
+ break?: boolean;
41
+ children: Array<BlockType | LeafType>;
42
+ }
43
+ export interface InputNodeTypes {
44
+ paragraph: string;
45
+ block_quote: string;
46
+ code_block: string;
47
+ link: string;
48
+ ul_list: string;
49
+ ol_list: string;
50
+ listItem: string;
51
+ heading: {
52
+ 1: string;
53
+ 2: string;
54
+ 3: string;
55
+ 4: string;
56
+ 5: string;
57
+ 6: string;
58
+ };
59
+ emphasis_mark: string;
60
+ strong_mark: string;
61
+ delete_mark: string;
62
+ inline_code_mark: string;
63
+ thematic_break: string;
64
+ image: string;
65
+ }
66
+ type RecursivePartial<T> = {
67
+ [P in keyof T]?: RecursivePartial<T[P]>;
68
+ };
69
+ export interface OptionType<T extends InputNodeTypes = InputNodeTypes> {
70
+ nodeTypes?: RecursivePartial<T>;
71
+ linkDestinationKey?: string;
72
+ imageSourceKey?: string;
73
+ imageCaptionKey?: string;
74
+ }
75
+ export interface MdastNode {
76
+ type?: MdastNodeType;
77
+ ordered?: boolean;
78
+ value?: string;
79
+ text?: string;
80
+ children?: Array<MdastNode>;
81
+ depth?: 1 | 2 | 3 | 4 | 5 | 6;
82
+ url?: string;
83
+ alt?: string;
84
+ lang?: string;
85
+ position?: any;
86
+ spread?: any;
87
+ checked?: any;
88
+ indent?: any;
89
+ }
90
+ export type TextNode = {
91
+ text?: string | undefined;
92
+ };
93
+ export type CodeBlockNode<T extends InputNodeTypes> = {
94
+ type: T['code_block'];
95
+ language: string | undefined;
96
+ children: Array<TextNode>;
97
+ };
98
+ export type HeadingNode<T extends InputNodeTypes> = {
99
+ type: T['heading'][1] | T['heading'][2] | T['heading'][3] | T['heading'][4] | T['heading'][5] | T['heading'][6];
100
+ children: Array<DeserializedNode<T>>;
101
+ };
102
+ export type ListNode<T extends InputNodeTypes> = {
103
+ type: T['ol_list'] | T['ul_list'];
104
+ children: Array<DeserializedNode<T>>;
105
+ };
106
+ export type ListItemNode<T extends InputNodeTypes> = {
107
+ type: T['listItem'];
108
+ children: Array<DeserializedNode<T>>;
109
+ };
110
+ export type ParagraphNode<T extends InputNodeTypes> = {
111
+ type: T['paragraph'];
112
+ break?: true;
113
+ children: Array<DeserializedNode<T>>;
114
+ };
115
+ export type LinkNode<T extends InputNodeTypes> = {
116
+ type: T['link'];
117
+ children: Array<DeserializedNode<T>>;
118
+ [urlKey: string]: string | undefined | Array<DeserializedNode<T>>;
119
+ };
120
+ export type ImageNode<T extends InputNodeTypes> = {
121
+ type: T['image'];
122
+ children: Array<DeserializedNode<T>>;
123
+ [sourceOrCaptionKey: string]: string | undefined | Array<DeserializedNode<T>>;
124
+ };
125
+ export type BlockQuoteNode<T extends InputNodeTypes> = {
126
+ type: T['block_quote'];
127
+ children: Array<DeserializedNode<T>>;
128
+ };
129
+ export type InlineCodeMarkNode<T extends InputNodeTypes> = {
130
+ type: T['inline_code_mark'];
131
+ children: Array<TextNode>;
132
+ language: string | undefined;
133
+ };
134
+ export type ThematicBreakNode<T extends InputNodeTypes> = {
135
+ type: T['thematic_break'];
136
+ children: Array<DeserializedNode<T>>;
137
+ };
138
+ export type ItalicNode<T extends InputNodeTypes> = {
139
+ [K in T['emphasis_mark']]: true;
140
+ } & {
141
+ children: TextNode;
142
+ };
143
+ export type BoldNode = {
144
+ bold: true;
145
+ children: TextNode;
146
+ };
147
+ export type StrikeThoughNode = {
148
+ strikeThrough: true;
149
+ children: TextNode;
150
+ };
151
+ export type InlineCodeNode = {
152
+ code: true;
153
+ text: string | undefined;
154
+ };
155
+ export type DeserializedNode<T extends InputNodeTypes> = CodeBlockNode<T> | HeadingNode<T> | ListNode<T> | ListItemNode<T> | ParagraphNode<T> | LinkNode<T> | ImageNode<T> | BlockQuoteNode<T> | InlineCodeMarkNode<T> | ThematicBreakNode<T> | ItalicNode<T> | BoldNode | StrikeThoughNode | InlineCodeNode | TextNode;
156
+ export {};
@@ -0,0 +1 @@
1
+ export * from './ast-types';
@@ -0,0 +1,3 @@
1
+ import { Descendant } from 'slate';
2
+ declare const deserialize: (node: string, callback?: (v: Descendant[]) => void) => void;
3
+ export default deserialize;
@@ -0,0 +1 @@
1
+ export { default as deserialize } from './deserialize';
@@ -0,0 +1,4 @@
1
+ declare const HOTKEYS: {
2
+ [key: string]: string;
3
+ };
4
+ export default HOTKEYS;
@@ -0,0 +1 @@
1
+ export { default as HOTKEYS } from './hot-keys';
@@ -0,0 +1,5 @@
1
+ export * from './ast-types';
2
+ export * from './deserialize';
3
+ export * from './hot-keys';
4
+ export * from './serialize';
5
+ export * from './transform';
@@ -0,0 +1 @@
1
+ export { default as serialize } from './serialize';
@@ -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
+ };
@@ -1,5 +1,5 @@
1
1
  import { BaseEditor } from 'slate';
2
2
  import { HistoryEditor } from 'slate-history';
3
3
  import { ReactEditor } from 'slate-react';
4
- declare const withInlines: (editor: BaseEditor & ReactEditor & HistoryEditor) => BaseEditor & ReactEditor & HistoryEditor;
4
+ declare const withInlines: (editor: BaseEditor & ReactEditor & HistoryEditor, id: string) => BaseEditor & ReactEditor & HistoryEditor;
5
5
  export default withInlines;
@@ -12,12 +12,16 @@ interface Props {
12
12
  onClick?: ((e?: React.MouseEvent<HTMLElement>) => void) | undefined;
13
13
  /** Function to be called when focused */
14
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;
15
17
  /** GTM event context */
16
18
  gtmContext?: string;
17
19
  /** GTM event type */
18
20
  gtmType?: string;
19
21
  /** Target for link */
20
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;
21
25
  /** Whether link should be disabled */
22
26
  disabled?: boolean;
23
27
  /** An ARIA label for the link */
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;