@targoninc/jess-components 0.0.26 → 0.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +9 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -915,11 +915,18 @@ function select(config) {
|
|
|
915
915
|
const selectId = v4_default();
|
|
916
916
|
function setSelected(value) {
|
|
917
917
|
const opts = document.querySelectorAll(`select[id="${selectId}"] option`);
|
|
918
|
-
opts.forEach((opt) =>
|
|
918
|
+
opts.forEach((opt) => {
|
|
919
|
+
opt.selected = opt.value === value;
|
|
920
|
+
});
|
|
919
921
|
}
|
|
920
922
|
value$.subscribe(setSelected);
|
|
921
923
|
setSelected(value$.value);
|
|
922
|
-
return create("div").applyGenericConfig(config).classes("jessc-select", "flex-v", "relative").children(when(config.label, create("label").classes("jess").text(config.label).build()), signalMap(options, create("select").classes("jessc-select-inner").id(selectId).onchange((e) =>
|
|
924
|
+
return create("div").applyGenericConfig(config).classes("jessc-select", "flex-v", "relative").children(when(config.label, create("label").classes("jess").text(config.label).build()), signalMap(options, create("select").classes("jessc-select-inner").id(selectId).onchange((e) => {
|
|
925
|
+
value$.value = e.target.value;
|
|
926
|
+
config.onchange && config.onchange(e.target.value);
|
|
927
|
+
}), (option) => {
|
|
928
|
+
return create("option").value(option.id).text(option.name).selected(compute((v) => v === option.id, value$)).build();
|
|
929
|
+
})).build();
|
|
923
930
|
}
|
|
924
931
|
function searchableSelect(config) {
|
|
925
932
|
const options = config.options ?? signal([]);
|