@pageboard/html 0.14.5 → 0.14.6
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/package.json +1 -1
- package/ui/fieldset-list.js +3 -0
- package/ui/form.js +9 -4
package/package.json
CHANGED
package/ui/fieldset-list.js
CHANGED
|
@@ -37,8 +37,10 @@ class HTMLElementFieldsetList extends Page.Element {
|
|
|
37
37
|
fill(values, scope) {
|
|
38
38
|
if (scope.$write || this.prefix == null) return;
|
|
39
39
|
// unflatten array-values
|
|
40
|
+
const vars = [];
|
|
40
41
|
for (const [key, val] of Object.entries(values)) {
|
|
41
42
|
if (!this.#prefixed(key)) continue;
|
|
43
|
+
vars.push(key);
|
|
42
44
|
if (Array.isArray(val)) {
|
|
43
45
|
for (let i = 0; i < val.length; i++) {
|
|
44
46
|
values[key + '.' + i] = val[i];
|
|
@@ -49,6 +51,7 @@ class HTMLElementFieldsetList extends Page.Element {
|
|
|
49
51
|
const list = this.#listFromValues({ ...values });
|
|
50
52
|
if (this.#initialSize == null) this.#initialSize = list.length;
|
|
51
53
|
this.#resize(list.length, scope);
|
|
54
|
+
return vars;
|
|
52
55
|
}
|
|
53
56
|
|
|
54
57
|
reset() {
|
package/ui/form.js
CHANGED
|
@@ -31,6 +31,7 @@ class HTMLElementForm extends Page.create(HTMLFormElement) {
|
|
|
31
31
|
if (action == "toggle") {
|
|
32
32
|
action = val ? "enable" : "disable";
|
|
33
33
|
}
|
|
34
|
+
const isQuery = ctx.expr.path[0] == "$query" && ctx.expr.path.length == 1;
|
|
34
35
|
|
|
35
36
|
state.finish(() => {
|
|
36
37
|
if (action == "enable") {
|
|
@@ -41,7 +42,10 @@ class HTMLElementForm extends Page.create(HTMLFormElement) {
|
|
|
41
42
|
if (val == null) {
|
|
42
43
|
form.reset?.();
|
|
43
44
|
} else if (typeof val == "object") {
|
|
44
|
-
form.fill?.(this.linearizeValues(val), state.scope);
|
|
45
|
+
const vars = form.fill?.(this.linearizeValues(val), state.scope) ?? [];
|
|
46
|
+
if (isQuery) {
|
|
47
|
+
for (const name of vars) state.vars[name] = true;
|
|
48
|
+
}
|
|
45
49
|
form.save?.();
|
|
46
50
|
}
|
|
47
51
|
}
|
|
@@ -222,14 +226,15 @@ class HTMLElementForm extends Page.create(HTMLFormElement) {
|
|
|
222
226
|
}
|
|
223
227
|
fill(query, scope) {
|
|
224
228
|
// fieldset-list are not custom inputs yet
|
|
229
|
+
const vars = [];
|
|
225
230
|
for (const node of this.querySelectorAll("element-fieldset-list")) {
|
|
226
|
-
node.fill
|
|
231
|
+
if (node.fill) vars.push(...node.fill(query, scope));
|
|
227
232
|
}
|
|
228
|
-
|
|
233
|
+
|
|
229
234
|
for (const elem of this.elements) {
|
|
230
235
|
const name = elem.name;
|
|
231
236
|
if (!name) continue;
|
|
232
|
-
if (name in query
|
|
237
|
+
if (name in query) vars.push(name);
|
|
233
238
|
const val = query[name];
|
|
234
239
|
if (val === undefined) {
|
|
235
240
|
elem.reset?.();
|