mirror of
https://github.com/status-im/status-desktop.git
synced 2025-01-10 06:16:32 +00:00
74a88a70b3
This property enables users to load any component into the input field. This is useful for rendering a "clearable" icon button, simple icons or even more complex buttons. Usage: ```qml StatusBaseInput { ... component: StatusIcon { name: "cancel" color: Theme.palette.dangerColor1 width: 16 } } ``` The `clearable` property of `StatusBaseInput` also renders and icon button on the right hand side. With this new feature, `clearable` is just a short-hand for: ```qml StatusBaseInput { ... component: StatusFlatRoundButton { visible: edit.text.length != 0 && statusBaseInput.clearable && !statusBaseInput.multiline && edit.activeFocus type: StatusFlatRoundButton.Type.Secondary width: 24 height: 24 icon.name: "clear" icon.width: 16 icon.height: 16 icon.color: Theme.palette.baseColor1 onClicked: { edit.clear() } } } ``` Closes #380
134 lines
2.9 KiB
QML
134 lines
2.9 KiB
QML
import QtQuick 2.14
|
|
import QtQuick.Controls 2.14
|
|
import QtQuick.Layouts 1.14
|
|
import StatusQ.Core 0.1
|
|
import StatusQ.Core.Theme 0.1
|
|
import StatusQ.Controls 0.1
|
|
import StatusQ.Controls.Validators 0.1
|
|
|
|
import Sandbox 0.1
|
|
|
|
Column {
|
|
spacing: 8
|
|
|
|
StatusInput {
|
|
input.placeholderText: "Placeholder"
|
|
}
|
|
|
|
StatusInput {
|
|
label: "Label"
|
|
input.placeholderText: "Disabled"
|
|
input.enabled: false
|
|
}
|
|
|
|
StatusInput {
|
|
input.placeholderText: "Clearable"
|
|
input.clearable: true
|
|
}
|
|
|
|
StatusInput {
|
|
input.placeholderText: "Invalid"
|
|
input.valid: false
|
|
}
|
|
|
|
StatusInput {
|
|
label: "Label"
|
|
|
|
input.icon.name: "search"
|
|
input.placeholderText: "Input with icon"
|
|
}
|
|
|
|
StatusInput {
|
|
label: "Label"
|
|
input.placeholderText: "Placeholder"
|
|
input.clearable: true
|
|
}
|
|
|
|
StatusInput {
|
|
charLimit: 30
|
|
input.placeholderText: "Placeholder"
|
|
input.clearable: true
|
|
}
|
|
|
|
StatusInput {
|
|
label: "Label"
|
|
charLimit: 30
|
|
input.placeholderText: "Placeholder"
|
|
input.clearable: true
|
|
}
|
|
|
|
StatusInput {
|
|
label: "Label"
|
|
charLimit: 30
|
|
errorMessage: "Error message"
|
|
|
|
input.clearable: true
|
|
input.valid: false
|
|
input.placeholderText: "Placeholder"
|
|
}
|
|
|
|
StatusInput {
|
|
label: "StatusInput"
|
|
secondaryLabel: "with right icon"
|
|
input.icon.width: 15
|
|
input.icon.height: 11
|
|
input.icon.name: text !== "" ? "checkmark" : ""
|
|
input.leftIcon: false
|
|
}
|
|
|
|
StatusInput {
|
|
label: "Label"
|
|
secondaryLabel: "secondary label"
|
|
input.placeholderText: "Placeholder"
|
|
input.implicitHeight: 56
|
|
}
|
|
|
|
StatusInput {
|
|
id: input
|
|
label: "Label"
|
|
charLimit: 30
|
|
input.placeholderText: "Input with validator"
|
|
|
|
validators: [
|
|
StatusMinLengthValidator {
|
|
minLength: 10
|
|
errorMessage: {
|
|
if (input.errors && input.errors.minLength) {
|
|
return `Value can't be shorter than ${input.errors.minLength.min} but got ${input.errors.minLength.actual}`
|
|
}
|
|
return ""
|
|
}
|
|
}
|
|
]
|
|
}
|
|
|
|
StatusInput {
|
|
label: "Label"
|
|
input.placeholderText: "Input width component (right side)"
|
|
input.component: StatusIcon {
|
|
icon: "cancel"
|
|
height: 16
|
|
color: Theme.palette.dangerColor1
|
|
}
|
|
}
|
|
|
|
|
|
StatusInput {
|
|
input.multiline: true
|
|
input.placeholderText: "Multiline"
|
|
}
|
|
|
|
StatusInput {
|
|
input.multiline: true
|
|
input.placeholderText: "Multiline with static height"
|
|
input.implicitHeight: 100
|
|
}
|
|
|
|
StatusInput {
|
|
input.multiline: true
|
|
input.placeholderText: "Multiline with max/min"
|
|
input.minimumHeight: 80
|
|
input.maximumHeight: 200
|
|
}
|
|
}
|