scoop:scoop.ui.component:0.1.0
src/sidebar/input.scoop
Selected production source · src/sidebar/input.scoop
1
package scoop.ui.component3
import scoop.graphics.*4
import scoop.ui.*5
import scoop.ui.style.*6
import scoop.ui.text.TextEditorState8
public fun sidebarInput(state: TextEditorState, configure: InputBuilder.() -> Unit = {}): View {9
val builder = InputBuilder();10
builder.configure()11
return component(12
builder.inputProps(state),13
{ current, mount -> SidebarInput(current, scope = mount) },14
builder.key15
)16
}18
public class SidebarInput public constructor(19
private val props: Props<InputProps>,20
scope: ComponentScope21
) : Component(scope) {22
private val themes = ThemeAccess(scope)23
public override fun onMount() {24
themes.mount(props.value.theme)25
}26
public override fun render(): View {27
val input = props.value28
val theme = themes.read(input.theme)29
val d = theme.tokens.typography.body.fontSize / 14.030
val style = input31
.style32
.copy {33
surface {34
if (suggestedSize == None) suggestedSize = Some(Size(0.0, 32.0 * d))35
style = styleOverride {36
background(Some(Paint(theme.tokens.palette.background.background)));37
boxShadows([])38
}39
.then(input.style.surface.style)40
}41
}42
return component(43
InputProps(44
input.state,45
input.placeholder,46
input.enabled,47
input.readOnly,48
input.invalid,49
input.description,50
input.fonts,51
style,52
input.theme,53
input.focus,54
input.direction,55
input.alignment,56
input.paintCache,57
input.caretBlink,58
input.onEdited,59
input.onSubmit,60
input.policy,61
input.projection,62
input.copy,63
input.labelTarget,64
input.group,65
input.chrome,66
input.contextMenu,67
input.protectedText,68
input.semantics,69
input.acceptDrops,70
input.drag,71
input.touch,72
input.touchScroll,73
input.scrollPhysics,74
inputPurpose = input.inputPurpose,75
softwareKeyboard = input.softwareKeyboard,76
primarySelection = input.primarySelection,77
automaticTextReplacement = input.automaticTextReplacement,78
label = input.label79
),80
{ current, mount -> Input(current, scope = mount) }81
)82
}83
}