Skip to content
This repository was archived by the owner on Mar 1, 2023. It is now read-only.

Commit d238ec5

Browse files
committed
Update scalafmt
Signed-off-by: Carlos Quiroz <[email protected]>
1 parent cd45b0e commit d238ec5

File tree

12 files changed

+385
-311
lines changed

12 files changed

+385
-311
lines changed

.scalafmt.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version = "2.4.2"
1+
version = "2.6.0"
22
style = default
33

44
maxColumn = 100

demo/src/main/scala/react/virtualized/demo/Data.scala

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ object Data {
2222
size: Int
2323
): DataRow = {
2424
val p = (new js.Object).asInstanceOf[DataRow]
25-
p.color = color
26-
p.index = index
27-
p.name = name
28-
p.random = random
25+
p.color = color
26+
p.index = index
27+
p.name = name
28+
p.random = random
2929
p.randomLong = randomLong
30-
p.size = size
30+
p.size = size
3131
p
3232
}
3333
}
@@ -42,7 +42,8 @@ object Data {
4242
Names(i % Names.length),
4343
rnd,
4444
randoms,
45-
RowHeights(i % RowHeights.length))
45+
RowHeights(i % RowHeights.length)
46+
)
4647
}).toList
4748

4849
val BadgeColors = List(

demo/src/main/scala/react/virtualized/demo/Demo.scala

Lines changed: 66 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ object TableStaticDemo {
1313
def datum(data: List[DataRow])(i: Int) = data(i % data.length)
1414
def rowheight(data: List[DataRow])(i: Int) = datum(data)(i).size
1515

16-
final case class Props(useDynamicRowHeight: Boolean, sortBy: String, s: Size)
17-
final case class State(sortDirection: SortDirection, data: List[DataRow])
16+
final case class Props(useDynamicRowHeight: Boolean, sortBy: String, s: Size)
17+
final case class State(sortDirection: SortDirection, data: List[DataRow])
1818

1919
def headerRenderer(sortBy: String)(
2020
columnData: DataRow,
@@ -26,11 +26,12 @@ object TableStaticDemo {
2626
): VdomNode =
2727
<.div("Full Name", SortIndicator(SortDirection.ASC).when(sortBy == dataKey))
2828

29-
def rowClassName(i: Int): String = i match {
30-
case x if x < 0 => "headerRow"
31-
case x if x % 2 == 0 => "evenRow"
32-
case _ => "oddRow"
33-
}
29+
def rowClassName(i: Int): String =
30+
i match {
31+
case x if x < 0 => "headerRow"
32+
case x if x % 2 == 0 => "evenRow"
33+
case _ => "oddRow"
34+
}
3435

3536
val component = ScalaComponent
3637
.builder[Props]("TableStaticDemo")
@@ -39,8 +40,9 @@ object TableStaticDemo {
3940
def sort(index: String, sortDirection: SortDirection): Callback = {
4041
val sorted = state.data.sortBy(_.index)
4142
$.setState(
42-
state.copy(data = if (sortDirection == SortDirection.ASC) sorted else sorted.reverse,
43-
sortDirection = sortDirection)
43+
state.copy(data = if (sortDirection == SortDirection.ASC) sorted else sorted.reverse,
44+
sortDirection = sortDirection
45+
)
4446
)
4547
}
4648
val columns = List(
@@ -54,33 +56,33 @@ object TableStaticDemo {
5456
210,
5557
"random",
5658
disableSort = true,
57-
className = "exampleColumn",
58-
label = "The description label is so long it will be truncated",
59-
flexGrow = 1,
59+
className = "exampleColumn",
60+
label = "The description label is so long it will be truncated",
61+
flexGrow = 1,
6062
cellRenderer =
6163
(cellData: DataRow, _: js.Any, _: String, _: js.Any, _: Int) => cellData.toString
6264
)
6365
)
6466
)
6567
Table(
6668
Table.props(
67-
disableHeader = false,
68-
noRowsRenderer = () => <.div(^.cls := "noRows", "No rows"),
69+
disableHeader = false,
70+
noRowsRenderer = () => <.div(^.cls := "noRows", "No rows"),
6971
overscanRowCount = 10,
70-
rowClassName = rowClassName _,
71-
height = 270,
72-
rowCount = 1000,
73-
rowHeight = if (props.useDynamicRowHeight) rowheight(state.data) _ else 40,
74-
onRowClick = x => Callback.log(x),
75-
onScroll = (c, s, t) => Callback.log(s"$c $s $t"),
76-
width = scala.math.max(1, props.s.width.toInt),
77-
rowGetter = datum(state.data),
78-
headerClassName = "headerColumn",
79-
sort = sort _,
80-
sortBy = props.sortBy,
81-
sortDirection = state.sortDirection,
82-
scrollTop = 2000,
83-
headerHeight = 30
72+
rowClassName = rowClassName _,
73+
height = 270,
74+
rowCount = 1000,
75+
rowHeight = if (props.useDynamicRowHeight) rowheight(state.data) _ else 40,
76+
onRowClick = x => Callback.log(x),
77+
onScroll = (c, s, t) => Callback.log(s"$c $s $t"),
78+
width = scala.math.max(1, props.s.width.toInt),
79+
rowGetter = datum(state.data),
80+
headerClassName = "headerColumn",
81+
sort = sort _,
82+
sortBy = props.sortBy,
83+
sortDirection = state.sortDirection,
84+
scrollTop = 2000,
85+
headerHeight = 30
8486
),
8587
columns: _*
8688
)
@@ -99,8 +101,8 @@ object TableDynamicDemo {
99101
def datum(data: List[DataRow])(i: Int) = data(i % data.length)
100102
def rowheight(data: List[DataRow])(i: Int) = datum(data)(i).size
101103

102-
final case class Props(useDynamicRowHeight: Boolean, sortBy: String, s: Size)
103-
final case class State(sortDirection: SortDirection, data: List[DataRow])
104+
final case class Props(useDynamicRowHeight: Boolean, sortBy: String, s: Size)
105+
final case class State(sortDirection: SortDirection, data: List[DataRow])
104106

105107
def headerRenderer(sortBy: String)(
106108
columnData: DataRow,
@@ -112,21 +114,22 @@ object TableDynamicDemo {
112114
): VdomNode =
113115
<.div("Full Name", SortIndicator(SortDirection.ASC).when(sortBy == dataKey))
114116

115-
def rowClassName(i: Int): String = i match {
116-
case x if x < 0 => "headerRow"
117-
case x if x % 2 == 0 => "evenRow"
118-
case _ => "oddRow"
119-
}
117+
def rowClassName(i: Int): String =
118+
i match {
119+
case x if x < 0 => "headerRow"
120+
case x if x % 2 == 0 => "evenRow"
121+
case _ => "oddRow"
122+
}
120123

121124
val dynamicCellRenderer: CellRenderer[DataRow, js.Object, js.Object] =
122125
(cellData: DataRow, _: js.Object, _: String, _: js.Object, rowIndex: Int) => {
123126
CellMeasurer(
124127
CellMeasurer.props(
125-
cache = TableCache.cache,
126-
parent = CellMeasurer.Parent.Zero,
128+
cache = TableCache.cache,
129+
parent = CellMeasurer.Parent.Zero,
127130
columnIndex = 2,
128-
rowIndex = rowIndex,
129-
children = <.div(cellData.toString)
131+
rowIndex = rowIndex,
132+
children = <.div(cellData.toString)
130133
)
131134
)
132135
}
@@ -139,8 +142,9 @@ object TableDynamicDemo {
139142
def sort(index: String, sortDirection: SortDirection): Callback = {
140143
val sorted = state.data.sortBy(_.index)
141144
$.setState(
142-
state.copy(data = if (sortDirection == SortDirection.ASC) sorted else sorted.reverse,
143-
sortDirection = sortDirection)
145+
state.copy(data = if (sortDirection == SortDirection.ASC) sorted else sorted.reverse,
146+
sortDirection = sortDirection
147+
)
144148
)
145149
}
146150
val columns = List(
@@ -153,34 +157,34 @@ object TableDynamicDemo {
153157
Column.props(
154158
TableCache.cache.getWidth(2),
155159
"random",
156-
disableSort = true,
157-
className = "exampleColumn",
158-
label = "The description label is so long it will be truncated",
159-
flexGrow = 1,
160+
disableSort = true,
161+
className = "exampleColumn",
162+
label = "The description label is so long it will be truncated",
163+
flexGrow = 1,
160164
cellRenderer = dynamicCellRenderer
161165
)
162166
)
163167
)
164168
val t = Table(
165169
Table.props(
166170
deferredMeasurementCache = TableCache.cache,
167-
disableHeader = false,
168-
noRowsRenderer = () => <.div(^.cls := "noRows", "No rows"),
169-
overscanRowCount = 10,
170-
rowClassName = rowClassName _,
171-
height = 600,
172-
rowCount = 10,
173-
rowHeight = TableCache.cache.rowHeight.toScala,
174-
onRowClick = x => Callback.log(x),
175-
onScroll = (c, s, t) => Callback.log(s"$c $s $t"),
176-
width = props.s.width.toInt,
177-
rowGetter = datum(state.data),
178-
headerClassName = "headerColumn",
179-
sort = sort _,
180-
sortBy = props.sortBy,
181-
sortDirection = state.sortDirection,
182-
scrollTop = 2000,
183-
headerHeight = 30
171+
disableHeader = false,
172+
noRowsRenderer = () => <.div(^.cls := "noRows", "No rows"),
173+
overscanRowCount = 10,
174+
rowClassName = rowClassName _,
175+
height = 600,
176+
rowCount = 10,
177+
rowHeight = TableCache.cache.rowHeight.toScala,
178+
onRowClick = x => Callback.log(x),
179+
onScroll = (c, s, t) => Callback.log(s"$c $s $t"),
180+
width = props.s.width.toInt,
181+
rowGetter = datum(state.data),
182+
headerClassName = "headerColumn",
183+
sort = sort _,
184+
sortBy = props.sortBy,
185+
sortDirection = state.sortDirection,
186+
scrollTop = 2000,
187+
headerHeight = 30
184188
),
185189
columns: _*
186190
)

facade/src/main/scala/react/virtualized/AutoSizer.scala

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ object AutoSizer {
2323
@js.native
2424
trait Props extends js.Object {
2525

26-
/** Function responsible for rendering children.*/
26+
/** Function responsible for rendering children. */
2727
var children: RawChildren = js.native
2828

29-
/** Optional custom CSS class name to attach to root AutoSizer element. */
29+
/** Optional custom CSS class name to attach to root AutoSizer element. */
3030
var className: js.UndefOr[String] = js.native
3131

3232
/** Default height to use for initial render; useful for SSR */
@@ -64,15 +64,15 @@ object AutoSizer {
6464
style: js.UndefOr[Style] = js.undefined
6565
): Props = {
6666
val p = (new js.Object).asInstanceOf[Props]
67-
p.className = (className, clazz).toJs
67+
p.className = (className, clazz).toJs
6868
p.defaultHeight = defaultHeight
69-
p.defaultWidth = defaultWidth
69+
p.defaultWidth = defaultWidth
7070
p.disableHeight = disableHeight
71-
p.disableWidth = disableWidth
72-
p.nonce = nonce
73-
p.onResize = (s: Size) => onResize(s).runNow
74-
p.children = (s: Size) => children(s).toRaw
75-
p.style = style.map(Style.toJsObject).getOrElse(new js.Object())
71+
p.disableWidth = disableWidth
72+
p.nonce = nonce
73+
p.onResize = (s: Size) => onResize(s).runNow
74+
p.children = (s: Size) => children(s).toRaw
75+
p.style = style.map(Style.toJsObject).getOrElse(new js.Object())
7676
p
7777
}
7878

facade/src/main/scala/react/virtualized/CellMeasurer.scala

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ object CellMeasurerCacheParams {
4141
fixedDirection == FixedHeight,
4242
fixedDirection == FixedWidth,
4343
minHeight,
44-
minWidth)
44+
minWidth
45+
)
4546

4647
private def rawapply(
4748
defaultHeight: js.UndefOr[JsNumber],
@@ -53,11 +54,11 @@ object CellMeasurerCacheParams {
5354
): CellMeasurerCacheParams = {
5455
val p = (new js.Object).asInstanceOf[CellMeasurerCacheParams]
5556
p.defaultHeight = defaultHeight
56-
p.defaultWidth = defaultWidth
57-
p.fixedHeight = fixedHeight
58-
p.fixedWidth = fixedWidth
59-
p.minHeight = minHeight
60-
p.minWidth = minWidth
57+
p.defaultWidth = defaultWidth
58+
p.fixedHeight = fixedHeight
59+
p.fixedWidth = fixedWidth
60+
p.minHeight = minHeight
61+
p.minWidth = minWidth
6162
p
6263
}
6364
}
@@ -90,7 +91,8 @@ object CellMeasurerCache {
9091
defaultWidth,
9192
fixedWidth,
9293
minHeight,
93-
minWidth)
94+
minWidth
95+
)
9496
)
9597
}
9698

@@ -110,7 +112,7 @@ object CellMeasurer {
110112
def apply(columnIndex: JsNumber, rowIndex: JsNumber): Cell = {
111113
val p = (new js.Object).asInstanceOf[Cell]
112114
p.columnIndex = columnIndex
113-
p.rowIndex = rowIndex
115+
p.rowIndex = rowIndex
114116
p
115117
}
116118
}
@@ -131,7 +133,7 @@ object CellMeasurer {
131133
): Parent = {
132134
val p = (new js.Object).asInstanceOf[Parent]
133135
p.invalidateCellSizeAfterRender = invalidateCellSizeAfterRender
134-
p.recomputeGridSize = recomputeGridSize
136+
p.recomputeGridSize = recomputeGridSize
135137
p
136138
}
137139

@@ -157,12 +159,12 @@ object CellMeasurer {
157159
children: VdomNode
158160
): Props = {
159161
val p = (new js.Object).asInstanceOf[Props]
160-
p.cache = cache
162+
p.cache = cache
161163
p.columnIndex = columnIndex
162-
p.index = index
163-
p.parent = parent
164-
p.rowIndex = rowIndex
165-
p.children = children.rawNode
164+
p.index = index
165+
p.parent = parent
166+
p.rowIndex = rowIndex
167+
p.children = children.rawNode
166168
p
167169
}
168170

facade/src/main/scala/react/virtualized/Column.scala

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ object Column {
121121
style: js.UndefOr[Style] = js.undefined
122122
): Props = {
123123
val p = (new js.Object).asInstanceOf[Props]
124-
p.width = width
125-
p.dataKey = dataKey
124+
p.width = width
125+
p.dataKey = dataKey
126126
p.`aria-label` = ariaLabel
127127
def rawCellDataGetter(cdg: CellDataGetter[B, C, A]): RawCellDataGetter =
128128
(cdp: RawCellDataParameter) =>
@@ -133,15 +133,16 @@ object Column {
133133
r.columnData.asInstanceOf[B],
134134
r.dataKey,
135135
r.rowData.asInstanceOf[C],
136-
r.rowIndex).toRaw
136+
r.rowIndex
137+
).toRaw
137138
).orUndefined
138-
p.className = (className, clazz).toJs
139-
p.columnData = columnData
140-
p.disableSort = disableSort
139+
p.className = (className, clazz).toJs
140+
p.columnData = columnData
141+
p.disableSort = disableSort
141142
p.defaultSortDirection = defaultSortDirection.toRaw
142-
p.flexGrow = flexGrow
143-
p.flexShrink = flexShrink
144-
p.headerClassName = headerClassName
143+
p.flexGrow = flexGrow
144+
p.flexShrink = flexShrink
145+
p.headerClassName = headerClassName
145146
p.headerRenderer = (r: RawHeaderRendererParameter) =>
146147
headerRenderer(
147148
r.columnData.asInstanceOf[B],
@@ -152,11 +153,11 @@ object Column {
152153
SortDirection.fromRaw(r.sortDirection.getOrElse(""))
153154
).toRaw
154155
p.headerStyle = headerStyle.map(Style.toJsObject)
155-
p.id = id
156-
p.label = label.rawNode
157-
p.maxWidth = maxWidth
158-
p.minWidth = minWidth
159-
p.style = style.map(Style.toJsObject)
156+
p.id = id
157+
p.label = label.rawNode
158+
p.maxWidth = maxWidth
159+
p.minWidth = minWidth
160+
p.style = style.map(Style.toJsObject)
160161
p
161162
}
162163

0 commit comments

Comments
 (0)