|
10 | 10 |
|
11 | 11 | from ..enums import ComponentType |
12 | 12 | from ..utils import find |
13 | | -from .core import ComponentUI |
| 13 | +from .core import ItemInterface |
14 | 14 | from .input_text import InputText |
15 | 15 | from .item import Item |
16 | 16 | from .label import Label |
|
36 | 36 | ModalItem = Union[Item[M]] |
37 | 37 |
|
38 | 38 |
|
39 | | -class BaseModal(ComponentUI): |
| 39 | +class BaseModal(ItemInterface): |
40 | 40 | """Represents a UI modal. |
41 | 41 |
|
42 | 42 | This object must be inherited to create a UI within Discord. |
@@ -130,9 +130,9 @@ def children(self) -> list[ModalItem]: |
130 | 130 | @children.setter |
131 | 131 | def children(self, value: list[ModalItem]): |
132 | 132 | for item in value: |
133 | | - if not isinstance(item, (InputText, Item)): |
| 133 | + if not isinstance(item, Item): |
134 | 134 | raise TypeError( |
135 | | - "all Modal children must be InputText or Item, not" |
| 135 | + "all BaseModal children must be Item, not" |
136 | 136 | f" {item.__class__.__name__}" |
137 | 137 | ) |
138 | 138 | self._children = value |
@@ -268,16 +268,20 @@ class Modal(BaseModal): |
268 | 268 |
|
269 | 269 | def __init__( |
270 | 270 | self, |
271 | | - *children: ModalItem, |
| 271 | + *children: InputText, |
272 | 272 | title: str, |
273 | 273 | custom_id: str | None = None, |
274 | 274 | timeout: float | None = None, |
275 | 275 | ) -> None: |
276 | 276 | super().__init__(*children, title=title, custom_id=custom_id, timeout=timeout) |
277 | 277 | self._weights = _ModalWeights(self._children) |
278 | 278 |
|
| 279 | + @property |
| 280 | + def children(self) -> list[InputText]: |
| 281 | + return self._children |
| 282 | + |
279 | 283 | @children.setter |
280 | | - def children(self, value: list[ModalItem]): |
| 284 | + def children(self, value: list[InputText]): |
281 | 285 | for item in value: |
282 | 286 | if not isinstance(item, InputText): |
283 | 287 | raise TypeError( |
@@ -323,12 +327,12 @@ def add_item(self, item: InputText) -> Self: |
323 | 327 | super().add_item(item) |
324 | 328 | return self |
325 | 329 |
|
326 | | - def remove_item(self, item: ModalItem) -> Self: |
327 | | - """Removes a component from the modal. |
| 330 | + def remove_item(self, item: InputText) -> Self: |
| 331 | + """Removes an InputText from the modal. |
328 | 332 |
|
329 | 333 | Parameters |
330 | 334 | ---------- |
331 | | - item: Union[class:`InputText`, :class:`Item`] |
| 335 | + item: Union[class:`InputText`] |
332 | 336 | The item to remove from the modal. |
333 | 337 | """ |
334 | 338 |
|
@@ -371,6 +375,10 @@ def __init__( |
371 | 375 | ) -> None: |
372 | 376 | super().__init__(*children, title=title, custom_id=custom_id, timeout=timeout) |
373 | 377 |
|
| 378 | + @property |
| 379 | + def children(self) -> list[ModalItem]: |
| 380 | + return self._children |
| 381 | + |
374 | 382 | @children.setter |
375 | 383 | def children(self, value: list[ModalItem]): |
376 | 384 | for item in value: |
|
0 commit comments