feat: basic select layout
This commit is contained in:
parent
b5a5559f7b
commit
c0fbd16929
@ -451,10 +451,27 @@ class Option:
|
||||
This could represent a data object, a string or a page.
|
||||
"""
|
||||
|
||||
def __init__(self, value: Any, text: Optional[str] = None, keys: Set[str] = None):
|
||||
def __init__(self, value: Any, text: Optional[str] = None, keys: Set[str] = None, hidden: bool = False):
|
||||
self.value = value
|
||||
self.text = text or str(value)
|
||||
self.hidden = hidden
|
||||
|
||||
self.keys = keys or set()
|
||||
self.keys.add(self.text)
|
||||
|
||||
|
||||
class SelectOption:
|
||||
def __init__(self, options: List[Option] = None):
|
||||
self._key_to_option: Dict[Any, Option] = dict()
|
||||
self._options: List[Option] = options
|
||||
|
||||
self.extend(options or [])
|
||||
|
||||
def append(self, option: Option):
|
||||
self._options.append(option)
|
||||
for key in option.keys:
|
||||
self._key_to_option[key] = option
|
||||
|
||||
def extend(self, options: List[Option]):
|
||||
for option in options:
|
||||
self.append(option)
|
Loading…
Reference in New Issue
Block a user