Browse Source

multi_select somewhat usable (#1861)

Masen Furer 1 năm trước cách đây
mục cha
commit
fe244b7eec

+ 1 - 1
reflex/components/__init__.py

@@ -113,7 +113,7 @@ input_left_addon = InputLeftAddon.create
 input_right_addon = InputRightAddon.create
 input_left_element = InputLeftElement.create
 input_right_element = InputRightElement.create
-multi_select = MultiSelect
+multi_select = MultiSelect.create
 multi_select_option = MultiSelectOption
 number_decrement_stepper = NumberDecrementStepper.create
 number_increment_stepper = NumberIncrementStepper.create

+ 12 - 8
reflex/components/forms/multiselect.py

@@ -46,8 +46,9 @@ class Select(Component):
     Props added by chakra-react-select are marked with "[chakra]".
     """
 
-    library = "chakra-react-select"
+    library = "chakra-react-select@4.7.5"
     tag = "Select"
+    alias = "MultiSelect"
 
     # Focus the control when it is mounted
     auto_focus: Var[bool]
@@ -311,7 +312,7 @@ class Select(Component):
                 lambda e0: [
                     Var.create_safe(f"{e0}.map(e => e.value)", _var_is_local=True)
                 ]
-                if self.is_multi
+                if self.is_multi.equals(Var.create_safe(True))
                 else lambda e0: [e0]
             ),
         }
@@ -341,10 +342,13 @@ class Select(Component):
             The `create` method is returning an instance of the `Select` class.
         """
         converted_options: List[Option] = []
-        for option in options:
-            if not isinstance(option, Option):
-                converted_options.append(Option(label=str(option), value=option))
-            else:
-                converted_options.append(option)
-        props["options"] = [o.dict() for o in converted_options]
+        if not isinstance(options, Var):
+            for option in options:
+                if not isinstance(option, Option):
+                    converted_options.append(Option(label=str(option), value=option))
+                else:
+                    converted_options.append(option)
+            props["options"] = [o.dict() for o in converted_options]
+        else:
+            props["options"] = options
         return super().create(*[], **props)

+ 0 - 1
reflex/constants/installer.py

@@ -103,7 +103,6 @@ class PackageJson(SimpleNamespace):
 
     DEPENDENCIES = {
         "axios": "1.4.0",
-        "chakra-react-select": "4.6.0",
         "focus-visible": "5.2.0",
         "framer-motion": "10.16.4",
         "json5": "2.2.3",