multi_select somewhat usable (#1861)

This commit is contained in:
Masen Furer 2023-10-20 09:43:46 -07:00 committed by GitHub
parent c653f95435
commit fe244b7eec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 10 deletions

View File

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

View File

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

View File

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