@skirbi/sugar 0.0.18 → 0.0.19
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/Changes +4 -0
- package/lib/htmlelement-select.mjs +8 -6
- package/lib/index.mjs +1 -1
- package/lib/with-connected-sugar.mjs +4 -0
- package/package.json +2 -1
package/Changes
CHANGED
|
@@ -112,9 +112,6 @@ export class HTMLElementSugarSelect extends HTMLElementSugarInput {
|
|
|
112
112
|
searchEl?.remove();
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
// Placeholder option (optional).
|
|
116
|
-
if (cfg.placeholder) this._addPlaceholder(select, cfg.placeholder);
|
|
117
|
-
|
|
118
115
|
if (hasStatic) {
|
|
119
116
|
this._setOptionsFromOptions(select, rawOptions, cfg);
|
|
120
117
|
if (searchEl) this._setupLocalSearch(select, searchEl);
|
|
@@ -133,7 +130,9 @@ export class HTMLElementSugarSelect extends HTMLElementSugarInput {
|
|
|
133
130
|
opt.value = '';
|
|
134
131
|
opt.textContent = text;
|
|
135
132
|
opt.disabled = true;
|
|
136
|
-
|
|
133
|
+
|
|
134
|
+
if (!select.value) opt.selected = true;
|
|
135
|
+
|
|
137
136
|
select.appendChild(opt);
|
|
138
137
|
}
|
|
139
138
|
|
|
@@ -141,8 +140,11 @@ export class HTMLElementSugarSelect extends HTMLElementSugarInput {
|
|
|
141
140
|
while (select.firstChild) select.removeChild(select.firstChild);
|
|
142
141
|
}
|
|
143
142
|
|
|
144
|
-
_setOptions(select, opts) {
|
|
143
|
+
_setOptions(select, opts, cfg) {
|
|
145
144
|
this._clearOptions(select);
|
|
145
|
+
|
|
146
|
+
if (cfg.placeholder) this._addPlaceholder(select, cfg.placeholder);
|
|
147
|
+
|
|
146
148
|
for (const o of opts) {
|
|
147
149
|
const opt = document.createElement('option');
|
|
148
150
|
opt.value = o.value == null ? '' : String(o.value);
|
|
@@ -189,7 +191,7 @@ export class HTMLElementSugarSelect extends HTMLElementSugarInput {
|
|
|
189
191
|
|
|
190
192
|
const items = Array.isArray(data) ? data : [];
|
|
191
193
|
const opts = items.map((it) => this._mapItemToOption(it, cfg));
|
|
192
|
-
this._setOptions(select, opts);
|
|
194
|
+
this._setOptions(select, opts, cfg);
|
|
193
195
|
}
|
|
194
196
|
|
|
195
197
|
_setupLocalSearch(select, searchEl) {
|
package/lib/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
],
|
|
39
39
|
"license": "MIT",
|
|
40
40
|
"name": "@skirbi/sugar",
|
|
41
|
+
"private": false,
|
|
41
42
|
"repository": {
|
|
42
43
|
"type": "git",
|
|
43
44
|
"url": "git+https://gitlab.com/skirbi/skirbi.git"
|
|
@@ -51,5 +52,5 @@
|
|
|
51
52
|
},
|
|
52
53
|
"sideEffects": false,
|
|
53
54
|
"type": "module",
|
|
54
|
-
"version": "0.0.
|
|
55
|
+
"version": "0.0.19"
|
|
55
56
|
}
|