Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import io.spine.chords.client.EventSubscription
import io.spine.chords.client.appshell.client
import io.spine.chords.proto.form.FormPartScope
import io.spine.chords.proto.form.MessageForm
import io.spine.chords.proto.form.MessageFormSetupBase
import io.spine.chords.proto.form.MessageFormUsageBase
import io.spine.chords.proto.form.MultipartFormScope
import io.spine.protobuf.ValidatingBuilder
import kotlinx.coroutines.TimeoutCancellationException
Expand Down Expand Up @@ -151,7 +151,7 @@ import kotlinx.coroutines.TimeoutCancellationException
*/
public class CommandMessageForm<C : CommandMessage> : MessageForm<C>() {
public companion object :
MessageFormSetupBase<CommandMessage, CommandMessageForm<CommandMessage>>(
MessageFormUsageBase<CommandMessage, CommandMessageForm<CommandMessage>>(
{ CommandMessageForm() }
) {

Expand Down
26 changes: 13 additions & 13 deletions core/src/main/kotlin/io/spine/chords/core/Component.kt
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ import io.spine.chords.core.appshell.app
*
* A component's constructor would actually not need to be used directly in most
* cases! Instead of using the constructor, such expressions work thanks to
* the [invoke][ComponentSetup.invoke] operator function being declared
* the [invoke][ComponentUsage.invoke] operator function being declared
* on the component's companion object, which is in particular required to
* prevent creating a new component's instance upon each composition, and use
* a cached instance instead.
Expand Down Expand Up @@ -145,7 +145,7 @@ import io.spine.chords.core.appshell.app
*
* - Create a subclass of [Component].
*
* - Add a companion object of type [ComponentSetup], which introduces
* - Add a companion object of type [ComponentUsage], which introduces
* the instance declaration API (which is technically being an invocation).
*
* You can consider the presence of this companion object as a kind of
Expand Down Expand Up @@ -523,7 +523,7 @@ import io.spine.chords.core.appshell.app
*
* @constructor A constructor, which is used internally by the component's
* implementation (its companion object). As an application developer, use
* [companion object][ComponentSetup]'s [invoke][ComponentSetup.invoke]
* [companion object][ComponentUsage]'s [invoke][ComponentUsage.invoke]
* operator for instantiating and rendering any specific
* component's implementation.
*
Expand All @@ -540,7 +540,7 @@ public abstract class Component {
*
* In most cases this property would not need to be used by the
* application's code directly, since it would be set automatically by
* [ComponentSetup.invoke] or an analogous component
* [ComponentUsage.invoke] or an analogous component
* declaration function.
*/
internal var props: ComponentProps<Component>? = null
Expand Down Expand Up @@ -643,7 +643,7 @@ public abstract class Component {
* lifecycle, including instance creation, property updates, and
* rendering, which removes the need to perform any of those steps
* explicitly. See the "Using class-based components" section in
* [Component] class description, and the [ComponentSetup.invoke]
* [Component] class description, and the [ComponentUsage.invoke]
* operator functions for details.
*
* - The component's composable content has to be specified by overriding
Expand Down Expand Up @@ -714,12 +714,12 @@ public abstract class Component {
*
* It generally doesn't need to be used directly when using the components,
* since it would be implicitly created by a lambda that is passed to the
* [ComponentSetup.invoke] function.
* [ComponentUsage.invoke] function.
* It is a part of an internal implementation of [Component], and, in case of
* some advanced components, can also be used when creating new components.
*
* @See Component
* @see ComponentSetup.invoke
* @see ComponentUsage.invoke
* @see Component.props
*/
public fun interface ComponentProps <C: Component> {
Expand All @@ -742,16 +742,16 @@ public fun interface ComponentProps <C: Component> {
* components" sections of the [Component] class for general information about
* how class-based components are used in an application.
*
* In most cases custom class-based components would use [ComponentSetup]
* In most cases custom class-based components would use [ComponentUsage]
* for to introduce the component's _instance declaration API_. However, in some
* rare case a component might require different instance declaration API. In
* such cases those companion objects would use this class as a base class for
* a companion object instead.
*
* @param createInstance A lambda that should create a component's instance.
* @see ComponentSetup
* @see ComponentUsage
*/
public abstract class AbstractComponentSetup(
public abstract class AbstractComponentUsage(
protected val createInstance: (() -> Component)? = null
) {

Expand Down Expand Up @@ -862,11 +862,11 @@ public abstract class AbstractComponentSetup(
* @constructor Creates a companion object for a component of type [C].
* @param createInstance A lambda that should create a component's instance of
* type [C] with the given properties configuration callback.
* @see AbstractComponentSetup
* @see AbstractComponentUsage
*/
public open class ComponentSetup<C: Component>(
public open class ComponentUsage<C: Component>(
createInstance: () -> C
) : AbstractComponentSetup(createInstance) {
) : AbstractComponentUsage(createInstance) {

/**
* Declares an instance of component of type [C] with the respective
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ import kotlinx.coroutines.launch
// All class's functions are better to have in this class.
@Suppress("TooManyFunctions", "LargeClass")
public class DropdownListBox<I> : Component() {
public companion object : AbstractComponentSetup() {
public companion object : AbstractComponentUsage() {

/**
* Declares an instance of [DropdownListBox] with the respective
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public class AppWindow(
* dialog that the user can interact with at a time. It's possible to
* display nested dialogs though. That is, when some dialog is already
* displayed, another dialog can be open (see
* [DialogSetup][io.spine.chords.core.layout.DialogSetup.open]), which means
* [DialogSetup][io.spine.chords.core.layout.DialogUsage.open]), which means
* that the first dialog still remains opened, but cannot be interacted with
* until the second one (which is displayed on top of it) is closed.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.window.application
import io.spine.chords.core.layout.Dialog
import io.spine.chords.core.layout.ConfirmationDialog
import io.spine.chords.core.layout.DialogSetup
import io.spine.chords.core.layout.DialogUsage
import io.spine.chords.core.layout.DialogDisplayMode
import io.spine.chords.core.writeOnce
import java.awt.Dimension
Expand Down Expand Up @@ -335,7 +335,7 @@ public class ApplicationUI(private val appWindow: AppWindow) {
* @param dialog The [Dialog] instance, which needs to be displayed.
*
* @see Dialog
* @see DialogSetup
* @see DialogUsage
* @see closeDialog
*/
internal fun openDialog(dialog: Dialog) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import io.spine.chords.core.AbstractComponentSetup
import io.spine.chords.core.AbstractComponentUsage
import io.spine.chords.core.ComponentProps
import java.util.concurrent.CompletableFuture
import kotlinx.coroutines.future.await
Expand All @@ -24,7 +24,7 @@ import kotlinx.coroutines.future.await
* (e.g. approve or deny some action).
*/
public class ConfirmationDialog : Dialog() {
public companion object : AbstractComponentSetup({ ConfirmationDialog() }) {
public companion object : AbstractComponentUsage({ ConfirmationDialog() }) {

/**
* Displays the confirmation dialog, and waits until the user
Expand Down
10 changes: 5 additions & 5 deletions core/src/main/kotlin/io/spine/chords/core/layout/Dialog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ import androidx.compose.ui.window.DialogWindow
import androidx.compose.ui.window.Popup
import androidx.compose.ui.window.PopupPositionProvider
import androidx.compose.ui.window.PopupProperties
import io.spine.chords.core.AbstractComponentSetup
import io.spine.chords.core.AbstractComponentUsage
import io.spine.chords.core.Component
import io.spine.chords.core.ComponentProps
import io.spine.chords.core.appshell.app
Expand All @@ -90,7 +90,7 @@ private val submitShortcutKey = Ctrl(Enter.key)
* submitting data.
*
* Note that an implementation of this class has to add a companion object of
* type [DialogSetup]. Here's an example of how a custom dialog can be created:
* type [DialogUsage]. Here's an example of how a custom dialog can be created:
*
* ```
* public class MyDialog : Dialog() {
Expand Down Expand Up @@ -302,7 +302,7 @@ public abstract class Dialog : Component() {
* some reason.
*
* In most cases the most convenient way to open a dialog would be using its
* companion object's [open][DialogSetup.open] method instead, like this:
* companion object's [open][DialogUsage.open] method instead, like this:
*
* ```
* MyDialog.open()
Expand Down Expand Up @@ -703,9 +703,9 @@ internal class LightweightDisplayMode(
*
* @see Dialog
*/
public open class DialogSetup<D: Dialog>(
public open class DialogUsage<D: Dialog>(
createInstance: () -> D
) : AbstractComponentSetup(createInstance) {
) : AbstractComponentUsage(createInstance) {

/**
* Displays the modal dialog [D].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import io.spine.chords.core.Component
* constructor's parameter.
*
* - Add a companion object of type
* [ComponentSetup][io.spine.chords.core.ComponentSetup] to ensure that the
* [ComponentSetup][io.spine.chords.core.ComponentUsage] to ensure that the
* component can actually be used (like any other class-based [Component]]).
*
* - Override either [customContent] (for rendering ordinary singlepart forms),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ package io.spine.chords.proto.form
import androidx.compose.runtime.Composable
import com.google.protobuf.Message
import io.spine.chords.core.ComponentProps
import io.spine.chords.core.ComponentSetup
import io.spine.chords.core.ComponentUsage
import io.spine.chords.core.InputComponent
import io.spine.chords.runtime.MessageField
import io.spine.chords.runtime.MessageFieldValue
Expand Down Expand Up @@ -117,15 +117,15 @@ import io.spine.chords.runtime.MessageFieldValue
* instance. It is invoked before each recomposition of the component.
* @return A component's instance that has been created for this
* declaration site.
* @see ComponentSetup.invoke
* @see ComponentUsage.invoke
*/
context(FormFieldsScope<M>)
@Composable
public operator fun <
C : InputComponent<V>,
M : Message,
V : MessageFieldValue
> ComponentSetup<C>.invoke(
> ComponentUsage<C>.invoke(
field: MessageField<M, V>,
props: ComponentProps<C>? = null
): C {
Expand All @@ -145,7 +145,7 @@ public operator fun <
*
* A regular way to both lazily instantiate and render a component is via
* the respective component's companion object's `invoke` operator (see the
* [ComponentSetup.invoke] operator functions).
* [ComponentUsage.invoke] operator functions).
*
* @receiver A context introduced by the parent form whose fields need to
* be edited.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ import io.spine.validate.ValidationException
// Seems all class's functions are better to have in this class.
@Suppress("TooManyFunctions")
public open class MessageForm<M : Message> : InputComponent<M>(), InputContext {
public companion object : MessageFormSetupBase<Message, MessageForm<Message>>(
public companion object : MessageFormUsageBase<Message, MessageForm<Message>>(
{ MessageForm() }
) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ package io.spine.chords.proto.form
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import com.google.protobuf.Message
import io.spine.chords.core.AbstractComponentSetup
import io.spine.chords.core.AbstractComponentUsage
import io.spine.chords.core.ComponentProps
import io.spine.chords.runtime.MessageField
import io.spine.protobuf.ValidatingBuilder
Expand All @@ -43,11 +43,11 @@ import io.spine.protobuf.ValidatingBuilder
* actual implementation.
*
* @see io.spine.chords.core.Component
* @see io.spine.chords.core.ComponentSetup
* @see io.spine.chords.core.ComponentUsage
*/
public open class MessageFormSetupBase<M: Message, F: MessageForm<M>>(
public open class MessageFormUsageBase<M: Message, F: MessageForm<M>>(
createInstance: () -> F
) : AbstractComponentSetup({ createInstance() }) {
) : AbstractComponentUsage({ createInstance() }) {

/**
* Declares a `MessageForm` instance, which is not bound to a parent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ package io.spine.chords.proto.form

import androidx.compose.runtime.Composable
import com.google.protobuf.Message
import io.spine.chords.core.AbstractComponentSetup
import io.spine.chords.core.AbstractComponentUsage
import io.spine.chords.core.FocusRequestDispatcher
import io.spine.chords.core.FocusableComponent
import io.spine.chords.core.primitive.RadioButtonWithText
Expand All @@ -46,7 +46,7 @@ import io.spine.protobuf.ValidatingBuilder
* @param F A type of the oneof field.
*/
public class OneofRadioButton<M : Message, F: MessageFieldValue> : FocusableComponent() {
public companion object : OneofRadioButtonSetup()
public companion object : OneofRadioButtonUsage()

/**
* The scope where this `OneofRadioButton` is declared.
Expand Down Expand Up @@ -82,7 +82,7 @@ public class OneofRadioButton<M : Message, F: MessageFieldValue> : FocusableComp
}
}

public open class OneofRadioButtonSetup : AbstractComponentSetup(
public open class OneofRadioButtonUsage : AbstractComponentUsage(
{ OneofRadioButton<Message, MessageFieldValue>() }
) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
package io.spine.chords.proto.money

import io.spine.chords.proto.form.vBuildBasedParser
import io.spine.chords.core.ComponentSetup
import io.spine.chords.core.ComponentUsage
import io.spine.chords.core.InputField
import io.spine.chords.proto.value.money.BankAccount

/**
* A field that allows entering a bank account number.
*/
public class BankAccountField : InputField<BankAccount>() {
public companion object : ComponentSetup<BankAccountField>({ BankAccountField() })
public companion object : ComponentUsage<BankAccountField>({ BankAccountField() })

init {
label = "Bank account"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import androidx.compose.ui.text.font.FontFamily.Companion.Monospace
import androidx.compose.ui.text.font.FontWeight.Companion.SemiBold
import androidx.compose.ui.text.input.getSelectedText
import androidx.compose.ui.unit.dp
import io.spine.chords.core.ComponentSetup
import io.spine.chords.core.ComponentUsage
import io.spine.chords.core.DropdownListBox
import io.spine.chords.core.DropdownListBoxScope
import io.spine.chords.core.keyboard.KeyRange.Companion.Digit
Expand Down Expand Up @@ -85,7 +85,7 @@ private val defaultCurrency = USD
* A field that allows entering [Money] values.
*/
public class MoneyField : InputField<Money>() {
public companion object : ComponentSetup<MoneyField>({ MoneyField() })
public companion object : ComponentUsage<MoneyField>({ MoneyField() })

/**
* A list of item values to choose from.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

package io.spine.chords.proto.money

import io.spine.chords.core.ComponentSetup
import io.spine.chords.core.ComponentUsage
import io.spine.chords.core.InputField
import io.spine.chords.core.InputReviser.Companion.DigitsOnly
import io.spine.chords.core.InputReviser.Companion.maxLength
Expand Down Expand Up @@ -65,7 +65,7 @@ private val PaymentCardNumberKt.maxValueLength get() = 19
* A field that allows entering a payment card number.
*/
public class PaymentCardNumberField : InputField<PaymentCardNumber>() {
public companion object : ComponentSetup<PaymentCardNumberField>({
public companion object : ComponentUsage<PaymentCardNumberField>({
PaymentCardNumberField()
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import io.spine.chords.core.ComponentSetup
import io.spine.chords.core.ComponentUsage
import io.spine.chords.core.ValidationErrorText
import io.spine.chords.proto.form.CustomMessageForm
import io.spine.chords.proto.form.FormPartScope
Expand All @@ -52,7 +52,7 @@ import io.spine.chords.proto.value.money.PaymentMethodDef.paymentCard
public class PaymentMethodEditor : CustomMessageForm<PaymentMethod>(
{ PaymentMethod.newBuilder() }
) {
public companion object : ComponentSetup<PaymentMethodEditor>({ PaymentMethodEditor() })
public companion object : ComponentUsage<PaymentMethodEditor>({ PaymentMethodEditor() })

/**
* Identifies the component's appearance parameters.
Expand Down
Loading