@nectary/components 0.33.0 → 0.35.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 (91) 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.js +1 -1
  9. package/avatar/index.js +1 -1
  10. package/button/index.js +68 -4
  11. package/button/types.d.ts +6 -0
  12. package/checkbox/index.js +64 -6
  13. package/checkbox/types.d.ts +8 -2
  14. package/date-picker/index.js +37 -12
  15. package/date-picker/types.d.ts +4 -2
  16. package/dialog/index.d.ts +1 -0
  17. package/dialog/index.js +8 -12
  18. package/dialog/types.d.ts +3 -3
  19. package/dropdown/index.js +44 -28
  20. package/dropdown/types.d.ts +6 -4
  21. package/dropdown-checkbox-option/index.js +1 -1
  22. package/dropdown-checkbox-option/types.d.ts +0 -2
  23. package/dropdown-radio-option/index.js +1 -1
  24. package/dropdown-radio-option/types.d.ts +0 -2
  25. package/dropdown-text-option/index.js +1 -1
  26. package/dropdown-text-option/types.d.ts +0 -2
  27. package/horizontal-stepper/index.d.ts +13 -0
  28. package/horizontal-stepper/index.js +104 -0
  29. package/horizontal-stepper/types.d.ts +9 -0
  30. package/horizontal-stepper/types.js +1 -0
  31. package/horizontal-stepper-item/index.d.ts +13 -0
  32. package/horizontal-stepper-item/index.js +100 -0
  33. package/horizontal-stepper-item/types.d.ts +15 -0
  34. package/horizontal-stepper-item/types.js +1 -0
  35. package/horizontal-stepper-item/utils.d.ts +2 -0
  36. package/horizontal-stepper-item/utils.js +1 -0
  37. package/icon-button/index.js +67 -3
  38. package/icon-button/types.d.ts +6 -0
  39. package/icons/create-icon-class.js +1 -1
  40. package/icons/exclamation/index.d.ts +11 -0
  41. package/icons/exclamation/index.js +4 -0
  42. package/icons-branded/create-icon-class.js +3 -7
  43. package/icons-branded/types.d.ts +3 -0
  44. package/icons-channel/create-icon-class.js +3 -7
  45. package/icons-channel/types.d.ts +3 -0
  46. package/input/index.js +50 -19
  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 +10 -13
  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 +41 -7
  71. package/stop-events/index.d.ts +1 -0
  72. package/stop-events/index.js +40 -0
  73. package/tabs/index.js +32 -8
  74. package/tabs/types.d.ts +3 -2
  75. package/tabs-option/index.js +2 -2
  76. package/textarea/index.js +58 -4
  77. package/textarea/types.d.ts +7 -2
  78. package/tile-control/index.d.ts +11 -0
  79. package/tile-control/index.js +181 -0
  80. package/tile-control/types.d.ts +38 -0
  81. package/tile-control/types.js +1 -0
  82. package/tile-control-option/index.d.ts +11 -0
  83. package/tile-control-option/index.js +161 -0
  84. package/tile-control-option/types.d.ts +37 -0
  85. package/tile-control-option/types.js +1 -0
  86. package/time-picker/index.js +17 -3
  87. package/time-picker/types.d.ts +4 -2
  88. package/toggle/index.js +63 -5
  89. package/toggle/types.d.ts +3 -1
  90. package/utils.d.ts +1 -0
  91. package/utils.js +3 -0
package/input/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 _$input, _$label, _$optionalText, _$additionalText, _$invalidText, _$iconSlot, _$iconWrapper, _$rightSlot, _$rightWrapper, _cursorPos, _isPendingDk, _onCompositionStart, _onSelectionChange, _onInput, _onIconSlotChange, _onRightSlotChange, _onEventFilter;
4
+ var _$input, _$label, _$optionalText, _$additionalText, _$invalidText, _$iconSlot, _$iconWrapper, _$rightSlot, _$rightWrapper, _cursorPos, _isPendingDk, _onCompositionStart, _onSelectionChange, _onInput, _onIconSlotChange, _onRightSlotChange, _onInputFocus, _onInputBlur, _onChangeReactHandler, _onFocusReactHandler, _onBlurReactHandler;
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, getLiteralAttribute, isAttrTrue, NectaryElement, setClass, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute, updateLiteralAttribute } from '../utils';
10
+ import { defineCustomElement, getAttribute, getBooleanAttribute, getLiteralAttribute, getReactEventHandler, isAttrTrue, NectaryElement, setClass, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute, updateLiteralAttribute } from '../utils';
11
11
  const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0;--sinch-color-icon:var(--sinch-color-stormy-500)}#wrapper{width:100%;box-sizing:border-box}#input-wrapper{position:relative;display:flex;flex-direction:row;align-items:center;box-sizing:border-box;border-radius:var(--sinch-shape-radius-s);width:100%;height:48px;background-color:var(--sinch-color-snow-100)}#input{all:initial;flex:1;min-width:0;height:48px;padding:0 12px 0 44px;font:var(--sinch-font-body);color:var(--sinch-color-text-default);caret-color:var(--sinch-caret-color,auto)}#input::placeholder{font:var(--sinch-font-body);color:var(--sinch-color-text-muted)}#border{position:absolute;border:1px solid var(--sinch-color-stormy-200);border-radius:var(--sinch-shape-radius-s);left:0;right:0;top:0;bottom:0;pointer-events:none}:host([invalidtext]:not([invalidtext=""]):not([disabled])) #border{border-color:var(--sinch-color-text-invalid)}#input:disabled{color:var(--sinch-color-stormy-100)}#input:disabled::placeholder{color:var(--sinch-color-snow-500)}#input:disabled+#border{border-color:var(--sinch-color-snow-500)}#input:focus+#border{border-color:var(--sinch-color-stormy-600)}#input[type=password]{font-size:1.5em;letter-spacing:.1em}#bottom,#top{display:flex;align-items:baseline}#top{height:24px;margin-bottom:2px}#additional,#invalid,#label,#optional{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#label{font:var(--sinch-font-title-s);color:var(--sinch-color-text-default)}#optional{flex:1;text-align:right;font:var(--sinch-font-small-text);color:var(--sinch-color-text-muted)}#additional{flex:1;text-align:right;font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-muted);line-height:20px;margin-top:2px}#additional:empty{display:none}#invalid{font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-invalid);line-height:20px;margin-top:2px}#invalid:empty{display:none}#icon{position:absolute;left:12px;top:12px;pointer-events:none;--sinch-icon-size:24px}#icon.empty{display:none}#icon.empty~#input{padding-left:12px}#right{display:flex;flex-direction:row;align-self:stretch;align-items:center;gap:4px;padding-right:8px}#right.empty{display:none}::slotted(sinch-help-tooltip){align-self:center;margin:0 8px}:host([disabled]:not([disabled=false])) :is(#label,#additional,#optional,#invalid){color:var(--sinch-color-stormy-100)}:host([disabled]:not([disabled=false])){--sinch-color-icon:var(--sinch-color-stormy-100)}</style><div id="wrapper"><div id="top"><label id="label" for="input"></label><slot name="tooltip"></slot><span id="optional"></span></div><div id="input-wrapper"><div id="icon"><slot name="icon"></slot></div><input id="input" type="text"/><div id="border"></div><div id="right"><slot name="right"></slot></div></div><div id="bottom"><div id="invalid"></div><div id="additional"></div></div></div>';
12
12
  import { inputTypes } from './utils';
13
13
  const template = document.createElement('template');
14
14
  template.innerHTML = templateHTML;
15
- defineCustomElement('sinch-input', (_$input = new WeakMap(), _$label = new WeakMap(), _$optionalText = new WeakMap(), _$additionalText = new WeakMap(), _$invalidText = new WeakMap(), _$iconSlot = new WeakMap(), _$iconWrapper = new WeakMap(), _$rightSlot = new WeakMap(), _$rightWrapper = new WeakMap(), _cursorPos = new WeakMap(), _isPendingDk = new WeakMap(), _onCompositionStart = new WeakMap(), _onSelectionChange = new WeakMap(), _onInput = new WeakMap(), _onIconSlotChange = new WeakMap(), _onRightSlotChange = new WeakMap(), _onEventFilter = new WeakMap(), class extends NectaryElement {
15
+ defineCustomElement('sinch-input', (_$input = new WeakMap(), _$label = new WeakMap(), _$optionalText = new WeakMap(), _$additionalText = new WeakMap(), _$invalidText = new WeakMap(), _$iconSlot = new WeakMap(), _$iconWrapper = new WeakMap(), _$rightSlot = new WeakMap(), _$rightWrapper = new WeakMap(), _cursorPos = new WeakMap(), _isPendingDk = new WeakMap(), _onCompositionStart = new WeakMap(), _onSelectionChange = new WeakMap(), _onInput = new WeakMap(), _onIconSlotChange = new WeakMap(), _onRightSlotChange = new WeakMap(), _onInputFocus = new WeakMap(), _onInputBlur = new WeakMap(), _onChangeReactHandler = new WeakMap(), _onFocusReactHandler = new WeakMap(), _onBlurReactHandler = new WeakMap(), class extends NectaryElement {
16
16
  constructor() {
17
17
  super();
18
18
 
@@ -117,6 +117,9 @@ defineCustomElement('sinch-input', (_$input = new WeakMap(), _$label = new WeakM
117
117
  detail: nextValue,
118
118
  bubbles: true
119
119
  }));
120
+ this.dispatchEvent(new CustomEvent('-change', {
121
+ detail: nextValue
122
+ }));
120
123
  }
121
124
  }
122
125
  });
@@ -135,10 +138,38 @@ defineCustomElement('sinch-input', (_$input = new WeakMap(), _$label = new WeakM
135
138
  }
136
139
  });
137
140
 
138
- _classPrivateFieldInitSpec(this, _onEventFilter, {
141
+ _classPrivateFieldInitSpec(this, _onInputFocus, {
142
+ writable: true,
143
+ value: () => {
144
+ this.dispatchEvent(new CustomEvent('-focus'));
145
+ }
146
+ });
147
+
148
+ _classPrivateFieldInitSpec(this, _onInputBlur, {
149
+ writable: true,
150
+ value: () => {
151
+ this.dispatchEvent(new CustomEvent('-blur'));
152
+ }
153
+ });
154
+
155
+ _classPrivateFieldInitSpec(this, _onChangeReactHandler, {
139
156
  writable: true,
140
157
  value: e => {
141
- e.stopPropagation();
158
+ getReactEventHandler(this, 'on-change')?.(e);
159
+ }
160
+ });
161
+
162
+ _classPrivateFieldInitSpec(this, _onFocusReactHandler, {
163
+ writable: true,
164
+ value: () => {
165
+ getReactEventHandler(this, 'on-focus')?.();
166
+ }
167
+ });
168
+
169
+ _classPrivateFieldInitSpec(this, _onBlurReactHandler, {
170
+ writable: true,
171
+ value: () => {
172
+ getReactEventHandler(this, 'on-blur')?.();
142
173
  }
143
174
  });
144
175
 
@@ -175,17 +206,17 @@ defineCustomElement('sinch-input', (_$input = new WeakMap(), _$label = new WeakM
175
206
 
176
207
  _classPrivateFieldGet(this, _$input).addEventListener('keydown', _classPrivateFieldGet(this, _onSelectionChange));
177
208
 
178
- _classPrivateFieldGet(this, _$iconSlot).addEventListener('slotchange', _classPrivateFieldGet(this, _onIconSlotChange));
179
-
180
- _classPrivateFieldGet(this, _$rightSlot).addEventListener('slotchange', _classPrivateFieldGet(this, _onRightSlotChange));
209
+ _classPrivateFieldGet(this, _$input).addEventListener('focus', _classPrivateFieldGet(this, _onInputFocus));
181
210
 
182
- _classPrivateFieldGet(this, _$rightSlot).addEventListener('input', _classPrivateFieldGet(this, _onEventFilter));
211
+ _classPrivateFieldGet(this, _$input).addEventListener('blur', _classPrivateFieldGet(this, _onInputBlur));
183
212
 
184
- _classPrivateFieldGet(this, _$rightSlot).addEventListener('change', _classPrivateFieldGet(this, _onEventFilter));
213
+ _classPrivateFieldGet(this, _$iconSlot).addEventListener('slotchange', _classPrivateFieldGet(this, _onIconSlotChange));
185
214
 
186
- _classPrivateFieldGet(this, _$rightSlot).addEventListener('focusin', _classPrivateFieldGet(this, _onEventFilter));
215
+ _classPrivateFieldGet(this, _$rightSlot).addEventListener('slotchange', _classPrivateFieldGet(this, _onRightSlotChange));
187
216
 
188
- _classPrivateFieldGet(this, _$rightSlot).addEventListener('focusout', _classPrivateFieldGet(this, _onEventFilter));
217
+ this.addEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
218
+ this.addEventListener('-focus', _classPrivateFieldGet(this, _onFocusReactHandler));
219
+ this.addEventListener('-blur', _classPrivateFieldGet(this, _onBlurReactHandler));
189
220
 
190
221
  _classPrivateFieldGet(this, _onIconSlotChange).call(this);
191
222
 
@@ -201,17 +232,17 @@ defineCustomElement('sinch-input', (_$input = new WeakMap(), _$label = new WeakM
201
232
 
202
233
  _classPrivateFieldGet(this, _$input).removeEventListener('keydown', _classPrivateFieldGet(this, _onSelectionChange));
203
234
 
204
- _classPrivateFieldGet(this, _$iconSlot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onIconSlotChange));
205
-
206
- _classPrivateFieldGet(this, _$rightSlot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onRightSlotChange));
235
+ _classPrivateFieldGet(this, _$input).removeEventListener('focus', _classPrivateFieldGet(this, _onInputFocus));
207
236
 
208
- _classPrivateFieldGet(this, _$rightSlot).removeEventListener('input', _classPrivateFieldGet(this, _onEventFilter));
237
+ _classPrivateFieldGet(this, _$input).removeEventListener('blur', _classPrivateFieldGet(this, _onInputBlur));
209
238
 
210
- _classPrivateFieldGet(this, _$rightSlot).removeEventListener('change', _classPrivateFieldGet(this, _onEventFilter));
239
+ _classPrivateFieldGet(this, _$iconSlot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onIconSlotChange));
211
240
 
212
- _classPrivateFieldGet(this, _$rightSlot).removeEventListener('focusin', _classPrivateFieldGet(this, _onEventFilter));
241
+ _classPrivateFieldGet(this, _$rightSlot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onRightSlotChange));
213
242
 
214
- _classPrivateFieldGet(this, _$rightSlot).removeEventListener('focusout', _classPrivateFieldGet(this, _onEventFilter));
243
+ this.removeEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
244
+ this.removeEventListener('-focus', _classPrivateFieldGet(this, _onFocusReactHandler));
245
+ this.removeEventListener('-blur', _classPrivateFieldGet(this, _onBlurReactHandler));
215
246
  }
216
247
 
217
248
  static get observedAttributes() {
package/input/types.d.ts CHANGED
@@ -22,7 +22,9 @@ export declare type TSinchInputElement = HTMLElement & {
22
22
  selectionEnd: number | null;
23
23
  selectionDirection: 'forward' | 'backward' | 'none' | null;
24
24
  /** Change value event */
25
- addEventListener(type: 'change', listener: (e: CustomEvent<string>) => void): void;
25
+ addEventListener(type: '-change', listener: (e: CustomEvent<string>) => void): void;
26
+ addEventListener(type: '-focus', listener: (e: CustomEvent<void>) => void): void;
27
+ addEventListener(type: '-blur', listener: (e: CustomEvent<void>) => void): void;
26
28
  /** Text field type, `text` by default */
27
29
  setAttribute(name: 'type', value: TSinchInputType): void;
28
30
  /** Value */
@@ -59,6 +61,10 @@ export declare type TSinchInputReact = TSinchElementReact<TSinchInputElement> &
59
61
  invalidText?: string;
60
62
  /** Disabled */
61
63
  disabled?: boolean;
64
+ /** @deprecated Change value handler */
65
+ onChange?: (e: SyntheticEvent<TSinchInputElement, CustomEvent<string>>) => void;
62
66
  /** Change value handler */
63
- onChange: (e: SyntheticEvent<TSinchInputElement, CustomEvent<string>>) => void;
67
+ 'on-change'?: (e: CustomEvent<string>) => void;
68
+ 'on-focus'?: (e: CustomEvent<void>) => void;
69
+ 'on-blur'?: (e: CustomEvent<void>) => void;
64
70
  };
package/link/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 _$anchor, _$text;
4
+ var _$anchor, _$text, _onAnchorClick, _onAnchorFocus, _onAnchorBlur, _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
10
  import '../icons/open-in-new';
11
- import { defineCustomElement, getBooleanAttribute, getAttribute, updateBooleanAttribute, updateAttribute, NectaryElement, isAttrTrue } from '../utils';
11
+ import { defineCustomElement, getBooleanAttribute, getAttribute, updateBooleanAttribute, updateAttribute, NectaryElement, isAttrTrue, getReactEventHandler } from '../utils';
12
12
  const templateHTML = '<style>:host{display:inline;outline:0}a{font:var(--sinch-font-body);font-size:inherit;line-height:inherit;color:var(--sinch-color-text-link);fill:var(--sinch-color-text-link);--sinch-size-icon:1em}#icon{display:none;margin-left:.2em;vertical-align:-.25em}a:hover{color:var(--sinch-color-tropical-600);fill:var(--sinch-color-tropical-600)}:host([disabled]:not([disabled=false])) a{color:var(--sinch-color-tropical-200);pointer-events:none;cursor:initial;fill:var(--sinch-color-tropical-200)}:host([external]:not([external=false])) #icon{display:inline-block}</style><a><span id="content"></span><sinch-icon-open-in-new id="icon"></sinch-icon-open-in-new></a>';
13
13
  const template = document.createElement('template');
14
14
  template.innerHTML = templateHTML;
15
- defineCustomElement('sinch-link', (_$anchor = new WeakMap(), _$text = new WeakMap(), class extends NectaryElement {
15
+ defineCustomElement('sinch-link', (_$anchor = new WeakMap(), _$text = new WeakMap(), _onAnchorClick = new WeakMap(), _onAnchorFocus = new WeakMap(), _onAnchorBlur = new WeakMap(), _onFocusReactHandler = new WeakMap(), _onBlurReactHandler = new WeakMap(), _onClickReactHandler = new WeakMap(), class extends NectaryElement {
16
16
  constructor() {
17
17
  super();
18
18
 
@@ -26,6 +26,52 @@ defineCustomElement('sinch-link', (_$anchor = new WeakMap(), _$text = new WeakMa
26
26
  value: void 0
27
27
  });
28
28
 
29
+ _classPrivateFieldInitSpec(this, _onAnchorClick, {
30
+ writable: true,
31
+ value: e => {
32
+ if (this.preventDefault) {
33
+ e.preventDefault();
34
+ }
35
+
36
+ this.dispatchEvent(new CustomEvent('-click'));
37
+ }
38
+ });
39
+
40
+ _classPrivateFieldInitSpec(this, _onAnchorFocus, {
41
+ writable: true,
42
+ value: () => {
43
+ this.dispatchEvent(new CustomEvent('-focus'));
44
+ }
45
+ });
46
+
47
+ _classPrivateFieldInitSpec(this, _onAnchorBlur, {
48
+ writable: true,
49
+ value: () => {
50
+ this.dispatchEvent(new CustomEvent('-blur'));
51
+ }
52
+ });
53
+
54
+ _classPrivateFieldInitSpec(this, _onFocusReactHandler, {
55
+ writable: true,
56
+ value: () => {
57
+ getReactEventHandler(this, 'on-focus')?.();
58
+ }
59
+ });
60
+
61
+ _classPrivateFieldInitSpec(this, _onBlurReactHandler, {
62
+ writable: true,
63
+ value: () => {
64
+ getReactEventHandler(this, 'on-blur')?.();
65
+ }
66
+ });
67
+
68
+ _classPrivateFieldInitSpec(this, _onClickReactHandler, {
69
+ writable: true,
70
+ value: e => {
71
+ getReactEventHandler(this, 'on-click')?.(e);
72
+ }
73
+ });
74
+
29
75
  const shadowRoot = this.attachShadow();
30
76
  shadowRoot.appendChild(template.content.cloneNode(true));
31
77
 
@@ -34,6 +80,30 @@ defineCustomElement('sinch-link', (_$anchor = new WeakMap(), _$text = new WeakMa
34
80
  _classPrivateFieldSet(this, _$text, shadowRoot.querySelector('#content'));
35
81
  }
36
82
 
83
+ connectedCallback() {
84
+ _classPrivateFieldGet(this, _$anchor).addEventListener('click', _classPrivateFieldGet(this, _onAnchorClick));
85
+
86
+ _classPrivateFieldGet(this, _$anchor).addEventListener('focus', _classPrivateFieldGet(this, _onAnchorFocus));
87
+
88
+ _classPrivateFieldGet(this, _$anchor).addEventListener('blur', _classPrivateFieldGet(this, _onAnchorBlur));
89
+
90
+ this.addEventListener('-click', _classPrivateFieldGet(this, _onClickReactHandler));
91
+ this.addEventListener('-focus', _classPrivateFieldGet(this, _onFocusReactHandler));
92
+ this.addEventListener('-blur', _classPrivateFieldGet(this, _onBlurReactHandler));
93
+ }
94
+
95
+ disconnectedCallback() {
96
+ _classPrivateFieldGet(this, _$anchor).removeEventListener('click', _classPrivateFieldGet(this, _onAnchorClick));
97
+
98
+ _classPrivateFieldGet(this, _$anchor).removeEventListener('focus', _classPrivateFieldGet(this, _onAnchorFocus));
99
+
100
+ _classPrivateFieldGet(this, _$anchor).removeEventListener('blur', _classPrivateFieldGet(this, _onAnchorBlur));
101
+
102
+ this.removeEventListener('-click', _classPrivateFieldGet(this, _onClickReactHandler));
103
+ this.removeEventListener('-focus', _classPrivateFieldGet(this, _onFocusReactHandler));
104
+ this.removeEventListener('-blur', _classPrivateFieldGet(this, _onBlurReactHandler));
105
+ }
106
+
37
107
  get text() {
38
108
  return getAttribute(this, 'text', '');
39
109
  }
@@ -66,6 +136,14 @@ defineCustomElement('sinch-link', (_$anchor = new WeakMap(), _$text = new WeakMa
66
136
  return getBooleanAttribute(this, 'external');
67
137
  }
68
138
 
139
+ set preventDefault(isPrevented) {
140
+ updateBooleanAttribute(this, 'preventdefault', isPrevented);
141
+ }
142
+
143
+ get preventDefault() {
144
+ return getBooleanAttribute(this, 'preventdefault');
145
+ }
146
+
69
147
  static get observedAttributes() {
70
148
  return ['text', 'href', 'external', 'disabled'];
71
149
  }
package/link/types.d.ts CHANGED
@@ -4,14 +4,23 @@ export declare type TSinchLinkElement = HTMLElement & {
4
4
  href: string;
5
5
  disabled: boolean;
6
6
  external: boolean;
7
+ preventDefault: boolean;
8
+ addEventListener(type: '-click', listener: (e: CustomEvent<void>) => void): void;
9
+ addEventListener(type: '-focus', listener: (e: CustomEvent<void>) => void): void;
10
+ addEventListener(type: '-blur', listener: (e: CustomEvent<void>) => void): void;
7
11
  setAttribute(name: 'text', value: string): void;
8
12
  setAttribute(name: 'href', value: string): void;
9
13
  setAttribute(name: 'disabled', value: ''): void;
10
14
  setAttribute(name: 'external', value: ''): void;
15
+ setAttribute(name: 'preventdefault', value: ''): void;
11
16
  };
12
17
  export declare type TSinchLinkReact = TSinchElementReact<TSinchLinkElement> & {
13
18
  text: string;
14
19
  href: string;
15
20
  disabled?: boolean;
16
21
  external?: boolean;
22
+ preventDefault?: boolean;
23
+ 'on-click'?: (e: CustomEvent<void>) => void;
24
+ 'on-focus'?: (e: CustomEvent<void>) => void;
25
+ 'on-blur'?: (e: CustomEvent<void>) => void;
17
26
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nectary/components",
3
- "version": "0.33.0",
3
+ "version": "0.35.0",
4
4
  "files": [
5
5
  "theme.css",
6
6
  "**/*/*.js",
@@ -1,7 +1,7 @@
1
1
  import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
2
  import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
3
 
4
- var _$left, _$right, _$buttons, _$wrapper, _onValueChange, _onButtonClick, _clamp, _dispatchChangeEvent;
4
+ var _$left, _$right, _$buttons, _$wrapper, _onValueChange, _onButtonClick, _clamp, _dispatchChangeEvent, _onChangeReactHandler;
5
5
 
6
6
  function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
7
7
 
@@ -13,8 +13,8 @@ function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(
13
13
 
14
14
  import '../icons/keyboard-arrow-left';
15
15
  import '../icons/keyboard-arrow-right';
16
- import { defineCustomElement, updateAttribute, getIntegerAttribute, setClass, NectaryElement, getRect } from '../utils';
17
- const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{display:flex;justify-content:center;gap:8px;width:100%;box-sizing:border-box}button{all:initial;width:28px;height:28px;box-sizing:border-box;cursor:pointer;text-align:center;contain:strict;--sinch-color-icon:var(--sinch-color-stormy-500)}button:disabled{--sinch-color-icon:var(--sinch-color-stormy-100);cursor:initial}button>*{pointer-events:none}.page{border-radius:50%;font:var(--sinch-font-body);color:var(--sinch-color-stormy-500)}.page.dots>span{display:none}.page.dots::after{content:"..."}.page.active{font:var(--sinch-font-emphasized-body);background-color:var(--sinch-color-snow-600);pointer-events:none;cursor:initial}.page.hidden{display:none}</style><div id="wrapper"><button id="left"><sinch-icon-keyboard-arrow-left></sinch-icon-keyboard-arrow-left></button> <button class="page"><span>1</span></button> <button class="page active"><span>2</span></button> <button class="page"><span>3</span></button> <button class="page"><span>4</span></button> <button class="page"><span>5</span></button> <button class="page dots"><span>6</span></button> <button class="page"><span>20</span></button> <button id="right"><sinch-icon-keyboard-arrow-right></sinch-icon-keyboard-arrow-right></button></div>';
16
+ import { defineCustomElement, updateAttribute, getIntegerAttribute, setClass, NectaryElement, getRect, getReactEventHandler } from '../utils';
17
+ const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{display:flex;justify-content:center;gap:8px;width:100%;box-sizing:border-box}button{all:initial;width:28px;height:28px;box-sizing:border-box;cursor:pointer;text-align:center;contain:strict;--sinch-color-icon:var(--sinch-color-stormy-500)}button:disabled{--sinch-color-icon:var(--sinch-color-stormy-100);cursor:initial}button>*{pointer-events:none}.page{border-radius:50%;font:var(--sinch-font-body);color:var(--sinch-color-stormy-500)}.page.dots>span{display:none}.page.dots::after{content:"..."}.page.active{font:var(--sinch-font-emphasized-body);background-color:var(--sinch-color-snow-600);pointer-events:none;cursor:initial}.page.hidden{display:none}</style><div id="wrapper"><button id="left"><sinch-icon-keyboard-arrow-left></sinch-icon-keyboard-arrow-left></button><button class="page"><span>1</span></button><button class="page active"><span>2</span></button><button class="page"><span>3</span></button><button class="page"><span>4</span></button><button class="page"><span>5</span></button><button class="page dots"><span>6</span></button><button class="page"><span>20</span></button><button id="right"><sinch-icon-keyboard-arrow-right></sinch-icon-keyboard-arrow-right></button></div>';
18
18
  const NUM_BUTTONS = 7;
19
19
  const MIDDLE_BTN_INDEX = Math.floor(NUM_BUTTONS / 2);
20
20
  const FIRST_BTN_INDEX = 0;
@@ -23,7 +23,7 @@ const DOTS_LEFT_INDEX = 1;
23
23
  const DOTS_RIGHT_INDEX = LAST_BTN_INDEX - 1;
24
24
  const template = document.createElement('template');
25
25
  template.innerHTML = templateHTML;
26
- defineCustomElement('sinch-pagination', (_$left = new WeakMap(), _$right = new WeakMap(), _$buttons = new WeakMap(), _$wrapper = new WeakMap(), _onValueChange = new WeakSet(), _onButtonClick = new WeakMap(), _clamp = new WeakSet(), _dispatchChangeEvent = new WeakSet(), class extends NectaryElement {
26
+ defineCustomElement('sinch-pagination', (_$left = new WeakMap(), _$right = new WeakMap(), _$buttons = new WeakMap(), _$wrapper = new WeakMap(), _onValueChange = new WeakSet(), _onButtonClick = new WeakMap(), _clamp = new WeakSet(), _dispatchChangeEvent = new WeakSet(), _onChangeReactHandler = new WeakMap(), class extends NectaryElement {
27
27
  constructor() {
28
28
  super();
29
29
 
@@ -92,6 +92,13 @@ defineCustomElement('sinch-pagination', (_$left = new WeakMap(), _$right = new W
92
92
  }
93
93
  });
94
94
 
95
+ _classPrivateFieldInitSpec(this, _onChangeReactHandler, {
96
+ writable: true,
97
+ value: e => {
98
+ getReactEventHandler(this, 'on-change')?.(e);
99
+ }
100
+ });
101
+
95
102
  const shadowRoot = this.attachShadow();
96
103
  shadowRoot.appendChild(template.content.cloneNode(true));
97
104
 
@@ -108,10 +115,14 @@ defineCustomElement('sinch-pagination', (_$left = new WeakMap(), _$right = new W
108
115
  _classPrivateMethodGet(this, _onValueChange, _onValueChange2).call(this);
109
116
 
110
117
  _classPrivateFieldGet(this, _$wrapper).addEventListener('click', _classPrivateFieldGet(this, _onButtonClick));
118
+
119
+ this.addEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
111
120
  }
112
121
 
113
122
  disconnectedCallback() {
114
123
  _classPrivateFieldGet(this, _$wrapper).removeEventListener('click', _classPrivateFieldGet(this, _onButtonClick));
124
+
125
+ this.removeEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
115
126
  }
116
127
 
117
128
  static get observedAttributes() {
@@ -217,14 +228,19 @@ function _onValueChange2() {
217
228
  _classPrivateFieldGet(this, _$right).disabled = isValueBad || value === max - 1;
218
229
  }
219
230
 
220
- function _clamp2(value, max) {
221
- return Math.max(0, Math.min(max - 1, value));
231
+ function _clamp2(value) {
232
+ const max = getIntegerAttribute(this, 'max', 0);
233
+ return Math.max(0, Math.min(max - 1, value)) + 1;
222
234
  }
223
235
 
224
236
  function _dispatchChangeEvent2(value) {
225
- const max = getIntegerAttribute(this, 'max', 0);
237
+ const detail = _classPrivateMethodGet(this, _clamp, _clamp2).call(this, value);
238
+
226
239
  this.dispatchEvent(new CustomEvent('change', {
227
- detail: _classPrivateMethodGet(this, _clamp, _clamp2).call(this, value, max) + 1,
240
+ detail,
228
241
  bubbles: true
229
242
  }));
243
+ this.dispatchEvent(new CustomEvent('-change', {
244
+ detail
245
+ }));
230
246
  }
@@ -7,11 +7,13 @@ export declare type TSinchPaginationElement = HTMLElement & {
7
7
  readonly nextButtonRect: TRect;
8
8
  nthButtonRect(index: number): TRect | null;
9
9
  addEventListener(type: 'change', listener: (e: CustomEvent<number>) => void): void;
10
+ addEventListener(type: '-change', listener: (e: CustomEvent<number>) => void): void;
10
11
  setAttribute(name: 'value', value: string): void;
11
12
  setAttribute(name: 'max', value: string): void;
12
13
  };
13
14
  export declare type TSinchPaginationReact = TSinchElementReact<TSinchPaginationElement> & {
14
15
  value: number;
15
16
  max: number;
16
- onChange: (event: SyntheticEvent<TSinchPaginationElement, CustomEvent<number>>) => void;
17
+ onChange?: (event: SyntheticEvent<TSinchPaginationElement, CustomEvent<number>>) => void;
18
+ 'on-change': (e: CustomEvent<number>) => void;
17
19
  };
package/popover/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
2
  import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
3
 
4
- var _$target, _$dialog, _isConnected, _resizeThrottle, _prevOverflowValue, _onExpand, _onCollapse, _isOpen, _onResize, _updateOrientation, _updateOrientationModal, _onBackdropClick, _onCancel, _onCloseReactHandler, _onTargetKeydown, _dispatchCloseEvent;
4
+ var _$target, _$dialog, _isConnected, _resizeThrottle, _prevOverflowValue, _onExpand, _onCollapse, _isOpen, _onResize, _updateOrientation, _updateOrientationModal, _onBackdropMouseDown, _onCancel, _onCloseReactHandler, _onTargetKeydown, _dispatchCloseEvent;
5
5
 
6
6
  function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
7
7
 
@@ -18,7 +18,7 @@ import { orientationValues } from './utils';
18
18
  const template = document.createElement('template');
19
19
  template.innerHTML = templateHTML;
20
20
  const POPOVER_OFFSET = 4;
21
- defineCustomElement('sinch-popover', (_$target = new WeakMap(), _$dialog = new WeakMap(), _isConnected = new WeakMap(), _resizeThrottle = new WeakMap(), _prevOverflowValue = new WeakMap(), _onExpand = new WeakSet(), _onCollapse = new WeakSet(), _isOpen = new WeakSet(), _onResize = new WeakMap(), _updateOrientation = new WeakMap(), _updateOrientationModal = new WeakMap(), _onBackdropClick = new WeakMap(), _onCancel = new WeakMap(), _onCloseReactHandler = new WeakMap(), _onTargetKeydown = new WeakMap(), _dispatchCloseEvent = new WeakSet(), class extends NectaryElement {
21
+ defineCustomElement('sinch-popover', (_$target = new WeakMap(), _$dialog = new WeakMap(), _isConnected = new WeakMap(), _resizeThrottle = new WeakMap(), _prevOverflowValue = new WeakMap(), _onExpand = new WeakSet(), _onCollapse = new WeakSet(), _isOpen = new WeakSet(), _onResize = new WeakMap(), _updateOrientation = new WeakMap(), _updateOrientationModal = new WeakMap(), _onBackdropMouseDown = new WeakMap(), _onCancel = new WeakMap(), _onCloseReactHandler = new WeakMap(), _onTargetKeydown = new WeakMap(), _dispatchCloseEvent = new WeakSet(), class extends NectaryElement {
22
22
  constructor() {
23
23
  super();
24
24
 
@@ -132,7 +132,7 @@ defineCustomElement('sinch-popover', (_$target = new WeakMap(), _$dialog = new W
132
132
  }
133
133
  });
134
134
 
135
- _classPrivateFieldInitSpec(this, _onBackdropClick, {
135
+ _classPrivateFieldInitSpec(this, _onBackdropMouseDown, {
136
136
  writable: true,
137
137
  value: e => {
138
138
  if (e.target !== _classPrivateFieldGet(this, _$dialog)) {
@@ -143,8 +143,6 @@ defineCustomElement('sinch-popover', (_$target = new WeakMap(), _$dialog = new W
143
143
  const isInside = e.x >= rect.x && e.x < rect.x + rect.width && e.y >= rect.y && e.y < rect.y + rect.height;
144
144
 
145
145
  if (!isInside) {
146
- e.stopPropagation();
147
-
148
146
  _classPrivateMethodGet(this, _dispatchCloseEvent, _dispatchCloseEvent2).call(this);
149
147
  }
150
148
  }
@@ -161,8 +159,9 @@ defineCustomElement('sinch-popover', (_$target = new WeakMap(), _$dialog = new W
161
159
 
162
160
  _classPrivateFieldInitSpec(this, _onCloseReactHandler, {
163
161
  writable: true,
164
- value: () => {
162
+ value: e => {
165
163
  getReactEventHandler(this, 'onClose')?.();
164
+ getReactEventHandler(this, 'on-close')?.(e);
166
165
  }
167
166
  });
168
167
 
@@ -201,9 +200,9 @@ defineCustomElement('sinch-popover', (_$target = new WeakMap(), _$dialog = new W
201
200
 
202
201
  _classPrivateFieldGet(this, _$dialog).addEventListener('cancel', _classPrivateFieldGet(this, _onCancel));
203
202
 
204
- _classPrivateFieldGet(this, _$dialog).addEventListener('mousedown', _classPrivateFieldGet(this, _onBackdropClick));
203
+ _classPrivateFieldGet(this, _$dialog).addEventListener('mousedown', _classPrivateFieldGet(this, _onBackdropMouseDown));
205
204
 
206
- this.addEventListener('close', _classPrivateFieldGet(this, _onCloseReactHandler));
205
+ this.addEventListener('-close', _classPrivateFieldGet(this, _onCloseReactHandler));
207
206
 
208
207
  _classPrivateFieldSet(this, _isConnected, true);
209
208
 
@@ -217,9 +216,9 @@ defineCustomElement('sinch-popover', (_$target = new WeakMap(), _$dialog = new W
217
216
  disconnectedCallback() {
218
217
  _classPrivateFieldGet(this, _$dialog).removeEventListener('cancel', _classPrivateFieldGet(this, _onCancel));
219
218
 
220
- _classPrivateFieldGet(this, _$dialog).removeEventListener('mousedown', _classPrivateFieldGet(this, _onBackdropClick));
219
+ _classPrivateFieldGet(this, _$dialog).removeEventListener('mousedown', _classPrivateFieldGet(this, _onBackdropMouseDown));
221
220
 
222
- this.removeEventListener('close', _classPrivateFieldGet(this, _onCloseReactHandler));
221
+ this.removeEventListener('-close', _classPrivateFieldGet(this, _onCloseReactHandler));
223
222
 
224
223
  _classPrivateMethodGet(this, _onCollapse, _onCollapse2).call(this);
225
224
 
@@ -358,7 +357,5 @@ function _isOpen2() {
358
357
  }
359
358
 
360
359
  function _dispatchCloseEvent2() {
361
- this.dispatchEvent(new CustomEvent('close', {
362
- bubbles: true
363
- }));
360
+ this.dispatchEvent(new CustomEvent('-close'));
364
361
  }
@@ -1,5 +1,4 @@
1
1
  import type { TRect, TSinchElementReact } from '../types';
2
- import type { SyntheticEvent } from 'react';
3
2
  export declare type TSinchPopoverOrientation = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'bottom' | 'top';
4
3
  export declare type TSinchPopoverElement = HTMLElement & {
5
4
  /** Open/close state */
@@ -10,7 +9,7 @@ export declare type TSinchPopoverElement = HTMLElement & {
10
9
  modal: boolean;
11
10
  readonly popoverRect: TRect;
12
11
  /** Close event */
13
- addEventListener(type: 'close', listener: (e: CustomEvent<void>) => void): void;
12
+ addEventListener(type: '-close', listener: (e: CustomEvent<void>) => void): void;
14
13
  /** Open/close state */
15
14
  setAttribute(name: 'open', value: ''): void;
16
15
  /** Orientation, where it *points to* from origin */
@@ -28,5 +27,7 @@ export declare type TSinchPopoverReact = TSinchElementReact<TSinchPopoverElement
28
27
  /** Label that is used for a11y */
29
28
  'aria-label': string;
30
29
  /** Close event handler */
31
- onClose?: (event: SyntheticEvent<TSinchPopoverElement, CustomEvent<void>>) => void;
30
+ onClose?: () => void;
31
+ /** Close event handler */
32
+ 'on-close'?: (e: CustomEvent<void>) => void;
32
33
  };
package/radio/index.js CHANGED
@@ -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, _onOptionKeyDown, _onSlotChange, _onOptionChange, _onValueChange, _dispatchChangeEvent, _getFirstOption, _getLastOption, _getNextOption, _getPrevOption, _getEnabledRadioElements, _findSelectedOption;
4
+ var _$slot, _onOptionKeyDown, _onSlotChange, _onOptionChange, _onValueChange, _dispatchChangeEvent, _getFirstOption, _getLastOption, _getNextOption, _getPrevOption, _getEnabledRadioElements, _findSelectedOption, _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, NectaryElement, updateAttribute, updateBooleanAttribute } from '../utils';
14
+ import { defineCustomElement, getAttribute, getBooleanAttribute, getReactEventHandler, NectaryElement, updateAttribute, updateBooleanAttribute } from '../utils';
15
15
  const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:column;gap:8px;box-sizing:border-box;width:100%}</style><div id="wrapper"><slot></slot></div>';
16
16
  const template = document.createElement('template');
17
17
  template.innerHTML = templateHTML;
18
- defineCustomElement('sinch-radio', (_$slot = new WeakMap(), _onOptionKeyDown = new WeakMap(), _onSlotChange = new WeakMap(), _onOptionChange = new WeakMap(), _onValueChange = new WeakSet(), _dispatchChangeEvent = new WeakSet(), _getFirstOption = new WeakSet(), _getLastOption = new WeakSet(), _getNextOption = new WeakSet(), _getPrevOption = new WeakSet(), _getEnabledRadioElements = new WeakSet(), _findSelectedOption = new WeakSet(), class extends NectaryElement {
18
+ defineCustomElement('sinch-radio', (_$slot = new WeakMap(), _onOptionKeyDown = new WeakMap(), _onSlotChange = new WeakMap(), _onOptionChange = new WeakMap(), _onValueChange = new WeakSet(), _dispatchChangeEvent = new WeakSet(), _getFirstOption = new WeakSet(), _getLastOption = new WeakSet(), _getNextOption = new WeakSet(), _getPrevOption = new WeakSet(), _getEnabledRadioElements = new WeakSet(), _findSelectedOption = new WeakSet(), _onChangeReactHandler = new WeakMap(), class extends NectaryElement {
19
19
  constructor() {
20
20
  super();
21
21
 
@@ -95,18 +95,39 @@ defineCustomElement('sinch-radio', (_$slot = new WeakMap(), _onOptionKeyDown = n
95
95
  }
96
96
  });
97
97
 
98
+ _classPrivateFieldInitSpec(this, _onChangeReactHandler, {
99
+ writable: true,
100
+ value: e => {
101
+ getReactEventHandler(this, 'on-change')?.(e);
102
+ }
103
+ });
104
+
98
105
  const shadowRoot = this.attachShadow();
99
106
  shadowRoot.appendChild(template.content.cloneNode(true));
100
- shadowRoot.addEventListener('keydown', _classPrivateFieldGet(this, _onOptionKeyDown));
101
- shadowRoot.addEventListener('change', _classPrivateFieldGet(this, _onOptionChange));
102
107
 
103
108
  _classPrivateFieldSet(this, _$slot, shadowRoot.querySelector('slot'));
104
-
105
- _classPrivateFieldGet(this, _$slot).addEventListener('slotchange', _classPrivateFieldGet(this, _onSlotChange));
106
109
  }
107
110
 
108
111
  connectedCallback() {
109
112
  this.setAttribute('role', 'radiogroup');
113
+
114
+ _classPrivateFieldGet(this, _$slot).addEventListener('slotchange', _classPrivateFieldGet(this, _onSlotChange));
115
+
116
+ _classPrivateFieldGet(this, _$slot).addEventListener('keydown', _classPrivateFieldGet(this, _onOptionKeyDown));
117
+
118
+ _classPrivateFieldGet(this, _$slot).addEventListener('option-change', _classPrivateFieldGet(this, _onOptionChange));
119
+
120
+ this.addEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
121
+ }
122
+
123
+ disconnectedCallback() {
124
+ _classPrivateFieldGet(this, _$slot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onSlotChange));
125
+
126
+ _classPrivateFieldGet(this, _$slot).removeEventListener('keydown', _classPrivateFieldGet(this, _onOptionKeyDown));
127
+
128
+ _classPrivateFieldGet(this, _$slot).removeEventListener('option-change', _classPrivateFieldGet(this, _onOptionChange));
129
+
130
+ this.removeEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
110
131
  }
111
132
 
112
133
  static get observedAttributes() {
@@ -126,6 +147,10 @@ defineCustomElement('sinch-radio', (_$slot = new WeakMap(), _onOptionKeyDown = n
126
147
  }
127
148
 
128
149
  attributeChangedCallback(name, oldVal, newVal) {
150
+ if (oldVal === newVal) {
151
+ return;
152
+ }
153
+
129
154
  switch (name) {
130
155
  case 'value':
131
156
  {
@@ -150,6 +175,9 @@ function _dispatchChangeEvent2(value) {
150
175
  detail: value,
151
176
  bubbles: true
152
177
  }));
178
+ this.dispatchEvent(new CustomEvent('-change', {
179
+ detail: value
180
+ }));
153
181
  }
154
182
 
155
183
  function _getFirstOption2() {
package/radio/types.d.ts CHANGED
@@ -3,10 +3,12 @@ import type { SyntheticEvent } from 'react';
3
3
  export declare type TSinchRadioElement = HTMLElement & {
4
4
  value: string;
5
5
  addEventListener(type: 'change', listener: (e: CustomEvent<boolean>) => void): void;
6
+ addEventListener(type: '-change', listener: (e: CustomEvent<boolean>) => void): void;
6
7
  setAttribute(name: 'value', value: string): void;
7
8
  };
8
9
  export declare type TSinchRadioReact = TSinchElementReact<TSinchRadioElement> & {
9
10
  value: string;
10
11
  'aria-label': string;
11
- onChange: (event: SyntheticEvent<TSinchRadioElement, CustomEvent<boolean>>) => void;
12
+ onChange?: (event: SyntheticEvent<TSinchRadioElement, CustomEvent<boolean>>) => void;
13
+ 'on-change'?: (e: CustomEvent<string>) => void;
12
14
  };
@@ -30,7 +30,7 @@ defineCustomElement('sinch-radio-option', (_$input = new WeakMap(), _$label = ne
30
30
  value: e => {
31
31
  e.stopPropagation();
32
32
  _classPrivateFieldGet(this, _$input).checked = false;
33
- this.dispatchEvent(new CustomEvent('change', {
33
+ this.dispatchEvent(new CustomEvent('option-change', {
34
34
  bubbles: true,
35
35
  detail: this.value
36
36
  }));
package/search/types.d.ts CHANGED
@@ -9,7 +9,6 @@ export declare type TSinchSearchElement = HTMLElement & {
9
9
  selectionEnd: HTMLInputElement['selectionEnd'];
10
10
  selectionDirection: HTMLInputElement['selectionDirection'];
11
11
  readonly dropdownRect: TRect;
12
- addEventListener(type: 'change', listener: (e: CustomEvent<string>) => void): void;
13
12
  setAttribute(name: 'value', value: string): void;
14
13
  setAttribute(name: 'label', value: string): void;
15
14
  setAttribute(name: 'placeholder', value: string): void;