|
@@ -62,16 +62,19 @@ class Notification(Element, component='notification.js'):
|
|
self._props['options'] = {
|
|
self._props['options'] = {
|
|
'message': str(message),
|
|
'message': str(message),
|
|
'position': position,
|
|
'position': position,
|
|
- 'type': type,
|
|
|
|
- 'color': color,
|
|
|
|
'multiLine': multi_line,
|
|
'multiLine': multi_line,
|
|
- 'icon': icon,
|
|
|
|
'spinner': spinner,
|
|
'spinner': spinner,
|
|
'closeBtn': close_button,
|
|
'closeBtn': close_button,
|
|
'timeout': (timeout or 0) * 1000,
|
|
'timeout': (timeout or 0) * 1000,
|
|
'group': False,
|
|
'group': False,
|
|
'attrs': {'data-id': f'nicegui-dialog-{self.id}'},
|
|
'attrs': {'data-id': f'nicegui-dialog-{self.id}'},
|
|
}
|
|
}
|
|
|
|
+ if type is not None:
|
|
|
|
+ self._props['options']['type'] = type
|
|
|
|
+ if color is not None:
|
|
|
|
+ self._props['options']['color'] = color
|
|
|
|
+ if icon is not None:
|
|
|
|
+ self._props['options']['icon'] = icon
|
|
self._props['options'].update(kwargs)
|
|
self._props['options'].update(kwargs)
|
|
with self:
|
|
with self:
|
|
def delete():
|
|
def delete():
|
|
@@ -108,21 +111,27 @@ class Notification(Element, component='notification.js'):
|
|
@property
|
|
@property
|
|
def type(self) -> NotificationType:
|
|
def type(self) -> NotificationType:
|
|
"""Type of the notification."""
|
|
"""Type of the notification."""
|
|
- return self._props['options']['type']
|
|
|
|
|
|
+ return self._props['options'].get('type')
|
|
|
|
|
|
@type.setter
|
|
@type.setter
|
|
def type(self, value: NotificationType) -> None:
|
|
def type(self, value: NotificationType) -> None:
|
|
- self._props['options']['type'] = value
|
|
|
|
|
|
+ if value is None:
|
|
|
|
+ self._props['options'].pop('type', None)
|
|
|
|
+ else:
|
|
|
|
+ self._props['options']['type'] = value
|
|
self.update()
|
|
self.update()
|
|
|
|
|
|
@property
|
|
@property
|
|
def color(self) -> Optional[str]:
|
|
def color(self) -> Optional[str]:
|
|
"""Color of the notification."""
|
|
"""Color of the notification."""
|
|
- return self._props['options']['color']
|
|
|
|
|
|
+ return self._props['options'].get('color')
|
|
|
|
|
|
@color.setter
|
|
@color.setter
|
|
def color(self, value: Optional[str]) -> None:
|
|
def color(self, value: Optional[str]) -> None:
|
|
- self._props['options']['color'] = value
|
|
|
|
|
|
+ if value is None:
|
|
|
|
+ self._props['options'].pop('color', None)
|
|
|
|
+ else:
|
|
|
|
+ self._props['options']['color'] = value
|
|
self.update()
|
|
self.update()
|
|
|
|
|
|
@property
|
|
@property
|
|
@@ -138,11 +147,14 @@ class Notification(Element, component='notification.js'):
|
|
@property
|
|
@property
|
|
def icon(self) -> Optional[str]:
|
|
def icon(self) -> Optional[str]:
|
|
"""Icon of the notification."""
|
|
"""Icon of the notification."""
|
|
- return self._props['options']['icon']
|
|
|
|
|
|
+ return self._props['options'].get('icon')
|
|
|
|
|
|
@icon.setter
|
|
@icon.setter
|
|
def icon(self, value: Optional[str]) -> None:
|
|
def icon(self, value: Optional[str]) -> None:
|
|
- self._props['options']['icon'] = value
|
|
|
|
|
|
+ if value is None:
|
|
|
|
+ self._props['options'].pop('icon', None)
|
|
|
|
+ else:
|
|
|
|
+ self._props['options']['icon'] = value
|
|
self.update()
|
|
self.update()
|
|
|
|
|
|
@property
|
|
@property
|