@@ -7,28 +7,50 @@ export interface RawSignal<T extends SignalTypes, Data> extends BaseSignal {
77 data : Data
88 metadata ?: Record < string , any >
99}
10-
1110export type InteractionData = ClickData | SubmitData | ChangeData
1211
13- interface SerializedTarget {
12+ export type ParsedAttributes = { [ attributeName : string ] : string | null }
13+
14+ export interface TargetedHTMLElement {
15+ id : string
16+ attributes : ParsedAttributes
1417 [ key : string ] : any
1518}
1619
1720type ClickData = {
1821 eventType : 'click'
19- target : SerializedTarget
22+ target : TargetedHTMLElement
2023}
2124
2225type SubmitData = {
2326 eventType : 'submit'
24- submitter ?: SerializedTarget
25- target : SerializedTarget
27+ submitter ?: TargetedHTMLElement
28+ target : TargetedHTMLElement
2629}
2730
2831export type ChangeData = {
2932 eventType : 'change'
30- target : SerializedTarget
33+ /**
34+ * The target element that changed.
35+ */
36+ target : TargetedHTMLElement
37+ /**
38+ * The name/type of "listener" that triggered the change.
39+ * Elements can change due to a variety of reasons, such as a mutation, a change event, or a contenteditable change
40+ */
3141 listener : 'contenteditable' | 'onchange' | 'mutation'
42+ /**
43+ * The change that occurred -- this is a key-value object of the change that occurred
44+ * For mutation listeners, this is the attributes that changed
45+ * For contenteditable listeners, this is the text that changed
46+ * @example
47+ * ```ts
48+ * { checked: true } // onchange
49+ * { value: 'new value' } // onchange / mutation
50+ * {'aria-selected': 'true' } // mutation
51+ * { textContent: 'Sentence1\nSentence2\n' } // contenteditable
52+ * ```
53+ */
3254 change : JSONValue
3355}
3456
0 commit comments