@jackuait/blok 0.1.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.
- package/LICENSE +190 -0
- package/README.md +23 -0
- package/dist/blok.mjs +5 -0
- package/dist/blok.umd.js +53 -0
- package/dist/bundle-6e604287.mjs +340 -0
- package/dist/codex-7de6c88e.mjs +15668 -0
- package/dist/vendor.LICENSE.txt +545 -0
- package/package.json +108 -0
- package/types/api/block.d.ts +87 -0
- package/types/api/blocks.d.ts +136 -0
- package/types/api/caret.d.ts +67 -0
- package/types/api/events.d.ts +28 -0
- package/types/api/i18n.d.ts +11 -0
- package/types/api/index.d.ts +17 -0
- package/types/api/inline-toolbar.d.ts +15 -0
- package/types/api/listeners.d.ts +32 -0
- package/types/api/notifier.d.ts +14 -0
- package/types/api/readonly.d.ts +17 -0
- package/types/api/sanitizer.d.ts +14 -0
- package/types/api/saver.d.ts +13 -0
- package/types/api/selection.d.ts +41 -0
- package/types/api/styles.d.ts +44 -0
- package/types/api/toolbar.d.ts +26 -0
- package/types/api/tools.d.ts +11 -0
- package/types/api/tooltip.d.ts +30 -0
- package/types/api/ui.d.ts +24 -0
- package/types/block-tunes/block-tune-data.d.ts +1 -0
- package/types/block-tunes/block-tune.d.ts +60 -0
- package/types/block-tunes/index.d.ts +1 -0
- package/types/configs/conversion-config.ts +26 -0
- package/types/configs/editor-config.d.ts +107 -0
- package/types/configs/i18n-config.d.ts +16 -0
- package/types/configs/i18n-dictionary.d.ts +93 -0
- package/types/configs/index.d.ts +7 -0
- package/types/configs/log-levels.d.ts +9 -0
- package/types/configs/paste-config.d.ts +38 -0
- package/types/configs/sanitizer-config.d.ts +43 -0
- package/types/data-formats/block-data.d.ts +23 -0
- package/types/data-formats/block-id.ts +4 -0
- package/types/data-formats/index.d.ts +2 -0
- package/types/data-formats/output-data.d.ts +46 -0
- package/types/events/block/Base.ts +11 -0
- package/types/events/block/BlockAdded.ts +21 -0
- package/types/events/block/BlockChanged.ts +21 -0
- package/types/events/block/BlockMoved.ts +26 -0
- package/types/events/block/BlockRemoved.ts +21 -0
- package/types/events/block/index.ts +44 -0
- package/types/index.d.ts +191 -0
- package/types/tools/adapters/base-tool-adapter.d.ts +76 -0
- package/types/tools/adapters/block-tool-adapter.d.ts +78 -0
- package/types/tools/adapters/block-tune-adapter.d.ts +14 -0
- package/types/tools/adapters/inline-tool-adapter.d.ts +10 -0
- package/types/tools/adapters/tool-factory.d.ts +5 -0
- package/types/tools/adapters/tool-type.ts +18 -0
- package/types/tools/adapters/tools-collection.d.ts +34 -0
- package/types/tools/block-tool-data.d.ts +5 -0
- package/types/tools/block-tool.d.ts +121 -0
- package/types/tools/hook-events.d.ts +23 -0
- package/types/tools/index.d.ts +16 -0
- package/types/tools/inline-tool.d.ts +37 -0
- package/types/tools/menu-config.d.ts +46 -0
- package/types/tools/paste-events.d.ts +52 -0
- package/types/tools/tool-config.d.ts +4 -0
- package/types/tools/tool-settings.d.ts +79 -0
- package/types/tools/tool.d.ts +65 -0
- package/types/utils/popover/hint.d.ts +29 -0
- package/types/utils/popover/index.d.ts +5 -0
- package/types/utils/popover/popover-event.ts +15 -0
- package/types/utils/popover/popover-item-type.ts +13 -0
- package/types/utils/popover/popover-item.d.ts +253 -0
- package/types/utils/popover/popover.d.ts +112 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event detail for tag substitution on paste
|
|
3
|
+
*/
|
|
4
|
+
export interface HTMLPasteEventDetail {
|
|
5
|
+
/**
|
|
6
|
+
* Pasted element
|
|
7
|
+
*/
|
|
8
|
+
data: HTMLElement;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Paste event for tag substitution
|
|
13
|
+
*/
|
|
14
|
+
export interface HTMLPasteEvent extends CustomEvent {
|
|
15
|
+
readonly detail: HTMLPasteEventDetail;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Event detail for file substitution on paste
|
|
20
|
+
*/
|
|
21
|
+
export interface FilePasteEventDetail {
|
|
22
|
+
/**
|
|
23
|
+
* Pasted file
|
|
24
|
+
*/
|
|
25
|
+
file: File;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface FilePasteEvent extends CustomEvent {
|
|
29
|
+
readonly detail: FilePasteEventDetail;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Event detail for pattern substitution on paste
|
|
34
|
+
*/
|
|
35
|
+
export interface PatternPasteEventDetail {
|
|
36
|
+
/**
|
|
37
|
+
* Pattern key
|
|
38
|
+
*/
|
|
39
|
+
key: string;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Pasted string
|
|
43
|
+
*/
|
|
44
|
+
data: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface PatternPasteEvent extends CustomEvent {
|
|
48
|
+
readonly detail: PatternPasteEventDetail;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export type PasteEvent = HTMLPasteEvent | FilePasteEvent | PatternPasteEvent;
|
|
52
|
+
export type PasteEventDetail = HTMLPasteEventDetail | FilePasteEventDetail | PatternPasteEventDetail;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { ToolConfig } from './tool-config';
|
|
2
|
+
import { ToolConstructable, BlockToolData, MenuConfig, MenuConfigItem } from './index';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Tool may specify its toolbox configuration
|
|
6
|
+
* It may include several entries as well
|
|
7
|
+
*/
|
|
8
|
+
export type ToolboxConfig = ToolboxConfigEntry | ToolboxConfigEntry[];
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Tool's Toolbox settings
|
|
12
|
+
*/
|
|
13
|
+
export interface ToolboxConfigEntry {
|
|
14
|
+
/**
|
|
15
|
+
* Tool title for Toolbox
|
|
16
|
+
*/
|
|
17
|
+
title?: string;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* HTML string with an icon for Toolbox
|
|
21
|
+
*/
|
|
22
|
+
icon?: string;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* May contain overrides for tool default data
|
|
26
|
+
*/
|
|
27
|
+
data?: BlockToolData
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Object passed to the Tool's constructor by {@link EditorConfig#tools}
|
|
32
|
+
*
|
|
33
|
+
* @template Config - the structure describing a config object supported by the tool
|
|
34
|
+
*/
|
|
35
|
+
export interface ExternalToolSettings<Config extends object = any> {
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Tool's class
|
|
39
|
+
*/
|
|
40
|
+
class: ToolConstructable;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* User configuration object that will be passed to the Tool's constructor
|
|
44
|
+
*/
|
|
45
|
+
config?: ToolConfig<Config>;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Is need to show Inline Toolbar.
|
|
49
|
+
* Can accept array of Tools for InlineToolbar or boolean.
|
|
50
|
+
*/
|
|
51
|
+
inlineToolbar?: boolean | string[];
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* BlockTunes for Tool
|
|
55
|
+
* Can accept array of tune names or boolean.
|
|
56
|
+
*/
|
|
57
|
+
tunes?: boolean | string[];
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Define shortcut that will render Tool
|
|
61
|
+
*/
|
|
62
|
+
shortcut?: string;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Tool's Toolbox settings
|
|
66
|
+
* It will be hidden from Toolbox when false is specified.
|
|
67
|
+
*/
|
|
68
|
+
toolbox?: ToolboxConfig | false;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* For internal Tools 'class' property is optional
|
|
73
|
+
*/
|
|
74
|
+
export type InternalToolSettings<Config extends object = any> = Omit<ExternalToolSettings<Config>, 'class'> & Partial<Pick<ExternalToolSettings<Config>, 'class'>>;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Union of external and internal Tools settings
|
|
78
|
+
*/
|
|
79
|
+
export type ToolSettings<Config extends object = any> = InternalToolSettings<Config> | ExternalToolSettings<Config>;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import {API} from '../index';
|
|
2
|
+
import {ToolConfig} from './tool-config';
|
|
3
|
+
import {SanitizerConfig} from '../configs';
|
|
4
|
+
import {MenuConfig} from './menu-config';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Abstract interface of all Tools
|
|
8
|
+
*/
|
|
9
|
+
export interface BaseTool<RenderReturnType = HTMLElement> {
|
|
10
|
+
/**
|
|
11
|
+
* Tool`s render method
|
|
12
|
+
*
|
|
13
|
+
* For Inline Tools returns {@link MenuConfig}
|
|
14
|
+
* @see https://editorjs.io/menu-config
|
|
15
|
+
*
|
|
16
|
+
* For Block Tools returns tool`s wrapper html element
|
|
17
|
+
*/
|
|
18
|
+
render(): RenderReturnType | Promise<RenderReturnType>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface BaseToolConstructorOptions<C extends object = any> {
|
|
22
|
+
/**
|
|
23
|
+
* Editor.js API
|
|
24
|
+
*/
|
|
25
|
+
api: API;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Tool configuration
|
|
29
|
+
*/
|
|
30
|
+
config?: ToolConfig<C>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface BaseToolConstructable {
|
|
34
|
+
/**
|
|
35
|
+
* Define Tool type as Inline
|
|
36
|
+
*/
|
|
37
|
+
isInline?: boolean;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Tool`s sanitizer configuration
|
|
41
|
+
*/
|
|
42
|
+
sanitize?: SanitizerConfig;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Shortcut for Tool
|
|
46
|
+
*/
|
|
47
|
+
shortcut?: string;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Title of Inline Tool.
|
|
51
|
+
* @deprecated use {@link MenuConfig} item title instead
|
|
52
|
+
*/
|
|
53
|
+
title?: string;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Tool`s prepare method. Can be async
|
|
57
|
+
* @param data
|
|
58
|
+
*/
|
|
59
|
+
prepare?(data: {toolName: string, config: ToolConfig}): void | Promise<void>;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Tool`s reset method to clean up anything set by prepare. Can be async
|
|
63
|
+
*/
|
|
64
|
+
reset?(): void | Promise<void>;
|
|
65
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hint parameters
|
|
3
|
+
*/
|
|
4
|
+
export interface HintParams {
|
|
5
|
+
/**
|
|
6
|
+
* Title of the hint
|
|
7
|
+
*/
|
|
8
|
+
title: string;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Secondary text to be displayed below the title
|
|
12
|
+
*/
|
|
13
|
+
description?: string;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Horizontal alignment of the hint content. Default is 'start'
|
|
17
|
+
*/
|
|
18
|
+
alignment?: HintTextAlignment;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Possible hint positions
|
|
23
|
+
*/
|
|
24
|
+
export type HintPosition = 'top' | 'bottom' | 'left' | 'right';
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Horizontal alignment of the hint content
|
|
28
|
+
*/
|
|
29
|
+
export type HintTextAlignment = 'start' | 'center';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* Event that can be triggered by the Popover
|
|
4
|
+
*/
|
|
5
|
+
export enum PopoverEvent {
|
|
6
|
+
/**
|
|
7
|
+
* When popover closes
|
|
8
|
+
*/
|
|
9
|
+
Closed = 'closed',
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* When it closes because item with 'closeOnActivate' property set was clicked
|
|
13
|
+
*/
|
|
14
|
+
ClosedOnActivate = 'closed-on-activate',
|
|
15
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Popover item types
|
|
3
|
+
*/
|
|
4
|
+
export enum PopoverItemType {
|
|
5
|
+
/** Regular item with icon, title and other properties */
|
|
6
|
+
Default = 'default',
|
|
7
|
+
|
|
8
|
+
/** Gray line used to separate items from each other */
|
|
9
|
+
Separator = 'separator',
|
|
10
|
+
|
|
11
|
+
/** Item with custom html content */
|
|
12
|
+
Html = 'html'
|
|
13
|
+
}
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { HintParams, HintPosition, HintTextAlignment } from "./hint";
|
|
2
|
+
import { PopoverItemType } from "./popover-item-type";
|
|
3
|
+
|
|
4
|
+
export { PopoverItemType } from './popover-item-type';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Represents popover item children configuration
|
|
8
|
+
*/
|
|
9
|
+
export interface PopoverItemChildren {
|
|
10
|
+
/**
|
|
11
|
+
* True if children items should be searchable
|
|
12
|
+
*/
|
|
13
|
+
searchable?: boolean;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* True if popover with children should be displayed instantly and not after item click/hover.
|
|
17
|
+
* False by default.
|
|
18
|
+
* Now is used only in the inline popover.
|
|
19
|
+
*/
|
|
20
|
+
isOpen?: boolean;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* False if keyboard navigation should be disabled in the children popover.
|
|
24
|
+
* True by default
|
|
25
|
+
*/
|
|
26
|
+
isFlippable?: boolean;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Items of nested popover that should be open on the current item hover/click (depending on platform)
|
|
30
|
+
*/
|
|
31
|
+
items?: PopoverItemParams[];
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Called once children popover is opened
|
|
35
|
+
*/
|
|
36
|
+
onOpen?: () => void;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Called once children popover is closed
|
|
40
|
+
*/
|
|
41
|
+
onClose?: () => void;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Adds children property to the item
|
|
46
|
+
*/
|
|
47
|
+
export type WithChildren<T> = Omit<T, 'onActivate'> & {
|
|
48
|
+
/**
|
|
49
|
+
* Popover item children configuration
|
|
50
|
+
*/
|
|
51
|
+
children: PopoverItemChildren;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Items with children should not have onActivate handler
|
|
55
|
+
*/
|
|
56
|
+
onActivate?: never;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Represents popover item with confirmation.
|
|
61
|
+
*/
|
|
62
|
+
export type PopoverItemDefaultWithConfirmationParams = Omit<PopoverItemDefaultBaseParams, 'onActivate'> & {
|
|
63
|
+
/**
|
|
64
|
+
* Popover item parameters that should be applied on item activation.
|
|
65
|
+
* May be used to ask user for confirmation before executing popover item activation handler.
|
|
66
|
+
*/
|
|
67
|
+
confirmation: PopoverItemDefaultBaseParams;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Items with confirmation should not have onActivate handler
|
|
71
|
+
*/
|
|
72
|
+
onActivate?: never;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Represents popover item separator.
|
|
77
|
+
* Special item type that is used to separate items in the popover.
|
|
78
|
+
*/
|
|
79
|
+
export interface PopoverItemSeparatorParams {
|
|
80
|
+
/**
|
|
81
|
+
* Item type
|
|
82
|
+
*/
|
|
83
|
+
type: PopoverItemType.Separator;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Represents popover item with custom html content
|
|
88
|
+
*/
|
|
89
|
+
export interface PopoverItemHtmlParams {
|
|
90
|
+
/**
|
|
91
|
+
* Item type
|
|
92
|
+
*/
|
|
93
|
+
type: PopoverItemType.Html;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Custom html content to be displayed in the popover
|
|
97
|
+
*/
|
|
98
|
+
element: HTMLElement;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Hint data to be displayed on item hover
|
|
102
|
+
*/
|
|
103
|
+
hint?: HintParams;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* True if popover should close once item is activated
|
|
107
|
+
*/
|
|
108
|
+
closeOnActivate?: boolean;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Item name
|
|
112
|
+
* Used in data attributes needed for automated end-to-end tests
|
|
113
|
+
*/
|
|
114
|
+
name?: string;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Common parameters for all kinds of default popover items: with or without confirmation
|
|
119
|
+
*/
|
|
120
|
+
export interface PopoverItemDefaultBaseParams {
|
|
121
|
+
/**
|
|
122
|
+
* Item type
|
|
123
|
+
*/
|
|
124
|
+
type?: PopoverItemType.Default;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Displayed text
|
|
128
|
+
*/
|
|
129
|
+
title?: string;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* @deprecated Use title instead
|
|
133
|
+
*/
|
|
134
|
+
label?: string;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Item icon to be appeared near a title
|
|
138
|
+
*/
|
|
139
|
+
icon?: string;
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Additional displayed text
|
|
143
|
+
*/
|
|
144
|
+
secondaryLabel?: string;
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* True if item should be highlighted as active
|
|
148
|
+
*/
|
|
149
|
+
isActive?: boolean | (() => boolean);
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* True if item should be disabled
|
|
153
|
+
*/
|
|
154
|
+
isDisabled?: boolean;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* True if popover should close once item is activated
|
|
158
|
+
*/
|
|
159
|
+
closeOnActivate?: boolean;
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Item name
|
|
163
|
+
* Used in data attributes needed for shortcuts work and automated end-to-end tests
|
|
164
|
+
*/
|
|
165
|
+
name?: string;
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Defines whether item should toggle on click.
|
|
169
|
+
* Can be represented as boolean value or a string key.
|
|
170
|
+
* In case of string, works like radio buttons group and highlights as inactive any other item that has same toggle key value.
|
|
171
|
+
*/
|
|
172
|
+
toggle?: boolean | string;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Hint data to be displayed on item hover
|
|
176
|
+
*/
|
|
177
|
+
hint?: HintParams;
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Popover item activation handler
|
|
181
|
+
*
|
|
182
|
+
* @param item - activated item
|
|
183
|
+
* @param event - event that initiated item activation
|
|
184
|
+
*/
|
|
185
|
+
onActivate: (item: PopoverItemParams, event?: PointerEvent) => void;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Default, non-separator and non-html popover items type
|
|
190
|
+
*/
|
|
191
|
+
export type PopoverItemDefaultParams =
|
|
192
|
+
PopoverItemDefaultBaseParams |
|
|
193
|
+
PopoverItemDefaultWithConfirmationParams |
|
|
194
|
+
WithChildren<PopoverItemDefaultBaseParams>;
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Represents single popover item
|
|
198
|
+
*/
|
|
199
|
+
export type PopoverItemParams =
|
|
200
|
+
PopoverItemDefaultParams |
|
|
201
|
+
PopoverItemSeparatorParams |
|
|
202
|
+
PopoverItemHtmlParams |
|
|
203
|
+
WithChildren<PopoverItemHtmlParams>;
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Parameters of how to render hint for the popover item
|
|
207
|
+
*/
|
|
208
|
+
type PopoverItemHintRenderParams = {
|
|
209
|
+
/**
|
|
210
|
+
* Hint position relative to the item
|
|
211
|
+
*/
|
|
212
|
+
position?: HintPosition;
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Horizontal alignment of the hint content.
|
|
216
|
+
* 'start' by default.
|
|
217
|
+
*/
|
|
218
|
+
alignment?: HintTextAlignment;
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* If false, hint will not be rendered.
|
|
222
|
+
* True by default.
|
|
223
|
+
* Used to disable hints on mobile popover
|
|
224
|
+
*/
|
|
225
|
+
enabled?: boolean;
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Popover item render params.
|
|
231
|
+
* The parameters that are not set by user via popover api but rather depend on technical implementation
|
|
232
|
+
*/
|
|
233
|
+
export type PopoverItemRenderParamsMap = {
|
|
234
|
+
[PopoverItemType.Default]?: {
|
|
235
|
+
/**
|
|
236
|
+
* Wrapper tag for the item.
|
|
237
|
+
* Div by default
|
|
238
|
+
*/
|
|
239
|
+
wrapperTag?: 'div' | 'button';
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Hint render params
|
|
243
|
+
*/
|
|
244
|
+
hint?: PopoverItemHintRenderParams
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
[PopoverItemType.Html]?: {
|
|
248
|
+
/**
|
|
249
|
+
* Hint render params
|
|
250
|
+
*/
|
|
251
|
+
hint?: PopoverItemHintRenderParams
|
|
252
|
+
};
|
|
253
|
+
};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { PopoverItemParams } from './popover-item';
|
|
2
|
+
import type Flipper from '../../../src/components/flipper';
|
|
3
|
+
import { PopoverEvent } from './popover-event';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Params required to render popover
|
|
7
|
+
*/
|
|
8
|
+
export interface PopoverParams {
|
|
9
|
+
/**
|
|
10
|
+
* Popover items config
|
|
11
|
+
*/
|
|
12
|
+
items: PopoverItemParams[];
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Element of the page that creates 'scope' of the popover.
|
|
16
|
+
* Depending on its size popover position will be calculated
|
|
17
|
+
*/
|
|
18
|
+
scopeElement?: HTMLElement;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Element relative to which the popover should be positioned
|
|
22
|
+
*/
|
|
23
|
+
trigger?: HTMLElement;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* True if popover should contain search field
|
|
27
|
+
*/
|
|
28
|
+
searchable?: boolean;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* False if keyboard navigation should be disabled.
|
|
32
|
+
* True by default
|
|
33
|
+
*/
|
|
34
|
+
flippable?: boolean;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Optional flipper instance to reuse for keyboard navigation
|
|
38
|
+
*/
|
|
39
|
+
flipper?: Flipper;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Popover texts overrides
|
|
43
|
+
*/
|
|
44
|
+
messages?: PopoverMessages
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* CSS class name for popover root element
|
|
48
|
+
*/
|
|
49
|
+
class?: string;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Popover nesting level. 0 value means that it is a root popover
|
|
53
|
+
*/
|
|
54
|
+
nestingLevel?: number;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Texts used inside popover
|
|
60
|
+
*/
|
|
61
|
+
export interface PopoverMessages {
|
|
62
|
+
/** Text displayed when search has no results */
|
|
63
|
+
nothingFound?: string;
|
|
64
|
+
|
|
65
|
+
/** Search input label */
|
|
66
|
+
search?: string
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Events fired by the Popover
|
|
72
|
+
*/
|
|
73
|
+
export interface PopoverEventMap {
|
|
74
|
+
/**
|
|
75
|
+
* Fired when popover closes
|
|
76
|
+
*/
|
|
77
|
+
[PopoverEvent.Closed]: undefined;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Fired when popover closes because item with 'closeOnActivate' property set was clicked
|
|
81
|
+
* Value is the item that was clicked
|
|
82
|
+
*/
|
|
83
|
+
[PopoverEvent.ClosedOnActivate]: undefined;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* HTML elements required to display popover
|
|
88
|
+
*/
|
|
89
|
+
export interface PopoverNodes {
|
|
90
|
+
/** Root popover element */
|
|
91
|
+
popover: HTMLElement;
|
|
92
|
+
|
|
93
|
+
/** Wraps all the visible popover elements, has background and rounded corners */
|
|
94
|
+
popoverContainer: HTMLElement;
|
|
95
|
+
|
|
96
|
+
/** Message displayed when no items found while searching */
|
|
97
|
+
nothingFoundMessage: HTMLElement;
|
|
98
|
+
|
|
99
|
+
/** Popover items wrapper */
|
|
100
|
+
items: HTMLElement;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* HTML elements required to display mobile popover
|
|
105
|
+
*/
|
|
106
|
+
export interface PopoverMobileNodes extends PopoverNodes {
|
|
107
|
+
/** Popover header element */
|
|
108
|
+
header: HTMLElement;
|
|
109
|
+
|
|
110
|
+
/** Overlay, displayed under popover on mobile */
|
|
111
|
+
overlay: HTMLElement;
|
|
112
|
+
}
|