org.scalajs.dom.raw.HTMLElement Scala Examples

The following examples show how to use org.scalajs.dom.raw.HTMLElement. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.
Example 1
Source File: DomHook.scala    From scastie   with Apache License 2.0 5 votes vote down vote up
package com.olegych.scastie.api
package runtime

import org.scalajs.dom.raw.HTMLElement
import scala.scalajs.js

import scala.collection.mutable.Buffer

import java.util.UUID

trait DomHook {
  private val elements = Buffer.empty[HTMLElement]

  def attach(element: HTMLElement): UUID = {
    val uuid = UUID.randomUUID()
    element.setAttribute("uuid", uuid.toString)
    elements += element
    uuid
  }

  def attachedElements(): js.Array[HTMLElement] = js.Array(elements.toSeq:_*)
} 
Example 2
Source File: SubMenu.scala    From Converter   with GNU General Public License v3.0 5 votes vote down vote up
package typingsSlinky.reactContextmenu.components

import org.scalajs.dom.raw.HTMLDivElement
import org.scalajs.dom.raw.HTMLElement
import slinky.core.facade.ReactElement
import slinky.web.SyntheticMouseEvent
import slinky.web.SyntheticTouchEvent
import slinky.web.html.div.tag
import typingsSlinky.StBuildingComponent
import typingsSlinky.react.mod.ReactText
import typingsSlinky.reactContextmenu.mod.SubMenuProps
import scala.scalajs.js
import scala.scalajs.js.`|`
import scala.scalajs.js.annotation._

object SubMenu {
  @JSImport("react-contextmenu", "SubMenu")
  @js.native
  object component extends js.Object
  
  @scala.inline
  class Builder (val args: js.Array[js.Any])
    extends AnyVal
       with StBuildingComponent[tag.type, typingsSlinky.reactContextmenu.mod.SubMenu] {
    @scala.inline
    def className(value: String): this.type = set("className", value.asInstanceOf[js.Any])
    @scala.inline
    def disabled(value: Boolean): this.type = set("disabled", value.asInstanceOf[js.Any])
    @scala.inline
    def hoverDelay(value: Double): this.type = set("hoverDelay", value.asInstanceOf[js.Any])
    @scala.inline
    def onClickFunction3(
      value: ( HTMLElement, 
          Unit
        ]) | js.Function
    ): this.type = set("onClick", value.asInstanceOf[js.Any])
    @scala.inline
    def preventCloseOnClick(value: Boolean): this.type = set("preventCloseOnClick", value.asInstanceOf[js.Any])
    @scala.inline
    def rtl(value: Boolean): this.type = set("rtl", value.asInstanceOf[js.Any])
  }
  
  def withProps(p: SubMenuProps): Builder = new Builder(js.Array(this.component, p.asInstanceOf[js.Any]))
  @scala.inline
  def apply(title: ReactElement | ReactText): Builder = {
    val __props = js.Dynamic.literal(title = title.asInstanceOf[js.Any])
    new Builder(js.Array(this.component, __props.asInstanceOf[SubMenuProps]))
  }
} 
Example 3
Source File: MenuItem.scala    From Converter   with GNU General Public License v3.0 5 votes vote down vote up
package typingsSlinky.reactContextmenu.components

import org.scalajs.dom.raw.HTMLDivElement
import org.scalajs.dom.raw.HTMLElement
import slinky.web.SyntheticMouseEvent
import slinky.web.SyntheticTouchEvent
import slinky.web.html.div.tag
import typingsSlinky.StBuildingComponent
import typingsSlinky.react.mod.HTMLAttributes
import typingsSlinky.reactContextmenu.mod.MenuItemProps
import scala.scalajs.js
import scala.scalajs.js.`|`
import scala.scalajs.js.annotation._

object MenuItem {
  @JSImport("react-contextmenu", "MenuItem")
  @js.native
  object component extends js.Object
  
  @scala.inline
  class Builder (val args: js.Array[js.Any])
    extends AnyVal
       with StBuildingComponent[tag.type, typingsSlinky.reactContextmenu.mod.MenuItem] {
    @scala.inline
    def attributes(value: HTMLAttributes[HTMLDivElement]): this.type = set("attributes", value.asInstanceOf[js.Any])
    @scala.inline
    def className(value: String): this.type = set("className", value.asInstanceOf[js.Any])
    @scala.inline
    def data(
      value:  HTMLElement, 
          Unit
        ]) | js.Function
    ): this.type = set("onClick", value.asInstanceOf[js.Any])
    @scala.inline
    def preventClose(value: Boolean): this.type = set("preventClose", value.asInstanceOf[js.Any])
  }
  
  def withProps(p: MenuItemProps): Builder = new Builder(js.Array(this.component, p.asInstanceOf[js.Any]))
  implicit def make(companion: MenuItem.type): Builder = new Builder(js.Array(this.component, js.Dictionary.empty))()
} 
Example 4
Source File: ContextMenu.scala    From Converter   with GNU General Public License v3.0 5 votes vote down vote up
package typingsSlinky.reactContextmenu.components

import org.scalajs.dom.raw.HTMLElement
import slinky.web.SyntheticMouseEvent
import slinky.web.html.`*`.tag
import typingsSlinky.StBuildingComponent
import typingsSlinky.reactContextmenu.mod.ContextMenuProps
import scala.scalajs.js
import scala.scalajs.js.`|`
import scala.scalajs.js.annotation._

object ContextMenu {
  @JSImport("react-contextmenu", "ContextMenu")
  @js.native
  object component extends js.Object
  
  @scala.inline
  class Builder (val args: js.Array[js.Any])
    extends AnyVal
       with StBuildingComponent[tag.type, typingsSlinky.reactContextmenu.mod.ContextMenu] {
    @scala.inline
    def className(value: String): this.type = set("className", value.asInstanceOf[js.Any])
    @scala.inline
    def data(value: js.Any): this.type = set("data", value.asInstanceOf[js.Any])
    @scala.inline
    def hideOnLeave(value: Boolean): this.type = set("hideOnLeave", value.asInstanceOf[js.Any])
    @scala.inline
    def onHide(value:  js.Any => Unit): this.type = set("onShow", js.Any.fromFunction1(value))
    @scala.inline
    def rtl(value: Boolean): this.type = set("rtl", value.asInstanceOf[js.Any])
  }
  
  def withProps(p: ContextMenuProps): Builder = new Builder(js.Array(this.component, p.asInstanceOf[js.Any]))
  @scala.inline
  def apply(id: String): Builder = {
    val __props = js.Dynamic.literal(id = id.asInstanceOf[js.Any])
    new Builder(js.Array(this.component, __props.asInstanceOf[ContextMenuProps]))
  }
} 
Example 5
Source File: DropzoneRootProps.scala    From Converter   with GNU General Public License v3.0 5 votes vote down vote up
package typingsSlinky.reactDropzone.mod

import org.scalablytyped.runtime.StringDictionary
import org.scalajs.dom.raw.HTMLElement
import typingsSlinky.react.mod.HTMLAttributes
import scala.scalajs.js
import scala.scalajs.js.`|`
import scala.scalajs.js.annotation._

@js.native
trait DropzoneRootProps
  extends HTMLAttributes[HTMLElement]
     with  StringDictionary[js.Any] {
  var refKey: js.UndefOr[String] = js.native
}

object DropzoneRootProps {
  @scala.inline
  def apply(): DropzoneRootProps = {
    val __obj = js.Dynamic.literal()
    __obj.asInstanceOf[DropzoneRootProps]
  }
  @scala.inline
  implicit class DropzoneRootPropsOps[Self <: DropzoneRootProps] (val x: Self) extends AnyVal {
    @scala.inline
    def duplicate: Self = (js.Dynamic.global.Object.assign(js.Dynamic.literal(), x)).asInstanceOf[Self]
    @scala.inline
    def combineWith[Other <: js.Any](other: Other): Self with Other = (js.Dynamic.global.Object.assign(js.Dynamic.literal(), x, other.asInstanceOf[js.Any])).asInstanceOf[Self with Other]
    @scala.inline
    def set(key: String, value: js.Any): Self = {
        x.asInstanceOf[js.Dynamic].updateDynamic(key)(value)
        x
    }
    @scala.inline
    def setRefKey(value: String): Self = this.set("refKey", value.asInstanceOf[js.Any])
    @scala.inline
    def deleteRefKey: Self = this.set("refKey", js.undefined)
  }
  
} 
Example 6
Source File: ReactDropzone.scala    From Converter   with GNU General Public License v3.0 5 votes vote down vote up
package typingsSlinky.reactDropzone.components

import org.scalajs.dom.raw.HTMLElement
import slinky.core.facade.ReactElement
import slinky.web.html.`*`.tag
import typingsSlinky.StBuildingComponent
import typingsSlinky.react.mod.DragEvent
import typingsSlinky.react.mod.Ref
import typingsSlinky.react.mod.RefAttributes
import typingsSlinky.reactDropzone.mod.DropEvent
import typingsSlinky.reactDropzone.mod.DropzoneProps
import typingsSlinky.reactDropzone.mod.DropzoneRef
import typingsSlinky.reactDropzone.mod.DropzoneState
import scala.scalajs.js
import scala.scalajs.js.`|`
import scala.scalajs.js.annotation._

object ReactDropzone {
  @JSImport("react-dropzone", JSImport.Default)
  @js.native
  object component extends js.Object
  
  @scala.inline
  class Builder (val args: js.Array[js.Any])
    extends AnyVal
       with StBuildingComponent[tag.type, Ref[js.Any] with js.Object] {
    @scala.inline
    def accept(value: String | js.Array[String]): this.type = set("accept", value.asInstanceOf[js.Any])
    @scala.inline
    def children(value:  DropEvent) => Unit
    ): this.type = set("onDropRejected", js.Any.fromFunction2(value))
    @scala.inline
    def onFileDialogCancel(value: () => Unit): this.type = set("onFileDialogCancel", js.Any.fromFunction0(value))
    @scala.inline
    def preventDropOnDocument(value: Boolean): this.type = set("preventDropOnDocument", value.asInstanceOf[js.Any])
  }
  
  def withProps(p: DropzoneProps with RefAttributes[DropzoneRef]): Builder = new Builder(js.Array(this.component, p.asInstanceOf[js.Any]))
  implicit def make(companion: ReactDropzone.type): Builder = new Builder(js.Array(this.component, js.Dictionary.empty))()
} 
Example 7
Source File: cloneElement.scala    From Converter   with GNU General Public License v3.0 5 votes vote down vote up
package typingsSlinky.react.mod

import org.scalajs.dom.raw.Element
import org.scalajs.dom.raw.HTMLElement
import org.scalajs.dom.raw.SVGElement
import slinky.core.ReactComponentClass
import typingsSlinky.std.Partial
import scala.scalajs.js
import scala.scalajs.js.`|`
import scala.scalajs.js.annotation._

@JSImport("react", "cloneElement")
@js.native
object cloneElement extends js.Object {
  // Custom components
  def apply[P](element: FunctionComponentElement[P]): FunctionComponentElement[P] = js.native
  def apply[P](
    element: FunctionComponentElement[P],
    props: Partial[P] with Attributes,
    children: slinky.core.facade.ReactElement*
  ): FunctionComponentElement[P] = js.native
  def apply[P](element: ReactElement): slinky.core.facade.ReactElement = js.native
  def apply[P](
    element: ReactElement,
    props: Partial[P] with Attributes,
    children: slinky.core.facade.ReactElement*
  ): slinky.core.facade.ReactElement = js.native
  def apply[P, T ](element: ReactSVGElement, props: P, children: slinky.core.facade.ReactElement*): ReactSVGElement = js.native
} 
Example 8
Source File: refForwardMod.scala    From Converter   with GNU General Public License v3.0 5 votes vote down vote up
package typingsSlinky.stardustUiReactComponentRef

import org.scalajs.dom.raw.HTMLElement
import typingsSlinky.react.mod.Component
import typingsSlinky.stardustUiReactComponentRef.anon.Children
import typingsSlinky.stardustUiReactComponentRef.anon.InnerRef
import typingsSlinky.stardustUiReactComponentRef.typesMod.RefProps
import scala.scalajs.js
import scala.scalajs.js.`|`
import scala.scalajs.js.annotation._

@JSImport("@stardust-ui/react-component-ref/dist/es/RefForward", JSImport.Namespace)
@js.native
object refForwardMod extends js.Object {
  @js.native
  trait RefForward
    extends Component[RefProps, js.Object, js.Any] {
    def handleRefOverride(node: HTMLElement): Unit = js.native
  }
  
  @js.native
  class default () extends RefForward
  
  
  @js.native
  object default extends js.Object {
    var displayName: String = js.native
    var propTypes: Children | InnerRef = js.native
  }
  
} 
Example 9
Source File: DomChangesPerformer.scala    From levsha   with Apache License 2.0 5 votes vote down vote up
package levsha.dom

import levsha.{Id, XmlNs}
import levsha.impl.DiffRenderContext.ChangesPerformer
import org.scalajs.dom.raw.HTMLElement
import org.scalajs.dom.{Element, Node}
import org.scalajs.{dom => browserDom}

import scala.collection.mutable
import scala.scalajs.js

final class DomChangesPerformer(target: Element) extends ChangesPerformer {

  private val index = mutable.Map[Id, Node](Id.TopLevel -> target)

  private def create(id: Id)(createNewElement: => Node): Unit = {
    val parentId = id.parent
    parentId.flatMap(index.get) foreach { parent =>
      val newEl = createNewElement
      newEl.asInstanceOf[js.Dynamic]
        .vid = id.mkString
      index.get(id) match {
        case Some(oldEl) if oldEl.parentNode == parent =>
          parent.replaceChild(newEl, oldEl)
          index.update(id, newEl)
        case _ =>
          parent.appendChild(newEl)
          index.update(id, newEl)
      }
    }
  }

  def createText(id: Id, text: String): Unit = create(id) {
    browserDom.document.createTextNode(text)
  }

  def create(id: Id, tag: String, xmlNs: String): Unit = create(id) {
    browserDom.document.createElementNS(xmlNs, tag)
  }

  def remove(id: Id): Unit = index.remove(id) foreach { el =>
    el.parentNode.removeChild(el)
  }

  def setAttr(id: Id, xmlNs: String, name: String, value: String): Unit = index.get(id) foreach {
    case node: Element if xmlNs eq XmlNs.html.uri => node.setAttribute(name, value)
    case node: Element => node.setAttributeNS(xmlNs, name, value)
    case node => browserDom.console.warn(s"Can't set attribute to $node")
  }

  def removeAttr(id: Id, xmlNs: String, name: String): Unit = index.get(id) foreach {
    case node: Element if xmlNs eq XmlNs.html.uri => node.removeAttribute(name)
    case node: Element => node.removeAttributeNS(xmlNs, name)
    case node => browserDom.console.warn(s"Can't remove attribute from $node")
  }

  def setStyle(id: Id, name: String, value: String): Unit = index.get(id) foreach {
    case node: HTMLElement => node.style.setProperty(name, value)
    case node => browserDom.console.warn(s"Can't set style to $node")
  }

  def removeStyle(id: Id, name: String): Unit = index.get(id) foreach {
    case node: HTMLElement => node.style.removeProperty(name)
    case node => browserDom.console.warn(s"Can't remove style from $node")
  }
} 
Example 10
Source File: FrontEnd.scala    From threejs-facade   with Mozilla Public License 2.0 5 votes vote down vote up
package org.denigma.preview

import org.denigma.binding.binders.GeneralBinder
import org.denigma.binding.extensions.sq
import org.denigma.binding.views.BindableView
import org.querki.jquery._
import org.scalajs.dom
import org.scalajs.dom.raw.HTMLElement
import org.denigma.binding.extensions._

import scala.collection.immutable.Map
import scala.scalajs.js
import scala.scalajs.js.annotation.JSExport
import scala.util.Try


@JSExport("FrontEnd")
object FrontEnd extends BindableView with scalajs.js.JSApp
{

  lazy val elem: HTMLElement = dom.document.body

  val sidebarParams = js.Dynamic.literal(
    exclusive = false,
    dimPage = false,
    closable = false,
    useLegacy = true
  )


  override lazy val injector = defaultInjector.register("sidebar")((el, params) => new SidebarView(el).withBinder(new GeneralBinder(_)))


  @JSExport
  def main(): Unit = {
    this.bindView()
    Example.activate() //activate examples
  }

  @JSExport
  def showLeftSidebar() = {
    $(".left.sidebar").dyn.sidebar(sidebarParams).sidebar("show")
  }

  @JSExport
  def load(content: String, into: String): Unit = {
    dom.document.getElementById(into).innerHTML = content
  }

  @JSExport
  def moveInto(from: String, into: String): Unit = {
    for {
      ins <- sq.byId(from)
      intoElement <- sq.byId(into)
    } {
      this.loadElementInto(intoElement, ins.innerHTML)
      ins.parentNode.removeChild(ins)
    }
  }

  withBinder(new GeneralBinder(_))

} 
Example 11
Source File: JumpCameraControls.scala    From threejs-facade   with Mozilla Public License 2.0 5 votes vote down vote up
package org.denigma.threejs.extensions.controls

import org.denigma.threejs.extensions.animations.{Animation, Scheduler}
import org.denigma.threejs.{Camera, Scene, Vector3}
import org.scalajs.dom
import org.scalajs.dom.raw.{Element, HTMLElement}
import org.scalajs.dom.MouseEvent

import scala.concurrent.duration
import scala.concurrent.duration.Duration
import scala.concurrent.duration.MILLISECONDS
import scala.language.postfixOps


class JumpCameraControls(val camera: Camera,
  val element: Element, //scalastyle:ignore
  val scene: Scene,
  val width: Double, val height: Double,
  center: Vector3 = new Vector3())
  extends HoverControls(camera, element, center) with IntersectionControls {

  implicit val scheduler = new Scheduler().start()

  override def onMouseMove(event: MouseEvent)= {
    this.onCursorMove(event.clientX, event.clientY, width, height)
    rotateOnMove(event)
  }

  def moveTo(position: Vector3): Unit = {
    val start = center.clone()
    val dp = new Vector3().subVectors(position, center)
    dom.console.info(dp)

    new Animation(Duration(1, duration.SECONDS))(p => {

      val m = dp.clone().multiplyScalar(p)
      val cur = start.clone().add(m)
      // dom.console.info(cur)
      center.copy(cur)
    }).go(scheduler)
    // center.copy(position)
  }

  override def onMouseDown(event: MouseEvent): Unit = {
    this.intersections.headOption match {
      case Some(obj) => obj.`object`.position match {
        case p: Vector3 if p.equals(center) => super.onMouseDown(event)
        case p: Vector3 => moveTo(p)
      }
      case None => super.onMouseDown(event)
    }

  }

} 
Example 12
Source File: ContextMenuProps.scala    From Converter   with GNU General Public License v3.0 5 votes vote down vote up
package typingsSlinky.reactContextmenu.mod

import org.scalajs.dom.raw.HTMLElement
import slinky.web.SyntheticMouseEvent
import scala.scalajs.js
import scala.scalajs.js.`|`
import scala.scalajs.js.annotation._

@js.native
trait ContextMenuProps extends js.Object {
  var className: js.UndefOr[String] = js.native
  var data: js.UndefOr[js.Any] = js.native
  var hideOnLeave: js.UndefOr[Boolean] = js.native
  var id: String = js.native
  var onHide: js.UndefOr[js.Function1[ js.Any => Unit): Self = this.set("onShow", js.Any.fromFunction1(value))
    @scala.inline
    def deleteOnShow: Self = this.set("onShow", js.undefined)
    @scala.inline
    def setRtl(value: Boolean): Self = this.set("rtl", value.asInstanceOf[js.Any])
    @scala.inline
    def deleteRtl: Self = this.set("rtl", js.undefined)
  }
  
} 
Example 13
Source File: Runtime.scala    From scastie   with Apache License 2.0 5 votes vote down vote up
package com.olegych.scastie.api
package runtime

import play.api.libs.json.Json

import org.scalajs.dom.raw.HTMLElement

import java.util.UUID

import java.awt.image.BufferedImage

import scala.reflect.ClassTag

object Runtime extends SharedRuntime {
  def write(in: Either[Option[RuntimeError], List[Instrumentation]]): String = {
    Json.stringify(Json.toJson(ScalaJsResult(in)))
  }
  def render[T](a: T, attach: HTMLElement => UUID)(implicit _ct: ClassTag[T] = null): Render = {
    val ct = Option(_ct)
    a match {
      case element: HTMLElement => {
        val uuid = attach(element)
        AttachedDom(uuid.toString)
      }
      case _ => super.render(a, ct.map(_.toString).getOrElse(""))
    }
  }

  def image(path: String): Html =
    throw new Exception("image(path: String): Html works only on the jvm")

  def toBase64(in: BufferedImage): Html =
    throw new Exception(
      "toBase64(in: BufferedImage): Html works only on the jvm"
    )
} 
Example 14
Source File: Global.scala    From scastie   with Apache License 2.0 5 votes vote down vote up
package com.olegych.scastie.client

import com.olegych.scastie.api._
import com.olegych.scastie.client.components.Scastie

import scala.scalajs.js
import scala.collection.mutable.{Map => MMap}
import scala.util.{Try, Failure, Success}

import org.scalajs.dom.raw.HTMLElement

import japgolly.scalajs.react._

import play.api.libs.json.Json

import java.util.UUID

object Global {
  type Scope = BackendScope[Scastie, ScastieState]

  private val scopes: MMap[UUID, Scope] = MMap()

  def subscribe(scope: Scope, id: UUID): Unit = {
    scopes(id) = scope
  }

  def unsubscribe(id: UUID): Unit = {
    scopes -= id
  }

  def error(er: js.Error, rawId: String): Unit = {
    withScope(rawId)(
      _.withEffectsImpure.modState(
        state =>
          state
            .copyAndSave(
              outputs = state.outputs.copy(
                runtimeError = Some(
                  RuntimeError(
                    message = er.toString,
                    line = None,
                    fullStack = ""
                  )
                )
              )
            )
            .setRunning(false)
      )
    )
  }

  def signal(instrumentationsRaw: String, attachedDoms: js.Array[HTMLElement], rawId: String): Unit = {

    val result =
      Json
        .fromJson[ScalaJsResult](
          Json.parse(instrumentationsRaw)
        )
        .asOpt

    val (instr, runtimeError) = result.map(_.in) match {
      case Some(Left(maybeRuntimeError)) => (Nil, maybeRuntimeError)
      case Some(Right(instrumentations)) => (instrumentations, None)
      case _                             => (Nil, None)
    }

    withScope(rawId)(
      _.withEffectsImpure.modState(
        state =>
          state
            .copyAndSave(
              outputs = state.outputs.copy(
                instrumentations = state.outputs.instrumentations ++ instr.toSet,
                runtimeError = runtimeError
              )
            )
            .setRunning(false)
            .copy(
              attachedDoms = AttachedDoms(
                attachedDoms.map(dom => (dom.getAttribute("uuid"), dom)).toMap
              )
          )
      )
    )
  }

  private def withScope(rawId: String)(body: Scope => Unit): Unit = {
    Try(UUID.fromString(rawId)) match {
      case Success(id) => {
        scopes.get(id).foreach { scope =>
          body(scope)
        }
      }
      case Failure(e) => e.printStackTrace()
    }
  }
} 
Example 15
Source File: RenderAnnotations.scala    From scastie   with Apache License 2.0 5 votes vote down vote up
package com.olegych.scastie.client.components.editor

import com.olegych.scastie.api

import japgolly.scalajs.react.Callback

import codemirror.{TextAreaEditor, CodeMirror, modeScala}

import org.scalajs.dom
import org.scalajs.dom.raw.HTMLElement

object RenderAnnotations {
  def apply(editor: TextAreaEditor,
            currentProps: Option[Editor],
            nextProps: Editor,
            state: EditorState,
            modState: (EditorState => EditorState) => Callback): Callback = {

    val doc = editor.getDoc()

    AnnotationDiff.setAnnotations[api.Instrumentation](
      currentProps,
      nextProps,
      state,
      modState,
      (props, _) => props.instrumentations, {
        case api.Instrumentation(api.Position(start, end), api.Value(value, tpe)) => {

          val startPos = doc.posFromIndex(start)
          val endPos = doc.posFromIndex(end)

          val process = (node: HTMLElement) => {
            CodeMirror.runMode(s"$value: $tpe", modeScala, node)
            node.title = tpe
            ()
          }

          val nl = '\n'

          if (value.contains(nl))
            Annotation.nextline(editor, endPos, value, process)
          else Annotation.inline(editor, startPos, value, process)
        }

        case api.Instrumentation(api.Position(start, end), api.Html(content, folded)) => {

          val startPos = doc.posFromIndex(start)
          val endPos = doc.posFromIndex(end)

          val process: (HTMLElement => Unit) = _.innerHTML = content
          if (!folded) Annotation.nextline(editor, endPos, content, process)
          else Annotation.fold(editor, startPos, endPos, content, process)
        }

        case instrumentation @ api.Instrumentation(
              api.Position(start, end),
              api.AttachedDom(uuid, folded)
            ) => {

          val startPos = doc.posFromIndex(start)
          val endPos = doc.posFromIndex(end)

          val domNode = nextProps.attachedDoms.get(uuid)

          if (!domNode.isEmpty) {
            val process: (HTMLElement => Unit) = element => {
              domNode.foreach(element.appendChild)
              ()
            }

            if (!folded) Annotation.nextline(editor, endPos, "", process)
            else Annotation.fold(editor, startPos, endPos, "", process)

          } else {
            dom.console.log("cannot find dom element uuid: " + uuid)
            Empty
          }
        }

      },
      _.renderAnnotations,
      (state, annotations) => state.copy(renderAnnotations = annotations)
    )
  }
} 
Example 16
Source File: CodeFolds.scala    From scastie   with Apache License 2.0 5 votes vote down vote up
package com.olegych.scastie.client.components.editor

import codemirror.TextAreaEditor

import japgolly.scalajs.react.Callback

import org.scalajs.dom
import org.scalajs.dom.raw.HTMLElement

object CodeFoldingAnnotations {
  private def findFolds(code: String): Set[RangePosititon] = {
    val (folds, _, _) = {
      val lines = code.split("\n").toList

      lines.foldLeft((Set.empty[RangePosititon], Option.empty[Int], 0)) {
        case ((folds, open, indexTotal), line) => {
          val (folds0, open0) =
            if (line == "// fold") {
              if (open.isEmpty) (folds, Some(indexTotal))
              else (folds, open)
            } else if (line == "// end-fold") {
              open match {
                case Some(start) =>
                  (folds + RangePosititon(start, indexTotal + line.length), None)

                case None => (folds, None)
              }
            } else {
              (folds, open)
            }

          (folds0, open0, indexTotal + line.length + 1)
        }
      }
    }

    folds
  }

  def apply(editor: TextAreaEditor, props: Editor): Callback = {
    Callback {
      val doc = editor.getDoc()
      findFolds(props.code).foreach { range =>
        val posStart = doc.posFromIndex(range.indexStart)
        val posEnd = doc.posFromIndex(range.indexEnd)

        var annotRef: Option[Annotation] = None
        val unfold: (HTMLElement => Unit) = { element =>
          def clear(event: dom.Event): Unit = {
            annotRef.foreach(_.clear())
          }

          element.className = element.className + " code-fold"
          element.addEventListener("touchstart", clear _, false)
          element.addEventListener("dblclick", clear _, false)
          element.addEventListener("click", clear _, false)
        }
        val annot = Annotation.fold(
          editor,
          posStart,
          posEnd,
          "-- Click to unfold --",
          unfold
        )

        annotRef = Some(annot)

        (range, annot)
      }
    }
  }
} 
Example 17
Source File: Annotation.scala    From scastie   with Apache License 2.0 5 votes vote down vote up
package com.olegych.scastie.client.components.editor

import codemirror.{TextMarker, TextMarkerOptions, LineWidget, TextAreaEditor}
import codemirror.CodeMirror.{Pos => CMPosition}

import org.scalajs.dom
import org.scalajs.dom.raw.{HTMLElement, HTMLPreElement, HTMLDivElement}

import scala.scalajs.js

private[editor] sealed trait Annotation {
  def clear(): Unit
}

private[editor] case class Line(lw: LineWidget) extends Annotation {
  def clear(): Unit = lw.clear()
}

private[editor] case class Marked(tm: TextMarker) extends Annotation {
  def clear(): Unit = tm.clear()
}

private[editor] case object Empty extends Annotation {
  def clear(): Unit = ()
}

object Annotation {
  def nextline(editor: TextAreaEditor,
               endPos: CMPosition,
               content: String,
               process: (HTMLElement => Unit),
               options: js.Any = null): Annotation = {
    val node =
      dom.document.createElement("pre").asInstanceOf[HTMLPreElement]
    node.className = "line"
    node.innerHTML = content

    process(node)
    Line(editor.addLineWidget(endPos.line, node, options))
  }

  def inline(editor: TextAreaEditor, startPos: CMPosition, content: String, process: (HTMLElement => Unit)): Annotation = {

    // inspired by blink/devtools WebInspector.JavaScriptSourceFrame::_renderDecorations

    val node =
      dom.document.createElement("pre").asInstanceOf[HTMLPreElement]

    node.className = "inline"

    def updateLeft(editor2: codemirror.Editor): Unit = {
      val doc2 = editor2.getDoc()
      val lineNumber = startPos.line
      doc2.getLine(lineNumber).toOption match {
        case Some(line) =>
          val basePos = new CMPosition { line = lineNumber; ch = 0 }
          val offsetPos = new CMPosition {
            line = lineNumber
            ch = doc2.getLine(lineNumber).map(_.length).getOrElse(0)
          }
          val mode = "local"
          val base = editor2.cursorCoords(basePos, mode)
          val offset = editor2.cursorCoords(offsetPos, mode)
          node.style.left = (offset.left - base.left).toString + "px"
        case _ =>
          // the line was deleted
          node.innerHTML = null
      }
    }
    updateLeft(editor)
    editor.onChange((editor, _) => updateLeft(editor))

    node.innerHTML = content
    process(node)

    Line(editor.addLineWidget(startPos.line, node, null))
  }

  def fold(editor: TextAreaEditor, startPos: CMPosition, endPos: CMPosition, content: String, process: (HTMLElement => Unit)): Annotation = {

    val node =
      dom.document.createElement("div").asInstanceOf[HTMLDivElement]
    node.className = "fold"
    node.innerHTML = content
    process(node)
    Marked(
      editor
        .getDoc()
        .markText(
          startPos,
          endPos,
          js.Dictionary[Any](
              "replacedWith" -> node,
              "handleMouseEvents" -> true
            )
            .asInstanceOf[TextMarkerOptions]
        )
    )
  }
} 
Example 18
Source File: ScalaJSExample.scala    From Full-Stack-Scala-Starter   with Apache License 2.0 5 votes vote down vote up
package example

import com.thoughtworks.binding.Binding.Var
import com.thoughtworks.binding.{Binding, dom}
import org.scalajs.dom.document
import org.scalajs.dom.ext.Ajax
import org.scalajs.dom.raw.{Event, HTMLElement}

import scala.scalajs.concurrent.JSExecutionContext.Implicits.queue
import scala.scalajs.js
import scala.scalajs.js.JSON



object ScalaJSExample extends js.JSApp {

  implicit def makeIntellijHappy(x: scala.xml.Elem): Binding[HTMLElement] = ???

  
  def countRequest(data: Var[String]) = {
    val url = "http://localhost:9000/count"
    Ajax.get(url).foreach { case xhr =>
      data.value = JSON.parse(xhr.responseText).count.toString
    }
  }

  @dom
  def render = {
    val data = Var("")
    countRequest(data) // initial population
    <div>
      <button onclick={event: Event => countRequest(data) }>
        Boop
      </button>
      From Play: The server has been booped { data.bind } times. Shared Message: {shared.SharedMessages.itWorks}.
    </div>
  }

  def main(): Unit = {
    dom.render(document.body, render)
  }
} 
Example 19
Source File: TabManager.scala    From akka-viz   with MIT License 5 votes vote down vote up
package akkaviz.frontend

import akkaviz.frontend.components.{TabMenu, _}
import akkaviz.protocol.ActorFailure
import org.scalajs.dom._
import org.scalajs.dom.raw.HTMLElement
import rx.{Ctx, Rx}

import scala.scalajs.js

class TabManager(
    container: TabMenu,
    repo: ActorRepository,
    upstreamConnection: ApiConnection.Upstream,
    failures: Rx[Seq[ActorFailure]]
)(implicit ctx: Ctx.Owner) {

  val openedTabs: js.Dictionary[Tab] = js.Dictionary.empty

  def attachTab[T <: Tab](tab: T): T = {
    console.log(tab.toString)
    attachDom(tab)
    tab match {
      case ct: ClosableTab =>
        handleClose(ct)
      case _ =>
        tab.tab.querySelector("a[data-toggle]").addEventListener("click", ignoreMiddleClick(tab) _)
    }
    tab
  }

  def createDetailTab(actorRef: String): ActorStateTab = {
    val stateVar = repo.state(actorRef)
    val actorFailures = failures.map(_.filter(_.actorRef == actorRef))
    new ActorStateTab(stateVar, upstreamConnection.send, openActorMessages, actorFailures)
  }

  def handleClose(tab: ClosableTab): ClosableTab = {
    tab.tab.querySelector("a.close-tab").onClick({ () => close(tab) })
    tab.tab.querySelector("a[data-toggle]").addEventListener("click", handleMiddleClick(tab) _)
    tab
  }

  private[this] def attachDom(tab: Tab): Tab = {
    container.attachTab(tab)
    tab
  }

  private[this] def openTabOrFocus(tabId: String, newTab: => Tab): Unit = {
    container.activate(openedTabs.getOrElseUpdate(tabId, attachTab(newTab)))
  }

  def openActorDetails(actorRef: ActorPath): Unit = {
    openTabOrFocus(ActorStateTab.stateTabId(actorRef), createDetailTab(actorRef))
  }

  def openLinkDetails(link: ActorLink): Unit = {
    openTabOrFocus(LinkStateTab.stateTabId(link), new LinkStateTab(link))
  }

  def openActorMessages(actorRef: ActorPath): Unit = {
    openTabOrFocus(ActorMessagesTab.stateTabId(actorRef), new ActorMessagesTab(actorRef))
  }

  def close(target: ClosableTab): Unit = {
    if (target.isActive) activateSiblingOf(target)
    target.tab.parentNode.removeChild(target.tab)
    target.tabBody.parentNode.removeChild(target.tabBody)
    target.onClose()
    openedTabs.delete(target.tabId)
  }

  private[this] def activateSiblingOf(ct: ClosableTab): Unit = {
    Option(ct.tab.nextElementSibling).orElse(Option(ct.tab.previousElementSibling)).map { s =>
      s.querySelector("a[data-toggle]").asInstanceOf[HTMLElement]
    }.foreach {
      _.click()
    }
  }

  private[this] def handleMiddleClick(tab: ClosableTab)(e: MouseEvent): Unit = {
    if (e.button == 1) {
      e.preventDefault()
      close(tab)
    }
  }

  private[this] def ignoreMiddleClick(tab: Tab)(e: MouseEvent): Boolean = {
    if (e.button == 1) {
      e.preventDefault()
    }
    false
  }
} 
Example 20
Source File: utils.scala    From scalajs-facades   with MIT License 5 votes vote down vote up
package chandu0101.scalajs.facades.leaflet

import org.scalajs.dom.raw.HTMLElement

import scala.scalajs.js
import scala.scalajs.js.annotation.JSName
import scala.scalajs.js.{UndefOr, undefined}




@JSName("L.Browser")
object LBrowser extends js.Object {
  
  val ie : Boolean = js.native
  val ie6 : Boolean = js.native
  val ie7 : Boolean = js.native
  val webkit : Boolean = js.native
  val webkit3d : Boolean = js.native
  val android : Boolean = js.native
  val android23 : Boolean = js.native
  val mobile : Boolean = js.native
  val opera : Boolean = js.native
  val mobileWebkit : Boolean = js.native
  val mobileOpera : Boolean = js.native
  val touch : Boolean = js.native
  val msTouch : Boolean = js.native
  val retina : Boolean = js.native

}


@JSName("L.DomUtil")
object LDomUtil extends js.Object {
  
  def get(id : String) : HTMLElement = js.native
  def getStyle(el : HTMLElement,style : String) : String = js.native
  def getViewportOffset(el : HTMLElement) : LPoint = js.native
  def create( tagName : String,className : String,container : UndefOr[HTMLElement] = undefined) : HTMLElement = js.native
  def disableTextSelection() : Unit = js.native
  def enableTextSelection() : Unit = js.native
  def hasCLass(el : HTMLElement,name : String) : Boolean = js.native
  def addClass(el : HTMLElement,name : String) : Unit = js.native
  def removeClass(el : HTMLElement,name : String) : Unit = js.native
  def setOpacity(el : HTMLElement,value : Double) : Unit = js.native
  def testProp(props : js.Array[String]) : js.Dynamic = js.native
  def getTranslateString(point : LPoint) : String = js.native
  def getScaleString( scale : Double,origin : LPoint) : String = js.native
  def setPosition(el : HTMLElement,point : LPoint,diable3D : UndefOr[Boolean] = undefined) : Unit = js.native
  def getPosition(el : HTMLElement) : LPoint = js.native
  val TRANSITION : String = js.native
  val TRANSFORM : String = js.native

}

@JSName("L.PosAnimation")
class LPosAnimation extends js.Object with LEventEmitter {
  
  def run(el : HTMLElement,newPos : LPoint,duration : UndefOr[Double] = undefined,easeLinearity : UndefOr[Double] = undefined) : LPosAnimation = js.native
}

object LPosAnimation {
  
  def apply() = new LPosAnimation()
  
}

@JSName("L.Draggable")
class LDraggable extends js.Object with LEventEmitter{
  
  def this(el : HTMLElement , dragHandle : UndefOr[HTMLElement] = undefined) = this()
  def enable() : Unit = js.native
  def disable() : Unit = js.native

}

object LDraggable {
  
  def apply(el : HTMLElement , dragHandle : UndefOr[HTMLElement] = undefined) = new LDraggable(el,dragHandle)
  
} 
Example 21
Source File: Dropdown.scala    From scalafiddle-editor   with Apache License 2.0 5 votes vote down vote up
package scalafiddle.client.component

import japgolly.scalajs.react._
import org.scalajs.dom
import org.scalajs.dom.raw.{HTMLElement, MouseEvent}
import scalajs.js

object Dropdown {
  import japgolly.scalajs.react.vdom.all._

  case class State(isOpen: Boolean = false)

  case class Props(classes: String, buttonContent: VdomNode, content: (() => Callback) => VdomNode)

  case class Backend($ : BackendScope[Props, State]) {
    def render(props: Props, state: State) = {
      div(cls := s"ui dropdown ${props.classes} ${if (state.isOpen) "active visible" else ""}", onClick ==> {
        (e: ReactEventFromHtml) =>
          dropdownClicked(e, state.isOpen)
      })(
        props.buttonContent,
        props.content(() => closeDropdown()).when(state.isOpen)
      )
    }

    val closeFn: js.Function1[MouseEvent, _] = (e: MouseEvent) => closeDropdown(e)

    def dropdownClicked(e: ReactEventFromHtml, isOpen: Boolean): Callback = {
      if (!isOpen) {
        Callback {
          dom.document.addEventListener("click", closeFn)
        } >> $.modState(s => s.copy(isOpen = true))
      } else {
        Callback.empty
      }
    }

    def closeDropdown(e: MouseEvent): Unit = {
      val state = $.state.runNow()
      val node  = $.getDOMNode.runNow().asInstanceOf[HTMLElement]
      if (state.isOpen && !node.contains(e.target.asInstanceOf[HTMLElement])) {
        closeDropdown().runNow()
      }
    }

    def closeDropdown(): Callback = {
      dom.document.removeEventListener("click", closeFn)
      $.modState(s => s.copy(isOpen = false))
    }
  }

  val component = ScalaComponent
    .builder[Props]("FiddleEditor")
    .initialState(State())
    .renderBackend[Backend]
    .build

  def apply(classes: String, buttonContent: VdomNode)(content: (() => Callback) => VdomNode) =
    component(Props(classes, buttonContent, content))
} 
Example 22
Source File: SubMenu.scala    From Converter   with GNU General Public License v3.0 5 votes vote down vote up
package typingsJapgolly.reactContextmenu.components

import japgolly.scalajs.react.Children.Varargs
import japgolly.scalajs.react.CtorType.ChildArg
import japgolly.scalajs.react.JsForwardRefComponent.force
import japgolly.scalajs.react.Key
import japgolly.scalajs.react.ReactMouseEventFrom
import japgolly.scalajs.react.ReactTouchEventFrom
import japgolly.scalajs.react.component.JsForwardRef.UnmountedWithRoot
import japgolly.scalajs.react.raw.React.Element
import org.scalablytyped.runtime.StringDictionary
import org.scalajs.dom.raw.HTMLDivElement
import org.scalajs.dom.raw.HTMLElement
import typingsJapgolly.react.mod.ReactText
import typingsJapgolly.reactContextmenu.mod.SubMenuProps
import scala.scalajs.js
import scala.scalajs.js.`|`
import scala.scalajs.js.annotation._

object SubMenu {
  def apply(
    title: Element | ReactText,
    className: String = null,
    disabled: js.UndefOr[Boolean] = js.undefined,
    hoverDelay: js.UndefOr[Double] = js.undefined,
    onClick: (js.Function3[
       HTMLElement, 
      Unit
    ]) | js.Function = null,
    preventCloseOnClick: js.UndefOr[Boolean] = js.undefined,
    rtl: js.UndefOr[Boolean] = js.undefined,
    key: Key = null,
    _overrides: StringDictionary[js.Any] = null
  )(
    children: ChildArg*
  ): UnmountedWithRoot[SubMenuProps, typingsJapgolly.reactContextmenu.mod.SubMenu, Unit, SubMenuProps] = {
    val __obj = js.Dynamic.literal(title = title.asInstanceOf[js.Any])
    if (className != null) __obj.updateDynamic("className")(className.asInstanceOf[js.Any])
    if (!js.isUndefined(disabled)) __obj.updateDynamic("disabled")(disabled.get.asInstanceOf[js.Any])
    if (!js.isUndefined(hoverDelay)) __obj.updateDynamic("hoverDelay")(hoverDelay.get.asInstanceOf[js.Any])
    if (onClick != null) __obj.updateDynamic("onClick")(onClick.asInstanceOf[js.Any])
    if (!js.isUndefined(preventCloseOnClick)) __obj.updateDynamic("preventCloseOnClick")(preventCloseOnClick.get.asInstanceOf[js.Any])
    if (!js.isUndefined(rtl)) __obj.updateDynamic("rtl")(rtl.get.asInstanceOf[js.Any])
    if (key != null) __obj.updateDynamic("key")(key.asInstanceOf[js.Any])
    if (_overrides != null) js.Dynamic.global.Object.assign(__obj, _overrides)
    val f = force[SubMenuProps, Varargs, typingsJapgolly.reactContextmenu.mod.SubMenu](this.componentImport)
    f(__obj.asInstanceOf[SubMenuProps])(children :_*)
  }
  @JSImport("react-contextmenu", "SubMenu")
  @js.native
  object componentImport extends js.Object
  
} 
Example 23
Source File: TransitionEvent.scala    From scalajs-react-bootstrap   with MIT License 5 votes vote down vote up
package com.acework.js.utils

import org.scalajs.dom._
import org.scalajs.dom.raw.HTMLElement


object TransitionEvent {

  val EVENT_NAME_MAP = Map(
    "transitioned" -> Map(
      "transition" -> "transitionend",
      "WebkitTransition" -> "webkitTransitionEnd",
      "MozTransition" -> "mozTransitionEnd",
      "OTransition" -> "oTransitionEnd",
      "msTransition" -> "MSTransitionEnd"
    ),
    "animationend" -> Map(
      "animation" -> "animationend",
      "WebkitAnimation" -> "webkitAnimationEnd",
      "MozAnimation" -> "mozAnimationEnd",
      "OAnimation" -> "oAnimationEnd",
      "msAnimation" -> "MSAnimationEnd"
    )
  )

  lazy val endEvents: List[String] = {
    try {
      var events: List[String] = Nil
      val testEl = document.createElement("div").asInstanceOf[HTMLElement]
      val style = testEl.style

      // On some platforms, in particular some releases of Android 4.x,
      // the un-prefixed "animation" and "transition" properties are defined on the
      // style object but the events that fire will still be prefixed, so we need
      // to check if the un-prefixed events are usable, and if not remove them
      // from the map
      val excludeAnimationEvent = !window.hasOwnProperty("AnimationEvent")

      val excludeTransition = !window.hasOwnProperty("TransitionEvent")

      for ((baseEventName, baseEvents) <- EVENT_NAME_MAP) {
        for ((styleName, eventName) <- baseEvents
             if style.hasOwnProperty(styleName) &&
               !(excludeAnimationEvent && styleName == "animation") &&
               !(excludeTransition && styleName == "transition")) {
          events = eventName :: events
        }
      }
      events
    }
    catch {
      case e: Throwable =>
        Nil
    }
  }

  def addEventListener(node: EventTarget, eventName: String, listener: (Event) => _) = {
    node.addEventListener(eventName, listener, false)
  }

  def removeEventListener(node: EventTarget, eventName: String, listener: (Event) => _) = {
    node.removeEventListener(eventName, listener, false)
  }

  def addEndEventListener(node: EventTarget, listener: (Event) => _) = {
    if (endEvents.isEmpty) {
      // if CSS transitions are not supported, trigger an "end animation event immediately
      //window.setTimeout(listener.asInstanceOf[Function0[Any]], 0)
      window.setTimeout(() => listener(null), 0)
    }
    else {
      endEvents.foreach { endEvent =>
        addEventListener(node, endEvent, listener)
      }
    }
  }

  def removeEndEventListener(node: EventTarget, listener: (Event) => _) = {
    endEvents.foreach { endEvent =>
      removeEventListener(node, endEvent, listener)
    }
  }
} 
Example 24
Source File: OverlayMixin.scala    From scalajs-react-bootstrap   with MIT License 5 votes vote down vote up
package com.acework.js.components.bootstrap

import japgolly.scalajs.react._
import org.scalajs.dom.raw.HTMLElement
import org.scalajs.dom.{Node, document}




trait OverlayContainer {
  // Provide `getDOMNode` fn mocking a React component API. The `document.body`
  // reference needs to be contained within this function so that it is not accessed
  // in environments where it would not be defined, e.g. nodejs. Equally this is needed
  // before the body is defined where `document.body === null`, this ensures
  // `document.body` is only accessed after componentDidMount.
  def getDOMNode: HTMLElement = document.body
}

class ReferencedContainer[P, S](ref: RefSimple[TopNode], scope: BackendScope[P, S]) extends OverlayContainer {
  override def getDOMNode = {
    val refNode = ref(scope)
    if (refNode != null)
      refNode.get.getDOMNode()
    else
      super.getDOMNode
  }
}

trait OverlayProps {
  val container: OverlayContainer
}

trait OverlayMixin[P <: OverlayProps, S] {

  val scope: BackendScope[P, S]

  var _overlayTarget: Option[Node] = None
  var _overlayInstance: Option[ReactComponentM_[TopNode]] = None

  def onComponentWillUnmount() = {
    _unrenderOverlay()
    _overlayTarget match {
      case Some(target) =>
        getContainerDOMNode.removeChild(target)
        _overlayTarget = None
      case None =>
    }
  }

  def onComponentDidUpdate() = {
    _renderOverlay()
  }

  def onComponentDidMount() = {
    _renderOverlay()
  }

  def _renderOverlay() = {
    _overlayTarget match {
      case None =>
        _mountOverlayTarget()
      case Some(_) =>
    }

    renderOverlay() match {
      case Some(overlay) =>
        _overlayInstance = Some(React.render(overlay, _overlayTarget.get))
      case None =>
        // unreder if the componet is null or transitions to null
        _unrenderOverlay()
    }
  }

  def _unrenderOverlay() = {
    _overlayTarget map { target =>
      React.unmountComponentAtNode(target)
      _overlayTarget = None
    }
  }

  def _mountOverlayTarget() = {
    _overlayTarget = Some(document.createElement("div"))
    getContainerDOMNode.appendChild(_overlayTarget.get)
  }

  def getOverlayDOMNode: Option[TopNode] = {
    var node: Option[TopNode] = None
    if (scope.isMounted()) {
      if (_overlayInstance.isDefined)
        node = Some(_overlayInstance.get.getDOMNode())
    }
    node
  }

  def getContainerDOMNode: HTMLElement = {
    scope.props.container.getDOMNode
  }

  def renderOverlay(): Option[ReactElement]

} 
Example 25
Source File: FadeMixin.scala    From scalajs-react-bootstrap   with MIT License 5 votes vote down vote up
package com.acework.js.components.bootstrap

import japgolly.scalajs.react.{BackendScope, TopNode}
import org.scalajs.dom.raw.HTMLElement
import org.scalajs.dom.{document, raw}

import scala.scalajs.js


trait FadeMixin[P <: OverlayProps, S] {

  def scope: BackendScope[P, S]

  var fadeOutEl: Option[raw.Element] = None

  def getElementAndSelf(root: TopNode, classes: Array[String]): Array[TopNode] = {
    val elements = root.querySelectorAll("." + classes.mkString("."))

    val els = (for (i <- 0 until elements.length) yield elements(i).asInstanceOf[TopNode]).toArray

    var matched = true
    for (i <- 0 until classes.length if matched) {
      val Pattern = "\\b${classes(i)}\\b".r
      root.className match {
        case Pattern() =>
        case _ =>
          matched = false
      }
    }
    if (matched)
      root +: els
    else
      els
  }

  def _fadeIn() = {
    if (scope.isMounted()) {
      val elements = getElementAndSelf(scope.getDOMNode(), Array("fade"))
      elements.foreach { el =>
        val classes = el.className.split(" ").filter(_ != "in") ++ Seq("in")
        el.className = classes.mkString(" ")
      }
    }
  }

  def _fadeOut() = {
    val elements = getElementAndSelf(scope.getDOMNode(), Array("fade", "in"))
    elements.foreach { el =>
      el.className = el.className.replace("\\bin\\b", "")
    }
    js.timers.setTimeout(300)(handleFadeOutEnd())
  }

  def handleFadeOutEnd(): Unit = {
    fadeOutEl.map { fadeout =>
      if (fadeout.parentNode != null)
        fadeout.parentNode.removeChild(fadeout)
    }
  }

  def onComponentDidMount() = {
    // FIXME what does this mean? -- if(document.querySelectorAll)
    //val nodes = document.querySelectorAll("")
    if (true) {
      // Firefox needs delay for transition to be triggered
      js.timers.setTimeout(20)(_fadeIn())
    }
  }

  def onComponentWillUnmount(): Unit = {
    val elements = getElementAndSelf(scope.getDOMNode(), Array("fade"))
    // TODO container
    val container = scope.props.container.getDOMNode
    if (elements.length > 0) {
      val fadeOut = document.createElement("div")
      container.appendChild(fadeOut)
      fadeOut.appendChild(scope.getDOMNode().cloneNode(deep = true))
      fadeOutEl = Some(fadeOut)
      js.timers.setTimeout(20)(_fadeOut())
    }
  }
} 
Example 26
Source File: IntrinsicElements.scala    From Converter   with GNU General Public License v3.0 5 votes vote down vote up
package typingsJapgolly.react.mod.global.JSX

import org.scalajs.dom.raw.HTMLElement
import org.scalajs.dom.raw.SVGElement
import typingsJapgolly.react.mod.DetailedHTMLProps
import typingsJapgolly.react.mod.HTMLAttributes
import typingsJapgolly.react.mod.SVGProps
import scala.scalajs.js
import scala.scalajs.js.`|`
import scala.scalajs.js.annotation._

@js.native
trait IntrinsicElements extends js.Object {
  // HTML
  var abbr: DetailedHTMLProps[HTMLAttributes[HTMLElement], HTMLElement] = js.native
  var animate: SVGProps[SVGElement] = js.native
}

object IntrinsicElements {
  @scala.inline
  def apply(abbr: DetailedHTMLProps[HTMLAttributes[HTMLElement], HTMLElement], animate: SVGProps[SVGElement]): IntrinsicElements = {
    val __obj = js.Dynamic.literal(abbr = abbr.asInstanceOf[js.Any], animate = animate.asInstanceOf[js.Any])
    __obj.asInstanceOf[IntrinsicElements]
  }
  @scala.inline
  implicit class IntrinsicElementsOps[Self <: IntrinsicElements] (val x: Self) extends AnyVal {
    @scala.inline
    def duplicate: Self = (js.Dynamic.global.Object.assign(js.Dynamic.literal(), x)).asInstanceOf[Self]
    @scala.inline
    def combineWith[Other <: js.Any](other: Other): Self with Other = (js.Dynamic.global.Object.assign(js.Dynamic.literal(), x, other.asInstanceOf[js.Any])).asInstanceOf[Self with Other]
    @scala.inline
    def set(key: String, value: js.Any): Self = {
        x.asInstanceOf[js.Dynamic].updateDynamic(key)(value)
        x
    }
    @scala.inline
    def setAbbr(value: DetailedHTMLProps[HTMLAttributes[HTMLElement], HTMLElement]): Self = this.set("abbr", value.asInstanceOf[js.Any])
    @scala.inline
    def setAnimate(value: SVGProps[SVGElement]): Self = this.set("animate", value.asInstanceOf[js.Any])
  }
  
} 
Example 27
Source File: IntrinsicElements.scala    From Converter   with GNU General Public License v3.0 5 votes vote down vote up
package typingsSlinky.react.mod.global.JSX

import org.scalajs.dom.raw.HTMLElement
import org.scalajs.dom.raw.SVGElement
import typingsSlinky.react.mod.DetailedHTMLProps
import typingsSlinky.react.mod.HTMLAttributes
import typingsSlinky.react.mod.SVGProps
import scala.scalajs.js
import scala.scalajs.js.`|`
import scala.scalajs.js.annotation._

@js.native
trait IntrinsicElements extends js.Object {
  // HTML
  var abbr: DetailedHTMLProps[HTMLAttributes[HTMLElement], HTMLElement] = js.native
  var animate: SVGProps[SVGElement] = js.native
}

object IntrinsicElements {
  @scala.inline
  def apply(abbr: DetailedHTMLProps[HTMLAttributes[HTMLElement], HTMLElement], animate: SVGProps[SVGElement]): IntrinsicElements = {
    val __obj = js.Dynamic.literal(abbr = abbr.asInstanceOf[js.Any], animate = animate.asInstanceOf[js.Any])
    __obj.asInstanceOf[IntrinsicElements]
  }
  @scala.inline
  implicit class IntrinsicElementsOps[Self <: IntrinsicElements] (val x: Self) extends AnyVal {
    @scala.inline
    def duplicate: Self = (js.Dynamic.global.Object.assign(js.Dynamic.literal(), x)).asInstanceOf[Self]
    @scala.inline
    def combineWith[Other <: js.Any](other: Other): Self with Other = (js.Dynamic.global.Object.assign(js.Dynamic.literal(), x, other.asInstanceOf[js.Any])).asInstanceOf[Self with Other]
    @scala.inline
    def set(key: String, value: js.Any): Self = {
        x.asInstanceOf[js.Dynamic].updateDynamic(key)(value)
        x
    }
    @scala.inline
    def setAbbr(value: DetailedHTMLProps[HTMLAttributes[HTMLElement], HTMLElement]): Self = this.set("abbr", value.asInstanceOf[js.Any])
    @scala.inline
    def setAnimate(value: SVGProps[SVGElement]): Self = this.set("animate", value.asInstanceOf[js.Any])
  }
  
} 
Example 28
Source File: actionsMod.scala    From Converter   with GNU General Public License v3.0 5 votes vote down vote up
package typingsJapgolly.reactContextmenu

import org.scalajs.dom.raw.HTMLElement
import scala.scalajs.js
import scala.scalajs.js.`|`
import scala.scalajs.js.annotation._

@JSImport("react-contextmenu/modules/actions", JSImport.Namespace)
@js.native
object actionsMod extends js.Object {
  def hideMenu(): Unit = js.native
  def hideMenu(opts: js.Any): Unit = js.native
  def hideMenu(opts: js.Any, target: HTMLElement): Unit = js.native
  def showMenu(): Unit = js.native
  def showMenu(opts: js.Any): Unit = js.native
  def showMenu(opts: js.Any, target: HTMLElement): Unit = js.native
} 
Example 29
Source File: SubMenuProps.scala    From Converter   with GNU General Public License v3.0 5 votes vote down vote up
package typingsJapgolly.reactContextmenu.mod

import japgolly.scalajs.react.Callback
import japgolly.scalajs.react.ReactMouseEventFrom
import japgolly.scalajs.react.ReactTouchEventFrom
import japgolly.scalajs.react.raw.React.Element
import japgolly.scalajs.react.vdom.VdomElement
import org.scalajs.dom.raw.HTMLDivElement
import org.scalajs.dom.raw.HTMLElement
import typingsJapgolly.react.mod.ReactText
import scala.scalajs.js
import scala.scalajs.js.`|`
import scala.scalajs.js.annotation._

@js.native
trait SubMenuProps extends js.Object {
  var className: js.UndefOr[String] = js.native
  var disabled: js.UndefOr[Boolean] = js.native
  var hoverDelay: js.UndefOr[Double] = js.native
  var onClick: js.UndefOr[
    (js.Function3[
       HTMLElement, 
          Unit
        ]) | js.Function
    ): Self = this.set("onClick", value.asInstanceOf[js.Any])
    @scala.inline
    def deleteOnClick: Self = this.set("onClick", js.undefined)
    @scala.inline
    def setPreventCloseOnClick(value: Boolean): Self = this.set("preventCloseOnClick", value.asInstanceOf[js.Any])
    @scala.inline
    def deletePreventCloseOnClick: Self = this.set("preventCloseOnClick", js.undefined)
    @scala.inline
    def setRtl(value: Boolean): Self = this.set("rtl", value.asInstanceOf[js.Any])
    @scala.inline
    def deleteRtl: Self = this.set("rtl", js.undefined)
  }
  
} 
Example 30
Source File: MenuItemProps.scala    From Converter   with GNU General Public License v3.0 5 votes vote down vote up
package typingsJapgolly.reactContextmenu.mod

import japgolly.scalajs.react.Callback
import japgolly.scalajs.react.ReactMouseEventFrom
import japgolly.scalajs.react.ReactTouchEventFrom
import org.scalajs.dom.raw.HTMLDivElement
import org.scalajs.dom.raw.HTMLElement
import typingsJapgolly.react.mod.HTMLAttributes
import scala.scalajs.js
import scala.scalajs.js.`|`
import scala.scalajs.js.annotation._

@js.native
trait MenuItemProps extends js.Object {
  var attributes: js.UndefOr[HTMLAttributes[HTMLDivElement]] = js.native
  var className: js.UndefOr[String] = js.native
  var data: js.UndefOr[
     HTMLElement, 
          Unit
        ]) | js.Function
    ): Self = this.set("onClick", value.asInstanceOf[js.Any])
    @scala.inline
    def deleteOnClick: Self = this.set("onClick", js.undefined)
    @scala.inline
    def setPreventClose(value: Boolean): Self = this.set("preventClose", value.asInstanceOf[js.Any])
    @scala.inline
    def deletePreventClose: Self = this.set("preventClose", js.undefined)
  }
  
} 
Example 31
Source File: ContextMenuProps.scala    From Converter   with GNU General Public License v3.0 5 votes vote down vote up
package typingsJapgolly.reactContextmenu.mod

import japgolly.scalajs.react.Callback
import japgolly.scalajs.react.ReactMouseEventFrom
import org.scalajs.dom.raw.HTMLElement
import scala.scalajs.js
import scala.scalajs.js.`|`
import scala.scalajs.js.annotation._

@js.native
trait ContextMenuProps extends js.Object {
  var className: js.UndefOr[String] = js.native
  var data: js.UndefOr[js.Any] = js.native
  var hideOnLeave: js.UndefOr[Boolean] = js.native
  var id: String = js.native
  var onHide: js.UndefOr[js.Function1[ js.Any) => value(t0).runNow()))
    @scala.inline
    def deleteOnShow: Self = this.set("onShow", js.undefined)
    @scala.inline
    def setRtl(value: Boolean): Self = this.set("rtl", value.asInstanceOf[js.Any])
    @scala.inline
    def deleteRtl: Self = this.set("rtl", js.undefined)
  }
  
} 
Example 32
Source File: ContainedModal.scala    From scalajs-react-bootstrap   with MIT License 5 votes vote down vote up
package demo.examples

import com.acework.js.components.bootstrap.Modal.{N, B, S, P}
import com.acework.js.components.bootstrap._
import japgolly.scalajs.react.ReactComponentC.{ReqProps, ConstProps}
import japgolly.scalajs.react._
import japgolly.scalajs.react.vdom.prefix_<^._
import org.scalajs.dom.raw.HTMLElement
import org.scalajs.dom.{Node, document}


object ContainedModal {

  val containerRef: RefSimple[TopNode] = Ref[HTMLElement]("container")

  def containedModel = {
    Modal.Modal(bsStyle = Styles.primary, title = "Contained Modal": ReactNode, animation = true,
      onRequestHide = () => ())(
        <.div(^.className := "modal-body",
          <.h4("Text in a modal"),
          <.p("Elit est explicabo ipsum eaque dolorem blanditiis doloribus sed id ipsam, beatae, rem fuga id earum? Inventore et facilis obcaecati.")
        ),
        <.div(^.className := "modal-footer",
          // FIXME link onClick to onRequestHide
          Button(Button.Button(), "Close"))
      )
  }

  class Backend(val scope: BackendScope[Unit, Unit])

  val trigger = ReactComponentB[Unit]("Trigger")
    .stateless
    .backend(new Backend(_))
    .render((_, _, B) => {

    <.div(^.className := "modal-container", ^.height := 300, ^.ref := containerRef,
      ModalTrigger.ModalTrigger(modal = containedModel,
        container = new ReferencedContainer(containerRef, B.scope))(
          Button(Button.Button(bsStyle = Styles.primary, bsSize = Sizes.lg), "Launch contained modal")
        )
    )
  }).
    buildU

} 
Example 33
Source File: MenuItem.scala    From Converter   with GNU General Public License v3.0 5 votes vote down vote up
package typingsJapgolly.reactContextmenu.components

import japgolly.scalajs.react.Children.Varargs
import japgolly.scalajs.react.CtorType.ChildArg
import japgolly.scalajs.react.JsForwardRefComponent.force
import japgolly.scalajs.react.Key
import japgolly.scalajs.react.ReactMouseEventFrom
import japgolly.scalajs.react.ReactTouchEventFrom
import japgolly.scalajs.react.component.JsForwardRef.UnmountedWithRoot
import org.scalablytyped.runtime.StringDictionary
import org.scalajs.dom.raw.HTMLDivElement
import org.scalajs.dom.raw.HTMLElement
import typingsJapgolly.react.mod.HTMLAttributes
import typingsJapgolly.reactContextmenu.mod.MenuItemProps
import scala.scalajs.js
import scala.scalajs.js.`|`
import scala.scalajs.js.annotation._

object MenuItem {
  def apply(
    attributes: HTMLAttributes[HTMLDivElement] = null,
    className: String = null,
    data:  HTMLElement, 
      Unit
    ]) | js.Function = null,
    preventClose: js.UndefOr[Boolean] = js.undefined,
    key: Key = null,
    _overrides: StringDictionary[js.Any] = null
  )(
    children: ChildArg*
  ): UnmountedWithRoot[MenuItemProps, typingsJapgolly.reactContextmenu.mod.MenuItem, Unit, MenuItemProps] = {
    val __obj = js.Dynamic.literal()
    if (attributes != null) __obj.updateDynamic("attributes")(attributes.asInstanceOf[js.Any])
    if (className != null) __obj.updateDynamic("className")(className.asInstanceOf[js.Any])
    if (data != null) __obj.updateDynamic("data")(data.asInstanceOf[js.Any])
    if (!js.isUndefined(disabled)) __obj.updateDynamic("disabled")(disabled.get.asInstanceOf[js.Any])
    if (!js.isUndefined(divider)) __obj.updateDynamic("divider")(divider.get.asInstanceOf[js.Any])
    if (onClick != null) __obj.updateDynamic("onClick")(onClick.asInstanceOf[js.Any])
    if (!js.isUndefined(preventClose)) __obj.updateDynamic("preventClose")(preventClose.get.asInstanceOf[js.Any])
    if (key != null) __obj.updateDynamic("key")(key.asInstanceOf[js.Any])
    if (_overrides != null) js.Dynamic.global.Object.assign(__obj, _overrides)
    val f = force[MenuItemProps, Varargs, typingsJapgolly.reactContextmenu.mod.MenuItem](this.componentImport)
    f(__obj.asInstanceOf[MenuItemProps])(children :_*)
  }
  @JSImport("react-contextmenu", "MenuItem")
  @js.native
  object componentImport extends js.Object
  
} 
Example 34
Source File: ContextMenu.scala    From Converter   with GNU General Public License v3.0 5 votes vote down vote up
package typingsJapgolly.reactContextmenu.components

import japgolly.scalajs.react.Callback
import japgolly.scalajs.react.Children.Varargs
import japgolly.scalajs.react.CtorType.ChildArg
import japgolly.scalajs.react.JsForwardRefComponent.force
import japgolly.scalajs.react.Key
import japgolly.scalajs.react.ReactMouseEventFrom
import japgolly.scalajs.react.component.JsForwardRef.UnmountedWithRoot
import org.scalablytyped.runtime.StringDictionary
import org.scalajs.dom.raw.HTMLElement
import typingsJapgolly.reactContextmenu.mod.ContextMenuProps
import scala.scalajs.js
import scala.scalajs.js.`|`
import scala.scalajs.js.annotation._

object ContextMenu {
  def apply(
    id: String,
    className: String = null,
    data: js.Any = null,
    hideOnLeave: js.UndefOr[Boolean] = js.undefined,
    onHide:  js.Any) => onShow(t0).runNow()))
    if (!js.isUndefined(rtl)) __obj.updateDynamic("rtl")(rtl.get.asInstanceOf[js.Any])
    if (key != null) __obj.updateDynamic("key")(key.asInstanceOf[js.Any])
    if (_overrides != null) js.Dynamic.global.Object.assign(__obj, _overrides)
    val f = force[ContextMenuProps, Varargs, typingsJapgolly.reactContextmenu.mod.ContextMenu](this.componentImport)
    f(__obj.asInstanceOf[ContextMenuProps])(children :_*)
  }
  @JSImport("react-contextmenu", "ContextMenu")
  @js.native
  object componentImport extends js.Object
  
} 
Example 35
Source File: DropzoneRootProps.scala    From Converter   with GNU General Public License v3.0 5 votes vote down vote up
package typingsJapgolly.reactDropzone.mod

import org.scalablytyped.runtime.StringDictionary
import org.scalajs.dom.raw.HTMLElement
import typingsJapgolly.react.mod.HTMLAttributes
import scala.scalajs.js
import scala.scalajs.js.`|`
import scala.scalajs.js.annotation._

@js.native
trait DropzoneRootProps
  extends HTMLAttributes[HTMLElement]
     with  StringDictionary[js.Any] {
  var refKey: js.UndefOr[String] = js.native
}

object DropzoneRootProps {
  @scala.inline
  def apply(): DropzoneRootProps = {
    val __obj = js.Dynamic.literal()
    __obj.asInstanceOf[DropzoneRootProps]
  }
  @scala.inline
  implicit class DropzoneRootPropsOps[Self <: DropzoneRootProps] (val x: Self) extends AnyVal {
    @scala.inline
    def duplicate: Self = (js.Dynamic.global.Object.assign(js.Dynamic.literal(), x)).asInstanceOf[Self]
    @scala.inline
    def combineWith[Other <: js.Any](other: Other): Self with Other = (js.Dynamic.global.Object.assign(js.Dynamic.literal(), x, other.asInstanceOf[js.Any])).asInstanceOf[Self with Other]
    @scala.inline
    def set(key: String, value: js.Any): Self = {
        x.asInstanceOf[js.Dynamic].updateDynamic(key)(value)
        x
    }
    @scala.inline
    def setRefKey(value: String): Self = this.set("refKey", value.asInstanceOf[js.Any])
    @scala.inline
    def deleteRefKey: Self = this.set("refKey", js.undefined)
  }
  
} 
Example 36
Source File: ReactDropzone.scala    From Converter   with GNU General Public License v3.0 5 votes vote down vote up
package typingsJapgolly.reactDropzone.components

import japgolly.scalajs.react.Callback
import japgolly.scalajs.react.CallbackTo
import japgolly.scalajs.react.Children.None
import japgolly.scalajs.react.JsForwardRefComponent.force
import japgolly.scalajs.react.Key
import japgolly.scalajs.react.ReactDragEventFrom
import japgolly.scalajs.react.component.JsForwardRef.UnmountedWithRoot
import japgolly.scalajs.react.raw.React.Element
import japgolly.scalajs.react.raw.React.Ref
import org.scalablytyped.runtime.StringDictionary
import org.scalajs.dom.raw.HTMLElement
import typingsJapgolly.react.mod.RefAttributes
import typingsJapgolly.reactDropzone.mod.DropEvent
import typingsJapgolly.reactDropzone.mod.DropzoneProps
import typingsJapgolly.reactDropzone.mod.DropzoneRef
import typingsJapgolly.reactDropzone.mod.DropzoneState
import scala.scalajs.js
import scala.scalajs.js.`|`
import scala.scalajs.js.annotation._

object ReactDropzone {
  def apply(
    accept: String | js.Array[String] = null,
    disabled: js.UndefOr[Boolean] = js.undefined,
    getFilesFromEvent:  DropEvent) => (onDropRejected(t0, t1)).runNow()))
    if (!js.isUndefined(onFileDialogCancel)) __obj.updateDynamic("onFileDialogCancel")(onFileDialogCancel.get.toJsFn)
    if (!js.isUndefined(preventDropOnDocument)) __obj.updateDynamic("preventDropOnDocument")(preventDropOnDocument.get.asInstanceOf[js.Any])
    if (key != null) __obj.updateDynamic("key")(key.asInstanceOf[js.Any])
    if (_overrides != null) js.Dynamic.global.Object.assign(__obj, _overrides)
    val f = force[DropzoneProps with RefAttributes[DropzoneRef], None, js.UndefOr[Null | Ref]](this.componentImport)
    f(__obj.asInstanceOf[DropzoneProps with RefAttributes[DropzoneRef]])
  }
  @JSImport("react-dropzone", JSImport.Default)
  @js.native
  object componentImport extends js.Object
  
} 
Example 37
Source File: cloneElement.scala    From Converter   with GNU General Public License v3.0 5 votes vote down vote up
package typingsJapgolly.react.mod

import japgolly.scalajs.react.raw.React.DomElement
import japgolly.scalajs.react.raw.React.Element
import japgolly.scalajs.react.raw.React.Node
import org.scalajs.dom.raw.HTMLElement
import org.scalajs.dom.raw.SVGElement
import typingsJapgolly.std.Partial
import scala.scalajs.js
import scala.scalajs.js.`|`
import scala.scalajs.js.annotation._

@JSImport("react", "cloneElement")
@js.native
object cloneElement extends js.Object {
  // Custom components
  def apply[P](element: FunctionComponentElement[P]): FunctionComponentElement[P] = js.native
  def apply[P](element: FunctionComponentElement[P], props: Partial[P] with Attributes, children: Node*): FunctionComponentElement[P] = js.native
  def apply[P](element: Element): Element = js.native
  def apply[P](element: Element, props: Partial[P] with Attributes, children: Node*): Element = js.native
  def apply[P, T ](element: ReactSVGElement, props: P, children: Node*): ReactSVGElement = js.native
} 
Example 38
Source File: refForwardMod.scala    From Converter   with GNU General Public License v3.0 5 votes vote down vote up
package typingsJapgolly.stardustUiReactComponentRef

import org.scalajs.dom.raw.HTMLElement
import typingsJapgolly.react.mod.Component
import typingsJapgolly.stardustUiReactComponentRef.anon.Children
import typingsJapgolly.stardustUiReactComponentRef.anon.InnerRef
import typingsJapgolly.stardustUiReactComponentRef.typesMod.RefProps
import scala.scalajs.js
import scala.scalajs.js.`|`
import scala.scalajs.js.annotation._

@JSImport("@stardust-ui/react-component-ref/dist/es/RefForward", JSImport.Namespace)
@js.native
object refForwardMod extends js.Object {
  @js.native
  trait RefForward
    extends Component[RefProps, js.Object, js.Any] {
    def handleRefOverride(node: HTMLElement): Unit = js.native
  }
  
  @js.native
  class default () extends RefForward
  
  
  @js.native
  object default extends js.Object {
    var displayName: String = js.native
    var propTypes: Children | InnerRef = js.native
  }
  
} 
Example 39
Source File: actionsMod.scala    From Converter   with GNU General Public License v3.0 5 votes vote down vote up
package typingsSlinky.reactContextmenu

import org.scalajs.dom.raw.HTMLElement
import scala.scalajs.js
import scala.scalajs.js.`|`
import scala.scalajs.js.annotation._

@JSImport("react-contextmenu/modules/actions", JSImport.Namespace)
@js.native
object actionsMod extends js.Object {
  def hideMenu(): Unit = js.native
  def hideMenu(opts: js.Any): Unit = js.native
  def hideMenu(opts: js.Any, target: HTMLElement): Unit = js.native
  def showMenu(): Unit = js.native
  def showMenu(opts: js.Any): Unit = js.native
  def showMenu(opts: js.Any, target: HTMLElement): Unit = js.native
} 
Example 40
Source File: SubMenuProps.scala    From Converter   with GNU General Public License v3.0 5 votes vote down vote up
package typingsSlinky.reactContextmenu.mod

import org.scalajs.dom.raw.HTMLDivElement
import org.scalajs.dom.raw.HTMLElement
import slinky.core.facade.ReactElement
import slinky.web.SyntheticMouseEvent
import slinky.web.SyntheticTouchEvent
import typingsSlinky.react.mod.ReactText
import scala.scalajs.js
import scala.scalajs.js.`|`
import scala.scalajs.js.annotation._

@js.native
trait SubMenuProps extends js.Object {
  var className: js.UndefOr[String] = js.native
  var disabled: js.UndefOr[Boolean] = js.native
  var hoverDelay: js.UndefOr[Double] = js.native
  var onClick: js.UndefOr[
    (js.Function3[
       HTMLElement, 
          Unit
        ]) | js.Function
    ): Self = this.set("onClick", value.asInstanceOf[js.Any])
    @scala.inline
    def deleteOnClick: Self = this.set("onClick", js.undefined)
    @scala.inline
    def setPreventCloseOnClick(value: Boolean): Self = this.set("preventCloseOnClick", value.asInstanceOf[js.Any])
    @scala.inline
    def deletePreventCloseOnClick: Self = this.set("preventCloseOnClick", js.undefined)
    @scala.inline
    def setRtl(value: Boolean): Self = this.set("rtl", value.asInstanceOf[js.Any])
    @scala.inline
    def deleteRtl: Self = this.set("rtl", js.undefined)
  }
  
} 
Example 41
Source File: MenuItemProps.scala    From Converter   with GNU General Public License v3.0 5 votes vote down vote up
package typingsSlinky.reactContextmenu.mod

import org.scalajs.dom.raw.HTMLDivElement
import org.scalajs.dom.raw.HTMLElement
import slinky.web.SyntheticMouseEvent
import slinky.web.SyntheticTouchEvent
import typingsSlinky.react.mod.HTMLAttributes
import scala.scalajs.js
import scala.scalajs.js.`|`
import scala.scalajs.js.annotation._

@js.native
trait MenuItemProps extends js.Object {
  var attributes: js.UndefOr[HTMLAttributes[HTMLDivElement]] = js.native
  var className: js.UndefOr[String] = js.native
  var data: js.UndefOr[
     HTMLElement, 
          Unit
        ]) | js.Function
    ): Self = this.set("onClick", value.asInstanceOf[js.Any])
    @scala.inline
    def deleteOnClick: Self = this.set("onClick", js.undefined)
    @scala.inline
    def setPreventClose(value: Boolean): Self = this.set("preventClose", value.asInstanceOf[js.Any])
    @scala.inline
    def deletePreventClose: Self = this.set("preventClose", js.undefined)
  }
  
}