Skip to main content

day_spec/controls/
combobox.rs

1// Copyright © The Daybrite Project
2// SPDX-License-Identifier: MPL-2.0
3
4pub const KIND: &str = "day.piece.combobox";
5
6/// Full props (realize). `items` seeds the dropdown, `text` the entry; `placeholder` is the
7/// empty-state prompt (fixed at build). After build, `items` and `text` change via [`ComboPatch`].
8#[derive(Clone, Debug, Default, PartialEq)]
9pub struct ComboProps {
10    pub items: Vec<String>,
11    pub text: String,
12    pub placeholder: String,
13}
14
15/// Sparse imperative updates: replace the dropdown's items, or the entry's text (programmatic
16/// sync from the bound signal). An items swap must keep the typed text, because the text is the
17/// value.
18#[derive(Clone, Debug, PartialEq)]
19pub enum ComboPatch {
20    Items(Vec<String>),
21    SetText(String),
22}