@voidable/ui 0.9.0 → 0.10.0

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.
Files changed (93) hide show
  1. package/dist/base-entry.d.ts +1 -0
  2. package/dist/base.d.ts +2 -1
  3. package/dist/base.js +5 -1
  4. package/dist/chunks/base-BxmMM3B7.js +298 -0
  5. package/dist/chunks/{keyboard-MQpfTX5I.js → keyboard-CEhMSkws.js} +19 -3
  6. package/dist/chunks/{modal-hivQ4YoU.js → modal-CgGp_fCs.js} +3 -3
  7. package/dist/chunks/{overlay-BywGMcDW.js → overlay-hLJ7IQHx.js} +2 -2
  8. package/dist/chunks/{parts-CMQQop0D.js → parts-DI_3VpSy.js} +21 -17
  9. package/dist/chunks/{base-CMruMbxC.js → projection-SnR79EHI.js} +105 -389
  10. package/dist/components/accordion.js +2 -2
  11. package/dist/components/action-input.d.ts +2 -2
  12. package/dist/components/action-input.js +56 -54
  13. package/dist/components/alert.js +2 -2
  14. package/dist/components/avatar.js +13 -11
  15. package/dist/components/badge.js +1 -1
  16. package/dist/components/banner.js +2 -2
  17. package/dist/components/bar-chart.js +31 -29
  18. package/dist/components/breadcrumbs.js +2 -2
  19. package/dist/components/button.js +1 -1
  20. package/dist/components/calendar.js +78 -76
  21. package/dist/components/card.js +1 -1
  22. package/dist/components/carousel.js +18 -17
  23. package/dist/components/checkbox-group.js +13 -12
  24. package/dist/components/checkbox.js +17 -16
  25. package/dist/components/collapsible.js +2 -2
  26. package/dist/components/color-picker.js +26 -24
  27. package/dist/components/combobox.js +17 -16
  28. package/dist/components/compose-input.js +13 -11
  29. package/dist/components/dialog.js +1 -1
  30. package/dist/components/divider.js +11 -9
  31. package/dist/components/donut-chart.js +51 -49
  32. package/dist/components/drawer.d.ts +2 -2
  33. package/dist/components/drawer.js +1 -1
  34. package/dist/components/dropdown-menu.js +4 -4
  35. package/dist/components/editable.js +13 -12
  36. package/dist/components/error-fallback.js +2 -2
  37. package/dist/components/field.js +10 -9
  38. package/dist/components/file-upload.js +19 -17
  39. package/dist/components/gauge.js +88 -86
  40. package/dist/components/hamburger.js +11 -9
  41. package/dist/components/hover-card.js +3 -3
  42. package/dist/components/indicator.js +14 -12
  43. package/dist/components/input.js +41 -39
  44. package/dist/components/line-chart.js +41 -39
  45. package/dist/components/list.js +1 -1
  46. package/dist/components/menu.js +3 -3
  47. package/dist/components/multiselect.js +30 -29
  48. package/dist/components/nav-bar.js +1 -1
  49. package/dist/components/nav-menu.js +20 -19
  50. package/dist/components/number-input.js +17 -15
  51. package/dist/components/pagination.js +22 -20
  52. package/dist/components/panel.js +2 -2
  53. package/dist/components/pin-input.js +32 -30
  54. package/dist/components/popover.js +3 -3
  55. package/dist/components/progress.js +14 -12
  56. package/dist/components/radio-group.js +13 -11
  57. package/dist/components/radio.d.ts +25 -0
  58. package/dist/components/radio.js +78 -29
  59. package/dist/components/scroll-area.js +8 -7
  60. package/dist/components/segmented-control.js +21 -21
  61. package/dist/components/select.js +49 -47
  62. package/dist/components/sidebar.d.ts +2 -2
  63. package/dist/components/sidebar.js +2 -2
  64. package/dist/components/skeleton.js +1 -1
  65. package/dist/components/slider.js +16 -14
  66. package/dist/components/spinner.js +11 -9
  67. package/dist/components/stat.js +19 -17
  68. package/dist/components/status-dot.js +1 -1
  69. package/dist/components/stepper.js +15 -13
  70. package/dist/components/switch.js +14 -12
  71. package/dist/components/table.js +1 -1
  72. package/dist/components/tabs.js +29 -29
  73. package/dist/components/tag.js +9 -8
  74. package/dist/components/tags-input.js +24 -22
  75. package/dist/components/textarea.js +34 -32
  76. package/dist/components/toast.d.ts +19 -2
  77. package/dist/components/toast.js +43 -10
  78. package/dist/components/toggle-group.js +16 -15
  79. package/dist/components/toggle.js +1 -1
  80. package/dist/components/tooltip.js +3 -3
  81. package/dist/components.json +1 -1
  82. package/dist/custom-elements.json +48 -18
  83. package/dist/dev.js +31 -7
  84. package/dist/index.js +1 -1
  85. package/dist/keyboard.d.ts +10 -0
  86. package/dist/llms.txt +1 -1
  87. package/dist/parts.d.ts +5 -0
  88. package/dist/projection-api.d.ts +23 -0
  89. package/dist/projection.d.ts +8 -2
  90. package/dist/reference.md +4 -4
  91. package/dist/vscode.html-custom-data.json +13 -7
  92. package/dist/web-types.json +17 -17
  93. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ export { VoidElement } from './base.js';
package/dist/base.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { LitElement, PropertyValues } from 'lit';
2
- import { PROJECTION_KEY, ProjectionController } from './projection.js';
2
+ import { PROJECTION_KEY } from './projection-api.js';
3
+ import { ProjectionController } from './projection.js';
3
4
  /** Same key as parts.ts's MORPH_PARTICIPANTS (a registered symbol, so base needs no import of parts.ts). */
4
5
  declare const MORPH_PARTICIPANTS: unique symbol;
5
6
  export declare class VoidElement extends LitElement {
package/dist/base.js CHANGED
@@ -1,2 +1,6 @@
1
- import { t as e } from "./chunks/base-CMruMbxC.js";
1
+ import { t as e } from "./chunks/base-BxmMM3B7.js";
2
+ import { r as t } from "./chunks/projection-SnR79EHI.js";
3
+ //#region src/base-entry.ts
4
+ t();
5
+ //#endregion
2
6
  export { e as VoidElement };
@@ -0,0 +1,298 @@
1
+ import { LitElement as e, ReactiveElement as t } from "lit";
2
+ //#region src/projection-api.ts
3
+ var n = "__voidProjection", r = {}, i = Symbol("voidReflectedDefaults"), a = Symbol("voidDefaultsProbe"), o = Symbol("voidReflectAgain");
4
+ function s(e) {
5
+ let t = e.constructor;
6
+ if (Object.prototype.hasOwnProperty.call(t, i)) return t[i];
7
+ let n = /* @__PURE__ */ new Map();
8
+ t[i] = n;
9
+ let r = null;
10
+ try {
11
+ customElements.get(e.localName) === t && (r = Object.assign(new t(), { [a]: !0 }));
12
+ } catch {
13
+ r = null;
14
+ }
15
+ if (!r) return n;
16
+ for (let [e, i] of t.elementProperties) {
17
+ if (!i.reflect || i.attribute === !1) continue;
18
+ let t = typeof i.attribute == "string" ? i.attribute : String(e).toLowerCase(), a = typeof i.converter == "function" || !!i.converter?.fromAttribute;
19
+ n.set(t, {
20
+ prop: e,
21
+ value: r[e],
22
+ custom: a,
23
+ options: i
24
+ });
25
+ }
26
+ return n;
27
+ }
28
+ var c = Symbol("voidMorphMeta");
29
+ function l(e) {
30
+ let t = e.constructor;
31
+ if (Object.prototype.hasOwnProperty.call(t, c)) return t[c];
32
+ let n = /* @__PURE__ */ new Map();
33
+ for (let [e, r] of t.elementProperties) {
34
+ if (r.attribute === !1) continue;
35
+ let t = typeof r.attribute == "string" ? r.attribute : String(e).toLowerCase();
36
+ n.set(t, !!r.reflect);
37
+ }
38
+ let r = {
39
+ attrs: n,
40
+ drafts: Object.entries(t.clientState ?? {}),
41
+ hook: e.morphedCallback !== h.prototype.morphedCallback,
42
+ edits: t.editState ?? []
43
+ };
44
+ return t[c] = r, r;
45
+ }
46
+ var u = 10, d = 1e3, f = Symbol.for("voidable.dev"), p = Symbol.for("@voidable/ui:morph-participants"), m = /* @__PURE__ */ new WeakMap(), h = class i extends e {
47
+ #e = null;
48
+ #t = null;
49
+ #n = !1;
50
+ #r = !1;
51
+ #i = null;
52
+ #a = void 0;
53
+ #o = void 0;
54
+ #s = !1;
55
+ #c = null;
56
+ static get observedAttributes() {
57
+ let e = super.observedAttributes;
58
+ return this.labelTarget ? [
59
+ ...e,
60
+ "aria-label",
61
+ "aria-labelledby"
62
+ ] : e;
63
+ }
64
+ #l = null;
65
+ #u(e, t) {
66
+ this.#l || (this.#l = {
67
+ "aria-label": null,
68
+ "aria-labelledby": null,
69
+ written: /* @__PURE__ */ new Map()
70
+ }, this.addController({ hostUpdated: () => this.#d() })), this.#l[e] = t || null, this.removeAttribute(e), this.#d();
71
+ }
72
+ #d() {
73
+ let e = this.#l, t = this.constructor.labelTarget;
74
+ if (!e || !t) return;
75
+ let n = Array.from(this.querySelectorAll(t));
76
+ for (let [t, r] of e.written) if (!n.includes(t)) {
77
+ e.written.delete(t);
78
+ for (let [e, n] of Object.entries(r)) n !== null && t.getAttribute(e) === n && t.removeAttribute(e);
79
+ }
80
+ for (let t of n) {
81
+ let n = e.written.get(t);
82
+ n || e.written.set(t, n = {
83
+ "aria-label": null,
84
+ "aria-labelledby": null
85
+ });
86
+ for (let r of ["aria-label", "aria-labelledby"]) {
87
+ let i = e[r], a = t.getAttribute(r);
88
+ r === "aria-labelledby" && a !== null && a !== n[r] || (i === null ? (n[r] !== null && a === n[r] && a !== null && t.removeAttribute(r), n[r] = null) : (a !== i && t.setAttribute(r, i), n[r] = i));
89
+ }
90
+ }
91
+ }
92
+ createRenderRoot() {
93
+ return this;
94
+ }
95
+ connectedCallback() {
96
+ this.#a === void 0 && (this.#a = this.#f(this), this.#o = this.outerHTML, !this.__voidProjection && this.render !== e.prototype.render && r.current?.create(this)), super.connectedCallback();
97
+ }
98
+ connectedMoveCallback() {}
99
+ #f(e) {
100
+ if (!e.hasAttributes()) return null;
101
+ let { attrs: t } = l(this), n = e.attributes, r = null;
102
+ for (let e = 0; e < n.length; e++) {
103
+ let i = n[e];
104
+ t.has(i.name) && (r ??= /* @__PURE__ */ new Map()).set(i.name, i.value);
105
+ }
106
+ return r;
107
+ }
108
+ shouldUpdate(e) {
109
+ return !this[a] && super.shouldUpdate(e);
110
+ }
111
+ update(n) {
112
+ this.#r = !0;
113
+ try {
114
+ this.render === e.prototype.render ? t.prototype.update.call(this, n) : super.update(n);
115
+ } finally {
116
+ this.#r = !1;
117
+ }
118
+ }
119
+ setHostAttribute(e, t) {
120
+ let n = t === !0 ? "" : t === !1 || t == null ? null : String(t), r = this.#e ??= /* @__PURE__ */ new Map();
121
+ this.#i && r.get(e) !== n && this.#i.delete(e), r.set(e, n), n === null ? this.hasAttribute(e) && super.removeAttribute(e) : this.getAttribute(e) !== n && super.setAttribute(e, n);
122
+ }
123
+ setHostStyle(e, t) {
124
+ t == null || t === "" ? (this.#t?.delete(e), this.style.removeProperty(e)) : ((this.#t ??= /* @__PURE__ */ new Map()).set(e, t), this.style.getPropertyValue(e) !== t && this.style.setProperty(e, t));
125
+ }
126
+ removeAttribute(e) {
127
+ super.removeAttribute(e), this.#p(e);
128
+ }
129
+ removeAttributeNS(e, t) {
130
+ super.removeAttributeNS(e, t), e || this.#p(t);
131
+ }
132
+ toggleAttribute(e, t) {
133
+ let n = super.toggleAttribute(e, t);
134
+ return n || this.#p(e), n;
135
+ }
136
+ setAttribute(e, t) {
137
+ super.setAttribute(e, t), e === "style" && this.#t?.size && this.#m();
138
+ }
139
+ #p(e) {
140
+ (e === "style" ? this.#t?.size : this.#e?.get(e) != null) && this.#m();
141
+ }
142
+ #m() {
143
+ this.#n || (this.#n = !0, queueMicrotask(() => {
144
+ this.#n = !1, this.#h();
145
+ }));
146
+ }
147
+ #h() {
148
+ if (this.#e) for (let [e, t] of this.#e) t !== null && !this.hasAttribute(e) && this.#g(e) && super.setAttribute(e, t);
149
+ if (this.#t) {
150
+ let e;
151
+ for (let [t, n] of this.#t) if (this.style.getPropertyValue(t) !== n) {
152
+ if (!(e ??= this.#g("style"))) break;
153
+ this.style.setProperty(t, n);
154
+ }
155
+ }
156
+ }
157
+ #g(e) {
158
+ let t = Date.now(), n = this.#i ??= /* @__PURE__ */ new Map(), r = n.get(e);
159
+ return r && r[0] === Infinity ? !1 : ((!r || t - r[1] > d) && n.set(e, r = [0, t]), ++r[0] <= u ? !0 : (r[0] = Infinity, globalThis[f]?.report?.({
160
+ kind: "attribute-fight",
161
+ tag: this.localName,
162
+ subject: e,
163
+ message: `<${this.localName}> ${e}: something keeps removing this attribute, which the component manages; after ${u} restorations within ${d} ms it is no longer put back. Find the script that removes it (a MutationObserver, a sanitiser) and leave the attribute alone.`,
164
+ element: this
165
+ }), !1));
166
+ }
167
+ attributeChangedCallback(e, t, n) {
168
+ if ((e === "aria-label" || e === "aria-labelledby") && this.constructor.labelTarget) {
169
+ n !== null && this.#u(e, n);
170
+ return;
171
+ }
172
+ if (super.attributeChangedCallback(e, t, n), n !== null || t === null || this.#r) return;
173
+ let r = s(this).get(e);
174
+ if (!r) return;
175
+ let i = this;
176
+ if (!r.custom && r.value !== void 0 && i[r.prop] !== r.value) {
177
+ i[r.prop] = r.value;
178
+ return;
179
+ }
180
+ let { options: a } = r, c = i[r.prop], l = typeof a.converter == "object" ? a.converter : void 0;
181
+ (l?.toAttribute ? l.toAttribute(c, a.type) : a.type === Boolean ? c ? "" : null : c ?? null) != null && this.requestUpdate(r.prop, o);
182
+ }
183
+ insertBefore(e, t) {
184
+ let r = this[n];
185
+ return r && t && t.parentNode !== this && (r.isProjected(t) || r.isWrapEnd(t)) ? r.insertBefore(e, t) : r && !t && r.append(e) ? e : super.insertBefore(e, t);
186
+ }
187
+ removeChild(e) {
188
+ let t = this[n];
189
+ return t && e.parentNode !== this && t.isProjected(e) ? e.parentNode.removeChild(e) : super.removeChild(e);
190
+ }
191
+ replaceChild(e, t) {
192
+ let r = this[n];
193
+ return r && t.parentNode !== this && r.isProjected(t) ? (r.insertBefore(e, t), t.parentNode.removeChild(t)) : super.replaceChild(e, t);
194
+ }
195
+ get textContent() {
196
+ return super.textContent ?? "";
197
+ }
198
+ set textContent(e) {
199
+ let t = this[n], r = e == null ? "" : String(e), i = r ? [this.ownerDocument.createTextNode(r)] : [];
200
+ (!t || !t.replaceContent(i)) && (super.textContent = e);
201
+ }
202
+ replaceChildren(...e) {
203
+ let t = this[n];
204
+ if (t) {
205
+ let n = [];
206
+ for (let t of e) typeof t == "string" ? n.push(this.ownerDocument.createTextNode(t)) : t.nodeType === Node.DOCUMENT_FRAGMENT_NODE ? n.push(...Array.from(t.childNodes)) : n.push(t);
207
+ for (let e of n) if (e.nodeType === Node.DOCUMENT_NODE || e.nodeType === Node.DOCUMENT_TYPE_NODE || e.contains(this)) throw new DOMException(`Failed to execute 'replaceChildren' on '${this.localName}': the new child cannot be inserted here.`, "HierarchyRequestError");
208
+ if (t.replaceContent(n)) return;
209
+ }
210
+ super.replaceChildren(...e);
211
+ }
212
+ voidBeforeMorph(e) {
213
+ if (e && e !== this) {
214
+ e instanceof i && e[n]?.unproject();
215
+ let t = !!r.current?.strip(e) || (this[p] ?? []).some((t) => t.isCopy?.(e)), a = this.#l;
216
+ if (a) {
217
+ for (let t of ["aria-label", "aria-labelledby"]) a[t] !== null && !e.hasAttribute(t) && (a[t] = null);
218
+ this.#d();
219
+ }
220
+ if (m.get(e) !== this) {
221
+ m.set(e, this);
222
+ for (let t of this[p] ?? []) t.voidBeforeMorph(e);
223
+ this.#_(e, t);
224
+ }
225
+ this.#y(e);
226
+ }
227
+ this.isConnected || r.current?.strip(this);
228
+ let t = this[n];
229
+ return t ? t.parked || t.unproject() : !1;
230
+ }
231
+ voidUnchanged(e) {
232
+ let t = e.outerHTML;
233
+ return t === this.#o && !this.__voidProjection?.parked ? !0 : (this.#o = t, !1);
234
+ }
235
+ voidAfterMorph() {
236
+ return this.__voidProjection?.reproject() ?? this.updateComplete;
237
+ }
238
+ #_(e, t = !1) {
239
+ let n = l(this), r = this.#a ?? null, a = e instanceof i && e.#a !== void 0 ? e.#a : t ? r : this.#f(e), o = null;
240
+ if (r) for (let [e, t] of r) a?.get(e) !== t && (o ??= /* @__PURE__ */ new Set()).add(e);
241
+ if (a) for (let [e, t] of a) r?.get(e) !== t && (o ??= /* @__PURE__ */ new Set()).add(e);
242
+ if (o && (this.#a = a), o && n.edits.length && this.#v()) {
243
+ for (let t of n.edits) {
244
+ if (!o.delete(t)) continue;
245
+ let n = this.getAttribute(t);
246
+ n === null ? e.removeAttribute(t) : e.getAttribute(t) !== n && e.setAttribute(t, n);
247
+ }
248
+ o.size || (o = null);
249
+ }
250
+ let s = this.attributes;
251
+ for (let t = 0; t < s.length; t++) {
252
+ let r = s[t];
253
+ n.attrs.get(r.name) !== !0 || o?.has(r.name) || e.getAttribute(r.name) !== r.value && e.setAttribute(r.name, r.value);
254
+ }
255
+ if (e instanceof i) {
256
+ let t = e.attributes;
257
+ for (let r = t.length - 1; r >= 0; r--) {
258
+ let i = t[r].name;
259
+ n.attrs.get(i) === !0 && !a?.has(i) && !this.hasAttribute(i) && e.removeAttribute(i);
260
+ }
261
+ }
262
+ if (a) for (let t of a.keys()) n.attrs.get(t) === !0 && !o?.has(t) && !this.hasAttribute(t) && e.removeAttribute(t);
263
+ if (o && n.drafts.length) {
264
+ let e = this;
265
+ for (let [t, r] of n.drafts) r !== null && o.has(r) && e[t] != null && (e[t] = null, this.requestUpdate());
266
+ }
267
+ if (o) for (let e of o) (this.#c ??= /* @__PURE__ */ new Set()).add(e);
268
+ (n.hook || this.#c) && !this.#s && (this.#s = !0, queueMicrotask(() => {
269
+ this.updateComplete.then(() => {
270
+ this.#s = !1;
271
+ let e = this.#c;
272
+ this.#c = null, this.isConnected && (e && this.serverChangedCallback(e), n.hook && this.morphedCallback());
273
+ });
274
+ }));
275
+ }
276
+ #v() {
277
+ let e = this.ownerDocument.activeElement;
278
+ return !!e && e !== this && this.contains(e) || !!r.current?.isFocusParked(this);
279
+ }
280
+ serverChangedCallback(e) {}
281
+ morphedCallback() {}
282
+ #y(e) {
283
+ if (this.#e) {
284
+ let t = e instanceof i ? e.#e : null;
285
+ for (let [n, r] of this.#e) {
286
+ if (r === null) continue;
287
+ let i = e.getAttribute(n);
288
+ (i === null || t?.has(n) && t.get(n) === i) && i !== r && e.setAttribute(n, r);
289
+ }
290
+ }
291
+ if (this.#t?.size && "style" in e) {
292
+ let t = e.style;
293
+ for (let [e, n] of this.#t) t.getPropertyValue(e) || t.setProperty(e, n);
294
+ }
295
+ }
296
+ };
297
+ //#endregion
298
+ export { n, r, h as t };
@@ -38,9 +38,25 @@ var r = class {
38
38
  reset() {
39
39
  clearTimeout(this.#t), this.#e = "";
40
40
  }
41
- }, i = 0;
41
+ };
42
+ function i(e) {
43
+ try {
44
+ if (e.matches(":dir(rtl)")) return !0;
45
+ } catch {}
46
+ return getComputedStyle(e).direction === "rtl";
47
+ }
42
48
  function a(e) {
43
- return `${e}-${++i}`;
49
+ return i(e) ? {
50
+ next: "ArrowLeft",
51
+ prev: "ArrowRight"
52
+ } : {
53
+ next: "ArrowRight",
54
+ prev: "ArrowLeft"
55
+ };
56
+ }
57
+ var o = 0;
58
+ function s(e) {
59
+ return `${e}-${++o}`;
44
60
  }
45
61
  //#endregion
46
- export { a, e as i, t as n, n as r, r as t };
62
+ export { e as a, n as i, t as n, s as o, a as r, r as t };
@@ -1,7 +1,7 @@
1
- import { t as e } from "./base-CMruMbxC.js";
1
+ import { t as e } from "./base-BxmMM3B7.js";
2
2
  import { t } from "./decorate-CaYbmmmm.js";
3
- import { n, r } from "./parts-CMQQop0D.js";
4
- import { t as i } from "./overlay-BywGMcDW.js";
3
+ import { n, r } from "./parts-DI_3VpSy.js";
4
+ import { t as i } from "./overlay-hLJ7IQHx.js";
5
5
  import { property as a } from "lit/decorators.js";
6
6
  //#region src/modal.ts
7
7
  var o = class extends e {
@@ -1,4 +1,4 @@
1
- import { i as e } from "./base-CMruMbxC.js";
1
+ import { r as e } from "./base-BxmMM3B7.js";
2
2
  //#region src/overlay.ts
3
3
  var t = new Set([
4
4
  "escape",
@@ -318,7 +318,7 @@ var S = class {
318
318
  return;
319
319
  }
320
320
  if (l(t)) try {
321
- c(t, ":popover-open") || (t.showPopover(), this._watchFade(t), e(t.ownerDocument));
321
+ c(t, ":popover-open") || (t.showPopover(), this._watchFade(t), e.current?.restoreParkedFocus(t.ownerDocument));
322
322
  } catch {}
323
323
  else t.hidden = !1;
324
324
  }
@@ -5,7 +5,7 @@ function n(e) {
5
5
  }
6
6
  var r = (e) => (e ?? "").split(/\s+/).filter(Boolean), i = class {
7
7
  constructor(t, n) {
8
- this._observer = null, this._queued = !1, this._attrs = /* @__PURE__ */ new Map(), this._styles = /* @__PURE__ */ new Map(), this._names = /* @__PURE__ */ new Set(), this._syncing = !1, this._pass = 0, this._onMutations = (e) => {
8
+ this._observer = null, this._queued = !1, this._attrs = /* @__PURE__ */ new Map(), this._styles = /* @__PURE__ */ new Map(), this._names = /* @__PURE__ */ new Set(), this._syncing = !1, this._observing = !1, this._namesDirty = !1, this._pass = 0, this._onMutations = (e) => {
9
9
  for (let t of e) {
10
10
  if (t.type === "attributes") {
11
11
  if (this._lostOwned(t.target, t.attributeName)) return this.requestSync();
@@ -50,7 +50,7 @@ var r = (e) => (e ?? "").split(/\s+/).filter(Boolean), i = class {
50
50
  r || this._attrs.set(e, r = /* @__PURE__ */ new Map()), r.set(t, {
51
51
  ...n,
52
52
  pass: this._syncing ? this._pass : r.get(t)?.pass ?? 0
53
- }), this._names.has(t) || (this._names.add(t), this._observer && this._observe());
53
+ }), this._names.has(t) || (this._names.add(t), this._observing && (this._syncing ? this._namesDirty = !0 : this._observe()));
54
54
  }
55
55
  set(e, t, n) {
56
56
  let r = n === !0 ? "" : n === !1 || n == null ? null : String(n);
@@ -113,10 +113,10 @@ var r = (e) => (e ?? "").split(/\s+/).filter(Boolean), i = class {
113
113
  }
114
114
  }
115
115
  hostConnected() {
116
- this._observer ??= new MutationObserver(this._onMutations), this._observe(), this.sync();
116
+ this._observer ??= new MutationObserver(this._onMutations), this.sync(), this._observing || this._observe();
117
117
  }
118
118
  hostDisconnected() {
119
- this._observer?.disconnect();
119
+ this._observer?.disconnect(), this._observing = !1;
120
120
  }
121
121
  sync() {
122
122
  if (this._syncing) return;
@@ -129,25 +129,29 @@ var r = (e) => (e ?? "").split(/\s+/).filter(Boolean), i = class {
129
129
  } finally {
130
130
  this._syncing = !1;
131
131
  }
132
- this._observer?.takeRecords();
132
+ this._namesDirty && (this._namesDirty = !1, this._observe(!0)), this._observer?.takeRecords();
133
133
  }
134
134
  requestSync() {
135
135
  this._queued || (this._queued = !0, queueMicrotask(() => {
136
136
  this._queued = !1, this.host.isConnected && this.sync();
137
137
  }));
138
138
  }
139
- _observe() {
140
- let e = this._observer;
141
- if (!e || !this.host.isConnected) return;
142
- let t = e.takeRecords();
143
- e.disconnect(), t.length && !this._syncing && queueMicrotask(() => this._onMutations(t)), e.observe(this.host, {
144
- childList: !0,
145
- subtree: !0,
146
- ...this._names.size ? {
147
- attributes: !0,
148
- attributeFilter: [...this._names].filter((e) => !e.includes(" ")).concat(this._tokenNames())
149
- } : {}
150
- });
139
+ _observe(e = !1) {
140
+ let t = this._observer;
141
+ if (!(!t || !this.host.isConnected)) {
142
+ if (this._observing) {
143
+ let n = t.takeRecords();
144
+ t.disconnect(), n.length && !e && !this._syncing && queueMicrotask(() => this._onMutations(n));
145
+ }
146
+ this._observing = !0, t.observe(this.host, {
147
+ childList: !0,
148
+ subtree: !0,
149
+ ...this._names.size ? {
150
+ attributes: !0,
151
+ attributeFilter: [...this._names].filter((e) => !e.includes(" ")).concat(this._tokenNames())
152
+ } : {}
153
+ });
154
+ }
151
155
  }
152
156
  _tokenNames() {
153
157
  let e = /* @__PURE__ */ new Set();