All Downloads are FREE. Search and download functionalities are using the official Maven repository.

be.doeraene.webcomponents.ui5.UploadCollectionItem.scala Maven / Gradle / Ivy

There is a newer version: 2.0.0
Show newest version
package be.doeraene.webcomponents.ui5

import be.doeraene.webcomponents.ui5.configkeys.{ButtonDesign, ColourScheme, IconName}
import be.doeraene.webcomponents.ui5.internal.Slot
import com.raquo.laminar.codecs.{BooleanAsAttrPresenceCodec, StringAsIsCodec}
import com.raquo.laminar.api.L.*
import com.raquo.laminar.tags.CustomHtmlTag
import com.raquo.laminar.keys.HtmlAttr
import com.raquo.laminar.nodes.ReactiveHtmlElement
import org.scalajs.dom

import scala.scalajs.js
import scala.scalajs.js.annotation.{JSImport, JSName}
import be.doeraene.webcomponents.ui5.configkeys.{ListMode, UploadState}
import be.doeraene.webcomponents.ui5.eventtypes.EventWithPreciseTarget
import be.doeraene.webcomponents.ui5.eventtypes.HasDetail
import be.doeraene.webcomponents.ui5.eventtypes.HasItem
import com.raquo.laminar.codecs.IntAsStringCodec
import be.doeraene.webcomponents.WebComponent

/** This component allows you to represent files before uploading them to a server, with the help of
  * ui5-upload-collection-item. It also allows you to show already uploaded files.
  *
  * @see
  *   the doc for more
  *   information.
  */
object UploadCollectionItem extends WebComponent {

  @js.native
  trait RawElement extends js.Object {
    def fileJS: dom.File | Null = js.native

    def progress: Int = js.native

    def fileName: String = js.native
  }

  object RawElement {
    extension (element: RawElement) def file: Option[dom.File] = Option(element.fileJS)
  }

  @js.native
  @JSImport("@ui5/webcomponents-fiori/dist/UploadCollectionItem.js", JSImport.Default)
  object RawImport extends js.Object

  // object-s are lazy so you need to actually use them in your code to prevent dead code elimination
  used(RawImport)

  type Ref = dom.html.Element with RawElement

  protected val tag: CustomHtmlTag[Ref] = CustomHtmlTag("ui5-upload-collection-item")

  lazy val disableDeleteButton: HtmlAttr[Boolean] =
    htmlAttr("disable-delete-button", BooleanAsAttrPresenceCodec)

  lazy val fileName: HtmlAttr[String] =
    htmlAttr("file-name", StringAsIsCodec)

  lazy val fileNameClickable: HtmlAttr[Boolean] =
    htmlAttr("file-name-clickable", BooleanAsAttrPresenceCodec)

  lazy val hideRetryButton: HtmlAttr[Boolean] =
    htmlAttr("hide-retry-button", BooleanAsAttrPresenceCodec)

  lazy val hideTerminateButton: HtmlAttr[Boolean] =
    htmlAttr("hide-terminate-button", BooleanAsAttrPresenceCodec)

  lazy val progress: HtmlAttr[Int] = htmlAttr("progress", IntAsStringCodec)

  lazy val uploadState: HtmlAttr[UploadState] =
    htmlAttr("upload-state", UploadState.AsStringCodec)

  object slots {
    val thumbnail: Slot = new Slot("thumbnail")
  }

  object events {
    val onFileNameClick: EventProp[EventWithPreciseTarget[Ref]] = new EventProp("file-name-click")
    val onRename: EventProp[EventWithPreciseTarget[Ref]]        = new EventProp("rename")
    val onRetry: EventProp[EventWithPreciseTarget[Ref]]         = new EventProp("retry")
    val onTerminate: EventProp[EventWithPreciseTarget[Ref]]     = new EventProp("terminate")
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy