1
0
Эх сурвалжийг харах

override dict in propsbase to use camelCase (#3910)

* override dict in propsbase to use camelCase

* fix underscore in dict

* dang it darglint
Khaleel Al-Adhami 8 сар өмнө
parent
commit
8657976a6e

+ 17 - 0
reflex/components/props.py

@@ -23,3 +23,20 @@ class PropsBase(Base):
         return LiteralObjectVar.create(
         return LiteralObjectVar.create(
             {format.to_camel_case(key): value for key, value in self.dict().items()}
             {format.to_camel_case(key): value for key, value in self.dict().items()}
         ).json()
         ).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()
+        }

+ 4 - 4
reflex/components/sonner/toast.py

@@ -171,12 +171,12 @@ class ToastProps(PropsBase):
             d["cancel"] = self.cancel
             d["cancel"] = self.cancel
             if isinstance(self.cancel, dict):
             if isinstance(self.cancel, dict):
                 d["cancel"] = ToastAction(**self.cancel)
                 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
                 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
                 self.on_auto_close, _toast_callback_signature
             )
             )
         return d
         return d