diff --git a/gradle.properties b/gradle.properties index 3ac5871..5aea3c5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 diff --git a/kotlin-react-intl/react-intl-samples/src/main/kotlin/samples/App.kt b/kotlin-react-intl/react-intl-samples/src/main/kotlin/samples/App.kt index c4df4f1..81cf972 100644 --- a/kotlin-react-intl/react-intl-samples/src/main/kotlin/samples/App.kt +++ b/kotlin-react-intl/react-intl-samples/src/main/kotlin/samples/App.kt @@ -30,6 +30,7 @@ class App : RComponent() { } styledDiv { css { +AppStyles.content } + plural() timeZone() messages() injected() diff --git a/kotlin-react-intl/react-intl-samples/src/main/kotlin/samples/Plural.kt b/kotlin-react-intl/react-intl-samples/src/main/kotlin/samples/Plural.kt new file mode 100644 index 0000000..8a02deb --- /dev/null +++ b/kotlin-react-intl/react-intl-samples/src/main/kotlin/samples/Plural.kt @@ -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 { + 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) diff --git a/kotlin-react-intl/src/main/kotlin/reactintl/ReactIntl.kt b/kotlin-react-intl/src/main/kotlin/reactintl/ReactIntl.kt index c80aa95..795bb39 100644 --- a/kotlin-react-intl/src/main/kotlin/reactintl/ReactIntl.kt +++ b/kotlin-react-intl/src/main/kotlin/reactintl/ReactIntl.kt @@ -19,7 +19,7 @@ external fun defineMessages(msgs: U): U @JsName("defineMessage") external fun defineMessage(msg: T): T -external interface IntlShape : ResolvedIntlConfig, IntlFormatters { +external interface IntlShape : ResolvedIntlConfig, IntlFormatters { var formatters: Formatters } @@ -33,7 +33,7 @@ external interface IntlCache { var displayNames: Record } -external interface ResolvedIntlConfig : CoreResolvedIntlConfig { +external interface ResolvedIntlConfig : CoreResolvedIntlConfig { var textComponent: ComponentType var wrapRichTextChunksInFragment: Boolean? } diff --git a/kotlin-react-intl/src/main/kotlin/reactintl/components/datetime/FormattedDateTime.kt b/kotlin-react-intl/src/main/kotlin/reactintl/components/datetime/FormattedDateTime.kt index d875d86..8113225 100644 --- a/kotlin-react-intl/src/main/kotlin/reactintl/components/datetime/FormattedDateTime.kt +++ b/kotlin-react-intl/src/main/kotlin/reactintl/components/datetime/FormattedDateTime.kt @@ -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 { diff --git a/kotlin-react-intl/src/main/kotlin/reactintl/components/list/FormattedList.kt b/kotlin-react-intl/src/main/kotlin/reactintl/components/list/FormattedList.kt index d55e698..0cd3d5c 100644 --- a/kotlin-react-intl/src/main/kotlin/reactintl/components/list/FormattedList.kt +++ b/kotlin-react-intl/src/main/kotlin/reactintl/components/list/FormattedList.kt @@ -12,7 +12,7 @@ external class FormattedListComponent : Component { } external interface FormattedListProps : ListFormatOptions, Props { - var value: Array + var value: Array } external interface FormattedListPartsProps : FormatListOptions, Props { diff --git a/kotlin-react-intl/src/main/kotlin/reactintl/components/message/FormattedMessage.kt b/kotlin-react-intl/src/main/kotlin/reactintl/components/message/FormattedMessage.kt index 78837de..149258d 100644 --- a/kotlin-react-intl/src/main/kotlin/reactintl/components/message/FormattedMessage.kt +++ b/kotlin-react-intl/src/main/kotlin/reactintl/components/message/FormattedMessage.kt @@ -8,15 +8,14 @@ import react.* import reactintl.* @JsName("FormattedMessage") -external class FormattedMessageComponent : - Component>, State> { +external class FormattedMessageComponent : Component>, State> { override fun render(): ReactElement? } -external interface FormattedMessageProps> : MessageDescriptor, Props { +external interface FormattedMessageProps> : MessageDescriptor, Props { var values: V? var tagName: Any? - var children: ((nodes: Array) -> ReactElement)? + var children: ((nodes: Array) -> ReactElement)? var ignoreTag: Boolean? } diff --git a/kotlin-react-intl/src/main/kotlin/reactintl/components/message/FormattedMessageDsl.kt b/kotlin-react-intl/src/main/kotlin/reactintl/components/message/FormattedMessageDsl.kt index 069793c..ce2142e 100644 --- a/kotlin-react-intl/src/main/kotlin/reactintl/components/message/FormattedMessageDsl.kt +++ b/kotlin-react-intl/src/main/kotlin/reactintl/components/message/FormattedMessageDsl.kt @@ -3,5 +3,5 @@ package reactintl.components.message import kotlinext.js.Record import react.* -fun RBuilder.formattedMessage(handler: RHandler>>) = +fun RBuilder.formattedMessage(handler: RHandler>>) = child(FormattedMessageComponent::class, handler) diff --git a/kotlin-react-intl/src/main/kotlin/reactintl/components/plural/FormattedPlural.kt b/kotlin-react-intl/src/main/kotlin/reactintl/components/plural/FormattedPlural.kt index 2ea7340..5c391c3 100644 --- a/kotlin-react-intl/src/main/kotlin/reactintl/components/plural/FormattedPlural.kt +++ b/kotlin-react-intl/src/main/kotlin/reactintl/components/plural/FormattedPlural.kt @@ -14,13 +14,13 @@ external class FormattedPluralComponent : Component 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 { diff --git a/kotlin-react-intl/src/main/kotlin/reactintl/components/provider/Provider.kt b/kotlin-react-intl/src/main/kotlin/reactintl/components/provider/Provider.kt index ae14dfd..6863b17 100644 --- a/kotlin-react-intl/src/main/kotlin/reactintl/components/provider/Provider.kt +++ b/kotlin-react-intl/src/main/kotlin/reactintl/components/provider/Provider.kt @@ -19,4 +19,4 @@ external interface ProviderState : State { var prevConfig: IntlConfig } -external val createIntl: CreateIntlFn +external val createIntl: CreateIntlFn