From 313fc83d2d6dd9abbbf609b6fae3ce34f1324eed Mon Sep 17 00:00:00 2001 From: Sebastian Arellanes <80025691+KapStorm@users.noreply.github.com> Date: Wed, 27 Sep 2023 20:04:46 -0700 Subject: [PATCH] Improve facades apply (#26) * Add apply method to facades * Update components to apply * Remove redundant children * Minor changes --- .../wiringbits/spra/ui/web/AdminView.scala | 12 ++--- .../ui/web/components/CreateGuesser.scala | 31 +++++-------- .../spra/ui/web/components/EditGuesser.scala | 38 ++++++--------- .../spra/ui/web/components/ListGuesser.scala | 46 +++++++------------ .../ui/web/facades/reactadmin/Admin.scala | 10 ++-- .../ui/web/facades/reactadmin/Button.scala | 10 ++-- .../facades/reactadmin/ComponentList.scala | 7 ++- .../ui/web/facades/reactadmin/Create.scala | 7 +-- .../ui/web/facades/reactadmin/Datagrid.scala | 9 ++-- .../ui/web/facades/reactadmin/DateField.scala | 7 ++- .../ui/web/facades/reactadmin/DateInput.scala | 11 ++++- .../facades/reactadmin/DateTimeInput.scala | 10 +++- .../spra/ui/web/facades/reactadmin/Edit.scala | 9 +++- .../web/facades/reactadmin/EmailField.scala | 7 ++- .../web/facades/reactadmin/FilterButton.scala | 7 ++- .../web/facades/reactadmin/ImageField.scala | 13 +++++- .../web/facades/reactadmin/NumberField.scala | 7 ++- .../web/facades/reactadmin/NumberInput.scala | 12 ++++- .../facades/reactadmin/ReferenceField.scala | 10 ++-- .../facades/reactadmin/ReferenceInput.scala | 14 ++++-- .../ui/web/facades/reactadmin/Resource.scala | 7 ++- .../web/facades/reactadmin/SelectInput.scala | 10 +++- .../web/facades/reactadmin/SimpleForm.scala | 8 +++- .../ui/web/facades/reactadmin/TextField.scala | 5 +- .../ui/web/facades/reactadmin/TextInput.scala | 12 ++++- .../ui/web/facades/reactadmin/Toolbar.scala | 6 +-- .../web/facades/reactadmin/TopToolbar.scala | 6 +-- 27 files changed, 206 insertions(+), 125 deletions(-) diff --git a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/AdminView.scala b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/AdminView.scala index e6d8e02..d80196b 100644 --- a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/AdminView.scala +++ b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/AdminView.scala @@ -43,18 +43,16 @@ object AdminView { def buildResources: Seq[ReactElement] = { tables.map { table => Resource( - Resource.Props( - name = table.name, - list = ListGuesser(table), - edit = EditGuesser(table, props.dataExplorerSettings), - create = CreateGuesser(table) - ) + name = table.name, + list = ListGuesser(table), + edit = EditGuesser(table, props.dataExplorerSettings), + create = CreateGuesser(table) ).withKey(table.name) } } div()( - Admin(Admin.Props(dataProvider = simpleRestProvider(tablesUrl), children = buildResources)), + Admin(simpleRestProvider(tablesUrl))(buildResources), error.map(h1(_)) ) } diff --git a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/components/CreateGuesser.scala b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/components/CreateGuesser.scala index 9cc17bf..36fbc9c 100644 --- a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/components/CreateGuesser.scala +++ b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/components/CreateGuesser.scala @@ -23,38 +23,29 @@ object CreateGuesser { field.`type` match { case ColumnType.Date => - DateTimeInput(DateTimeInput.Props(source = field.name, isRequired = isRequired, validate = required)) + DateTimeInput(source = field.name, isRequired = isRequired, validate = required) case ColumnType.Text => - TextInput(TextInput.Props(source = field.name, isRequired = isRequired, validate = required)) + TextInput(source = field.name, isRequired = isRequired, validate = required) case ColumnType.Email => - TextInput(TextInput.Props(source = field.name, isRequired = isRequired, validate = required)) + TextInput(source = field.name, isRequired = isRequired, validate = required) case ColumnType.Image => - ImageField(ImageField.Props(source = field.name, isRequired = isRequired, validate = required)) + ImageField(source = field.name, isRequired = isRequired, validate = required) case ColumnType.Number => - NumberInput(NumberInput.Props(source = field.name, isRequired = isRequired, validate = required)) + NumberInput(source = field.name, isRequired = isRequired, validate = required) case ColumnType.Reference(reference, source) => ReferenceInput( - ReferenceInput.Props( - source = field.name, - reference = reference, - children = Seq( - SelectInput(SelectInput.Props(optionText = source, isRequired = isRequired, validate = required)) - ), - isRequired = isRequired, - validate = required - ) - ) + source = field.name, + reference = reference, + isRequired = isRequired, + validate = required + )(SelectInput(optionText = source, isRequired = isRequired, validate = required)) } } .getOrElse(Fragment()) } Create( - Create.Props( - SimpleForm( - SimpleForm.Props(toolbar = Fragment(), children = inputs :+ SaveButton()) - ) - ) + SimpleForm(Fragment())(inputs.appended(SaveButton()): _*) ) } } diff --git a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/components/EditGuesser.scala b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/components/EditGuesser.scala index acaef7d..99fe257 100644 --- a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/components/EditGuesser.scala +++ b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/components/EditGuesser.scala @@ -30,19 +30,16 @@ object EditGuesser { if !field.isVisible then Fragment() else field.`type` match { - case ColumnType.Date => DateTimeInput(DateTimeInput.Props(source = field.name, disabled = field.disabled)) - case ColumnType.Text => TextInput(TextInput.Props(source = field.name, disabled = field.disabled)) - case ColumnType.Email => TextInput(TextInput.Props(source = field.name, disabled = field.disabled)) - case ColumnType.Image => ImageField(ImageField.Props(source = field.name)) - case ColumnType.Number => NumberInput(NumberInput.Props(source = field.name, disabled = field.disabled)) + case ColumnType.Date => DateTimeInput(source = field.name, disabled = field.disabled) + case ColumnType.Text => TextInput(source = field.name, disabled = field.disabled) + case ColumnType.Email => TextInput(source = field.name, disabled = field.disabled) + case ColumnType.Image => ImageField(source = field.name) + case ColumnType.Number => NumberInput(source = field.name, disabled = field.disabled) case ColumnType.Reference(reference, source) => ReferenceInput( - ReferenceInput.Props( - source = field.name, - reference = reference, - children = Seq(SelectInput(SelectInput.Props(optionText = source, disabled = field.disabled))) - ) - ) + source = field.name, + reference = reference + )(SelectInput(optionText = source, disabled = field.disabled)) } } @@ -65,29 +62,22 @@ object EditGuesser { tableAction .map { x => x.actions.map { action => - Button(Button.Props(onClick = () => onClick(action, ctx), children = Seq(action.text))) + Button(onClick = () => onClick(action, ctx))(action.text) }: Seq[ReactElement] } .getOrElse(Seq.empty) } - val actions = TopToolbar(TopToolbar.Props(children = buttons())) + val actions = TopToolbar(buttons()) val deleteButton: ReactElement = if (props.response.canBeDeleted) DeleteButton() else Fragment() val toolbar: ReactElement = Toolbar( - Toolbar.Props(children = - Seq( - SaveButton(), - deleteButton - ) - ) + SaveButton(), + deleteButton ) - Edit( - Edit.Props( - actions = actions(), - children = Seq(SimpleForm(SimpleForm.Props(toolbar = toolbar, children = inputs))) - ) + Edit(actions)( + SimpleForm(toolbar)(inputs) ) } } diff --git a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/components/ListGuesser.scala b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/components/ListGuesser.scala index 6afd586..6b6978e 100644 --- a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/components/ListGuesser.scala +++ b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/components/ListGuesser.scala @@ -20,14 +20,8 @@ object ListGuesser { val component: FunctionalComponent[Props] = FunctionalComponent[Props] { props => val fields = ResponseGuesser.getTypesFromResponse(props.response) - def defaultField(reference: String, source: String, children: Seq[ReactElement]): ReactElement = - ReferenceField( - ReferenceField.Props( - reference = reference, - source = source, - children = children - ) - ) + def defaultField(reference: String, source: String)(children: ReactElement*): ReactElement = + ReferenceField(reference = reference, source = source)(children) val widgetFields: Seq[ReactElement] = fields.map { field => if !field.isVisible then Fragment() @@ -35,42 +29,36 @@ object ListGuesser { val imageStyles = js.Dynamic.literal("width" -> "100px") val styles = js.Dynamic.literal("& img" -> imageStyles) field.`type` match { - case Date => DateField(DateField.Props(source = field.name, showTime = true)) - case Text => TextField(TextField.Props(source = field.name)) - case Email => EmailField(EmailField.Props(source = field.name)) - case Image => ImageField(ImageField.Props(source = field.name, sx = styles)) - case Number => NumberField(NumberField.Props(source = field.name)) + case Date => DateField(source = field.name, showTime = true) + case Text => TextField(source = field.name) + case Email => EmailField(source = field.name) + case Image => ImageField(source = field.name, sx = styles) + case Number => NumberField(source = field.name) case ColumnType.Reference(reference, source) => - defaultField(reference, field.name, Seq(TextField(TextField.Props(source = source)))) + defaultField(reference, field.name)(TextField(source = source)) } } } val filterList: Seq[ReactElement] = fields.filter(_.filterable).map { field => field.`type` match { - case ColumnType.Date => DateInput(DateInput.Props(source = field.name)) - case ColumnType.Text | ColumnType.Email => TextInput(TextInput.Props(source = field.name)) + case ColumnType.Date => DateInput(source = field.name) + case ColumnType.Text | ColumnType.Email => TextInput(source = field.name) case ColumnType.Image => Fragment() - case ColumnType.Number => NumberInput(NumberInput.Props(source = field.name)) + case ColumnType.Number => NumberInput(source = field.name) case ColumnType.Reference(reference, source) => - defaultField(reference, field.name, Seq(TextField(TextField.Props(source = source)))) + defaultField(reference, field.name)(TextField(source = source)) } } val listToolbar: ReactElement = TopToolbar( - TopToolbar.Props( - children = Seq( - FilterButton(FilterButton.Props(filters = filterList)), - ExportButton(), - CreateButton() - ) - ) + FilterButton(filters = filterList), + ExportButton(), + CreateButton() ) - ComponentList(ComponentList.Props(actions = listToolbar, filters = filterList))( - Datagrid( - Datagrid.Props(rowClick = "edit", bulkActionButtons = props.response.canBeDeleted, children = widgetFields) - ) + ComponentList(listToolbar)(filterList: _*)( + Datagrid(rowClick = "edit", bulkActionButtons = props.response.canBeDeleted)(widgetFields) ) } } diff --git a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/Admin.scala b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/Admin.scala index 248cc43..2e00abe 100644 --- a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/Admin.scala +++ b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/Admin.scala @@ -1,13 +1,17 @@ package net.wiringbits.spra.ui.web.facades.reactadmin import net.wiringbits.spra.ui.web.facades.DataProvider -import slinky.core.ExternalComponent -import slinky.core.facade.ReactElement +import slinky.core.{BuildingComponent, ExternalComponent} import scala.scalajs.js import scala.scalajs.js.| object Admin extends ExternalComponent { - case class Props(dataProvider: DataProvider, children: Seq[ReactElement]) + case class Props(dataProvider: DataProvider) + + def apply(dataProvider: DataProvider): BuildingComponent[_, _] = { + super.apply(Props(dataProvider)) + } + override val component: String | js.Object = ReactAdmin.Admin } diff --git a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/Button.scala b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/Button.scala index cf555bb..ad46272 100644 --- a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/Button.scala +++ b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/Button.scala @@ -1,12 +1,16 @@ package net.wiringbits.spra.ui.web.facades.reactadmin -import slinky.core.ExternalComponent -import slinky.core.facade.ReactElement +import slinky.core.{BuildingComponent, ExternalComponent} import scala.scalajs.js import scala.scalajs.js.| object Button extends ExternalComponent { - case class Props(onClick: () => Unit, children: Seq[ReactElement]) + case class Props(onClick: () => Unit) + + def apply(onClick: () => Unit): BuildingComponent[_, _] = { + super.apply(Props(onClick)) + } + override val component: String | js.Object = ReactAdmin.Button } diff --git a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/ComponentList.scala b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/ComponentList.scala index 1c20654..81c973b 100644 --- a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/ComponentList.scala +++ b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/ComponentList.scala @@ -1,12 +1,17 @@ package net.wiringbits.spra.ui.web.facades.reactadmin -import slinky.core.ExternalComponent import slinky.core.facade.ReactElement +import slinky.core.{BuildingComponent, ExternalComponent} import scala.scalajs.js import scala.scalajs.js.| object ComponentList extends ExternalComponent { case class Props(actions: ReactElement, filters: Seq[ReactElement]) + + def apply(actions: ReactElement)(filters: ReactElement*): BuildingComponent[_, _] = { + super.apply(Props(actions, filters)) + } + override val component: String | js.Object = ReactAdmin.List } diff --git a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/Create.scala b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/Create.scala index feeceab..95e0303 100644 --- a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/Create.scala +++ b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/Create.scala @@ -1,12 +1,9 @@ package net.wiringbits.spra.ui.web.facades.reactadmin -import slinky.core.ExternalComponent -import slinky.core.facade.ReactElement +import slinky.core.ExternalComponentNoProps import scala.scalajs.js -object Create extends ExternalComponent { - case class Props(children: ReactElement*) - +object Create extends ExternalComponentNoProps { override val component: String | js.Object = ReactAdmin.Create } diff --git a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/Datagrid.scala b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/Datagrid.scala index e2d0ac1..082f9eb 100644 --- a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/Datagrid.scala +++ b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/Datagrid.scala @@ -1,12 +1,15 @@ package net.wiringbits.spra.ui.web.facades.reactadmin -import slinky.core.ExternalComponent -import slinky.core.facade.ReactElement +import slinky.core.{BuildingComponent, ExternalComponent} import scala.scalajs.js import scala.scalajs.js.| object Datagrid extends ExternalComponent { - case class Props(rowClick: String, bulkActionButtons: Boolean, children: Seq[ReactElement]) + case class Props(rowClick: String, bulkActionButtons: Boolean) + + def apply(rowClick: String, bulkActionButtons: Boolean): BuildingComponent[_, _] = + super.apply(Props(rowClick, bulkActionButtons)) + override val component: String | js.Object = ReactAdmin.Datagrid } diff --git a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/DateField.scala b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/DateField.scala index 911e965..97e86e2 100644 --- a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/DateField.scala +++ b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/DateField.scala @@ -1,11 +1,16 @@ package net.wiringbits.spra.ui.web.facades.reactadmin -import slinky.core.ExternalComponent +import slinky.core.{BuildingComponent, ExternalComponent} import scala.scalajs.js import scala.scalajs.js.| object DateField extends ExternalComponent { case class Props(source: String, showTime: Boolean) + + def apply(source: String, showTime: Boolean = false): BuildingComponent[_, _] = { + super.apply(Props(source, showTime)) + } + override val component: String | js.Object = ReactAdmin.DateField } diff --git a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/DateInput.scala b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/DateInput.scala index 452f422..660ff58 100644 --- a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/DateInput.scala +++ b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/DateInput.scala @@ -1,11 +1,20 @@ package net.wiringbits.spra.ui.web.facades.reactadmin -import slinky.core.ExternalComponent +import slinky.core.{BuildingComponent, ExternalComponent} import scala.scalajs.js import scala.scalajs.js.| object DateInput extends ExternalComponent { case class Props(source: String, isRequired: Boolean = false, validate: js.UndefOr[js.Any] = js.undefined) + + def apply( + source: String, + isRequired: Boolean = false, + validate: js.UndefOr[js.Any] = js.undefined + ): BuildingComponent[_, _] = { + super.apply(Props(source, isRequired, validate)) + } + override val component: String | js.Object = ReactAdmin.DateInput } diff --git a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/DateTimeInput.scala b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/DateTimeInput.scala index a1fad12..6228b76 100644 --- a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/DateTimeInput.scala +++ b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/DateTimeInput.scala @@ -1,6 +1,6 @@ package net.wiringbits.spra.ui.web.facades.reactadmin -import slinky.core.ExternalComponent +import slinky.core.{BuildingComponent, ExternalComponent} import scala.scalajs.js import scala.scalajs.js.| @@ -12,5 +12,13 @@ object DateTimeInput extends ExternalComponent { isRequired: Boolean = false, validate: js.UndefOr[js.Any] = js.undefined ) + + def apply( + source: String, + disabled: Boolean = false, + isRequired: Boolean = false, + validate: js.UndefOr[js.Any] = js.undefined + ): BuildingComponent[_, _] = super.apply(Props(source, disabled, isRequired, validate)) + override val component: String | js.Object = ReactAdmin.DateTimeInput } diff --git a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/Edit.scala b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/Edit.scala index f26dc95..be49de9 100644 --- a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/Edit.scala +++ b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/Edit.scala @@ -1,12 +1,17 @@ package net.wiringbits.spra.ui.web.facades.reactadmin -import slinky.core.ExternalComponent import slinky.core.facade.ReactElement +import slinky.core.{BuildingComponent, ExternalComponent} import scala.scalajs.js import scala.scalajs.js.| object Edit extends ExternalComponent { - case class Props(actions: ReactElement, children: Seq[ReactElement]) + case class Props(actions: ReactElement) + + def apply(actions: ReactElement): BuildingComponent[_, _] = { + super.apply(Props(actions)) + } + override val component: String | js.Object = ReactAdmin.Edit } diff --git a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/EmailField.scala b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/EmailField.scala index 3cc7dcd..e4ca7d6 100644 --- a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/EmailField.scala +++ b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/EmailField.scala @@ -1,11 +1,16 @@ package net.wiringbits.spra.ui.web.facades.reactadmin -import slinky.core.ExternalComponent +import slinky.core.{BuildingComponent, ExternalComponent} import scala.scalajs.js import scala.scalajs.js.| object EmailField extends ExternalComponent { case class Props(source: String) + + def apply(source: String): BuildingComponent[_, _] = { + super.apply(Props(source)) + } + override val component: String | js.Object = ReactAdmin.EmailField } diff --git a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/FilterButton.scala b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/FilterButton.scala index 5d5b368..c10ab38 100644 --- a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/FilterButton.scala +++ b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/FilterButton.scala @@ -1,12 +1,17 @@ package net.wiringbits.spra.ui.web.facades.reactadmin -import slinky.core.ExternalComponent import slinky.core.facade.ReactElement +import slinky.core.{BuildingComponent, ExternalComponent} import scala.scalajs.js import scala.scalajs.js.| object FilterButton extends ExternalComponent { case class Props(filters: Seq[ReactElement]) + + def apply(filters: ReactElement*): BuildingComponent[_, _] = { + super.apply(Props(filters)) + } + override val component: String | js.Object = ReactAdmin.FilterButton } diff --git a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/ImageField.scala b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/ImageField.scala index e6d4388..0330951 100644 --- a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/ImageField.scala +++ b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/ImageField.scala @@ -1,6 +1,6 @@ package net.wiringbits.spra.ui.web.facades.reactadmin -import slinky.core.ExternalComponent +import slinky.core.{BuildingComponent, ExternalComponent} import scala.scalajs.js import scala.scalajs.js.| @@ -13,5 +13,16 @@ object ImageField extends ExternalComponent { isRequired: Boolean = false, validate: js.UndefOr[js.Any] = js.undefined ) + + def apply( + source: String, + disabled: Boolean = false, + sx: js.Dynamic = js.Dynamic.literal(), + isRequired: Boolean = false, + validate: js.UndefOr[js.Any] = js.undefined + ): BuildingComponent[_, _] = { + super.apply(Props(source, disabled, sx, isRequired, validate)) + } + override val component: String | js.Object = ReactAdmin.ImageField } diff --git a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/NumberField.scala b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/NumberField.scala index bae3d5d..86be01a 100644 --- a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/NumberField.scala +++ b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/NumberField.scala @@ -1,11 +1,16 @@ package net.wiringbits.spra.ui.web.facades.reactadmin -import slinky.core.ExternalComponent +import slinky.core.{BuildingComponent, ExternalComponent} import scala.scalajs.js import scala.scalajs.js.| object NumberField extends ExternalComponent { case class Props(source: String) + + def apply(source: String): BuildingComponent[_, _] = { + super.apply(Props(source)) + } + override val component: String | js.Object = ReactAdmin.NumberField } diff --git a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/NumberInput.scala b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/NumberInput.scala index 799bd6d..e64ed42 100644 --- a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/NumberInput.scala +++ b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/NumberInput.scala @@ -1,6 +1,6 @@ package net.wiringbits.spra.ui.web.facades.reactadmin -import slinky.core.ExternalComponent +import slinky.core.{BuildingComponent, ExternalComponent} import scala.scalajs.js import scala.scalajs.js.| @@ -12,5 +12,15 @@ object NumberInput extends ExternalComponent { isRequired: Boolean = false, validate: js.UndefOr[js.Any] = js.undefined ) + + def apply( + source: String, + disabled: Boolean = false, + isRequired: Boolean = false, + validate: js.UndefOr[js.Any] = js.undefined + ): BuildingComponent[_, _] = { + super.apply(Props(source, disabled, isRequired, validate)) + } + override val component: String | js.Object = ReactAdmin.NumberInput } diff --git a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/ReferenceField.scala b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/ReferenceField.scala index 4a42ef6..860aa06 100644 --- a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/ReferenceField.scala +++ b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/ReferenceField.scala @@ -1,12 +1,16 @@ package net.wiringbits.spra.ui.web.facades.reactadmin -import slinky.core.ExternalComponent -import slinky.core.facade.ReactElement +import slinky.core.{BuildingComponent, ExternalComponent} import scala.scalajs.js import scala.scalajs.js.| object ReferenceField extends ExternalComponent { - case class Props(reference: String, source: String, children: Seq[ReactElement]) + case class Props(reference: String, source: String) + + def apply(reference: String, source: String): BuildingComponent[_, _] = { + super.apply(Props(reference, source)) + } + override val component: String | js.Object = ReactAdmin.ReferenceField } diff --git a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/ReferenceInput.scala b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/ReferenceInput.scala index 1d657ae..6731602 100644 --- a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/ReferenceInput.scala +++ b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/ReferenceInput.scala @@ -1,7 +1,6 @@ package net.wiringbits.spra.ui.web.facades.reactadmin -import slinky.core.ExternalComponent -import slinky.core.facade.ReactElement +import slinky.core.{BuildingComponent, ExternalComponent} import scala.scalajs.js import scala.scalajs.js.| @@ -10,9 +9,18 @@ object ReferenceInput extends ExternalComponent { case class Props( source: String, reference: String, - children: Seq[ReactElement], isRequired: Boolean = false, validate: js.UndefOr[js.Any] = js.undefined ) + + def apply( + source: String, + reference: String, + isRequired: Boolean = false, + validate: js.UndefOr[js.Any] = js.undefined + ): BuildingComponent[_, _] = { + super.apply(Props(source, reference, isRequired, validate)) + } + override val component: String | js.Object = ReactAdmin.ReferenceInput } diff --git a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/Resource.scala b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/Resource.scala index 93865c0..2d28280 100644 --- a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/Resource.scala +++ b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/Resource.scala @@ -1,11 +1,16 @@ package net.wiringbits.spra.ui.web.facades.reactadmin -import slinky.core.ExternalComponent +import slinky.core.{BuildingComponent, ExternalComponent} import scala.scalajs.js import scala.scalajs.js.| object Resource extends ExternalComponent { case class Props(name: String, edit: js.Object, list: js.Object, create: js.Object) + + def apply(name: String, edit: js.Object, list: js.Object, create: js.Object): BuildingComponent[_, _] = { + this.apply(Props(name, edit, list, create)) + } + override val component: String | js.Object = ReactAdmin.Resource } diff --git a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/SelectInput.scala b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/SelectInput.scala index 3e635c2..c040bf7 100644 --- a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/SelectInput.scala +++ b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/SelectInput.scala @@ -1,6 +1,6 @@ package net.wiringbits.spra.ui.web.facades.reactadmin -import slinky.core.ExternalComponent +import slinky.core.{BuildingComponent, ExternalComponent} import scala.scalajs.js import scala.scalajs.js.| @@ -12,5 +12,13 @@ object SelectInput extends ExternalComponent { isRequired: Boolean = false, validate: js.UndefOr[js.Any] = js.undefined ) + + def apply( + optionText: String = "", + disabled: Boolean = false, + isRequired: Boolean = false, + validate: js.UndefOr[js.Any] = js.undefined + ): BuildingComponent[_, _] = super.apply(Props(optionText, disabled, isRequired, validate)) + override val component: String | js.Object = ReactAdmin.SelectInput } diff --git a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/SimpleForm.scala b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/SimpleForm.scala index d8a3183..fc46ffd 100644 --- a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/SimpleForm.scala +++ b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/SimpleForm.scala @@ -1,12 +1,16 @@ package net.wiringbits.spra.ui.web.facades.reactadmin -import slinky.core.ExternalComponent import slinky.core.facade.ReactElement +import slinky.core.{BuildingComponent, ExternalComponent} import scala.scalajs.js import scala.scalajs.js.| object SimpleForm extends ExternalComponent { - case class Props(toolbar: ReactElement, children: Seq[ReactElement]) + case class Props(toolbar: ReactElement) + + def apply(toolbar: ReactElement): BuildingComponent[_, _] = + super.apply(Props(toolbar)) + override val component: String | js.Object = ReactAdmin.SimpleForm } diff --git a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/TextField.scala b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/TextField.scala index b8eabc8..d43f532 100644 --- a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/TextField.scala +++ b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/TextField.scala @@ -1,11 +1,14 @@ package net.wiringbits.spra.ui.web.facades.reactadmin -import slinky.core.ExternalComponent +import slinky.core.{BuildingComponent, ExternalComponent} import scala.scalajs.js import scala.scalajs.js.| object TextField extends ExternalComponent { case class Props(source: String) + + def apply(source: String): BuildingComponent[_, _] = super.apply(Props(source)) + override val component: String | js.Object = ReactAdmin.TextField } diff --git a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/TextInput.scala b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/TextInput.scala index 5c49cd0..a1003f0 100644 --- a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/TextInput.scala +++ b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/TextInput.scala @@ -1,6 +1,6 @@ package net.wiringbits.spra.ui.web.facades.reactadmin -import slinky.core.ExternalComponent +import slinky.core.{BuildingComponent, ExternalComponent} import scala.scalajs.js import scala.scalajs.js.| @@ -12,5 +12,15 @@ object TextInput extends ExternalComponent { isRequired: Boolean = false, validate: js.UndefOr[js.Any] = js.undefined ) + + def apply( + source: String, + disabled: Boolean = false, + isRequired: Boolean = false, + validate: js.UndefOr[js.Any] = js.undefined + ): BuildingComponent[_, _] = { + super.apply(Props(source, disabled, isRequired, validate)) + } + override val component: String | js.Object = ReactAdmin.TextInput } diff --git a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/Toolbar.scala b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/Toolbar.scala index c4939af..c4cba10 100644 --- a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/Toolbar.scala +++ b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/Toolbar.scala @@ -1,12 +1,10 @@ package net.wiringbits.spra.ui.web.facades.reactadmin -import slinky.core.ExternalComponent -import slinky.core.facade.ReactElement +import slinky.core.ExternalComponentNoProps import scala.scalajs.js import scala.scalajs.js.| -object Toolbar extends ExternalComponent { - case class Props(children: Seq[ReactElement]) +object Toolbar extends ExternalComponentNoProps { override val component: String | js.Object = ReactAdmin.Toolbar } diff --git a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/TopToolbar.scala b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/TopToolbar.scala index 87edf28..228cdc1 100644 --- a/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/TopToolbar.scala +++ b/spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/reactadmin/TopToolbar.scala @@ -1,12 +1,10 @@ package net.wiringbits.spra.ui.web.facades.reactadmin -import slinky.core.ExternalComponent -import slinky.core.facade.ReactElement +import slinky.core.ExternalComponentNoProps import scala.scalajs.js import scala.scalajs.js.| -object TopToolbar extends ExternalComponent { - case class Props(children: Seq[ReactElement]) +object TopToolbar extends ExternalComponentNoProps { override val component: String | js.Object = ReactAdmin.TopToolbar }