@nectary/components 0.41.0 → 0.42.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 (128) hide show
  1. package/accordion/index.js +0 -16
  2. package/accordion/types.d.ts +9 -1
  3. package/accordion-item/index.js +0 -24
  4. package/accordion-item/types.d.ts +18 -3
  5. package/action-menu/index.js +1 -45
  6. package/action-menu-option/index.js +0 -18
  7. package/alert/index.js +0 -10
  8. package/alert/types.d.ts +6 -0
  9. package/avatar/index.js +57 -20
  10. package/avatar/types.d.ts +25 -7
  11. package/avatar/utils.d.ts +10 -2
  12. package/avatar/utils.js +23 -2
  13. package/badge/index.d.ts +11 -0
  14. package/badge/index.js +140 -0
  15. package/badge/types.d.ts +38 -0
  16. package/badge/utils.d.ts +11 -0
  17. package/badge/utils.js +23 -0
  18. package/button/index.js +0 -18
  19. package/card/index.js +0 -16
  20. package/card/types.d.ts +15 -3
  21. package/card-container/index.js +0 -1
  22. package/chat/index.js +0 -1
  23. package/chat-block/index.js +0 -19
  24. package/chat-block/types.d.ts +16 -4
  25. package/chat-bubble/index.js +0 -9
  26. package/chat-bubble/types.d.ts +6 -0
  27. package/checkbox/index.js +0 -23
  28. package/chip/index.js +16 -25
  29. package/chip/utils.d.ts +3 -0
  30. package/chip/utils.js +11 -0
  31. package/color-menu/index.js +8 -86
  32. package/color-menu/utils.js +0 -4
  33. package/color-swatch/index.js +17 -17
  34. package/color-swatch/types.d.ts +2 -2
  35. package/color-swatch/utils.d.ts +3 -0
  36. package/color-swatch/utils.js +11 -0
  37. package/date-picker/index.js +1 -50
  38. package/date-picker/utils.js +0 -7
  39. package/dialog/index.js +1 -17
  40. package/field/index.js +0 -19
  41. package/file-drop/index.js +0 -40
  42. package/file-drop/utils.js +0 -6
  43. package/file-picker/index.js +0 -17
  44. package/file-picker/utils.js +0 -1
  45. package/file-status/index.js +0 -12
  46. package/grid/index.js +0 -1
  47. package/grid-item/index.js +0 -9
  48. package/help-tooltip/index.js +0 -14
  49. package/horizontal-stepper/index.js +0 -12
  50. package/horizontal-stepper-item/index.js +0 -14
  51. package/icon-button/index.js +0 -15
  52. package/icons/create-icon-class.js +0 -2
  53. package/icons-branded/create-icon-class.js +0 -8
  54. package/icons-channel/create-icon-class.js +0 -6
  55. package/illustrations/create-illustration-class.js +0 -11
  56. package/inline-alert/index.js +0 -14
  57. package/input/index.js +0 -37
  58. package/link/index.js +0 -25
  59. package/list/index.js +0 -2
  60. package/list-item/index.js +0 -2
  61. package/logo/create-logo-class.js +0 -9
  62. package/package.json +1 -1
  63. package/pagination/index.js +0 -31
  64. package/pop/index.js +64 -68
  65. package/pop/utils.js +0 -1
  66. package/popover/index.js +0 -33
  67. package/popover/utils.js +0 -2
  68. package/progress/index.js +0 -10
  69. package/radio/index.js +0 -30
  70. package/radio-option/index.js +0 -20
  71. package/segment/index.js +0 -15
  72. package/segment-collapse/index.js +0 -13
  73. package/segmented-control/index.js +0 -12
  74. package/segmented-control-option/index.js +0 -18
  75. package/segmented-icon-control/index.js +0 -16
  76. package/segmented-icon-control-option/index.js +0 -14
  77. package/select-button/index.js +0 -23
  78. package/select-menu/index.js +1 -63
  79. package/select-menu-option/index.js +0 -14
  80. package/spinner/index.js +0 -4
  81. package/stop-events/index.js +0 -5
  82. package/table/index.js +0 -2
  83. package/table-body/index.js +0 -2
  84. package/table-cell/index.js +0 -4
  85. package/table-head/index.js +0 -2
  86. package/table-head-cell/index.js +0 -11
  87. package/table-row/index.js +0 -6
  88. package/tabs/index.js +0 -30
  89. package/tabs-option/index.js +0 -19
  90. package/tag/index.js +18 -21
  91. package/tag/utils.d.ts +3 -0
  92. package/tag/utils.js +11 -0
  93. package/text/index.js +1 -12
  94. package/textarea/index.js +0 -40
  95. package/{utils → theme}/colors.d.ts +0 -1
  96. package/{utils → theme}/colors.js +0 -1
  97. package/theme.css +13 -209
  98. package/tile-control/index.js +0 -24
  99. package/tile-control-option/index.js +0 -18
  100. package/time-picker/index.js +2 -51
  101. package/time-picker/utils.js +0 -18
  102. package/title/index.js +1 -12
  103. package/title/utils.js +0 -5
  104. package/toast/index.js +0 -19
  105. package/toast-manager/index.js +0 -27
  106. package/toggle/index.js +0 -23
  107. package/tooltip/index.js +0 -27
  108. package/tooltip/utils.js +0 -4
  109. package/utils/animation.js +0 -20
  110. package/utils/context.js +0 -6
  111. package/utils/index.d.ts +1 -0
  112. package/utils/index.js +11 -52
  113. package/vertical-stepper/index.js +0 -12
  114. package/vertical-stepper-item/index.js +0 -14
  115. package/avatar-badge/index.d.ts +0 -11
  116. package/avatar-badge/index.js +0 -38
  117. package/avatar-badge/types.d.ts +0 -8
  118. package/avatar-status/index.d.ts +0 -11
  119. package/avatar-status/index.js +0 -37
  120. package/avatar-status/types.d.ts +0 -9
  121. package/avatar-status/types.js +0 -1
  122. package/avatar-status/utils.d.ts +0 -5
  123. package/avatar-status/utils.js +0 -6
  124. package/chat-avatar/index.d.ts +0 -12
  125. package/chat-avatar/index.js +0 -52
  126. package/chat-avatar/types.d.ts +0 -12
  127. package/chat-avatar/types.js +0 -1
  128. /package/{avatar-badge → badge}/types.js +0 -0
@@ -4,56 +4,45 @@ const template = document.createElement('template');
4
4
  template.innerHTML = templateHTML;
5
5
  defineCustomElement('sinch-accordion', class extends NectaryElement {
6
6
  #$slot;
7
-
8
7
  constructor() {
9
8
  super();
10
9
  const shadowRoot = this.attachShadow();
11
10
  shadowRoot.appendChild(template.content.cloneNode(true));
12
11
  this.#$slot = shadowRoot.querySelector('slot');
13
12
  }
14
-
15
13
  static get observedAttributes() {
16
14
  return ['value'];
17
15
  }
18
-
19
16
  connectedCallback() {
20
17
  this.setAttribute('aria-label', 'accordion');
21
18
  this.#$slot.addEventListener('slotchange', this.#onSlotChange);
22
19
  this.#$slot.addEventListener('option-change', this.#onOptionChange);
23
20
  this.addEventListener('-change', this.#onChangeReactHandler);
24
21
  }
25
-
26
22
  disconnectedCallback() {
27
23
  this.#$slot.removeEventListener('slotchange', this.#onSlotChange);
28
24
  this.#$slot.removeEventListener('option-change', this.#onOptionChange);
29
25
  this.removeEventListener('-change', this.#onChangeReactHandler);
30
26
  }
31
-
32
27
  get nodeName() {
33
28
  return 'select';
34
29
  }
35
-
36
30
  set value(value) {
37
31
  updateAttribute(this, 'value', value);
38
32
  }
39
-
40
33
  get value() {
41
34
  return getAttribute(this, 'value', '');
42
35
  }
43
-
44
36
  set multiple(isMultiple) {
45
37
  updateBooleanAttribute(this, 'multiple', isMultiple);
46
38
  }
47
-
48
39
  get multiple() {
49
40
  return getBooleanAttribute(this, 'multiple');
50
41
  }
51
-
52
42
  attributeChangedCallback(name, oldVal, newVal) {
53
43
  if (oldVal === newVal) {
54
44
  return;
55
45
  }
56
-
57
46
  switch (name) {
58
47
  case 'value':
59
48
  {
@@ -62,7 +51,6 @@ defineCustomElement('sinch-accordion', class extends NectaryElement {
62
51
  }
63
52
  }
64
53
  }
65
-
66
54
  #onSlotChange = () => {
67
55
  this.#onValueChange(this.value);
68
56
  };
@@ -79,25 +67,21 @@ defineCustomElement('sinch-accordion', class extends NectaryElement {
79
67
  detail: result
80
68
  }));
81
69
  };
82
-
83
70
  #onValueChange(csv) {
84
71
  if (this.multiple) {
85
72
  const values = getCsvSet(csv);
86
-
87
73
  for (const $option of this.#$slot.assignedElements()) {
88
74
  const isChecked = !getBooleanAttribute($option, 'disabled') && values.has(getAttribute($option, 'value', ''));
89
75
  updateBooleanAttribute($option, 'data-checked', isChecked);
90
76
  }
91
77
  } else {
92
78
  const value = getFirstCsvValue(csv);
93
-
94
79
  for (const $option of this.#$slot.assignedElements()) {
95
80
  const isChecked = !getBooleanAttribute($option, 'disabled') && value === getAttribute($option, 'value', '');
96
81
  updateBooleanAttribute($option, 'data-checked', isChecked);
97
82
  }
98
83
  }
99
84
  }
100
-
101
85
  #onChangeReactHandler = e => {
102
86
  getReactEventHandler(this, 'on-change')?.(e);
103
87
  };
@@ -1,16 +1,24 @@
1
1
  import type { TSinchElementReact } from '../types';
2
2
  import type { SyntheticEvent } from 'react';
3
3
  export declare type TSinchAccordionElement = HTMLElement & {
4
+ /** Value */
4
5
  value: string;
6
+ /** Allows to expand multiple items simultanously */
5
7
  multiple: boolean;
8
+ /** Change value event */
6
9
  addEventListener(type: '-change', listener: (e: CustomEvent<string>) => void): void;
10
+ /** Value */
7
11
  setAttribute(name: 'value', value: string): void;
12
+ /** Allows to expand multiple items simultanously */
8
13
  setAttribute(name: 'multiple', value: ''): void;
9
14
  };
10
15
  export declare type TSinchAccordionReact = TSinchElementReact<TSinchAccordionElement> & {
11
- multiple?: boolean;
16
+ /** Value */
12
17
  value: string;
18
+ multiple?: boolean;
19
+ /** Allows to expand multiple items simultanously */
13
20
  /** @deprecated */
14
21
  onChange?: (e: SyntheticEvent<TSinchAccordionElement, CustomEvent<string>>) => void;
22
+ /** Change value handler */
15
23
  'on-change'?: (e: CustomEvent<string>) => void;
16
24
  };
@@ -8,7 +8,6 @@ defineCustomElement('sinch-accordion-item', class extends NectaryElement {
8
8
  #$button;
9
9
  #$buttonContent;
10
10
  #$optionalText;
11
-
12
11
  constructor() {
13
12
  super();
14
13
  const shadowRoot = this.attachShadow();
@@ -17,83 +16,65 @@ defineCustomElement('sinch-accordion-item', class extends NectaryElement {
17
16
  this.#$buttonContent = shadowRoot.querySelector('#title');
18
17
  this.#$optionalText = shadowRoot.querySelector('#optional');
19
18
  }
20
-
21
19
  connectedCallback() {
22
20
  this.#$button.addEventListener('click', this.#onButtonClick);
23
21
  }
24
-
25
22
  disconnectedCallback() {
26
23
  this.#$button.removeEventListener('click', this.#onButtonClick);
27
24
  }
28
-
29
25
  static get observedAttributes() {
30
26
  return ['label', 'disabled', 'data-checked', 'optionaltext'];
31
27
  }
32
-
33
28
  set value(value) {
34
29
  updateAttribute(this, 'value', value);
35
30
  }
36
-
37
31
  get value() {
38
32
  return getAttribute(this, 'value', '');
39
33
  }
40
-
41
34
  set label(value) {
42
35
  updateAttribute(this, 'label', value);
43
36
  }
44
-
45
37
  get label() {
46
38
  return getAttribute(this, 'label', '');
47
39
  }
48
-
49
40
  set disabled(isDisabled) {
50
41
  updateBooleanAttribute(this, 'disabled', isDisabled);
51
42
  }
52
-
53
43
  get disabled() {
54
44
  return getBooleanAttribute(this, 'disabled');
55
45
  }
56
-
57
46
  get status() {
58
47
  return getLiteralAttribute(this, statusValues, 'status', null);
59
48
  }
60
-
61
49
  set status(value) {
62
50
  updateLiteralAttribute(this, statusValues, 'status', value);
63
51
  }
64
-
65
52
  set optionalText(value) {
66
53
  updateAttribute(this, 'optionaltext', value);
67
54
  }
68
-
69
55
  get optionalText() {
70
56
  return getAttribute(this, 'optionaltext');
71
57
  }
72
-
73
58
  attributeChangedCallback(name, oldVal, newVal) {
74
59
  if (oldVal === newVal) {
75
60
  return;
76
61
  }
77
-
78
62
  switch (name) {
79
63
  case 'label':
80
64
  {
81
65
  this.#$buttonContent.textContent = newVal;
82
66
  break;
83
67
  }
84
-
85
68
  case 'disabled':
86
69
  {
87
70
  this.#$button.disabled = isAttrTrue(newVal);
88
71
  break;
89
72
  }
90
-
91
73
  case 'data-checked':
92
74
  {
93
75
  updateExplicitBooleanAttribute(this.#$button, 'aria-expanded', isAttrTrue(newVal));
94
76
  break;
95
77
  }
96
-
97
78
  case 'optionaltext':
98
79
  {
99
80
  this.#$optionalText.textContent = newVal;
@@ -101,7 +82,6 @@ defineCustomElement('sinch-accordion-item', class extends NectaryElement {
101
82
  }
102
83
  }
103
84
  }
104
-
105
85
  #onButtonClick = e => {
106
86
  e.stopPropagation();
107
87
  this.dispatchEvent(new CustomEvent('option-change', {
@@ -109,17 +89,13 @@ defineCustomElement('sinch-accordion-item', class extends NectaryElement {
109
89
  detail: this.value
110
90
  }));
111
91
  };
112
-
113
92
  get focusable() {
114
93
  return true;
115
94
  }
116
-
117
95
  focus() {
118
96
  this.#$button.focus();
119
97
  }
120
-
121
98
  blur() {
122
99
  this.#$button.blur();
123
100
  }
124
-
125
101
  });
@@ -1,21 +1,36 @@
1
1
  import type { TSinchElementReact } from '../types';
2
2
  export declare type TSinchAccordionStatusType = 'info' | 'success' | 'warn' | 'error';
3
3
  export declare type TSinchAccordionItemElement = HTMLElement & {
4
+ /** Value */
4
5
  value: string;
6
+ /** Label */
5
7
  label: string;
8
+ /** Optional text on the right side */
6
9
  optionalText: string | null;
7
- disabled: boolean;
10
+ /** Status */
8
11
  status: TSinchAccordionStatusType | null;
12
+ /** Disabled */
13
+ disabled: boolean;
14
+ /** Value */
9
15
  setAttribute(name: 'value', value: string): void;
16
+ /** Label */
10
17
  setAttribute(name: 'label', value: string): void;
18
+ /** Optional text on the right side */
11
19
  setAttribute(name: 'optionaltext', value: string): void;
12
- setAttribute(name: 'disabled', value: ''): void;
20
+ /** Status */
13
21
  setAttribute(name: 'status', value: TSinchAccordionStatusType): void;
22
+ /** Disabled */
23
+ setAttribute(name: 'disabled', value: ''): void;
14
24
  };
15
25
  export declare type TSinchAccordionItemReact = TSinchElementReact<TSinchAccordionItemElement> & {
26
+ /** Value */
16
27
  value: string;
28
+ /** Label */
17
29
  label: string;
30
+ /** Optional text on the right side */
18
31
  optionalText?: string;
19
- disabled?: boolean;
32
+ /** Status */
20
33
  status?: TSinchAccordionStatusType;
34
+ /** Disabled */
35
+ disabled?: boolean;
21
36
  };
@@ -9,7 +9,6 @@ defineCustomElement('sinch-action-menu', class extends NectaryElement {
9
9
  #$optionSlot;
10
10
  #$listbox;
11
11
  #controller = null;
12
-
13
12
  constructor() {
14
13
  super();
15
14
  const shadowRoot = this.attachShadow();
@@ -17,7 +16,6 @@ defineCustomElement('sinch-action-menu', class extends NectaryElement {
17
16
  this.#$optionSlot = shadowRoot.querySelector('slot');
18
17
  this.#$listbox = shadowRoot.querySelector('#listbox');
19
18
  }
20
-
21
19
  connectedCallback() {
22
20
  this.#controller = new AbortController();
23
21
  const {
@@ -43,30 +41,24 @@ defineCustomElement('sinch-action-menu', class extends NectaryElement {
43
41
  dispatchContextConnectEvent(this, 'keydown');
44
42
  dispatchContextConnectEvent(this, 'visibility');
45
43
  }
46
-
47
44
  disconnectedCallback() {
48
45
  dispatchContextDisconnectEvent(this, 'keydown');
49
46
  dispatchContextDisconnectEvent(this, 'visibility');
50
47
  this.#controller.abort();
51
48
  }
52
-
53
49
  static get observedAttributes() {
54
50
  return ['rows'];
55
51
  }
56
-
57
52
  set rows(value) {
58
53
  updateIntegerAttribute(this, 'rows', value);
59
54
  }
60
-
61
55
  get rows() {
62
56
  return getIntegerAttribute(this, 'rows', null);
63
57
  }
64
-
65
58
  attributeChangedCallback(name, oldVal, newVal) {
66
59
  if (oldVal === newVal) {
67
60
  return;
68
61
  }
69
-
70
62
  switch (name) {
71
63
  case 'rows':
72
64
  {
@@ -78,7 +70,6 @@ defineCustomElement('sinch-action-menu', class extends NectaryElement {
78
70
  }
79
71
  }
80
72
  }
81
-
82
73
  #onListboxBlur = () => {
83
74
  this.#selectOption(null);
84
75
  };
@@ -102,28 +93,23 @@ defineCustomElement('sinch-action-menu', class extends NectaryElement {
102
93
  });
103
94
  }
104
95
  };
105
-
106
96
  #handleKeydown(e) {
107
97
  switch (e.code) {
108
98
  case 'Enter':
109
99
  {
110
100
  const $opt = this.#findSelectedOption();
111
-
112
101
  if ($opt !== null) {
113
102
  e.preventDefault();
114
103
  $opt.click();
115
104
  }
116
-
117
105
  break;
118
106
  }
119
-
120
107
  case 'ArrowUp':
121
108
  {
122
109
  e.preventDefault();
123
110
  this.#selectOption(this.#getPrevOption());
124
111
  break;
125
112
  }
126
-
127
113
  case 'ArrowDown':
128
114
  {
129
115
  e.preventDefault();
@@ -132,78 +118,58 @@ defineCustomElement('sinch-action-menu', class extends NectaryElement {
132
118
  }
133
119
  }
134
120
  }
135
-
136
121
  #getFirstOption() {
137
122
  const $options = this.#getOptionElements();
138
-
139
123
  for (let i = 0; i < $options.length; i++) {
140
124
  const el = $options[i];
141
-
142
125
  if (!getBooleanAttribute(el, 'disabled')) {
143
126
  return el;
144
127
  }
145
128
  }
146
-
147
129
  return null;
148
130
  }
149
-
150
131
  #getLastOption() {
151
132
  const $options = this.#getOptionElements();
152
-
153
133
  for (let i = $options.length - 1; i >= 0; i--) {
154
134
  const el = $options[i];
155
-
156
135
  if (!getBooleanAttribute(el, 'disabled')) {
157
136
  return el;
158
137
  }
159
138
  }
160
-
161
139
  return null;
162
140
  }
163
-
164
141
  #getNextOption() {
165
142
  const index = this.#getSelectedOptionIndex();
166
-
167
143
  if (index !== null) {
168
144
  const $options = this.#getOptionElements();
169
-
170
145
  for (let i = 1; i <= $options.length; i++) {
171
146
  const el = $options[(i + index) % $options.length];
172
-
173
147
  if (!getBooleanAttribute(el, 'disabled')) {
174
148
  return el;
175
149
  }
176
150
  }
177
151
  }
178
-
179
152
  return this.#getFirstOption();
180
153
  }
181
-
182
154
  #getPrevOption() {
183
155
  const index = this.#getSelectedOptionIndex();
184
-
185
156
  if (index !== null) {
186
157
  const $options = this.#getOptionElements();
187
-
188
158
  for (let i = 1; i <= $options.length; i++) {
189
159
  const el = $options[(index - i + $options.length) % $options.length];
190
-
191
160
  if (!getBooleanAttribute(el, 'disabled')) {
192
161
  return el;
193
162
  }
194
163
  }
195
164
  }
196
-
197
165
  return this.#getLastOption();
198
166
  }
199
-
200
167
  #selectOption($option) {
201
168
  const hasRows = this.hasAttribute('rows');
202
-
203
169
  for (const $op of this.#getOptionElements()) {
204
170
  const isSelected = $op === $option;
205
- updateBooleanAttribute($op, 'data-selected', isSelected);
206
171
 
172
+ updateBooleanAttribute($op, 'data-selected', isSelected);
207
173
  if (isSelected && hasRows) {
208
174
  $op.scrollIntoView?.({
209
175
  block: 'nearest'
@@ -211,39 +177,29 @@ defineCustomElement('sinch-action-menu', class extends NectaryElement {
211
177
  }
212
178
  }
213
179
  }
214
-
215
180
  #getOptionElements() {
216
181
  return this.#$optionSlot.assignedElements();
217
182
  }
218
-
219
183
  #getSelectedOptionIndex() {
220
184
  const elements = this.#getOptionElements();
221
-
222
185
  for (let i = 0; i < elements.length; i++) {
223
186
  const el = elements[i];
224
-
225
187
  if (!getBooleanAttribute(el, 'disabled') && getBooleanAttribute(el, 'data-selected')) {
226
188
  return i;
227
189
  }
228
190
  }
229
-
230
191
  return null;
231
192
  }
232
-
233
193
  #findSelectedOption() {
234
194
  const elements = this.#getOptionElements();
235
-
236
195
  for (const el of elements) {
237
196
  if (getBooleanAttribute(el, 'data-selected')) {
238
197
  return el;
239
198
  }
240
199
  }
241
-
242
200
  return null;
243
201
  }
244
-
245
202
  get focusable() {
246
203
  return true;
247
204
  }
248
-
249
205
  });
@@ -7,7 +7,6 @@ defineCustomElement('sinch-action-menu-option', class ActionMenuOption extends N
7
7
  #$wrapper;
8
8
  #$content;
9
9
  #controller = null;
10
-
11
10
  constructor() {
12
11
  super();
13
12
  const shadowRoot = this.attachShadow();
@@ -15,7 +14,6 @@ defineCustomElement('sinch-action-menu-option', class ActionMenuOption extends N
15
14
  this.#$wrapper = shadowRoot.querySelector('#wrapper');
16
15
  this.#$content = shadowRoot.querySelector('#content');
17
16
  }
18
-
19
17
  connectedCallback() {
20
18
  this.#controller = new AbortController();
21
19
  const {
@@ -29,76 +27,60 @@ defineCustomElement('sinch-action-menu-option', class ActionMenuOption extends N
29
27
  signal
30
28
  });
31
29
  }
32
-
33
30
  disconnectedCallback() {
34
31
  this.#controller.abort();
35
32
  }
36
-
37
33
  static get observedAttributes() {
38
34
  return ['text', 'disabled', 'data-selected'];
39
35
  }
40
-
41
36
  attributeChangedCallback(name, oldVal, newVal) {
42
37
  if (oldVal === newVal) {
43
38
  return;
44
39
  }
45
-
46
40
  switch (name) {
47
41
  case 'text':
48
42
  {
49
43
  this.#$content.textContent = newVal;
50
44
  break;
51
45
  }
52
-
53
46
  case 'disabled':
54
47
  {
55
48
  updateBooleanAttribute(this, 'disabled', isAttrTrue(newVal));
56
49
  break;
57
50
  }
58
-
59
51
  case 'data-selected':
60
52
  {
61
53
  const isDisabled = getBooleanAttribute(this, 'disabled');
62
-
63
54
  if (isDisabled) {
64
55
  updateBooleanAttribute(this, 'aria-selected', false);
65
56
  } else {
66
57
  updateExplicitBooleanAttribute(this, 'aria-selected', isAttrTrue(newVal));
67
58
  }
68
-
69
59
  break;
70
60
  }
71
61
  }
72
62
  }
73
-
74
63
  set text(value) {
75
64
  updateAttribute(this, 'text', value);
76
65
  }
77
-
78
66
  get text() {
79
67
  return getAttribute(this, 'text', '');
80
68
  }
81
-
82
69
  set disabled(isDisabled) {
83
70
  updateBooleanAttribute(this, 'disabled', isDisabled);
84
71
  }
85
-
86
72
  get disabled() {
87
73
  return getBooleanAttribute(this, 'disabled');
88
74
  }
89
-
90
75
  click() {
91
76
  this.#dispatchClickEvent();
92
77
  }
93
-
94
78
  #onMouseDown = () => {
95
79
  this.#dispatchClickEvent();
96
80
  };
97
-
98
81
  #dispatchClickEvent() {
99
82
  this.dispatchEvent(new CustomEvent('-click'));
100
83
  }
101
-
102
84
  #onClickReactHandler = e => {
103
85
  getReactEventHandler(this, 'on-click')?.(e);
104
86
  };
package/alert/index.js CHANGED
@@ -9,38 +9,30 @@ const template = document.createElement('template');
9
9
  template.innerHTML = templateHTML;
10
10
  defineCustomElement('sinch-alert', class extends NectaryElement {
11
11
  #$text;
12
-
13
12
  constructor() {
14
13
  super();
15
14
  const shadowRoot = this.attachShadow();
16
15
  shadowRoot.appendChild(template.content.cloneNode(true));
17
16
  this.#$text = shadowRoot.querySelector('#text');
18
17
  }
19
-
20
18
  connectedCallback() {
21
19
  this.setAttribute('role', 'alert');
22
20
  }
23
-
24
21
  get type() {
25
22
  return getLiteralAttribute(this, typeValues, 'type');
26
23
  }
27
-
28
24
  set type(value) {
29
25
  updateLiteralAttribute(this, typeValues, 'type', value);
30
26
  }
31
-
32
27
  get text() {
33
28
  return getAttribute(this, 'text', '');
34
29
  }
35
-
36
30
  set text(value) {
37
31
  updateAttribute(this, 'text', value);
38
32
  }
39
-
40
33
  static get observedAttributes() {
41
34
  return ['text', 'type'];
42
35
  }
43
-
44
36
  attributeChangedCallback(name, _, newVal) {
45
37
  switch (name) {
46
38
  case 'type':
@@ -48,7 +40,6 @@ defineCustomElement('sinch-alert', class extends NectaryElement {
48
40
  assertType(newVal);
49
41
  break;
50
42
  }
51
-
52
43
  case 'text':
53
44
  {
54
45
  this.#$text.textContent = newVal;
@@ -56,5 +47,4 @@ defineCustomElement('sinch-alert', class extends NectaryElement {
56
47
  }
57
48
  }
58
49
  }
59
-
60
50
  });
package/alert/types.d.ts CHANGED
@@ -1,12 +1,18 @@
1
1
  import type { TSinchElementReact } from '../types';
2
2
  export declare type TSinchAlertType = 'info' | 'warn' | 'error';
3
3
  export declare type TSinchAlertElement = HTMLElement & {
4
+ /** Type */
4
5
  type: TSinchAlertType;
6
+ /** Text */
5
7
  text: string;
8
+ /** Type */
6
9
  setAttribute(name: 'type', value: TSinchAlertType): void;
10
+ /** Text */
7
11
  setAttribute(name: 'text', value: string): void;
8
12
  };
9
13
  export declare type TSinchAlertReact = TSinchElementReact<TSinchAlertElement> & {
14
+ /** Type */
10
15
  type: TSinchAlertType;
16
+ /** Text */
11
17
  text: string;
12
18
  };