@pageboard/html 0.10.9 → 0.10.10
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/form-input-property.js +2 -0
- package/elements/form-inputs.js +4 -4
- package/package.json +1 -1
- package/ui/select.js +20 -8
|
@@ -64,6 +64,7 @@ exports.input_property = {
|
|
|
64
64
|
required = prop.required && prop.required.indexOf(propKey) >= 0;
|
|
65
65
|
if (cases) {
|
|
66
66
|
prop = cases[propKey];
|
|
67
|
+
name = list.slice(0, i - 1).concat(list.slice(i + 1)).join('.');
|
|
67
68
|
cases = null;
|
|
68
69
|
} else {
|
|
69
70
|
if (prop.select && prop.select.$data == `0/${propKey}`) {
|
|
@@ -133,6 +134,7 @@ exports.input_property = {
|
|
|
133
134
|
for (const item of listOf) {
|
|
134
135
|
content.appendChild(view.render({
|
|
135
136
|
type: multiple ? 'input_checkbox' : 'input_radio',
|
|
137
|
+
id,
|
|
136
138
|
data: {
|
|
137
139
|
name: name,
|
|
138
140
|
value: item.type == "null" ? null : item.const,
|
package/elements/form-inputs.js
CHANGED
|
@@ -359,8 +359,8 @@ exports.input_checkbox = {
|
|
|
359
359
|
<div class="ui [toggle|?] checkbox">
|
|
360
360
|
<input type="checkbox" required="[required]" disabled="[disabled]"
|
|
361
361
|
name="[name]" value="[value]" checked="[checked]"
|
|
362
|
-
id="for-[name][value|or:|pre:-]" />
|
|
363
|
-
<label block-content="label" for="for-[name][value|or:|pre:-]">Label</label>
|
|
362
|
+
id="for-[name][value|or:|pre:-]-[$id|slice:0:6]" />
|
|
363
|
+
<label block-content="label" for="for-[name][value|or:|pre:-]-[$id|slice:0:6]">Label</label>
|
|
364
364
|
</div>
|
|
365
365
|
</div>`,
|
|
366
366
|
stylesheets: [
|
|
@@ -405,8 +405,8 @@ exports.input_radio = {
|
|
|
405
405
|
<div class="ui radio checkbox">
|
|
406
406
|
<input type="radio" disabled="[disabled]"
|
|
407
407
|
name="[name]" value="[value|or:]" checked="[checked]"
|
|
408
|
-
id="for-[name][value|or:|pre:-]" />
|
|
409
|
-
<label block-content="label" for="for-[name][value|or:|pre:-]">Label</label>
|
|
408
|
+
id="for-[name][value|or:|pre:-]-[$id|slice:0:6]" />
|
|
409
|
+
<label block-content="label" for="for-[name][value|or:|pre:-]-[$id|slice:0:6]">Label</label>
|
|
410
410
|
</div>
|
|
411
411
|
</div>`,
|
|
412
412
|
stylesheets: [
|
package/package.json
CHANGED
package/ui/select.js
CHANGED
|
@@ -100,11 +100,15 @@ class HTMLElementSelect extends VirtualHTMLElement {
|
|
|
100
100
|
}
|
|
101
101
|
#setPlaceholder(str) {
|
|
102
102
|
const text = this.#text;
|
|
103
|
-
|
|
104
|
-
text.classList.add('default');
|
|
103
|
+
if (!str) str = this.options.placeholder;
|
|
105
104
|
|
|
106
105
|
const defaultOption = this.#select.querySelector('option[value=""]');
|
|
107
|
-
if (defaultOption)
|
|
106
|
+
if (defaultOption) {
|
|
107
|
+
if (!str) str = defaultOption.innerHTML;
|
|
108
|
+
else defaultOption.innerHTML = str;
|
|
109
|
+
}
|
|
110
|
+
text.textContent = str;
|
|
111
|
+
text.classList.add('default');
|
|
108
112
|
}
|
|
109
113
|
|
|
110
114
|
#menuOption(val) {
|
|
@@ -124,11 +128,13 @@ class HTMLElementSelect extends VirtualHTMLElement {
|
|
|
124
128
|
const select = this.#select;
|
|
125
129
|
if (!select) return;
|
|
126
130
|
const menu = this.#menu;
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
131
|
+
menu.children.forEach(item => {
|
|
132
|
+
const val = item.dataset.value || item.innerText != "-" && item.innerText.trim() || "";
|
|
133
|
+
select.insertAdjacentHTML(
|
|
134
|
+
'beforeEnd',
|
|
135
|
+
`<option value="${val}">${item.innerHTML}</option>`
|
|
136
|
+
);
|
|
137
|
+
});
|
|
132
138
|
}
|
|
133
139
|
setup(state) {
|
|
134
140
|
this.#observer = new MutationObserver((mutations) => this.#fillSelect());
|
|
@@ -154,6 +160,12 @@ class HTMLElementSelect extends VirtualHTMLElement {
|
|
|
154
160
|
for (const node of this.querySelectorAll('.ui.label')) node.remove();
|
|
155
161
|
}
|
|
156
162
|
select.name = this.options.name;
|
|
163
|
+
if (!select.required) {
|
|
164
|
+
const menu = this.#menu;
|
|
165
|
+
if (!menu.querySelector('element-select-option[data-value=""]')) {
|
|
166
|
+
menu.insertAdjacentHTML('afterBegin', `<element-select-option data-value="" block-type="input_select_option" class="item">-</element-select-option>`);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
157
169
|
this.#fillSelect();
|
|
158
170
|
}
|
|
159
171
|
|