@pageboard/html 0.11.7 → 0.11.8
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/fieldsets.js +1 -1
- package/elements/image.js +1 -1
- package/elements/input-property.js +5 -1
- package/lib/nouislider.js +20 -6
- package/package.json +1 -1
- package/ui/fieldset-list.js +26 -0
- package/ui/fieldset.js +3 -2
- package/ui/form.js +9 -4
- package/ui/menu.css +6 -3
- package/ui/menu.js +1 -1
package/elements/fieldsets.js
CHANGED
|
@@ -32,7 +32,7 @@ exports.fieldset = {
|
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
34
|
contents: "fieldset_legend block+",
|
|
35
|
-
html: '<fieldset class="[plain|?]" data-name="[name]" data-value="[value]" is="element-fieldset"></fieldset>',
|
|
35
|
+
html: '<fieldset class="[plain|?]" data-name="[name|split:.|slice:1|join:.]" data-value="[value]" is="element-fieldset"></fieldset>',
|
|
36
36
|
scripts: ["../ui/fieldset.js"],
|
|
37
37
|
stylesheets: ['../ui/fieldset.css']
|
|
38
38
|
};
|
package/elements/image.js
CHANGED
|
@@ -132,7 +132,7 @@ exports.image = {
|
|
|
132
132
|
class="[display.fit|or:none] [display.horizontal|or:] [display.vertical|or:]"
|
|
133
133
|
alt="[alt]"
|
|
134
134
|
data-src="[url|or:[$element.resources.empty]]"
|
|
135
|
-
data-crop="[crop.x];[crop.y];[crop.width];[crop.height];[crop.zoom]"
|
|
135
|
+
data-crop="[crop.x|or:50];[crop.y|or:50];[crop.width|or:100];[crop.height|or:100];[crop.zoom|or:100]"
|
|
136
136
|
>
|
|
137
137
|
<div block-content="legend"></div>
|
|
138
138
|
</element-image>`,
|
|
@@ -80,13 +80,17 @@ exports.input_property = {
|
|
|
80
80
|
cases = null;
|
|
81
81
|
discKey = null;
|
|
82
82
|
} else {
|
|
83
|
+
if (prop.type == "array" && prop.items && !Array.isArray(prop.items)) {
|
|
84
|
+
prop = prop.items;
|
|
85
|
+
}
|
|
83
86
|
if (prop.select && prop.select.$data == `0/${propKey}`) {
|
|
84
87
|
cases = prop.selectCases;
|
|
85
88
|
} else if (prop.discriminator && prop.discriminator.propertyName == propKey) {
|
|
86
89
|
cases = prop.oneOf;
|
|
87
90
|
discKey = propKey;
|
|
88
91
|
}
|
|
89
|
-
|
|
92
|
+
if (prop.properties) prop = prop.properties;
|
|
93
|
+
prop = prop[propKey];
|
|
90
94
|
}
|
|
91
95
|
if (prop == null) break;
|
|
92
96
|
}
|
package/lib/nouislider.js
CHANGED
|
@@ -714,6 +714,7 @@
|
|
|
714
714
|
var hover = entry.indexOf("hover") >= 0;
|
|
715
715
|
var unconstrained = entry.indexOf("unconstrained") >= 0;
|
|
716
716
|
var dragAll = entry.indexOf("drag-all") >= 0;
|
|
717
|
+
var smoothSteps = entry.indexOf("smooth-steps") >= 0;
|
|
717
718
|
if (fixed) {
|
|
718
719
|
if (parsed.handles !== 2) {
|
|
719
720
|
throw new Error("noUiSlider: 'fixed' behaviour must be used with 2 handles");
|
|
@@ -728,6 +729,7 @@
|
|
|
728
729
|
tap: tap || snap,
|
|
729
730
|
drag: drag,
|
|
730
731
|
dragAll: dragAll,
|
|
732
|
+
smoothSteps: smoothSteps,
|
|
731
733
|
fixed: fixed,
|
|
732
734
|
snap: snap,
|
|
733
735
|
hover: hover,
|
|
@@ -1472,6 +1474,14 @@
|
|
|
1472
1474
|
scope_Body.removeEventListener("selectstart", preventDefault);
|
|
1473
1475
|
}
|
|
1474
1476
|
}
|
|
1477
|
+
if (options.events.smoothSteps) {
|
|
1478
|
+
data.handleNumbers.forEach(function (handleNumber) {
|
|
1479
|
+
setHandle(handleNumber, scope_Locations[handleNumber], true, true, false, false);
|
|
1480
|
+
});
|
|
1481
|
+
data.handleNumbers.forEach(function (handleNumber) {
|
|
1482
|
+
fireEvent("update", handleNumber);
|
|
1483
|
+
});
|
|
1484
|
+
}
|
|
1475
1485
|
data.handleNumbers.forEach(function (handleNumber) {
|
|
1476
1486
|
fireEvent("change", handleNumber);
|
|
1477
1487
|
fireEvent("set", handleNumber);
|
|
@@ -1771,7 +1781,7 @@
|
|
|
1771
1781
|
});
|
|
1772
1782
|
}
|
|
1773
1783
|
// Split out the handle positioning logic so the Move event can use it, too
|
|
1774
|
-
function checkHandlePosition(reference, handleNumber, to, lookBackward, lookForward, getValue) {
|
|
1784
|
+
function checkHandlePosition(reference, handleNumber, to, lookBackward, lookForward, getValue, smoothSteps) {
|
|
1775
1785
|
var distance;
|
|
1776
1786
|
// For sliders with multiple handles, limit movement to the other handle.
|
|
1777
1787
|
// Apply the margin option by adding it to the handle positions.
|
|
@@ -1810,7 +1820,9 @@
|
|
|
1810
1820
|
to = Math.min(to, distance);
|
|
1811
1821
|
}
|
|
1812
1822
|
}
|
|
1813
|
-
|
|
1823
|
+
if (!smoothSteps) {
|
|
1824
|
+
to = scope_Spectrum.getStep(to);
|
|
1825
|
+
}
|
|
1814
1826
|
// Limit percentage to the 0 - 100 range
|
|
1815
1827
|
to = limit(to);
|
|
1816
1828
|
// Return false if handle can't move
|
|
@@ -1830,6 +1842,7 @@
|
|
|
1830
1842
|
var proposals = locations.slice();
|
|
1831
1843
|
// Store first handle now, so we still have it in case handleNumbers is reversed
|
|
1832
1844
|
var firstHandle = handleNumbers[0];
|
|
1845
|
+
var smoothSteps = options.events.smoothSteps;
|
|
1833
1846
|
var b = [!upward, upward];
|
|
1834
1847
|
var f = [upward, !upward];
|
|
1835
1848
|
// Copy handleNumbers so we don't change the dataset
|
|
@@ -1842,7 +1855,7 @@
|
|
|
1842
1855
|
// Step 1: get the maximum percentage that any of the handles can move
|
|
1843
1856
|
if (handleNumbers.length > 1) {
|
|
1844
1857
|
handleNumbers.forEach(function (handleNumber, o) {
|
|
1845
|
-
var to = checkHandlePosition(proposals, handleNumber, proposals[handleNumber] + proposal, b[o], f[o], false);
|
|
1858
|
+
var to = checkHandlePosition(proposals, handleNumber, proposals[handleNumber] + proposal, b[o], f[o], false, smoothSteps);
|
|
1846
1859
|
// Stop if one of the handles can't move.
|
|
1847
1860
|
if (to === false) {
|
|
1848
1861
|
proposal = 0;
|
|
@@ -1860,7 +1873,8 @@
|
|
|
1860
1873
|
var state = false;
|
|
1861
1874
|
// Step 2: Try to set the handles with the found percentage
|
|
1862
1875
|
handleNumbers.forEach(function (handleNumber, o) {
|
|
1863
|
-
state =
|
|
1876
|
+
state =
|
|
1877
|
+
setHandle(handleNumber, locations[handleNumber] + proposal, b[o], f[o], false, smoothSteps) || state;
|
|
1864
1878
|
});
|
|
1865
1879
|
// Step 3: If a handle moved, fire events
|
|
1866
1880
|
if (state) {
|
|
@@ -1905,9 +1919,9 @@
|
|
|
1905
1919
|
}
|
|
1906
1920
|
// Test suggested values and apply margin, step.
|
|
1907
1921
|
// if exactInput is true, don't run checkHandlePosition, then the handle can be placed in between steps (#436)
|
|
1908
|
-
function setHandle(handleNumber, to, lookBackward, lookForward, exactInput) {
|
|
1922
|
+
function setHandle(handleNumber, to, lookBackward, lookForward, exactInput, smoothSteps) {
|
|
1909
1923
|
if (!exactInput) {
|
|
1910
|
-
to = checkHandlePosition(scope_Locations, handleNumber, to, lookBackward, lookForward, false);
|
|
1924
|
+
to = checkHandlePosition(scope_Locations, handleNumber, to, lookBackward, lookForward, false, smoothSteps);
|
|
1911
1925
|
}
|
|
1912
1926
|
if (to === false) {
|
|
1913
1927
|
return false;
|
package/package.json
CHANGED
package/ui/fieldset-list.js
CHANGED
|
@@ -29,15 +29,25 @@ class WalkIndex {
|
|
|
29
29
|
|
|
30
30
|
class HTMLElementFieldsetList extends VirtualHTMLElement {
|
|
31
31
|
#size;
|
|
32
|
+
#initialSize;
|
|
32
33
|
#prefix;
|
|
33
34
|
#model;
|
|
34
35
|
#walk;
|
|
35
36
|
|
|
36
37
|
fill(values, scope) {
|
|
37
38
|
const list = this.#listFromValues({ ...values });
|
|
39
|
+
if (this.#initialSize == null) this.#initialSize = list.length;
|
|
38
40
|
this.#resize(list.length, scope);
|
|
39
41
|
}
|
|
40
42
|
|
|
43
|
+
reset() {
|
|
44
|
+
this.#resize(this.#initialSize, {}); // missing scope
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
save() {
|
|
48
|
+
this.#initialSize = this.#size;
|
|
49
|
+
}
|
|
50
|
+
|
|
41
51
|
#prepare() {
|
|
42
52
|
this.ownTpl.prerender();
|
|
43
53
|
if (this.isContentEditable) return;
|
|
@@ -105,8 +115,24 @@ class HTMLElementFieldsetList extends VirtualHTMLElement {
|
|
|
105
115
|
for (const node of inputs) {
|
|
106
116
|
if (node.name.startsWith(prefix)) {
|
|
107
117
|
node.name = `${prefix}[$field.index].${node.name.substring(prefix.length)}`;
|
|
118
|
+
if (node.id?.startsWith('for-' + prefix)) {
|
|
119
|
+
node.id = `for-${prefix}[$field.index].${node.id.substring(4 + prefix.length)}`;
|
|
120
|
+
}
|
|
108
121
|
}
|
|
109
122
|
}
|
|
123
|
+
const conditionalFieldsets = tpl.querySelectorAll('[is="element-fieldset"]');
|
|
124
|
+
for (const node of conditionalFieldsets) {
|
|
125
|
+
if (node.dataset.name?.startsWith(prefix)) {
|
|
126
|
+
node.dataset.name = `${prefix}[$field.index].${node.dataset.name.substring(prefix.length)}`;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
const labels = tpl.querySelectorAll('label[for]');
|
|
130
|
+
for (const node of labels) {
|
|
131
|
+
if (node.htmlFor?.startsWith('for-' + prefix)) {
|
|
132
|
+
node.htmlFor = `for-${prefix}[$field.index].${node.htmlFor.substring(4 + prefix.length)}`;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
110
136
|
const subtpl = inputs.ancestor();
|
|
111
137
|
if (!subtpl) {
|
|
112
138
|
console.warn("fieldset-list should contain input[name]", this);
|
package/ui/fieldset.js
CHANGED
|
@@ -10,12 +10,13 @@ class HTMLCustomFieldSetElement extends HTMLFieldSetElement {
|
|
|
10
10
|
|
|
11
11
|
#update() {
|
|
12
12
|
if (this.isContentEditable || !this.options.name) return;
|
|
13
|
-
const
|
|
14
|
-
const val = this.form?.read(true)?.[name];
|
|
13
|
+
const val = this.form?.read(true)?.[this.options.name];
|
|
15
14
|
this.disabled = this.hidden = val != this.options.value;
|
|
16
15
|
}
|
|
17
16
|
|
|
18
17
|
patch(state) {
|
|
18
|
+
// before/after form#fill
|
|
19
|
+
this.#update();
|
|
19
20
|
state.finish(() => this.#update());
|
|
20
21
|
}
|
|
21
22
|
setup() {
|
package/ui/form.js
CHANGED
|
@@ -43,10 +43,6 @@ class HTMLCustomFormElement extends HTMLFormElement {
|
|
|
43
43
|
const fd = new FormData(this);
|
|
44
44
|
const query = {};
|
|
45
45
|
fd.forEach((val, key) => {
|
|
46
|
-
const cur = this.querySelectorAll(`[name="${key}"]`).slice(-1).pop();
|
|
47
|
-
if (cur.type == "file") {
|
|
48
|
-
val = cur.value;
|
|
49
|
-
}
|
|
50
46
|
if (val == "") val = null;
|
|
51
47
|
// build array-like values
|
|
52
48
|
const old = query[key];
|
|
@@ -79,6 +75,9 @@ class HTMLCustomFormElement extends HTMLFormElement {
|
|
|
79
75
|
if (defVal == "") defVal = null;
|
|
80
76
|
|
|
81
77
|
switch (type) {
|
|
78
|
+
case "file":
|
|
79
|
+
query[name] = val;
|
|
80
|
+
break;
|
|
82
81
|
case "radio":
|
|
83
82
|
if (!withDefaults && node.checked == node.defaultChecked) {
|
|
84
83
|
if (query[name] == val) {
|
|
@@ -172,11 +171,17 @@ class HTMLCustomFormElement extends HTMLFormElement {
|
|
|
172
171
|
return vars;
|
|
173
172
|
}
|
|
174
173
|
save() {
|
|
174
|
+
for (const node of this.querySelectorAll("element-fieldset-list")) {
|
|
175
|
+
node.save();
|
|
176
|
+
}
|
|
175
177
|
for (const node of this.elements) {
|
|
176
178
|
if (node.save) node.save();
|
|
177
179
|
}
|
|
178
180
|
}
|
|
179
181
|
reset() {
|
|
182
|
+
for (const node of this.querySelectorAll("element-fieldset-list")) {
|
|
183
|
+
node.reset();
|
|
184
|
+
}
|
|
180
185
|
for (const node of this.elements) {
|
|
181
186
|
if (node.reset) node.reset();
|
|
182
187
|
}
|
package/ui/menu.css
CHANGED
|
@@ -45,14 +45,17 @@
|
|
|
45
45
|
display: flex;
|
|
46
46
|
flex-direction: column;
|
|
47
47
|
}
|
|
48
|
+
.right.burger .popup.item > .placer {
|
|
49
|
+
left: auto;
|
|
50
|
+
right:0;
|
|
51
|
+
}
|
|
48
52
|
.right.popup.item > .placer > div {
|
|
49
53
|
left:auto;
|
|
50
54
|
right:0;
|
|
51
55
|
}
|
|
52
56
|
.fixed.popup.item > .placer > div {
|
|
53
|
-
|
|
54
|
-
max-
|
|
55
|
-
max-height: 100%;
|
|
57
|
+
max-width: 100vw;
|
|
58
|
+
max-height: 100vh;
|
|
56
59
|
}
|
|
57
60
|
.center.popup.item > .placer > div {
|
|
58
61
|
transform: translateX(-50%);
|
package/ui/menu.js
CHANGED
|
@@ -57,7 +57,7 @@ class HTMLElementMenu extends VirtualHTMLElement {
|
|
|
57
57
|
} else {
|
|
58
58
|
const padding = this.offsetTop + this.offsetHeight;
|
|
59
59
|
const menu = tosser.lastElementChild.lastElementChild;
|
|
60
|
-
menu.style.maxHeight = `calc(
|
|
60
|
+
menu.style.maxHeight = `calc(100vh - ${padding}px)`;
|
|
61
61
|
}
|
|
62
62
|
} else if (item) {
|
|
63
63
|
this.active = item != this.active ? item : null;
|