@nectary/components 0.39.0 → 0.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/accordion/index.js +47 -84
  2. package/accordion-item/index.js +30 -53
  3. package/action-menu/index.d.ts +0 -1
  4. package/action-menu/index.js +177 -223
  5. package/action-menu/types.d.ts +8 -18
  6. package/action-menu-option/index.d.ts +1 -0
  7. package/action-menu-option/index.js +52 -62
  8. package/action-menu-option/types.d.ts +9 -0
  9. package/action-menu-option/utils.d.ts +2 -0
  10. package/action-menu-option/utils.js +3 -0
  11. package/alert/index.js +6 -20
  12. package/avatar/index.js +12 -31
  13. package/avatar-badge/index.js +8 -22
  14. package/avatar-status/index.js +1 -1
  15. package/button/index.js +46 -92
  16. package/button/types.d.ts +1 -1
  17. package/card/index.js +21 -59
  18. package/chat-avatar/index.js +8 -22
  19. package/chat-block/index.js +29 -69
  20. package/chat-bubble/index.js +6 -20
  21. package/checkbox/index.js +59 -107
  22. package/chip/index.d.ts +13 -0
  23. package/chip/index.js +140 -0
  24. package/chip/types.d.ts +37 -0
  25. package/color-menu/index.d.ts +14 -0
  26. package/color-menu/index.js +450 -0
  27. package/color-menu/types.d.ts +36 -0
  28. package/color-menu/utils.d.ts +1 -0
  29. package/color-menu/utils.js +15 -0
  30. package/color-swatch/index.d.ts +13 -0
  31. package/color-swatch/index.js +60 -0
  32. package/color-swatch/types.d.ts +11 -0
  33. package/colors.json +61 -49
  34. package/date-picker/index.js +162 -293
  35. package/dialog/index.js +70 -142
  36. package/field/index.js +44 -65
  37. package/file-drop/index.js +123 -200
  38. package/file-picker/index.d.ts +0 -1
  39. package/file-picker/index.js +55 -108
  40. package/file-status/index.js +15 -39
  41. package/help-tooltip/index.js +11 -28
  42. package/horizontal-stepper/index.js +33 -59
  43. package/horizontal-stepper-item/index.js +13 -37
  44. package/icon-button/index.d.ts +1 -0
  45. package/icon-button/index.js +51 -85
  46. package/icon-button/types.d.ts +16 -2
  47. package/icons-channel/notify/index.d.ts +11 -0
  48. package/icons-channel/notify/index.js +4 -0
  49. package/illustrations/create-illustration-class.js +1 -1
  50. package/inline-alert/index.js +29 -81
  51. package/input/index.js +117 -222
  52. package/link/index.js +51 -97
  53. package/list-item/index.js +1 -1
  54. package/package.json +12 -14
  55. package/pagination/index.js +113 -163
  56. package/pop/index.d.ts +11 -0
  57. package/pop/index.js +391 -0
  58. package/pop/types.d.ts +35 -0
  59. package/pop/utils.d.ts +7 -0
  60. package/pop/utils.js +18 -0
  61. package/popover/index.d.ts +1 -0
  62. package/popover/index.js +105 -314
  63. package/popover/types.d.ts +8 -1
  64. package/popover/utils.d.ts +5 -0
  65. package/popover/utils.js +17 -1
  66. package/progress/index.js +9 -28
  67. package/radio/index.js +103 -169
  68. package/radio-option/index.js +28 -48
  69. package/segment/index.js +49 -130
  70. package/segment-collapse/index.js +28 -49
  71. package/segmented-control/index.js +36 -73
  72. package/segmented-control-option/index.js +45 -87
  73. package/segmented-icon-control/index.js +47 -84
  74. package/segmented-icon-control-option/index.js +42 -79
  75. package/select-button/index.d.ts +13 -0
  76. package/select-button/index.js +158 -0
  77. package/select-button/types.d.ts +43 -0
  78. package/select-menu/index.d.ts +11 -0
  79. package/select-menu/index.js +345 -0
  80. package/select-menu/types.d.ts +29 -0
  81. package/{dropdown-text-option → select-menu-option}/index.d.ts +5 -7
  82. package/select-menu-option/index.js +76 -0
  83. package/{select-option → select-menu-option}/types.d.ts +8 -9
  84. package/stop-events/index.js +7 -20
  85. package/table-head-cell/index.js +7 -21
  86. package/tabs/index.js +103 -165
  87. package/tabs-option/index.js +24 -44
  88. package/tag/index.d.ts +0 -1
  89. package/tag/index.js +35 -38
  90. package/tag/types.d.ts +12 -7
  91. package/textarea/index.js +96 -167
  92. package/theme.css +146 -49
  93. package/tile-control/index.js +55 -96
  94. package/tile-control-option/index.js +45 -87
  95. package/time-picker/index.js +216 -368
  96. package/title/index.js +6 -20
  97. package/toast/index.js +32 -70
  98. package/toast-manager/index.js +141 -217
  99. package/toggle/index.js +59 -107
  100. package/tooltip/index.d.ts +2 -0
  101. package/tooltip/index.js +160 -17
  102. package/tooltip/types.d.ts +13 -0
  103. package/tooltip/utils.d.ts +5 -0
  104. package/tooltip/utils.js +25 -1
  105. package/utils/animation.d.ts +17 -0
  106. package/utils/animation.js +142 -0
  107. package/utils/colors.d.ts +5 -0
  108. package/utils/colors.js +5 -0
  109. package/utils/context.d.ts +15 -0
  110. package/utils/context.js +57 -0
  111. package/{utils.d.ts → utils/index.d.ts} +15 -11
  112. package/{utils.js → utils/index.js} +104 -48
  113. package/vertical-stepper/index.js +29 -50
  114. package/vertical-stepper-item/index.js +13 -37
  115. package/dropdown/index.d.ts +0 -12
  116. package/dropdown/index.js +0 -415
  117. package/dropdown/types.d.ts +0 -32
  118. package/dropdown-checkbox-option/index.d.ts +0 -11
  119. package/dropdown-checkbox-option/index.js +0 -88
  120. package/dropdown-checkbox-option/types.d.ts +0 -15
  121. package/dropdown-radio-option/index.d.ts +0 -11
  122. package/dropdown-radio-option/index.js +0 -88
  123. package/dropdown-radio-option/types.d.ts +0 -15
  124. package/dropdown-text-option/index.js +0 -104
  125. package/dropdown-text-option/types.d.ts +0 -16
  126. package/select/index.d.ts +0 -13
  127. package/select/index.js +0 -316
  128. package/select/types.d.ts +0 -53
  129. package/select-option/index.d.ts +0 -11
  130. package/select-option/index.js +0 -8
  131. package/tag/utils.d.ts +0 -5
  132. package/tag/utils.js +0 -6
  133. package/tag-close/index.d.ts +0 -12
  134. package/tag-close/index.js +0 -42
  135. package/tag-close/types.d.ts +0 -5
  136. /package/{dropdown-checkbox-option → chip}/types.js +0 -0
  137. /package/{dropdown-radio-option → color-menu}/types.js +0 -0
  138. /package/{dropdown-text-option → color-swatch}/types.js +0 -0
  139. /package/{dropdown → pop}/types.js +0 -0
  140. /package/{select-option → select-button}/types.js +0 -0
  141. /package/{tag-close → select-menu}/types.js +0 -0
  142. /package/{select → select-menu-option}/types.js +0 -0
@@ -1,12 +1,3 @@
1
- import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
- import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
-
4
- var _$text, _$caption, _$closeWrapper, _$closeSlot, _$actionWrapper, _$actionSlot, _onCloseSlotChange, _onActionSlotChange;
5
-
6
- function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
7
-
8
- function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
9
-
10
1
  import '../icons/report-problem';
11
2
  import '../icons/report';
12
3
  import '../icons/check-circle';
@@ -18,87 +9,38 @@ const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-dire
18
9
  import { assertType, typeValues } from './utils';
19
10
  const template = document.createElement('template');
20
11
  template.innerHTML = templateHTML;
21
- defineCustomElement('sinch-inline-alert', (_$text = new WeakMap(), _$caption = new WeakMap(), _$closeWrapper = new WeakMap(), _$closeSlot = new WeakMap(), _$actionWrapper = new WeakMap(), _$actionSlot = new WeakMap(), _onCloseSlotChange = new WeakMap(), _onActionSlotChange = new WeakMap(), class extends NectaryElement {
12
+ defineCustomElement('sinch-inline-alert', class extends NectaryElement {
13
+ #$text;
14
+ #$caption;
15
+ #$closeWrapper;
16
+ #$closeSlot;
17
+ #$actionWrapper;
18
+ #$actionSlot;
19
+
22
20
  constructor() {
23
21
  super();
24
-
25
- _classPrivateFieldInitSpec(this, _$text, {
26
- writable: true,
27
- value: void 0
28
- });
29
-
30
- _classPrivateFieldInitSpec(this, _$caption, {
31
- writable: true,
32
- value: void 0
33
- });
34
-
35
- _classPrivateFieldInitSpec(this, _$closeWrapper, {
36
- writable: true,
37
- value: void 0
38
- });
39
-
40
- _classPrivateFieldInitSpec(this, _$closeSlot, {
41
- writable: true,
42
- value: void 0
43
- });
44
-
45
- _classPrivateFieldInitSpec(this, _$actionWrapper, {
46
- writable: true,
47
- value: void 0
48
- });
49
-
50
- _classPrivateFieldInitSpec(this, _$actionSlot, {
51
- writable: true,
52
- value: void 0
53
- });
54
-
55
- _classPrivateFieldInitSpec(this, _onCloseSlotChange, {
56
- writable: true,
57
- value: () => {
58
- setClass(_classPrivateFieldGet(this, _$closeWrapper), 'empty', _classPrivateFieldGet(this, _$closeSlot).assignedElements().length === 0);
59
- }
60
- });
61
-
62
- _classPrivateFieldInitSpec(this, _onActionSlotChange, {
63
- writable: true,
64
- value: () => {
65
- setClass(_classPrivateFieldGet(this, _$actionWrapper), 'empty', _classPrivateFieldGet(this, _$actionSlot).assignedElements().length === 0);
66
- }
67
- });
68
-
69
22
  const shadowRoot = this.attachShadow();
70
23
  shadowRoot.appendChild(template.content.cloneNode(true));
71
-
72
- _classPrivateFieldSet(this, _$text, shadowRoot.querySelector('#text'));
73
-
74
- _classPrivateFieldSet(this, _$caption, shadowRoot.querySelector('#caption'));
75
-
76
- _classPrivateFieldSet(this, _$closeWrapper, shadowRoot.querySelector('#close'));
77
-
78
- _classPrivateFieldSet(this, _$closeSlot, shadowRoot.querySelector('slot[name="close"]'));
79
-
80
- _classPrivateFieldSet(this, _$actionWrapper, shadowRoot.querySelector('#action'));
81
-
82
- _classPrivateFieldSet(this, _$actionSlot, shadowRoot.querySelector('slot[name="action"]'));
24
+ this.#$text = shadowRoot.querySelector('#text');
25
+ this.#$caption = shadowRoot.querySelector('#caption');
26
+ this.#$closeWrapper = shadowRoot.querySelector('#close');
27
+ this.#$closeSlot = shadowRoot.querySelector('slot[name="close"]');
28
+ this.#$actionWrapper = shadowRoot.querySelector('#action');
29
+ this.#$actionSlot = shadowRoot.querySelector('slot[name="action"]');
83
30
  }
84
31
 
85
32
  connectedCallback() {
86
33
  this.setAttribute('aria-atomic', 'true');
87
34
  this.setAttribute('aria-live', 'polite');
88
-
89
- _classPrivateFieldGet(this, _$closeSlot).addEventListener('slotchange', _classPrivateFieldGet(this, _onCloseSlotChange));
90
-
91
- _classPrivateFieldGet(this, _$actionSlot).addEventListener('slotchange', _classPrivateFieldGet(this, _onActionSlotChange));
92
-
93
- _classPrivateFieldGet(this, _onCloseSlotChange).call(this);
94
-
95
- _classPrivateFieldGet(this, _onActionSlotChange).call(this);
35
+ this.#$closeSlot.addEventListener('slotchange', this.#onCloseSlotChange);
36
+ this.#$actionSlot.addEventListener('slotchange', this.#onActionSlotChange);
37
+ this.#onCloseSlotChange();
38
+ this.#onActionSlotChange();
96
39
  }
97
40
 
98
41
  disconnectedCallback() {
99
- _classPrivateFieldGet(this, _$closeSlot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onCloseSlotChange));
100
-
101
- _classPrivateFieldGet(this, _$actionSlot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onActionSlotChange));
42
+ this.#$closeSlot.removeEventListener('slotchange', this.#onCloseSlotChange);
43
+ this.#$actionSlot.removeEventListener('slotchange', this.#onActionSlotChange);
102
44
  }
103
45
 
104
46
  get type() {
@@ -139,16 +81,22 @@ defineCustomElement('sinch-inline-alert', (_$text = new WeakMap(), _$caption = n
139
81
 
140
82
  case 'text':
141
83
  {
142
- _classPrivateFieldGet(this, _$text).textContent = newVal;
84
+ this.#$text.textContent = newVal;
143
85
  break;
144
86
  }
145
87
 
146
88
  case 'caption':
147
89
  {
148
- updateAttribute(_classPrivateFieldGet(this, _$caption), 'text', newVal);
90
+ updateAttribute(this.#$caption, 'text', newVal);
149
91
  break;
150
92
  }
151
93
  }
152
94
  }
153
95
 
154
- }));
96
+ #onCloseSlotChange = () => {
97
+ setClass(this.#$closeWrapper, 'empty', this.#$closeSlot.assignedElements().length === 0);
98
+ };
99
+ #onActionSlotChange = () => {
100
+ setClass(this.#$actionWrapper, 'empty', this.#$actionSlot.assignedElements().length === 0);
101
+ };
102
+ });
package/input/index.js CHANGED
@@ -1,220 +1,57 @@
1
- import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
- import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
-
4
- var _$input, _$iconSlot, _$iconWrapper, _$rightSlot, _$rightWrapper, _cursorPos, _isPendingDk, _onCompositionStart, _onSelectionChange, _onInput, _onIconSlotChange, _onRightSlotChange, _onInputFocus, _onInputBlur, _onChangeReactHandler, _onFocusReactHandler, _onBlurReactHandler;
5
-
6
- function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
7
-
8
- function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
9
-
10
1
  import { defineCustomElement, getAttribute, getBooleanAttribute, getLiteralAttribute, getReactEventHandler, isAttrTrue, NectaryElement, setClass, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute, updateLiteralAttribute } from '../utils';
11
- const templateHTML = '<style>:host{display:inline-block;vertical-align:middle}#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);--sinch-color-icon:var(--sinch-color-stormy-500)}#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)}#input::placeholder{font:var(--sinch-font-body);color:var(--sinch-color-text-muted);opacity:1}#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([invalid]:not([invalid=false]):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}#icon{display:flex;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}:host([disabled]:not([disabled=false])){--sinch-color-icon:var(--sinch-color-stormy-100)}</style><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>';
2
+ const templateHTML = '<style>:host{display:inline-block;vertical-align:middle}#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);--sinch-color-icon:var(--sinch-color-stormy-500)}#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)}#input::placeholder{font:var(--sinch-font-body);color:var(--sinch-color-text-muted);opacity:1}#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([invalid]:not([invalid=false]):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}#icon{display:flex;position:absolute;left:12px;top:12px;pointer-events:none;--sinch-size-icon: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}:host([disabled]:not([disabled=false])){--sinch-color-icon:var(--sinch-color-stormy-100)}</style><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>';
12
3
  import { inputTypes } from './utils';
13
4
  const template = document.createElement('template');
14
5
  template.innerHTML = templateHTML;
15
- defineCustomElement('sinch-input', (_$input = 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 {
6
+ defineCustomElement('sinch-input', class extends NectaryElement {
7
+ #$input;
8
+ #$iconSlot;
9
+ #$iconWrapper;
10
+ #$rightSlot;
11
+ #$rightWrapper;
12
+ #cursorPos = null;
13
+ #isPendingDk = false;
14
+
16
15
  constructor() {
17
16
  super();
18
-
19
- _classPrivateFieldInitSpec(this, _$input, {
20
- writable: true,
21
- value: void 0
22
- });
23
-
24
- _classPrivateFieldInitSpec(this, _$iconSlot, {
25
- writable: true,
26
- value: void 0
27
- });
28
-
29
- _classPrivateFieldInitSpec(this, _$iconWrapper, {
30
- writable: true,
31
- value: void 0
32
- });
33
-
34
- _classPrivateFieldInitSpec(this, _$rightSlot, {
35
- writable: true,
36
- value: void 0
37
- });
38
-
39
- _classPrivateFieldInitSpec(this, _$rightWrapper, {
40
- writable: true,
41
- value: void 0
42
- });
43
-
44
- _classPrivateFieldInitSpec(this, _cursorPos, {
45
- writable: true,
46
- value: null
47
- });
48
-
49
- _classPrivateFieldInitSpec(this, _isPendingDk, {
50
- writable: true,
51
- value: false
52
- });
53
-
54
- _classPrivateFieldInitSpec(this, _onCompositionStart, {
55
- writable: true,
56
- value: () => {
57
- _classPrivateFieldSet(this, _isPendingDk, true);
58
- }
59
- });
60
-
61
- _classPrivateFieldInitSpec(this, _onSelectionChange, {
62
- writable: true,
63
- value: () => {
64
- _classPrivateFieldSet(this, _cursorPos, _classPrivateFieldGet(this, _$input).selectionEnd);
65
- }
66
- });
67
-
68
- _classPrivateFieldInitSpec(this, _onInput, {
69
- writable: true,
70
- value: e => {
71
- e.stopPropagation();
72
-
73
- const nextValue = _classPrivateFieldGet(this, _$input).value;
74
-
75
- const prevValue = this.value;
76
-
77
- if (prevValue !== nextValue) {
78
- const nextCursorPos = _classPrivateFieldGet(this, _$input).selectionEnd;
79
-
80
- if (!_classPrivateFieldGet(this, _isPendingDk)) {
81
- _classPrivateFieldGet(this, _$input).value = prevValue;
82
-
83
- const prevCursorPos = _classPrivateFieldGet(this, _cursorPos);
84
-
85
- const isPrevCursorEnd = prevCursorPos === null || prevCursorPos === prevValue.length;
86
-
87
- if (!isPrevCursorEnd) {
88
- _classPrivateFieldGet(this, _$input).setSelectionRange(prevCursorPos, prevCursorPos);
89
- }
90
- }
91
-
92
- _classPrivateFieldSet(this, _isPendingDk, false);
93
-
94
- _classPrivateFieldSet(this, _cursorPos, nextCursorPos);
95
-
96
- this.dispatchEvent(new CustomEvent('change', {
97
- detail: nextValue,
98
- bubbles: true
99
- }));
100
- this.dispatchEvent(new CustomEvent('-change', {
101
- detail: nextValue
102
- }));
103
- }
104
- }
105
- });
106
-
107
- _classPrivateFieldInitSpec(this, _onIconSlotChange, {
108
- writable: true,
109
- value: () => {
110
- setClass(_classPrivateFieldGet(this, _$iconWrapper), 'empty', _classPrivateFieldGet(this, _$iconSlot).assignedElements().length === 0);
111
- }
112
- });
113
-
114
- _classPrivateFieldInitSpec(this, _onRightSlotChange, {
115
- writable: true,
116
- value: () => {
117
- setClass(_classPrivateFieldGet(this, _$rightWrapper), 'empty', _classPrivateFieldGet(this, _$rightSlot).assignedElements().length === 0);
118
- }
119
- });
120
-
121
- _classPrivateFieldInitSpec(this, _onInputFocus, {
122
- writable: true,
123
- value: () => {
124
- this.dispatchEvent(new CustomEvent('-focus'));
125
- }
126
- });
127
-
128
- _classPrivateFieldInitSpec(this, _onInputBlur, {
129
- writable: true,
130
- value: () => {
131
- this.dispatchEvent(new CustomEvent('-blur'));
132
- }
133
- });
134
-
135
- _classPrivateFieldInitSpec(this, _onChangeReactHandler, {
136
- writable: true,
137
- value: e => {
138
- getReactEventHandler(this, 'on-change')?.(e);
139
- }
140
- });
141
-
142
- _classPrivateFieldInitSpec(this, _onFocusReactHandler, {
143
- writable: true,
144
- value: () => {
145
- getReactEventHandler(this, 'on-focus')?.();
146
- }
147
- });
148
-
149
- _classPrivateFieldInitSpec(this, _onBlurReactHandler, {
150
- writable: true,
151
- value: () => {
152
- getReactEventHandler(this, 'on-blur')?.();
153
- }
154
- });
155
-
156
17
  const shadowRoot = this.attachShadow();
157
18
  shadowRoot.appendChild(template.content.cloneNode(true));
158
-
159
- _classPrivateFieldSet(this, _$input, shadowRoot.querySelector('#input'));
160
-
161
- _classPrivateFieldSet(this, _$iconSlot, shadowRoot.querySelector('slot[name="icon"]'));
162
-
163
- _classPrivateFieldSet(this, _$iconWrapper, shadowRoot.querySelector('#icon'));
164
-
165
- _classPrivateFieldSet(this, _$rightSlot, shadowRoot.querySelector('slot[name="right"]'));
166
-
167
- _classPrivateFieldSet(this, _$rightWrapper, shadowRoot.querySelector('#right'));
19
+ this.#$input = shadowRoot.querySelector('#input');
20
+ this.#$iconSlot = shadowRoot.querySelector('slot[name="icon"]');
21
+ this.#$iconWrapper = shadowRoot.querySelector('#icon');
22
+ this.#$rightSlot = shadowRoot.querySelector('slot[name="right"]');
23
+ this.#$rightWrapper = shadowRoot.querySelector('#right');
168
24
  }
169
25
 
170
26
  connectedCallback() {
171
27
  this.setAttribute('role', 'textbox');
172
-
173
- _classPrivateFieldGet(this, _$input).addEventListener('input', _classPrivateFieldGet(this, _onInput));
174
-
175
- _classPrivateFieldGet(this, _$input).addEventListener('compositionstart', _classPrivateFieldGet(this, _onCompositionStart));
176
-
177
- _classPrivateFieldGet(this, _$input).addEventListener('mousedown', _classPrivateFieldGet(this, _onSelectionChange));
178
-
179
- _classPrivateFieldGet(this, _$input).addEventListener('keydown', _classPrivateFieldGet(this, _onSelectionChange));
180
-
181
- _classPrivateFieldGet(this, _$input).addEventListener('focus', _classPrivateFieldGet(this, _onInputFocus));
182
-
183
- _classPrivateFieldGet(this, _$input).addEventListener('blur', _classPrivateFieldGet(this, _onInputBlur));
184
-
185
- _classPrivateFieldGet(this, _$iconSlot).addEventListener('slotchange', _classPrivateFieldGet(this, _onIconSlotChange));
186
-
187
- _classPrivateFieldGet(this, _$rightSlot).addEventListener('slotchange', _classPrivateFieldGet(this, _onRightSlotChange));
188
-
189
- this.addEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
190
- this.addEventListener('-focus', _classPrivateFieldGet(this, _onFocusReactHandler));
191
- this.addEventListener('-blur', _classPrivateFieldGet(this, _onBlurReactHandler));
192
-
193
- _classPrivateFieldGet(this, _onIconSlotChange).call(this);
194
-
195
- _classPrivateFieldGet(this, _onRightSlotChange).call(this);
28
+ this.#$input.addEventListener('input', this.#onInput);
29
+ this.#$input.addEventListener('compositionstart', this.#onCompositionStart);
30
+ this.#$input.addEventListener('mousedown', this.#onSelectionChange);
31
+ this.#$input.addEventListener('keydown', this.#onSelectionChange);
32
+ this.#$input.addEventListener('focus', this.#onInputFocus);
33
+ this.#$input.addEventListener('blur', this.#onInputBlur);
34
+ this.#$iconSlot.addEventListener('slotchange', this.#onIconSlotChange);
35
+ this.#$rightSlot.addEventListener('slotchange', this.#onRightSlotChange);
36
+ this.addEventListener('-change', this.#onChangeReactHandler);
37
+ this.addEventListener('-focus', this.#onFocusReactHandler);
38
+ this.addEventListener('-blur', this.#onBlurReactHandler);
39
+ this.#onIconSlotChange();
40
+ this.#onRightSlotChange();
196
41
  }
197
42
 
198
43
  disconnectedCallback() {
199
- _classPrivateFieldGet(this, _$input).removeEventListener('input', _classPrivateFieldGet(this, _onInput));
200
-
201
- _classPrivateFieldGet(this, _$input).removeEventListener('compositionstart', _classPrivateFieldGet(this, _onCompositionStart));
202
-
203
- _classPrivateFieldGet(this, _$input).removeEventListener('mousedown', _classPrivateFieldGet(this, _onSelectionChange));
204
-
205
- _classPrivateFieldGet(this, _$input).removeEventListener('keydown', _classPrivateFieldGet(this, _onSelectionChange));
206
-
207
- _classPrivateFieldGet(this, _$input).removeEventListener('focus', _classPrivateFieldGet(this, _onInputFocus));
208
-
209
- _classPrivateFieldGet(this, _$input).removeEventListener('blur', _classPrivateFieldGet(this, _onInputBlur));
210
-
211
- _classPrivateFieldGet(this, _$iconSlot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onIconSlotChange));
212
-
213
- _classPrivateFieldGet(this, _$rightSlot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onRightSlotChange));
214
-
215
- this.removeEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
216
- this.removeEventListener('-focus', _classPrivateFieldGet(this, _onFocusReactHandler));
217
- this.removeEventListener('-blur', _classPrivateFieldGet(this, _onBlurReactHandler));
44
+ this.#$input.removeEventListener('input', this.#onInput);
45
+ this.#$input.removeEventListener('compositionstart', this.#onCompositionStart);
46
+ this.#$input.removeEventListener('mousedown', this.#onSelectionChange);
47
+ this.#$input.removeEventListener('keydown', this.#onSelectionChange);
48
+ this.#$input.removeEventListener('focus', this.#onInputFocus);
49
+ this.#$input.removeEventListener('blur', this.#onInputBlur);
50
+ this.#$iconSlot.removeEventListener('slotchange', this.#onIconSlotChange);
51
+ this.#$rightSlot.removeEventListener('slotchange', this.#onRightSlotChange);
52
+ this.removeEventListener('-change', this.#onChangeReactHandler);
53
+ this.removeEventListener('-focus', this.#onFocusReactHandler);
54
+ this.removeEventListener('-blur', this.#onBlurReactHandler);
218
55
  }
219
56
 
220
57
  static get observedAttributes() {
@@ -246,7 +83,7 @@ defineCustomElement('sinch-input', (_$input = new WeakMap(), _$iconSlot = new We
246
83
  }
247
84
 
248
85
  get placeholder() {
249
- return getAttribute(this, 'placeholder', null);
86
+ return getAttribute(this, 'placeholder');
250
87
  }
251
88
 
252
89
  set invalid(isInvalid) {
@@ -266,51 +103,49 @@ defineCustomElement('sinch-input', (_$input = new WeakMap(), _$iconSlot = new We
266
103
  }
267
104
 
268
105
  get selectionStart() {
269
- return _classPrivateFieldGet(this, _$input).selectionStart;
106
+ return this.#$input.selectionStart;
270
107
  }
271
108
 
272
109
  set selectionStart(value) {
273
- _classPrivateFieldGet(this, _$input).selectionStart = value;
110
+ this.#$input.selectionStart = value;
274
111
  }
275
112
 
276
113
  get selectionEnd() {
277
- return _classPrivateFieldGet(this, _$input).selectionEnd;
114
+ return this.#$input.selectionEnd;
278
115
  }
279
116
 
280
117
  set selectionEnd(value) {
281
- _classPrivateFieldGet(this, _$input).selectionEnd = value;
118
+ this.#$input.selectionEnd = value;
282
119
  }
283
120
 
284
121
  get selectionDirection() {
285
- return _classPrivateFieldGet(this, _$input).selectionDirection;
122
+ return this.#$input.selectionDirection;
286
123
  }
287
124
 
288
125
  set selectionDirection(value) {
289
- _classPrivateFieldGet(this, _$input).selectionDirection = value;
126
+ this.#$input.selectionDirection = value;
290
127
  }
291
128
 
292
129
  attributeChangedCallback(name, _, newVal) {
293
130
  switch (name) {
294
131
  case 'type':
295
132
  {
296
- updateLiteralAttribute(_classPrivateFieldGet(this, _$input), inputTypes, 'type', newVal);
133
+ updateLiteralAttribute(this.#$input, inputTypes, 'type', newVal);
297
134
  break;
298
135
  }
299
136
 
300
137
  case 'value':
301
138
  {
302
139
  const nextVal = newVal ?? '';
303
-
304
- const prevVal = _classPrivateFieldGet(this, _$input).value;
140
+ const prevVal = this.#$input.value;
305
141
 
306
142
  if (nextVal !== prevVal) {
307
- const prevCursorPos = _classPrivateFieldGet(this, _$input).selectionEnd;
308
-
143
+ const prevCursorPos = this.#$input.selectionEnd;
309
144
  const isPrevCursorEnd = prevCursorPos === prevVal.length;
310
- _classPrivateFieldGet(this, _$input).value = nextVal;
145
+ this.#$input.value = nextVal;
311
146
 
312
147
  if (!isPrevCursorEnd) {
313
- _classPrivateFieldGet(this, _$input).setSelectionRange(_classPrivateFieldGet(this, _cursorPos), _classPrivateFieldGet(this, _cursorPos));
148
+ this.#$input.setSelectionRange(this.#cursorPos, this.#cursorPos);
314
149
  }
315
150
  }
316
151
 
@@ -319,7 +154,7 @@ defineCustomElement('sinch-input', (_$input = new WeakMap(), _$iconSlot = new We
319
154
 
320
155
  case 'placeholder':
321
156
  {
322
- _classPrivateFieldGet(this, _$input).placeholder = newVal ?? '';
157
+ this.#$input.placeholder = newVal ?? '';
323
158
  updateAttribute(this, 'aria-placeholder', newVal);
324
159
  break;
325
160
  }
@@ -333,19 +168,79 @@ defineCustomElement('sinch-input', (_$input = new WeakMap(), _$iconSlot = new We
333
168
  case 'disabled':
334
169
  {
335
170
  const isDisabled = isAttrTrue(newVal);
336
- _classPrivateFieldGet(this, _$input).disabled = isDisabled;
171
+ this.#$input.disabled = isDisabled;
337
172
  updateBooleanAttribute(this, 'disabled', isDisabled);
338
173
  break;
339
174
  }
340
175
  }
341
176
  }
342
177
 
178
+ get focusable() {
179
+ return true;
180
+ }
181
+
343
182
  focus() {
344
- _classPrivateFieldGet(this, _$input).focus();
183
+ this.#$input.focus();
345
184
  }
346
185
 
347
186
  blur() {
348
- _classPrivateFieldGet(this, _$input).blur();
349
- }
187
+ this.#$input.blur();
188
+ }
189
+
190
+ #onCompositionStart = () => {
191
+ this.#isPendingDk = true;
192
+ };
193
+ #onSelectionChange = () => {
194
+ this.#cursorPos = this.#$input.selectionEnd;
195
+ };
196
+ #onInput = e => {
197
+ e.stopPropagation();
198
+ const nextValue = this.#$input.value;
199
+ const prevValue = this.value;
200
+
201
+ if (prevValue !== nextValue) {
202
+ const nextCursorPos = this.#$input.selectionEnd;
203
+
204
+ if (!this.#isPendingDk) {
205
+ this.#$input.value = prevValue;
206
+ const prevCursorPos = this.#cursorPos;
207
+ const isPrevCursorEnd = prevCursorPos === null || prevCursorPos === prevValue.length;
208
+
209
+ if (!isPrevCursorEnd) {
210
+ this.#$input.setSelectionRange(prevCursorPos, prevCursorPos);
211
+ }
212
+ }
350
213
 
351
- }));
214
+ this.#isPendingDk = false;
215
+ this.#cursorPos = nextCursorPos;
216
+ this.dispatchEvent(new CustomEvent('change', {
217
+ detail: nextValue,
218
+ bubbles: true
219
+ }));
220
+ this.dispatchEvent(new CustomEvent('-change', {
221
+ detail: nextValue
222
+ }));
223
+ }
224
+ };
225
+ #onIconSlotChange = () => {
226
+ setClass(this.#$iconWrapper, 'empty', this.#$iconSlot.assignedElements().length === 0);
227
+ };
228
+ #onRightSlotChange = () => {
229
+ setClass(this.#$rightWrapper, 'empty', this.#$rightSlot.assignedElements().length === 0);
230
+ };
231
+ #onInputFocus = () => {
232
+ this.dispatchEvent(new CustomEvent('-focus'));
233
+ };
234
+ #onInputBlur = () => {
235
+ this.dispatchEvent(new CustomEvent('-blur'));
236
+ };
237
+ #onChangeReactHandler = e => {
238
+ getReactEventHandler(this, 'on-change')?.(e);
239
+ };
240
+ #onFocusReactHandler = () => {
241
+ getReactEventHandler(this, 'on-focus')?.();
242
+ };
243
+ #onBlurReactHandler = () => {
244
+ getReactEventHandler(this, 'on-blur')?.();
245
+ };
246
+ });