-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathevents.types.ts
More file actions
265 lines (261 loc) · 10.5 KB
/
events.types.ts
File metadata and controls
265 lines (261 loc) · 10.5 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
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
import type { Result, ResultVariant, Suggestion } from '@empathyco/x-types'
import type { ComputedRef } from 'vue'
import type { ExtractPayload } from '../store/store.types'
import type { ArrowKey, PropsWithType } from '../utils'
import type { AiXEvents } from '../x-modules/ai'
import type { DeviceXEvents } from '../x-modules/device'
import type { EmpathizeXEvents } from '../x-modules/empathize/events.types'
import type { ExperienceControlsXEvents } from '../x-modules/experience-controls/events.types'
import type { ExtraParamsXEvents } from '../x-modules/extra-params'
import type { FacetsXEvents } from '../x-modules/facets/events.types'
import type { HistoryQueriesXEvents } from '../x-modules/history-queries/events.types'
import type { IdentifierResultsXEvents } from '../x-modules/identifier-results/events.types'
import type { NextQueriesXEvents } from '../x-modules/next-queries/events.types'
import type { PopularSearchesXEvents } from '../x-modules/popular-searches/events.types'
import type { QueriesPreviewXEvents } from '../x-modules/queries-preview/events.types'
import type { QuerySuggestionsXEvents } from '../x-modules/query-suggestions/events.types'
import type { RecommendationsXEvents } from '../x-modules/recommendations/events.types'
import type { RelatedPromptsXEvents } from '../x-modules/related-prompts/events.types'
import type { RelatedTagsXEvents } from '../x-modules/related-tags/events.types'
import type { ScrollXEvents } from '../x-modules/scroll/events.types'
import type { SearchBoxXEvents } from '../x-modules/search-box/events.types'
import type { SearchXEvents } from '../x-modules/search/events.types'
import type { SemanticQueriesXEvents } from '../x-modules/semantic-queries/events.types'
import type { TaggingXEvents } from '../x-modules/tagging/events.types'
import type { UrlXEvents } from '../x-modules/url/events.types'
import type { XModuleName } from '../x-modules/x-modules.types'
import type { WireMetadata } from './wiring.types'
/**.
* Dictionary of all the {@link XEvent | XEvents}, where each key is the event name, and the value
* is the event payload type or `void` if it has no payload. All the events listed in this file are
* common to all X components modules, so they might be fired by components of any module.
*
*
* @remarks
* Aside from common events, this interface also extends the different XModule's XEventsTypes. If
* you arrived here from eDocs portal, please find the event you are looking for in the specific
* module. In the following links you will find the events that are special for each module:
*
* {@link https://github.com/empathyco/x/blob/main/packages/x-components/src/x-modules/device/events.types.ts | DeviceXEvents}
* {@link https://github.com/empathyco/x/blob/main/packages/x-components/src/x-modules/empathize/events.types.ts | EmpathizeXEvents}
* {@link https://github.com/empathyco/x/blob/main/packages/x-components/src/x-modules/facets/events.types.ts | FacetsXEvents}
* {@link https://github.com/empathyco/x/blob/main/packages/x-components/src/x-modules/history-queries/events.types.ts | HistoryQueriesXEvents}
* {@link https://github.com/empathyco/x/blob/main/packages/x-components/src/x-modules/identifier-results/events.types.ts | IdentifierResultsXEvents}
* {@link https://github.com/empathyco/x/blob/main/packages/x-components/src/x-modules/next-queries/events.types.ts | NextQueriesXEvents}
* {@link https://github.com/empathyco/x/blob/main/packages/x-components/src/x-modules/popular-searches/events.types.ts | PopularSearchesXEvents}
* {@link https://github.com/empathyco/x/blob/main/packages/x-components/src/x-modules/queries-preview/events.types.ts | QueriesPreviewXEvents}
* {@link https://github.com/empathyco/x/blob/main/packages/x-components/src/x-modules/query-suggestions/events.types.ts | QuerySuggestionsXEvents}
* {@link https://github.com/empathyco/x/blob/main/packages/x-components/src/x-modules/recommendations/events.types.ts | RecommendationsXEvents}
* {@link https://github.com/empathyco/x/blob/main/packages/x-components/src/x-modules/related-tags/events.types.ts | RelatedTagsXEvents}
* {@link https://github.com/empathyco/x/blob/main/packages/x-components/src/x-modules/scroll/events.types.ts | ScrollXEvents}
* {@link https://github.com/empathyco/x/blob/main/packages/x-components/src/x-modules/search-box/events.types.ts | SearchBoxXEvents}
* {@link https://github.com/empathyco/x/blob/main/packages/x-components/src/x-modules/search/events.types.ts | SearchXEvents}
* {@link https://github.com/empathyco/x/blob/main/packages/x-components/src/x-modules/tagging/events.types.ts | TaggingXEvents}
* {@link https://github.com/empathyco/x/blob/main/packages/x-components/src/x-modules/url/events.types.ts | UrlXEvents}
* {@link https://github.com/empathyco/x/blob/main/packages/x-components/src/x-modules/related-prompts/events.types.ts | RelatedPromptsXEvents}
*
* @public
*/
export interface XEventsTypes
extends
DeviceXEvents,
EmpathizeXEvents,
ExtraParamsXEvents,
FacetsXEvents,
HistoryQueriesXEvents,
IdentifierResultsXEvents,
NextQueriesXEvents,
PopularSearchesXEvents,
QueriesPreviewXEvents,
QuerySuggestionsXEvents,
RecommendationsXEvents,
RelatedTagsXEvents,
ScrollXEvents,
SearchBoxXEvents,
SearchXEvents,
SemanticQueriesXEvents,
TaggingXEvents,
ExperienceControlsXEvents,
UrlXEvents,
RelatedPromptsXEvents,
AiXEvents {
/**
* The provided number of columns of a grid has changed.
* Payload: the columns number.
*/
ColumnsNumberProvided: number
/**
* The rendered number of columns of a grid has changed.
* Payload: the columns number.
*/
RenderedColumnsNumberChanged: number
/**
* Any kind of suggestions have been displayed (query-suggestions, popular searches...)
* Payload: The displayed {@link @empathyco/x-types#Suggestion | suggestions}.
*/
SuggestionsDisplayed: Suggestion[]
/**
* The `BaseToggleIdPanel` `isOpen` state changed.
* Payload: the new state.
*/
TogglePanelStateChanged: boolean
/**
* The user has accepted a query
* Payload: the accepted query.
*/
UserAcceptedAQuery: string
/**
* The user has accepted the spellcheck
* Payload: the spellcheck query.
*/
UserAcceptedSpellcheckQuery: string
/**
* The user has clicked on a result.
* Payload: The {@link @empathyco/x-types#Result | result} that the user clicked.
*/
UserClickedAResult: Result
/**
* The user has clicked on a display result.
* Payload: The {@link @empathyco/x-types#Result | result} that the user clicked.
*/
UserClickedADisplayResult: Result
/**
* The user clicked the button to close the events modal.
* Payload: none.
*/
UserClickedCloseEventsModal: void
/**
* The user clicked the button to close a modal.
* Payload: the id of the modal to close.
*/
UserClickedCloseModal: string
/**
* The user clicked the button to close X.
* Payload: none.
*/
UserClickedCloseX: void
/**
* The user clicked out of the main modal.
* Payload: none.
*/
UserClickedOutOfMainModal: void
/**
* The user clicked the button to select the number of columns.
* Payload: the column number.
*/
UserClickedColumnPicker: number
/**
* The user clicked the button to open the events modal.
* Payload: none.
*/
UserClickedOpenEventsModal: void
/**
* The user clicked the button to open a modal.
* Payload: the id of the modal to open.
*/
UserClickedOpenModal: string
/**
* The user clicked the button to open X.
* Payload: none.
*/
UserClickedOpenX: void
/**
* The user clicked out of the events modal while it is opened.
* Payload: none.
*/
UserClickedOutOfEventsModal: void
/**
* The user clicked out of a modal while it was opened.
* Payload: the id of the modal.
*/
UserClickedOutOfModal: string
/**
* The user clicked the button to toggle a panel.
* Payload: the id of the panel to toggle.
*/
UserClickedPanelToggleButton: string
/**
* The user has clicked on the add to cart button of a result.
* Payload: The {@link @empathyco/x-types#Result | result} that the user clicked.
*/
UserClickedResultAddToCart: Result
/**
* The user has clicked on the rating of a result.
* Payload: The {@link @empathyco/x-types#Result | result} that the user clicked.
*/
UserClickedAResultRating: Result
/**
* The user has clicked the scroll to top button.
* Payload: The scroll id which has scrolled to top.
*/
UserClickedScrollToTop: string
/**
* The user opened X programmatically.
* Payload: none.
*/
UserOpenXProgrammatically: void
/**
* The user pressed an {@link ArrowKey | arrow key} with the focus on the search-box.
* Payload: the pressed {@link ArrowKey | arrow key}.
*/
UserPressedArrowKey: ArrowKey
/**
* The user has reached the top of the empathize and keeps navigating in that direction.
* Payload: none.
*/
UserReachedEmpathizeTop: void
/**
* The user selected a result variant.
* Payload: And object containing the result, the selected variant, the level of the selected
* variant and the query preview hash.
*/
UserSelectedAResultVariant: {
result: Result
variant: ResultVariant
level: number
queryPreviewHash: ComputedRef<string> | null
}
/**
* User selected any kind of suggestion (query-suggestion, popular-search...)
* Payload: The {@link @empathyco/x-types#Suggestion | suggestion} that the user selected.
*/
UserSelectedASuggestion: Suggestion
/**
* A callback from the snippet has been executed.
* Payload: An object containing the event that executed the callback, the callback result, and
* the original event payload and metadata.
*/
SnippetCallbackExecuted: {
event: XEvent
callbackReturn: unknown
payload: ExtractPayload<XEvent>
metadata: WireMetadata
}
/**
* A new {@link XModule} has been registered.
* Payload: The name of the XModule that has been registered.
*/
ModuleRegistered: XModuleName
}
/**
* Name of all available events.
*
* @public
*/
export type XEvent = keyof XEventsTypes
/**
* Selects events of the with a payload matching the provided type.
*
* @typeParam Type - The type that events payload should match.
* @public
*/
export type XEventsOf<Type> = PropsWithType<XEventsTypes, Type>
/**
* Extracts the payload type of an event.
*
* @typeParam Event - The {@link XEvent} to extract its payload type
* @public
*/
export type XEventPayload<Event extends XEvent> = XEventsTypes[Event] extends void
? undefined
: XEventsTypes[Event]