@pageboard/html 0.14.5 → 0.14.7
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/elements/layout.js +4 -4
- package/package.json +1 -1
- package/ui/fieldset-list.js +3 -0
- package/ui/form.js +10 -5
package/elements/layout.js
CHANGED
|
@@ -119,7 +119,7 @@ exports.layout = {
|
|
|
119
119
|
title: 'Inline (em)',
|
|
120
120
|
type: 'number',
|
|
121
121
|
default: 0,
|
|
122
|
-
multipleOf: 0.
|
|
122
|
+
multipleOf: 0.01,
|
|
123
123
|
nullable: true
|
|
124
124
|
},
|
|
125
125
|
inlineUnits: {
|
|
@@ -129,7 +129,7 @@ exports.layout = {
|
|
|
129
129
|
title: 'Block (rem)',
|
|
130
130
|
type: 'number',
|
|
131
131
|
default: 0,
|
|
132
|
-
multipleOf: 0.
|
|
132
|
+
multipleOf: 0.01,
|
|
133
133
|
nullable: true
|
|
134
134
|
},
|
|
135
135
|
blockUnits: {
|
|
@@ -147,7 +147,7 @@ exports.layout = {
|
|
|
147
147
|
type: 'number',
|
|
148
148
|
default: 0,
|
|
149
149
|
minimum: 0,
|
|
150
|
-
multipleOf: 0.
|
|
150
|
+
multipleOf: 0.01,
|
|
151
151
|
nullable: true
|
|
152
152
|
},
|
|
153
153
|
inlineUnits: {
|
|
@@ -158,7 +158,7 @@ exports.layout = {
|
|
|
158
158
|
type: 'number',
|
|
159
159
|
default: 0,
|
|
160
160
|
minimum: 0,
|
|
161
|
-
multipleOf: 0.
|
|
161
|
+
multipleOf: 0.01,
|
|
162
162
|
nullable: true
|
|
163
163
|
},
|
|
164
164
|
blockUnits: {
|
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?.();
|
|
@@ -354,7 +359,7 @@ class HTMLElementForm extends Page.create(HTMLFormElement) {
|
|
|
354
359
|
form.classList.add('loading');
|
|
355
360
|
scope.$response = await state.fetch(form.method, Page.format({
|
|
356
361
|
pathname: form.getAttribute('action'),
|
|
357
|
-
query:
|
|
362
|
+
query: form.dataset // because patch populates data from parameters
|
|
358
363
|
}), scope.$request);
|
|
359
364
|
} catch (err) {
|
|
360
365
|
scope.$response = err;
|