Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add syntactic sugar for onBeforeInput & onBeforeInputCapture #696

Merged
merged 1 commit into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions generator/src/main/scala/slinky/generator/Generator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ object Generator {

val eventToSynthetic = Map[String, String => String](
"EventHandler" -> (t => s"slinky.core.SyntheticEvent[$t, org.scalajs.dom.Event]"),
"InputEventHandler" -> (t => s"slinky.web.SyntheticInputEvent[$t]"),
"ClipboardEventHandler" -> (t => s"slinky.web.SyntheticClipboardEvent[$t]"),
"CompositionEventHandler" -> (t => s"slinky.web.SyntheticCompositionEvent[$t]"),
"KeyboardEventHandler" -> (t => s"slinky.web.SyntheticKeyboardEvent[$t]"),
Expand Down
12 changes: 12 additions & 0 deletions web/html.json
Original file line number Diff line number Diff line change
Expand Up @@ -2214,6 +2214,18 @@
"hasCaptureVariant" : true
},

// Input Events
{
"attributeName" : "onBeforeInput",
"attributeType" : "InputEventHandler",
"docLines" : [
""
],
"compatibleTags" : null,
"withDash" : false,
"hasCaptureVariant" : true
},

// Keyboard Events
{
"attributeName" : "onKeyDown",
Expand Down
11 changes: 11 additions & 0 deletions web/src/main/scala/slinky/web/SyntheticInputEvent.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package slinky.web

import slinky.core.SyntheticEvent
import scala.scalajs.js
import org.scalajs.dom.InputEvent

//https://react.dev/reference/react-dom/components/common#inputevent-handler
@js.native
trait SyntheticInputEvent[+TargetType] extends SyntheticEvent[TargetType, InputEvent] {
val data: String = js.native
}
Loading