Skip to content
This repository has been archived by the owner on Feb 10, 2023. It is now read-only.

Commit

Permalink
Merge pull request #101 from rpiaggio/as
Browse files Browse the repository at this point in the history
Add missing as.toJsObject. Specific types in withChildren and addModifiers.
  • Loading branch information
rpiaggio authored Mar 14, 2020
2 parents e901ea7 + 3658992 commit 0e865d1
Show file tree
Hide file tree
Showing 84 changed files with 300 additions and 281 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changes

## 0.3.7

* Protected cprops.
* Specific types in withChildren and addModifiers.
* Passthrough properties in some components.

## 0.3.5

* Support Form, FormField, FormGroup component
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ lazy val facade =
"com.github.japgolly.scalajs-react" %%% "core" % scalaJsReact,
"com.github.japgolly.scalajs-react" %%% "extra" % scalaJsReact,
"com.github.japgolly.scalajs-react" %%% "test" % scalaJsReact % Test,
"io.github.cquiroz.react" %%% "common" % "0.6.0",
"io.github.cquiroz.react" %%% "common" % "0.6.2",
"com.lihaoyi" %%% "utest" % "0.7.4" % Test,
"org.typelevel" %%% "cats-core" % "2.1.1" % Test
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import react.common._
import react.semanticui._
import react.semanticui.elements.button.Button
import react.semanticui.elements.icon.Icon
import react.semanticui.modules.modal._
import react.semanticui.{ raw => suiraw }
import react.semanticui.modules.modal._

final case class Confirm(
as: js.UndefOr[AsC] = js.undefined,
Expand Down Expand Up @@ -47,9 +47,9 @@ final case class Confirm(
style: js.UndefOr[Style] = js.undefined,
trigger: js.UndefOr[VdomNode] = js.undefined,
override val children: CtorType.ChildrenArgs = Seq.empty
) extends GenericComponentPC[Confirm.ConfirmProps] {
override def cprops = Confirm.props(this)
@inline def renderWith = Confirm.component(Confirm.props(this))
) extends GenericComponentPC[Confirm.ConfirmProps, Confirm] {
override protected def cprops = Confirm.props(this)
@inline def renderWith = Confirm.component(Confirm.props(this))
override def withChildren(children: CtorType.ChildrenArgs) =
copy(children = children)
}
Expand Down Expand Up @@ -163,7 +163,7 @@ object Confirm {
style: js.UndefOr[Style] = js.undefined,
trigger: js.UndefOr[VdomNode] = js.undefined
): ConfirmProps = {
val p = (new js.Object).asInstanceOf[ConfirmProps]
val p = as.toJsObject[ConfirmProps]
p.as = as.toJs
p.actions = actions.toRaw
p.basic = basic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ final case class Portal(
openOnTriggerMouseEnter: js.UndefOr[Boolean] = js.undefined,
trigger: js.UndefOr[VdomNode] = js.undefined,
override val children: CtorType.ChildrenArgs = Seq.empty
) extends GenericComponentPC[Portal.PortalProps] {
override def cprops = Portal.props(this)
@inline def renderWith = Portal.component(Portal.props(this))
) extends GenericComponentPC[Portal.PortalProps, Portal] {
override protected def cprops = Portal.props(this)
@inline def renderWith = Portal.component(Portal.props(this))
override def withChildren(children: CtorType.ChildrenArgs) =
copy(children = children)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ final case class PortalInner(
onUnmountE: js.UndefOr[PortalInner.OnUnmount] = js.undefined,
onUnmount: js.UndefOr[Callback] = js.undefined,
override val children: CtorType.ChildrenArgs = Seq.empty
) extends GenericComponentPC[PortalInner.PortalInnerProps] {
override def cprops = PortalInner.props(this)
@inline def renderWith = PortalInner.component(PortalInner.props(this))
) extends GenericComponentPC[PortalInner.PortalInnerProps, PortalInner] {
override protected def cprops = PortalInner.props(this)
@inline def renderWith = PortalInner.component(PortalInner.props(this))
override def withChildren(children: CtorType.ChildrenArgs) =
copy(children = children)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ final case class Radio(
`type`: js.UndefOr[CheckboxType] = CheckboxType.Radio,
value: js.UndefOr[String | JsNumber] = js.undefined
) extends GenericComponentP[Radio.RadioProps] {
override def cprops = Radio.props(this)
@inline def render = Radio.component(Radio.props(this))
override protected def cprops = Radio.props(this)
@inline def render = Radio.component(Radio.props(this))
}

object Radio {
Expand Down
57 changes: 28 additions & 29 deletions facade/src/main/scala/react/semanticui/collections/form/Form.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,30 @@ import react.common._
import react.semanticui._
import react.semanticui.{ raw => suiraw }
import org.scalajs.dom
import japgolly.scalajs.react.vdom.TagMod

final case class Form(
as: js.UndefOr[AsC] = js.undefined,
action: js.UndefOr[String] = js.undefined,
child: js.UndefOr[VdomNode] = js.undefined,
className: js.UndefOr[String] = js.undefined,
clazz: js.UndefOr[Css] = js.undefined,
error: js.UndefOr[Boolean] = js.undefined,
inverted: js.UndefOr[Boolean] = js.undefined,
loading: js.UndefOr[Boolean] = js.undefined,
onSubmitE: js.UndefOr[Form.OnSubmitE] = js.undefined,
onSubmit: js.UndefOr[Callback] = js.undefined,
reply: js.UndefOr[Boolean] = js.undefined,
size: js.UndefOr[SemanticSize] = js.undefined,
success: js.UndefOr[Boolean] = js.undefined,
unstackable: js.UndefOr[Boolean] = js.undefined,
warning: js.UndefOr[Boolean] = js.undefined,
widths: js.UndefOr[FormWidths] = js.undefined,
override val children: CtorType.ChildrenArgs = Seq.empty
) extends GenericComponentPC[Form.FormProps] {
override def cprops = Form.props(this)
@inline def renderWith =
Form.component(Form.props(this))
override def withChildren(children: CtorType.ChildrenArgs) =
copy(children = children)
as: js.UndefOr[AsC] = js.undefined,
action: js.UndefOr[String] = js.undefined,
child: js.UndefOr[VdomNode] = js.undefined,
className: js.UndefOr[String] = js.undefined,
clazz: js.UndefOr[Css] = js.undefined,
error: js.UndefOr[Boolean] = js.undefined,
inverted: js.UndefOr[Boolean] = js.undefined,
loading: js.UndefOr[Boolean] = js.undefined,
onSubmitE: js.UndefOr[Form.OnSubmitE] = js.undefined,
onSubmit: js.UndefOr[Callback] = js.undefined,
reply: js.UndefOr[Boolean] = js.undefined,
size: js.UndefOr[SemanticSize] = js.undefined,
success: js.UndefOr[Boolean] = js.undefined,
unstackable: js.UndefOr[Boolean] = js.undefined,
warning: js.UndefOr[Boolean] = js.undefined,
widths: js.UndefOr[FormWidths] = js.undefined,
override val modifiers: Seq[TagMod] = Seq.empty
) extends GenericComponentPAC[Form.FormProps, Form] {
override protected def cprops = Form.props(this)
override protected val component = Form.component
override def addModifiers(modifiers: Seq[TagMod]) = copy(modifiers = this.modifiers ++ modifiers)
}

object Form {
Expand Down Expand Up @@ -135,7 +134,7 @@ object Form {
warning: js.UndefOr[Boolean] = js.undefined,
widths: js.UndefOr[FormWidths] = js.undefined
): FormProps = {
val p = (new js.Object).asInstanceOf[FormProps]
val p = as.toJsObject[FormProps]
p.as = as.toJs
p.action = action
p.children = child.toJs
Expand All @@ -153,13 +152,13 @@ object Form {
p
}

private lazy val component =
JsComponent[FormProps, Children.Varargs, Null](RawComponent)

val Default: Form = Form()

val defaultProps: FormProps = props(Default)

private val component =
JsComponent[FormProps, Children.Varargs, Null](RawComponent)

def apply(content: VdomNode*): Form =
new Form(children = content)
def apply(content: TagMod*): Form =
Form(modifiers = content)
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ final case class FormField(
`type`: js.UndefOr[String] = js.undefined,
width: js.UndefOr[SemanticWidth] = js.undefined,
override val children: CtorType.ChildrenArgs = Seq.empty
) extends GenericComponentPC[FormField.FormFieldProps] {
override def cprops = FormField.props(this)
) extends GenericComponentPC[FormField.FormFieldProps, FormField] {
override protected def cprops = FormField.props(this)
@inline def renderWith =
FormField.component(FormField.props(this))
override def withChildren(children: CtorType.ChildrenArgs) =
Expand Down Expand Up @@ -120,7 +120,7 @@ object FormField {
`type`: js.UndefOr[String] = js.undefined,
width: js.UndefOr[SemanticWidth] = js.undefined
): FormFieldProps = {
val p = (new js.Object).asInstanceOf[FormFieldProps]
val p = as.toJsObject[FormFieldProps]
p.as = as.toJs
p.children = child.toJs
p.className = (className, clazz).toJs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ final case class FormGroup(
unstackable: js.UndefOr[Boolean] = js.undefined,
widths: js.UndefOr[SemanticWidth | FormWidths] = js.undefined,
override val children: CtorType.ChildrenArgs = Seq.empty
) extends GenericComponentPC[FormGroup.FormGroupProps] {
override def cprops = FormGroup.props(this)
) extends GenericComponentPC[FormGroup.FormGroupProps, FormGroup] {
override protected def cprops = FormGroup.props(this)
@inline def renderWith =
FormGroup.component(FormGroup.props(this))
override def withChildren(children: CtorType.ChildrenArgs) =
Expand Down Expand Up @@ -93,7 +93,7 @@ object FormGroup {
unstackable: js.UndefOr[Boolean] = js.undefined,
widths: js.UndefOr[SemanticWidth | FormWidths] = js.undefined
): FormGroupProps = {
val p = (new js.Object).asInstanceOf[FormGroupProps]
val p = as.toJsObject[FormGroupProps]
p.as = as.toJs
p.children = child.toJs
p.className = (className, clazz).toJs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ final case class Grid(
textAlign: js.UndefOr[SemanticTextAlignment] = js.undefined,
verticalAlign: js.UndefOr[SemanticVerticalAlignment] = js.undefined,
override val children: CtorType.ChildrenArgs = Seq.empty
) extends GenericFnComponentPC[Grid.GridProps] {
override def cprops = Grid.props(this)
) extends GenericFnComponentPC[Grid.GridProps, Grid] {
override protected def cprops = Grid.props(this)
override def withChildren(children: CtorType.ChildrenArgs) =
copy(children = children)
@inline def renderWith =
Expand Down Expand Up @@ -152,7 +152,7 @@ object Grid {
textAlign: js.UndefOr[SemanticTextAlignment] = js.undefined,
verticalAlign: js.UndefOr[SemanticVerticalAlignment] = js.undefined
): GridProps = {
val p = (new js.Object).asInstanceOf[GridProps]
val p = as.toJsObject[GridProps]
p.as = as.toJs
p.celled = celled.toJs
p.centered = centered
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ final case class GridColumn(
widescreen: js.UndefOr[SemanticWidth] = js.undefined,
width: js.UndefOr[SemanticWidth] = js.undefined,
override val children: CtorType.ChildrenArgs = Seq.empty
) extends GenericFnComponentPC[GridColumn.GridColumnProps] {
override def cprops = GridColumn.props(this)
) extends GenericFnComponentPC[GridColumn.GridColumnProps, GridColumn] {
override protected def cprops = GridColumn.props(this)
override def withChildren(children: CtorType.ChildrenArgs) =
copy(children = children)
@inline def renderWith =
Expand Down Expand Up @@ -135,7 +135,7 @@ object GridColumn {
widescreen: js.UndefOr[SemanticWidth] = js.undefined,
width: js.UndefOr[SemanticWidth] = js.undefined
): GridColumnProps = {
val p = (new js.Object).asInstanceOf[GridColumnProps]
val p = as.toJsObject[GridColumnProps]
p.as = as.toJs
p.children = children.toJs
p.className = (className, clazz).toJs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ final case class GridRow(
textAlign: js.UndefOr[SemanticTextAlignment] = js.undefined,
verticalAlign: js.UndefOr[SemanticVerticalAlignment] = js.undefined,
override val children: CtorType.ChildrenArgs = Seq.empty
) extends GenericFnComponentPC[GridRow.GridRowProps] {
override def cprops = GridRow.props(this)
) extends GenericFnComponentPC[GridRow.GridRowProps, GridRow] {
override protected def cprops = GridRow.props(this)
override def withChildren(children: CtorType.ChildrenArgs) =
copy(children = children)
@inline def renderWith =
Expand Down Expand Up @@ -112,7 +112,7 @@ object GridRow {
textAlign: js.UndefOr[SemanticTextAlignment] = js.undefined,
verticalAlign: js.UndefOr[SemanticVerticalAlignment] = js.undefined
): GridRowProps = {
val p = (new js.Object).asInstanceOf[GridRowProps]
val p = as.toJsObject[GridRowProps]
p.as = as.toJs
p.centered = centered
p.children = children.toJs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ final case class Menu(
vertical: js.UndefOr[Boolean] = js.undefined,
widths: js.UndefOr[SemanticWidth] = js.undefined,
override val children: CtorType.ChildrenArgs = Seq.empty
) extends GenericComponentPC[Menu.MenuProps] {
override def cprops = Menu.props(this)
) extends GenericComponentPC[Menu.MenuProps, Menu] {
override protected def cprops = Menu.props(this)
@inline def renderWith =
Menu.component(Menu.props(this))
override def withChildren(children: CtorType.ChildrenArgs) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ final case class MenuHeader(
clazz: js.UndefOr[Css] = js.undefined,
content: js.UndefOr[VdomNode] = js.undefined,
override val children: CtorType.ChildrenArgs = Seq.empty
) extends GenericFnComponentPC[MenuHeader.MenuHeaderProps] {
override def cprops = MenuHeader.props(this)
) extends GenericFnComponentPC[MenuHeader.MenuHeaderProps, MenuHeader] {
override protected def cprops = MenuHeader.props(this)
override def withChildren(children: CtorType.ChildrenArgs) =
copy(children = children)
@inline def renderWith =
Expand Down Expand Up @@ -63,7 +63,7 @@ object MenuHeader {
clazz: js.UndefOr[Css] = js.undefined,
content: js.UndefOr[VdomNode] = js.undefined
): MenuHeaderProps = {
val p = (new js.Object).asInstanceOf[MenuHeaderProps]
val p = as.toJsObject[MenuHeaderProps]
p.as = as.toJs
p.children = children.toJs
p.className = (className, clazz).toJs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ final case class MenuItem(
onClick: js.UndefOr[Callback] = js.undefined,
position: js.UndefOr[MenuItemPosition] = js.undefined,
override val children: CtorType.ChildrenArgs = Seq.empty
) extends GenericComponentPC[MenuItem.MenuItemProps] {
override def cprops = MenuItem.props(this)
) extends GenericComponentPC[MenuItem.MenuItemProps, MenuItem] {
override protected def cprops = MenuItem.props(this)
@inline def renderWith =
MenuItem.component(MenuItem.props(this))
override def withChildren(children: CtorType.ChildrenArgs) =
Expand Down Expand Up @@ -148,7 +148,7 @@ object MenuItem {
onClick: js.UndefOr[Callback] = js.undefined,
position: js.UndefOr[MenuItemPosition] = js.undefined
): MenuItemProps = {
val p = (new js.Object).asInstanceOf[MenuItemProps]
val p = as.toJsObject[MenuItemProps]
p.as = as.toJs
p.active = active
p.children = children.toJs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ final case class MenuMenu(
content: js.UndefOr[VdomNode] = js.undefined,
position: js.UndefOr[MenuMenuPosition] = js.undefined,
override val children: CtorType.ChildrenArgs = Seq.empty
) extends GenericFnComponentPC[MenuMenu.MenuMenuProps] {
override def cprops = MenuMenu.props(this)
) extends GenericFnComponentPC[MenuMenu.MenuMenuProps, MenuMenu] {
override protected def cprops = MenuMenu.props(this)
override def withChildren(children: CtorType.ChildrenArgs) =
copy(children = children)
@inline def renderWith =
Expand Down Expand Up @@ -68,7 +68,7 @@ object MenuMenu {
content: js.UndefOr[VdomNode] = js.undefined,
position: js.UndefOr[MenuMenuPosition] = js.undefined
): MenuMenuProps = {
val p = (new js.Object).asInstanceOf[MenuMenuProps]
val p = as.toJsObject[MenuMenuProps]
p.as = as.toJs
p.children = children.toJs
p.className = (className, clazz).toJs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ final case class Message(
visible: js.UndefOr[Boolean] = js.undefined,
warning: js.UndefOr[Boolean] = js.undefined,
override val children: CtorType.ChildrenArgs = Seq.empty
) extends GenericComponentPC[Message.MessageProps] {
override def cprops = Message.props(this)
) extends GenericComponentPC[Message.MessageProps, Message] {
override protected def cprops = Message.props(this)
@inline def renderWith =
Message.component(Message.props(this))
override def withChildren(children: CtorType.ChildrenArgs) =
Expand Down Expand Up @@ -186,7 +186,7 @@ object Message {
visible: js.UndefOr[Boolean] = js.undefined,
warning: js.UndefOr[Boolean] = js.undefined
): MessageProps = {
val p = (new js.Object).asInstanceOf[MessageProps]
val p = as.toJsObject[MessageProps]
p.as = as.toJs
p.attached = attached.toJs
p.children = children.toJs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ final case class MessageContent(
clazz: js.UndefOr[Css] = js.undefined,
content: js.UndefOr[VdomNode | MessageContent.MessageContentProps] = js.undefined,
override val children: CtorType.ChildrenArgs = Seq.empty
) extends GenericComponentPC[MessageContent.MessageContentProps] {
override def cprops = MessageContent.props(this)
) extends GenericComponentPC[MessageContent.MessageContentProps, MessageContent] {
override protected def cprops = MessageContent.props(this)
@inline def renderWith =
MessageContent.component(MessageContent.props(this))
override def withChildren(children: CtorType.ChildrenArgs) =
Expand Down Expand Up @@ -70,7 +70,7 @@ object MessageContent {
clazz: js.UndefOr[Css] = js.undefined,
content: js.UndefOr[VdomNode | MessageContent.MessageContentProps] = js.undefined
): MessageContentProps = {
val p = (new js.Object).asInstanceOf[MessageContentProps]
val p = as.toJsObject[MessageContentProps]
p.as = as.toJs
p.children = children.toJs
p.className = (className, clazz).toJs
Expand Down
Loading

0 comments on commit 0e865d1

Please sign in to comment.