|
@@ -67,25 +67,29 @@ class Notification(Element, component='notification.js'):
|
|
|
with context.client.layout:
|
|
|
super().__init__()
|
|
|
if options:
|
|
|
- self._props['options'] = options
|
|
|
+ self._props.update(options)
|
|
|
else:
|
|
|
- self._props['options'] = {
|
|
|
- 'message': str(message),
|
|
|
- 'position': position,
|
|
|
- 'multiLine': multi_line,
|
|
|
- 'spinner': spinner,
|
|
|
- 'closeBtn': close_button,
|
|
|
- 'timeout': (timeout or 0) * 1000,
|
|
|
- 'group': False,
|
|
|
- 'attrs': {'data-id': f'nicegui-dialog-{self.id}'},
|
|
|
- }
|
|
|
+ if message != '':
|
|
|
+ self._props['message'] = str(message)
|
|
|
+ if position != 'bottom':
|
|
|
+ self._props['position'] = position
|
|
|
+ if multi_line:
|
|
|
+ self._props['multiLine'] = multi_line
|
|
|
+ if spinner:
|
|
|
+ self._props['spinner'] = spinner
|
|
|
+ if close_button:
|
|
|
+ self._props['closeBtn'] = close_button
|
|
|
+ if timeout != 5.0:
|
|
|
+ self._props['timeout'] = (timeout or 0) * 1000
|
|
|
+ self._props['group'] = False
|
|
|
+ self._props['attrs'] = {'data-id': f'nicegui-dialog-{self.id}'}
|
|
|
if type is not None:
|
|
|
- self._props['options']['type'] = type
|
|
|
+ self._props['type'] = type
|
|
|
if color is not None:
|
|
|
- self._props['options']['color'] = color
|
|
|
+ self._props['color'] = color
|
|
|
if icon is not None:
|
|
|
- self._props['options']['icon'] = icon
|
|
|
- self._props['options'].update(kwargs)
|
|
|
+ self._props['icon'] = icon
|
|
|
+ self._props['kwargs'] = kwargs
|
|
|
|
|
|
if on_dismiss:
|
|
|
self.on_dismiss(on_dismiss)
|
|
@@ -102,90 +106,90 @@ class Notification(Element, component='notification.js'):
|
|
|
@property
|
|
|
def message(self) -> str:
|
|
|
"""Message text."""
|
|
|
- return self._props['options']['message']
|
|
|
+ return self._props['message']
|
|
|
|
|
|
@message.setter
|
|
|
def message(self, value: Any) -> None:
|
|
|
- self._props['options']['message'] = str(value)
|
|
|
+ self._props['message'] = str(value)
|
|
|
self.update()
|
|
|
|
|
|
@property
|
|
|
def position(self) -> NotificationPosition:
|
|
|
"""Position on the screen."""
|
|
|
- return self._props['options']['position']
|
|
|
+ return self._props['position']
|
|
|
|
|
|
@position.setter
|
|
|
def position(self, value: NotificationPosition) -> None:
|
|
|
- self._props['options']['position'] = value
|
|
|
+ self._props['position'] = value
|
|
|
self.update()
|
|
|
|
|
|
@property
|
|
|
def type(self) -> NotificationType:
|
|
|
"""Type of the notification."""
|
|
|
- return self._props['options'].get('type')
|
|
|
+ return self._props.get('type')
|
|
|
|
|
|
@type.setter
|
|
|
def type(self, value: NotificationType) -> None:
|
|
|
if value is None:
|
|
|
- self._props['options'].pop('type', None)
|
|
|
+ self._props.pop('type', None)
|
|
|
else:
|
|
|
- self._props['options']['type'] = value
|
|
|
+ self._props['type'] = value
|
|
|
self.update()
|
|
|
|
|
|
@property
|
|
|
def color(self) -> Optional[str]:
|
|
|
"""Color of the notification."""
|
|
|
- return self._props['options'].get('color')
|
|
|
+ return self._props.get('color')
|
|
|
|
|
|
@color.setter
|
|
|
def color(self, value: Optional[str]) -> None:
|
|
|
if value is None:
|
|
|
- self._props['options'].pop('color', None)
|
|
|
+ self._props.pop('color', None)
|
|
|
else:
|
|
|
- self._props['options']['color'] = value
|
|
|
+ self._props['color'] = value
|
|
|
self.update()
|
|
|
|
|
|
@property
|
|
|
def multi_line(self) -> bool:
|
|
|
"""Whether the notification is multi-line."""
|
|
|
- return self._props['options']['multiLine']
|
|
|
+ return self._props['multiLine']
|
|
|
|
|
|
@multi_line.setter
|
|
|
def multi_line(self, value: bool) -> None:
|
|
|
- self._props['options']['multiLine'] = value
|
|
|
+ self._props['multiLine'] = value
|
|
|
self.update()
|
|
|
|
|
|
@property
|
|
|
def icon(self) -> Optional[str]:
|
|
|
"""Icon of the notification."""
|
|
|
- return self._props['options'].get('icon')
|
|
|
+ return self._props.get('icon')
|
|
|
|
|
|
@icon.setter
|
|
|
def icon(self, value: Optional[str]) -> None:
|
|
|
if value is None:
|
|
|
- self._props['options'].pop('icon', None)
|
|
|
+ self._props.pop('icon', None)
|
|
|
else:
|
|
|
- self._props['options']['icon'] = value
|
|
|
+ self._props['icon'] = value
|
|
|
self.update()
|
|
|
|
|
|
@property
|
|
|
def spinner(self) -> bool:
|
|
|
"""Whether the notification is a spinner."""
|
|
|
- return self._props['options']['spinner']
|
|
|
+ return self._props['spinner']
|
|
|
|
|
|
@spinner.setter
|
|
|
def spinner(self, value: bool) -> None:
|
|
|
- self._props['options']['spinner'] = value
|
|
|
+ self._props['spinner'] = value
|
|
|
self.update()
|
|
|
|
|
|
@property
|
|
|
def close_button(self) -> Union[bool, str]:
|
|
|
"""Whether the notification has a close button."""
|
|
|
- return self._props['options']['closeBtn']
|
|
|
+ return self._props['closeBtn']
|
|
|
|
|
|
@close_button.setter
|
|
|
def close_button(self, value: Union[bool, str]) -> None:
|
|
|
- self._props['options']['closeBtn'] = value
|
|
|
+ self._props['closeBtn'] = value
|
|
|
self.update()
|
|
|
|
|
|
def on_dismiss(self, callback: Handler[UiEventArguments]) -> Self:
|