package facades.antd.data
import com.payalabs.scalajs.react.bridge.{ReactBridgeComponent, WithProps}
import japgolly.scalajs.react.raw.React
import scala.scalajs.js
import scala.scalajs.js.annotation.JSImport
object Table extends ReactBridgeComponent {
@js.native
trait ColumnProps[T] extends js.Object {
var title: React.Node
var key: String
var render: js.UndefOr[(js.Dynamic, T, Int) => React.Node] // text, record, index => Node
var dataIndex: String
}
@JSImport("antd", "Table")
@js.native
object RawComponent extends js.Object
override lazy val componentValue = RawComponent
def apply[T](columns: js.Array[ColumnProps[T]], dataSource: js.Array[T], bordered: Boolean = false, childrenColumnName: js.UndefOr[js.Array[String]] = js.undefined): WithProps =
auto
}
@JSExportAll
case class User(name: String, email: String)
Table[User](
columns = (0 to 1)
.map(
e => {
val cp = new js.Object().asInstanceOf[ColumnProps[User]]
cp.title = <.span(e.toString).rawElement
cp.key = e.toString
cp.dataIndex = "name"
cp
}
)
.toJSArray,
dataSource = (0 to 100)
.map(e => {
User(s"User $e", s"[email protected]")
})
.toJSArray
)()
I would like to use the same "easy" writing style (e.g. apply the rewrite macro) I can use in the apply method, for ColumnProps (e.g. VdomNode instead of .rawElement, etc.)