Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added documentation and type-hinting to base element class. #356

Merged
merged 11 commits into from
Feb 13, 2023
Prev Previous commit
Next Next commit
Ran black on typedefs.py
  • Loading branch information
Steve Jackson committed Feb 10, 2023
commit 4245a065f91c0ea3eef22046497cac5fbd7d7ffd
121 changes: 91 additions & 30 deletions nicegui/typedefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,45 +7,106 @@

# note: This element of typed dict is necessary due to the use of the "class" keyword.
# note: Ideally the dict types get better refined moving forward to give more clarity to the caller.
ElementAsDict = TypedDict('ElementAsDict', {
'id': int,
'tag': str,
'class': List[str],
'style': Dict[str, str],
'props': Dict[str, Any],
'events': Dict[str, Dict],
'text': str,
'slots': Dict
})
ElementAsDict = TypedDict(
"ElementAsDict",
{
"id": int,
"tag": str,
"class": List[str],
"style": Dict[str, str],
"props": Dict[str, Any],
"events": Dict[str, Dict],
"text": str,
"slots": Dict,
},
)

WindowsEvents = Literal[
'afterprint', 'beforeprint', 'beforeunload', 'error', 'hashchange', 'load', 'message', 'offline', 'online',
'pagehide', 'pageshow', 'popstate', 'resize', 'storage', 'unload']
"afterprint",
"beforeprint",
"beforeunload",
"error",
"hashchange",
"load",
"message",
"offline",
"online",
"pagehide",
"pageshow",
"popstate",
"resize",
"storage",
"unload",
]
FormEvents = Literal[
'blur', 'change', 'contextmenu', 'focus', 'input', 'invalid', 'reset', 'search', 'select',
'submit']
KeyboardEvents = Literal[
'keydown', 'keypress', 'keyup'
"blur",
"change",
"contextmenu",
"focus",
"input",
"invalid",
"reset",
"search",
"select",
"submit",
]
KeyboardEvents = Literal["keydown", "keypress", "keyup"]
MouseEvents = Literal[
'click', 'dblclick', 'mousedown', 'mousemove', 'mouseout', 'mouseover', 'mouseup',
'mousewheel', 'wheel'
"click",
"dblclick",
"mousedown",
"mousemove",
"mouseout",
"mouseover",
"mouseup",
"mousewheel",
"wheel",
]
DragEvents = Literal[
'drag', 'dragend', 'dragenter', 'dragleave', 'dragover', 'dragstart', 'drop', 'scroll'
]
ClipboardEvents = Literal[
'copy', 'cut', 'paste'
"drag",
"dragend",
"dragenter",
"dragleave",
"dragover",
"dragstart",
"drop",
"scroll",
]
ClipboardEvents = Literal["copy", "cut", "paste"]
MediaEvents = Literal[
'abort', 'canplay', 'canplaythrough', 'cuechange', 'durationchange', 'emptied', 'ended', 'error',
'loadeddata', 'loadedmetadata', 'loadstart', 'pause', 'play', 'playing', 'progress', 'ratechange',
'seeked', 'seeking', 'stalled', 'suspend', 'timeupdate', 'volumechange', 'waiting'
"abort",
"canplay",
"canplaythrough",
"cuechange",
"durationchange",
"emptied",
"ended",
"error",
"loadeddata",
"loadedmetadata",
"loadstart",
"pause",
"play",
"playing",
"progress",
"ratechange",
"seeked",
"seeking",
"stalled",
"suspend",
"timeupdate",
"volumechange",
"waiting",
]
MiscEvents = Literal['toggle']
MiscEvents = Literal["toggle"]

AnyHTMLEvent = Union[
WindowsEvents, FormEvents, KeyboardEvents, MouseEvents, DragEvents, ClipboardEvents, MediaEvents, MiscEvents]



WindowsEvents,
FormEvents,
KeyboardEvents,
MouseEvents,
DragEvents,
ClipboardEvents,
MediaEvents,
MiscEvents,
]