Skip to content

Commit

Permalink
Update kotlin-react-intl wrapper to v5.21.0
Browse files Browse the repository at this point in the history
  • Loading branch information
samgarasx committed Oct 23, 2021
1 parent 66818d9 commit ad3db88
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 18 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ kotlin-styled.version=5.3.1-pre.258

kotlin-antd.version=4.8.6-pre.15
kotlin-moment.version=2.29.1-pre.14
kotlin-react-intl.version=5.20.13-pre.14
kotlin-react-intl.version=5.21.0-pre.15
kotlin-react-responsive.version=8.2.0-pre.14
kotlin-uikit.version=3.7.6-pre.13
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class App : RComponent<Props, State>() {
}
styledDiv {
css { +AppStyles.content }
plural()
timeZone()
messages()
injected()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package samples

import kotlinx.html.js.onClickFunction
import react.*
import react.dom.button
import reactintl.components.plural.formattedPlural
import reactintl.components.provider.intlProvider

private val app = fc<Props> {
val (dogs, setDogs) = useState(1)

intlProvider {
attrs {
locale = "en"
defaultLocale = "en"
}
formattedPlural {
attrs {
value = dogs
one = ReactNode("I have a unique dog")
other = ReactNode("I have $dogs dogs")
}
}
button {
attrs.onClickFunction = { setDogs(dogs + 1) }
+"Add dogs"
}
}
}

fun RBuilder.plural() = child(app)
4 changes: 2 additions & 2 deletions kotlin-react-intl/src/main/kotlin/reactintl/ReactIntl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ external fun <K, T : MessageDescriptor, U> defineMessages(msgs: U): U
@JsName("defineMessage")
external fun <T : MessageDescriptor> defineMessage(msg: T): T

external interface IntlShape : ResolvedIntlConfig, IntlFormatters<Any /* String, ReactNode */> {
external interface IntlShape : ResolvedIntlConfig, IntlFormatters<ReactNode> {
var formatters: Formatters
}

Expand All @@ -33,7 +33,7 @@ external interface IntlCache {
var displayNames: Record<String, DisplayNames>
}

external interface ResolvedIntlConfig : CoreResolvedIntlConfig<Any /* String | ReactNode */> {
external interface ResolvedIntlConfig : CoreResolvedIntlConfig<ReactNode> {
var textComponent: ComponentType<Props>
var wrapRichTextChunksInFragment: Boolean?
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ external interface FormattedTimePartsProps : FormatDateOptions, Props {
external interface FormattedDateTimeRangeProps : FormatDateOptions, Props {
var from: Any /* Number | Date */
var to: Any /* Number | Date */
fun children(value: Any /* String | ReactNode */): ReactElement?
fun children(value: ReactNode): ReactElement?
}

external interface Formats : IntlDateTime.DateTimeFormatOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ external class FormattedListComponent : Component<FormattedListProps, State> {
}

external interface FormattedListProps : ListFormatOptions, Props {
var value: Array<Any /* String | ReactNode */>
var value: Array<ReactNode>
}

external interface FormattedListPartsProps : FormatListOptions, Props {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@ import react.*
import reactintl.*

@JsName("FormattedMessage")
external class FormattedMessageComponent :
Component<FormattedMessageProps<Record<String, Any /* String | ReactNode */>>, State> {
external class FormattedMessageComponent : Component<FormattedMessageProps<Record<String, ReactNode>>, State> {
override fun render(): ReactElement?
}

external interface FormattedMessageProps<V : Record<String, Any /* String | ReactNode */>> : MessageDescriptor, Props {
external interface FormattedMessageProps<V : Record<String, ReactNode>> : MessageDescriptor, Props {
var values: V?
var tagName: Any?
var children: ((nodes: Array<Any /* String | ReactNode */>) -> ReactElement)?
var children: ((nodes: Array<ReactNode>) -> ReactElement)?
var ignoreTag: Boolean?
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ package reactintl.components.message
import kotlinext.js.Record
import react.*

fun RBuilder.formattedMessage(handler: RHandler<FormattedMessageProps<Record<String, Any /* String | ReactNode */>>>) =
fun RBuilder.formattedMessage(handler: RHandler<FormattedMessageProps<Record<String, ReactNode>>>) =
child(FormattedMessageComponent::class, handler)
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ external class FormattedPluralComponent : Component<FormattedPluralProps, State>
external interface FormattedPluralProps : FormatPluralOptions, Props {
var value: Number
var intl: IntlShape
var other: Any /* String | ReactNode */
var zero: Any? /* String | ReactNode */
var one: Any? /* String | ReactNode */
var two: Any? /* String | ReactNode */
var few: Any? /* String | ReactNode */
var many: Any? /* String | ReactNode */
var children: ((value: Any? /* String | ReactNode */) -> ReactElement?)?
var other: ReactNode
var zero: ReactNode?
var one: ReactNode?
var two: ReactNode?
var few: ReactNode?
var many: ReactNode?
var children: ((value: ReactNode?) -> ReactElement?)?
}

external object IntlPlural {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ external interface ProviderState : State {
var prevConfig: IntlConfig
}

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

0 comments on commit ad3db88

Please sign in to comment.