Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to scala 3 #12

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .bsp/sbt.json

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ local.properties
.metals/
project/metals.sbt
out/
.bsp/
18 changes: 15 additions & 3 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
version=2.6.1
version=3.0.0-RC5
runner.dialect = scala3
style = default
danglingParentheses.preset = true
align {
tokens.add = [":", "="]
}
maxColumn = 120
rewrite.rules = [SortImports, RedundantBraces, RedundantParens, PreferCurlyFors]

rewrite {
rules = [SortImports, RedundantBraces, RedundantParens, PreferCurlyFors]
scala3 = {
convertToNewSyntax = true,
removeOptionalBraces: yes,
insertEndMarkerMinLines = 10
}
}
project.excludeFilters = [
node_modules,
target
Expand Down
44 changes: 22 additions & 22 deletions antd/src/main/scala/demo/App.scala
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package demo

import japgolly.scalajs.react.vdom.html_<^._
import japgolly.scalajs.react.vdom.html_<^.*
import japgolly.scalajs.react.{Callback, ScalaFnComponent}
import typings.antDesignIcons.components.AntdIcon
import typings.antDesignIconsSvg.downOutlinedMod.{default => DownOutlinedIcon}
import typings.antDesignIconsSvg.downloadOutlinedMod.{default => DownloadOutlinedIcon}
import typings.antDesignIconsSvg.homeOutlinedMod.{default => HomeOutlinedIcon}
import typings.antDesignIconsSvg.lockTwoToneMod.{default => LockTwoToneIcon}
import typings.antDesignIconsSvg.mailTwoToneMod.{default => MailTwoToneIcon}
import typings.antDesignIconsSvg.shopOutlinedMod.{default => ShopOutlinedIcon}
import typings.antDesignIconsSvg.userOutlinedMod.{default => UserOutlinedIcon}
import typings.antDesignIconsSvg.downOutlinedMod.default as DownOutlinedIcon
import typings.antDesignIconsSvg.downloadOutlinedMod.default as DownloadOutlinedIcon
import typings.antDesignIconsSvg.homeOutlinedMod.default as HomeOutlinedIcon
import typings.antDesignIconsSvg.lockTwoToneMod.default as LockTwoToneIcon
import typings.antDesignIconsSvg.mailTwoToneMod.default as MailTwoToneIcon
import typings.antDesignIconsSvg.shopOutlinedMod.default as ShopOutlinedIcon
import typings.antDesignIconsSvg.userOutlinedMod.default as UserOutlinedIcon
import typings.antd.antdStrings
import typings.antd.components.{List => AntList, _}
import typings.antd.notificationMod.{ArgsProps, IconType, default => Notification}
import typings.antd.components.{List as AntList, *}
import typings.antd.notificationMod.{ArgsProps, IconType, default as Notification}
import typings.antd.tableInterfaceMod.{ColumnGroupType, ColumnType}
import typings.react.mod.useState
import typings.rcSelect.interfaceMod.OptionData
Expand All @@ -25,13 +25,13 @@ import scala.scalajs.js.annotation.JSImport
@js.native
object CSS extends js.Any

object App {
object App:

private val css = CSS // touch to load

val component = ScalaFnComponent[Unit] { _ =>
val js.Tuple2(isModalVisible, updateIsModalVisible) = useState(false)
val js.Tuple2(selectValue, updateSelectValue) = useState("lucy")
val js.Tuple2(isModalVisible, updateIsModalVisible) = useState(false)
val js.Tuple2(selectValue, updateSelectValue) = useState("lucy")
val js.Tuple2(multiSelectValue, updateMultiSelectValue) = useState(List("a10", "c12"))

val renderIntro = Row(
Expand Down Expand Up @@ -76,7 +76,7 @@ object App {
def renderTable =
<.section(
<.h2("Table"),
Table[TableItem]
Table[TableItem]()
.bordered(true)
.dataSourceVarargs(
new TableItem(1, "Mike", 32, "10 Downing St."),
Expand All @@ -91,8 +91,8 @@ object App {
// TODO: is a varargs constructor missing here?
ColumnGroupType[TableItem](
scala.scalajs.js.Array(
ColumnType[TableItem].setTitle("Age").setDataIndex("age").setKey("age"),
ColumnType[TableItem].setTitle("Address").setDataIndex("address").setKey("address")
ColumnType[TableItem]().setTitle("Age").setDataIndex("age").setKey("age"),
ColumnType[TableItem]().setTitle("Address").setDataIndex("address").setKey("address")
)
).setTitle("Age & Address")
)
Expand Down Expand Up @@ -129,7 +129,7 @@ object App {

val renderSelect = <.section(
<.h2("Select"),
Select[String]
Select[String]()
.defaultValue(selectValue)
.onChange((changedValue, _) => Callback(updateSelectValue(changedValue)))(
Option("jack")("Jack"),
Expand All @@ -141,8 +141,8 @@ object App {

val renderMultiSelect = <.section(
<.h2("Multiple select"),
Select[js.Array[String]]
.defaultValue(js.Array(multiSelectValue: _*))
Select[js.Array[String]]()
.defaultValue(js.Array(multiSelectValue*))
.mode(antdStrings.multiple)
.onChange((changedValue, _) => Callback(updateMultiSelectValue(changedValue.toList)))(
(10 until 36).map { n =>
Expand All @@ -154,7 +154,7 @@ object App {

val renderGroupSelect = <.section(
<.h2("Select with grouped options"),
Select[String]
Select[String]()
.defaultValue(selectValue)
.onChange((changedValue, _) => Callback(updateSelectValue(changedValue)))(
Select.OptGroup.label("Manager")(
Expand Down Expand Up @@ -368,7 +368,7 @@ object App {
.description("Description")
): VdomElement

AntList()(Seq.fill(3)(item): _*)
AntList()(Seq.fill(3)(item)*)
}
)

Expand Down Expand Up @@ -455,4 +455,4 @@ object App {
)
)
}
}
end App
12 changes: 6 additions & 6 deletions antd/src/main/scala/demo/CoordinatedDemo.scala
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package demo

import japgolly.scalajs.react.{Callback, ScalaFnComponent}
import japgolly.scalajs.react.vdom.html_<^._
import japgolly.scalajs.react.vdom.html_<^.*
import org.scalablytyped.runtime.StringDictionary
import typings.antd.antdStrings
import typings.antd.components._
import typings.antd.components.*
import typings.antd.formFormMod.useForm
import typings.antd.gridColMod.ColProps
import typings.rcFieldForm.interfaceMod.BaseRule
import typings.std.global.console

object CoordinatedDemo {
object CoordinatedDemo:
val component = ScalaFnComponent[String] { noteTitle =>
val form = useForm().head
Form
Expand All @@ -28,14 +28,14 @@ object CoordinatedDemo {
.label("Gender")
.name("gender")
.rulesVarargs(BaseRule().setRequired(true).setMessage("Please select your gender!'"))(
Select[String]
Select[String]()
.placeholder("Select a option and change input text above")
.onChange { (value, _) =>
Callback(
form.setFieldsValue(
StringDictionary(
"gender" -> value,
"note" -> s"Hi, ${if (value == "male") "man" else "lady"}!"
"note" -> s"Hi, ${if value == "male" then "man" else "lady"}!"
)
)
)
Expand All @@ -49,4 +49,4 @@ object CoordinatedDemo {
)
)
}
}
end CoordinatedDemo
12 changes: 5 additions & 7 deletions antd/src/main/scala/demo/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ import org.scalajs.dom
import scala.scalajs.js
import scala.scalajs.js.annotation.JSImport

object Main {
def main(args: Array[String]): Unit = {
IndexCSS
App.component().renderIntoDOM(dom.document.getElementById("container"))
}
}

@JSImport("./index.css", JSImport.Namespace)
@js.native
object IndexCSS extends js.Object

@main
def main: Unit =
IndexCSS
App.component().renderIntoDOM(dom.document.getElementById("container"))
39 changes: 19 additions & 20 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ lazy val baseSettings: Project => Project =
_.enablePlugins(ScalaJSPlugin)
.settings(
version := "0.1-SNAPSHOT",
scalaVersion := "2.13.2",
scalaVersion := "3.0.1",
scalacOptions ++= ScalacOptions.flags,
scalaJSUseMainModuleInitializer := true,
/* disabled because it somehow triggers many warnings */
Expand All @@ -56,7 +56,7 @@ lazy val `react-mobx` =
.settings(
useYarn := true,
webpackDevServerPort := 8001,
stFlavour := Flavour.Japgolly,
stFlavour := Flavour.ScalajsReact,
Compile / npmDependencies ++= Seq(
"mobx" -> "5.15.4",
"mobx-react" -> "6.2.2"
Expand All @@ -70,7 +70,7 @@ lazy val `react-slick` =
.settings(
useYarn := true,
webpackDevServerPort := 8002,
stFlavour := Flavour.Japgolly,
stFlavour := Flavour.ScalajsReact,
Compile / npmDependencies ++= Seq(
"react-slick" -> "0.23",
"@types/react-slick" -> "0.23.4"
Expand All @@ -84,7 +84,7 @@ lazy val `react-big-calendar` =
.settings(
useYarn := true,
webpackDevServerPort := 8003,
stFlavour := Flavour.Japgolly,
stFlavour := Flavour.ScalajsReact,
Compile / npmDependencies ++= Seq(
"moment" -> "2.24.0",
"react-big-calendar" -> "0.24.4",
Expand All @@ -98,7 +98,7 @@ lazy val `semantic-ui-react-kitchensink` = project
.settings(
useYarn := true,
webpackDevServerPort := 8004,
stFlavour := Flavour.Japgolly,
stFlavour := Flavour.ScalajsReact,
stReactEnableTreeShaking := Selection.All,
Compile / npmDependencies ++= Seq(
"semantic-ui-react" -> "0.88.2"
Expand All @@ -118,7 +118,7 @@ lazy val `storybook-react` = project
Process("yarn", baseDirectory.value).!
baseDirectory.value
},
stFlavour := Flavour.Japgolly,
stFlavour := Flavour.ScalajsReact,
/** This is not suitable for development, but effective for demo.
* Run `yarn storybook` commands yourself, and run `~storybook-react/fastOptJS` from sbt
*/
Expand All @@ -141,7 +141,7 @@ lazy val antd =
.settings(
useYarn := true,
webpackDevServerPort := 8006,
stFlavour := Flavour.Japgolly,
stFlavour := Flavour.ScalajsReact,
Compile / npmDependencies ++= Seq("antd" -> "4.5.1")
)

Expand All @@ -152,7 +152,7 @@ lazy val `react-router-dom` =
.settings(
useYarn := true,
webpackDevServerPort := 8007,
stFlavour := Flavour.Japgolly,
stFlavour := Flavour.ScalajsReact,
Compile / npmDependencies ++= Seq(
"react-router-dom" -> "5.1.2",
"@types/react-router-dom" -> "5.1.2" // note 5.1.4 did weird things to the Link component
Expand All @@ -166,7 +166,7 @@ lazy val `material-ui` =
.settings(
useYarn := true,
webpackDevServerPort := 8008,
stFlavour := Flavour.Japgolly,
stFlavour := Flavour.ScalajsReact,
stReactEnableTreeShaking := Selection.All,
Compile / npmDependencies ++= Seq(
"@material-ui/core" -> "3.9.4", // note: version 4 is not supported yet
Expand All @@ -186,7 +186,7 @@ lazy val `react-leaflet` = project
.settings(
useYarn := true,
webpackDevServerPort := 8009,
stFlavour := Flavour.Japgolly,
stFlavour := Flavour.ScalajsReact,
Compile / npmDependencies ++= Seq(
"react-leaflet" -> "2.6.3",
"@types/react-leaflet" -> "2.5.1",
Expand All @@ -200,7 +200,7 @@ lazy val `office-ui-fabric-react` = project
.settings(
useYarn := true,
webpackDevServerPort := 8010,
stFlavour := Flavour.Japgolly,
stFlavour := Flavour.ScalajsReact,
stReactEnableTreeShaking := Selection.All,
Compile / npmDependencies ++= Seq(
"office-ui-fabric-react" -> "7.107.1"
Expand All @@ -213,7 +213,7 @@ lazy val `react-dnd` = project
.settings(
useYarn := true,
webpackDevServerPort := 8011,
stFlavour := Flavour.Japgolly,
stFlavour := Flavour.ScalajsReact,
Compile / npmDependencies ++= Seq(
"react-dnd" -> "11.1.3",
"react-dnd-html5-backend" -> "11.1.3"
Expand All @@ -226,7 +226,7 @@ lazy val `react-i18n` = project
.settings(
useYarn := true,
webpackDevServerPort := 8012,
stFlavour := Flavour.Japgolly,
stFlavour := Flavour.ScalajsReact,
Compile / npmDependencies ++= Seq(
"i18next" -> "19.5.2",
"i18next-browser-languagedetector" -> "5.0.0",
Expand All @@ -240,7 +240,7 @@ lazy val `nivo` = project
.settings(
useYarn := true,
webpackDevServerPort := 8013,
stFlavour := Flavour.Japgolly,
stFlavour := Flavour.ScalajsReact,
Compile / npmDependencies ++= Seq(
"@nivo/line" -> "0.62.0"
)
Expand All @@ -252,7 +252,7 @@ lazy val downshift = project
.settings(
useYarn := true,
webpackDevServerPort := 8014,
stFlavour := Flavour.Japgolly,
stFlavour := Flavour.ScalajsReact,
Compile / npmDependencies ++= Seq(
"downshift" -> "6.0.5"
)
Expand All @@ -264,7 +264,7 @@ lazy val `react-redux` = project
.settings(
useYarn := true,
webpackDevServerPort := 8015,
stFlavour := Flavour.Japgolly,
stFlavour := Flavour.ScalajsReact,
stReactEnableTreeShaking := Selection.All,
Compile / npmDependencies ++= Seq(
"react-redux" -> "7.1",
Expand All @@ -279,7 +279,7 @@ lazy val `react-window` = project
.settings(
useYarn := true,
webpackDevServerPort := 8016,
stFlavour := Flavour.Japgolly,
stFlavour := Flavour.ScalajsReact,
stReactEnableTreeShaking := Selection.All,
Compile / npmDependencies ++= Seq(
"react-window" -> "1.8.6",
Expand All @@ -293,10 +293,9 @@ lazy val `react-markdown` = project
.enablePlugins(ScalablyTypedConverterPlugin)
.configure(baseSettings, withCssLoading, browserProject, reactNpmDeps, bundlerSettings)
.settings(
webpack / version := "4.44.1",
useYarn := true,
webpackDevServerPort := 8017,
stFlavour := Flavour.Japgolly,
stFlavour := Flavour.ScalajsReact,
Compile / npmDependencies ++= Seq(
"react-markdown"-> "^5.0.3",
"react-syntax-highlighter"-> "^15.4.3",
Expand All @@ -318,7 +317,7 @@ lazy val `react-native` = project
Process("yarn", baseDirectory.value).!
baseDirectory.value
},
stFlavour := Flavour.Japgolly,
stFlavour := Flavour.ScalajsReact,
stStdlib := List("es5"),
run := {
(Compile / fastOptJS).value
Expand Down
12 changes: 6 additions & 6 deletions docs/antd/antd-opt-bundle.js

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions docs/downshift/downshift-opt-bundle.js

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions docs/material-ui/material-ui-opt-bundle.js

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions docs/nivo/nivo-opt-bundle.js

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions docs/office-ui-fabric-react/office-ui-fabric-react-opt-bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/react-big-calendar/react-big-calendar-opt-bundle.js

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions docs/react-dnd/react-dnd-opt-bundle.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions docs/react-i18n/react-i18n-opt-bundle.js

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions docs/react-leaflet/react-leaflet-opt-bundle.js

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions docs/react-markdown/react-markdown-opt-bundle.js

Large diffs are not rendered by default.

Loading