@nectary/components 2.2.1 → 2.2.3

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 (71) hide show
  1. package/accordion/index.js +21 -16
  2. package/accordion-item/index.js +9 -17
  3. package/action-menu/index.js +6 -9
  4. package/action-menu-option/index.js +3 -7
  5. package/alert/index.js +12 -12
  6. package/avatar/index.js +26 -23
  7. package/badge/index.js +2 -2
  8. package/button/index.js +6 -4
  9. package/card/index.js +6 -6
  10. package/checkbox/index.js +3 -3
  11. package/chip/index.js +2 -2
  12. package/code-tag/index.js +6 -9
  13. package/color-menu/index.js +10 -17
  14. package/color-menu-option/index.d.ts +0 -1
  15. package/color-menu-option/index.js +2 -6
  16. package/color-swatch/index.js +9 -9
  17. package/date-picker/index.js +0 -3
  18. package/dialog/index.js +16 -10
  19. package/dialog/types.d.ts +2 -0
  20. package/emoji/index.js +3 -0
  21. package/field/index.js +4 -4
  22. package/file-drop/index.js +21 -19
  23. package/file-picker/index.js +18 -18
  24. package/file-status/index.js +8 -5
  25. package/flag/index.js +3 -0
  26. package/help-tooltip/index.d.ts +1 -0
  27. package/help-tooltip/index.js +2 -1
  28. package/horizontal-stepper/index.js +1 -4
  29. package/horizontal-stepper-item/index.js +0 -3
  30. package/icon-button/index.js +5 -6
  31. package/input/index.js +8 -5
  32. package/link/index.js +2 -2
  33. package/package.json +1 -1
  34. package/pagination/index.js +2 -6
  35. package/pop/index.js +5 -4
  36. package/popover/index.js +2 -2
  37. package/progress/index.js +4 -4
  38. package/progress-stepper/index.js +1 -4
  39. package/progress-stepper-item/index.js +5 -5
  40. package/radio/index.js +28 -24
  41. package/radio-option/index.js +12 -34
  42. package/rich-text/index.js +12 -12
  43. package/segment/index.js +5 -2
  44. package/segmented-control/index.js +42 -21
  45. package/segmented-control-option/index.js +23 -30
  46. package/segmented-icon-control/index.js +46 -26
  47. package/segmented-icon-control-option/index.js +25 -32
  48. package/select-button/index.js +3 -4
  49. package/select-menu/index.js +0 -3
  50. package/select-menu-option/index.js +2 -2
  51. package/skeleton/index.js +0 -3
  52. package/spinner/index.js +0 -3
  53. package/table-head-cell/index.js +2 -2
  54. package/table-row/index.js +2 -2
  55. package/tabs/index.js +7 -7
  56. package/tabs-icon-option/index.js +2 -2
  57. package/tabs-option/index.js +2 -2
  58. package/tag/index.js +5 -2
  59. package/text/index.js +5 -2
  60. package/textarea/index.js +12 -6
  61. package/tile-control/index.js +2 -2
  62. package/tile-control-option/index.js +0 -3
  63. package/time-picker/index.js +3 -4
  64. package/title/index.js +4 -4
  65. package/toast/index.js +0 -3
  66. package/toggle/index.js +2 -2
  67. package/tooltip/index.js +1 -1
  68. package/utils/dom.d.ts +1 -0
  69. package/utils/dom.js +5 -2
  70. package/vertical-stepper/index.js +1 -4
  71. package/vertical-stepper-item/index.js +0 -3
@@ -1,9 +1,10 @@
1
- import { defineCustomElement, getAttribute, getBooleanAttribute, unpackCsv, getFirstCsvValue, getReactEventHandler, NectaryElement, updateAttribute, updateBooleanAttribute, updateCsv } from '../utils';
1
+ import { defineCustomElement, getAttribute, getBooleanAttribute, unpackCsv, getFirstCsvValue, getReactEventHandler, NectaryElement, updateAttribute, updateBooleanAttribute, updateCsv, getTargetByAttribute } from '../utils';
2
2
  const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:column;box-sizing:border-box;width:100%;height:100%}::slotted(sinch-accordion-item){flex-shrink:1}</style><div id="wrapper"><slot></slot></div>';
3
3
  const template = document.createElement('template');
4
4
  template.innerHTML = templateHTML;
5
5
  defineCustomElement('sinch-accordion', class extends NectaryElement {
6
6
  #$slot;
7
+ #controller = null;
7
8
  constructor() {
8
9
  super();
9
10
  const shadowRoot = this.attachShadow();
@@ -14,15 +15,20 @@ defineCustomElement('sinch-accordion', class extends NectaryElement {
14
15
  return ['value'];
15
16
  }
16
17
  connectedCallback() {
17
- this.setAttribute('aria-label', 'accordion');
18
- this.#$slot.addEventListener('slotchange', this.#onSlotChange);
19
- this.#$slot.addEventListener('option-change', this.#onOptionChange);
20
- this.addEventListener('-change', this.#onChangeReactHandler);
18
+ this.#controller = new AbortController();
19
+ const {
20
+ signal
21
+ } = this.#controller;
22
+ const options = {
23
+ signal
24
+ };
25
+ this.#$slot.addEventListener('slotchange', this.#onSlotChange, options);
26
+ this.#$slot.addEventListener('click', this.#onOptionClick, options);
27
+ this.addEventListener('-change', this.#onChangeReactHandler, options);
21
28
  }
22
29
  disconnectedCallback() {
23
- this.#$slot.removeEventListener('slotchange', this.#onSlotChange);
24
- this.#$slot.removeEventListener('option-change', this.#onOptionChange);
25
- this.removeEventListener('-change', this.#onChangeReactHandler);
30
+ this.#controller.abort();
31
+ this.#controller = null;
26
32
  }
27
33
  set value(value) {
28
34
  updateAttribute(this, 'value', value);
@@ -37,9 +43,6 @@ defineCustomElement('sinch-accordion', class extends NectaryElement {
37
43
  return getBooleanAttribute(this, 'multiple');
38
44
  }
39
45
  attributeChangedCallback(name, oldVal, newVal) {
40
- if (oldVal === newVal) {
41
- return;
42
- }
43
46
  switch (name) {
44
47
  case 'value':
45
48
  {
@@ -51,11 +54,13 @@ defineCustomElement('sinch-accordion', class extends NectaryElement {
51
54
  #onSlotChange = () => {
52
55
  this.#onValueChange(this.value);
53
56
  };
54
- #onOptionChange = e => {
55
- e.stopPropagation();
56
- const $elem = e.target;
57
- const value = e.detail;
58
- const result = this.multiple ? updateCsv(this.value, value, !getBooleanAttribute($elem, 'data-checked')) : getBooleanAttribute($elem, 'data-checked') ? '' : value;
57
+ #onOptionClick = e => {
58
+ const target = getTargetByAttribute(e, 'value');
59
+ if (target === null || getBooleanAttribute(target, 'disabled')) {
60
+ return;
61
+ }
62
+ const value = getAttribute(target, 'value', '');
63
+ const result = this.multiple ? updateCsv(this.value, value, !getBooleanAttribute(target, 'data-checked')) : getBooleanAttribute(target, 'data-checked') ? '' : value;
59
64
  this.dispatchEvent(new CustomEvent('-change', {
60
65
  detail: result
61
66
  }));
@@ -1,8 +1,8 @@
1
1
  import '../icon';
2
2
  import '../title';
3
3
  import '../text';
4
- import { defineCustomElement, getAttribute, getBooleanAttribute, getLiteralAttribute, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute, updateLiteralAttribute } from '../utils';
5
- const templateHTML = '<style>:host{display:block;outline:0;min-height:48px}#wrapper{display:flex;flex-direction:column;position:relative;width:100%;height:100%;box-sizing:border-box;overflow:hidden;border-bottom:1px solid var(--sinch-comp-accordion-color-default-border-initial)}:host(:last-child)>#wrapper{border-bottom:none}#button{all:initial;cursor:pointer;display:flex;align-items:center;gap:8px;box-sizing:border-box;width:100%;height:48px;padding:12px 8px;--sinch-global-color-icon:var(--sinch-comp-accordion-color-default-icon-initial);--sinch-global-size-icon:var(--sinch-comp-accordion-size-icon)}#button>*{pointer-events:none}#button:disabled{cursor:initial;--sinch-global-color-icon:var(--sinch-comp-accordion-color-disabled-icon-initial)}#button::before{width:8px;height:8px;border-radius:50%;margin-left:2px;margin-right:8px}:host([status=success]) #button::before{content:"";background-color:var(--sinch-comp-accordion-color-default-status-success)}:host([status=warn]) #button::before{content:"";background-color:var(--sinch-comp-accordion-color-default-status-warning)}:host([status=error]) #button::before{content:"";background-color:var(--sinch-comp-accordion-color-default-status-error)}:host([status=info]) #button::before{content:"";background-color:var(--sinch-comp-accordion-color-default-status-info)}#title{flex:1;min-width:0;--sinch-comp-title-font:var(--sinch-comp-accordion-font-title);--sinch-global-color-text:var(--sinch-comp-accordion-color-default-title-initial)}#button:disabled>#title{--sinch-global-color-text:var(--sinch-comp-accordion-color-disabled-title-initial)}#content{display:none;overflow-y:auto;flex-shrink:1;min-height:0;padding:0 8px 18px}#dropdown-icon{transform:rotate(0)}#button[aria-expanded=true]>#dropdown-icon{transform:rotate(180deg)}#button[aria-expanded=true]+#content{display:block}#optional{--sinch-comp-text-font:var(--sinch-comp-accordion-font-optional-text);--sinch-global-color-text:var(--sinch-comp-accordion-color-default-optional-text-initial)}#button:disabled>#optional{--sinch-global-color-text:var(--sinch-comp-accordion-color-disabled-optional-text-initial)}</style><div id="wrapper"><button id="button" aria-controls="content" aria-expanded="false"><slot name="icon"></slot><sinch-title id="title" level="3" type="m" ellipsis></sinch-title><sinch-text id="optional" type="m"></sinch-text><sinch-icon id="dropdown-icon" name="keyboard_arrow_down"></sinch-icon></button><div id="content" role="region" aria-labelledby="button"><slot name="content"></slot></div></div>';
4
+ import { defineCustomElement, getAttribute, getBooleanAttribute, getLiteralAttribute, isAttrEqual, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute, updateLiteralAttribute } from '../utils';
5
+ const templateHTML = '<style>:host{display:block;outline:0;min-height:48px}#wrapper{display:flex;flex-direction:column;position:relative;width:100%;height:100%;box-sizing:border-box;overflow:hidden;border-bottom:1px solid var(--sinch-comp-accordion-color-default-border-initial)}:host(:last-child)>#wrapper{border-bottom:none}#button{all:initial;display:flex;position:relative;align-items:center;gap:8px;box-sizing:border-box;width:100%;height:48px;padding:0 4px 0 8px;cursor:pointer;--sinch-global-color-icon:var(--sinch-comp-accordion-color-default-icon-initial);--sinch-global-size-icon:var(--sinch-comp-accordion-size-icon)}#button>*{pointer-events:none}#button:disabled{cursor:initial;--sinch-global-color-icon:var(--sinch-comp-accordion-color-disabled-icon-initial)}#button:focus-visible::after{content:"";position:absolute;inset:0;border:2px solid var(--sinch-comp-accordion-color-default-outline-focus);pointer-events:none}#status-wrapper{display:none;width:18px;height:24px;padding:8px 8px 8px 2px;box-sizing:border-box}#status{width:8px;height:8px;border-radius:50%}:host([status]:not([status=""])) #status-wrapper{display:block}:host([status=success]) #status{background-color:var(--sinch-comp-accordion-color-default-status-success)}:host([status=warn]) #status{background-color:var(--sinch-comp-accordion-color-default-status-warning)}:host([status=error]) #status{background-color:var(--sinch-comp-accordion-color-default-status-error)}:host([status=info]) #status{background-color:var(--sinch-comp-accordion-color-default-status-info)}#title{flex:1;min-width:0;--sinch-comp-title-font:var(--sinch-comp-accordion-font-title);--sinch-global-color-text:var(--sinch-comp-accordion-color-default-title-initial)}#button:disabled>#title{--sinch-global-color-text:var(--sinch-comp-accordion-color-disabled-title-initial)}#content{display:none;overflow-y:auto;flex-shrink:1;min-height:0;padding:0 8px 12px}#dropdown-icon{transform:rotate(0);will-change:transform;transition:transform .25s ease-in-out}#button[aria-expanded=true]>#dropdown-icon{transform:rotate(180deg)}#button[aria-expanded=true]+#content{display:block}#optional{--sinch-comp-text-font:var(--sinch-comp-accordion-font-optional-text);--sinch-global-color-text:var(--sinch-comp-accordion-color-default-optional-text-initial)}#button:disabled>#optional{--sinch-global-color-text:var(--sinch-comp-accordion-color-disabled-optional-text-initial)}</style><div id="wrapper"><button id="button" aria-controls="content" aria-expanded="false"><div id="status-wrapper"><div id="status"></div></div><slot name="icon"></slot><sinch-title id="title" level="3" type="m" ellipsis></sinch-title><sinch-text id="optional" type="m"></sinch-text><sinch-icon id="dropdown-icon" name="keyboard_arrow_down"></sinch-icon></button><div id="content" role="region" aria-labelledby="button"><slot name="content"></slot></div></div>';
6
6
  import { statusValues } from './utils';
7
7
  const template = document.createElement('template');
8
8
  template.innerHTML = templateHTML;
@@ -12,23 +12,21 @@ defineCustomElement('sinch-accordion-item', class extends NectaryElement {
12
12
  #$optionalText;
13
13
  constructor() {
14
14
  super();
15
- const shadowRoot = this.attachShadow();
15
+ const shadowRoot = this.attachShadow({
16
+ delegatesFocus: true
17
+ });
16
18
  shadowRoot.appendChild(template.content.cloneNode(true));
17
19
  this.#$button = shadowRoot.querySelector('#button');
18
20
  this.#$title = shadowRoot.querySelector('#title');
19
21
  this.#$optionalText = shadowRoot.querySelector('#optional');
20
22
  }
21
- connectedCallback() {
22
- this.#$button.addEventListener('click', this.#onButtonClick);
23
- }
24
- disconnectedCallback() {
25
- this.#$button.removeEventListener('click', this.#onButtonClick);
26
- }
23
+ connectedCallback() {}
24
+ disconnectedCallback() {}
27
25
  static get observedAttributes() {
28
26
  return ['label', 'disabled', 'data-checked', 'optionaltext'];
29
27
  }
30
28
  attributeChangedCallback(name, oldVal, newVal) {
31
- if (oldVal === newVal) {
29
+ if (isAttrEqual(oldVal, newVal)) {
32
30
  return;
33
31
  }
34
32
  switch (name) {
@@ -40,6 +38,7 @@ defineCustomElement('sinch-accordion-item', class extends NectaryElement {
40
38
  case 'disabled':
41
39
  {
42
40
  this.#$button.disabled = isAttrTrue(newVal);
41
+ updateBooleanAttribute(this, name, isAttrTrue(newVal));
43
42
  break;
44
43
  }
45
44
  case 'data-checked':
@@ -84,13 +83,6 @@ defineCustomElement('sinch-accordion-item', class extends NectaryElement {
84
83
  get optionalText() {
85
84
  return getAttribute(this, 'optionaltext');
86
85
  }
87
- #onButtonClick = e => {
88
- e.stopPropagation();
89
- this.dispatchEvent(new CustomEvent('option-change', {
90
- bubbles: true,
91
- detail: this.value
92
- }));
93
- };
94
86
  get focusable() {
95
87
  return true;
96
88
  }
@@ -41,16 +41,7 @@ defineCustomElement('sinch-action-menu', class extends NectaryElement {
41
41
  static get observedAttributes() {
42
42
  return ['rows'];
43
43
  }
44
- set rows(value) {
45
- updateIntegerAttribute(this, 'rows', value);
46
- }
47
- get rows() {
48
- return getIntegerAttribute(this, 'rows', null);
49
- }
50
44
  attributeChangedCallback(name, oldVal, newVal) {
51
- if (oldVal === newVal) {
52
- return;
53
- }
54
45
  switch (name) {
55
46
  case 'rows':
56
47
  {
@@ -62,6 +53,12 @@ defineCustomElement('sinch-action-menu', class extends NectaryElement {
62
53
  }
63
54
  }
64
55
  }
56
+ set rows(value) {
57
+ updateIntegerAttribute(this, 'rows', value);
58
+ }
59
+ get rows() {
60
+ return getIntegerAttribute(this, 'rows', null);
61
+ }
65
62
  #onListboxBlur = () => {
66
63
  this.#selectOption(null);
67
64
  };
@@ -1,5 +1,5 @@
1
1
  import '../text';
2
- import { defineCustomElement, getAttribute, getBooleanAttribute, getReactEventHandler, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
2
+ import { defineCustomElement, getAttribute, getBooleanAttribute, getReactEventHandler, isAttrEqual, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
3
3
  const templateHTML = '<style>:host{display:block;cursor:pointer}:host([disabled]){cursor:initial}#wrapper{all:initial;display:flex;position:relative;box-sizing:border-box;height:40px;width:100%;padding:8px 16px;align-items:center;gap:10px;user-select:none;background-color:var(--sinch-comp-action-menu-color-default-background-initial);--sinch-global-color-text:var(--sinch-comp-action-menu-color-default-text-initial);--sinch-global-color-icon:var(--sinch-comp-action-menu-color-default-icon-initial);--sinch-global-size-icon:var(--sinch-comp-action-menu-size-icon)}:host([data-selected])>#wrapper{background-color:var(--sinch-comp-action-menu-color-default-background-selected)}:host(:hover)>#wrapper{background-color:var(--sinch-comp-action-menu-color-default-background-hover)}:host([disabled])>#wrapper{pointer-events:none;background-color:var(--sinch-comp-action-menu-color-disabled-background-initial);--sinch-global-color-text:var(--sinch-comp-action-menu-color-disabled-text-initial);--sinch-global-color-icon:var(--sinch-comp-action-menu-color-disabled-icon-initial)}#content{flex:1;min-width:0;--sinch-comp-text-font:var(--sinch-comp-action-menu-font-option)}::slotted(*){margin-left:-6px}</style><div id="wrapper" inert><slot name="icon"></slot><sinch-text id="content" type="m" ellipsis></sinch-text></div>';
4
4
  const template = document.createElement('template');
5
5
  template.innerHTML = templateHTML;
@@ -33,7 +33,7 @@ defineCustomElement('sinch-action-menu-option', class ActionMenuOption extends N
33
33
  return ['text', 'disabled', 'data-selected'];
34
34
  }
35
35
  attributeChangedCallback(name, oldVal, newVal) {
36
- if (oldVal === newVal) {
36
+ if (isAttrEqual(oldVal, newVal)) {
37
37
  return;
38
38
  }
39
39
  switch (name) {
@@ -50,11 +50,7 @@ defineCustomElement('sinch-action-menu-option', class ActionMenuOption extends N
50
50
  case 'data-selected':
51
51
  {
52
52
  const isDisabled = getBooleanAttribute(this, 'disabled');
53
- if (isDisabled) {
54
- updateBooleanAttribute(this, 'aria-selected', false);
55
- } else {
56
- updateExplicitBooleanAttribute(this, 'aria-selected', isAttrTrue(newVal));
57
- }
53
+ updateExplicitBooleanAttribute(this, 'aria-selected', isAttrTrue(newVal) && !isDisabled);
58
54
  break;
59
55
  }
60
56
  }
package/alert/index.js CHANGED
@@ -21,18 +21,6 @@ defineCustomElement('sinch-alert', class extends NectaryElement {
21
21
  disconnectedCallback() {
22
22
  super.disconnectedCallback();
23
23
  }
24
- get type() {
25
- return getLiteralAttribute(this, typeValues, 'type');
26
- }
27
- set type(value) {
28
- updateLiteralAttribute(this, typeValues, 'type', value);
29
- }
30
- get text() {
31
- return getAttribute(this, 'text', '');
32
- }
33
- set text(value) {
34
- updateAttribute(this, 'text', value);
35
- }
36
24
  static get observedAttributes() {
37
25
  return ['text'];
38
26
  }
@@ -45,4 +33,16 @@ defineCustomElement('sinch-alert', class extends NectaryElement {
45
33
  }
46
34
  }
47
35
  }
36
+ get type() {
37
+ return getLiteralAttribute(this, typeValues, 'type');
38
+ }
39
+ set type(value) {
40
+ updateLiteralAttribute(this, typeValues, 'type', value);
41
+ }
42
+ get text() {
43
+ return getAttribute(this, 'text', '');
44
+ }
45
+ set text(value) {
46
+ updateAttribute(this, 'text', value);
47
+ }
48
48
  });
package/avatar/index.js CHANGED
@@ -20,6 +20,32 @@ defineCustomElement('sinch-avatar', class extends NectaryElement {
20
20
  super.connectedCallback();
21
21
  this.#updateColor();
22
22
  }
23
+ disconnectedCallback() {
24
+ super.disconnectedCallback();
25
+ }
26
+ static get observedAttributes() {
27
+ return ['alt', 'src', 'color'];
28
+ }
29
+ attributeChangedCallback(name, _, newVal) {
30
+ switch (name) {
31
+ case 'alt':
32
+ {
33
+ this.#$text.textContent = newVal;
34
+ this.#$image.alt = newVal ?? '';
35
+ break;
36
+ }
37
+ case 'src':
38
+ {
39
+ this.#$image.src = newVal ?? '';
40
+ break;
41
+ }
42
+ case 'color':
43
+ {
44
+ this.#updateColor();
45
+ break;
46
+ }
47
+ }
48
+ }
23
49
  get src() {
24
50
  return getAttribute(this, 'src');
25
51
  }
@@ -50,29 +76,6 @@ defineCustomElement('sinch-avatar', class extends NectaryElement {
50
76
  set status(value) {
51
77
  updateLiteralAttribute(this, statusValues, 'status', value);
52
78
  }
53
- static get observedAttributes() {
54
- return ['alt', 'src', 'color'];
55
- }
56
- attributeChangedCallback(name, _, newVal) {
57
- switch (name) {
58
- case 'alt':
59
- {
60
- this.#$text.textContent = newVal;
61
- this.#$image.alt = newVal ?? '';
62
- break;
63
- }
64
- case 'src':
65
- {
66
- this.#$image.src = newVal ?? '';
67
- break;
68
- }
69
- case 'color':
70
- {
71
- this.#updateColor();
72
- break;
73
- }
74
- }
75
- }
76
79
  #updateColor() {
77
80
  if (!this.isDomConnected) {
78
81
  return;
package/badge/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { defineCustomElement, getAttribute, getBooleanAttribute, getLiteralAttribute, getRect, isAttrTrue, NectaryElement, setClass, updateAttribute, updateBooleanAttribute, updateLiteralAttribute } from '../utils';
1
+ import { defineCustomElement, getAttribute, getBooleanAttribute, getLiteralAttribute, getRect, isAttrEqual, isAttrTrue, NectaryElement, setClass, updateAttribute, updateBooleanAttribute, updateLiteralAttribute } from '../utils';
2
2
  import { DEFAULT_SIZE, sizeValues } from '../utils/size';
3
3
  const templateHTML = '<style>:host{display:inline-flex;flex-direction:column;position:relative}#badge-wrapper{position:absolute;left:0;top:0;width:fit-content;border-radius:var(--sinch-comp-badge-shape-radius);padding:1px;pointer-events:none;background-color:var(--sinch-comp-badge-color-border)}#badge{box-sizing:border-box;color:var(--sinch-comp-badge-color-text);background-color:var(--sinch-comp-badge-color-background);width:20px;height:20px;border-radius:var(--sinch-comp-badge-shape-radius)}#badge.long{width:fit-content;padding:0 5px}#text{display:block;width:100%;height:100%;text-align:center;font:var(--sinch-comp-badge-font-size-l);line-height:20px;text-rendering:optimizelegibility}:host([size="m"]) #badge-wrapper{left:calc(100% - 8px);top:-8px}:host([size="m"]) #badge{width:14px;height:14px}:host([size="m"]) #badge.long{width:fit-content;padding:0 3px}:host([size="m"]) #text{font:var(--sinch-comp-badge-font-size-m);line-height:14px}:host([size="s"]) #badge{width:8px;height:8px;padding:0}:host([size="s"]) #text{display:none}:host([hidden]) #badge-wrapper{display:none}</style><slot id="slot"></slot><div id="badge-wrapper"><div id="badge"><span id="text"></span></div></div>';
4
4
  import { modeValues } from './utils';
@@ -30,7 +30,7 @@ defineCustomElement('sinch-badge', class extends NectaryElement {
30
30
  return ['text', 'size', 'mode', 'hidden'];
31
31
  }
32
32
  attributeChangedCallback(name, oldVal, newVal) {
33
- if (oldVal === newVal) {
33
+ if (isAttrEqual(oldVal, newVal)) {
34
34
  return;
35
35
  }
36
36
  switch (name) {
package/button/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { defineCustomElement, getBooleanAttribute, getAttribute, isAttrTrue, updateBooleanAttribute, updateAttribute, NectaryElement, getReactEventHandler, getLiteralAttribute, updateLiteralAttribute, Context, subscribeContext } from '../utils';
1
+ import { defineCustomElement, getBooleanAttribute, getAttribute, isAttrTrue, updateBooleanAttribute, updateAttribute, NectaryElement, getReactEventHandler, getLiteralAttribute, updateLiteralAttribute, Context, subscribeContext, isAttrEqual } from '../utils';
2
2
  import { DEFAULT_SIZE, sizeValues } from '../utils/size';
3
3
  const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0;cursor:pointer}:host([disabled]){cursor:initial}#button{all:initial;display:block;position:relative;width:100%;height:var(--sinch-local-size);user-select:none;--sinch-local-size:var(--sinch-comp-button-size-container-m);--sinch-global-size-icon:var(--sinch-comp-button-size-icon-m);--sinch-local-font:var(--sinch-comp-button-font-size-m-text);--sinch-local-shape-radius:var(--sinch-comp-button-shape-radius-size-m);--sinch-global-color-icon:var(--sinch-local-color-icon)}:host([data-size="l"])>#button{--sinch-local-size:var(--sinch-comp-button-size-container-l);--sinch-global-size-icon:var(--sinch-comp-button-size-icon-l);--sinch-local-shape-radius:var(--sinch-comp-button-shape-radius-size-l);--sinch-local-font:var(--sinch-comp-button-font-size-l-text)}:host([data-size="m"])>#button{--sinch-local-size:var(--sinch-comp-button-size-container-m);--sinch-global-size-icon:var(--sinch-comp-button-size-icon-m);--sinch-local-shape-radius:var(--sinch-comp-button-shape-radius-size-m);--sinch-local-font:var(--sinch-comp-button-font-size-m-text)}:host([data-size="s"])>#button{--sinch-local-size:var(--sinch-comp-button-size-container-s);--sinch-global-size-icon:var(--sinch-comp-button-size-icon-s);--sinch-local-shape-radius:var(--sinch-comp-button-shape-radius-size-s);--sinch-local-font:var(--sinch-comp-button-font-size-s-text)}:host([type=primary])>#button{--sinch-local-color-background:var(--sinch-comp-button-color-primary-default-background-initial);--sinch-local-color-border:var(--sinch-comp-button-color-primary-default-border-initial);--sinch-local-color-text:var(--sinch-comp-button-color-primary-default-text-initial);--sinch-local-color-icon:var(--sinch-comp-button-color-primary-default-icon-initial);--sinch-local-color-outline-focus:var(--sinch-comp-button-color-primary-default-outilne-focus);--sinch-local-shadow:var(--sinch-comp-button-shadow-primary-initial)}:host([type=secondary])>#button{--sinch-local-color-background:var(--sinch-comp-button-color-secondary-default-background-initial);--sinch-local-color-border:var(--sinch-comp-button-color-secondary-default-border-initial);--sinch-local-color-outline-focus:var(--sinch-comp-button-color-secondary-default-outline-focus);--sinch-local-color-text:var(--sinch-comp-button-color-secondary-default-text-initial);--sinch-local-color-icon:var(--sinch-comp-button-color-secondary-default-icon-initial);--sinch-local-shadow:var(--sinch-comp-button-shadow-secondary-initial)}:host([type=tertiary])>#button{--sinch-local-color-background:var(--sinch-comp-button-color-tertiary-default-background-initial);--sinch-local-color-border:var(--sinch-comp-button-color-tertiary-default-border-initial);--sinch-local-color-outline-focus:var(--sinch-comp-button-color-tertiary-default-outline-focus);--sinch-local-color-text:var(--sinch-comp-button-color-tertiary-default-text-initial);--sinch-local-color-icon:var(--sinch-comp-button-color-tertiary-default-icon-initial);--sinch-local-shadow:var(--sinch-comp-button-shadow-tertiary-initial)}:host([type=cta-primary])>#button{--sinch-local-color-background:var(--sinch-comp-button-color-cta-primary-default-background-initial);--sinch-local-color-border:var(--sinch-comp-button-color-cta-primary-default-border-initial);--sinch-local-color-outline-focus:var(--sinch-comp-button-color-cta-primary-default-outline-focus);--sinch-local-color-text:var(--sinch-comp-button-color-cta-primary-default-text-initial);--sinch-local-color-icon:var(--sinch-comp-button-color-cta-primary-default-icon-initial);--sinch-local-shadow:var(--sinch-comp-button-shadow-cta-primary-initial)}:host([type=cta-secondary])>#button{--sinch-local-color-background:var(--sinch-comp-button-color-cta-secondary-default-background-initial);--sinch-local-color-border:var(--sinch-comp-button-color-cta-secondary-default-border-initial);--sinch-local-color-outline-focus:var(--sinch-comp-button-color-cta-secondary-default-outline-focus);--sinch-local-color-text:var(--sinch-comp-button-color-cta-secondary-default-text-initial);--sinch-local-color-icon:var(--sinch-comp-button-color-cta-secondary-default-icon-initial);--sinch-local-shadow:var(--sinch-comp-button-shadow-cta-secondary-initial)}:host([type=destructive])>#button{--sinch-local-color-background:var(--sinch-comp-button-color-danger-default-background-initial);--sinch-local-color-border:var(--sinch-comp-button-color-danger-default-border-initial);--sinch-local-color-text:var(--sinch-comp-button-color-danger-default-text-initial);--sinch-global-color-icon:var(--sinch-comp-button-color-danger-default-icon-initial);--sinch-local-shadow:var(--sinch-comp-button-shadow-danger-initial)}:host([type=primary]:focus-visible)>#button{--sinch-local-shadow:var(--sinch-comp-button-shadow-primary-focus)}:host([type=secondary]:focus-visible)>#button{--sinch-local-shadow:var(--sinch-comp-button-shadow-secondary-focus)}:host([type=tertiary]:focus-visible)>#button{--sinch-local-shadow:var(--sinch-comp-button-shadow-tertiary-focus)}:host([type=cta-primary]:focus-visible)>#button{--sinch-local-shadow:var(--sinch-comp-button-shadow-cta-primary-focus)}:host([type=cta-secondary]:focus-visible)>#button{--sinch-local-shadow:var(--sinch-comp-button-shadow-cta-secondary-focus)}:host([type=destructive]:focus-visible)>#button{--sinch-local-shadow:var(--sinch-comp-button-shadow-danger-focus)}:host([type=primary]:hover)>#button{--sinch-local-color-background:var(--sinch-comp-button-color-primary-default-background-hover);--sinch-local-shadow:var(--sinch-comp-button-shadow-primary-hover)}:host([type=primary]:active)>#button{--sinch-local-color-background:var(--sinch-comp-button-color-primary-default-background-active);--sinch-local-shadow:var(--sinch-comp-button-shadow-primary-active)}:host([type=secondary]:hover)>#button{--sinch-local-color-background:var(--sinch-comp-button-color-secondary-default-background-hover);--sinch-local-shadow:var(--sinch-comp-button-shadow-secondary-hover)}:host([type=secondary]:active)>#button{--sinch-local-color-background:var(--sinch-comp-button-color-secondary-default-background-active);--sinch-local-shadow:var(--sinch-comp-button-shadow-secondary-active)}:host([type=tertiary]:hover)>#button{--sinch-local-color-background:var(--sinch-comp-button-color-tertiary-default-background-hover);--sinch-local-shadow:var(--sinch-comp-button-shadow-tertiary-hover)}:host([type=tertiary]:active)>#button{--sinch-local-color-background:var(--sinch-comp-button-color-tertiary-default-background-active);--sinch-local-shadow:var(--sinch-comp-button-shadow-tertiary-active)}:host([type=cta-primary]:hover)>#button{--sinch-local-color-background:var(--sinch-comp-button-color-cta-primary-default-background-hover);--sinch-local-shadow:var(--sinch-comp-button-shadow-cta-primary-hover)}:host([type=cta-primary]:active)>#button{--sinch-local-color-background:var(--sinch-comp-button-color-cta-primary-default-background-active);--sinch-local-shadow:var(--sinch-comp-button-shadow-cta-primary-active)}:host([type=cta-secondary]:hover)>#button{--sinch-local-color-background:var(--sinch-comp-button-color-cta-secondary-default-background-hover);--sinch-local-shadow:var(--sinch-comp-button-shadow-cta-secondary-hover)}:host([type=cta-secondary]:active)>#button{--sinch-local-color-background:var(--sinch-comp-button-color-cta-secondary-default-background-active);--sinch-local-shadow:var(--sinch-comp-button-shadow-cta-secondary-active)}:host([type=destructive]:hover)>#button{--sinch-local-color-background:var(--sinch-comp-button-color-danger-default-background-hover);--sinch-local-shadow:var(--sinch-comp-button-shadow-danger-hover)}:host([type=destructive]:active)>#button{--sinch-local-color-background:var(--sinch-comp-button-color-danger-default-background-active);--sinch-local-shadow:var(--sinch-comp-button-shadow-danger-active)}:host([type=primary][disabled])>#button{--sinch-local-color-background:var(--sinch-comp-button-color-primary-disabled-background-initial);--sinch-local-color-border:var(--sinch-comp-button-color-primary-disabled-border-initial);--sinch-local-color-text:var(--sinch-comp-button-color-primary-disabled-text-initial);--sinch-global-color-icon:var(--sinch-comp-button-color-primary-disabled-icon-initial);--sinch-local-shadow:var(--sinch-comp-button-shadow-primary-disabled)}:host([type=secondary][disabled])>#button{--sinch-local-color-background:var(--sinch-comp-button-color-secondary-disabled-background-initial);--sinch-local-color-border:var(--sinch-comp-button-color-secondary-disabled-border-initial);--sinch-local-color-text:var(--sinch-comp-button-color-secondary-disabled-text-initial);--sinch-global-color-icon:var(--sinch-comp-button-color-secondary-disabled-icon-initial);--sinch-local-shadow:var(--sinch-comp-button-shadow-secondary-disabled)}:host([type=tertiary][disabled])>#button{--sinch-local-color-background:var(--sinch-comp-button-color-tertiary-disabled-background-initial);--sinch-local-color-border:var(--sinch-comp-button-color-tertiary-disabled-border-initial);--sinch-local-color-text:var(--sinch-comp-button-color-tertiary-disabled-text-initial);--sinch-global-color-icon:var(--sinch-comp-button-color-tertiary-disabled-icon-initial);--sinch-local-shadow:var(--sinch-comp-button-shadow-tertiary-disabled)}:host([type=cta-primary][disabled])>#button{--sinch-local-color-background:var(--sinch-comp-button-color-cta-primary-disabled-background-initial);--sinch-local-color-border:var(--sinch-comp-button-color-cta-primary-disabled-border-initial);--sinch-local-color-text:var(--sinch-comp-button-color-cta-primary-disabled-text-initial);--sinch-global-color-icon:var(--sinch-comp-button-color-cta-primary-disabled-icon-initial);--sinch-local-shadow:var(--sinch-comp-button-shadow-cta-primary-disabled)}:host([type=cta-secondary][disabled])>#button{--sinch-local-color-background:var(--sinch-comp-button-color-cta-secondary-disabled-background-initial);--sinch-local-color-border:var(--sinch-comp-button-color-cta-secondary-disabled-border-initial);--sinch-local-color-text:var(--sinch-comp-button-color-cta-secondary-disabled-text-initial);--sinch-global-color-icon:var(--sinch-comp-button-color-cta-secondary-disabled-icon-initial);--sinch-local-shadow:var(--sinch-comp-button-shadow-cta-secondary-disabled)}:host([type=destructive][disabled])>#button{--sinch-local-color-background:var(--sinch-comp-button-color-danger-disabled-background-initial);--sinch-local-color-border:var(--sinch-comp-button-color-danger-disabled-border-initial);--sinch-local-color-text:var(--sinch-comp-button-color-danger-disabled-text-initial);--sinch-global-color-icon:var(--sinch-comp-button-color-danger-disabled-icon-initial);--sinch-local-shadow:var(--sinch-comp-button-shadow-danger-disabled)}#button::before{content:"";position:absolute;inset:0;background-color:var(--sinch-local-color-background);border:1px solid var(--sinch-local-color-border);border-radius:var(--sinch-local-shape-radius);box-shadow:var(--sinch-local-shadow);pointer-events:none}:host(:not([disabled]):active) #button::before{border-width:2px}:host(:focus-visible) #button::after{position:absolute;content:"";inset:-3px;border:2px solid var(--sinch-local-color-outline-focus);border-radius:calc(var(--sinch-local-shape-radius) + 3px);pointer-events:none}#content{position:relative;display:flex;align-items:center;justify-content:center;gap:.75em;width:100%;height:100%;padding:0 1em;box-sizing:border-box;pointer-events:none}#text{font:var(--sinch-local-font);color:var(--sinch-local-color-text);overflow:hidden;white-space:nowrap;text-overflow:ellipsis;flex-shrink:1;min-width:0}</style><div id="button" inert><div id="content"><slot name="left-icon"></slot><span id="text"></span><slot name="right-icon"></slot></div></div>';
4
4
  import { typeValues } from './utils';
@@ -58,7 +58,10 @@ defineCustomElement('sinch-button', class extends NectaryElement {
58
58
  static get observedAttributes() {
59
59
  return ['text', 'disabled', 'size', 'data-size'];
60
60
  }
61
- attributeChangedCallback(name, _, newVal) {
61
+ attributeChangedCallback(name, oldVal, newVal) {
62
+ if (isAttrEqual(oldVal, newVal)) {
63
+ return;
64
+ }
62
65
  switch (name) {
63
66
  case 'text':
64
67
  {
@@ -67,8 +70,7 @@ defineCustomElement('sinch-button', class extends NectaryElement {
67
70
  }
68
71
  case 'disabled':
69
72
  {
70
- const isDisabled = isAttrTrue(newVal);
71
- updateBooleanAttribute(this, 'disabled', isDisabled);
73
+ updateBooleanAttribute(this, 'disabled', isAttrTrue(newVal));
72
74
  break;
73
75
  }
74
76
  case 'size':
package/card/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import '../title';
2
2
  import '../text';
3
- import { defineCustomElement, getBooleanAttribute, getAttribute, updateAttribute, setClass, NectaryElement, isAttrTrue, getRect } from '../utils';
3
+ import { defineCustomElement, getBooleanAttribute, getAttribute, updateAttribute, setClass, NectaryElement, isAttrTrue, getRect, isAttrEqual, updateBooleanAttribute } from '../utils';
4
4
  const templateHTML = '<style>:host{display:block;outline:0}#wrapper{border-radius:var(--sinch-comp-card-shape-radius);border:1px solid var(--sinch-comp-card-color-white-default-border-initial);background-color:var(--sinch-comp-card-color-white-default-background-initial);box-shadow:var(--sinch-comp-card-shadow-initial);overflow:hidden}:host(:hover) #wrapper{box-shadow:var(--sinch-comp-card-shadow-hover)}#card-body{padding:24px;box-sizing:border-box;display:flex;flex-direction:column;gap:16px}#illustration-wrapper{display:none;overflow:hidden;height:240px}#illustration-wrapper.active{display:block}#label{--sinch-comp-text-font:var(--sinch-comp-card-font-label);--sinch-global-color-text:var(--sinch-comp-card-color-white-default-title-initial)}#label:empty{display:none}#header{display:flex;flex-direction:row;align-items:center;gap:8px;--sinch-global-size-icon:var(--sinch-comp-card-size-icon)}#caption{flex:1;min-width:0;--sinch-comp-title-font:var(--sinch-comp-card-font-title);--sinch-global-color-text:var(--sinch-comp-card-color-white-default-title-initial)}#description{flex:1;min-height:0;max-height:120px;overflow-y:auto;--sinch-comp-text-font:var(--sinch-comp-card-font-description);--sinch-global-color-text:var(--sinch-comp-card-color-white-default-description-initial)}#description:empty{display:none}slot[name=action]::slotted(*){margin-top:20px;align-self:flex-start;max-width:100%}:host([draggable=true]) #header{cursor:grab}</style><div id="wrapper"><div id="illustration-wrapper"><slot name="illustration"></slot></div><div id="card-body"><sinch-text id="label" type="s" emphasized ellipsis></sinch-text><div id="header"><slot name="icon"></slot><sinch-title id="caption" type="m" level="3" ellipsis></sinch-title></div><sinch-text id="description" type="m"></sinch-text><slot name="action"></slot></div></div>';
5
5
  const template = document.createElement('template');
6
6
  template.innerHTML = templateHTML;
@@ -42,8 +42,8 @@ defineCustomElement('sinch-card', class extends NectaryElement {
42
42
  }
43
43
  }
44
44
  disconnectedCallback() {
45
- this.#disableDragging();
46
45
  super.disconnectedCallback();
46
+ this.#disableDragging();
47
47
  this.#controller.abort();
48
48
  this.#controller = null;
49
49
  }
@@ -51,9 +51,6 @@ defineCustomElement('sinch-card', class extends NectaryElement {
51
51
  return ['text', 'label', 'caption', 'draggable'];
52
52
  }
53
53
  attributeChangedCallback(name, oldVal, newVal) {
54
- if (oldVal === newVal) {
55
- return;
56
- }
57
54
  switch (name) {
58
55
  case 'text':
59
56
  {
@@ -72,13 +69,16 @@ defineCustomElement('sinch-card', class extends NectaryElement {
72
69
  }
73
70
  case 'draggable':
74
71
  {
72
+ if (isAttrEqual(oldVal, newVal)) {
73
+ return;
74
+ }
75
75
  const isDraggingEnabled = isAttrTrue(newVal);
76
76
  if (isDraggingEnabled) {
77
77
  this.#enableDraggable();
78
78
  } else {
79
79
  this.#disableDragging();
80
- this.removeAttribute('draggable');
81
80
  }
81
+ updateBooleanAttribute(this, name, isDraggingEnabled);
82
82
  break;
83
83
  }
84
84
  }
package/checkbox/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { defineCustomElement, getAttribute, getBooleanAttribute, getReactEventHandler, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
2
- const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{display:flex;flex-direction:row;box-sizing:border-box;width:100%;--sinch-local-size:24px;--sinch-local-color-background:var(--sinch-comp-checkbox-color-default-background-initial);--sinch-local-color-background-hover:var(--sinch-comp-checkbox-color-default-background-hover);--sinch-local-color-background-active:var(--sinch-comp-checkbox-color-default-background-active);--sinch-local-color-border:var(--sinch-comp-checkbox-color-default-border-initial);--sinch-local-color-border-hover:var(--sinch-comp-checkbox-color-default-border-hover);--sinch-local-color-border-active:var(--sinch-comp-checkbox-color-default-border-active);--sinch-local-color-text:var(--sinch-comp-checkbox-color-default-text-initial)}:host([invalid])>#wrapper{--sinch-local-color-background:var(--sinch-comp-checkbox-color-invalid-background-initial);--sinch-local-color-background-hover:var(--sinch-comp-checkbox-color-invalid-background-hover);--sinch-local-color-background-active:var(--sinch-comp-checkbox-color-invalid-background-active);--sinch-local-color-border:var(--sinch-comp-checkbox-color-invalid-border-initial);--sinch-local-color-border-hover:var(--sinch-comp-checkbox-color-invalid-border-hover);--sinch-local-color-border-active:var(--sinch-comp-checkbox-color-invalid-border-active);--sinch-local-color-text:var(--sinch-comp-checkbox-color-invalid-text-initial)}:host([checked])>#wrapper{--sinch-local-color-background:var(--sinch-comp-checkbox-color-checked-background-initial);--sinch-local-color-background-hover:var(--sinch-comp-checkbox-color-checked-background-hover);--sinch-local-color-background-active:var(--sinch-comp-checkbox-color-checked-background-active);--sinch-local-color-border:var(--sinch-comp-checkbox-color-checked-border-initial);--sinch-local-color-border-hover:var(--sinch-comp-checkbox-color-checked-border-hover);--sinch-local-color-border-active:var(--sinch-comp-checkbox-color-checked-border-active)}:host([disabled])>#wrapper{--sinch-local-color-background:var(--sinch-comp-checkbox-color-disabled-background-initial);--sinch-local-color-border:var(--sinch-comp-checkbox-color-disabled-border-initial);--sinch-local-color-text:var(--sinch-comp-checkbox-color-disabled-text-initial)}:host([disabled][checked])>#wrapper{--sinch-local-color-background:var(--sinch-comp-checkbox-color-checked-disabled-background-initial);--sinch-local-color-border:var(--sinch-comp-checkbox-color-checked-disabled-border-initial)}#checkbox{width:var(--sinch-local-size);height:var(--sinch-local-size);cursor:pointer}:host([disabled]) #checkbox{cursor:initial}#icon-container{position:relative;width:var(--sinch-local-size);height:var(--sinch-local-size);align-self:flex-start}#checkbox::before{content:"";position:absolute;top:0;left:0;width:var(--sinch-local-size);height:var(--sinch-local-size);border:2px solid var(--sinch-comp-checkbox-color-default-outline-focus);border-radius:calc(var(--sinch-comp-checkbox-shape-radius) + 3px);transition:opacity .1s linear;opacity:0;box-sizing:border-box;pointer-events:none}:host(:focus-visible) #checkbox::before{opacity:1}#checkbox::after{content:"";position:absolute;width:18px;height:18px;inset:0;margin:auto;background-color:var(--sinch-local-color-background);border:1px solid var(--sinch-local-color-border);border-radius:var(--sinch-comp-checkbox-shape-radius);transition:background-color .1s linear;box-sizing:border-box;pointer-events:none}:host(:hover:not([disabled])) #checkbox::after{background-color:var(--sinch-local-color-background-hover);border-color:var(--sinch-local-color-border-hover)}:host(:active:not([disabled])) #checkbox::after{background-color:var(--sinch-local-color-background-active);border-color:var(--sinch-local-color-border-active)}#icon-checkmark,#icon-indeterminate{position:absolute;left:4px;top:4px;width:16px;height:16px;transition:opacity .1s linear;opacity:0;pointer-events:none;fill:var(--sinch-sys-color-container-main-default)}:host(:not([indeterminate])[checked]) #icon-checkmark{opacity:1}:host([indeterminate][checked]) #icon-indeterminate{opacity:1}@media (prefers-reduced-motion){#checkbox::after,#checkbox::before,#icon-checkmark,#icon-indeterminate{transition:none}}#label{flex:1;align-self:center;padding-left:7px;font:var(--sinch-comp-checkbox-font-label);color:var(--sinch-local-color-text);cursor:pointer}#label:empty{display:none}:host([disabled]) #label{cursor:initial}</style><div id="wrapper"><div id="icon-container"><div id="checkbox"></div><svg id="icon-checkmark" viewBox="0 0 24 24" aria-hidden="true"><path d="M9 16.17 5.53 12.7a.996.996 0 1 0-1.41 1.41l4.18 4.18c.39.39 1.02.39 1.41 0L20.29 7.71a.996.996 0 1 0-1.41-1.41L9 16.17Z"/></svg><svg id="icon-indeterminate" viewBox="0 0 24 24" aria-hidden="true"><path d="M18 13H6c-.55 0-1-.45-1-1s.45-1 1-1h12c.55 0 1 .45 1 1s-.45 1-1 1Z"/></svg></div><span id="label"></span></div>';
1
+ import { defineCustomElement, getAttribute, getBooleanAttribute, getReactEventHandler, isAttrEqual, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
2
+ const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{display:flex;flex-direction:row;box-sizing:border-box;width:100%;min-height:24px;--sinch-local-color-background:var(--sinch-comp-checkbox-color-default-background-initial);--sinch-local-color-background-hover:var(--sinch-comp-checkbox-color-default-background-hover);--sinch-local-color-background-active:var(--sinch-comp-checkbox-color-default-background-active);--sinch-local-color-border:var(--sinch-comp-checkbox-color-default-border-initial);--sinch-local-color-border-hover:var(--sinch-comp-checkbox-color-default-border-hover);--sinch-local-color-border-active:var(--sinch-comp-checkbox-color-default-border-active);--sinch-local-color-text:var(--sinch-comp-checkbox-color-default-text-initial)}:host([invalid])>#wrapper{--sinch-local-color-background:var(--sinch-comp-checkbox-color-invalid-background-initial);--sinch-local-color-background-hover:var(--sinch-comp-checkbox-color-invalid-background-hover);--sinch-local-color-background-active:var(--sinch-comp-checkbox-color-invalid-background-active);--sinch-local-color-border:var(--sinch-comp-checkbox-color-invalid-border-initial);--sinch-local-color-border-hover:var(--sinch-comp-checkbox-color-invalid-border-hover);--sinch-local-color-border-active:var(--sinch-comp-checkbox-color-invalid-border-active);--sinch-local-color-text:var(--sinch-comp-checkbox-color-invalid-text-initial)}:host([checked])>#wrapper{--sinch-local-color-background:var(--sinch-comp-checkbox-color-checked-background-initial);--sinch-local-color-background-hover:var(--sinch-comp-checkbox-color-checked-background-hover);--sinch-local-color-background-active:var(--sinch-comp-checkbox-color-checked-background-active);--sinch-local-color-border:var(--sinch-comp-checkbox-color-checked-border-initial);--sinch-local-color-border-hover:var(--sinch-comp-checkbox-color-checked-border-hover);--sinch-local-color-border-active:var(--sinch-comp-checkbox-color-checked-border-active)}:host([disabled])>#wrapper{--sinch-local-color-background:var(--sinch-comp-checkbox-color-disabled-background-initial);--sinch-local-color-border:var(--sinch-comp-checkbox-color-disabled-border-initial);--sinch-local-color-text:var(--sinch-comp-checkbox-color-disabled-text-initial)}:host([disabled][checked])>#wrapper{--sinch-local-color-background:var(--sinch-comp-checkbox-color-checked-disabled-background-initial);--sinch-local-color-border:var(--sinch-comp-checkbox-color-checked-disabled-border-initial)}#checkbox{width:18px;height:18px;cursor:pointer}:host([disabled]) #checkbox{cursor:initial}#icon-container{position:relative;width:18px;height:18px;align-self:flex-start;margin-top:3px}#checkbox::before{content:"";position:absolute;inset:-3px;border:2px solid var(--sinch-comp-checkbox-color-default-outline-focus);border-radius:calc(var(--sinch-comp-checkbox-shape-radius) + 3px);transition:opacity .1s linear;opacity:0;box-sizing:border-box;pointer-events:none}:host(:focus-visible) #checkbox::before{opacity:1}#checkbox::after{content:"";position:absolute;width:18px;height:18px;inset:0;margin:auto;background-color:var(--sinch-local-color-background);border:1px solid var(--sinch-local-color-border);border-radius:var(--sinch-comp-checkbox-shape-radius);transition:background-color .1s linear;box-sizing:border-box;pointer-events:none}:host(:hover:not([disabled])) #checkbox::after{background-color:var(--sinch-local-color-background-hover);border-color:var(--sinch-local-color-border-hover)}:host(:active:not([disabled])) #checkbox::after{background-color:var(--sinch-local-color-background-active);border-color:var(--sinch-local-color-border-active)}#icon-checkmark,#icon-indeterminate{position:absolute;left:1px;top:1px;width:16px;height:16px;transition:opacity .1s linear;opacity:0;pointer-events:none;fill:var(--sinch-sys-color-container-main-default)}:host(:not([indeterminate])[checked]) #icon-checkmark{opacity:1}:host([indeterminate][checked]) #icon-indeterminate{opacity:1}@media (prefers-reduced-motion){#checkbox::after,#checkbox::before,#icon-checkmark,#icon-indeterminate{transition:none}}#label{flex:1;align-self:center;padding-left:8px;font:var(--sinch-comp-checkbox-font-label);color:var(--sinch-local-color-text);cursor:pointer}#label:empty{display:none}:host([disabled]) #label{cursor:initial}</style><div id="wrapper"><div id="icon-container"><div id="checkbox"></div><svg id="icon-checkmark" viewBox="0 0 24 24" aria-hidden="true"><path d="M9 16.17 5.53 12.7a.996.996 0 1 0-1.41 1.41l4.18 4.18c.39.39 1.02.39 1.41 0L20.29 7.71a.996.996 0 1 0-1.41-1.41L9 16.17Z"/></svg><svg id="icon-indeterminate" viewBox="0 0 24 24" aria-hidden="true"><path d="M18 13H6c-.55 0-1-.45-1-1s.45-1 1-1h12c.55 0 1 .45 1 1s-.45 1-1 1Z"/></svg></div><span id="label"></span></div>';
3
3
  const template = document.createElement('template');
4
4
  template.innerHTML = templateHTML;
5
5
  defineCustomElement('sinch-checkbox', class extends NectaryElement {
@@ -36,7 +36,7 @@ defineCustomElement('sinch-checkbox', class extends NectaryElement {
36
36
  return ['checked', 'disabled', 'text', 'invalid', 'indeterminate'];
37
37
  }
38
38
  attributeChangedCallback(name, oldVal, newVal) {
39
- if (newVal === oldVal) {
39
+ if (isAttrEqual(oldVal, newVal)) {
40
40
  return;
41
41
  }
42
42
  switch (name) {
package/chip/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import '../text';
2
2
  import '../icon';
3
- import { defineCustomElement, getBooleanAttribute, getAttribute, updateBooleanAttribute, updateAttribute, NectaryElement, getReactEventHandler, isAttrTrue } from '../utils';
3
+ import { defineCustomElement, getBooleanAttribute, getAttribute, updateBooleanAttribute, updateAttribute, NectaryElement, getReactEventHandler, isAttrTrue, isAttrEqual } from '../utils';
4
4
  const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0;cursor:pointer}#button{all:initial;position:relative;display:flex;flex-direction:row;align-items:center;gap:4px;width:100%;height:var(--sinch-comp-chip-size-container-m);padding:0 5px 0 9px;border-radius:var(--sinch-comp-chip-shape-radius);background-color:var(--sinch-comp-chip-color-neutral-default-background-initial);box-sizing:border-box;--sinch-global-color-text:var(--sinch-comp-chip-color-neutral-default-foreground-initial);--sinch-global-color-icon:var(--sinch-comp-chip-color-neutral-default-foreground-initial);--sinch-global-size-icon:var(--sinch-comp-chip-size-icon-m)}:host(:focus-visible)>#button::after{content:"";position:absolute;inset:-4px;border-radius:calc(var(--sinch-comp-chip-shape-radius) + 4px);border:2px solid var(--sinch-comp-chip-color-outiline-focus);pointer-events:none}#text{flex:1;--sinch-comp-text-font:var(--sinch-comp-chip-font-size-m-label)}:host([small]) #button{height:var(--sinch-comp-chip-size-container-s);padding:0 3px 0 7px;--sinch-global-size-icon:var(--sinch-comp-chip-size-icon-s)}:host([small]) #text{--sinch-comp-text-font:var(--sinch-comp-chip-font-size-s-label)}::slotted(*){margin-left:-4px}</style><div id="button" inert><slot name="icon"></slot><sinch-text id="text" type="xs" ellipsis></sinch-text><sinch-icon id="icon-close" name="cancel"></sinch-icon></div>';
5
5
  import { getChipColorBg, getChipColorFg } from './utils';
6
6
  const template = document.createElement('template');
@@ -56,7 +56,7 @@ defineCustomElement('sinch-chip', class extends NectaryElement {
56
56
  return ['text', 'color', 'small'];
57
57
  }
58
58
  attributeChangedCallback(name, oldVal, newVal) {
59
- if (oldVal === newVal) {
59
+ if (isAttrEqual(oldVal, newVal)) {
60
60
  return;
61
61
  }
62
62
  switch (name) {
package/code-tag/index.js CHANGED
@@ -10,19 +10,10 @@ defineCustomElement('sinch-code-tag', class extends NectaryElement {
10
10
  shadowRoot.appendChild(template.content.cloneNode(true));
11
11
  this.#$text = shadowRoot.querySelector('#content');
12
12
  }
13
- get text() {
14
- return getAttribute(this, 'text', '');
15
- }
16
- set text(value) {
17
- updateAttribute(this, 'text', value);
18
- }
19
13
  static get observedAttributes() {
20
14
  return ['text'];
21
15
  }
22
16
  attributeChangedCallback(name, oldVal, newVal) {
23
- if (oldVal === newVal) {
24
- return;
25
- }
26
17
  switch (name) {
27
18
  case 'text':
28
19
  {
@@ -31,4 +22,10 @@ defineCustomElement('sinch-code-tag', class extends NectaryElement {
31
22
  }
32
23
  }
33
24
  }
25
+ get text() {
26
+ return getAttribute(this, 'text', '');
27
+ }
28
+ set text(value) {
29
+ updateAttribute(this, 'text', value);
30
+ }
34
31
  });
@@ -1,4 +1,4 @@
1
- import { attrValueToPixels, defineCustomElement, getAttribute, getBooleanAttribute, getIntegerAttribute, getReactEventHandler, getRect, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute, updateIntegerAttribute, subscribeContext, isTargetEqual } from '../utils';
1
+ import { attrValueToPixels, defineCustomElement, getAttribute, getBooleanAttribute, getIntegerAttribute, getReactEventHandler, getRect, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute, updateIntegerAttribute, subscribeContext, getTargetByAttribute } from '../utils';
2
2
  const templateHTML = '<style>:host{display:block;outline:0}#listbox{display:flex;flex-direction:row;flex-wrap:wrap;padding:4px 10px;overflow-y:auto}#listbox.empty{display:none}</style><div id="listbox" role="presentation"><slot id="options"></slot></div>';
3
3
  const NUM_COLS_DEFAULT = 5;
4
4
  const ITEM_WIDTH = 44;
@@ -34,7 +34,7 @@ defineCustomElement('sinch-color-menu', class extends NectaryElement {
34
34
  this.addEventListener('-change', this.#onChangeReactHandler, options);
35
35
  subscribeContext(this, 'keydown', this.#onContextKeyDown, signal);
36
36
  subscribeContext(this, 'visibility', this.#onContextVisibility, signal);
37
- this.#updateColumns();
37
+ this.#onSlotChange();
38
38
  }
39
39
  disconnectedCallback() {
40
40
  super.disconnectedCallback();
@@ -44,10 +44,7 @@ defineCustomElement('sinch-color-menu', class extends NectaryElement {
44
44
  static get observedAttributes() {
45
45
  return ['value', 'rows', 'cols'];
46
46
  }
47
- attributeChangedCallback(name, oldVal, newVal) {
48
- if (oldVal === newVal) {
49
- return;
50
- }
47
+ attributeChangedCallback(name) {
51
48
  switch (name) {
52
49
  case 'value':
53
50
  {
@@ -129,12 +126,12 @@ defineCustomElement('sinch-color-menu', class extends NectaryElement {
129
126
  this.#selectOption(null);
130
127
  };
131
128
  #onListboxClick = e => {
132
- const $elem = e.target;
133
- if (isTargetEqual(e, this.#$listbox)) {
129
+ const target = getTargetByAttribute(e, 'value');
130
+ if (target === null) {
134
131
  return;
135
132
  }
136
133
  this.focus();
137
- this.#dispatchChangeEvent($elem);
134
+ this.#dispatchChangeEvent(target);
138
135
  };
139
136
  #onContextVisibility = e => {
140
137
  if (e.detail) {
@@ -300,14 +297,10 @@ defineCustomElement('sinch-color-menu', class extends NectaryElement {
300
297
  return null;
301
298
  }
302
299
  #dispatchChangeEvent($opt) {
303
- if ($opt === null) {
304
- return;
305
- }
306
- if ($opt !== null) {
307
- this.dispatchEvent(new CustomEvent('-change', {
308
- detail: getAttribute($opt, 'value')
309
- }));
310
- }
300
+ const value = getAttribute($opt, 'value', '');
301
+ this.dispatchEvent(new CustomEvent('-change', {
302
+ detail: value
303
+ }));
311
304
  }
312
305
  #onChangeReactHandler = e => {
313
306
  getReactEventHandler(this, 'on-change')?.(e);
@@ -1,6 +1,5 @@
1
1
  import '../color-swatch';
2
2
  import '../tooltip';
3
- import '../icon';
4
3
  import type { TSinchColorMenuOptionElement, TSinchColorMenuOptionReact } from './types';
5
4
  declare global {
6
5
  namespace JSX {
@@ -1,9 +1,8 @@
1
1
  import '../color-swatch';
2
2
  import '../tooltip';
3
- import '../icon';
4
3
  import { getSwatchColorFg } from '../color-swatch/utils';
5
4
  import { defineCustomElement, getAttribute, NectaryElement, updateAttribute } from '../utils';
6
- const templateHTML = '<style>:host{display:block;outline:0}#wrapper{width:44px;height:56px;padding:12px 6px;box-sizing:border-box}#swatch-wrapper{position:relative;cursor:pointer;width:32px;height:32px}#swatch-wrapper::after{content:"";position:absolute;width:34px;height:34px;inset:-3px;border:2px solid transparent;border-radius:50%;pointer-events:none}:host([data-selected]:not([data-checked])) #swatch-wrapper::after{border-color:var(--sinch-comp-color-swatch-color-outline-focus)}#check{display:none;position:absolute;left:4px;top:4px;pointer-events:none;--sinch-global-size-icon:24px}:host([data-checked]) #check{display:block}</style><div id="wrapper"><sinch-tooltip id="tooltip"><div id="swatch-wrapper"><sinch-color-swatch id="swatch"></sinch-color-swatch><sinch-icon id="check" name="check"></sinch-icon></div></sinch-tooltip></div>';
5
+ const templateHTML = '<style>:host{display:block;outline:0}#wrapper{width:44px;height:56px;padding:12px 6px;box-sizing:border-box}#swatch-wrapper{position:relative;cursor:pointer;width:32px;height:32px}#swatch-wrapper::after{content:"";position:absolute;width:34px;height:34px;inset:-3px;border:2px solid var(--sinch-comp-color-menu-option-color-default-border-initial);border-radius:50%;pointer-events:none}:host([data-checked]) #swatch-wrapper::after{border-color:var(--sinch-comp-color-menu-option-color-default-border-selected)}:host([data-selected]) #swatch-wrapper::after{border-color:var(--sinch-comp-color-menu-option-color-default-border-focus)}:host(:hover) #swatch-wrapper::after{border-color:var(--sinch-comp-color-menu-option-color-default-border-hover)}:host(:active) #swatch-wrapper::after{border-color:var(--sinch-comp-color-menu-option-color-default-border-active)}</style><div id="wrapper"><sinch-tooltip id="tooltip"><div id="swatch-wrapper"><sinch-color-swatch id="swatch"></sinch-color-swatch></div></sinch-tooltip></div>';
7
6
  const template = document.createElement('template');
8
7
  template.innerHTML = templateHTML;
9
8
  defineCustomElement('sinch-color-menu-option', class extends NectaryElement {
@@ -25,10 +24,7 @@ defineCustomElement('sinch-color-menu-option', class extends NectaryElement {
25
24
  static get observedAttributes() {
26
25
  return ['value'];
27
26
  }
28
- attributeChangedCallback(name, oldVal, newVal) {
29
- if (oldVal === newVal) {
30
- return;
31
- }
27
+ attributeChangedCallback(name, _, newVal) {
32
28
  switch (name) {
33
29
  case 'value':
34
30
  {