Skip to content

Commit

Permalink
zauberzeug#263 support ui.date with "range" and "multiple" props
Browse files Browse the repository at this point in the history
  • Loading branch information
falkoschindler committed Jan 25, 2023
1 parent 13615a6 commit 03fadf7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions nicegui/elements/date.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@


class Date(ValueElement):
EVENT_ARGS = ['*']

def __init__(self,
value: Optional[str] = None,
Expand Down
3 changes: 2 additions & 1 deletion nicegui/elements/mixins/value_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

class ValueElement(Element):
VALUE_PROP = 'model-value'
EVENT_ARGS = ['value']
value = BindableProperty(on_change=lambda sender, value: sender.on_value_change(value))

def __init__(self, *, value: Any, on_value_change: Optional[Callable], throttle: float = 0, **kwargs) -> None:
Expand All @@ -17,7 +18,7 @@ def __init__(self, *, value: Any, on_value_change: Optional[Callable], throttle:

def handle_change(msg: Dict) -> None:
self.set_value(self._msg_to_value(msg))
self.on(f'update:{self.VALUE_PROP}', handle_change, ['value'], throttle=throttle)
self.on(f'update:{self.VALUE_PROP}', handle_change, self.EVENT_ARGS, throttle=throttle)

def bind_value_to(self, target_object: Any, target_name: str = 'value', forward: Callable = lambda x: x):
bind_to(self, 'value', target_object, target_name, forward)
Expand Down

0 comments on commit 03fadf7

Please sign in to comment.