Skip to content

Commit

Permalink
Scala 3.5.0 (#196)
Browse files Browse the repository at this point in the history
* Scala 3.5.0

* chore: update Scala version to 3.5.0

* chore: update laminarVersion to 17.1.0

Vars <3

* feat: Update password field rendering in UI5WidgetFactory

This commit updates the `UI5WidgetFactory` in the `modules/ui5` directory to include a new implementation for rendering a password input field. The `renderSecret` method now uses the `Input` component from the `com.raquo.laminar.api.L` package and sets the input type to "password". This change allows for rendering password fields with the appropriate input type in UI5 widgets.

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* feat: Update rendering of form fields in UI5WidgetFactory

This commit updates the `UI5WidgetFactory` in the `modules/ui5` directory to improve the rendering of form fields. The `renderVar` method now uses the `asForm` extension method from the `Form` object to render the form fields. This change ensures consistency in rendering across different types of form fields in UI5 widgets.

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* feat: Update dependencies and add scala-java-time library

This commit updates the dependencies in the `build.sbt` file. It updates the `web-components-ui5` library to version 2.0.0-RC1 and adds the `scala-java-time` library with version 2.6.0. These updates ensure compatibility with the latest versions of the dependencies and introduce new functionality provided by the `scala-java-time` library.

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* feat: Update dependencies and add scala-java-time library
Date support

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
  • Loading branch information
cheleb and renovate[bot] authored Aug 24, 2024
1 parent b8ca862 commit c246f35
Show file tree
Hide file tree
Showing 18 changed files with 256 additions and 173 deletions.
5 changes: 3 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ val scala33 = "3.5.0"

val tapirVersion = "1.11.1"

val laminarVersion = "17.0.0"
val laminarVersion = "17.1.0"

inThisBuild(
List(
Expand Down Expand Up @@ -161,6 +161,7 @@ lazy val core = scalajsProject("core", false)
.settings(scalacOptions ++= usedScalacOptions)
.settings(
libraryDependencies ++= Seq(
"io.github.cquiroz" %%% "scala-java-time" % "2.6.0",
"com.softwaremill.magnolia1_3" %%% "magnolia" % "1.3.7",
"com.raquo" %%% "laminar" % laminarVersion,
// "io.laminext" %%% "websocket" % laminarVersion,
Expand All @@ -182,7 +183,7 @@ lazy val ui5 = scalajsProject("ui5", false)
.dependsOn(core)
.settings(
libraryDependencies ++= Seq(
"be.doeraene" %%% "web-components-ui5" % "1.21.0"
"be.doeraene" %%% "web-components-ui5" % "2.0.0-RC1"
)
)

Expand Down
120 changes: 68 additions & 52 deletions examples/client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions examples/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
},
"license": "MIT",
"dependencies": {
"@ui5/webcomponents": "1.24.0",
"@ui5/webcomponents-fiori": "1.24.0",
"@ui5/webcomponents-icons": "1.24.0",
"@ui5/webcomponents": "2.0.1",
"@ui5/webcomponents-fiori": "2.0.1",
"@ui5/webcomponents-icons": "2.0.1",
"highlight.js": "^11.8.0",
"jsdom": "^9.9.0"
},
Expand Down
2 changes: 1 addition & 1 deletion examples/client/src/main/scala/HelloWorld.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ case class Sample(name: String, component: HtmlElement)

object App extends App {

val sample = Var(samples.tree.component)
val sample = Var(samples.list.component)

private def item(name: String) = SideNavigation.item(
_.text := name,
Expand Down
2 changes: 1 addition & 1 deletion examples/client/src/main/scala/samples/EitherSample.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ val either = Sample(
s"$item"
)
},
Form.renderVar(eitherVar)
eitherVar.asForm
)
}
)
2 changes: 1 addition & 1 deletion examples/client/src/main/scala/samples/EnumSample.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ val enums = Sample(
s"$item"
)
},
Form.renderVar(eitherVar)
eitherVar.asForm
)
}
)
14 changes: 9 additions & 5 deletions examples/client/src/main/scala/samples/ListElement.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@ import dev.cheleb.scalamigen.{*, given}

import com.raquo.laminar.api.L.*

case class Person2(name: String, age: Int)
case class Person2(id: Int, name: String, age: Int)

case class ListElement(
ints: List[Person2]
)

val listPersonVar = Var(ListElement(List(1, 2, 3).map(Person2("Vlad", _))))
val listPersonVar = Var(
ListElement(List(1, 2, 3).map(id => Person2(id, "Vlad", 20)))
)
val listIntVar = Var(List(1, 2, 3))

given (Person2 => Int) = _.id

val list = Sample(
"List",
div(
Expand All @@ -21,12 +25,12 @@ val list = Sample(
s"$item"
)
},
Form.renderVar(listPersonVar),
listPersonVar.asForm,
child <-- listIntVar.signal.map { item =>
div(
s"$item"
)
},
Form.renderVar(listIntVar)
}
// Form.renderVar(listIntVar)
)
)
8 changes: 7 additions & 1 deletion examples/client/src/main/scala/samples/Persons.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ import magnolia1.*

import io.github.iltotore.iron.*
import io.github.iltotore.iron.constraint.all.*
import samples.model.Password
import java.time.LocalDate

// Define some models
case class Person(
name: String,
password: Password,
birthDate: LocalDate,
fav: Pet,
pet: Option[Pet],
email: Option[String],
Expand All @@ -34,6 +38,8 @@ given Defaultable[Pet] with
val vlad =
Person(
"Vlad",
Password("not a password"),
LocalDate.of(1431, 11, 8),
Pet("Batman", 666, House(2), 169),
Some(Pet("Wolfy", 12, House(1), 42)),
Some("[email protected]"),
Expand All @@ -51,6 +57,6 @@ val person = Sample(
s"$item"
)
},
Form.renderVar(personVar)
personVar.asForm
)
)
2 changes: 1 addition & 1 deletion examples/client/src/main/scala/samples/SimpleSample.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ val simple = Sample(
s"$item"
)
},
Form.renderVar(eitherVar)
eitherVar.asForm
)
}
)
2 changes: 1 addition & 1 deletion examples/client/src/main/scala/samples/Tree.scala
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ val tree = Sample(
child <-- treeVar2.signal
.distinctByFn(Tree.isSameStructure)
.map { item =>
Form.renderVar(treeVar2)
treeVar2.asForm
}
)
}
Expand Down
2 changes: 1 addition & 1 deletion examples/client/src/main/scala/samples/Validation.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ val validation = Sample(
s"$item"
)
},
Form.renderVar(ironSampleVar)
ironSampleVar.asForm
)
)
24 changes: 24 additions & 0 deletions examples/client/src/main/scala/samples/model/LoginPassword.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package samples.model

import dev.cheleb.scalamigen.Form
import com.raquo.laminar.api.L.*
import dev.cheleb.scalamigen.WidgetFactory

opaque type Password = String

object Password:
def apply(password: String): Password = password
given Form[Password] with
override def render(
variable: Var[Password],
syncParent: () => Unit,
values: List[Password] = List.empty
)(using factory: WidgetFactory): HtmlElement =
factory.renderSecret
.amend(
value <-- variable.signal,
onInput.mapToValue --> { v =>
variable.set(v)
syncParent()
}
)
Loading

0 comments on commit c246f35

Please sign in to comment.