@nectary/components 0.34.0 → 0.36.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 (105) hide show
  1. package/accordion/index.js +35 -10
  2. package/accordion/types.d.ts +3 -2
  3. package/accordion-item/index.js +8 -4
  4. package/action-menu/index.js +7 -8
  5. package/action-menu/types.d.ts +3 -3
  6. package/action-menu-option/index.js +23 -3
  7. package/action-menu-option/types.d.ts +2 -0
  8. package/alert/index.d.ts +4 -0
  9. package/alert/index.js +17 -32
  10. package/alert/types.d.ts +1 -7
  11. package/alert/utils.d.ts +3 -0
  12. package/alert/utils.js +6 -1
  13. package/avatar/index.js +1 -1
  14. package/button/index.js +69 -5
  15. package/button/types.d.ts +6 -0
  16. package/checkbox/index.js +64 -6
  17. package/checkbox/types.d.ts +8 -2
  18. package/date-picker/index.js +37 -12
  19. package/date-picker/types.d.ts +4 -2
  20. package/dialog/index.js +5 -6
  21. package/dialog/types.d.ts +3 -3
  22. package/dropdown/index.js +44 -28
  23. package/dropdown/types.d.ts +6 -4
  24. package/dropdown-checkbox-option/index.js +1 -1
  25. package/dropdown-checkbox-option/types.d.ts +0 -2
  26. package/dropdown-radio-option/index.js +1 -1
  27. package/dropdown-radio-option/types.d.ts +0 -2
  28. package/dropdown-text-option/index.js +1 -1
  29. package/dropdown-text-option/types.d.ts +0 -2
  30. package/horizontal-stepper/types.d.ts +4 -0
  31. package/horizontal-stepper-item/index.js +1 -1
  32. package/horizontal-stepper-item/types.d.ts +9 -0
  33. package/icon-button/index.js +75 -5
  34. package/icon-button/types.d.ts +6 -0
  35. package/icons/create-icon-class.js +1 -1
  36. package/icons-branded/create-icon-class.js +3 -7
  37. package/icons-branded/types.d.ts +3 -0
  38. package/icons-channel/create-icon-class.js +3 -7
  39. package/icons-channel/types.d.ts +3 -0
  40. package/inline-alert/index.d.ts +17 -0
  41. package/inline-alert/index.js +154 -0
  42. package/inline-alert/types.d.ts +15 -0
  43. package/inline-alert/utils.d.ts +5 -0
  44. package/inline-alert/utils.js +6 -0
  45. package/input/index.d.ts +0 -1
  46. package/input/index.js +58 -5
  47. package/input/types.d.ts +8 -2
  48. package/link/index.js +81 -3
  49. package/link/types.d.ts +9 -0
  50. package/package.json +1 -1
  51. package/pagination/index.js +24 -8
  52. package/pagination/types.d.ts +3 -1
  53. package/popover/index.js +5 -6
  54. package/popover/types.d.ts +4 -3
  55. package/radio/index.js +36 -8
  56. package/radio/types.d.ts +3 -1
  57. package/radio-option/index.js +1 -1
  58. package/search/types.d.ts +0 -1
  59. package/segment-collapse/index.js +28 -12
  60. package/segment-collapse/types.d.ts +3 -1
  61. package/segmented-control/index.js +28 -23
  62. package/segmented-control/types.d.ts +3 -2
  63. package/segmented-control-option/index.js +59 -13
  64. package/segmented-control-option/types.d.ts +4 -0
  65. package/segmented-icon-control/index.js +27 -16
  66. package/segmented-icon-control/types.d.ts +5 -2
  67. package/segmented-icon-control-option/index.js +54 -12
  68. package/segmented-icon-control-option/types.d.ts +4 -0
  69. package/select/index.js +68 -9
  70. package/select/types.d.ts +8 -2
  71. package/tabs/index.js +32 -8
  72. package/tabs/types.d.ts +3 -2
  73. package/tabs-option/index.js +2 -2
  74. package/text/index.js +1 -1
  75. package/textarea/index.js +58 -4
  76. package/textarea/types.d.ts +7 -2
  77. package/tile-control/index.d.ts +11 -0
  78. package/tile-control/index.js +181 -0
  79. package/tile-control/types.d.ts +38 -0
  80. package/tile-control/types.js +1 -0
  81. package/tile-control-option/index.d.ts +11 -0
  82. package/tile-control-option/index.js +161 -0
  83. package/tile-control-option/types.d.ts +37 -0
  84. package/time-picker/index.js +18 -4
  85. package/time-picker/types.d.ts +4 -2
  86. package/toggle/index.js +63 -5
  87. package/toggle/types.d.ts +3 -1
  88. package/vertical-stepper/index.d.ts +13 -0
  89. package/vertical-stepper/index.js +95 -0
  90. package/vertical-stepper/types.d.ts +13 -0
  91. package/vertical-stepper/types.js +1 -0
  92. package/vertical-stepper-item/index.d.ts +13 -0
  93. package/vertical-stepper-item/index.js +100 -0
  94. package/vertical-stepper-item/types.d.ts +24 -0
  95. package/vertical-stepper-item/types.js +1 -0
  96. package/vertical-stepper-item/utils.d.ts +2 -0
  97. package/vertical-stepper-item/utils.js +1 -0
  98. package/alert-button/index.d.ts +0 -11
  99. package/alert-button/index.js +0 -59
  100. package/alert-button/types.d.ts +0 -8
  101. package/alert-close/index.d.ts +0 -12
  102. package/alert-close/index.js +0 -38
  103. package/alert-close/types.d.ts +0 -3
  104. /package/{alert-button → inline-alert}/types.js +0 -0
  105. /package/{alert-close → tile-control-option}/types.js +0 -0
@@ -1,7 +1,7 @@
1
- import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
2
1
  import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
+ import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
3
 
4
- var _$slot, _onSlotChange, _onOptionChange, _onValueChange;
4
+ var _$slot, _onSlotChange, _onOptionChange, _onValueChange, _onChangeReactHandler;
5
5
 
6
6
  function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
7
7
 
@@ -11,11 +11,11 @@ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollect
11
11
 
12
12
  function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
13
13
 
14
- import { defineCustomElement, getAttribute, getBooleanAttribute, getCsvSet, getFirstCsvValue, NectaryElement, updateAttribute, updateBooleanAttribute, updateCsv } from '../utils';
14
+ import { defineCustomElement, getAttribute, getBooleanAttribute, getCsvSet, getFirstCsvValue, getReactEventHandler, NectaryElement, updateAttribute, updateBooleanAttribute, updateCsv } from '../utils';
15
15
  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>';
16
16
  const template = document.createElement('template');
17
17
  template.innerHTML = templateHTML;
18
- defineCustomElement('sinch-accordion', (_$slot = new WeakMap(), _onSlotChange = new WeakMap(), _onOptionChange = new WeakMap(), _onValueChange = new WeakSet(), class extends NectaryElement {
18
+ defineCustomElement('sinch-accordion', (_$slot = new WeakMap(), _onSlotChange = new WeakMap(), _onOptionChange = new WeakMap(), _onValueChange = new WeakSet(), _onChangeReactHandler = new WeakMap(), class extends NectaryElement {
19
19
  constructor() {
20
20
  super();
21
21
 
@@ -39,21 +39,28 @@ defineCustomElement('sinch-accordion', (_$slot = new WeakMap(), _onSlotChange =
39
39
  e.stopPropagation();
40
40
  const $elem = e.target;
41
41
  const value = e.detail;
42
- const result = this.multiple ? updateCsv(this.value, value, !getBooleanAttribute($elem, 'checked')) : getBooleanAttribute($elem, 'checked') ? '' : value;
42
+ const result = this.multiple ? updateCsv(this.value, value, !getBooleanAttribute($elem, 'data-checked')) : getBooleanAttribute($elem, 'data-checked') ? '' : value;
43
43
  this.dispatchEvent(new CustomEvent('change', {
44
44
  detail: result,
45
45
  bubbles: true
46
46
  }));
47
+ this.dispatchEvent(new CustomEvent('-change', {
48
+ detail: result
49
+ }));
50
+ }
51
+ });
52
+
53
+ _classPrivateFieldInitSpec(this, _onChangeReactHandler, {
54
+ writable: true,
55
+ value: e => {
56
+ getReactEventHandler(this, 'on-change')?.(e);
47
57
  }
48
58
  });
49
59
 
50
60
  const shadowRoot = this.attachShadow();
51
61
  shadowRoot.appendChild(template.content.cloneNode(true));
52
- shadowRoot.addEventListener('change', _classPrivateFieldGet(this, _onOptionChange));
53
62
 
54
63
  _classPrivateFieldSet(this, _$slot, shadowRoot.querySelector('slot'));
55
-
56
- _classPrivateFieldGet(this, _$slot).addEventListener('slotchange', _classPrivateFieldGet(this, _onSlotChange));
57
64
  }
58
65
 
59
66
  static get observedAttributes() {
@@ -62,6 +69,20 @@ defineCustomElement('sinch-accordion', (_$slot = new WeakMap(), _onSlotChange =
62
69
 
63
70
  connectedCallback() {
64
71
  this.setAttribute('aria-label', 'accordion');
72
+
73
+ _classPrivateFieldGet(this, _$slot).addEventListener('slotchange', _classPrivateFieldGet(this, _onSlotChange));
74
+
75
+ _classPrivateFieldGet(this, _$slot).addEventListener('option-change', _classPrivateFieldGet(this, _onOptionChange));
76
+
77
+ this.addEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
78
+ }
79
+
80
+ disconnectedCallback() {
81
+ _classPrivateFieldGet(this, _$slot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onSlotChange));
82
+
83
+ _classPrivateFieldGet(this, _$slot).removeEventListener('option-change', _classPrivateFieldGet(this, _onOptionChange));
84
+
85
+ this.removeEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
65
86
  }
66
87
 
67
88
  get nodeName() {
@@ -85,6 +106,10 @@ defineCustomElement('sinch-accordion', (_$slot = new WeakMap(), _onSlotChange =
85
106
  }
86
107
 
87
108
  attributeChangedCallback(name, oldVal, newVal) {
109
+ if (oldVal === newVal) {
110
+ return;
111
+ }
112
+
88
113
  switch (name) {
89
114
  case 'value':
90
115
  {
@@ -103,14 +128,14 @@ function _onValueChange2(csv) {
103
128
 
104
129
  for (const $option of _classPrivateFieldGet(this, _$slot).assignedElements()) {
105
130
  const isChecked = !getBooleanAttribute($option, 'disabled') && values.has(getAttribute($option, 'value', ''));
106
- updateBooleanAttribute($option, 'checked', isChecked);
131
+ updateBooleanAttribute($option, 'data-checked', isChecked);
107
132
  }
108
133
  } else {
109
134
  const value = getFirstCsvValue(csv);
110
135
 
111
136
  for (const $option of _classPrivateFieldGet(this, _$slot).assignedElements()) {
112
137
  const isChecked = !getBooleanAttribute($option, 'disabled') && value === getAttribute($option, 'value', '');
113
- updateBooleanAttribute($option, 'checked', isChecked);
138
+ updateBooleanAttribute($option, 'data-checked', isChecked);
114
139
  }
115
140
  }
116
141
  }
@@ -3,12 +3,13 @@ import type { SyntheticEvent } from 'react';
3
3
  export declare type TSinchAccordionElement = HTMLElement & {
4
4
  value: string;
5
5
  multiple: boolean;
6
- addEventListener(type: 'change', listener: (e: CustomEvent<string>) => void): void;
6
+ addEventListener(type: '-change', listener: (e: CustomEvent<string>) => void): void;
7
7
  setAttribute(name: 'value', value: string): void;
8
8
  setAttribute(name: 'multiple', value: ''): void;
9
9
  };
10
10
  export declare type TSinchAccordionReact = TSinchElementReact<TSinchAccordionElement> & {
11
11
  multiple?: boolean;
12
12
  value: string;
13
- onChange: (e: SyntheticEvent<TSinchAccordionElement, CustomEvent<string>>) => void;
13
+ onChange?: (e: SyntheticEvent<TSinchAccordionElement, CustomEvent<string>>) => void;
14
+ 'on-change'?: (e: CustomEvent<string>) => void;
14
15
  };
@@ -9,7 +9,7 @@ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollect
9
9
 
10
10
  import '../icons/keyboard-arrow-down';
11
11
  import { defineCustomElement, getAttribute, getBooleanAttribute, getLiteralAttribute, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute, updateLiteralAttribute } from '../utils';
12
- 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-color-stormy-200);--sinch-size-icon:16px}#button{all:initial;cursor:pointer;display:flex;align-items:center;gap:8px;box-sizing:border-box;width:100%;height:48px;padding:12px 8px;font:var(--sinch-font-title-s);color:var(--sinch-color-text-default);fill:var(--sinch-color-stormy-500)}#button>*{pointer-events:none}#button:disabled{cursor:initial;color:var(--sinch-color-stormy-100);fill:var(--sinch-color-stormy-100)}#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-color-success-500)}:host([status=warn]) #button::before{content:"";background-color:var(--sinch-color-warning-500)}:host([status=error]) #button::before{content:"";background-color:var(--sinch-color-error-500)}:host([status=info]) #button::before{content:"";background-color:var(--sinch-color-informative-500)}#title{flex:1;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}#content{display:none;overflow-y:auto;flex-shrink:1;min-height:0;padding:0 8px 18px;font:var(--sinch-font-body);color:var(--sinch-color-text-default)}#dropdown-icon{--sinch-size-icon:24px}#button[aria-expanded=true]>#dropdown-icon{transform:rotate(180deg)}#button[aria-expanded=true]+#content{display:block}#optional{font:var(--sinch-font-small-text);color:var(--sinch-color-stormy-300)}</style><div id="wrapper"><button id="button" aria-controls="content" aria-expanded="false"><slot name="icon"></slot><span id="title"></span> <span id="optional"></span><sinch-icon-keyboard-arrow-down id="dropdown-icon"></sinch-icon-keyboard-arrow-down></button><div id="content" role="region" aria-labelledby="button"><slot name="content"></slot></div></div>';
12
+ 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-color-stormy-200);--sinch-size-icon:16px}#button{all:initial;cursor:pointer;display:flex;align-items:center;gap:8px;box-sizing:border-box;width:100%;height:48px;padding:12px 8px;font:var(--sinch-font-title-s);color:var(--sinch-color-text-default);fill:var(--sinch-color-stormy-500)}#button>*{pointer-events:none}#button:disabled{cursor:initial;color:var(--sinch-color-stormy-100);fill:var(--sinch-color-stormy-100)}#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-color-success-500)}:host([status=warn]) #button::before{content:"";background-color:var(--sinch-color-warning-500)}:host([status=error]) #button::before{content:"";background-color:var(--sinch-color-error-500)}:host([status=info]) #button::before{content:"";background-color:var(--sinch-color-informative-500)}#title{flex:1;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}#content{display:none;overflow-y:auto;flex-shrink:1;min-height:0;padding:0 8px 18px;font:var(--sinch-font-body);color:var(--sinch-color-text-default)}#dropdown-icon{--sinch-size-icon:24px}#button[aria-expanded=true]>#dropdown-icon{transform:rotate(180deg)}#button[aria-expanded=true]+#content{display:block}#optional{font:var(--sinch-font-small-text);color:var(--sinch-color-stormy-300)}</style><div id="wrapper"><button id="button" aria-controls="content" aria-expanded="false"><slot name="icon"></slot><span id="title"></span><span id="optional"></span><sinch-icon-keyboard-arrow-down id="dropdown-icon"></sinch-icon-keyboard-arrow-down></button><div id="content" role="region" aria-labelledby="button"><slot name="content"></slot></div></div>';
13
13
  import { statusValues } from './utils';
14
14
  const template = document.createElement('template');
15
15
  template.innerHTML = templateHTML;
@@ -36,7 +36,7 @@ defineCustomElement('sinch-accordion-item', (_$button = new WeakMap(), _$buttonC
36
36
  writable: true,
37
37
  value: e => {
38
38
  e.stopPropagation();
39
- this.dispatchEvent(new CustomEvent('change', {
39
+ this.dispatchEvent(new CustomEvent('option-change', {
40
40
  bubbles: true,
41
41
  detail: this.value
42
42
  }));
@@ -62,7 +62,7 @@ defineCustomElement('sinch-accordion-item', (_$button = new WeakMap(), _$buttonC
62
62
  }
63
63
 
64
64
  static get observedAttributes() {
65
- return ['label', 'disabled', 'checked', 'optionaltext'];
65
+ return ['label', 'disabled', 'data-checked', 'optionaltext'];
66
66
  }
67
67
 
68
68
  set value(value) {
@@ -106,6 +106,10 @@ defineCustomElement('sinch-accordion-item', (_$button = new WeakMap(), _$buttonC
106
106
  }
107
107
 
108
108
  attributeChangedCallback(name, oldVal, newVal) {
109
+ if (oldVal === newVal) {
110
+ return;
111
+ }
112
+
109
113
  switch (name) {
110
114
  case 'label':
111
115
  {
@@ -119,7 +123,7 @@ defineCustomElement('sinch-accordion-item', (_$button = new WeakMap(), _$buttonC
119
123
  break;
120
124
  }
121
125
 
122
- case 'checked':
126
+ case 'data-checked':
123
127
  {
124
128
  updateExplicitBooleanAttribute(_classPrivateFieldGet(this, _$button), 'aria-expanded', isAttrTrue(newVal));
125
129
  break;
@@ -93,16 +93,15 @@ defineCustomElement('sinch-action-menu', (_$optionSlot = new WeakMap(), _$listbo
93
93
  _classPrivateFieldInitSpec(this, _onClose, {
94
94
  writable: true,
95
95
  value: () => {
96
- this.dispatchEvent(new CustomEvent('close', {
97
- bubbles: true
98
- }));
96
+ this.dispatchEvent(new CustomEvent('-close'));
99
97
  }
100
98
  });
101
99
 
102
100
  _classPrivateFieldInitSpec(this, _onReactClose, {
103
101
  writable: true,
104
- value: () => {
102
+ value: e => {
105
103
  getReactEventHandler(this, 'onClose')?.();
104
+ getReactEventHandler(this, 'on-close')?.(e);
106
105
  }
107
106
  });
108
107
 
@@ -118,11 +117,11 @@ defineCustomElement('sinch-action-menu', (_$optionSlot = new WeakMap(), _$listbo
118
117
 
119
118
  connectedCallback() {
120
119
  this.setAttribute('role', 'listbox');
121
- this.addEventListener('close', _classPrivateFieldGet(this, _onReactClose));
120
+ this.addEventListener('-close', _classPrivateFieldGet(this, _onReactClose));
122
121
  }
123
122
 
124
123
  disconnectedCallback() {
125
- this.removeEventListener('close', _classPrivateFieldGet(this, _onReactClose));
124
+ this.removeEventListener('-close', _classPrivateFieldGet(this, _onReactClose));
126
125
  }
127
126
 
128
127
  static get observedAttributes() {
@@ -178,11 +177,11 @@ defineCustomElement('sinch-action-menu', (_$optionSlot = new WeakMap(), _$listbo
178
177
  if (isAttrTrue(newVal)) {
179
178
  _classPrivateFieldGet(this, _$popover).addEventListener('keydown', _classPrivateFieldGet(this, _onListboxKeyDown));
180
179
 
181
- _classPrivateFieldGet(this, _$popover).addEventListener('close', _classPrivateFieldGet(this, _onClose));
180
+ _classPrivateFieldGet(this, _$popover).addEventListener('-close', _classPrivateFieldGet(this, _onClose));
182
181
  } else {
183
182
  _classPrivateFieldGet(this, _$popover).removeEventListener('keydown', _classPrivateFieldGet(this, _onListboxKeyDown));
184
183
 
185
- _classPrivateFieldGet(this, _$popover).removeEventListener('close', _classPrivateFieldGet(this, _onClose));
184
+ _classPrivateFieldGet(this, _$popover).removeEventListener('-close', _classPrivateFieldGet(this, _onClose));
186
185
 
187
186
  _classPrivateMethodGet(this, _selectOption, _selectOption2).call(this, null);
188
187
  }
@@ -1,13 +1,12 @@
1
1
  import type { TSinchPopoverOrientation } from '../popover/types';
2
2
  import type { TRect, TSinchElementReact } from '../types';
3
- import type { SyntheticEvent } from 'react';
4
3
  export declare type TSinchActionMenuElement = HTMLElement & {
5
4
  open: boolean;
6
5
  orientation: TSinchPopoverOrientation;
7
6
  maxVisibleItems: number | null;
8
7
  modal: boolean;
9
8
  readonly dropdownRect: TRect;
10
- addEventListener(type: 'close', listener: (e: CustomEvent<void>) => void): void;
9
+ addEventListener(type: '-close', listener: (e: CustomEvent<void>) => void): void;
11
10
  setAttribute(name: 'open', value: ''): void;
12
11
  setAttribute(name: 'orientation', value: TSinchPopoverOrientation): void;
13
12
  setAttribute(name: 'maxvisibleitems', value: string): void;
@@ -19,5 +18,6 @@ export declare type TSinchActionMenuReact = TSinchElementReact<TSinchActionMenuE
19
18
  maxVisibleItems?: number;
20
19
  modal?: boolean;
21
20
  'aria-label': string;
22
- onClose: (event: SyntheticEvent<TSinchActionMenuElement, CustomEvent<void>>) => void;
21
+ onClose?: () => void;
22
+ 'on-close'?: (e: CustomEvent<void>) => void;
23
23
  };
@@ -1,17 +1,17 @@
1
1
  import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
2
  import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
3
 
4
- var _$wrapper, _$content, _onMouseDown;
4
+ var _$wrapper, _$content, _onClick, _onMouseDown, _onClickReactHandler;
5
5
 
6
6
  function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
7
7
 
8
8
  function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
9
9
 
10
- import { defineCustomElement, getAttribute, getBooleanAttribute, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute } from '../utils';
10
+ import { defineCustomElement, getAttribute, getBooleanAttribute, getReactEventHandler, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute } from '../utils';
11
11
  const templateHTML = '<style>:host{display:block}#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;cursor:pointer;font:inherit;color:inherit;--sinch-size-icon:24px}#content{flex-shrink:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}:host(:hover)>#wrapper,:host([data-selected])>#wrapper{background-color:var(--sinch-color-snow-500)}:host([disabled]:not([disabled=false]))>#wrapper{color:var(--sinch-color-stormy-100);cursor:initial;pointer-events:none;--sinch-color-icon:var(--sinch-color-stormy-100)}::slotted(*){margin-left:-6px}</style><div id="wrapper"><slot name="icon"></slot><span id="content"></span></div>';
12
12
  const template = document.createElement('template');
13
13
  template.innerHTML = templateHTML;
14
- defineCustomElement('sinch-action-menu-option', (_$wrapper = new WeakMap(), _$content = new WeakMap(), _onMouseDown = new WeakMap(), class ActionMenuOption extends NectaryElement {
14
+ defineCustomElement('sinch-action-menu-option', (_$wrapper = new WeakMap(), _$content = new WeakMap(), _onClick = new WeakMap(), _onMouseDown = new WeakMap(), _onClickReactHandler = new WeakMap(), class ActionMenuOption extends NectaryElement {
15
15
  constructor() {
16
16
  super();
17
17
 
@@ -25,6 +25,13 @@ defineCustomElement('sinch-action-menu-option', (_$wrapper = new WeakMap(), _$co
25
25
  value: void 0
26
26
  });
27
27
 
28
+ _classPrivateFieldInitSpec(this, _onClick, {
29
+ writable: true,
30
+ value: () => {
31
+ this.dispatchEvent(new CustomEvent('-click'));
32
+ }
33
+ });
34
+
28
35
  _classPrivateFieldInitSpec(this, _onMouseDown, {
29
36
  writable: true,
30
37
  value: e => {
@@ -34,6 +41,13 @@ defineCustomElement('sinch-action-menu-option', (_$wrapper = new WeakMap(), _$co
34
41
  }
35
42
  });
36
43
 
44
+ _classPrivateFieldInitSpec(this, _onClickReactHandler, {
45
+ writable: true,
46
+ value: e => {
47
+ getReactEventHandler(this, 'on-click')?.(e);
48
+ }
49
+ });
50
+
37
51
  const shadowRoot = this.attachShadow();
38
52
  shadowRoot.appendChild(template.content.cloneNode(true));
39
53
 
@@ -46,10 +60,16 @@ defineCustomElement('sinch-action-menu-option', (_$wrapper = new WeakMap(), _$co
46
60
  this.setAttribute('role', 'option');
47
61
 
48
62
  _classPrivateFieldGet(this, _$wrapper).addEventListener('mousedown', _classPrivateFieldGet(this, _onMouseDown));
63
+
64
+ this.addEventListener('-click', _classPrivateFieldGet(this, _onClickReactHandler));
65
+ this.addEventListener('click', _classPrivateFieldGet(this, _onClick));
49
66
  }
50
67
 
51
68
  disconnectedCallback() {
52
69
  _classPrivateFieldGet(this, _$wrapper).removeEventListener('mousedown', _classPrivateFieldGet(this, _onMouseDown));
70
+
71
+ this.removeEventListener('-click', _classPrivateFieldGet(this, _onClickReactHandler));
72
+ this.removeEventListener('click', _classPrivateFieldGet(this, _onClick));
53
73
  }
54
74
 
55
75
  static get observedAttributes() {
@@ -2,6 +2,7 @@ import type { TSinchElementReact } from '../types';
2
2
  export declare type TSinchActionMenuOptionElement = HTMLElement & {
3
3
  text: string;
4
4
  disabled: boolean;
5
+ addEventListener(type: '-click', listener: (e: CustomEvent<void>) => void): void;
5
6
  setAttribute(name: 'text', value: string): void;
6
7
  setAttribute(name: 'disabled', value: ''): void;
7
8
  };
@@ -9,4 +10,5 @@ export declare type TSinchActionMenuOptionReact = TSinchElementReact<TSinchActio
9
10
  text: string;
10
11
  disabled?: boolean;
11
12
  'aria-label': string;
13
+ 'on-click'?: (e: CustomEvent<void>) => void;
12
14
  };
package/alert/index.d.ts CHANGED
@@ -1,3 +1,7 @@
1
+ import '../icons/report-problem';
2
+ import '../icons/report';
3
+ import '../icons/info';
4
+ import '../text';
1
5
  import type { TSinchAlertElement, TSinchAlertReact } from './types';
2
6
  declare global {
3
7
  namespace JSX {
package/alert/index.js CHANGED
@@ -1,18 +1,22 @@
1
1
  import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
2
  import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
3
 
4
- var _$text, _$caption;
4
+ var _$text;
5
5
 
6
6
  function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
7
7
 
8
8
  function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
9
9
 
10
- import { defineCustomElement, getBooleanAttribute, getAttribute, getLiteralAttribute, updateBooleanAttribute, updateAttribute, updateLiteralAttribute, NectaryElement } from '../utils';
11
- const templateHTML = '<style>:host{--sinch-color-alert-info-background:#D5E5F8;--sinch-color-alert-success-background:#D7F1D8;--sinch-color-alert-warn-background:#FFE8D6;--sinch-color-alert-error-background:#FCD7D4;display:block}#wrapper{display:flex;flex-direction:row;column-gap:12px;align-items:center;position:relative;padding:12px 18px;border-radius:var(--sinch-shape-radius-l);font:var(--sinch-font-body);color:var(--sinch-color-stormy-600);background-color:var(--sinch-color-alert-info-background);box-sizing:border-box;width:100%;min-height:56px}#body-wrapper{display:flex;flex-direction:row;align-items:center;column-gap:12px;flex:1;min-width:0}#caption{display:none;font:var(--sinch-font-title-s);margin:0;margin-bottom:4px}#text{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin:0;flex:1;min-width:0}:is(#icon-info,#icon-success,#icon-warn,#icon-error){display:none}:host([type=success]) #wrapper{background-color:var(--sinch-color-alert-success-background)}:host([type=warn]) #wrapper{background-color:var(--sinch-color-alert-warn-background)}:host([type=error]) #wrapper{background-color:var(--sinch-color-alert-error-background)}:host([type=info]) #wrapper{background-color:var(--sinch-color-alert-info-background)}:host([type=success]) #icon-success{display:block}:host([type=warn]) #icon-warn{display:block}:host([type=error]) #icon-error{display:block}:host(:is([type=info],:not([type]))) #icon-info{display:block}:host([multiline]:not([multiline=false])) #wrapper{align-items:flex-start;padding:16px 18px}:host([multiline]:not([multiline=false])) #body-wrapper{flex-direction:column;align-items:flex-start}:host([multiline]:not([multiline=false])) #caption{display:block}:host([multiline]:not([multiline=false])) :is(#icon-info,#icon-success,#icon-warn,#icon-error){margin-top:2px}:host([multiline]:not([multiline=false])) #text{overflow:unset;text-overflow:unset;white-space:unset}:host([multiline]:not([multiline=false])) ::slotted(sinch-alert-button){margin-top:10px}</style><div id="wrapper"><svg id="icon-info" width="20" height="20" viewBox="0 0 20 20" aria-hidden="true"><path d="M10 0C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0Zm0 15c-.55 0-1-.45-1-1v-4c0-.55.45-1 1-1s1 .45 1 1v4c0 .55-.45 1-1 1Zm1-8H9V5h2v2Z" fill="#2071CE"/></svg> <svg id="icon-success" width="20" height="20" viewBox="0 0 20 20" aria-hidden="true"><path d="M10 0C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0ZM7.29 14.29 3.7 10.7a.996.996 0 1 1 1.41-1.41L8 12.17l6.88-6.88a.996.996 0 1 1 1.41 1.41L8.7 14.29a.996.996 0 0 1-1.41 0Z" fill="#2E8540"/></svg> <svg id="icon-warn" width="20" height="20" viewBox="0 0 20 20" aria-hidden="true"><path d="M2.47 18h15.06c1.54 0 2.5-1.67 1.73-3L11.73 1.99c-.77-1.33-2.69-1.33-3.46 0L.74 15c-.77 1.33.19 3 1.73 3ZM10 11c-.55 0-1-.45-1-1V8c0-.55.45-1 1-1s1 .45 1 1v2c0 .55-.45 1-1 1Zm1 4H9v-2h2v2Z" fill="#FF8C34"/></svg> <svg id="icon-error" width="20" height="20" viewBox="0 0 18 18" aria-hidden="true"><path d="M12.32 0H5.68c-.26 0-.52.11-.7.29L.29 4.98c-.18.18-.29.44-.29.7v6.63c0 .27.11.52.29.71l4.68 4.68c.19.19.45.3.71.3h6.63c.27 0 .52-.11.71-.29l4.68-4.68a.99.99 0 0 0 .29-.71V5.68c0-.27-.11-.52-.29-.71L13.02.29c-.18-.18-.44-.29-.7-.29ZM9 14.3c-.72 0-1.3-.58-1.3-1.3 0-.72.58-1.3 1.3-1.3.72 0 1.3.58 1.3 1.3 0 .72-.58 1.3-1.3 1.3ZM9 10c-.55 0-1-.45-1-1V5c0-.55.45-1 1-1s1 .45 1 1v4c0 .55-.45 1-1 1Z" fill="#E31C3D"/></svg><div id="body-wrapper"><p id="caption"></p><p id="text"></p><slot name="button"></slot></div><slot name="close"></slot></div>';
12
- import { typeValues } from './utils';
10
+ import '../icons/report-problem';
11
+ import '../icons/report';
12
+ import '../icons/info';
13
+ import '../text';
14
+ import { defineCustomElement, getAttribute, getLiteralAttribute, updateAttribute, updateLiteralAttribute, NectaryElement } from '../utils';
15
+ const templateHTML = '<style>#wrapper{display:flex;flex-direction:row;gap:8px;align-items:center;padding:0 16px;box-sizing:border-box;width:100%;height:48px}#text{color:var(--sinch-color-stormy-500);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0}#icon-error,#icon-info,#icon-warn{display:none}:host([type=warn]) #wrapper{background-color:var(--sinch-color-warning-200)}:host([type=error]) #wrapper{background-color:var(--sinch-color-error-200)}:host([type=info]) #wrapper{background-color:var(--sinch-color-informative-200)}:host([type=warn]) #icon-warn{display:block;--sinch-color-icon:var(--sinch-color-warning-500)}:host([type=error]) #icon-error{display:block;--sinch-color-icon:var(--sinch-color-error-500)}:host([type=info]) #icon-info{display:block;--sinch-color-icon:var(--sinch-color-informative-500)}</style><div id="wrapper"><sinch-icon-info id="icon-info"></sinch-icon-info><sinch-icon-report-problem id="icon-warn"></sinch-icon-report-problem><sinch-icon-report id="icon-error"></sinch-icon-report><sinch-text id="text" type="m"></sinch-text><slot name="action"></slot><slot name="close"></slot></div>';
16
+ import { assertType, typeValues } from './utils';
13
17
  const template = document.createElement('template');
14
18
  template.innerHTML = templateHTML;
15
- defineCustomElement('sinch-alert', (_$text = new WeakMap(), _$caption = new WeakMap(), class extends NectaryElement {
19
+ defineCustomElement('sinch-alert', (_$text = new WeakMap(), class extends NectaryElement {
16
20
  constructor() {
17
21
  super();
18
22
 
@@ -21,17 +25,14 @@ defineCustomElement('sinch-alert', (_$text = new WeakMap(), _$caption = new Weak
21
25
  value: void 0
22
26
  });
23
27
 
24
- _classPrivateFieldInitSpec(this, _$caption, {
25
- writable: true,
26
- value: void 0
27
- });
28
-
29
28
  const shadowRoot = this.attachShadow();
30
29
  shadowRoot.appendChild(template.content.cloneNode(true));
31
30
 
32
31
  _classPrivateFieldSet(this, _$text, shadowRoot.querySelector('#text'));
32
+ }
33
33
 
34
- _classPrivateFieldSet(this, _$caption, shadowRoot.querySelector('#caption'));
34
+ connectedCallback() {
35
+ this.setAttribute('role', 'alert');
35
36
  }
36
37
 
37
38
  get type() {
@@ -50,37 +51,21 @@ defineCustomElement('sinch-alert', (_$text = new WeakMap(), _$caption = new Weak
50
51
  updateAttribute(this, 'text', value);
51
52
  }
52
53
 
53
- get caption() {
54
- return getAttribute(this, 'caption', '');
55
- }
56
-
57
- set caption(value) {
58
- updateAttribute(this, 'caption', value);
59
- }
60
-
61
- get multiline() {
62
- return getBooleanAttribute(this, 'multiline');
63
- }
64
-
65
- set multiline(isMultiline) {
66
- updateBooleanAttribute(this, 'multiline', isMultiline);
67
- }
68
-
69
54
  static get observedAttributes() {
70
- return ['text', 'caption'];
55
+ return ['text', 'type'];
71
56
  }
72
57
 
73
58
  attributeChangedCallback(name, _, newVal) {
74
59
  switch (name) {
75
- case 'text':
60
+ case 'type':
76
61
  {
77
- _classPrivateFieldGet(this, _$text).textContent = newVal;
62
+ assertType(newVal);
78
63
  break;
79
64
  }
80
65
 
81
- case 'caption':
66
+ case 'text':
82
67
  {
83
- _classPrivateFieldGet(this, _$caption).textContent = newVal;
68
+ _classPrivateFieldGet(this, _$text).textContent = newVal;
84
69
  break;
85
70
  }
86
71
  }
package/alert/types.d.ts CHANGED
@@ -1,18 +1,12 @@
1
1
  import type { TSinchElementReact } from '../types';
2
- export declare type TSinchAlertType = 'info' | 'success' | 'warn' | 'error';
2
+ export declare type TSinchAlertType = 'info' | 'warn' | 'error';
3
3
  export declare type TSinchAlertElement = HTMLElement & {
4
4
  type: TSinchAlertType;
5
5
  text: string;
6
- caption: string;
7
- multiline: boolean;
8
6
  setAttribute(name: 'type', value: TSinchAlertType): void;
9
7
  setAttribute(name: 'text', value: string): void;
10
- setAttribute(name: 'caption', value: string): void;
11
- setAttribute(name: 'multiline', value: ''): void;
12
8
  };
13
9
  export declare type TSinchAlertReact = TSinchElementReact<TSinchAlertElement> & {
14
10
  type: TSinchAlertType;
15
11
  text: string;
16
- caption?: string;
17
- multiline?: boolean;
18
12
  };
package/alert/utils.d.ts CHANGED
@@ -1,2 +1,5 @@
1
1
  import type { TSinchAlertType } from './types';
2
2
  export declare const typeValues: readonly TSinchAlertType[];
3
+ declare type TAssertType = (value: string | null) => asserts value is TSinchAlertType;
4
+ export declare const assertType: TAssertType;
5
+ export {};
package/alert/utils.js CHANGED
@@ -1 +1,6 @@
1
- export const typeValues = ['info', 'success', 'warn', 'error'];
1
+ export const typeValues = ['info', 'warn', 'error'];
2
+ export const assertType = value => {
3
+ if (value === null || !typeValues.includes(value)) {
4
+ throw new Error(`sinch-alert: invalid type attribute: ${value}`);
5
+ }
6
+ };
package/avatar/index.js CHANGED
@@ -8,7 +8,7 @@ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedec
8
8
  function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
9
9
 
10
10
  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>';
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>';
12
12
  import { backgroundValues, sizeValues } from './utils';
13
13
  const template = document.createElement('template');
14
14
  template.innerHTML = templateHTML;
package/button/index.js CHANGED
@@ -1,18 +1,18 @@
1
1
  import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
2
  import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
3
 
4
- var _$button, _$text;
4
+ var _$button, _$text, _onButtonClick, _onButtonFocus, _onButtonBlur, _onFocusReactHandler, _onBlurReactHandler, _onClickReactHandler;
5
5
 
6
6
  function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
7
7
 
8
8
  function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
9
9
 
10
- import { defineCustomElement, getBooleanAttribute, getAttribute, getLiteralAttribute, isAttrTrue, updateBooleanAttribute, updateAttribute, updateLiteralAttribute, NectaryElement } from '../utils';
11
- const templateHTML = '<style>:host{--sinch-color-button-background:var(--sinch-color-tropical-500);--sinch-color-button-background-hover:var(--sinch-color-tropical-400);--sinch-color-button-background-focus:var(--sinch-color-tropical-500);--sinch-color-button-background-active:var(--sinch-color-tropical-600);--sinch-color-button-background-disabled:var(--sinch-color-tropical-100);--sinch-color-button-text:var(--sinch-color-text-inverted);--sinch-color-button-text-disabled:var(--sinch-color-text-inverted);--sinch-color-button-border:var(--sinch-color-transparent);--sinch-color-button-border-hover:var(--sinch-color-transparent);--sinch-color-button-border-focus:var(--sinch-color-tropical-700);--sinch-color-button-border-active:var(--sinch-color-transparent);--sinch-color-button-border-disabled:var(--sinch-color-transparent);--sinch-color-spinner-bg:var(--sinch-color-tropical-300);--sinch-color-spinner-fg:var(--sinch-color-snow-100);--sinch-color-icon:var(--sinch-color-text-inverted);display:inline-block;vertical-align:middle;outline:0}:host([type=secondary]){--sinch-color-button-background:var(--sinch-color-snow-100);--sinch-color-button-background-hover:var(--sinch-color-tropical-100);--sinch-color-button-background-focus:var(--sinch-color-snow-100);--sinch-color-button-background-active:var(--sinch-color-tropical-100);--sinch-color-button-background-disabled:var(--sinch-color-snow-100);--sinch-color-button-text:var(--sinch-color-tropical-500);--sinch-color-button-text-disabled:var(--sinch-color-tropical-100);--sinch-color-button-border:var(--sinch-color-tropical-500);--sinch-color-button-border-hover:var(--sinch-color-tropical-500);--sinch-color-button-border-focus:var(--sinch-color-tropical-700);--sinch-color-button-border-active:var(--sinch-color-tropical-500);--sinch-color-button-border-disabled:var(--sinch-color-tropical-100);--sinch-color-spinner-bg:var(--sinch-color-tropical-100);--sinch-color-spinner-fg:var(--sinch-color-tropical-500);--sinch-color-icon:var(--sinch-color-tropical-500)}:host([type=secondary]) button:is(:hover,:active){--sinch-color-spinner-bg:var(--sinch-color-tropical-300);--sinch-color-spinner-fg:var(--sinch-color-snow-100)}:host([type=secondary]) button:disabled{--sinch-color-spinner-bg:var(--sinch-color-tropical-200);--sinch-color-spinner-fg:var(--sinch-color-tropical-400)}:host([type=cta-primary]){--sinch-color-button-background:var(--sinch-color-honey-500);--sinch-color-button-background-hover:var(--sinch-color-honey-400);--sinch-color-button-background-focus:var(--sinch-color-honey-500);--sinch-color-button-background-active:var(--sinch-color-honey-600);--sinch-color-button-background-disabled:var(--sinch-color-honey-100);--sinch-color-button-text:var(--sinch-color-text-default);--sinch-color-button-text-disabled:var(--sinch-color-stormy-300);--sinch-color-button-border:var(--sinch-color-transparent);--sinch-color-button-border-hover:var(--sinch-color-transparent);--sinch-color-button-border-focus:var(--sinch-color-text-default);--sinch-color-button-border-active:var(--sinch-color-transparent);--sinch-color-button-border-disabled:var(--sinch-color-transparent);--sinch-color-spinner-bg:var(--sinch-color-honey-700);--sinch-color-spinner-fg:var(--sinch-color-stormy-600);--sinch-color-icon:var(--sinch-color-text-default)}:host([type=cta-primary]) button:disabled{--sinch-color-spinner-bg:var(--sinch-color-snow-100);--sinch-color-spinner-fg:var(--sinch-color-stormy-300)}:host([type=cta-secondary]){--sinch-color-button-background:var(--sinch-color-snow-100);--sinch-color-button-background-hover:var(--sinch-color-snow-500);--sinch-color-button-background-focus:var(--sinch-color-snow-100);--sinch-color-button-background-active:var(--sinch-color-snow-500);--sinch-color-button-background-disabled:var(--sinch-color-snow-100);--sinch-color-button-text:var(--sinch-color-stormy-500);--sinch-color-button-text-disabled:var(--sinch-color-stormy-200);--sinch-color-button-border:var(--sinch-color-stormy-500);--sinch-color-button-border-hover:var(--sinch-color-stormy-500);--sinch-color-button-border-focus:var(--sinch-color-stormy-500);--sinch-color-button-border-active:var(--sinch-color-stormy-500);--sinch-color-button-border-disabled:var(--sinch-color-stormy-200);--sinch-color-spinner-bg:var(--sinch-color-snow-800);--sinch-color-spinner-fg:var(--sinch-color-stormy-600);--sinch-color-icon:var(--sinch-color-stormy-500)}:host([type=cta-secondary]) button:disabled{--sinch-color-spinner-bg:var(--sinch-color-snow-600);--sinch-color-spinner-fg:var(--sinch-color-stormy-200);--sinch-color-icon:var(--sinch-color-stormy-200)}:host([type=destructive]){--sinch-color-button-background:var(--sinch-color-snow-100);--sinch-color-button-background-hover:var(--sinch-color-error-200);--sinch-color-button-background-focus:var(--sinch-color-snow-100);--sinch-color-button-background-active:var(--sinch-color-error-200);--sinch-color-button-background-disabled:var(--sinch-color-snow-100);--sinch-color-button-text:var(--sinch-color-text-invalid);--sinch-color-button-text-disabled:var(--sinch-color-error-200);--sinch-color-button-border:var(--sinch-color-error-500);--sinch-color-button-border-hover:var(--sinch-color-error-500);--sinch-color-button-border-focus:var(--sinch-color-error-800);--sinch-color-button-border-active:var(--sinch-color-error-500);--sinch-color-button-border-disabled:var(--sinch-color-error-200);--sinch-color-spinner-bg:var(--sinch-color-raspberry-100);--sinch-color-spinner-fg:var(--sinch-color-raspberry-500);--sinch-color-icon:var(--sinch-color-text-invalid)}:host([type=destructive]) button:is(:hover,:active){--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-500)}button{all:initial;position:relative;display:flex;align-items:center;justify-content:center;gap:12px;box-sizing:border-box;width:100%;height:48px;padding:12px;border-radius:var(--sinch-shape-radius-s);font:var(--sinch-font-title-s);color:var(--sinch-color-button-text);background-color:var(--sinch-color-button-background);cursor:pointer;--sinch-size-icon:24px}button::before{content:"";position:absolute;left:0;top:0;bottom:0;right:0;border:1px solid var(--sinch-color-button-border);border-radius:var(--sinch-shape-radius-s)}button:focus{background-color:var(--sinch-color-button-background-focus)}button:focus::before{border-color:var(--sinch-color-button-border-focus);border-width:2px}button:hover{background-color:var(--sinch-color-button-background-hover)}button:hover::before{border-color:var(--sinch-color-button-border-hover);border-width:1px}button:active{background-color:var(--sinch-color-button-background-active)}button:active::before{border-color:var(--sinch-color-button-border-active);border-width:2px}button:disabled{color:var(--sinch-color-button-text-disabled);background-color:var(--sinch-color-button-background-disabled);cursor:initial;--sinch-color-spinner-bg:var(--sinch-color-snow-100);--sinch-color-spinner-fg:var(--sinch-color-tropical-200);--sinch-color-icon:var(--sinch-color-button-text-disabled)}button:disabled::before{border-color:var(--sinch-color-button-border-disabled)}button>*{pointer-events:none}#text{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;display:none}:host([text]:not([text=""])) #text{display:initial}:host([text]:not([text=""])) button{padding:12px 24px}:host([small]:not([small=false]))>button{height:32px;padding:8px;line-height:16px;font-size:14px;gap:8px;border-radius:var(--sinch-shape-radius-s);--sinch-size-icon:16px}:host([small]:not([small=false]))>button::before{border-radius:var(--sinch-shape-radius-s)}:host([text]:not([text=""])[small]:not([small=false])) button{padding:8px 16px}</style><button><slot name="left-icon"></slot><span id="text"></span><slot name="right-icon"></slot></button>';
10
+ 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>';
12
12
  import { buttonTypes } from './utils';
13
13
  const template = document.createElement('template');
14
14
  template.innerHTML = templateHTML;
15
- defineCustomElement('sinch-button', (_$button = new WeakMap(), _$text = new WeakMap(), class extends NectaryElement {
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 {
16
16
  constructor() {
17
17
  super();
18
18
 
@@ -26,16 +26,80 @@ defineCustomElement('sinch-button', (_$button = new WeakMap(), _$text = new Weak
26
26
  value: void 0
27
27
  });
28
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
+
29
71
  const shadowRoot = this.attachShadow();
30
72
  shadowRoot.appendChild(template.content.cloneNode(true));
31
73
 
32
- _classPrivateFieldSet(this, _$button, shadowRoot.querySelector('button'));
74
+ _classPrivateFieldSet(this, _$button, shadowRoot.querySelector('#button'));
33
75
 
34
76
  _classPrivateFieldSet(this, _$text, shadowRoot.querySelector('#text'));
35
77
  }
36
78
 
37
79
  connectedCallback() {
38
80
  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));
91
+ }
92
+
93
+ 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));
39
103
  }
40
104
 
41
105
  static get observedAttributes() {