@nectary/components 0.39.0 → 0.40.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 (115) hide show
  1. package/accordion/index.js +47 -84
  2. package/accordion-item/index.js +26 -53
  3. package/action-menu/index.d.ts +0 -1
  4. package/action-menu/index.js +179 -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 +51 -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 +42 -92
  16. package/card/index.js +21 -59
  17. package/chat-avatar/index.js +8 -22
  18. package/chat-block/index.js +29 -69
  19. package/chat-bubble/index.js +6 -20
  20. package/checkbox/index.js +55 -107
  21. package/chip/index.d.ts +13 -0
  22. package/chip/index.js +137 -0
  23. package/chip/types.d.ts +38 -0
  24. package/color-menu/index.d.ts +13 -0
  25. package/color-menu/index.js +464 -0
  26. package/color-menu/types.d.ts +37 -0
  27. package/color-swatch/index.d.ts +13 -0
  28. package/color-swatch/index.js +59 -0
  29. package/color-swatch/types.d.ts +12 -0
  30. package/colors.json +57 -49
  31. package/date-picker/index.js +161 -292
  32. package/dialog/index.js +70 -142
  33. package/dropdown-checkbox-option/index.js +6 -20
  34. package/dropdown-radio-option/index.js +6 -20
  35. package/field/index.js +25 -63
  36. package/file-drop/index.js +123 -200
  37. package/file-picker/index.d.ts +0 -1
  38. package/file-picker/index.js +55 -108
  39. package/file-status/index.js +15 -39
  40. package/help-tooltip/index.js +1 -1
  41. package/horizontal-stepper/index.js +33 -59
  42. package/horizontal-stepper-item/index.js +13 -37
  43. package/icon-button/index.js +39 -84
  44. package/icons-channel/notify/index.d.ts +11 -0
  45. package/icons-channel/notify/index.js +4 -0
  46. package/illustrations/create-illustration-class.js +1 -1
  47. package/inline-alert/index.js +29 -81
  48. package/input/index.js +113 -222
  49. package/link/index.js +46 -96
  50. package/list-item/index.js +1 -1
  51. package/package.json +12 -14
  52. package/pagination/index.js +109 -163
  53. package/popover/index.js +224 -294
  54. package/progress/index.js +9 -28
  55. package/radio/index.js +103 -169
  56. package/radio-option/index.js +24 -48
  57. package/segment/index.js +49 -130
  58. package/segment-collapse/index.js +24 -49
  59. package/segmented-control/index.js +36 -73
  60. package/segmented-control-option/index.js +41 -87
  61. package/segmented-icon-control/index.js +47 -84
  62. package/segmented-icon-control-option/index.js +38 -79
  63. package/select-button/index.d.ts +13 -0
  64. package/select-button/index.js +153 -0
  65. package/select-button/types.d.ts +43 -0
  66. package/select-menu/index.d.ts +11 -0
  67. package/select-menu/index.js +346 -0
  68. package/select-menu/types.d.ts +29 -0
  69. package/select-menu/types.js +1 -0
  70. package/{dropdown-text-option → select-menu-option}/index.d.ts +5 -7
  71. package/select-menu-option/index.js +76 -0
  72. package/{select-option → select-menu-option}/types.d.ts +8 -9
  73. package/stop-events/index.js +7 -20
  74. package/table-head-cell/index.js +7 -21
  75. package/tabs/index.js +103 -165
  76. package/tabs-option/index.js +20 -44
  77. package/tag/index.d.ts +0 -1
  78. package/tag/index.js +37 -38
  79. package/tag/types.d.ts +13 -7
  80. package/textarea/index.js +92 -167
  81. package/theme.css +80 -49
  82. package/tile-control/index.js +55 -96
  83. package/tile-control-option/index.js +40 -86
  84. package/time-picker/index.js +216 -368
  85. package/title/index.js +6 -20
  86. package/toast/index.js +32 -70
  87. package/toast-manager/index.js +141 -217
  88. package/toggle/index.js +54 -106
  89. package/types.d.ts +7 -0
  90. package/utils/colors.d.ts +10 -0
  91. package/utils/colors.js +121 -0
  92. package/{utils.d.ts → utils/index.d.ts} +17 -9
  93. package/{utils.js → utils/index.js} +96 -39
  94. package/vertical-stepper/index.js +29 -50
  95. package/vertical-stepper-item/index.js +13 -37
  96. package/dropdown/index.d.ts +0 -12
  97. package/dropdown/index.js +0 -415
  98. package/dropdown/types.d.ts +0 -32
  99. package/dropdown-text-option/index.js +0 -104
  100. package/dropdown-text-option/types.d.ts +0 -16
  101. package/select/index.d.ts +0 -13
  102. package/select/index.js +0 -316
  103. package/select/types.d.ts +0 -53
  104. package/select-option/index.d.ts +0 -11
  105. package/select-option/index.js +0 -8
  106. package/tag/utils.d.ts +0 -5
  107. package/tag/utils.js +0 -6
  108. package/tag-close/index.d.ts +0 -12
  109. package/tag-close/index.js +0 -42
  110. package/tag-close/types.d.ts +0 -5
  111. /package/{dropdown-text-option → chip}/types.js +0 -0
  112. /package/{dropdown → color-menu}/types.js +0 -0
  113. /package/{select-option → color-swatch}/types.js +0 -0
  114. /package/{select → select-button}/types.js +0 -0
  115. /package/{tag-close → select-menu-option}/types.js +0 -0
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,7 +168,7 @@ 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
  }
@@ -341,11 +176,67 @@ defineCustomElement('sinch-input', (_$input = new WeakMap(), _$iconSlot = new We
341
176
  }
342
177
 
343
178
  focus() {
344
- _classPrivateFieldGet(this, _$input).focus();
179
+ this.#$input.focus();
345
180
  }
346
181
 
347
182
  blur() {
348
- _classPrivateFieldGet(this, _$input).blur();
349
- }
183
+ this.#$input.blur();
184
+ }
185
+
186
+ #onCompositionStart = () => {
187
+ this.#isPendingDk = true;
188
+ };
189
+ #onSelectionChange = () => {
190
+ this.#cursorPos = this.#$input.selectionEnd;
191
+ };
192
+ #onInput = e => {
193
+ e.stopPropagation();
194
+ const nextValue = this.#$input.value;
195
+ const prevValue = this.value;
196
+
197
+ if (prevValue !== nextValue) {
198
+ const nextCursorPos = this.#$input.selectionEnd;
199
+
200
+ if (!this.#isPendingDk) {
201
+ this.#$input.value = prevValue;
202
+ const prevCursorPos = this.#cursorPos;
203
+ const isPrevCursorEnd = prevCursorPos === null || prevCursorPos === prevValue.length;
204
+
205
+ if (!isPrevCursorEnd) {
206
+ this.#$input.setSelectionRange(prevCursorPos, prevCursorPos);
207
+ }
208
+ }
350
209
 
351
- }));
210
+ this.#isPendingDk = false;
211
+ this.#cursorPos = nextCursorPos;
212
+ this.dispatchEvent(new CustomEvent('change', {
213
+ detail: nextValue,
214
+ bubbles: true
215
+ }));
216
+ this.dispatchEvent(new CustomEvent('-change', {
217
+ detail: nextValue
218
+ }));
219
+ }
220
+ };
221
+ #onIconSlotChange = () => {
222
+ setClass(this.#$iconWrapper, 'empty', this.#$iconSlot.assignedElements().length === 0);
223
+ };
224
+ #onRightSlotChange = () => {
225
+ setClass(this.#$rightWrapper, 'empty', this.#$rightSlot.assignedElements().length === 0);
226
+ };
227
+ #onInputFocus = () => {
228
+ this.dispatchEvent(new CustomEvent('-focus'));
229
+ };
230
+ #onInputBlur = () => {
231
+ this.dispatchEvent(new CustomEvent('-blur'));
232
+ };
233
+ #onChangeReactHandler = e => {
234
+ getReactEventHandler(this, 'on-change')?.(e);
235
+ };
236
+ #onFocusReactHandler = () => {
237
+ getReactEventHandler(this, 'on-focus')?.();
238
+ };
239
+ #onBlurReactHandler = () => {
240
+ getReactEventHandler(this, 'on-blur')?.();
241
+ };
242
+ });
package/link/index.js CHANGED
@@ -1,110 +1,38 @@
1
- import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
- import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
-
4
- var _$anchor, _$text, _onAnchorClick, _onAnchorFocus, _onAnchorBlur, _onFocusReactHandler, _onBlurReactHandler, _onClickReactHandler;
5
-
6
- function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
7
-
8
- function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
9
-
10
1
  import '../icons/open-in-new';
11
2
  import '../icons/arrow-forward';
12
3
  import { defineCustomElement, getBooleanAttribute, getAttribute, updateBooleanAttribute, updateAttribute, NectaryElement, isAttrTrue, getReactEventHandler } from '../utils';
13
4
  const templateHTML = '<style>:host{display:inline}a{font:var(--sinch-font-text-m);font-size:inherit;line-height:inherit;color:var(--sinch-color-tropical-500);border-radius:.5em;--sinch-size-icon:1em;--sinch-color-icon:var(--sinch-color-tropical-500)}a:hover{color:var(--sinch-color-tropical-600);--sinch-color-icon:var(--sinch-color-tropical-600)}a:focus-visible{outline:2px solid var(--sinch-color-aqua-400);outline-offset:2px}@supports not selector(:focus-visible){a:focus{outline:2px solid var(--sinch-color-aqua-400);outline-offset:2px}}#external-icon{display:none;margin-right:.2em;vertical-align:-.2em}#standalone-icon{display:none}:host([external]:not([external=false])) #external-icon{display:inline-block}:host([standalone]:not([standalone=false])){display:block}:host([standalone]:not([standalone=false])) a{display:block;font:var(--sinch-font-text-m);font-weight:var(--sinch-font-weight-emphasized);text-decoration:none;border-radius:var(--sinch-shape-radius-m);width:fit-content;--sinch-size-icon:24px}:host([standalone]:not([standalone=false])) #external-icon{margin-right:8px;vertical-align:-7px}:host([standalone]:not([standalone=false]):is([external=false],:not([external]))) #standalone-icon{display:inline-block;vertical-align:-7px;margin-left:8px}:host([disabled]:not([disabled=false])) a{color:var(--sinch-color-tropical-200);pointer-events:none;cursor:initial;--sinch-color-icon:var(--sinch-color-tropical-200)}</style><a referrerpolicy="no-referer" aria-hidden="true"><sinch-icon-open-in-new id="external-icon"></sinch-icon-open-in-new><span id="content"></span><sinch-icon-arrow-forward id="standalone-icon"></sinch-icon-arrow-forward></a>';
14
5
  const template = document.createElement('template');
15
6
  template.innerHTML = templateHTML;
16
- 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 {
7
+ defineCustomElement('sinch-link', class extends NectaryElement {
8
+ #$anchor;
9
+ #$text;
10
+
17
11
  constructor() {
18
12
  super();
19
-
20
- _classPrivateFieldInitSpec(this, _$anchor, {
21
- writable: true,
22
- value: void 0
23
- });
24
-
25
- _classPrivateFieldInitSpec(this, _$text, {
26
- writable: true,
27
- value: void 0
28
- });
29
-
30
- _classPrivateFieldInitSpec(this, _onAnchorClick, {
31
- writable: true,
32
- value: e => {
33
- if (this.preventDefault) {
34
- e.preventDefault();
35
- }
36
-
37
- this.dispatchEvent(new CustomEvent('-click'));
38
- }
39
- });
40
-
41
- _classPrivateFieldInitSpec(this, _onAnchorFocus, {
42
- writable: true,
43
- value: () => {
44
- this.dispatchEvent(new CustomEvent('-focus'));
45
- }
46
- });
47
-
48
- _classPrivateFieldInitSpec(this, _onAnchorBlur, {
49
- writable: true,
50
- value: () => {
51
- this.dispatchEvent(new CustomEvent('-blur'));
52
- }
53
- });
54
-
55
- _classPrivateFieldInitSpec(this, _onFocusReactHandler, {
56
- writable: true,
57
- value: () => {
58
- getReactEventHandler(this, 'on-focus')?.();
59
- }
60
- });
61
-
62
- _classPrivateFieldInitSpec(this, _onBlurReactHandler, {
63
- writable: true,
64
- value: () => {
65
- getReactEventHandler(this, 'on-blur')?.();
66
- }
67
- });
68
-
69
- _classPrivateFieldInitSpec(this, _onClickReactHandler, {
70
- writable: true,
71
- value: e => {
72
- getReactEventHandler(this, 'on-click')?.(e);
73
- }
74
- });
75
-
76
13
  const shadowRoot = this.attachShadow();
77
14
  shadowRoot.appendChild(template.content.cloneNode(true));
78
-
79
- _classPrivateFieldSet(this, _$anchor, shadowRoot.querySelector('a'));
80
-
81
- _classPrivateFieldSet(this, _$text, shadowRoot.querySelector('#content'));
15
+ this.#$anchor = shadowRoot.querySelector('a');
16
+ this.#$text = shadowRoot.querySelector('#content');
82
17
  }
83
18
 
84
19
  connectedCallback() {
85
20
  this.setAttribute('role', 'link');
86
-
87
- _classPrivateFieldGet(this, _$anchor).addEventListener('click', _classPrivateFieldGet(this, _onAnchorClick));
88
-
89
- _classPrivateFieldGet(this, _$anchor).addEventListener('focus', _classPrivateFieldGet(this, _onAnchorFocus));
90
-
91
- _classPrivateFieldGet(this, _$anchor).addEventListener('blur', _classPrivateFieldGet(this, _onAnchorBlur));
92
-
93
- this.addEventListener('-click', _classPrivateFieldGet(this, _onClickReactHandler));
94
- this.addEventListener('-focus', _classPrivateFieldGet(this, _onFocusReactHandler));
95
- this.addEventListener('-blur', _classPrivateFieldGet(this, _onBlurReactHandler));
21
+ this.#$anchor.addEventListener('click', this.#onAnchorClick);
22
+ this.#$anchor.addEventListener('focus', this.#onAnchorFocus);
23
+ this.#$anchor.addEventListener('blur', this.#onAnchorBlur);
24
+ this.addEventListener('-click', this.#onClickReactHandler);
25
+ this.addEventListener('-focus', this.#onFocusReactHandler);
26
+ this.addEventListener('-blur', this.#onBlurReactHandler);
96
27
  }
97
28
 
98
29
  disconnectedCallback() {
99
- _classPrivateFieldGet(this, _$anchor).removeEventListener('click', _classPrivateFieldGet(this, _onAnchorClick));
100
-
101
- _classPrivateFieldGet(this, _$anchor).removeEventListener('focus', _classPrivateFieldGet(this, _onAnchorFocus));
102
-
103
- _classPrivateFieldGet(this, _$anchor).removeEventListener('blur', _classPrivateFieldGet(this, _onAnchorBlur));
104
-
105
- this.removeEventListener('-click', _classPrivateFieldGet(this, _onClickReactHandler));
106
- this.removeEventListener('-focus', _classPrivateFieldGet(this, _onFocusReactHandler));
107
- this.removeEventListener('-blur', _classPrivateFieldGet(this, _onBlurReactHandler));
30
+ this.#$anchor.removeEventListener('click', this.#onAnchorClick);
31
+ this.#$anchor.removeEventListener('focus', this.#onAnchorFocus);
32
+ this.#$anchor.removeEventListener('blur', this.#onAnchorBlur);
33
+ this.removeEventListener('-click', this.#onClickReactHandler);
34
+ this.removeEventListener('-focus', this.#onFocusReactHandler);
35
+ this.removeEventListener('-blur', this.#onBlurReactHandler);
108
36
  }
109
37
 
110
38
  get text() {
@@ -167,30 +95,52 @@ defineCustomElement('sinch-link', (_$anchor = new WeakMap(), _$text = new WeakMa
167
95
  switch (name) {
168
96
  case 'text':
169
97
  {
170
- _classPrivateFieldGet(this, _$text).textContent = newVal;
98
+ this.#$text.textContent = newVal;
171
99
  break;
172
100
  }
173
101
 
174
102
  case 'href':
175
103
  {
176
- updateAttribute(_classPrivateFieldGet(this, _$anchor), 'href', newVal);
104
+ updateAttribute(this.#$anchor, 'href', newVal);
177
105
  break;
178
106
  }
179
107
 
180
108
  case 'external':
181
109
  {
182
- updateAttribute(_classPrivateFieldGet(this, _$anchor), 'target', isAttrTrue(newVal) ? '_blank' : null);
110
+ updateAttribute(this.#$anchor, 'target', isAttrTrue(newVal) ? '_blank' : null);
183
111
  break;
184
112
  }
185
113
  }
186
114
  }
187
115
 
188
116
  focus() {
189
- _classPrivateFieldGet(this, _$anchor).focus();
117
+ this.#$anchor.focus();
190
118
  }
191
119
 
192
120
  blur() {
193
- _classPrivateFieldGet(this, _$anchor).blur();
121
+ this.#$anchor.blur();
194
122
  }
195
123
 
196
- }));
124
+ #onAnchorClick = e => {
125
+ if (this.preventDefault) {
126
+ e.preventDefault();
127
+ }
128
+
129
+ this.dispatchEvent(new CustomEvent('-click'));
130
+ };
131
+ #onAnchorFocus = () => {
132
+ this.dispatchEvent(new CustomEvent('-focus'));
133
+ };
134
+ #onAnchorBlur = () => {
135
+ this.dispatchEvent(new CustomEvent('-blur'));
136
+ };
137
+ #onFocusReactHandler = () => {
138
+ getReactEventHandler(this, 'on-focus')?.();
139
+ };
140
+ #onBlurReactHandler = () => {
141
+ getReactEventHandler(this, 'on-blur')?.();
142
+ };
143
+ #onClickReactHandler = e => {
144
+ getReactEventHandler(this, 'on-click')?.(e);
145
+ };
146
+ });
@@ -1,6 +1,6 @@
1
1
  import '../icons/keyboard-arrow-down';
2
2
  import { defineCustomElement, NectaryElement } from '../utils';
3
- const templateHTML = '<style>:host{display:block;outline:0}#wrapper{width:100%;height:100%;box-sizing:border-box;overflow:hidden;padding:8px 0;border-bottom:1px solid var(--sinch-color-snow-600)}:host(:last-child)>#wrapper{border-bottom:none}:host(:hover)>#wrapper{background-color:var(--sinch-color-snow-500)}</style><div id="wrapper"><slot name="content"></slot></div>';
3
+ const templateHTML = '<style>:host{display:block;outline:0}#wrapper{width:100%;height:100%;box-sizing:border-box;overflow:hidden;padding:8px 0;border-bottom:1px solid var(--sinch-color-snow-500)}:host(:last-child)>#wrapper{border-bottom:none}:host(:hover)>#wrapper{background-color:var(--sinch-color-snow-400)}</style><div id="wrapper"><slot name="content"></slot></div>';
4
4
  const template = document.createElement('template');
5
5
  template.innerHTML = templateHTML;
6
6
  defineCustomElement('sinch-list-item', class extends NectaryElement {
package/package.json CHANGED
@@ -1,12 +1,10 @@
1
1
  {
2
2
  "name": "@nectary/components",
3
- "version": "0.39.0",
3
+ "version": "0.40.0",
4
4
  "files": [
5
5
  "theme.css",
6
6
  "**/*/*.js",
7
7
  "**/*/*.d.ts",
8
- "utils.js",
9
- "utils.d.ts",
10
8
  "types.d.ts",
11
9
  "colors.json"
12
10
  ],
@@ -14,19 +12,19 @@
14
12
  "build": "NODE_ENV=production babel . --extensions '.ts' --out-dir . && tsc --declaration --emitDeclarationOnly"
15
13
  },
16
14
  "dependencies": {
17
- "@babel/runtime": "^7.17.0",
15
+ "@babel/runtime": "^7.19.0",
18
16
  "dialog-polyfill": "^0.5.6"
19
17
  },
20
18
  "devDependencies": {
21
- "@babel/cli": "^7.17.0",
22
- "@babel/core": "^7.17.0",
23
- "@babel/plugin-transform-runtime": "^7.17.0",
24
- "@babel/preset-env": "^7.16.0",
25
- "@babel/preset-typescript": "^7.16.0",
26
- "@types/node": "^17.0.14",
27
- "@types/react": "^17.0.0",
28
- "babel-plugin-html-inline-minifier": "workspace:babel-plugin-html-inline-minifier@*",
29
- "babel-plugin-transform-inline-environment-variables": "^0.4.3",
30
- "typescript": "^4.4.2"
19
+ "@babel/cli": "^7.19.3",
20
+ "@babel/core": "^7.19.3",
21
+ "@babel/plugin-transform-runtime": "^7.19.1",
22
+ "@babel/preset-env": "^7.19.3",
23
+ "@babel/preset-typescript": "^7.18.6",
24
+ "@types/node": "^17.0.45",
25
+ "@types/react": "^17.0.50",
26
+ "babel-plugin-html-inline-minifier": "workspace:^0.0.0",
27
+ "babel-plugin-transform-inline-environment-variables": "^0.4.4",
28
+ "typescript": "^4.8.4"
31
29
  }
32
30
  }