-
Notifications
You must be signed in to change notification settings - Fork 7
/
events.ts
115 lines (104 loc) · 4.7 KB
/
events.ts
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
export type BlrFocusEventDetail = {
originalEvent: FocusEvent;
};
export type BlrFocusEvent = CustomEvent<BlrFocusEventDetail>;
export const BlrFocusEventName = 'blrFocus';
export function createBlrFocusEvent(detail: BlrFocusEventDetail): BlrFocusEvent {
return new CustomEvent(BlrFocusEventName, { bubbles: true, composed: true, detail });
}
export type BlrBlurEventDetail = {
originalEvent: FocusEvent;
};
export type BlrBlurEvent = CustomEvent<BlrBlurEventDetail>;
export const BlrBlurEventName = 'blrBlur';
export function createBlrBlurEvent(detail: BlrBlurEventDetail): BlrBlurEvent {
return new CustomEvent(BlrBlurEventName, { bubbles: true, composed: true, detail });
}
export type BlrClickEventDetail = {
originalEvent: MouseEvent | KeyboardEvent;
};
export type BlrClickEvent = CustomEvent<BlrClickEventDetail>;
export const BlrClickEventName = 'blrClick';
export function createBlrClickEvent(detail: BlrClickEventDetail): BlrClickEvent {
return new CustomEvent(BlrClickEventName, { bubbles: true, composed: true, detail });
}
export type BlrNumberStepperClickEventDetail = {
originalEvent: MouseEvent | KeyboardEvent;
direction: 'increase' | 'decrease';
step: number;
};
export type BlrNumberStepperClickEvent = CustomEvent<BlrNumberStepperClickEventDetail>;
export const BlrNumberStepperClickEventName = 'blrNumberStepperClick';
export function createBlrNumberStepperClickEvent(detail: BlrNumberStepperClickEventDetail): BlrNumberStepperClickEvent {
return new CustomEvent(BlrNumberStepperClickEventName, { bubbles: true, composed: true, detail });
}
export type BlrSelectEventDetail = {
originalEvent: Event;
};
export type BlrSelectEvent = CustomEvent<BlrSelectEventDetail>;
export const BlrSelectEventName = 'blrSelect';
export function createBlrSelectEvent(detail: BlrSelectEventDetail): BlrSelectEvent {
return new CustomEvent(BlrSelectEventName, { bubbles: true, composed: true, detail });
}
/* per-input change events */
export type BlrChangeEventDetail = {
originalEvent: Event;
changedValue: string | null;
};
export type BlrChangeEvent = CustomEvent<BlrChangeEventDetail>;
export const BlrChangeEventName = 'blrChange';
export function createBlrChangeEvent(detail: BlrChangeEventDetail): BlrChangeEvent {
return new CustomEvent(BlrChangeEventName, { bubbles: true, composed: true, detail });
}
export type BlrCheckedChangeEventDetail = {
originalEvent: Event;
checkedState: boolean | undefined;
};
export type BlrCheckedChangeEvent = CustomEvent<BlrCheckedChangeEventDetail>;
export const BlrCheckedChangeEventName = 'blrCheckedChange';
export function createBlrCheckedChangeEvent(detail: BlrCheckedChangeEventDetail): BlrCheckedChangeEvent {
return new CustomEvent(BlrCheckedChangeEventName, { bubbles: true, composed: true, detail });
}
export type BlrSelectedValueChangeEventDetail = {
originalEvent: Event;
selectedValue: string;
};
export type BlrSelectedValueChangeEvent = CustomEvent<BlrSelectedValueChangeEventDetail>;
export const BlrSelectedValueChangeEventName = 'blrSelectedValueChange';
export function createBlrSelectedValueChangeEvent(
detail: BlrSelectedValueChangeEventDetail
): BlrSelectedValueChangeEvent {
return new CustomEvent(BlrSelectedValueChangeEventName, { bubbles: true, composed: true, detail });
}
export type BlrTextValueChangeEventDetail = {
originalEvent: Event;
inputValue: string;
};
export type BlrTextValueChangeEvent = CustomEvent<BlrTextValueChangeEventDetail>;
export const BlrTextValueChangeEventName = 'blrTextValueChange';
export function createBlrTextValueChangeEvent(detail: BlrTextValueChangeEventDetail): BlrTextValueChangeEvent {
return new CustomEvent(BlrTextValueChangeEventName, { bubbles: true, composed: true, detail });
}
export type BlrNumberValueChangeEventDetail = {
originalEvent: Event;
inputValue: number;
};
export type BlrNumberValueChangeEvent = CustomEvent<BlrNumberValueChangeEventDetail>;
export const BlrNumberValueChangeEventName = 'blrNumberValueChange';
export function createBlrNumberValueChangeEvent(detail: BlrNumberValueChangeEventDetail): BlrNumberValueChangeEvent {
return new CustomEvent(BlrNumberValueChangeEventName, { bubbles: true, composed: true, detail });
}
declare global {
interface GlobalEventHandlersEventMap {
[BlrFocusEventName]: BlrFocusEvent;
[BlrBlurEventName]: BlrBlurEvent;
[BlrClickEventName]: BlrClickEvent;
[BlrNumberStepperClickEventName]: BlrNumberStepperClickEvent;
[BlrSelectEventName]: BlrSelectEvent;
[BlrChangeEventName]: BlrChangeEvent;
[BlrCheckedChangeEventName]: BlrCheckedChangeEvent;
[BlrSelectedValueChangeEventName]: BlrSelectedValueChangeEvent;
[BlrTextValueChangeEventName]: BlrTextValueChangeEvent;
[BlrNumberValueChangeEventName]: BlrNumberValueChangeEvent;
}
}