@nectary/components 0.39.0 → 0.41.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 (142) hide show
  1. package/accordion/index.js +47 -84
  2. package/accordion-item/index.js +30 -53
  3. package/action-menu/index.d.ts +0 -1
  4. package/action-menu/index.js +177 -223
  5. package/action-menu/types.d.ts +8 -18
  6. package/action-menu-option/index.d.ts +1 -0
  7. package/action-menu-option/index.js +52 -62
  8. package/action-menu-option/types.d.ts +9 -0
  9. package/action-menu-option/utils.d.ts +2 -0
  10. package/action-menu-option/utils.js +3 -0
  11. package/alert/index.js +6 -20
  12. package/avatar/index.js +12 -31
  13. package/avatar-badge/index.js +8 -22
  14. package/avatar-status/index.js +1 -1
  15. package/button/index.js +46 -92
  16. package/button/types.d.ts +1 -1
  17. package/card/index.js +21 -59
  18. package/chat-avatar/index.js +8 -22
  19. package/chat-block/index.js +29 -69
  20. package/chat-bubble/index.js +6 -20
  21. package/checkbox/index.js +59 -107
  22. package/chip/index.d.ts +13 -0
  23. package/chip/index.js +140 -0
  24. package/chip/types.d.ts +37 -0
  25. package/color-menu/index.d.ts +14 -0
  26. package/color-menu/index.js +450 -0
  27. package/color-menu/types.d.ts +36 -0
  28. package/color-menu/utils.d.ts +1 -0
  29. package/color-menu/utils.js +15 -0
  30. package/color-swatch/index.d.ts +13 -0
  31. package/color-swatch/index.js +60 -0
  32. package/color-swatch/types.d.ts +11 -0
  33. package/colors.json +61 -49
  34. package/date-picker/index.js +162 -293
  35. package/dialog/index.js +70 -142
  36. package/field/index.js +44 -65
  37. package/file-drop/index.js +123 -200
  38. package/file-picker/index.d.ts +0 -1
  39. package/file-picker/index.js +55 -108
  40. package/file-status/index.js +15 -39
  41. package/help-tooltip/index.js +11 -28
  42. package/horizontal-stepper/index.js +33 -59
  43. package/horizontal-stepper-item/index.js +13 -37
  44. package/icon-button/index.d.ts +1 -0
  45. package/icon-button/index.js +51 -85
  46. package/icon-button/types.d.ts +16 -2
  47. package/icons-channel/notify/index.d.ts +11 -0
  48. package/icons-channel/notify/index.js +4 -0
  49. package/illustrations/create-illustration-class.js +1 -1
  50. package/inline-alert/index.js +29 -81
  51. package/input/index.js +117 -222
  52. package/link/index.js +51 -97
  53. package/list-item/index.js +1 -1
  54. package/package.json +12 -14
  55. package/pagination/index.js +113 -163
  56. package/pop/index.d.ts +11 -0
  57. package/pop/index.js +391 -0
  58. package/pop/types.d.ts +35 -0
  59. package/pop/utils.d.ts +7 -0
  60. package/pop/utils.js +18 -0
  61. package/popover/index.d.ts +1 -0
  62. package/popover/index.js +105 -314
  63. package/popover/types.d.ts +8 -1
  64. package/popover/utils.d.ts +5 -0
  65. package/popover/utils.js +17 -1
  66. package/progress/index.js +9 -28
  67. package/radio/index.js +103 -169
  68. package/radio-option/index.js +28 -48
  69. package/segment/index.js +49 -130
  70. package/segment-collapse/index.js +28 -49
  71. package/segmented-control/index.js +36 -73
  72. package/segmented-control-option/index.js +45 -87
  73. package/segmented-icon-control/index.js +47 -84
  74. package/segmented-icon-control-option/index.js +42 -79
  75. package/select-button/index.d.ts +13 -0
  76. package/select-button/index.js +158 -0
  77. package/select-button/types.d.ts +43 -0
  78. package/select-menu/index.d.ts +11 -0
  79. package/select-menu/index.js +345 -0
  80. package/select-menu/types.d.ts +29 -0
  81. package/{dropdown-text-option → select-menu-option}/index.d.ts +5 -7
  82. package/select-menu-option/index.js +76 -0
  83. package/{select-option → select-menu-option}/types.d.ts +8 -9
  84. package/stop-events/index.js +7 -20
  85. package/table-head-cell/index.js +7 -21
  86. package/tabs/index.js +103 -165
  87. package/tabs-option/index.js +24 -44
  88. package/tag/index.d.ts +0 -1
  89. package/tag/index.js +35 -38
  90. package/tag/types.d.ts +12 -7
  91. package/textarea/index.js +96 -167
  92. package/theme.css +146 -49
  93. package/tile-control/index.js +55 -96
  94. package/tile-control-option/index.js +45 -87
  95. package/time-picker/index.js +216 -368
  96. package/title/index.js +6 -20
  97. package/toast/index.js +32 -70
  98. package/toast-manager/index.js +141 -217
  99. package/toggle/index.js +59 -107
  100. package/tooltip/index.d.ts +2 -0
  101. package/tooltip/index.js +160 -17
  102. package/tooltip/types.d.ts +13 -0
  103. package/tooltip/utils.d.ts +5 -0
  104. package/tooltip/utils.js +25 -1
  105. package/utils/animation.d.ts +17 -0
  106. package/utils/animation.js +142 -0
  107. package/utils/colors.d.ts +5 -0
  108. package/utils/colors.js +5 -0
  109. package/utils/context.d.ts +15 -0
  110. package/utils/context.js +57 -0
  111. package/{utils.d.ts → utils/index.d.ts} +15 -11
  112. package/{utils.js → utils/index.js} +104 -48
  113. package/vertical-stepper/index.js +29 -50
  114. package/vertical-stepper-item/index.js +13 -37
  115. package/dropdown/index.d.ts +0 -12
  116. package/dropdown/index.js +0 -415
  117. package/dropdown/types.d.ts +0 -32
  118. package/dropdown-checkbox-option/index.d.ts +0 -11
  119. package/dropdown-checkbox-option/index.js +0 -88
  120. package/dropdown-checkbox-option/types.d.ts +0 -15
  121. package/dropdown-radio-option/index.d.ts +0 -11
  122. package/dropdown-radio-option/index.js +0 -88
  123. package/dropdown-radio-option/types.d.ts +0 -15
  124. package/dropdown-text-option/index.js +0 -104
  125. package/dropdown-text-option/types.d.ts +0 -16
  126. package/select/index.d.ts +0 -13
  127. package/select/index.js +0 -316
  128. package/select/types.d.ts +0 -53
  129. package/select-option/index.d.ts +0 -11
  130. package/select-option/index.js +0 -8
  131. package/tag/utils.d.ts +0 -5
  132. package/tag/utils.js +0 -6
  133. package/tag-close/index.d.ts +0 -12
  134. package/tag-close/index.js +0 -42
  135. package/tag-close/types.d.ts +0 -5
  136. /package/{dropdown-checkbox-option → chip}/types.js +0 -0
  137. /package/{dropdown-radio-option → color-menu}/types.js +0 -0
  138. /package/{dropdown-text-option → color-swatch}/types.js +0 -0
  139. /package/{dropdown → pop}/types.js +0 -0
  140. /package/{select-option → select-button}/types.js +0 -0
  141. /package/{tag-close → select-menu}/types.js +0 -0
  142. /package/{select → select-menu-option}/types.js +0 -0
@@ -1,14 +1,23 @@
1
1
  import type { TSinchElementReact } from '../types';
2
2
  export declare type TSinchActionMenuOptionElement = HTMLElement & {
3
+ /** Display text */
3
4
  text: string;
5
+ /** Disabled state */
4
6
  disabled: boolean;
7
+ /** Click event */
5
8
  addEventListener(type: '-click', listener: (e: CustomEvent<void>) => void): void;
9
+ /** Display text */
6
10
  setAttribute(name: 'text', value: string): void;
11
+ /** Disabled state */
7
12
  setAttribute(name: 'disabled', value: ''): void;
8
13
  };
9
14
  export declare type TSinchActionMenuOptionReact = TSinchElementReact<TSinchActionMenuOptionElement> & {
15
+ /** Display text */
10
16
  text: string;
17
+ /** Disabled state */
11
18
  disabled?: boolean;
19
+ /** Label that is used for a11y */
12
20
  'aria-label': string;
21
+ /** Click event handler */
13
22
  'on-click'?: (e: CustomEvent<void>) => void;
14
23
  };
@@ -0,0 +1,2 @@
1
+ import type { TSinchActionMenuOptionElement } from './types';
2
+ export declare const isSinchActionMenuOption: (el: EventTarget | null) => el is TSinchActionMenuOptionElement;
@@ -0,0 +1,3 @@
1
+ export const isSinchActionMenuOption = el => {
2
+ return el instanceof Element && el.tagName === 'SINCH-ACTION-MENU-OPTION';
3
+ };
package/alert/index.js CHANGED
@@ -1,12 +1,3 @@
1
- import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
- import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
-
4
- var _$text;
5
-
6
- function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
7
-
8
- function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
9
-
10
1
  import '../icons/report-problem';
11
2
  import '../icons/report';
12
3
  import '../icons/info';
@@ -16,19 +7,14 @@ const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-dire
16
7
  import { assertType, typeValues } from './utils';
17
8
  const template = document.createElement('template');
18
9
  template.innerHTML = templateHTML;
19
- defineCustomElement('sinch-alert', (_$text = new WeakMap(), class extends NectaryElement {
10
+ defineCustomElement('sinch-alert', class extends NectaryElement {
11
+ #$text;
12
+
20
13
  constructor() {
21
14
  super();
22
-
23
- _classPrivateFieldInitSpec(this, _$text, {
24
- writable: true,
25
- value: void 0
26
- });
27
-
28
15
  const shadowRoot = this.attachShadow();
29
16
  shadowRoot.appendChild(template.content.cloneNode(true));
30
-
31
- _classPrivateFieldSet(this, _$text, shadowRoot.querySelector('#text'));
17
+ this.#$text = shadowRoot.querySelector('#text');
32
18
  }
33
19
 
34
20
  connectedCallback() {
@@ -65,10 +51,10 @@ defineCustomElement('sinch-alert', (_$text = new WeakMap(), class extends Nectar
65
51
 
66
52
  case 'text':
67
53
  {
68
- _classPrivateFieldGet(this, _$text).textContent = newVal;
54
+ this.#$text.textContent = newVal;
69
55
  break;
70
56
  }
71
57
  }
72
58
  }
73
59
 
74
- }));
60
+ });
package/avatar/index.js CHANGED
@@ -1,41 +1,22 @@
1
- import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
- import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
-
4
- var _$text, _$image;
5
-
6
- function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
7
-
8
- function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
9
-
10
1
  import { defineCustomElement, getAttribute, getLiteralAttribute, NectaryElement, updateAttribute, updateLiteralAttribute } from '../utils';
11
- const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{position:relative;width:40px;height:40px;font:var(--sinch-font-title-s);line-height:38px;color:var(--sinch-color-text-default);background-color:var(--sinch-color-snow-700);text-align:center;border-radius:50%;border:1px solid var(--sinch-color-snow-100);box-sizing:border-box;text-transform:uppercase;--sinch-avatar-badge-size:16px;--sinch-avatar-badge-font:700 12px/14px "Gilroy","Arial","sans-serif"}:host([background=blue]) #wrapper{background-color:var(--sinch-color-stormy-500);color:var(--sinch-color-snow-100)}:host([background=yellow]) #wrapper{background-color:var(--sinch-color-honey-500)}:host([size="l"]) #wrapper{width:56px;height:56px;font:var(--sinch-font-title-m);line-height:54px;--sinch-avatar-badge-size:20px;--sinch-avatar-badge-font:700 12px/18px "Gilroy","Arial","sans-serif"}:host([size="s"]) #wrapper{width:24px;height:24px;font:var(--sinch-font-extra-small-text);line-height:22px;--sinch-avatar-badge-size:11px;--sinch-avatar-badge-font:500 8px/9px "Gilroy","Arial","sans-serif"}#text{display:block;width:100%;height:100%;box-sizing:border-box}#image{display:none;width:100%;height:100%;object-fit:contain;position:absolute;left:0;top:0;border-radius:50%}:host([src]:not([src=""])) #image{display:block}::slotted(sinch-avatar-badge){position:absolute;top:-2px;left:calc(100% - 15px)}:host([size="l"]) ::slotted(sinch-avatar-badge){left:calc(100% - 19px)}:host([size="s"]) ::slotted(sinch-avatar-badge){left:calc(100% - 9px)}::slotted(sinch-avatar-status){position:absolute;bottom:-2px;right:-2px}:host([size="l"]) ::slotted(sinch-avatar-status){bottom:2px;right:2px}</style><div id="wrapper"><span id="text"></span><img id="image" alt=""/><slot name="badge"></slot><slot name="status"></slot></div>';
2
+ const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{position:relative;width:40px;height:40px;background-color:var(--sinch-color-snow-100);border-radius:50%;--sinch-avatar-badge-size:16px;--sinch-avatar-badge-font:700 12px/14px "Gilroy","Arial","sans-serif"}#circle{position:relative;width:calc(100% - 2px);height:calc(100% - 2px);left:1px;top:1px;border-radius:50%;-webkit-mask:linear-gradient(#fff,#000);mask:linear-gradient(#fff,#000)}#text{display:block;width:100%;height:100%;font:var(--sinch-font-title-s);line-height:38px;text-transform:uppercase;text-align:center;background-color:var(--sinch-color-snow-700);color:var(--sinch-color-text-default)}:host([background=blue]) #text{background-color:var(--sinch-color-stormy-500);color:var(--sinch-color-snow-100)}:host([background=yellow]) #text{background-color:var(--sinch-color-honey-500)}:host([size="l"]) #wrapper{width:56px;height:56px;--sinch-avatar-badge-size:20px;--sinch-avatar-badge-font:700 12px/18px "Gilroy","Arial","sans-serif"}:host([size="l"]) #text{font:var(--sinch-font-title-m);line-height:54px}:host([size="s"]) #wrapper{width:24px;height:24px;--sinch-avatar-badge-size:11px;--sinch-avatar-badge-font:500 8px/9px "Gilroy","Arial","sans-serif"}:host([size="s"]) #text{font:var(--sinch-font-extra-small-text);line-height:22px}#image{display:none;position:absolute;left:0;top:0;width:100%;height:100%;object-fit:contain}:host([src]:not([src=""])) #image{display:block}::slotted(sinch-avatar-badge){position:absolute;top:-1px;left:calc(100% - 16px)}:host([size="l"]) ::slotted(sinch-avatar-badge){left:calc(100% - 20px)}:host([size="s"]) ::slotted(sinch-avatar-badge){left:calc(100% - 10px)}::slotted(sinch-avatar-status){position:absolute;bottom:-1px;right:-1px}:host([size="l"]) ::slotted(sinch-avatar-status){bottom:3px;right:3px}</style><div id="wrapper"><div id="circle"><span id="text"></span><img id="image" alt=""/></div><slot name="badge"></slot><slot name="status"></slot></div>';
12
3
  import { backgroundValues, sizeValues } from './utils';
13
4
  const template = document.createElement('template');
14
5
  template.innerHTML = templateHTML;
15
- defineCustomElement('sinch-avatar', (_$text = new WeakMap(), _$image = new WeakMap(), class extends NectaryElement {
6
+ defineCustomElement('sinch-avatar', class extends NectaryElement {
7
+ #$text;
8
+ #$image;
9
+
16
10
  constructor() {
17
11
  super();
18
-
19
- _classPrivateFieldInitSpec(this, _$text, {
20
- writable: true,
21
- value: void 0
22
- });
23
-
24
- _classPrivateFieldInitSpec(this, _$image, {
25
- writable: true,
26
- value: void 0
27
- });
28
-
29
12
  const shadowRoot = this.attachShadow();
30
13
  shadowRoot.appendChild(template.content.cloneNode(true));
31
-
32
- _classPrivateFieldSet(this, _$text, shadowRoot.querySelector('#text'));
33
-
34
- _classPrivateFieldSet(this, _$image, shadowRoot.querySelector('#image'));
14
+ this.#$text = shadowRoot.querySelector('#text');
15
+ this.#$image = shadowRoot.querySelector('#image');
35
16
  }
36
17
 
37
18
  get src() {
38
- return getAttribute(this, 'src', null);
19
+ return getAttribute(this, 'src');
39
20
  }
40
21
 
41
22
  set src(value) {
@@ -74,17 +55,17 @@ defineCustomElement('sinch-avatar', (_$text = new WeakMap(), _$image = new WeakM
74
55
  switch (name) {
75
56
  case 'alt':
76
57
  {
77
- _classPrivateFieldGet(this, _$text).textContent = newVal;
78
- _classPrivateFieldGet(this, _$image).alt = newVal ?? '';
58
+ this.#$text.textContent = newVal;
59
+ this.#$image.alt = newVal ?? '';
79
60
  break;
80
61
  }
81
62
 
82
63
  case 'src':
83
64
  {
84
- _classPrivateFieldGet(this, _$image).src = newVal ?? '';
65
+ this.#$image.src = newVal ?? '';
85
66
  break;
86
67
  }
87
68
  }
88
69
  }
89
70
 
90
- }));
71
+ });
@@ -1,29 +1,15 @@
1
- import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
- import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
-
4
- var _$text;
5
-
6
- function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
7
-
8
- function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
9
-
10
1
  import { defineCustomElement, getAttribute, NectaryElement, setClass, updateAttribute } from '../utils';
11
- const templateHTML = '<style>:host{display:inline-block;vertical-align:middle}#text{width:var(--sinch-avatar-badge-size);height:var(--sinch-avatar-badge-size);border:1px solid var(--sinch-color-snow-100);border-radius:calc(var(--sinch-avatar-badge-size)/ 2);text-align:center;box-sizing:border-box;color:var(--sinch-color-snow-100);font:var(--sinch-avatar-badge-font);background-color:var(--sinch-color-raspberry-500)}#text.long{width:fit-content;padding:0 calc(var(--sinch-avatar-badge-size)/ 4)}</style><div id="text"></div>';
2
+ const templateHTML = '<style>:host{display:inline-block;vertical-align:middle}#wrapper{width:fit-content;background-color:var(--sinch-color-snow-100);border-radius:calc(var(--sinch-avatar-badge-size)/ 2);padding:1px;box-sizing:border-box}#text{width:calc(var(--sinch-avatar-badge-size) - 2px);height:calc(var(--sinch-avatar-badge-size) - 2px);font:var(--sinch-avatar-badge-font);color:var(--sinch-color-snow-100);text-align:center;background-color:var(--sinch-color-raspberry-500);border-radius:calc(var(--sinch-avatar-badge-size)/ 2 - 1px)}#text.long{width:fit-content;padding:0 calc(var(--sinch-avatar-badge-size)/ 4)}</style><div id="wrapper"><div id="text"></div></div>';
12
3
  const template = document.createElement('template');
13
4
  template.innerHTML = templateHTML;
14
- defineCustomElement('sinch-avatar-badge', (_$text = new WeakMap(), class extends NectaryElement {
5
+ defineCustomElement('sinch-avatar-badge', class extends NectaryElement {
6
+ #$text;
7
+
15
8
  constructor() {
16
9
  super();
17
-
18
- _classPrivateFieldInitSpec(this, _$text, {
19
- writable: true,
20
- value: void 0
21
- });
22
-
23
10
  const shadowRoot = this.attachShadow();
24
11
  shadowRoot.appendChild(template.content.cloneNode(true));
25
-
26
- _classPrivateFieldSet(this, _$text, shadowRoot.querySelector('#text'));
12
+ this.#$text = shadowRoot.querySelector('#text');
27
13
  }
28
14
 
29
15
  get text() {
@@ -42,11 +28,11 @@ defineCustomElement('sinch-avatar-badge', (_$text = new WeakMap(), class extends
42
28
  switch (name) {
43
29
  case 'text':
44
30
  {
45
- _classPrivateFieldGet(this, _$text).textContent = newVal;
46
- setClass(_classPrivateFieldGet(this, _$text), 'long', newVal !== null && newVal.length > 1);
31
+ this.#$text.textContent = newVal;
32
+ setClass(this.#$text, 'long', newVal !== null && newVal.length > 1);
47
33
  break;
48
34
  }
49
35
  }
50
36
  }
51
37
 
52
- }));
38
+ });
@@ -1,5 +1,5 @@
1
1
  import { defineCustomElement, getLiteralAttribute, NectaryElement, updateLiteralAttribute } from '../utils';
2
- const templateHTML = '<style>:host{display:inline-block;vertical-align:middle}#circle{width:10px;height:10px;border:1px solid var(--sinch-color-snow-100);border-radius:50%;box-sizing:border-box}:host([color=grey]) #circle{background-color:var(--sinch-color-snow-600)}:host([color=yellow]) #circle{background-color:var(--sinch-color-honey-500)}:host([color=red]) #circle{background-color:var(--sinch-color-raspberry-500)}:host([color=green]) #circle{background-color:var(--sinch-color-grass-400)}</style><div id="circle"></div>';
2
+ const templateHTML = '<style>:host{display:inline-block;vertical-align:middle}#wrapper{width:10px;height:10px;padding:1px;box-sizing:border-box;border-radius:50%;background-color:var(--sinch-color-snow-100)}#circle{width:8px;height:8px;border-radius:50%}:host([color=grey]) #circle{background-color:var(--sinch-color-snow-600)}:host([color=yellow]) #circle{background-color:var(--sinch-color-honey-500)}:host([color=red]) #circle{background-color:var(--sinch-color-raspberry-500)}:host([color=green]) #circle{background-color:var(--sinch-color-grass-400)}</style><div id="wrapper"><div id="circle"></div></div>';
3
3
  import { assertColor, colorValues } from './utils';
4
4
  const template = document.createElement('template');
5
5
  template.innerHTML = templateHTML;
package/button/index.js CHANGED
@@ -1,105 +1,37 @@
1
- import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
- import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
-
4
- var _$button, _$text, _onButtonClick, _onButtonFocus, _onButtonBlur, _onFocusReactHandler, _onBlurReactHandler, _onClickReactHandler;
5
-
6
- function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
7
-
8
- function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
9
-
10
1
  import { defineCustomElement, getBooleanAttribute, getAttribute, getLiteralAttribute, isAttrTrue, updateBooleanAttribute, updateAttribute, updateLiteralAttribute, NectaryElement, getReactEventHandler } from '../utils';
11
- const templateHTML = '<style>:host{--sinch-button-color-background:var(--sinch-color-tropical-500);--sinch-button-color-background-hover:var(--sinch-color-tropical-400);--sinch-button-color-background-active:var(--sinch-color-tropical-600);--sinch-button-color-background-disabled:var(--sinch-color-tropical-100);--sinch-button-color-border:var(--sinch-color-transparent);--sinch-button-color-border-disabled:var(--sinch-color-transparent);--sinch-button-color-text:var(--sinch-color-snow-100);--sinch-button-color-text-disabled:var(--sinch-color-snow-100);--sinch-button-shape-radius:var(--sinch-shape-radius-l);display:inline-block;vertical-align:middle;outline:0}#button{--sinch-color-icon:var(--sinch-button-color-text);--sinch-color-spinner-bg:var(--sinch-color-tropical-300);--sinch-color-spinner-fg:var(--sinch-color-snow-100)}#button:disabled{--sinch-color-icon:var(--sinch-button-color-text-disabled);--sinch-color-spinner-bg:var(--sinch-color-snow-100);--sinch-color-spinner-fg:var(--sinch-color-tropical-200)}:host([small]:not([small=false])){--sinch-button-shape-radius:var(--sinch-shape-radius-m)}:host([type=secondary]){--sinch-button-color-background:var(--sinch-color-snow-100);--sinch-button-color-background-hover:var(--sinch-color-tropical-100);--sinch-button-color-background-active:var(--sinch-color-tropical-100);--sinch-button-color-background-disabled:var(--sinch-color-snow-100);--sinch-button-color-border:var(--sinch-color-tropical-500);--sinch-button-color-border-disabled:var(--sinch-color-tropical-200);--sinch-button-color-text:var(--sinch-color-tropical-500);--sinch-button-color-text-disabled:var(--sinch-color-tropical-200)}:host([type=secondary])>#button{--sinch-color-spinner-bg:var(--sinch-color-tropical-500);--sinch-color-spinner-fg:var(--sinch-color-tropical-100)}:host([type=secondary]) #button:enabled:active,:host([type=secondary]) #button:enabled:hover{--sinch-color-spinner-fg:var(--sinch-color-tropical-200)}:host([type=secondary]) #button:disabled{--sinch-color-spinner-bg:var(--sinch-color-tropical-200)}:host([type=cta-primary]){--sinch-button-color-background:var(--sinch-color-honey-500);--sinch-button-color-background-hover:var(--sinch-color-honey-400);--sinch-button-color-background-active:var(--sinch-color-honey-600);--sinch-button-color-background-disabled:var(--sinch-color-honey-200);--sinch-button-color-text:var(--sinch-color-stormy-500);--sinch-button-color-text-disabled:var(--sinch-color-stormy-300)}:host([type=cta-primary])>#button{--sinch-color-spinner-bg:var(--sinch-color-honey-700);--sinch-color-spinner-fg:var(--sinch-color-stormy-500)}:host([type=cta-primary])>#button:disabled{--sinch-color-spinner-bg:var(--sinch-color-honey-100);--sinch-color-spinner-fg:var(--sinch-color-stormy-300)}:host([type=cta-secondary]){--sinch-button-color-background:transparent;--sinch-button-color-background-hover:var(--sinch-color-snow-500);--sinch-button-color-background-active:var(--sinch-color-snow-500);--sinch-button-color-background-disabled:transparent;--sinch-button-color-text:var(--sinch-color-stormy-500);--sinch-button-color-text-disabled:var(--sinch-color-stormy-100);--sinch-button-color-border:var(--sinch-color-stormy-500);--sinch-button-color-border-disabled:var(--sinch-color-stormy-100)}:host([type=cta-secondary])>#button{--sinch-color-spinner-bg:var(--sinch-color-snow-700);--sinch-color-spinner-fg:var(--sinch-color-stormy-500)}:host([type=cta-secondary])>#button:disabled{--sinch-color-spinner-bg:var(--sinch-color-snow-500);--sinch-color-spinner-fg:var(--sinch-color-stormy-100)}:host([type=cta-secondary])>#button::before{mix-blend-mode:multiply}:host([type=destructive]){--sinch-button-color-background:var(--sinch-color-snow-100);--sinch-button-color-background-hover:var(--sinch-color-raspberry-100);--sinch-button-color-background-active:var(--sinch-color-raspberry-100);--sinch-button-color-background-disabled:var(--sinch-color-snow-100);--sinch-button-color-text:var(--sinch-color-raspberry-500);--sinch-button-color-text-disabled:var(--sinch-color-raspberry-200);--sinch-button-color-border:var(--sinch-color-raspberry-500);--sinch-button-color-border-disabled:var(--sinch-color-raspberry-200)}:host([type=destructive])>#button{--sinch-color-spinner-bg:var(--sinch-color-raspberry-100);--sinch-color-spinner-fg:var(--sinch-color-raspberry-500)}:host([type=destructive])>#button:enabled:active,:host([type=destructive])>#button:enabled:hover{--sinch-color-spinner-bg:var(--sinch-color-raspberry-200);--sinch-color-spinner-fg:var(--sinch-color-raspberry-500)}:host([type=destructive])>#button:disabled{--sinch-color-spinner-bg:var(--sinch-color-raspberry-100);--sinch-color-spinner-fg:var(--sinch-color-raspberry-200)}#button{all:initial;display:block;position:relative;width:100%;height:48px;font:var(--sinch-font-title-s);color:var(--sinch-button-color-text);cursor:pointer;--sinch-size-icon:24px}#button::before{content:"";position:absolute;left:0;top:0;bottom:0;right:0;border:1px solid var(--sinch-button-color-border);border-radius:var(--sinch-button-shape-radius);background-color:var(--sinch-button-color-background);box-shadow:var(--sinch-elevation-level-1);pointer-events:none}#button:focus-visible::after{position:absolute;content:"";left:-4px;top:-4px;right:-4px;bottom:-4px;border:2px solid var(--sinch-color-aqua-400);border-radius:calc(var(--sinch-button-shape-radius) + 4px);pointer-events:none}@supports not selector(:focus-visible){#button:focus::after{position:absolute;content:"";left:-4px;top:-4px;right:-4px;bottom:-4px;border:2px solid var(--sinch-color-aqua-400);border-radius:calc(var(--sinch-button-shape-radius) + 4px);pointer-events:none}}#button:enabled:hover::before{background-color:var(--sinch-button-color-background-hover)}#button:enabled:active::before{background-color:var(--sinch-button-color-background-active);border-width:2px;box-shadow:var(--sinch-elevation-level-0)}#button:disabled{color:var(--sinch-button-color-text-disabled);cursor:initial}#button:disabled::before{background-color:var(--sinch-button-color-background-disabled);border-color:var(--sinch-button-color-border-disabled)}:host([type=cta-primary])>#button::before,:host([type=primary])>#button::before{border-width:0}#content{position:relative;display:flex;align-items:center;justify-content:center;gap:12px;width:100%;height:100%;padding:0 16px;box-sizing:border-box;pointer-events:none}:host([small]:not([small=false]))>#button{font:var(--sinch-font-title-xs);height:32px;--sinch-size-icon:16px}:host([small]:not([small=false])) #content{padding:0 12px;gap:8px}#text{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;flex-shrink:1;min-width:0}</style><button id="button"><div id="content"><slot name="left-icon"></slot><span id="text"></span><slot name="right-icon"></slot></div></button>';
2
+ const templateHTML = '<style>:host{--sinch-button-color-background:var(--sinch-color-tropical-500);--sinch-button-color-background-hover:var(--sinch-color-tropical-400);--sinch-button-color-background-active:var(--sinch-color-tropical-600);--sinch-button-color-background-disabled:var(--sinch-color-tropical-100);--sinch-button-color-border:var(--sinch-color-transparent);--sinch-button-color-border-disabled:var(--sinch-color-transparent);--sinch-button-color-text:var(--sinch-color-snow-100);--sinch-button-color-text-disabled:var(--sinch-color-snow-100);--sinch-button-shape-radius:var(--sinch-shape-radius-l);display:inline-block;vertical-align:middle;outline:0}#button{--sinch-color-icon:var(--sinch-button-color-text);--sinch-color-spinner-bg:var(--sinch-color-tropical-300);--sinch-color-spinner-fg:var(--sinch-color-snow-100)}#button:disabled{--sinch-color-icon:var(--sinch-button-color-text-disabled);--sinch-color-spinner-bg:var(--sinch-color-snow-100);--sinch-color-spinner-fg:var(--sinch-color-tropical-200)}:host([small]:not([small=false])){--sinch-button-shape-radius:var(--sinch-shape-radius-m)}:host([type=secondary]){--sinch-button-color-background:var(--sinch-color-snow-100);--sinch-button-color-background-hover:var(--sinch-color-tropical-100);--sinch-button-color-background-active:var(--sinch-color-tropical-100);--sinch-button-color-background-disabled:var(--sinch-color-snow-100);--sinch-button-color-border:var(--sinch-color-tropical-500);--sinch-button-color-border-disabled:var(--sinch-color-tropical-200);--sinch-button-color-text:var(--sinch-color-tropical-500);--sinch-button-color-text-disabled:var(--sinch-color-tropical-200)}:host([type=secondary])>#button{--sinch-color-spinner-bg:var(--sinch-color-tropical-500);--sinch-color-spinner-fg:var(--sinch-color-tropical-100)}:host([type=secondary]) #button:enabled:active,:host([type=secondary]) #button:enabled:hover{--sinch-color-spinner-fg:var(--sinch-color-tropical-200)}:host([type=secondary]) #button:disabled{--sinch-color-spinner-bg:var(--sinch-color-tropical-200)}:host([type=cta-primary]){--sinch-button-color-background:var(--sinch-color-honey-500);--sinch-button-color-background-hover:var(--sinch-color-honey-400);--sinch-button-color-background-active:var(--sinch-color-honey-600);--sinch-button-color-background-disabled:var(--sinch-color-honey-200);--sinch-button-color-text:var(--sinch-color-stormy-500);--sinch-button-color-text-disabled:var(--sinch-color-stormy-300)}:host([type=cta-primary])>#button{--sinch-color-spinner-bg:var(--sinch-color-honey-700);--sinch-color-spinner-fg:var(--sinch-color-stormy-500)}:host([type=cta-primary])>#button:disabled{--sinch-color-spinner-bg:var(--sinch-color-honey-100);--sinch-color-spinner-fg:var(--sinch-color-stormy-300)}:host([type=cta-secondary]){--sinch-button-color-background:transparent;--sinch-button-color-background-hover:#F1F3F4;--sinch-button-color-background-active:#E3E6E8;--sinch-button-color-background-disabled:transparent;--sinch-button-color-text:var(--sinch-color-stormy-500);--sinch-button-color-text-disabled:var(--sinch-color-stormy-100);--sinch-button-color-border:var(--sinch-color-stormy-500);--sinch-button-color-border-disabled:var(--sinch-color-stormy-100)}:host([type=cta-secondary])>#button{--sinch-color-spinner-bg:var(--sinch-color-snow-700);--sinch-color-spinner-fg:var(--sinch-color-stormy-500)}:host([type=cta-secondary])>#button:disabled{--sinch-color-spinner-bg:var(--sinch-color-snow-500);--sinch-color-spinner-fg:var(--sinch-color-stormy-100)}:host([type=cta-secondary])>#button::before{mix-blend-mode:multiply}:host([type=destructive]){--sinch-button-color-background:var(--sinch-color-snow-100);--sinch-button-color-background-hover:var(--sinch-color-raspberry-100);--sinch-button-color-background-active:var(--sinch-color-raspberry-100);--sinch-button-color-background-disabled:var(--sinch-color-snow-100);--sinch-button-color-text:var(--sinch-color-raspberry-500);--sinch-button-color-text-disabled:var(--sinch-color-raspberry-200);--sinch-button-color-border:var(--sinch-color-raspberry-500);--sinch-button-color-border-disabled:var(--sinch-color-raspberry-200)}:host([type=destructive])>#button{--sinch-color-spinner-bg:var(--sinch-color-raspberry-100);--sinch-color-spinner-fg:var(--sinch-color-raspberry-500)}:host([type=destructive])>#button:enabled:active,:host([type=destructive])>#button:enabled:hover{--sinch-color-spinner-bg:var(--sinch-color-raspberry-200);--sinch-color-spinner-fg:var(--sinch-color-raspberry-500)}:host([type=destructive])>#button:disabled{--sinch-color-spinner-bg:var(--sinch-color-raspberry-100);--sinch-color-spinner-fg:var(--sinch-color-raspberry-200)}#button{all:initial;display:block;position:relative;width:100%;height:48px;font:var(--sinch-font-title-s);color:var(--sinch-button-color-text);cursor:pointer;--sinch-size-icon:24px}#button::before{content:"";position:absolute;left:0;top:0;bottom:0;right:0;border:1px solid var(--sinch-button-color-border);border-radius:var(--sinch-button-shape-radius);background-color:var(--sinch-button-color-background);box-shadow:var(--sinch-elevation-level-1);pointer-events:none}#button:focus-visible::after{position:absolute;content:"";left:-4px;top:-4px;right:-4px;bottom:-4px;border:2px solid var(--sinch-color-border-focus);border-radius:calc(var(--sinch-button-shape-radius) + 4px);pointer-events:none}@supports not selector(:focus-visible){#button:focus::after{position:absolute;content:"";left:-4px;top:-4px;right:-4px;bottom:-4px;border:2px solid var(--sinch-color-border-focus);border-radius:calc(var(--sinch-button-shape-radius) + 4px);pointer-events:none}}#button:enabled:hover::before{background-color:var(--sinch-button-color-background-hover)}#button:enabled:active::before{background-color:var(--sinch-button-color-background-active);border-width:2px;box-shadow:var(--sinch-elevation-level-0)}#button:disabled{color:var(--sinch-button-color-text-disabled);cursor:initial}#button:disabled::before{background-color:var(--sinch-button-color-background-disabled);border-color:var(--sinch-button-color-border-disabled)}:host([type=cta-primary])>#button::before,:host([type=primary])>#button::before{border-width:0}#content{position:relative;display:flex;align-items:center;justify-content:center;gap:12px;width:100%;height:100%;padding:0 16px;box-sizing:border-box;pointer-events:none}:host([small]:not([small=false]))>#button{font:var(--sinch-font-title-xs);height:32px;--sinch-size-icon:16px}:host([small]:not([small=false])) #content{padding:0 12px;gap:8px}#text{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;flex-shrink:1;min-width:0}</style><button id="button"><div id="content"><slot name="left-icon"></slot><span id="text"></span><slot name="right-icon"></slot></div></button>';
12
3
  import { buttonTypes } from './utils';
13
4
  const template = document.createElement('template');
14
5
  template.innerHTML = templateHTML;
15
- defineCustomElement('sinch-button', (_$button = new WeakMap(), _$text = new WeakMap(), _onButtonClick = new WeakMap(), _onButtonFocus = new WeakMap(), _onButtonBlur = new WeakMap(), _onFocusReactHandler = new WeakMap(), _onBlurReactHandler = new WeakMap(), _onClickReactHandler = new WeakMap(), class extends NectaryElement {
6
+ defineCustomElement('sinch-button', class extends NectaryElement {
7
+ #$button;
8
+ #$text;
9
+
16
10
  constructor() {
17
11
  super();
18
-
19
- _classPrivateFieldInitSpec(this, _$button, {
20
- writable: true,
21
- value: void 0
22
- });
23
-
24
- _classPrivateFieldInitSpec(this, _$text, {
25
- writable: true,
26
- value: void 0
27
- });
28
-
29
- _classPrivateFieldInitSpec(this, _onButtonClick, {
30
- writable: true,
31
- value: () => {
32
- this.dispatchEvent(new CustomEvent('-click'));
33
- }
34
- });
35
-
36
- _classPrivateFieldInitSpec(this, _onButtonFocus, {
37
- writable: true,
38
- value: () => {
39
- this.dispatchEvent(new CustomEvent('-focus'));
40
- }
41
- });
42
-
43
- _classPrivateFieldInitSpec(this, _onButtonBlur, {
44
- writable: true,
45
- value: () => {
46
- this.dispatchEvent(new CustomEvent('-blur'));
47
- }
48
- });
49
-
50
- _classPrivateFieldInitSpec(this, _onFocusReactHandler, {
51
- writable: true,
52
- value: () => {
53
- getReactEventHandler(this, 'on-focus')?.();
54
- }
55
- });
56
-
57
- _classPrivateFieldInitSpec(this, _onBlurReactHandler, {
58
- writable: true,
59
- value: () => {
60
- getReactEventHandler(this, 'on-blur')?.();
61
- }
62
- });
63
-
64
- _classPrivateFieldInitSpec(this, _onClickReactHandler, {
65
- writable: true,
66
- value: e => {
67
- getReactEventHandler(this, 'on-click')?.(e);
68
- }
69
- });
70
-
71
12
  const shadowRoot = this.attachShadow();
72
13
  shadowRoot.appendChild(template.content.cloneNode(true));
73
-
74
- _classPrivateFieldSet(this, _$button, shadowRoot.querySelector('#button'));
75
-
76
- _classPrivateFieldSet(this, _$text, shadowRoot.querySelector('#text'));
14
+ this.#$button = shadowRoot.querySelector('#button');
15
+ this.#$text = shadowRoot.querySelector('#text');
77
16
  }
78
17
 
79
18
  connectedCallback() {
80
19
  this.setAttribute('role', 'button');
81
-
82
- _classPrivateFieldGet(this, _$button).addEventListener('click', _classPrivateFieldGet(this, _onButtonClick));
83
-
84
- _classPrivateFieldGet(this, _$button).addEventListener('focus', _classPrivateFieldGet(this, _onButtonFocus));
85
-
86
- _classPrivateFieldGet(this, _$button).addEventListener('blur', _classPrivateFieldGet(this, _onButtonBlur));
87
-
88
- this.addEventListener('-click', _classPrivateFieldGet(this, _onClickReactHandler));
89
- this.addEventListener('-focus', _classPrivateFieldGet(this, _onFocusReactHandler));
90
- this.addEventListener('-blur', _classPrivateFieldGet(this, _onBlurReactHandler));
20
+ this.#$button.addEventListener('click', this.#onButtonClick);
21
+ this.#$button.addEventListener('focus', this.#onButtonFocus);
22
+ this.#$button.addEventListener('blur', this.#onButtonBlur);
23
+ this.addEventListener('-click', this.#onClickReactHandler);
24
+ this.addEventListener('-focus', this.#onFocusReactHandler);
25
+ this.addEventListener('-blur', this.#onBlurReactHandler);
91
26
  }
92
27
 
93
28
  disconnectedCallback() {
94
- _classPrivateFieldGet(this, _$button).removeEventListener('click', _classPrivateFieldGet(this, _onButtonClick));
95
-
96
- _classPrivateFieldGet(this, _$button).removeEventListener('focus', _classPrivateFieldGet(this, _onButtonFocus));
97
-
98
- _classPrivateFieldGet(this, _$button).removeEventListener('blur', _classPrivateFieldGet(this, _onButtonBlur));
99
-
100
- this.removeEventListener('-click', _classPrivateFieldGet(this, _onClickReactHandler));
101
- this.removeEventListener('-focus', _classPrivateFieldGet(this, _onFocusReactHandler));
102
- this.removeEventListener('-blur', _classPrivateFieldGet(this, _onBlurReactHandler));
29
+ this.#$button.removeEventListener('click', this.#onButtonClick);
30
+ this.#$button.removeEventListener('focus', this.#onButtonFocus);
31
+ this.#$button.removeEventListener('blur', this.#onButtonBlur);
32
+ this.removeEventListener('-click', this.#onClickReactHandler);
33
+ this.removeEventListener('-focus', this.#onFocusReactHandler);
34
+ this.removeEventListener('-blur', this.#onBlurReactHandler);
103
35
  }
104
36
 
105
37
  static get observedAttributes() {
@@ -110,14 +42,14 @@ defineCustomElement('sinch-button', (_$button = new WeakMap(), _$text = new Weak
110
42
  switch (name) {
111
43
  case 'text':
112
44
  {
113
- _classPrivateFieldGet(this, _$text).textContent = newVal;
45
+ this.#$text.textContent = newVal;
114
46
  break;
115
47
  }
116
48
 
117
49
  case 'disabled':
118
50
  {
119
51
  const isDisabled = isAttrTrue(newVal);
120
- _classPrivateFieldGet(this, _$button).disabled = isDisabled;
52
+ this.#$button.disabled = isDisabled;
121
53
  updateBooleanAttribute(this, 'disabled', isDisabled);
122
54
  break;
123
55
  }
@@ -156,12 +88,34 @@ defineCustomElement('sinch-button', (_$button = new WeakMap(), _$text = new Weak
156
88
  return getBooleanAttribute(this, 'small');
157
89
  }
158
90
 
91
+ get focusable() {
92
+ return true;
93
+ }
94
+
159
95
  focus() {
160
- _classPrivateFieldGet(this, _$button).focus();
96
+ this.#$button.focus();
161
97
  }
162
98
 
163
99
  blur() {
164
- _classPrivateFieldGet(this, _$button).blur();
100
+ this.#$button.blur();
165
101
  }
166
102
 
167
- }));
103
+ #onButtonClick = () => {
104
+ this.dispatchEvent(new CustomEvent('-click'));
105
+ };
106
+ #onButtonFocus = () => {
107
+ this.dispatchEvent(new CustomEvent('-focus'));
108
+ };
109
+ #onButtonBlur = () => {
110
+ this.dispatchEvent(new CustomEvent('-blur'));
111
+ };
112
+ #onFocusReactHandler = () => {
113
+ getReactEventHandler(this, 'on-focus')?.();
114
+ };
115
+ #onBlurReactHandler = () => {
116
+ getReactEventHandler(this, 'on-blur')?.();
117
+ };
118
+ #onClickReactHandler = e => {
119
+ getReactEventHandler(this, 'on-click')?.(e);
120
+ };
121
+ });
package/button/types.d.ts CHANGED
@@ -29,7 +29,7 @@ export declare type TSinchButtonReact = TSinchElementReact<TSinchButtonElement>
29
29
  type: TSinchButtonType;
30
30
  /** Text content */
31
31
  text: string;
32
- /** Label that is used for a11y – might be different from `label` */
32
+ /** Label that is used for a11y */
33
33
  'aria-label': string;
34
34
  /** Disabled */
35
35
  disabled?: boolean;
package/card/index.js CHANGED
@@ -1,74 +1,33 @@
1
- import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
- import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
-
4
- var _$text, _$label, _$caption, _$illustrationSlot, _$illustrationSlotWrapper, _onIllustrationSlotChange;
5
-
6
- function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
7
-
8
- function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
9
-
10
1
  import '../title';
11
2
  import '../text';
12
3
  import { defineCustomElement, getBooleanAttribute, getAttribute, updateBooleanAttribute, updateAttribute, setClass, NectaryElement } from '../utils';
13
4
  const templateHTML = '<style>:host{display:block;outline:0}#wrapper{border-radius:var(--sinch-shape-radius-l);border:1px solid var(--sinch-color-snow-700);background-color:var(--sinch-color-snow-100);box-shadow:var(--sinch-elevation-level-0);overflow:hidden}:host(:hover) #wrapper{box-shadow:var(--sinch-elevation-level-1)}#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{color:var(--sinch-color-stormy-300)}#label:empty{display:none}#header{display:flex;flex-direction:row;align-items:center;gap:8px;--sinch-size-icon:48px}#caption{color:var(--sinch-color-stormy-500);flex:1;min-width:0}#description{color:var(--sinch-color-stormy-500);flex:1;min-height:0;max-height:120px;overflow-y:auto}#description:empty{display:none}:host([disabled]:not([disabled=false])) :is(#illustration-wrapper,#description,#header,#label){opacity:.6}slot[name=action]::slotted(*){margin-top:20px;align-self:flex-start;max-width:100%}</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>';
14
5
  const template = document.createElement('template');
15
6
  template.innerHTML = templateHTML;
16
- defineCustomElement('sinch-card', (_$text = new WeakMap(), _$label = new WeakMap(), _$caption = new WeakMap(), _$illustrationSlot = new WeakMap(), _$illustrationSlotWrapper = new WeakMap(), _onIllustrationSlotChange = new WeakMap(), class extends NectaryElement {
7
+ defineCustomElement('sinch-card', class extends NectaryElement {
8
+ #$text;
9
+ #$label;
10
+ #$caption;
11
+ #$illustrationSlot;
12
+ #$illustrationSlotWrapper;
13
+
17
14
  constructor() {
18
15
  super();
19
-
20
- _classPrivateFieldInitSpec(this, _$text, {
21
- writable: true,
22
- value: void 0
23
- });
24
-
25
- _classPrivateFieldInitSpec(this, _$label, {
26
- writable: true,
27
- value: void 0
28
- });
29
-
30
- _classPrivateFieldInitSpec(this, _$caption, {
31
- writable: true,
32
- value: void 0
33
- });
34
-
35
- _classPrivateFieldInitSpec(this, _$illustrationSlot, {
36
- writable: true,
37
- value: void 0
38
- });
39
-
40
- _classPrivateFieldInitSpec(this, _$illustrationSlotWrapper, {
41
- writable: true,
42
- value: void 0
43
- });
44
-
45
- _classPrivateFieldInitSpec(this, _onIllustrationSlotChange, {
46
- writable: true,
47
- value: () => {
48
- setClass(_classPrivateFieldGet(this, _$illustrationSlotWrapper), 'active', _classPrivateFieldGet(this, _$illustrationSlot).assignedElements().length > 0);
49
- }
50
- });
51
-
52
16
  const shadowRoot = this.attachShadow();
53
17
  shadowRoot.appendChild(template.content.cloneNode(true));
54
-
55
- _classPrivateFieldSet(this, _$text, shadowRoot.querySelector('#description'));
56
-
57
- _classPrivateFieldSet(this, _$label, shadowRoot.querySelector('#label'));
58
-
59
- _classPrivateFieldSet(this, _$caption, shadowRoot.querySelector('#caption'));
60
-
61
- _classPrivateFieldSet(this, _$illustrationSlot, shadowRoot.querySelector('slot[name="illustration"]'));
62
-
63
- _classPrivateFieldSet(this, _$illustrationSlotWrapper, shadowRoot.querySelector('#illustration-wrapper'));
18
+ this.#$text = shadowRoot.querySelector('#description');
19
+ this.#$label = shadowRoot.querySelector('#label');
20
+ this.#$caption = shadowRoot.querySelector('#caption');
21
+ this.#$illustrationSlot = shadowRoot.querySelector('slot[name="illustration"]');
22
+ this.#$illustrationSlotWrapper = shadowRoot.querySelector('#illustration-wrapper');
64
23
  }
65
24
 
66
25
  connectedCallback() {
67
- _classPrivateFieldGet(this, _$illustrationSlot).addEventListener('slotchange', _classPrivateFieldGet(this, _onIllustrationSlotChange));
26
+ this.#$illustrationSlot.addEventListener('slotchange', this.#onIllustrationSlotChange);
68
27
  }
69
28
 
70
29
  disconnectedCallback() {
71
- _classPrivateFieldGet(this, _$illustrationSlot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onIllustrationSlotChange));
30
+ this.#$illustrationSlot.removeEventListener('slotchange', this.#onIllustrationSlotChange);
72
31
  }
73
32
 
74
33
  static get observedAttributes() {
@@ -79,19 +38,19 @@ defineCustomElement('sinch-card', (_$text = new WeakMap(), _$label = new WeakMap
79
38
  switch (name) {
80
39
  case 'text':
81
40
  {
82
- _classPrivateFieldGet(this, _$text).textContent = newVal;
41
+ this.#$text.textContent = newVal;
83
42
  break;
84
43
  }
85
44
 
86
45
  case 'label':
87
46
  {
88
- _classPrivateFieldGet(this, _$label).textContent = newVal;
47
+ this.#$label.textContent = newVal;
89
48
  break;
90
49
  }
91
50
 
92
51
  case 'caption':
93
52
  {
94
- updateAttribute(_classPrivateFieldGet(this, _$caption), 'text', newVal);
53
+ updateAttribute(this.#$caption, 'text', newVal);
95
54
  break;
96
55
  }
97
56
  }
@@ -129,4 +88,7 @@ defineCustomElement('sinch-card', (_$text = new WeakMap(), _$label = new WeakMap
129
88
  return getBooleanAttribute(this, 'disabled');
130
89
  }
131
90
 
132
- }));
91
+ #onIllustrationSlotChange = () => {
92
+ setClass(this.#$illustrationSlotWrapper, 'active', this.#$illustrationSlot.assignedElements().length > 0);
93
+ };
94
+ });
@@ -1,30 +1,16 @@
1
- import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
- import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
-
4
- var _$avatar;
5
-
6
- function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
7
-
8
- function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
9
-
10
1
  import '../avatar';
11
2
  import { defineCustomElement, getAttribute, NectaryElement, updateAttribute } from '../utils';
12
3
  const templateHTML = '<style>:host{display:inline-block;vertical-align:middle}sinch-avatar{display:block}</style><sinch-avatar background="blue" size="l"></sinch-avatar>';
13
4
  const template = document.createElement('template');
14
5
  template.innerHTML = templateHTML;
15
- defineCustomElement('sinch-chat-avatar', (_$avatar = new WeakMap(), class extends NectaryElement {
6
+ defineCustomElement('sinch-chat-avatar', class extends NectaryElement {
7
+ #$avatar;
8
+
16
9
  constructor() {
17
10
  super();
18
-
19
- _classPrivateFieldInitSpec(this, _$avatar, {
20
- writable: true,
21
- value: void 0
22
- });
23
-
24
11
  const shadowRoot = this.attachShadow();
25
12
  shadowRoot.appendChild(template.content.cloneNode(true));
26
-
27
- _classPrivateFieldSet(this, _$avatar, shadowRoot.querySelector('sinch-avatar'));
13
+ this.#$avatar = shadowRoot.querySelector('sinch-avatar');
28
14
  }
29
15
 
30
16
  static get observedAttributes() {
@@ -35,20 +21,20 @@ defineCustomElement('sinch-chat-avatar', (_$avatar = new WeakMap(), class extend
35
21
  switch (name) {
36
22
  case 'src':
37
23
  {
38
- updateAttribute(_classPrivateFieldGet(this, _$avatar), 'src', newVal);
24
+ updateAttribute(this.#$avatar, 'src', newVal);
39
25
  break;
40
26
  }
41
27
 
42
28
  case 'alt':
43
29
  {
44
- updateAttribute(_classPrivateFieldGet(this, _$avatar), 'alt', newVal);
30
+ updateAttribute(this.#$avatar, 'alt', newVal);
45
31
  break;
46
32
  }
47
33
  }
48
34
  }
49
35
 
50
36
  get src() {
51
- return getAttribute(this, 'src', null);
37
+ return getAttribute(this, 'src');
52
38
  }
53
39
 
54
40
  set src(value) {
@@ -63,4 +49,4 @@ defineCustomElement('sinch-chat-avatar', (_$avatar = new WeakMap(), class extend
63
49
  updateAttribute(this, 'alt', value);
64
50
  }
65
51
 
66
- }));
52
+ });