Skip to content

Commit ad3db88

Browse files
author
samgarasx
committed
Update kotlin-react-intl wrapper to v5.21.0
1 parent 66818d9 commit ad3db88

File tree

10 files changed

+49
-18
lines changed

10 files changed

+49
-18
lines changed

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ kotlin-styled.version=5.3.1-pre.258
88

99
kotlin-antd.version=4.8.6-pre.15
1010
kotlin-moment.version=2.29.1-pre.14
11-
kotlin-react-intl.version=5.20.13-pre.14
11+
kotlin-react-intl.version=5.21.0-pre.15
1212
kotlin-react-responsive.version=8.2.0-pre.14
1313
kotlin-uikit.version=3.7.6-pre.13

kotlin-react-intl/react-intl-samples/src/main/kotlin/samples/App.kt

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class App : RComponent<Props, State>() {
3030
}
3131
styledDiv {
3232
css { +AppStyles.content }
33+
plural()
3334
timeZone()
3435
messages()
3536
injected()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package samples
2+
3+
import kotlinx.html.js.onClickFunction
4+
import react.*
5+
import react.dom.button
6+
import reactintl.components.plural.formattedPlural
7+
import reactintl.components.provider.intlProvider
8+
9+
private val app = fc<Props> {
10+
val (dogs, setDogs) = useState(1)
11+
12+
intlProvider {
13+
attrs {
14+
locale = "en"
15+
defaultLocale = "en"
16+
}
17+
formattedPlural {
18+
attrs {
19+
value = dogs
20+
one = ReactNode("I have a unique dog")
21+
other = ReactNode("I have $dogs dogs")
22+
}
23+
}
24+
button {
25+
attrs.onClickFunction = { setDogs(dogs + 1) }
26+
+"Add dogs"
27+
}
28+
}
29+
}
30+
31+
fun RBuilder.plural() = child(app)

kotlin-react-intl/src/main/kotlin/reactintl/ReactIntl.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ external fun <K, T : MessageDescriptor, U> defineMessages(msgs: U): U
1919
@JsName("defineMessage")
2020
external fun <T : MessageDescriptor> defineMessage(msg: T): T
2121

22-
external interface IntlShape : ResolvedIntlConfig, IntlFormatters<Any /* String, ReactNode */> {
22+
external interface IntlShape : ResolvedIntlConfig, IntlFormatters<ReactNode> {
2323
var formatters: Formatters
2424
}
2525

@@ -33,7 +33,7 @@ external interface IntlCache {
3333
var displayNames: Record<String, DisplayNames>
3434
}
3535

36-
external interface ResolvedIntlConfig : CoreResolvedIntlConfig<Any /* String | ReactNode */> {
36+
external interface ResolvedIntlConfig : CoreResolvedIntlConfig<ReactNode> {
3737
var textComponent: ComponentType<Props>
3838
var wrapRichTextChunksInFragment: Boolean?
3939
}

kotlin-react-intl/src/main/kotlin/reactintl/components/datetime/FormattedDateTime.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ external interface FormattedTimePartsProps : FormatDateOptions, Props {
5353
external interface FormattedDateTimeRangeProps : FormatDateOptions, Props {
5454
var from: Any /* Number | Date */
5555
var to: Any /* Number | Date */
56-
fun children(value: Any /* String | ReactNode */): ReactElement?
56+
fun children(value: ReactNode): ReactElement?
5757
}
5858

5959
external interface Formats : IntlDateTime.DateTimeFormatOptions {

kotlin-react-intl/src/main/kotlin/reactintl/components/list/FormattedList.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ external class FormattedListComponent : Component<FormattedListProps, State> {
1212
}
1313

1414
external interface FormattedListProps : ListFormatOptions, Props {
15-
var value: Array<Any /* String | ReactNode */>
15+
var value: Array<ReactNode>
1616
}
1717

1818
external interface FormattedListPartsProps : FormatListOptions, Props {

kotlin-react-intl/src/main/kotlin/reactintl/components/message/FormattedMessage.kt

+3-4
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@ import react.*
88
import reactintl.*
99

1010
@JsName("FormattedMessage")
11-
external class FormattedMessageComponent :
12-
Component<FormattedMessageProps<Record<String, Any /* String | ReactNode */>>, State> {
11+
external class FormattedMessageComponent : Component<FormattedMessageProps<Record<String, ReactNode>>, State> {
1312
override fun render(): ReactElement?
1413
}
1514

16-
external interface FormattedMessageProps<V : Record<String, Any /* String | ReactNode */>> : MessageDescriptor, Props {
15+
external interface FormattedMessageProps<V : Record<String, ReactNode>> : MessageDescriptor, Props {
1716
var values: V?
1817
var tagName: Any?
19-
var children: ((nodes: Array<Any /* String | ReactNode */>) -> ReactElement)?
18+
var children: ((nodes: Array<ReactNode>) -> ReactElement)?
2019
var ignoreTag: Boolean?
2120
}
2221

kotlin-react-intl/src/main/kotlin/reactintl/components/message/FormattedMessageDsl.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ package reactintl.components.message
33
import kotlinext.js.Record
44
import react.*
55

6-
fun RBuilder.formattedMessage(handler: RHandler<FormattedMessageProps<Record<String, Any /* String | ReactNode */>>>) =
6+
fun RBuilder.formattedMessage(handler: RHandler<FormattedMessageProps<Record<String, ReactNode>>>) =
77
child(FormattedMessageComponent::class, handler)

kotlin-react-intl/src/main/kotlin/reactintl/components/plural/FormattedPlural.kt

+7-7
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ external class FormattedPluralComponent : Component<FormattedPluralProps, State>
1414
external interface FormattedPluralProps : FormatPluralOptions, Props {
1515
var value: Number
1616
var intl: IntlShape
17-
var other: Any /* String | ReactNode */
18-
var zero: Any? /* String | ReactNode */
19-
var one: Any? /* String | ReactNode */
20-
var two: Any? /* String | ReactNode */
21-
var few: Any? /* String | ReactNode */
22-
var many: Any? /* String | ReactNode */
23-
var children: ((value: Any? /* String | ReactNode */) -> ReactElement?)?
17+
var other: ReactNode
18+
var zero: ReactNode?
19+
var one: ReactNode?
20+
var two: ReactNode?
21+
var few: ReactNode?
22+
var many: ReactNode?
23+
var children: ((value: ReactNode?) -> ReactElement?)?
2424
}
2525

2626
external object IntlPlural {

kotlin-react-intl/src/main/kotlin/reactintl/components/provider/Provider.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ external interface ProviderState : State {
1919
var prevConfig: IntlConfig
2020
}
2121

22-
external val createIntl: CreateIntlFn<Any /* String | ReactNode */, IntlConfig, IntlShape>
22+
external val createIntl: CreateIntlFn<ReactNode, IntlConfig, IntlShape>

0 commit comments

Comments
 (0)