@skirbi/sugar 0.0.17 → 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 CHANGED
@@ -1,5 +1,15 @@
1
1
  Revision history for @skirbi/sugar
2
2
 
3
+ 0.0.19 2026-04-24 18:31:29Z
4
+
5
+ * Fix nuking placeholder for select
6
+
7
+ 0.0.18 2026-04-20 06:11:32Z
8
+
9
+ * Move renderGuardSelector and hasRenderedShape from with-connected-sugar to
10
+ the base sugar class for @skirbi/bolbe. We need this protection for some
11
+ non-morping semtic elements such as semtic-terminal. Dragons, I found them.
12
+
3
13
  0.0.17 2026-04-20 02:34:38Z
4
14
 
5
15
  * Fakedom, not fakedomE
@@ -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
- opt.selected = true;
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) {
@@ -27,6 +27,7 @@ import { registerDevAlias } from './aliases.mjs';
27
27
 
28
28
  export class HTMLElementSugar extends HTMLElement {
29
29
 
30
+ static renderGuardSelector = '';
30
31
  /**
31
32
  * Register the element using its static `tag` name.
32
33
  * Should be called once per component.
@@ -258,6 +259,11 @@ export class HTMLElementSugar extends HTMLElement {
258
259
  }
259
260
  }
260
261
 
262
+ hasRenderedShape() {
263
+ const sel = this.constructor.renderGuardSelector;
264
+ return !!(sel && this.querySelector(sel));
265
+ }
266
+
261
267
  /**
262
268
  * Called when an observed attribute changes.
263
269
  * @param {string} name - The attribute name
package/lib/index.mjs CHANGED
@@ -2,7 +2,7 @@
2
2
  //
3
3
  // SPDX-License-Identifier: MIT
4
4
 
5
- const VERSION = "0.0.17";
5
+ const VERSION = "0.0.19";
6
6
 
7
7
  export { HTMLElementSugar } from './htmlelement.mjs';
8
8
  export { HTMLElementSugarInput } from './htmlelement-input.mjs';
@@ -1,6 +1,9 @@
1
+ // SPDX-FileCopyrightText: 2026 Wesley Schwengle <wesleys@opperschaap.net>
2
+ //
3
+ // SPDX-License-Identifier: MIT
4
+
1
5
  export const withConnectedSugar = (Base) =>
2
6
  class extends Base {
3
- static renderGuardSelector = '';
4
7
  static morphTriggerSelector = '';
5
8
 
6
9
  connectedCallback() {
@@ -32,7 +35,7 @@ export const withConnectedSugar = (Base) =>
32
35
  }
33
36
 
34
37
  _shouldRenderOnMorph() {
35
- return this._hasMorphTrigger() && !this._hasRenderedShape();
38
+ return this._hasMorphTrigger() && !this.hasRenderedShape();
36
39
  }
37
40
 
38
41
  _hasMorphTrigger() {
@@ -42,16 +45,11 @@ export const withConnectedSugar = (Base) =>
42
45
 
43
46
  _shouldRenderOnConnect() {
44
47
  const guard = this.constructor.renderGuardSelector;
45
- if (guard) return !this._hasRenderedShape();
48
+ if (guard) return !this.hasRenderedShape();
46
49
 
47
50
  return true;
48
51
  }
49
52
 
50
- _hasRenderedShape() {
51
- const sel = this.constructor.renderGuardSelector;
52
- return !!(sel && this.querySelector(sel));
53
- }
54
-
55
53
  disconnectedCallback() {
56
54
  this._sugarMo?.disconnect();
57
55
  this._sugarMo = null;
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.17"
55
+ "version": "0.0.19"
55
56
  }