scoop:scoop.ui.component:0.1.0
src/input_group/control.scoop
Selected production source · src/input_group/control.scoop
1
package scoop.ui.component3
import scoop.ui.*5
internal fun inputGroupControlEnabled(control: InputGroupControl): Boolean = when (control) {6
case Input(val value) -> value.enabled7
case Textarea(val value) -> value.enabled8
case Custom(_, _) -> true9
}11
internal fun inputGroupControlInvalid(control: InputGroupControl): Boolean = when (control) {12
case Input(val value) -> value.invalid13
case Textarea(val value) -> value.invalid14
case Custom(_, _) -> false15
}17
internal fun inputGroupFocus(control: InputGroupControl, own: FocusHandle): FocusHandle =18
when (control) {19
case Input(val value) -> value.focus.handle ?: own20
case Textarea(val value) -> value.focus.handle ?: own21
case Custom(_, val focus) -> focus22
}24
internal fun inputGroupControlView(25
group: InputGroupProps,26
focus: FocusHandle,27
enabled: Boolean,28
invalid: Boolean29
): View = when (group.control) {30
case Input(val value) ->31
component(32
InputProps(33
value.state,34
placeholder = value.placeholder,35
label = value.label,36
enabled = enabled,37
readOnly = value.readOnly,38
invalid = invalid,39
description = value.description,40
fonts = if (panelPresent(value.fonts)) value.fonts else group.fonts,41
style = value.style,42
theme = if (panelPresent(value.theme)) value.theme else group.theme,43
focus = value.focus.copy { this.handle = Some(focus) },44
direction = value.direction,45
alignment = value.alignment,46
paintCache = value.paintCache,47
caretBlink = value.caretBlink,48
onEdited = value.onEdited,49
onSubmit = value.onSubmit,50
policy = value.policy,51
projection = value.projection,52
copy = value.copy,53
protectedText = value.protectedText,54
acceptDrops = value.acceptDrops,55
drag = value.drag,56
touch = value.touch,57
touchScroll = value.touchScroll,58
inputPurpose = value.inputPurpose,59
softwareKeyboard = value.softwareKeyboard,60
primarySelection = value.primarySelection,61
automaticTextReplacement = value.automaticTextReplacement,62
scrollPhysics = value.scrollPhysics,63
labelTarget = value.labelTarget,64
chrome = TextFieldChrome.Bare,65
contextMenu = value.contextMenu,66
semantics = value.semantics67
),68
{ current, mount -> Input(current, scope = mount) }69
)70
case Textarea(val value) ->71
component(72
TextareaProps(73
value.state,74
placeholder = value.placeholder,75
label = value.label,76
rows = value.rows,77
wrap = value.wrap,78
tab = value.tab,79
submit = value.submit,80
enabled = enabled,81
readOnly = value.readOnly,82
invalid = invalid,83
description = value.description,84
fonts = if (panelPresent(value.fonts)) value.fonts else group.fonts,85
style = value.style,86
theme = if (panelPresent(value.theme)) value.theme else group.theme,87
focus = value.focus.copy { this.handle = Some(focus) },88
direction = value.direction,89
alignment = value.alignment,90
scrollbars = value.scrollbars,91
scrollbarBehavior = value.scrollbarBehavior,92
paintCache = value.paintCache,93
caretBlink = value.caretBlink,94
onEdited = value.onEdited,95
onSubmit = value.onSubmit,96
policy = value.policy,97
projection = value.projection,98
copy = value.copy,99
protectedText = value.protectedText,100
acceptDrops = value.acceptDrops,101
drag = value.drag,102
touch = value.touch,103
touchScroll = value.touchScroll,104
inputPurpose = value.inputPurpose,105
softwareKeyboard = value.softwareKeyboard,106
primarySelection = value.primarySelection,107
automaticTextReplacement = value.automaticTextReplacement,108
scrollPhysics = value.scrollPhysics,109
labelTarget = value.labelTarget,110
chrome = TextFieldChrome.Bare,111
contextMenu = value.contextMenu,112
semantics = value.semantics113
),114
{ current, mount -> Textarea(current, scope = mount) }115
)116
case Custom(val view, _) -> view117
}