4
4
from itertools import groupby
5
5
from typing import TYPE_CHECKING , Any , Dict , List , Optional , Tuple
6
6
7
- from .item import Item
7
+ from .input_text import InputText
8
8
from .view import _ViewWeights
9
9
10
- __all__ = ("Modal" ,)
10
+ __all__ = (
11
+ "Modal" ,
12
+ "ModalStore" ,
13
+ )
11
14
12
15
13
16
if TYPE_CHECKING :
@@ -24,7 +27,7 @@ class Modal:
24
27
def __init__ (self , title : str , custom_id : Optional [str ] = None ) -> None :
25
28
self .custom_id = custom_id or os .urandom (16 ).hex ()
26
29
self .title = title
27
- self .children : List [Item ] = []
30
+ self .children : List [InputText ] = []
28
31
self .__weights = _ViewWeights (self .children )
29
32
30
33
async def callback (self , interaction : Interaction ):
@@ -40,7 +43,7 @@ async def callback(self, interaction: Interaction):
40
43
pass
41
44
42
45
def to_components (self ) -> List [Dict [str , Any ]]:
43
- def key (item : Item ) -> int :
46
+ def key (item : InputText ) -> int :
44
47
return item ._rendered_row or 0
45
48
46
49
children = sorted (self .children , key = key )
@@ -59,30 +62,30 @@ def key(item: Item) -> int:
59
62
60
63
return components
61
64
62
- def add_item (self , item : Item ):
63
- """Adds an item to the modal dialog.
65
+ def add_item (self , item : InputText ):
66
+ """Adds an InputText component to the modal dialog.
64
67
65
68
Parameters
66
69
----------
67
- item: :class:`Item `
70
+ item: :class:`InputText `
68
71
The item to add to the modal dialog
69
72
"""
70
73
71
74
if len (self .children ) > 5 :
72
75
raise ValueError ("You can only have up to 5 items in a modal dialog." )
73
76
74
- if not isinstance (item , Item ):
75
- raise TypeError (f"expected Item not { item .__class__ !r} " )
77
+ if not isinstance (item , InputText ):
78
+ raise TypeError (f"expected InputText not { item .__class__ !r} " )
76
79
77
80
self .__weights .add_item (item )
78
81
self .children .append (item )
79
82
80
- def remove_item (self , item : Item ):
81
- """Removes an item from the modal dialog.
83
+ def remove_item (self , item : InputText ):
84
+ """Removes an InputText component from the modal dialog.
82
85
83
86
Parameters
84
87
----------
85
- item: :class:`Item `
88
+ item: :class:`InputText `
86
89
The item to remove from the modal dialog.
87
90
"""
88
91
try :
0 commit comments