@jungherz-de/glasskit-elements 1.16.0 → 1.16.1

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.
@@ -204,6 +204,24 @@ var GlassKitElements = (function (exports) {
204
204
 
205
205
  // ── Utility Methods ──
206
206
 
207
+ /**
208
+ * For elements whose heading arrives as `title`. That is also the global
209
+ * HTML attribute, and a title on the host shows as a browser tooltip — the
210
+ * sheet's heading floating over its form. So the value is read into
211
+ * this._title and the attribute is taken off the host; a later
212
+ * setAttribute('title') comes through attributeChangedCallback, is taken
213
+ * the same way and removed again, and the element's `title` accessor
214
+ * answers from this._title. The removal fires the callback with null,
215
+ * which is ignored here — only an empty string clears the heading.
216
+ * Returns whether a value was taken.
217
+ */
218
+ takeTitle(value = this.getAttribute('title')) {
219
+ if (value === null) return false;
220
+ this._title = value;
221
+ this.removeAttribute('title');
222
+ return true;
223
+ }
224
+
207
225
  getBoolAttr(name) {
208
226
  return this.hasAttribute(name);
209
227
  }
@@ -1204,11 +1222,12 @@ var GlassKitElements = (function (exports) {
1204
1222
  action.appendChild(this.createElement('slot', [], { name: 'action' }));
1205
1223
  root.append(icon, this._titleEl, this._textEl, action);
1206
1224
  this._wrapper.appendChild(root);
1225
+ this.takeTitle();
1207
1226
  this._update();
1208
1227
  }
1209
1228
 
1210
1229
  _update() {
1211
- const title = this.getAttribute('title') || '';
1230
+ const title = this._title || '';
1212
1231
  const text = this.getAttribute('text') || '';
1213
1232
  this._titleEl.textContent = title;
1214
1233
  this._titleEl.hidden = !title;
@@ -1216,10 +1235,22 @@ var GlassKitElements = (function (exports) {
1216
1235
  this._textEl.hidden = !text;
1217
1236
  }
1218
1237
 
1219
- onAttributeChanged() {
1238
+ onAttributeChanged(name, _old, value) {
1239
+ if (name === 'title' && !this.takeTitle(value)) return;
1240
+ if (this._titleEl) this._update();
1241
+ }
1242
+
1243
+ _applyTitle() {
1220
1244
  if (this._titleEl) this._update();
1221
1245
  }
1222
1246
 
1247
+ // `title` is the heading, never a tooltip — see GlkElement.takeTitle().
1248
+ get title() { return this._title ?? ''; }
1249
+ set title(v) {
1250
+ this._title = v == null ? '' : String(v);
1251
+ this._applyTitle();
1252
+ }
1253
+
1223
1254
  get text() { return this.getAttribute('text') || ''; }
1224
1255
  set text(v) {
1225
1256
  if (v) this.setAttribute('text', v);
@@ -2901,7 +2932,8 @@ var GlassKitElements = (function (exports) {
2901
2932
  // Header
2902
2933
  const header = this.createElement('div', ['glass-modal__header'], { part: 'header' });
2903
2934
  this._titleEl = this.createElement('h2', ['glass-modal__title']);
2904
- this._titleEl.textContent = this.getAttribute('title') || '';
2935
+ this.takeTitle();
2936
+ this._applyTitle();
2905
2937
  header.appendChild(this._titleEl);
2906
2938
 
2907
2939
  // Body
@@ -2970,14 +3002,14 @@ var GlassKitElements = (function (exports) {
2970
3002
  document.removeEventListener('keydown', this._onKeydown);
2971
3003
  }
2972
3004
 
2973
- onAttributeChanged(name) {
3005
+ onAttributeChanged(name, _old, value) {
2974
3006
  if (!this._overlay) return;
2975
3007
  switch (name) {
2976
3008
  case 'open':
2977
3009
  this._overlay.classList.toggle('is-active', this.getBoolAttr('open'));
2978
3010
  break;
2979
3011
  case 'title':
2980
- this._titleEl.textContent = this.getAttribute('title') || '';
3012
+ if (this.takeTitle(value)) this._applyTitle();
2981
3013
  break;
2982
3014
  }
2983
3015
  }
@@ -2985,6 +3017,17 @@ var GlassKitElements = (function (exports) {
2985
3017
  show() { this.setAttribute('open', ''); }
2986
3018
  close() { this.removeAttribute('open'); }
2987
3019
 
3020
+ _applyTitle() {
3021
+ if (this._titleEl) this._titleEl.textContent = this._title || '';
3022
+ }
3023
+
3024
+ // `title` is the heading, never a tooltip — see GlkElement.takeTitle().
3025
+ get title() { return this._title ?? ''; }
3026
+ set title(v) {
3027
+ this._title = v == null ? '' : String(v);
3028
+ this._applyTitle();
3029
+ }
3030
+
2988
3031
  get open() { return this.getBoolAttr('open'); }
2989
3032
  set open(v) { this.setBoolAttr('open', v); }
2990
3033
  }
@@ -3236,12 +3279,14 @@ var GlassKitElements = (function (exports) {
3236
3279
  this._panel.append(this._titleEl, body, actions);
3237
3280
  this._overlay.appendChild(this._panel);
3238
3281
  this._wrapper.appendChild(this._overlay);
3282
+ this.takeTitle();
3239
3283
  this._applyTitle();
3240
3284
  this._applyMode();
3241
3285
  }
3242
3286
 
3243
3287
  _applyTitle() {
3244
- const title = this.getAttribute('title') || '';
3288
+ if (!this._titleEl) return;
3289
+ const title = this._title || '';
3245
3290
  this._titleEl.textContent = title;
3246
3291
  this._titleEl.hidden = !title;
3247
3292
  if (title) this._panel.setAttribute('aria-label', title);
@@ -3311,7 +3356,7 @@ var GlassKitElements = (function (exports) {
3311
3356
  document.removeEventListener('keydown', this._onKeydown);
3312
3357
  }
3313
3358
 
3314
- onAttributeChanged(name) {
3359
+ onAttributeChanged(name, _old, value) {
3315
3360
  if (!this._overlay) return;
3316
3361
  switch (name) {
3317
3362
  case 'open':
@@ -3320,13 +3365,20 @@ var GlassKitElements = (function (exports) {
3320
3365
  else this._hide();
3321
3366
  break;
3322
3367
  case 'inline': this._applyMode(); break;
3323
- case 'title': this._applyTitle(); break;
3368
+ case 'title': if (this.takeTitle(value)) this._applyTitle(); break;
3324
3369
  }
3325
3370
  }
3326
3371
 
3327
3372
  show() { this.setAttribute('open', ''); }
3328
3373
  close() { this.removeAttribute('open'); }
3329
3374
 
3375
+ // `title` is the heading, never a tooltip — see GlkElement.takeTitle().
3376
+ get title() { return this._title ?? ''; }
3377
+ set title(v) {
3378
+ this._title = v == null ? '' : String(v);
3379
+ this._applyTitle();
3380
+ }
3381
+
3330
3382
  get open() { return this.getBoolAttr('open'); }
3331
3383
  set open(v) { this.setBoolAttr('open', v); }
3332
3384
 
@@ -3359,7 +3411,8 @@ var GlassKitElements = (function (exports) {
3359
3411
 
3360
3412
  // Trigger button
3361
3413
  this._trigger = this.createElement('button', ['glass-accordion__trigger']);
3362
- this._triggerText = document.createTextNode(this.getAttribute('title') || '');
3414
+ this.takeTitle();
3415
+ this._triggerText = document.createTextNode(this._title || '');
3363
3416
  this._trigger.appendChild(this._triggerText);
3364
3417
  this._trigger.insertAdjacentHTML('beforeend', CHEVRON_SVG);
3365
3418
 
@@ -3387,18 +3440,29 @@ var GlassKitElements = (function (exports) {
3387
3440
  this._trigger?.removeEventListener('click', this._onClick);
3388
3441
  }
3389
3442
 
3390
- onAttributeChanged(name) {
3443
+ onAttributeChanged(name, _old, value) {
3391
3444
  if (!this._item) return;
3392
3445
  switch (name) {
3393
3446
  case 'open':
3394
3447
  this._item.classList.toggle('is-open', this.getBoolAttr('open'));
3395
3448
  break;
3396
3449
  case 'title':
3397
- this._triggerText.textContent = this.getAttribute('title') || '';
3450
+ if (this.takeTitle(value)) this._applyTitle();
3398
3451
  break;
3399
3452
  }
3400
3453
  }
3401
3454
 
3455
+ _applyTitle() {
3456
+ if (this._triggerText) this._triggerText.textContent = this._title || '';
3457
+ }
3458
+
3459
+ // `title` is the heading, never a tooltip — see GlkElement.takeTitle().
3460
+ get title() { return this._title ?? ''; }
3461
+ set title(v) {
3462
+ this._title = v == null ? '' : String(v);
3463
+ this._applyTitle();
3464
+ }
3465
+
3402
3466
  get open() { return this.getBoolAttr('open'); }
3403
3467
  set open(v) { this.setBoolAttr('open', v); }
3404
3468
  }
@@ -3525,7 +3589,8 @@ var GlassKitElements = (function (exports) {
3525
3589
  // Content — title + optional subtitle.
3526
3590
  this._content = this.createElement('div', ['glass-list__content']);
3527
3591
  this._titleEl = this.createElement('div', ['glass-list__title']);
3528
- this._titleEl.textContent = this.getAttribute('title') || '';
3592
+ this.takeTitle();
3593
+ this._titleEl.textContent = this._title || '';
3529
3594
  this._subtitleEl = this.createElement('div', ['glass-list__subtitle']);
3530
3595
  if (this.getBoolAttr('wrap')) this._subtitleEl.classList.add('glass-list__subtitle--wrap');
3531
3596
  const initialSubtitle = this.getAttribute('subtitle') || '';
@@ -3591,11 +3656,11 @@ var GlassKitElements = (function (exports) {
3591
3656
  this._item?.removeEventListener('click', this._onClick);
3592
3657
  }
3593
3658
 
3594
- onAttributeChanged(name) {
3659
+ onAttributeChanged(name, _old, value) {
3595
3660
  if (!this._item) return;
3596
3661
  switch (name) {
3597
3662
  case 'title':
3598
- this._titleEl.textContent = this.getAttribute('title') || '';
3663
+ if (this.takeTitle(value)) this._applyTitle();
3599
3664
  break;
3600
3665
  case 'subtitle': {
3601
3666
  const value = this.getAttribute('subtitle') || '';
@@ -3635,6 +3700,17 @@ var GlassKitElements = (function (exports) {
3635
3700
  }
3636
3701
  }
3637
3702
 
3703
+ _applyTitle() {
3704
+ if (this._titleEl) this._titleEl.textContent = this._title || '';
3705
+ }
3706
+
3707
+ // `title` is the heading, never a tooltip — see GlkElement.takeTitle().
3708
+ get title() { return this._title ?? ''; }
3709
+ set title(v) {
3710
+ this._title = v == null ? '' : String(v);
3711
+ this._applyTitle();
3712
+ }
3713
+
3638
3714
  get interactive() { return this.getBoolAttr('interactive'); }
3639
3715
  set interactive(v) { this.setBoolAttr('interactive', v); }
3640
3716