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 antd #47

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
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
77 changes: 45 additions & 32 deletions antd/src/main/scala/demo/App.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import slinky.core._
import slinky.core.annotations.react
import slinky.core.facade.Hooks._
import slinky.core.facade.ReactElement
import slinky.web.html.*.tag
import slinky.web.html._
import typings.StBuildingComponent.Default
import typings.antDesignIcons.components.AntdIcon
import typings.antDesignIconsSvg.downOutlinedMod.{default => DownOutlinedIcon}
import typings.antDesignIconsSvg.downloadOutlinedMod.{default => DownloadOutlinedIcon}
Expand All @@ -13,20 +15,21 @@ 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.antd.antdStrings
import typings.antd.components.{List => AntList, _}
import typings.antd.components.Form.{Form => FormItem}
import typings.antd.components.{List => AntList, _}
import typings.antd.generatePickerMod.RangePickerDateProps
import typings.antd.{antdStrings, mod}
import typings.antd.notificationMod.{ArgsProps, IconType, default => Notification}
import typings.antd.tableInterfaceMod.{ColumnGroupType, ColumnType}
import typings.antd.tooltipMod.{TooltipProps, TooltipPropsWithTitle}
import typings.moment.mod.Moment
import typings.moment.mod.unitOfTime.DurationConstructor
import typings.moment.{mod => moment}
import typings.rcPicker.interfaceMod.{EventValue, RangeValue}
import typings.rcPicker.rangePickerMod.RangeShowTimeObject
import typings.rcSelect.interfaceMod.OptionData
import typings.rcTreeSelect.interfaceMod.DataNode
import typings.rcTreeSelect.strategyUtilMod
import typings.react.mod.CSSProperties
import typings.rcSelect.selectMod
import typings.rcTreeSelect.{strategyUtilMod, treeSelectMod}
import typings.react.mod.{CSSProperties, RefAttributes}
import typings.std.global.console

import scala.scalajs.js
Expand Down Expand Up @@ -103,14 +106,14 @@ object CSS extends js.Any
)
.columnsVarargs(
ColumnType[TableItem]()
.setTitle("Name")
.setTitle("Name": ReactElement)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunate side effect of the the union encoding in Scala.js. No double implicit conversions.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it have a .setTitleReactElement or something like that?

.setDataIndex("name")
.setKey("name")
.setRender((_, tableItem, _) => Tag(tableItem.name).build),
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": ReactElement).setDataIndex("age").setKey("age"),
ColumnType[TableItem].setTitle("Address": ReactElement).setDataIndex("address").setKey("address")
)
).setTitleReactElement("Age & Address")
)
Expand Down Expand Up @@ -174,11 +177,11 @@ object CSS extends js.Any
Select[String]
.defaultValue(selectValue)
.onChange((changedValue, _) => updateSelectValue(changedValue))(
Select.OptGroup.label("Manager")(
Select.OptGroup("Manager")(
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess label changed from being optional to mandatory?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, exactly

Select.Option("jack")("Jack"),
Select.Option("lucy")("Lucy")
),
Select.OptGroup.label("Engineer")(
Select.OptGroup("Engineer")(
Select.Option("yiminghe")("Yiminghe")
)
)
Expand All @@ -202,7 +205,8 @@ object CSS extends js.Any
Spin
.size(antdStrings.large)
.spinning(true)(
Alert(message = "Alert message title")
Alert
.message("Alert message title")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vice versa here, message is now optional?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

.description("Further details about the context of this alert.")
.`type`(antdStrings.info)
.showIcon(true)
Expand Down Expand Up @@ -282,13 +286,15 @@ object CSS extends js.Any
.filterOption(true) // Filter options by input
.defaultActiveFirstOption(true) // Make first option active - enter to select
.optionsVarargs(
OptionData("Alphabet"),
OptionData("Baguette").set(
"label",
span(AntdIcon(ShopOutlinedIcon), " Baguette")
), // Set label as a ReactElement for customised display
OptionData("Bicycle"),
OptionData("Croissant")
selectMod.DefaultOptionType("Alphabet"),
selectMod
.DefaultOptionType("Baguette")
.set(
"label",
span(AntdIcon(ShopOutlinedIcon), " Baguette")
), // Set label as a ReactElement for customised display
selectMod.DefaultOptionType("Bicycle"),
selectMod.DefaultOptionType("Croissant")
)
.onChange { case (text, _) => setText(text) }
}
Expand Down Expand Up @@ -410,7 +416,9 @@ object CSS extends js.Any

val renderTooltip = section(
h2("Tooltip"),
Tooltip.TooltipPropsWithTitleRefAttributes(title = ("Tooltip": ReactElement))(span("Hover me"))
Tooltip(TooltipPropsWithTitle("Tooltip": ReactElement).asInstanceOf[TooltipProps with RefAttributes[Any]])(
span("Hover me")
)
)

val renderTimeline = section(
Expand All @@ -431,17 +439,22 @@ object CSS extends js.Any
)
)

// Workaround for https://github.com/ScalablyTyped/Converter/issues/470
def RangePicker[DateType](props: RangePickerDateProps[DateType]) =
new Default[tag.type, mod.DatePicker.RangePicker](js.Array(mod.DatePicker.RangePicker, props))

val renderRangePicker = section(
h2("Range Picker"),
DatePicker.PickerBaseProps.RangePicker
.RangePickerDateProps()
.showTime(RangeShowTimeObject[Moment].setFormat("HH:mm"))
.format("YYYY/MM/DD HH:mm")
.value(rangePickerValues)
.onChange { (values: RangeValue[Moment], formatString: js.Tuple2[String, String]) =>
console.log(formatString)
updateRangePickerValues(values)
},
RangePicker(
RangePickerDateProps[Moment]()
.setShowTime(RangeShowTimeObject[Moment].setFormat("HH:mm"))
.setFormat("YYYY/MM/DD HH:mm")
.setValue(rangePickerValues)
.setOnChange { (values: RangeValue[Moment], formatString: js.Tuple2[String, String]) =>
console.log(formatString)
updateRangePickerValues(values)
}
),
div(b("Note that moment.js date times are ready to be localized")),
div(s"moment.js current locale: ${moment.apply().locale()}"),
div(s"moment.js duration en_US: ${moment.apply().locale("en_US").fromNow()}"),
Expand All @@ -453,9 +466,9 @@ object CSS extends js.Any
val renderTreeSelect = section(
h2("Multiple and checkable Tree Select"), {
def node(title: String, value: String) =
DataNode().setTitle(title).setValue(value).setKey(value)
treeSelectMod.DefaultOptionType().setTitle(title).setValue(value).setKey(value)

val data: js.Array[DataNode] = js.Array(
val data: js.Array[treeSelectMod.DefaultOptionType] = js.Array(
node("Node1", "0-0").setChildrenVarargs(
node("Child Node1", "0-0-0")
),
Expand All @@ -466,7 +479,7 @@ object CSS extends js.Any
)
)

TreeSelect[js.Array[String]]
TreeSelect[js.Array[String], treeSelectMod.DefaultOptionType]()
.value(selectTreeValues)
.onChange((values, _, _) => updateSelectTreeValues(values))
.treeData(data)
Expand Down
4 changes: 2 additions & 2 deletions antd/src/main/scala/demo/CoordinatedDemo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ object CoordinatedDemo {
)
)
}(
Select.Option(value = "male")("Male"),
Select.Option(value = "female")("Female")
Select.Option.value("male")("Male"),
Select.Option.value("female")("Female")
)
),
FormItem[Values]().wrapperCol(ColProps().setSpan(12).setOffset(5))(
Expand Down
Loading