diff --git a/Project.toml b/Project.toml index 47fb1f11..5c16c08e 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "PlutoUI" uuid = "7f904dfe-b85e-4ff6-b463-dae2292396a8" authors = ["Fons van der Plas "] -version = "0.7.18" +version = "0.7.19" [deps] AbstractPlutoDingetjes = "6e696c72-6542-2067-7265-42206c756150" diff --git a/src/Builtins.jl b/src/Builtins.jl index 333db584..a925d81e 100644 --- a/src/Builtins.jl +++ b/src/Builtins.jl @@ -180,7 +180,7 @@ begin Base.get(slider::Slider) = slider.default Bonds.initial_value(slider::Slider) = slider.default - Bonds.possible_values(slider::Slider) = slider.range + Bonds.possible_values(slider::Slider) = 1:length(slider.values) function Bonds.transform_value(slider::Slider, val_from_js) slider.values[val_from_js] @@ -580,14 +580,16 @@ begin Base.get(select::Select) = select.default Bonds.initial_value(select::Select) = select.default - Bonds.possible_values(select::Select) = (o.first for o in select.options) + Bonds.possible_values(select::Select) = (string(i) for i in 1:length(select.options)) function Bonds.transform_value(select::Select, val_from_js) + # val_from_js will be a String, but let's allow Integers as well, there's no harm in that val_num = val_from_js isa Integer ? val_from_js : tryparse(Int64, val_from_js) select.options[val_num].first end function Bonds.validate_value(select::Select, val_from_js) + # val_from_js will be a String, but let's allow Integers as well, there's no harm in that val_num = val_from_js isa Integer ? val_from_js : tryparse(Int64, val_from_js) val_num isa Integer && 1 <= val_num <= length(select.options) end