@kubex/zinc 1.1.89 → 1.1.91

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.
@@ -321,7 +321,6 @@ Add custom quick actions to the context menu using the `zn-editor-quick-action`
321
321
  ```html:preview
322
322
  <zn-editor
323
323
  name="content"
324
- value="<p>Select this text to see custom quick actions in the context menu</p>"
325
324
  style="height: 300px">
326
325
  <zn-editor-quick-action
327
326
  slot="context-items"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubex/zinc",
3
- "version": "1.1.89",
3
+ "version": "1.1.91",
4
4
  "description": "A collection of web components for building web applications based off of @shoelace-style/Shoelace",
5
5
  "keywords": [
6
6
  "web components",
@@ -14,6 +14,7 @@ import type {PropertyValues} from 'lit';
14
14
  *
15
15
  */
16
16
  export default class ZnAbsoluteContainer extends ZincElement {
17
+ private _resizeFrame: number | null = null;
17
18
 
18
19
  constructor() {
19
20
  super();
@@ -30,12 +31,30 @@ export default class ZnAbsoluteContainer extends ZincElement {
30
31
  this.resize();
31
32
  }
32
33
 
34
+ disconnectedCallback() {
35
+ super.disconnectedCallback();
36
+ if (this._resizeFrame !== null) {
37
+ cancelAnimationFrame(this._resizeFrame);
38
+ this._resizeFrame = null;
39
+ }
40
+ }
41
+
33
42
  resize() {
34
- let newSize = 0;
35
- Array.from(this.children).forEach((child) => {
36
- newSize += child.getBoundingClientRect().height;
43
+ if (this._resizeFrame !== null) {
44
+ return;
45
+ }
46
+ this._resizeFrame = requestAnimationFrame(() => {
47
+ this._resizeFrame = null;
48
+ let newSize = 0;
49
+ Array.from(this.children).forEach((child) => {
50
+ newSize += child.getBoundingClientRect().height;
51
+ });
52
+ const minHeight = newSize + 'px';
53
+ // Guarded write: setting style re-triggers our own MutationController
54
+ if (this.style.minHeight !== minHeight) {
55
+ this.style.minHeight = minHeight;
56
+ }
37
57
  });
38
- this.style.minHeight = newSize + 'px';
39
58
  }
40
59
 
41
60
  // the height of this element is set to the height of its children (absolute positioned)
@@ -120,6 +120,9 @@ export default class ZnInlineEdit extends ZincElement implements ZincFormControl
120
120
  /** The heading shown above the slash menu's items. */
121
121
  @property({ attribute: 'slash-heading' }) slashHeading = 'Insert';
122
122
 
123
+ /** Hides the insertion keys normally shown against the slash menu's items. */
124
+ @property({ attribute: 'slash-hide-keys', type: Boolean }) slashHideKeys = false;
125
+
123
126
  /** Resolves additional slash menu items each time the menu opens. JavaScript only. */
124
127
  @property({ attribute: false }) slashItemsProvider?: (query: string) => SlashMenuItem[] | Promise<SlashMenuItem[]>;
125
128
 
@@ -463,6 +466,7 @@ export default class ZnInlineEdit extends ZincElement implements ZincFormControl
463
466
  slash-trigger="${this.slashTrigger}"
464
467
  slash-heading="${this.slashHeading}"
465
468
  slash-preset="${this.slashPreset}"
469
+ ?slash-hide-keys="${this.slashHideKeys}"
466
470
  .slashItems="${this.slashItems}"
467
471
  .slashItemsProvider="${this.slashItemsProvider}"
468
472
  @zn-input="${this.handleInput}"
@@ -485,6 +489,7 @@ export default class ZnInlineEdit extends ZincElement implements ZincFormControl
485
489
  slash-trigger="${this.slashTrigger}"
486
490
  slash-heading="${this.slashHeading}"
487
491
  slash-preset="${this.slashPreset}"
492
+ ?slash-hide-keys="${this.slashHideKeys}"
488
493
  .slashItems="${this.slashItems}"
489
494
  .slashItemsProvider="${this.slashItemsProvider}"
490
495
  @zn-input="${this.handleInput}"
@@ -279,6 +279,9 @@ export default class ZnInput extends ZincElement implements ZincFormControl {
279
279
  /** The heading shown above the slash menu's items. */
280
280
  @property({attribute: 'slash-heading'}) slashHeading = 'Insert';
281
281
 
282
+ /** Hides the insertion keys normally shown against the slash menu's items. */
283
+ @property({attribute: 'slash-hide-keys', type: Boolean}) slashHideKeys = false;
284
+
282
285
  /**
283
286
  * Resolves additional items each time the menu opens, for lists that come from elsewhere (e.g. an
284
287
  * API). Receives the current query and may return a promise. JavaScript only.
@@ -1097,7 +1100,7 @@ export default class ZnInput extends ZincElement implements ZincFormControl {
1097
1100
  </div>
1098
1101
  ${this.hasSlashMenu
1099
1102
  ? html`
1100
- <zn-slash-menu part="slash-menu" heading=${this.slashHeading}></zn-slash-menu>`
1103
+ <zn-slash-menu part="slash-menu" heading=${this.slashHeading} ?hide-keys=${this.slashHideKeys}></zn-slash-menu>`
1101
1104
  : ''}
1102
1105
  <slot name="slash-menu"></slot>
1103
1106
  <slot name="slash-items" hidden></slot>
@@ -1,4 +1,4 @@
1
- import {type CSSResultGroup, html, unsafeCSS, PropertyValues} from 'lit';
1
+ import {type CSSResultGroup, html, type PropertyValues, unsafeCSS} from 'lit';
2
2
  import {MutationController} from '@lit-labs/observers/mutation-controller.js';
3
3
  import {property, query} from "lit/decorators.js";
4
4
  import {ResizeController} from '@lit-labs/observers/resize-controller.js';
@@ -34,6 +34,9 @@ export default class ZnScrollContainer extends ZincElement {
34
34
  @query('.scroll-footer')
35
35
  private footer: HTMLElement;
36
36
 
37
+ private _footerObserved: boolean = false;
38
+ private _footerHeightFrame: number | null = null;
39
+
37
40
  protected firstUpdated(_changedProperties: PropertyValues) {
38
41
  super.firstUpdated(_changedProperties);
39
42
  if (this.startScrolled && this.container) {
@@ -41,15 +44,34 @@ export default class ZnScrollContainer extends ZincElement {
41
44
  }
42
45
  }
43
46
 
47
+ disconnectedCallback() {
48
+ super.disconnectedCallback();
49
+ if (this._footerHeightFrame !== null) {
50
+ cancelAnimationFrame(this._footerHeightFrame);
51
+ this._footerHeightFrame = null;
52
+ }
53
+ }
54
+
44
55
  scrollEnd() {
45
56
  this.container.scrollTop = this.container.scrollHeight;
46
57
  }
47
58
 
59
+ private _syncFooterHeight() {
60
+ if (this._footerHeightFrame !== null) {
61
+ return;
62
+ }
63
+ this._footerHeightFrame = requestAnimationFrame(() => {
64
+ this._footerHeightFrame = null;
65
+ const height = `${this.footer?.clientHeight ?? 0}px`;
66
+ if (this.style.getPropertyValue('--zn-scroll-footer-height') !== height) {
67
+ this.style.setProperty('--zn-scroll-footer-height', height);
68
+ }
69
+ });
70
+ }
71
+
48
72
  private readonly _footerResizeObserver = new ResizeController(this, {
49
73
  target: null,
50
- callback: () => {
51
- this.style.setProperty('--zn-scroll-footer-height', `${this.footer?.clientHeight ?? 0}px`);
52
- },
74
+ callback: () => this._syncFooterHeight(),
53
75
  });
54
76
 
55
77
  private readonly _domObserver = new MutationController(this, {
@@ -58,8 +80,11 @@ export default class ZnScrollContainer extends ZincElement {
58
80
  callback: () => {
59
81
  setTimeout(() => this.scrollEnd(), 100);
60
82
  if (this.footer) {
61
- this.style.setProperty('--zn-scroll-footer-height', `${this.footer.clientHeight}px`);
62
- this._footerResizeObserver.observe(this.footer);
83
+ this._syncFooterHeight();
84
+ if (!this._footerObserved) {
85
+ this._footerObserved = true;
86
+ this._footerResizeObserver.observe(this.footer);
87
+ }
63
88
  }
64
89
  },
65
90
  });
@@ -65,6 +65,9 @@ export default class ZnSlashMenu extends ZincElement {
65
65
  /** The most items to render at once. Remaining matches are reported in the footer. */
66
66
  @property({attribute: 'max-items', type: Number}) maxItems = 25;
67
67
 
68
+ /** Hides the insertion key (the item's value) normally shown against each item. */
69
+ @property({attribute: 'hide-keys', type: Boolean}) hideKeys = false;
70
+
68
71
  /** The element or caret rect the panel is positioned against. */
69
72
  @property({attribute: false}) anchor: Element | VirtualElement | null = null;
70
73
 
@@ -269,7 +272,7 @@ export default class ZnSlashMenu extends ZincElement {
269
272
 
270
273
  private renderItem(item: SlashMenuItem, index: number, showIcons: boolean) {
271
274
  const isActive = index === this.activeIndex;
272
- const token = item.value && item.value !== item.label && !item.value.includes('\n') ? item.value : '';
275
+ const token = !this.hideKeys && item.value && item.value !== item.label && !item.value.includes('\n') ? item.value : '';
273
276
 
274
277
  return html`
275
278
  <button
@@ -203,6 +203,9 @@ export default class ZnTextarea extends ZincElement implements ZincFormControl {
203
203
  /** The heading shown above the slash menu's items. */
204
204
  @property({attribute: 'slash-heading'}) slashHeading = 'Insert';
205
205
 
206
+ /** Hides the insertion keys normally shown against the slash menu's items. */
207
+ @property({attribute: 'slash-hide-keys', type: Boolean}) slashHideKeys = false;
208
+
206
209
  /**
207
210
  * Resolves additional items each time the menu opens, for lists that come from elsewhere (e.g. an
208
211
  * API). Receives the current query and may return a promise. JavaScript only.
@@ -584,7 +587,7 @@ export default class ZnTextarea extends ZincElement implements ZincFormControl {
584
587
  </div>
585
588
  ${this.hasSlashMenu
586
589
  ? html`
587
- <zn-slash-menu part="slash-menu" heading=${this.slashHeading}></zn-slash-menu>`
590
+ <zn-slash-menu part="slash-menu" heading=${this.slashHeading} ?hide-keys=${this.slashHideKeys}></zn-slash-menu>`
588
591
  : ''}
589
592
  <slot name="slash-menu"></slot>
590
593
  <slot name="slash-items" hidden></slot>
@@ -72,6 +72,9 @@ export default class ZnTranslations extends ZincElement implements ZincFormContr
72
72
  /** The heading shown above the slash menu's items. */
73
73
  @property({attribute: 'slash-heading'}) slashHeading = 'Insert';
74
74
 
75
+ /** Hides the insertion keys normally shown against the slash menu's items. */
76
+ @property({attribute: 'slash-hide-keys', type: Boolean}) slashHideKeys = false;
77
+
75
78
  /** Resolves additional slash menu items each time the menu opens. JavaScript only. */
76
79
  @property({attribute: false}) slashItemsProvider?: (query: string) => SlashMenuItem[] | Promise<SlashMenuItem[]>;
77
80
 
@@ -444,6 +447,7 @@ export default class ZnTranslations extends ZincElement implements ZincFormContr
444
447
  slash-trigger="${this.slashTrigger}"
445
448
  slash-heading="${this.slashHeading}"
446
449
  slash-preset="${this.slashPreset}"
450
+ ?slash-hide-keys="${this.slashHideKeys}"
447
451
  .slashItems="${this.slashItems}"
448
452
  .slashItemsProvider="${this.slashItemsProvider}"
449
453
  @zn-change="${this.handleValueUpdate}"