override dict in propsbase to use camelCase (#3910)
* override dict in propsbase to use camelCase * fix underscore in dict * dang it darglint
This commit is contained in:
parent
5dcf554bd4
commit
8657976a6e
@ -23,3 +23,20 @@ class PropsBase(Base):
|
||||
return LiteralObjectVar.create(
|
||||
{format.to_camel_case(key): value for key, value in self.dict().items()}
|
||||
).json()
|
||||
|
||||
def dict(self, *args, **kwargs):
|
||||
"""Convert the object to a dictionary.
|
||||
|
||||
Keys will be converted to camelCase.
|
||||
|
||||
Args:
|
||||
*args: Arguments to pass to the parent class.
|
||||
**kwargs: Keyword arguments to pass to the parent class.
|
||||
|
||||
Returns:
|
||||
The object as a dictionary.
|
||||
"""
|
||||
return {
|
||||
format.to_camel_case(key): value
|
||||
for key, value in super().dict(*args, **kwargs).items()
|
||||
}
|
||||
|
@ -171,12 +171,12 @@ class ToastProps(PropsBase):
|
||||
d["cancel"] = self.cancel
|
||||
if isinstance(self.cancel, dict):
|
||||
d["cancel"] = ToastAction(**self.cancel)
|
||||
if "on_dismiss" in d:
|
||||
d["on_dismiss"] = format.format_queue_events(
|
||||
if "onDismiss" in d:
|
||||
d["onDismiss"] = format.format_queue_events(
|
||||
self.on_dismiss, _toast_callback_signature
|
||||
)
|
||||
if "on_auto_close" in d:
|
||||
d["on_auto_close"] = format.format_queue_events(
|
||||
if "onAutoClose" in d:
|
||||
d["onAutoClose"] = format.format_queue_events(
|
||||
self.on_auto_close, _toast_callback_signature
|
||||
)
|
||||
return d
|
||||
|
Loading…
Reference in New Issue
Block a user