Files
metabuilder/fakemui/qml-components/form/CAutocomplete.qml
JohnDoe6345789 58a94d0489 feat(styles): add component-specific styles for TaskDetail, SearchDialog, and Documentation
feat(styles): create global styles entry point and organize global styles

feat(styles): implement base HTML element styles and utility classes for flexbox

feat(styles): establish layout, position, spacing, and text utility classes

feat(styles): introduce mixins for animations, cards, dialogs, flexbox, grid, and responsive design

test(quick_guide): add component and metadata validation tests for quick_guide package

test(ui_level6): implement metadata validation tests for ui_level6 package
2025-12-30 02:29:58 +00:00

53 lines
1.4 KiB
QML

import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
/**
* CAutocomplete.qml - simple autocomplete input with popup suggestions
*/
Item {
id: root
width: 300
property alias text: input.text
property var suggestions: []
property Component delegate: null
signal accepted(string value)
TextField {
id: input
anchors.left: parent.left
anchors.right: parent.right
placeholderText: "Type to search..."
onTextChanged: {
popup.open()
}
onAccepted: root.accepted(text)
}
Popup {
id: popup
x: input.mapToItem(root, 0, input.height).x
y: input.mapToItem(root, 0, input.height).y
width: input.width
modal: false
focus: true
Rectangle {
width: parent.width
color: Theme.surface
radius: StyleVariables.radiusSm
border.color: Theme.divider
ListView {
id: list
width: parent.width
model: root.suggestions
delegate: root.delegate ? root.delegate : ItemDelegate { text: modelData; onClicked: { root.input.text = modelData; popup.close(); root.accepted(modelData); } }
clip: true
interactive: true
height: Math.min(200, contentHeight)
}
}
}
}