-
Notifications
You must be signed in to change notification settings - Fork 637
Expand file tree
/
Copy pathtemplates.ts
More file actions
67 lines (52 loc) · 2.08 KB
/
templates.ts
File metadata and controls
67 lines (52 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import { PassedElementType } from './passed-element-type';
import { StringPreEscaped } from './string-pre-escaped';
import { ChoiceFull } from './choice-full';
import { GroupFull } from './group-full';
// eslint-disable-next-line import/no-cycle
import { Options } from './options';
import { Types } from './types';
export type TemplateOptions = Pick<
Options,
| 'classNames'
| 'allowHTML'
| 'removeItemButtonAlignLeft'
| 'removeItemIconText'
| 'removeItemLabelText'
| 'searchEnabled'
| 'labelId'
| 'itemDeselectText'
>;
export const NoticeTypes = {
noChoices: 'no-choices',
noResults: 'no-results',
addChoice: 'add-choice',
generic: '',
} as const;
export type NoticeType = Types.ValueOf<typeof NoticeTypes>;
export type CallbackOnCreateTemplatesFn = (
template: Types.StrToEl,
escapeForTemplate: Types.EscapeForTemplateFn,
getClassNames: Types.GetClassNamesFn,
) => Partial<Templates>;
export interface Templates {
containerOuter(
options: TemplateOptions,
dir: HTMLElement['dir'],
isSelectElement: boolean,
isSelectOneElement: boolean,
searchEnabled: boolean,
passedElementType: PassedElementType,
labelId: string,
): HTMLDivElement;
containerInner({ classNames: { containerInner } }: TemplateOptions): HTMLDivElement;
itemList(options: TemplateOptions, isSelectOneElement: boolean): HTMLDivElement;
placeholder(options: TemplateOptions, value: StringPreEscaped | string): HTMLDivElement;
item(options: TemplateOptions, choice: ChoiceFull, removeItemButton: boolean): HTMLDivElement;
choiceList(options: TemplateOptions, isSelectOneElement: boolean): HTMLDivElement;
choiceGroup(options: TemplateOptions, group: GroupFull): HTMLDivElement;
choice(options: TemplateOptions, choice: ChoiceFull, selectText: string, groupText?: string): HTMLDivElement;
input(options: TemplateOptions, placeholderValue: string | null): HTMLInputElement;
dropdown(options: TemplateOptions): HTMLDivElement;
notice(options: TemplateOptions, innerText: string, type: NoticeType): HTMLDivElement;
option(choice: ChoiceFull): HTMLOptionElement;
}