@ashley-shrok/viewmodel-shell 3.6.1 → 3.6.2
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/browser.js +19 -0
- package/package.json +1 -1
package/dist/browser.js
CHANGED
|
@@ -688,6 +688,25 @@ export class BrowserAdapter {
|
|
|
688
688
|
o.selected = isMulti ? selectedSet.has(opt.value) : opt.value === selectedSingle;
|
|
689
689
|
sel.appendChild(o);
|
|
690
690
|
});
|
|
691
|
+
// A <select> ALWAYS displays a selected option — HTML auto-selects the
|
|
692
|
+
// first when none is explicitly `selected`. VMS is state-driven: the
|
|
693
|
+
// submitted _state carries the value, NOT a DOM harvest, so the value the
|
|
694
|
+
// user SEES selected must be reflected in state. Without this seed a select
|
|
695
|
+
// whose bound path has no value (or that the user leaves at its displayed
|
|
696
|
+
// default) writes NOTHING to state — its key is ABSENT on dispatch even
|
|
697
|
+
// though an option is visibly chosen — so presence-checking server
|
|
698
|
+
// validators report it unset. Seed the effective displayed value whenever
|
|
699
|
+
// state doesn't already carry it. An app wanting a "please choose" state
|
|
700
|
+
// uses a placeholder option (value ""): the seeded value is then "" — an
|
|
701
|
+
// explicit empty the server can reject, never a silently-missing key.
|
|
702
|
+
if (isMulti) {
|
|
703
|
+
if (!Array.isArray(stateValue)) {
|
|
704
|
+
this.sa.write(n.bind, Array.from(sel.selectedOptions, o => o.value));
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
else if (stateValue === undefined || String(stateValue) !== sel.value) {
|
|
708
|
+
this.sa.write(n.bind, sel.value);
|
|
709
|
+
}
|
|
691
710
|
sel.addEventListener("change", () => {
|
|
692
711
|
if (isMulti) {
|
|
693
712
|
const arr = Array.from(sel.selectedOptions).map(o => o.value);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ashley-shrok/viewmodel-shell",
|
|
3
|
-
"version": "3.6.
|
|
3
|
+
"version": "3.6.2",
|
|
4
4
|
"description": "A server-driven UI framework where the wire format is structured enough that agents can build full-stack apps without ever opening a browser and all UI tests are pure unit tests with no browser runtime. Server returns a JSON tree of typed nodes; a thin TypeScript adapter renders it to DOM. Backend-agnostic \u2014 a .NET reference backend ships with the repo, but any language can produce the JSON contract.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|