@kubex/zinc 1.1.35 → 1.1.36

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubex/zinc",
3
- "version": "1.1.35",
3
+ "version": "1.1.36",
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",
@@ -80,6 +80,9 @@ export default class ZnChatMessage extends ZincElement {
80
80
  /** Marks the message as initiated by an agent (affects styling and grouping). */
81
81
  @property({type: Boolean, reflect: true, attribute: 'agent-initiated'}) agentInitiated = false;
82
82
 
83
+ /** Hides the sender's name in the message header. */
84
+ @property({type: Boolean, reflect: true, attribute: 'hide-sender'}) hideSender = false;
85
+
83
86
  /** Whether any element is assigned to the `attachments` slot — drives the attachments row visibility. */
84
87
  @state() private hasAttachments = false;
85
88
 
@@ -199,7 +202,8 @@ export default class ZnChatMessage extends ZincElement {
199
202
  private renderHeader() {
200
203
  return html`
201
204
  <div part="header" class="message__header">
202
- <span class="message__sender">${this.sender || (this.customerInitiated ? 'Customer' : 'You')}</span>
205
+ ${this.hideSender ? nothing : html`
206
+ <span class="message__sender">${this.sender || (this.customerInitiated ? 'Customer' : 'You')}</span>`}
203
207
  ${this.time ? html`<span class="message__time">${this.getSentTime()}</span>` : nothing}
204
208
  ${this.actionType === 'internal' ? html`
205
209
  <zn-chip type="info">Internal Note</zn-chip>` : nothing}
@@ -15,6 +15,7 @@ interface SettingsContainerFilter {
15
15
  checked: boolean;
16
16
  label: string;
17
17
  itemSelector?: string;
18
+ toggleAttribute?: string;
18
19
  }
19
20
 
20
21
  /**
@@ -56,7 +57,9 @@ export default class ZnSettingsContainer extends ZincElement {
56
57
  config: {childList: true, subtree: true, attributes: true},
57
58
  callback: mutations => {
58
59
  for (const mutation of mutations) {
59
- if (mutation.type === 'attributes' && mutation.attributeName === 'hidden') {
60
+ if (mutation.type === 'attributes' &&
61
+ (mutation.attributeName === 'hidden' ||
62
+ this.filters.some(f => f.toggleAttribute === mutation.attributeName))) {
60
63
  continue;
61
64
  }
62
65
  this.scheduleUpdateFilters();
@@ -159,7 +162,8 @@ export default class ZnSettingsContainer extends ZincElement {
159
162
  const checked = existingChecked.has(attribute) ? !!existingChecked.get(attribute) : defaultChecked;
160
163
  const label = filter.textContent || 'Unnamed Filter';
161
164
  const itemSelector = filter.getAttribute('item-selector') || '*';
162
- nextFilters.push({attribute, checked, label, itemSelector});
165
+ const toggleAttribute = filter.getAttribute('toggle-attribute') || undefined;
166
+ nextFilters.push({attribute, checked, label, itemSelector, toggleAttribute});
163
167
  });
164
168
  this.filters = nextFilters;
165
169
  }
@@ -173,9 +177,18 @@ export default class ZnSettingsContainer extends ZincElement {
173
177
  items = this.querySelectorAll(filter.itemSelector + attrAppend);
174
178
  }
175
179
  items.forEach(item => {
180
+ if (filter.toggleAttribute) {
181
+ if (checked) {
182
+ item.removeAttribute(filter.toggleAttribute);
183
+ } else {
184
+ item.setAttribute(filter.toggleAttribute, 'true');
185
+ }
186
+ return;
187
+ }
188
+
176
189
  if (checked) {
177
190
  const shouldStayHidden = this.filters.some(f => {
178
- if (f.attribute === filter.attribute || f.checked) return false;
191
+ if (f.attribute === filter.attribute || f.checked || f.toggleAttribute) return false;
179
192
  const fAttrAppend = f.attribute === "*" ? `` : `[${f.attribute}]`;
180
193
  let fItems;
181
194
  if (f.itemSelector && f.itemSelector.startsWith('>')) {