Skip to content

Commit

Permalink
Merge pull request #145
Browse files Browse the repository at this point in the history
scalajs-react-2-and-scala-3
  • Loading branch information
nafg committed Jan 11, 2022
2 parents 7049c22 + 671eb6a commit effac87
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 30 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ target/
.bsp/
.vscode/
metals.sbt
*.semanticdb
/*/yarn.lock
42 changes: 22 additions & 20 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
import _root_.io.github.nafg.scalacoptions._
import sbtdynver.GitDirtySuffix


def myScalacOptions(version: String) =
ScalacOptions.all(version)(
(opts: options.Common) =>
opts.deprecation ++
opts.unchecked ++
opts.feature,
(_: options.V2).explaintypes,
(_: options.V2_13).Xlint("_"),
(opts: options.V2_13_6_+) =>
opts.WdeadCode ++
opts.WextraImplicit ++
opts.WnumericWiden ++
opts.XlintUnused ++
opts.WvalueDiscard ++
opts.Xsource("3")
)

inThisBuild(List(
organization := "io.github.nafg.scalajs-facades",
homepage := Some(url("https://github.com/nafg/scalajs-facades")),
licenses := List("Apache-2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0")),
developers := List(
Developer("nafg", "Naftoli Gugenheim", "[email protected]", url("https://github.com/nafg"))
),
crossScalaVersions := Seq("2.12.15", "2.13.7"),
crossScalaVersions := Seq("2.13.7", "3.0.2"),
scalaVersion := (ThisBuild / crossScalaVersions).value.last,
scalacOptions ++= Seq(
"-deprecation",
"-feature",
"-unchecked",
"-explaintypes",
"-Xlint:_",
"-Ywarn-dead-code",
"-Ywarn-extra-implicit",
"-Ywarn-numeric-widen",
"-Ywarn-unused:_",
"-Ywarn-value-discard"
),
scalacOptions ++=
(if (scalaVersion.value.startsWith("2.12."))
List("-language:higherKinds", "-Xfuture", "-Ypartial-unification")
else
Nil),
scalacOptions ++= myScalacOptions(scalaVersion.value),
dynverGitDescribeOutput ~= (_.map(o => o.copy(dirtySuffix = GitDirtySuffix("")))),
dynverSonatypeSnapshots := true,
githubWorkflowJobSetup +=
Expand Down Expand Up @@ -60,7 +62,8 @@ lazy val simpleFacade =
sjsCrossTarget,
sonatypeProfileName := "io.github.nafg",
libraryDependencies ++= Seq(
"com.github.japgolly.scalajs-react" %%% "extra" % "1.7.7",
"com.github.japgolly.scalajs-react" %%% "core" % "2.0.0",
"com.github.japgolly.scalajs-react" %%% "extra" % "2.0.0",
"me.shadaj" %%% "slinky-readwrite" % "0.7.0",
"org.scalameta" %%% "munit" % "0.7.29" % Test
)
Expand All @@ -79,7 +82,6 @@ def moduleConfig(npmName: String, npmVersion: String): Project => Project =
useYarn := true,
sonatypeProfileName := "io.github.nafg",
Compile / npmDependencies += npmName -> npmVersion,
libraryDependencies += "com.github.japgolly.scalajs-react" %%% "extra" % "1.7.7",
scalacOptions ++= (if (scalaJSVersion.startsWith("0.6.")) Seq("-P:scalajs:sjsDefinedByDefault") else Nil)
)

Expand Down
2 changes: 1 addition & 1 deletion project/FacadeGenerator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ object FacadeGenerator {
|${imports.map("import " + _).mkString("\n")}
|import scala.scalajs.js
|import scala.scalajs.js.annotation.JSImport
|import japgolly.scalajs.react.raw.React.ElementType
|import japgolly.scalajs.react.facade.React.ElementType
|import io.github.nafg.simplefacade.{FacadeModule, ${if (factoryMethods.isEmpty || info.maybeChildrenProp.isDefined) "" else "Factory, "}PropTypes}
|
|
Expand Down
1 change: 1 addition & 0 deletions project/build-build.sbt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
libraryDependencies += "com.lihaoyi" %% "os-lib" % "0.8.0"
libraryDependencies += "com.lihaoyi" %% "ujson" % "1.4.4"
libraryDependencies += "io.github.nafg.scalac-options" %% "scalac-options" % "0.1.9"
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import scala.scalajs.js
import scala.scalajs.js.annotation.JSImport

import japgolly.scalajs.react.Callback
import japgolly.scalajs.react.raw.React.ElementType
import japgolly.scalajs.react.facade.React.ElementType
import io.github.nafg.simplefacade.Implicits.{callbackToWriter, elementTypeWriter}
import io.github.nafg.simplefacade.{FacadeModule, PropTypes}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package io.github.nafg.scalajs.facades.reactselect

import scala.scalajs.js
import scala.scalajs.js.JSConverters._


class OptGroup[A](val label: String, val options: js.Array[A]) extends js.Object
object OptGroup {
def apply[A](label: String)(options: Seq[A]): Opt[A] =
new OptGroup[A](label, options.toJSArray)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package io.github.nafg.scalajs.facades
import scala.concurrent.Future
import scala.language.implicitConversions
import scala.scalajs.js
import scala.scalajs.js.JSConverters._
import scala.scalajs.js.|

import slinky.readwrite.{Reader, Writer}
Expand All @@ -14,14 +13,11 @@ package object reactselect {
implicit def readOptA[A]: Reader[Opt[A]] = _.asInstanceOf[Opt[A]]
implicit def writeOptA[A]: Writer[Opt[A]] = _.asInstanceOf[js.Object]

def OptGroup[A](label: String)(options: Seq[A]): Opt[A] =
new OptGroup[A](label, options.toJSArray)

def Opt[A](value: A): Opt[A] = value

implicit class Opt_fold[A](self: Opt[A]) {
def foldRaw[R](groupF: OptGroup[A] => R, optionF: A => R): R =
if (self.isInstanceOf[OptGroup[_]])
if ((self: Any).isInstanceOf[OptGroup[_]])
groupF(self.asInstanceOf[OptGroup[A]])
else
optionF(self.asInstanceOf[A])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package io.github.nafg.simplefacade
import scala.scalajs.js

import japgolly.scalajs.react.CallbackTo
import japgolly.scalajs.react.raw.React
import japgolly.scalajs.react.raw.React.ElementType
import japgolly.scalajs.react.facade.React
import japgolly.scalajs.react.facade.React.ElementType
import japgolly.scalajs.react.vdom.VdomElement
import japgolly.scalajs.react.vdom.html_<^.VdomNode

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ object PropTypes {
raw.addClassNameToProps()
new Multiple(
raw.nonEmptyChildren.toList.map(new Single("children", _)) :+
new Multiple(raw.props.asInstanceOf[AnyDict].map { case (k, v) => new Single(k, v) })
// see https://github.com/lampepfl/dotty/issues/14244
new Multiple(raw.props.asInstanceOf[AnyDict].toIterable.map { case (k, v) => new Single(k, v) })
)
}

Expand Down

0 comments on commit effac87

Please sign in to comment.