@nectary/components 0.36.1 → 0.38.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 (59) hide show
  1. package/alert/index.js +1 -1
  2. package/avatar-badge/index.js +1 -1
  3. package/avatar-status/index.js +1 -1
  4. package/button/types.d.ts +6 -0
  5. package/chat-avatar/index.js +1 -1
  6. package/dialog/index.js +1 -1
  7. package/dropdown-text-option/index.js +1 -1
  8. package/field/index.d.ts +11 -0
  9. package/field/index.js +144 -0
  10. package/field/types.d.ts +35 -0
  11. package/field/types.js +1 -0
  12. package/file-drop/index.d.ts +13 -0
  13. package/file-drop/index.js +320 -0
  14. package/file-drop/types.d.ts +50 -0
  15. package/file-drop/types.js +1 -0
  16. package/file-drop/utils.d.ts +2 -0
  17. package/file-drop/utils.js +37 -0
  18. package/file-picker/index.d.ts +12 -0
  19. package/file-picker/index.js +170 -0
  20. package/file-picker/types.d.ts +32 -0
  21. package/file-picker/types.js +1 -0
  22. package/file-picker/utils.d.ts +1 -0
  23. package/file-picker/utils.js +9 -0
  24. package/file-status/index.d.ts +17 -0
  25. package/file-status/index.js +100 -0
  26. package/file-status/types.d.ts +18 -0
  27. package/file-status/types.js +1 -0
  28. package/file-status/utils.d.ts +5 -0
  29. package/file-status/utils.js +6 -0
  30. package/icons-branded/easytouse/index.d.ts +11 -0
  31. package/icons-branded/easytouse/index.js +4 -0
  32. package/illustrations/create-illustration-class.js +1 -1
  33. package/inline-alert/index.js +1 -1
  34. package/inline-alert/types.d.ts +2 -2
  35. package/input/index.js +10 -82
  36. package/input/types.d.ts +10 -24
  37. package/link/index.d.ts +1 -0
  38. package/link/index.js +19 -12
  39. package/link/types.d.ts +29 -0
  40. package/package.json +2 -2
  41. package/popover/index.js +37 -15
  42. package/progress/index.d.ts +17 -0
  43. package/progress/index.js +87 -0
  44. package/progress/types.d.ts +12 -0
  45. package/progress/types.js +1 -0
  46. package/search/index.js +1 -1
  47. package/select/index.d.ts +1 -0
  48. package/select/index.js +12 -94
  49. package/select/types.d.ts +6 -24
  50. package/spinner/index.js +1 -1
  51. package/text/index.js +9 -1
  52. package/text/types.d.ts +3 -0
  53. package/textarea/index.js +15 -83
  54. package/textarea/types.d.ts +28 -12
  55. package/title/index.js +10 -2
  56. package/title/types.d.ts +3 -0
  57. package/utils.d.ts +2 -0
  58. package/utils.js +26 -1
  59. package/vertical-stepper-item/index.js +1 -1
package/select/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import '../dropdown';
2
+ import '../icons/keyboard-arrow-down';
2
3
  import type { TSinchSelectElement, TSinchSelectReact } from './types';
3
4
  declare global {
4
5
  namespace JSX {
package/select/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 _$button, _$buttonContent, _$label, _$optionalText, _$additionalText, _$invalidText, _$dropdown, _$optionSlot, _$sh, _createElement, _updateButtonContent, _onValueChange, _getOptionWithValue, _onLabelClick, _onDropdownClick, _onDropdownClose, _onButtonFocus, _onButtonBlur, _onChangeReactHandler, _onFocusReactHandler, _onBlurReactHandler;
4
+ var _$button, _$buttonContent, _$dropdown, _$optionSlot, _$sh, _createElement, _updateButtonContent, _onValueChange, _getOptionWithValue, _onDropdownClick, _onDropdownClose, _onButtonFocus, _onButtonBlur, _onChangeReactHandler, _onFocusReactHandler, _onBlurReactHandler;
5
5
 
6
6
  function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
7
7
 
@@ -12,11 +12,12 @@ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollect
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
14
  import '../dropdown';
15
+ import '../icons/keyboard-arrow-down';
15
16
  import { defineCustomElement, getAttribute, getBooleanAttribute, getIntegerAttribute, getReactEventHandler, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute, updateIntegerAttribute } from '../utils';
16
- const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0;--sinch-color-icon:var(--sinch-color-stormy-500)}#wrapper{position:relative}sinch-dropdown{display:block}#button{all:initial;display:flex;align-items:center;gap:8px;border:1px solid var(--sinch-color-stormy-200);border-radius:var(--sinch-shape-radius-s);box-sizing:border-box;width:100%;height:48px;padding:8px 12px;font:var(--sinch-font-body);color:var(--sinch-color-text-default);background-color:var(--sinch-color-snow-100);cursor:pointer}#button:focus{border-color:var(--sinch-color-stormy-600)}#dropdown-icon{fill:var(--sinch-color-stormy-500)}#button>*{pointer-events:none}#button[data-unselected]{color:var(--sinch-color-text-muted)}#button:disabled{border-color:var(--sinch-color-snow-500);color:var(--sinch-color-stormy-100);cursor:initial}#button:disabled #dropdown-icon{fill:var(--sinch-color-stormy-100)}:host([invalidtext]:not([invalidtext=""])) #button:not(:disabled){border-color:var(--sinch-color-text-invalid)}#content{flex:1;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}#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}::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="button"></label><slot name="tooltip"></slot><span id="optional"></span></div><sinch-dropdown id="dropdown" orientation="bottom"><button slot="target" id="button"><span id="content"></span><svg id="dropdown-icon" width="12" height="8" aria-hidden="true"><path d="M1.41.59 6 5.17 10.59.59 12 2 6 8 0 2 1.41.59Z"/></svg></button><slot name="option" slot="option"></slot></sinch-dropdown><div id="bottom"><span id="invalid"></span><span id="additional"></span></div></div>';
17
+ const templateHTML = '<style>:host{display:inline-block;vertical-align:middle}#dropdown{display:block;width:100%}#button{all:initial;display:flex;align-items:center;gap:8px;border:1px solid var(--sinch-color-stormy-200);border-radius:var(--sinch-shape-radius-s);box-sizing:border-box;width:100%;height:48px;padding:0 12px;font:var(--sinch-font-body);color:var(--sinch-color-text-default);background-color:var(--sinch-color-snow-100);cursor:pointer;--sinch-color-icon:var(--sinch-color-stormy-500);--sinch-size-icon:24px}#button:focus{border-color:var(--sinch-color-stormy-600)}#dropdown-icon{fill:var(--sinch-color-stormy-500)}#button>*{pointer-events:none}#button[data-unselected]{color:var(--sinch-color-text-muted)}#button:disabled{border-color:var(--sinch-color-snow-500);color:var(--sinch-color-stormy-100);cursor:initial}#button:disabled #dropdown-icon{fill:var(--sinch-color-stormy-100)}:host([invalid]:not([invalid=false])) #button:enabled{border-color:var(--sinch-color-text-invalid)}#content{flex:1;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}:host([disabled]:not([disabled=false])) #button{--sinch-color-icon:var(--sinch-color-stormy-100)}</style><sinch-dropdown id="dropdown" orientation="bottom"><button slot="target" id="button"><span id="content"></span><sinch-icon-keyboard-arrow-down id="dropdown-icon"></sinch-icon-keyboard-arrow-down></button><slot name="option" slot="option"></slot></sinch-dropdown>';
17
18
  const template = document.createElement('template');
18
19
  template.innerHTML = templateHTML;
19
- defineCustomElement('sinch-select', (_$button = new WeakMap(), _$buttonContent = new WeakMap(), _$label = new WeakMap(), _$optionalText = new WeakMap(), _$additionalText = new WeakMap(), _$invalidText = new WeakMap(), _$dropdown = new WeakMap(), _$optionSlot = new WeakMap(), _$sh = new WeakMap(), _createElement = new WeakSet(), _updateButtonContent = new WeakSet(), _onValueChange = new WeakMap(), _getOptionWithValue = new WeakSet(), _onLabelClick = new WeakMap(), _onDropdownClick = new WeakMap(), _onDropdownClose = new WeakMap(), _onButtonFocus = new WeakMap(), _onButtonBlur = new WeakMap(), _onChangeReactHandler = new WeakMap(), _onFocusReactHandler = new WeakMap(), _onBlurReactHandler = new WeakMap(), class extends NectaryElement {
20
+ defineCustomElement('sinch-select', (_$button = new WeakMap(), _$buttonContent = new WeakMap(), _$dropdown = new WeakMap(), _$optionSlot = new WeakMap(), _$sh = new WeakMap(), _createElement = new WeakSet(), _updateButtonContent = new WeakSet(), _onValueChange = new WeakMap(), _getOptionWithValue = new WeakSet(), _onDropdownClick = new WeakMap(), _onDropdownClose = new WeakMap(), _onButtonFocus = new WeakMap(), _onButtonBlur = new WeakMap(), _onChangeReactHandler = new WeakMap(), _onFocusReactHandler = new WeakMap(), _onBlurReactHandler = new WeakMap(), class extends NectaryElement {
20
21
  constructor() {
21
22
  super();
22
23
 
@@ -36,26 +37,6 @@ defineCustomElement('sinch-select', (_$button = new WeakMap(), _$buttonContent =
36
37
  value: void 0
37
38
  });
38
39
 
39
- _classPrivateFieldInitSpec(this, _$label, {
40
- writable: true,
41
- value: void 0
42
- });
43
-
44
- _classPrivateFieldInitSpec(this, _$optionalText, {
45
- writable: true,
46
- value: void 0
47
- });
48
-
49
- _classPrivateFieldInitSpec(this, _$additionalText, {
50
- writable: true,
51
- value: void 0
52
- });
53
-
54
- _classPrivateFieldInitSpec(this, _$invalidText, {
55
- writable: true,
56
- value: void 0
57
- });
58
-
59
40
  _classPrivateFieldInitSpec(this, _$dropdown, {
60
41
  writable: true,
61
42
  value: void 0
@@ -86,13 +67,6 @@ defineCustomElement('sinch-select', (_$button = new WeakMap(), _$buttonContent =
86
67
  }
87
68
  });
88
69
 
89
- _classPrivateFieldInitSpec(this, _onLabelClick, {
90
- writable: true,
91
- value: () => {
92
- this.focus();
93
- }
94
- });
95
-
96
70
  _classPrivateFieldInitSpec(this, _onDropdownClick, {
97
71
  writable: true,
98
72
  value: () => {
@@ -151,15 +125,7 @@ defineCustomElement('sinch-select', (_$button = new WeakMap(), _$buttonContent =
151
125
 
152
126
  _classPrivateFieldSet(this, _$buttonContent, shadowRoot.querySelector('#content'));
153
127
 
154
- _classPrivateFieldSet(this, _$label, shadowRoot.querySelector('#label'));
155
-
156
- _classPrivateFieldSet(this, _$optionalText, shadowRoot.querySelector('#optional'));
157
-
158
- _classPrivateFieldSet(this, _$additionalText, shadowRoot.querySelector('#additional'));
159
-
160
- _classPrivateFieldSet(this, _$invalidText, shadowRoot.querySelector('#invalid'));
161
-
162
- _classPrivateFieldSet(this, _$dropdown, shadowRoot.querySelector('sinch-dropdown'));
128
+ _classPrivateFieldSet(this, _$dropdown, shadowRoot.querySelector('#dropdown'));
163
129
 
164
130
  _classPrivateFieldSet(this, _$optionSlot, shadowRoot.querySelector('slot[name="option"]'));
165
131
  }
@@ -178,8 +144,6 @@ defineCustomElement('sinch-select', (_$button = new WeakMap(), _$buttonContent =
178
144
 
179
145
  _classPrivateFieldGet(this, _$button).addEventListener('blur', _classPrivateFieldGet(this, _onButtonBlur));
180
146
 
181
- _classPrivateFieldGet(this, _$label).addEventListener('click', _classPrivateFieldGet(this, _onLabelClick));
182
-
183
147
  this.addEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
184
148
  this.addEventListener('-focus', _classPrivateFieldGet(this, _onFocusReactHandler));
185
149
  this.addEventListener('-blur', _classPrivateFieldGet(this, _onBlurReactHandler));
@@ -196,15 +160,13 @@ defineCustomElement('sinch-select', (_$button = new WeakMap(), _$buttonContent =
196
160
 
197
161
  _classPrivateFieldGet(this, _$button).removeEventListener('blur', _classPrivateFieldGet(this, _onButtonBlur));
198
162
 
199
- _classPrivateFieldGet(this, _$label).removeEventListener('click', _classPrivateFieldGet(this, _onLabelClick));
200
-
201
163
  this.removeEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
202
164
  this.removeEventListener('-focus', _classPrivateFieldGet(this, _onFocusReactHandler));
203
165
  this.removeEventListener('-blur', _classPrivateFieldGet(this, _onBlurReactHandler));
204
166
  }
205
167
 
206
168
  static get observedAttributes() {
207
- return ['value', 'label', 'placeholder', 'optionaltext', 'additionaltext', 'invalidtext', 'disabled', 'maxvisibleitems'];
169
+ return ['value', 'placeholder', 'invalid', 'disabled', 'maxvisibleitems'];
208
170
  }
209
171
 
210
172
  get nodeName() {
@@ -227,36 +189,12 @@ defineCustomElement('sinch-select', (_$button = new WeakMap(), _$buttonContent =
227
189
  return getAttribute(this, 'placeholder', null);
228
190
  }
229
191
 
230
- set label(value) {
231
- updateAttribute(this, 'label', value);
232
- }
233
-
234
- get label() {
235
- return getAttribute(this, 'label', '');
236
- }
237
-
238
- set optionalText(value) {
239
- updateAttribute(this, 'optionaltext', value);
240
- }
241
-
242
- get optionalText() {
243
- return getAttribute(this, 'optionaltext', null);
244
- }
245
-
246
- set additionalText(value) {
247
- updateAttribute(this, 'additionaltext', value);
248
- }
249
-
250
- get additionalText() {
251
- return getAttribute(this, 'additionaltext', null);
252
- }
253
-
254
- set invalidText(value) {
255
- updateAttribute(this, 'invalidtext', value);
192
+ set invalid(value) {
193
+ updateBooleanAttribute(this, 'invalid', value);
256
194
  }
257
195
 
258
- get invalidText() {
259
- return getAttribute(this, 'placeholder', null);
196
+ get invalid() {
197
+ return getBooleanAttribute(this, 'invalid');
260
198
  }
261
199
 
262
200
  set disabled(isDisabled) {
@@ -303,29 +241,9 @@ defineCustomElement('sinch-select', (_$button = new WeakMap(), _$buttonContent =
303
241
  break;
304
242
  }
305
243
 
306
- case 'label':
307
- {
308
- _classPrivateFieldGet(this, _$label).textContent = newVal;
309
- break;
310
- }
311
-
312
- case 'optionaltext':
313
- {
314
- _classPrivateFieldGet(this, _$optionalText).textContent = newVal;
315
- break;
316
- }
317
-
318
- case 'additionaltext':
319
- {
320
- _classPrivateFieldGet(this, _$additionalText).textContent = newVal;
321
- break;
322
- }
323
-
324
- case 'invalidtext':
244
+ case 'invalid':
325
245
  {
326
- const isInvalid = newVal !== null && newVal !== '';
327
- _classPrivateFieldGet(this, _$invalidText).textContent = newVal;
328
- updateExplicitBooleanAttribute(this, 'aria-invalid', isInvalid);
246
+ updateExplicitBooleanAttribute(this, 'aria-invalid', isAttrTrue(newVal));
329
247
  break;
330
248
  }
331
249
 
package/select/types.d.ts CHANGED
@@ -3,16 +3,10 @@ import type { SyntheticEvent } from 'react';
3
3
  export declare type TSinchSelectElement = HTMLElement & {
4
4
  /** Value that matches one of the options `value` */
5
5
  value: string;
6
- /** Label */
7
- label: string;
8
6
  /** Text that appears when it has no value set */
9
7
  placeholder: string | null;
10
- /** Optional text */
11
- optionalText: string | null;
12
- /** Additional text */
13
- additionalText: string | null;
14
- /** Invalid text, controls the overall invalid state */
15
- invalidText: string | null;
8
+ /** Invalid state */
9
+ invalid: boolean;
16
10
  /** Disabled */
17
11
  disabled: boolean;
18
12
  /** Number of visible at the same time options in the list */
@@ -26,16 +20,10 @@ export declare type TSinchSelectElement = HTMLElement & {
26
20
  addEventListener(type: '-blur', listener: (e: CustomEvent<void>) => void): void;
27
21
  /** Value that matches one of the options `value` */
28
22
  setAttribute(name: 'value', value: string): void;
29
- /** Label */
30
- setAttribute(name: 'label', value: string): void;
31
23
  /** Text that appears when it has no value set */
32
24
  setAttribute(name: 'placeholder', value: string): void;
33
- /** Optional text */
34
- setAttribute(name: 'optionaltext', value: string): void;
35
- /** Additional text */
36
- setAttribute(name: 'additionaltext', value: string): void;
37
- /** Invalid text, controls the overall invalid state */
38
- setAttribute(name: 'invalidtext', value: string): void;
25
+ /** Invalid state */
26
+ setAttribute(name: 'invalid', value: ''): void;
39
27
  /** Disabled */
40
28
  setAttribute(name: 'disabled', value: ''): void;
41
29
  /** Number of visible at the same time options in the list */
@@ -44,18 +32,12 @@ export declare type TSinchSelectElement = HTMLElement & {
44
32
  export declare type TSinchSelectReact = TSinchElementReact<TSinchSelectElement> & {
45
33
  /** Value that matches one of the options `value` */
46
34
  value: string;
47
- /** Label */
48
- label: string;
49
35
  /** Label that is used for a11y – might be different from `label` */
50
36
  'aria-label': string;
51
37
  /** Text that appears when it has no value set */
52
38
  placeholder?: string;
53
- /** Optional text */
54
- optionalText?: string;
55
- /** Additional text */
56
- additionalText?: string;
57
- /** Invalid text, controls the overall invalid state */
58
- invalidText?: string;
39
+ /** Invalid state */
40
+ invalid?: boolean;
59
41
  /** Disabled */
60
42
  disabled?: boolean;
61
43
  /** Number of visible at the same time options in the list */
package/spinner/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { defineCustomElement, getLiteralAttribute, NectaryElement, updateLiteralAttribute } from '../utils';
2
- const templateHTML = '<style>:host{display:inline-block;vertical-align:middle}@keyframes spinner{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}div{animation:1.5s linear infinite spinner;animation-play-state:running;border:solid 3px var(--sinch-color-spinner-bg,#d4dadd);border-bottom-color:var(--sinch-color-spinner-fg,#0a273d);border-radius:50%;height:20px;width:20px;box-sizing:border-box;will-change:transform}:host([type=large]) div{height:46px;width:46px;border-width:4px}:host([type=small]) div{height:14px;width:14px;border-width:2px}:host([static]:not([static=false])) div{animation-play-state:paused}</style><div></div>';
2
+ const templateHTML = '<style>:host{display:inline-block;vertical-align:middle}@keyframes spinner{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}div{animation:1.5s linear infinite spinner;animation-play-state:running;border:solid 3px var(--sinch-color-spinner-bg,#d4dadd);border-bottom-color:var(--sinch-color-spinner-fg,#0a273d);border-radius:50%;height:20px;width:20px;box-sizing:border-box;will-change:transform;margin:2px}:host([type=large]) div{height:48px;width:48px;border-width:4px}:host([type=small]) div{height:14px;width:14px;border-width:2px;margin:1px}:host([static]:not([static=false])) div{animation-play-state:paused}</style><div></div>';
3
3
  import { spinnerTypes } from './utils';
4
4
  const template = document.createElement('template');
5
5
  template.innerHTML = templateHTML;
package/text/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import '../icons/cancel';
2
2
  import { defineCustomElement, getBooleanAttribute, updateBooleanAttribute, NectaryElement, getLiteralAttribute, updateLiteralAttribute, isAttrTrue } from '../utils';
3
- const templateHTML = '<style>:host{display:block;font:var(--sinch-font-text-m)}:host([inline]:not([inline=false])){display:inline}:host([type="s"]){font:var(--sinch-font-text-s)}:host([type=xs]){font:var(--sinch-font-text-xs)}:host([type=xxs]){font:var(--sinch-font-text-xxs)}:host([emphasized]:not([emphasized=false])){font-weight:var(--sinch-font-weight-emphasized)}</style><slot></slot>';
3
+ const templateHTML = '<style>:host{display:block;font:var(--sinch-font-text-m)}:host([inline]:not([inline=false])){display:inline}:host([type="s"]){font:var(--sinch-font-text-s)}:host([type=xs]){font:var(--sinch-font-text-xs)}:host([type=xxs]){font:var(--sinch-font-text-xxs)}:host([emphasized]:not([emphasized=false])){font-weight:var(--sinch-font-weight-emphasized)}:host([ellipsis]:not([ellipsis=false])){overflow:hidden;text-overflow:ellipsis;white-space:nowrap}</style><slot></slot>';
4
4
  import { assertType, typeValues } from './utils';
5
5
  const template = document.createElement('template');
6
6
  template.innerHTML = templateHTML;
@@ -31,6 +31,14 @@ defineCustomElement('sinch-text', class extends NectaryElement {
31
31
  return getBooleanAttribute(this, 'inline');
32
32
  }
33
33
 
34
+ set ellipsis(isEllipsis) {
35
+ updateBooleanAttribute(this, 'ellipsis', isEllipsis);
36
+ }
37
+
38
+ get ellipsis() {
39
+ return getBooleanAttribute(this, 'ellipsis');
40
+ }
41
+
34
42
  set emphasized(isEmphasized) {
35
43
  updateBooleanAttribute(this, 'emphasized', isEmphasized);
36
44
  }
package/text/types.d.ts CHANGED
@@ -4,12 +4,15 @@ export declare type TSinchTextElement = HTMLElement & {
4
4
  type: TSinchTextType;
5
5
  inline: boolean;
6
6
  emphasized: boolean;
7
+ ellipsis: boolean;
7
8
  setAttribute(name: 'type', value: TSinchTextType): void;
8
9
  setAttribute(name: 'inline', value: ''): void;
9
10
  setAttribute(name: 'emphasized', value: ''): void;
11
+ setAttribute(name: 'ellipsis', value: ''): void;
10
12
  };
11
13
  export declare type TSinchTextReact = TSinchElementReact<TSinchTextElement> & {
12
14
  type: TSinchTextType;
13
15
  inline?: boolean;
14
16
  emphasized?: boolean;
17
+ ellipsis?: boolean;
15
18
  };
package/textarea/index.js CHANGED
@@ -1,17 +1,17 @@
1
1
  import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
2
  import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
3
 
4
- var _$input, _$label, _$optionalText, _$additionalText, _$invalidText, _cursorPos, _isPendingDk, _onCompositionStart, _onSelectionChange, _onInput, _onInputFocus, _onInputBlur, _onChangeReactHandler, _onFocusReactHandler, _onBlurReactHandler;
4
+ var _$input, _cursorPos, _isPendingDk, _onCompositionStart, _onSelectionChange, _onInput, _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
10
  import { defineCustomElement, getAttribute, getBooleanAttribute, getIntegerAttribute, getReactEventHandler, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
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{all:initial;display:block;border:1px solid var(--sinch-color-stormy-200);box-sizing:border-box;border-radius:var(--sinch-shape-radius-s);width:100%;padding:8px 12px;font:var(--sinch-font-body);color:var(--sinch-color-text-default);caret-color:var(--sinch-caret-color,auto);background-color:var(--sinch-color-snow-100);resize:none}#input::placeholder{font:var(--sinch-font-body);color:var(--sinch-color-text-muted)}#input:disabled{border-color:var(--sinch-color-snow-500);color:var(--sinch-color-stormy-100)}#input:disabled::placeholder{color:var(--sinch-color-snow-500)}#input:focus{border-color:var(--sinch-color-stormy-600)}:host([resizable]:not([resizable=false])) #input{resize:vertical}:host([invalidtext]:not([invalidtext=""])) #input:not(:disabled){border-color:var(--sinch-color-text-invalid)}#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}::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><textarea id="input"></textarea><div id="bottom"><span id="invalid"></span><span id="additional"></span></div></div>';
11
+ const templateHTML = '<style>:host{display:inline-block;vertical-align:middle}#input{all:initial;display:block;border:1px solid var(--sinch-color-stormy-200);box-sizing:border-box;border-radius:var(--sinch-shape-radius-s);width:100%;padding:8px 12px;font:var(--sinch-font-body);color:var(--sinch-color-text-default);background-color:var(--sinch-color-snow-100);resize:none}#input::placeholder{font:var(--sinch-font-body);color:var(--sinch-color-text-muted);opacity:1}#input:disabled{border-color:var(--sinch-color-snow-500);color:var(--sinch-color-stormy-100)}#input:disabled::placeholder{color:var(--sinch-color-snow-500)}#input:focus{border-color:var(--sinch-color-stormy-600)}:host([resizable]:not([resizable=false])) #input{resize:vertical}:host([invalid]:not([invalid=false])) #input:enabled{border-color:var(--sinch-color-text-invalid)}</style><textarea id="input"></textarea>';
12
12
  const template = document.createElement('template');
13
13
  template.innerHTML = templateHTML;
14
- defineCustomElement('sinch-textarea', (_$input = new WeakMap(), _$label = new WeakMap(), _$optionalText = new WeakMap(), _$additionalText = new WeakMap(), _$invalidText = new WeakMap(), _cursorPos = new WeakMap(), _isPendingDk = new WeakMap(), _onCompositionStart = new WeakMap(), _onSelectionChange = new WeakMap(), _onInput = new WeakMap(), _onInputFocus = new WeakMap(), _onInputBlur = new WeakMap(), _onChangeReactHandler = new WeakMap(), _onFocusReactHandler = new WeakMap(), _onBlurReactHandler = new WeakMap(), class extends NectaryElement {
14
+ defineCustomElement('sinch-textarea', (_$input = new WeakMap(), _cursorPos = new WeakMap(), _isPendingDk = new WeakMap(), _onCompositionStart = new WeakMap(), _onSelectionChange = new WeakMap(), _onInput = new WeakMap(), _onInputFocus = new WeakMap(), _onInputBlur = new WeakMap(), _onChangeReactHandler = new WeakMap(), _onFocusReactHandler = new WeakMap(), _onBlurReactHandler = new WeakMap(), class extends NectaryElement {
15
15
  constructor() {
16
16
  super();
17
17
 
@@ -20,26 +20,6 @@ defineCustomElement('sinch-textarea', (_$input = new WeakMap(), _$label = new We
20
20
  value: void 0
21
21
  });
22
22
 
23
- _classPrivateFieldInitSpec(this, _$label, {
24
- writable: true,
25
- value: void 0
26
- });
27
-
28
- _classPrivateFieldInitSpec(this, _$optionalText, {
29
- writable: true,
30
- value: void 0
31
- });
32
-
33
- _classPrivateFieldInitSpec(this, _$additionalText, {
34
- writable: true,
35
- value: void 0
36
- });
37
-
38
- _classPrivateFieldInitSpec(this, _$invalidText, {
39
- writable: true,
40
- value: void 0
41
- });
42
-
43
23
  _classPrivateFieldInitSpec(this, _cursorPos, {
44
24
  writable: true,
45
25
  value: null
@@ -142,14 +122,6 @@ defineCustomElement('sinch-textarea', (_$input = new WeakMap(), _$label = new We
142
122
  shadowRoot.appendChild(template.content.cloneNode(true));
143
123
 
144
124
  _classPrivateFieldSet(this, _$input, shadowRoot.querySelector('#input'));
145
-
146
- _classPrivateFieldSet(this, _$label, shadowRoot.querySelector('#label'));
147
-
148
- _classPrivateFieldSet(this, _$optionalText, shadowRoot.querySelector('#optional'));
149
-
150
- _classPrivateFieldSet(this, _$additionalText, shadowRoot.querySelector('#additional'));
151
-
152
- _classPrivateFieldSet(this, _$invalidText, shadowRoot.querySelector('#invalid'));
153
125
  }
154
126
 
155
127
  connectedCallback() {
@@ -192,10 +164,14 @@ defineCustomElement('sinch-textarea', (_$input = new WeakMap(), _$label = new We
192
164
  }
193
165
 
194
166
  static get observedAttributes() {
195
- return ['value', 'placeholder', 'label', 'optionaltext', 'additionaltext', 'invalidtext', 'disabled', 'rows'];
167
+ return ['value', 'placeholder', 'invalid', 'disabled', 'rows'];
196
168
  }
197
169
 
198
- attributeChangedCallback(name, _, newVal) {
170
+ attributeChangedCallback(name, oldVal, newVal) {
171
+ if (oldVal === newVal) {
172
+ return;
173
+ }
174
+
199
175
  switch (name) {
200
176
  case 'value':
201
177
  {
@@ -217,12 +193,6 @@ defineCustomElement('sinch-textarea', (_$input = new WeakMap(), _$label = new We
217
193
  break;
218
194
  }
219
195
 
220
- case 'label':
221
- {
222
- _classPrivateFieldGet(this, _$label).textContent = newVal;
223
- break;
224
- }
225
-
226
196
  case 'placeholder':
227
197
  {
228
198
  _classPrivateFieldGet(this, _$input).placeholder = newVal ?? '';
@@ -230,23 +200,9 @@ defineCustomElement('sinch-textarea', (_$input = new WeakMap(), _$label = new We
230
200
  break;
231
201
  }
232
202
 
233
- case 'optionaltext':
234
- {
235
- _classPrivateFieldGet(this, _$optionalText).textContent = newVal;
236
- break;
237
- }
238
-
239
- case 'additionaltext':
240
- {
241
- _classPrivateFieldGet(this, _$additionalText).textContent = newVal;
242
- break;
243
- }
244
-
245
- case 'invalidtext':
203
+ case 'invalid':
246
204
  {
247
- const isInvalid = newVal !== null && newVal !== '';
248
- _classPrivateFieldGet(this, _$invalidText).textContent = newVal;
249
- updateExplicitBooleanAttribute(this, 'aria-invalid', isInvalid);
205
+ updateExplicitBooleanAttribute(this, 'aria-invalid', isAttrTrue(newVal));
250
206
  break;
251
207
  }
252
208
 
@@ -286,36 +242,12 @@ defineCustomElement('sinch-textarea', (_$input = new WeakMap(), _$label = new We
286
242
  return getAttribute(this, 'placeholder', null);
287
243
  }
288
244
 
289
- set label(value) {
290
- updateAttribute(this, 'label', value);
291
- }
292
-
293
- get label() {
294
- return getAttribute(this, 'label', '');
295
- }
296
-
297
- set optionalText(value) {
298
- updateAttribute(this, 'optionaltext', value);
299
- }
300
-
301
- get optionalText() {
302
- return getAttribute(this, 'optionaltext', null);
303
- }
304
-
305
- set additionalText(value) {
306
- updateAttribute(this, 'additionaltext', value);
307
- }
308
-
309
- get additionalText() {
310
- return getAttribute(this, 'additionaltext', null);
311
- }
312
-
313
- set invalidText(value) {
314
- updateAttribute(this, 'invalidtext', value);
245
+ set invalid(value) {
246
+ updateBooleanAttribute(this, 'invalid', value);
315
247
  }
316
248
 
317
- get invalidText() {
318
- return getAttribute(this, 'invalidtext', null);
249
+ get invalid() {
250
+ return getBooleanAttribute(this, 'invalid');
319
251
  }
320
252
 
321
253
  set disabled(isDisabled) {
@@ -1,44 +1,60 @@
1
1
  import type { TSinchElementReact } from '../types';
2
2
  import type { SyntheticEvent } from 'react';
3
3
  export declare type TSinchTextareaElement = HTMLElement & {
4
+ /** Value */
4
5
  value: string;
5
- label: string;
6
+ /** Text that appears in the text field when it has no value set */
6
7
  placeholder: string | null;
7
- optionalText: string | null;
8
- invalidText: string | null;
9
- additionalText: string | null;
8
+ /** Disabled */
10
9
  disabled: boolean;
10
+ /** Invalid state */
11
+ invalid: boolean;
11
12
  selectionStart: HTMLTextAreaElement['selectionStart'];
12
13
  selectionEnd: HTMLTextAreaElement['selectionEnd'];
13
14
  selectionDirection: HTMLTextAreaElement['selectionDirection'];
15
+ /** Number of rows */
14
16
  rows: HTMLTextAreaElement['rows'];
17
+ /** Whether the text field is resizable */
15
18
  resizable: boolean;
19
+ /** Change value event */
16
20
  addEventListener(type: '-change', listener: (e: CustomEvent<string>) => void): void;
21
+ /** Focus event */
17
22
  addEventListener(type: '-focus', listener: (e: CustomEvent<void>) => void): void;
23
+ /** Blur event */
18
24
  addEventListener(type: '-blur', listener: (e: CustomEvent<void>) => void): void;
25
+ /** Value */
19
26
  setAttribute(name: 'value', value: string): void;
20
- setAttribute(name: 'label', value: string): void;
27
+ /** Text that appears in the text field when it has no value set */
21
28
  setAttribute(name: 'placeholder', value: string): void;
22
- setAttribute(name: 'optionaltext', value: string): void;
23
- setAttribute(name: 'invalidtext', value: string): void;
24
- setAttribute(name: 'additionaltext', value: string): void;
29
+ /** Invalid state */
30
+ setAttribute(name: 'invalid', value: ''): void;
31
+ /** Disabled */
25
32
  setAttribute(name: 'disabled', value: ''): void;
33
+ /** Number of rows */
26
34
  setAttribute(name: 'rows', value: string): void;
35
+ /** Whether the text field is resizable */
27
36
  setAttribute(name: 'resizable', value: ''): void;
28
37
  };
29
38
  export declare type TSinchTextareaReact = TSinchElementReact<TSinchTextareaElement> & {
39
+ /** Value */
30
40
  value: string;
31
- label: string;
41
+ /** Text that appears in the text field when it has no value set */
32
42
  placeholder?: string;
33
- optionalText?: string;
34
- invalidText?: string;
35
- additionalText?: string;
43
+ /** Disabled */
36
44
  disabled?: boolean;
45
+ /** Invalid state */
46
+ invalid?: boolean;
37
47
  'aria-label': string;
48
+ /** Number of rows */
38
49
  rows?: number;
50
+ /** Whether the text field is resizable */
39
51
  resizable?: boolean;
52
+ /** @deprecated Change value handler */
40
53
  onChange?: (e: SyntheticEvent<TSinchTextareaElement, CustomEvent<string>>) => void;
54
+ /** Change value handler */
41
55
  'on-change'?: (e: CustomEvent<string>) => void;
56
+ /** Focus handler */
42
57
  'on-focus'?: (e: CustomEvent<void>) => void;
58
+ /** Blur handler */
43
59
  'on-blur'?: (e: CustomEvent<void>) => void;
44
60
  };
package/title/index.js CHANGED
@@ -8,8 +8,8 @@ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedec
8
8
  function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
9
9
 
10
10
  import '../icons/cancel';
11
- import { defineCustomElement, getAttribute, updateAttribute, updateLiteralAttribute, getLiteralAttribute, NectaryElement } from '../utils';
12
- const templateHTML = '<style>:host{display:block}:host([type=xl])>*{font:var(--sinch-font-title-xl)}:host([type="l"])>*{font:var(--sinch-font-title-l)}:host([type="m"])>*{font:var(--sinch-font-title-m)}:host([type="s"])>*{font:var(--sinch-font-title-s)}:host([type=xs])>*{font:var(--sinch-font-title-xs)}</style><span id="text"></span>';
11
+ import { defineCustomElement, getAttribute, updateAttribute, updateLiteralAttribute, getLiteralAttribute, NectaryElement, updateBooleanAttribute, getBooleanAttribute } from '../utils';
12
+ const templateHTML = '<style>:host{display:block}:host([type=xl]) #text{font:var(--sinch-font-title-xl)}:host([type="l"]) #text{font:var(--sinch-font-title-l)}:host([type="m"]) #text{font:var(--sinch-font-title-m)}:host([type="s"]) #text{font:var(--sinch-font-title-s)}:host([type=xs]) #text{font:var(--sinch-font-title-xs)}:host([ellipsis]:not([ellipsis=false])) #text{display:block;width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}</style><span id="text"></span>';
13
13
  import { assertLevel, assertType, typeValues } from './utils';
14
14
  const template = document.createElement('template');
15
15
  template.innerHTML = templateHTML;
@@ -48,6 +48,14 @@ defineCustomElement('sinch-title', (_$text = new WeakMap(), class extends Nectar
48
48
  return getLiteralAttribute(this, typeValues, 'type');
49
49
  }
50
50
 
51
+ set ellipsis(isEllipsis) {
52
+ updateBooleanAttribute(this, 'ellipsis', isEllipsis);
53
+ }
54
+
55
+ get ellipsis() {
56
+ return getBooleanAttribute(this, 'ellipsis');
57
+ }
58
+
51
59
  static get observedAttributes() {
52
60
  return ['text', 'type', 'level'];
53
61
  }
package/title/types.d.ts CHANGED
@@ -5,12 +5,15 @@ export declare type TSinchTitleElement = HTMLElement & {
5
5
  text: string;
6
6
  type: TSinchTitleType;
7
7
  level: TSinchTitleLevel;
8
+ ellipsis: boolean;
8
9
  setAttribute(name: 'text', value: string): void;
9
10
  setAttribute(name: 'type', value: TSinchTitleType): void;
10
11
  setAttribute(name: 'level', value: TSinchTitleLevel): void;
12
+ setAttribute(name: 'ellipsis', value: ''): void;
11
13
  };
12
14
  export declare type TSinchTitleReact = TSinchElementReact<TSinchTitleElement> & {
13
15
  text: string;
14
16
  type: TSinchTitleType;
15
17
  level: TSinchTitleLevel;
18
+ ellipsis?: boolean;
16
19
  };
package/utils.d.ts CHANGED
@@ -8,6 +8,7 @@ declare global {
8
8
  }
9
9
  export declare class NectaryElement extends HTMLElement {
10
10
  attachShadow(options?: Partial<ShadowRootInit>): ShadowRoot;
11
+ __version: string;
11
12
  }
12
13
  export declare const getReactEventHandler: ($element: HTMLElement, handlerName: string) => ((arg?: any) => void) | null;
13
14
  export declare const updateExplicitBooleanAttribute: ($element: Element, attrName: string, attrValue: boolean | null | undefined) => void;
@@ -46,4 +47,5 @@ export declare const throttleAnimationFrame: (cb: (...args: any[]) => void) => {
46
47
  fn: (...args: any[]) => void;
47
48
  cancel: () => void;
48
49
  };
50
+ export declare const getFirstSlotElement: (root: HTMLSlotElement) => HTMLElement | null;
49
51
  export {};
package/utils.js CHANGED
@@ -1,3 +1,5 @@
1
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
+ import pkg from './package.json';
1
3
  const nectaryDefinitions = new Map();
2
4
  let nectaryRegistry = null;
3
5
  export const defineCustomElement = (name, constructor) => {
@@ -27,6 +29,12 @@ export const setNectaryRegistry = registry => {
27
29
  nectaryDefinitions.clear();
28
30
  };
29
31
  export class NectaryElement extends HTMLElement {
32
+ constructor() {
33
+ super(...arguments);
34
+
35
+ _defineProperty(this, '__version', pkg.version);
36
+ }
37
+
30
38
  attachShadow(options) {
31
39
  return super.attachShadow({
32
40
  mode: 'closed',
@@ -236,4 +244,21 @@ const throttle = (delayFn, cancelFn) => cb => {
236
244
  };
237
245
  };
238
246
 
239
- export const throttleAnimationFrame = throttle(global.requestAnimationFrame, global.cancelAnimationFrame);
247
+ export const throttleAnimationFrame = throttle(global.requestAnimationFrame, global.cancelAnimationFrame);
248
+ export const getFirstSlotElement = root => {
249
+ let slot = root;
250
+
251
+ while (true) {
252
+ const el = slot.assignedElements()[0];
253
+
254
+ if (el == null) {
255
+ return null;
256
+ }
257
+
258
+ if (el.tagName !== 'SLOT') {
259
+ return el;
260
+ }
261
+
262
+ slot = el;
263
+ }
264
+ };