Scoop API

scoop:scoop.ui.component:0.1.0

src/sidebar/input.scoop

Selected production source · src/sidebar/input.scoop

1package scoop.ui.component
3import scoop.graphics.*
4import scoop.ui.*
5import scoop.ui.style.*
6import scoop.ui.text.TextEditorState
8public 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.key
15 )
18public class SidebarInput public constructor(
19 private val props: Props<InputProps>,
20 scope: ComponentScope
21) : 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.value
28 val theme = themes.read(input.theme)
29 val d = theme.tokens.typography.body.fontSize / 14.0
30 val style = input
31 .style
32 .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.label
79 ),
80 { current, mount -> Input(current, scope = mount) }
81 )
82 }