diff --git a/build.sbt b/build.sbt index 6f2a8d13..1e9ceb08 100644 --- a/build.sbt +++ b/build.sbt @@ -1,7 +1,7 @@ val reactJS = "16.13.1" -val scalaJsReact = "1.7.4" +val scalaJsReact = "1.7.5" val FUILess = "2.8.6" -val reactSUI = "1.1.1" +val reactSUI = "1.2.0" val Toasts = "0.6.5" parallelExecution in (ThisBuild, Test) := false @@ -142,7 +142,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.9.6", + "io.github.cquiroz.react" %%% "common" % "0.9.7", "com.lihaoyi" %%% "utest" % "0.7.4" % Test, "org.typelevel" %%% "cats-core" % "2.1.1" % Test ), diff --git a/facade/src/main/scala/react/semanticui/addons/confirm/Confirm.scala b/facade/src/main/scala/react/semanticui/addons/confirm/Confirm.scala index 7d7266d7..c8e26116 100644 --- a/facade/src/main/scala/react/semanticui/addons/confirm/Confirm.scala +++ b/facade/src/main/scala/react/semanticui/addons/confirm/Confirm.scala @@ -25,7 +25,7 @@ final case class Confirm( confirmButton: js.UndefOr[ShorthandS[Button]] = js.undefined, content: js.UndefOr[ShorthandS[ModalContent]] = js.undefined, defaultOpen: js.UndefOr[Boolean] = js.undefined, - dimmer: js.UndefOr[ModalDimmer] = js.undefined, + dimmer: js.UndefOr[Dimmer] = js.undefined, eventPool: js.UndefOr[String] = js.undefined, header: js.UndefOr[ShorthandS[ModalHeader]] = js.undefined, onActionClickE: js.UndefOr[Modal.OnActionClick] = js.undefined, @@ -136,7 +136,7 @@ object Confirm { confirmButton: js.UndefOr[ShorthandS[Button]] = js.undefined, content: js.UndefOr[ShorthandS[ModalContent]] = js.undefined, defaultOpen: js.UndefOr[Boolean] = js.undefined, - dimmer: js.UndefOr[ModalDimmer] = js.undefined, + dimmer: js.UndefOr[Dimmer] = js.undefined, eventPool: js.UndefOr[String] = js.undefined, header: js.UndefOr[ShorthandS[ModalHeader]] = js.undefined, onActionClickE: js.UndefOr[Modal.OnActionClick] = js.undefined, diff --git a/facade/src/main/scala/react/semanticui/modules/modal/Modal.scala b/facade/src/main/scala/react/semanticui/modules/modal/Modal.scala index 373ca4e1..dd7e6a84 100644 --- a/facade/src/main/scala/react/semanticui/modules/modal/Modal.scala +++ b/facade/src/main/scala/react/semanticui/modules/modal/Modal.scala @@ -26,7 +26,7 @@ final case class Modal( closeOnDocumentClick: js.UndefOr[Boolean] = js.undefined, content: js.UndefOr[ShorthandS[ModalContent]] = js.undefined, defaultOpen: js.UndefOr[Boolean] = js.undefined, - dimmer: js.UndefOr[ModalDimmer] = js.undefined, + dimmer: js.UndefOr[Dimmer | ModalDimmer] = js.undefined, eventPool: js.UndefOr[String] = js.undefined, header: js.UndefOr[ShorthandS[ModalHeader]] = js.undefined, onActionClickE: js.UndefOr[Modal.OnActionClick] = js.undefined, @@ -108,7 +108,9 @@ object Modal { var defaultOpen: js.UndefOr[Boolean] = js.native /** A modal can appear in a dimmer. */ - var dimmer: js.UndefOr[Boolean | String] = js.native + var dimmer + : js.UndefOr[Boolean | String | suiraw.SemanticShorthandItemS[ModalDimmer.ModalDimmerProps]] = + js.native /** Event pool namespace that is used to handle component events */ var eventPool: js.UndefOr[String] = js.native @@ -215,7 +217,7 @@ object Modal { closeOnDocumentClick: js.UndefOr[Boolean] = js.undefined, content: js.UndefOr[ShorthandS[ModalContent]] = js.undefined, defaultOpen: js.UndefOr[Boolean] = js.undefined, - dimmer: js.UndefOr[ModalDimmer] = js.undefined, + dimmer: js.UndefOr[Dimmer | ModalDimmer] = js.undefined, eventPool: js.UndefOr[String] = js.undefined, header: js.UndefOr[ShorthandS[ModalHeader]] = js.undefined, onActionClickE: js.UndefOr[OnActionClick] = js.undefined, @@ -242,7 +244,13 @@ object Modal { closeOnDocumentClick.foreach(v => p.closeOnDocumentClick = v) content.toJs.foreach(v => p.content = v) defaultOpen.foreach(v => p.defaultOpen = v) - dimmer.toJs.foreach(v => p.dimmer = v) + dimmer.foreach { v => + (v: Any) match { + case x: Dimmer => x.toJs + case x => x + } + } + eventPool.foreach(v => p.eventPool = v) header.toJs.foreach(v => p.header = v) (onActionClickE, onActionClick).toJs.foreach(v => p.onActionClick = v) diff --git a/facade/src/main/scala/react/semanticui/modules/modal/ModalDimmer.scala b/facade/src/main/scala/react/semanticui/modules/modal/ModalDimmer.scala new file mode 100644 index 00000000..82e032fc --- /dev/null +++ b/facade/src/main/scala/react/semanticui/modules/modal/ModalDimmer.scala @@ -0,0 +1,101 @@ +package react.semanticui.modules.modal + +import scala.scalajs.js +import js.annotation._ +import japgolly.scalajs.react._ +import japgolly.scalajs.react.vdom.VdomNode +import japgolly.scalajs.react.raw.React +import react.common._ +import react.semanticui._ +import react.semanticui.{ raw => suiraw } +import japgolly.scalajs.react.vdom.TagMod + +final case class ModalDimmer( + as: js.UndefOr[AsC] = js.undefined, + blurring: js.UndefOr[Boolean] = js.undefined, + className: js.UndefOr[String] = js.undefined, + clazz: js.UndefOr[Css] = js.undefined, + centered: js.UndefOr[Boolean] = js.undefined, + content: js.UndefOr[ShorthandS[VdomNode]] = js.undefined, + inverted: js.UndefOr[Boolean] = js.undefined, + scrolling: js.UndefOr[Boolean] = js.undefined, + override val modifiers: Seq[TagMod] = Seq.empty +) extends GenericFnComponentPAC[ModalDimmer.ModalDimmerProps, ModalDimmer] { + override protected def cprops = ModalDimmer.props(this) + override protected val component = ModalDimmer.component + override def addModifiers(modifiers: Seq[TagMod]) = copy(modifiers = this.modifiers ++ modifiers) +} + +object ModalDimmer { + @js.native + @JSImport("semantic-ui-react", "ModalDimmer") + object RawComponent extends js.Function1[js.Any, js.Any] { + def apply(i: js.Any): js.Any = js.native + } + + @js.native + trait ModalDimmerProps extends js.Object { + @JSBracketAccess + def apply(key: String): js.Any = js.native + + @JSBracketAccess + def update(key: String, v: js.Any): Unit = js.native + + /** An element type to render as (string or function). */ + var as: js.UndefOr[AsT] = js.native + + /** A dimmer can be blurred. */ + var blurring: js.UndefOr[Boolean] = js.native + + /** Primary content. */ + var children: js.UndefOr[React.Node] = js.native + + /** Additional classes. */ + var className: js.UndefOr[String] = js.native + + /** A dimmer can center its contents in the viewport. */ + var centered: js.UndefOr[Boolean] = js.native + + /** Shorthand for primary content. */ + var content: js.UndefOr[suiraw.SemanticShorthandContent] = js.native + + /** A dimmer can be inverted. */ + var inverted: js.UndefOr[Boolean] = js.native + + /** The node where the modal should mount. Defaults to document.body. */ + // mountNode?: any + + /** A dimmer can make body scrollable. */ + var scrolling: js.UndefOr[Boolean] = js.native + } + + def props(q: ModalDimmer): ModalDimmerProps = + rawprops(q.as, q.blurring, q.className, q.clazz, q.centered, q.content, q.inverted, q.scrolling) + + def rawprops( + as: js.UndefOr[AsC] = js.undefined, + blurring: js.UndefOr[Boolean] = js.undefined, + className: js.UndefOr[String] = js.undefined, + clazz: js.UndefOr[Css] = js.undefined, + centered: js.UndefOr[Boolean] = js.undefined, + content: js.UndefOr[ShorthandS[VdomNode]] = js.undefined, + inverted: js.UndefOr[Boolean] = js.undefined, + scrolling: js.UndefOr[Boolean] = js.undefined + ): ModalDimmerProps = { + val p = as.toJsObject[ModalDimmerProps] + as.toJs.foreach(v => p.as = v) + blurring.foreach(v => p.blurring = v) + (className, clazz).toJs.foreach(v => p.className = v) + centered.foreach(v => p.centered = v) + content.toJs.foreach(v => p.content = v) + inverted.foreach(v => p.inverted = v) + scrolling.foreach(v => p.scrolling = v) + p + } + + private val component = + JsFnComponent[ModalDimmerProps, Children.Varargs](RawComponent) + + def apply(modifiers: TagMod*): ModalDimmer = + new ModalDimmer(modifiers = modifiers) +} diff --git a/facade/src/main/scala/react/semanticui/modules/modal/package.scala b/facade/src/main/scala/react/semanticui/modules/modal/package.scala index 3c4c1498..1ac00780 100644 --- a/facade/src/main/scala/react/semanticui/modules/modal/package.scala +++ b/facade/src/main/scala/react/semanticui/modules/modal/package.scala @@ -4,13 +4,13 @@ import react.common.EnumValue import react.common.EnumValueB package modal { - sealed trait ModalDimmer extends Product with Serializable - object ModalDimmer { - implicit val enum: EnumValueB[ModalDimmer] = EnumValueB.toLowerCaseStringT(Dimmer) + sealed trait Dimmer extends Product with Serializable + object Dimmer { + implicit val enum: EnumValueB[Dimmer] = EnumValueB.toLowerCaseStringT(Dimmer) - case object Dimmer extends ModalDimmer - case object Blurring extends ModalDimmer - case object Inverted extends ModalDimmer + case object Dimmer extends Dimmer + case object Blurring extends Dimmer + case object Inverted extends Dimmer } sealed trait ModalSize extends Product with Serializable diff --git a/facade/src/test/scala/react/semanticui/modules/modal/ModalDimmerTests.scala b/facade/src/test/scala/react/semanticui/modules/modal/ModalDimmerTests.scala new file mode 100644 index 00000000..72059398 --- /dev/null +++ b/facade/src/test/scala/react/semanticui/modules/modal/ModalDimmerTests.scala @@ -0,0 +1,19 @@ +package react.semanticui.modules.modal + +import utest._ +import japgolly.scalajs.react.test._ +import japgolly.scalajs.react.vdom.html_<^._ + +object ModalDimmerTests extends TestSuite { + val tests = Tests { + test("render") { + val modal = ModalDimmer("Abc") + ReactTestUtils.withNewBodyElement { mountNode => + modal.renderIntoDOM(mountNode) + assert( + mountNode.innerHTML == """