Skip to content

Commit

Permalink
Add onBeforeInput & onBeforeInputCapture
Browse files Browse the repository at this point in the history
  • Loading branch information
strobe committed Feb 21, 2024
1 parent 675bf4b commit e05e971
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
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
}

0 comments on commit e05e971

Please sign in to comment.