@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/input/index.js CHANGED
@@ -1,18 +1,18 @@
1
1
  import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
2
  import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
3
 
4
- var _$input, _$label, _$optionalText, _$additionalText, _$invalidText, _$iconSlot, _$iconWrapper, _$rightSlot, _$rightWrapper, _cursorPos, _isPendingDk, _onCompositionStart, _onSelectionChange, _onInput, _onIconSlotChange, _onRightSlotChange, _onInputFocus, _onInputBlur, _onChangeReactHandler, _onFocusReactHandler, _onBlurReactHandler;
4
+ var _$input, _$iconSlot, _$iconWrapper, _$rightSlot, _$rightWrapper, _cursorPos, _isPendingDk, _onCompositionStart, _onSelectionChange, _onInput, _onIconSlotChange, _onRightSlotChange, _onInputFocus, _onInputBlur, _onChangeReactHandler, _onFocusReactHandler, _onBlurReactHandler;
5
5
 
6
6
  function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
7
7
 
8
8
  function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
9
9
 
10
10
  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;outline:0;--sinch-color-icon:var(--sinch-color-stormy-500)}#wrapper{width:100%;box-sizing:border-box}#input-wrapper{position:relative;display:flex;flex-direction:row;align-items:center;box-sizing:border-box;border-radius:var(--sinch-shape-radius-s);width:100%;height:48px;background-color:var(--sinch-color-snow-100)}#input{all:initial;flex:1;min-width:0;height:48px;padding:0 12px 0 44px;font:var(--sinch-font-body);color:var(--sinch-color-text-default);caret-color:var(--sinch-caret-color,auto)}#input::placeholder{font:var(--sinch-font-body);color:var(--sinch-color-text-muted)}#border{position:absolute;border:1px solid var(--sinch-color-stormy-200);border-radius:var(--sinch-shape-radius-s);left:0;right:0;top:0;bottom:0;pointer-events:none}:host([invalidtext]:not([invalidtext=""]):not([disabled])) #border{border-color:var(--sinch-color-text-invalid)}#input:disabled{color:var(--sinch-color-stormy-100)}#input:disabled::placeholder{color:var(--sinch-color-snow-500)}#input:disabled+#border{border-color:var(--sinch-color-snow-500)}#input:focus+#border{border-color:var(--sinch-color-stormy-600)}#input[type=password]{font-size:1.5em;letter-spacing:.1em}#bottom,#top{display:flex;align-items:baseline}#top{height:24px;margin-bottom:2px}#additional,#invalid,#label,#optional{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#label{font:var(--sinch-font-title-s);color:var(--sinch-color-text-default)}#optional{flex:1;text-align:right;font:var(--sinch-font-small-text);color:var(--sinch-color-text-muted)}#additional{flex:1;text-align:right;font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-muted);line-height:20px;margin-top:2px}#additional:empty{display:none}#invalid{font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-invalid);line-height:20px;margin-top:2px}#invalid:empty{display:none}#icon{position:absolute;left:12px;top:12px;pointer-events:none;--sinch-icon-size:24px}#icon.empty{display:none}#icon.empty~#input{padding-left:12px}#right{display:flex;flex-direction:row;align-self:stretch;align-items:center;gap:4px;padding-right:8px}#right.empty{display:none}::slotted(sinch-help-tooltip){align-self:center;margin:0 8px}:host([disabled]:not([disabled=false])) :is(#label,#additional,#optional,#invalid){color:var(--sinch-color-stormy-100)}:host([disabled]:not([disabled=false])){--sinch-color-icon:var(--sinch-color-stormy-100)}</style><div id="wrapper"><div id="top"><label id="label" for="input"></label><slot name="tooltip"></slot><span id="optional"></span></div><div id="input-wrapper"><div id="icon"><slot name="icon"></slot></div><input id="input" type="text"/><div id="border"></div><div id="right"><slot name="right"></slot></div></div><div id="bottom"><div id="invalid"></div><div id="additional"></div></div></div>';
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>';
12
12
  import { inputTypes } from './utils';
13
13
  const template = document.createElement('template');
14
14
  template.innerHTML = templateHTML;
15
- defineCustomElement('sinch-input', (_$input = new WeakMap(), _$label = new WeakMap(), _$optionalText = new WeakMap(), _$additionalText = new WeakMap(), _$invalidText = new WeakMap(), _$iconSlot = new WeakMap(), _$iconWrapper = new WeakMap(), _$rightSlot = new WeakMap(), _$rightWrapper = new WeakMap(), _cursorPos = new WeakMap(), _isPendingDk = new WeakMap(), _onCompositionStart = new WeakMap(), _onSelectionChange = new WeakMap(), _onInput = new WeakMap(), _onIconSlotChange = new WeakMap(), _onRightSlotChange = new WeakMap(), _onInputFocus = new WeakMap(), _onInputBlur = new WeakMap(), _onChangeReactHandler = new WeakMap(), _onFocusReactHandler = new WeakMap(), _onBlurReactHandler = new WeakMap(), class extends NectaryElement {
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 {
16
16
  constructor() {
17
17
  super();
18
18
 
@@ -21,26 +21,6 @@ defineCustomElement('sinch-input', (_$input = new WeakMap(), _$label = new WeakM
21
21
  value: void 0
22
22
  });
23
23
 
24
- _classPrivateFieldInitSpec(this, _$label, {
25
- writable: true,
26
- value: void 0
27
- });
28
-
29
- _classPrivateFieldInitSpec(this, _$optionalText, {
30
- writable: true,
31
- value: void 0
32
- });
33
-
34
- _classPrivateFieldInitSpec(this, _$additionalText, {
35
- writable: true,
36
- value: void 0
37
- });
38
-
39
- _classPrivateFieldInitSpec(this, _$invalidText, {
40
- writable: true,
41
- value: void 0
42
- });
43
-
44
24
  _classPrivateFieldInitSpec(this, _$iconSlot, {
45
25
  writable: true,
46
26
  value: void 0
@@ -178,14 +158,6 @@ defineCustomElement('sinch-input', (_$input = new WeakMap(), _$label = new WeakM
178
158
 
179
159
  _classPrivateFieldSet(this, _$input, shadowRoot.querySelector('#input'));
180
160
 
181
- _classPrivateFieldSet(this, _$label, shadowRoot.querySelector('#label'));
182
-
183
- _classPrivateFieldSet(this, _$optionalText, shadowRoot.querySelector('#optional'));
184
-
185
- _classPrivateFieldSet(this, _$additionalText, shadowRoot.querySelector('#additional'));
186
-
187
- _classPrivateFieldSet(this, _$invalidText, shadowRoot.querySelector('#invalid'));
188
-
189
161
  _classPrivateFieldSet(this, _$iconSlot, shadowRoot.querySelector('slot[name="icon"]'));
190
162
 
191
163
  _classPrivateFieldSet(this, _$iconWrapper, shadowRoot.querySelector('#icon'));
@@ -246,7 +218,7 @@ defineCustomElement('sinch-input', (_$input = new WeakMap(), _$label = new WeakM
246
218
  }
247
219
 
248
220
  static get observedAttributes() {
249
- return ['type', 'value', 'placeholder', 'label', 'optionaltext', 'additionaltext', 'invalidtext', 'disabled'];
221
+ return ['type', 'value', 'placeholder', 'invalid', 'disabled'];
250
222
  }
251
223
 
252
224
  get nodeName() {
@@ -277,36 +249,12 @@ defineCustomElement('sinch-input', (_$input = new WeakMap(), _$label = new WeakM
277
249
  return getAttribute(this, 'placeholder', null);
278
250
  }
279
251
 
280
- set label(value) {
281
- updateAttribute(this, 'label', value);
282
- }
283
-
284
- get label() {
285
- return getAttribute(this, 'label', '');
252
+ set invalid(isInvalid) {
253
+ updateBooleanAttribute(this, 'invalid', isInvalid);
286
254
  }
287
255
 
288
- set optionalText(value) {
289
- updateAttribute(this, 'optionaltext', value);
290
- }
291
-
292
- get optionalText() {
293
- return getAttribute(this, 'optionaltext', null);
294
- }
295
-
296
- set additionalText(value) {
297
- updateAttribute(this, 'additionaltext', value);
298
- }
299
-
300
- get additionalText() {
301
- return getAttribute(this, 'additionaltext', null);
302
- }
303
-
304
- set invalidText(value) {
305
- updateAttribute(this, 'invalidtext', value);
306
- }
307
-
308
- get invalidText() {
309
- return getAttribute(this, 'invalidtext', null);
256
+ get invalid() {
257
+ return getBooleanAttribute(this, 'invalid');
310
258
  }
311
259
 
312
260
  set disabled(isDisabled) {
@@ -369,12 +317,6 @@ defineCustomElement('sinch-input', (_$input = new WeakMap(), _$label = new WeakM
369
317
  break;
370
318
  }
371
319
 
372
- case 'label':
373
- {
374
- _classPrivateFieldGet(this, _$label).textContent = newVal;
375
- break;
376
- }
377
-
378
320
  case 'placeholder':
379
321
  {
380
322
  _classPrivateFieldGet(this, _$input).placeholder = newVal ?? '';
@@ -382,23 +324,9 @@ defineCustomElement('sinch-input', (_$input = new WeakMap(), _$label = new WeakM
382
324
  break;
383
325
  }
384
326
 
385
- case 'optionaltext':
386
- {
387
- _classPrivateFieldGet(this, _$optionalText).textContent = newVal;
388
- break;
389
- }
390
-
391
- case 'additionaltext':
392
- {
393
- _classPrivateFieldGet(this, _$additionalText).textContent = newVal;
394
- break;
395
- }
396
-
397
- case 'invalidtext':
327
+ case 'invalid':
398
328
  {
399
- const isInvalid = newVal !== null && newVal !== '';
400
- _classPrivateFieldGet(this, _$invalidText).textContent = newVal;
401
- updateExplicitBooleanAttribute(this, 'aria-invalid', isInvalid);
329
+ updateExplicitBooleanAttribute(this, 'aria-invalid', isAttrTrue(newVal));
402
330
  break;
403
331
  }
404
332
 
package/input/types.d.ts CHANGED
@@ -6,16 +6,10 @@ export declare type TSinchInputElement = HTMLElement & {
6
6
  type: TSinchInputType;
7
7
  /** Value */
8
8
  value: string;
9
- /** Label */
10
- label: string;
11
9
  /** Text that appears in the text field when it has no value set */
12
10
  placeholder: string | null;
13
- /** Optional text */
14
- optionalText: string | null;
15
- /** Additional text */
16
- additionalText: string | null;
17
- /** Invalid text, controls the overall invalid state of the text field */
18
- invalidText: string | null;
11
+ /** Invalid state */
12
+ invalid: boolean;
19
13
  /** Disabled */
20
14
  disabled: boolean;
21
15
  selectionStart: number | null;
@@ -23,48 +17,40 @@ export declare type TSinchInputElement = HTMLElement & {
23
17
  selectionDirection: 'forward' | 'backward' | 'none' | null;
24
18
  /** Change value event */
25
19
  addEventListener(type: '-change', listener: (e: CustomEvent<string>) => void): void;
20
+ /** Focus event */
26
21
  addEventListener(type: '-focus', listener: (e: CustomEvent<void>) => void): void;
22
+ /** Blur event */
27
23
  addEventListener(type: '-blur', listener: (e: CustomEvent<void>) => void): void;
28
24
  /** Text field type, `text` by default */
29
25
  setAttribute(name: 'type', value: TSinchInputType): void;
30
26
  /** Value */
31
27
  setAttribute(name: 'value', value: string): void;
32
- /** Label */
33
- setAttribute(name: 'label', value: string): void;
34
28
  /** Text that appears in the text field when it has no value set */
35
29
  setAttribute(name: 'placeholder', value: string): void;
36
- /** Optional text */
37
- setAttribute(name: 'optionaltext', value: string): void;
38
- /** Additional text */
39
- setAttribute(name: 'additionaltext', value: string): void;
40
- /** Invalid text, controls the overall invalid state of the text field */
41
- setAttribute(name: 'invalidtext', value: string): void;
30
+ /** Invalid state */
31
+ setAttribute(name: 'invalid', value: ''): void;
42
32
  /** Disabled */
43
33
  setAttribute(name: 'disabled', value: ''): void;
44
34
  };
45
35
  export declare type TSinchInputReact = TSinchElementReact<TSinchInputElement> & {
46
36
  /** Controlled value, doesn't change on its own and requres an onChange-value state loop */
47
37
  value: string;
48
- /** Label that shows in UI */
49
- label: string;
50
38
  /** Label that is used for a11y – might be different from `label` */
51
39
  'aria-label': string;
52
40
  /** Text field type, `text` by default */
53
41
  type?: TSinchInputType;
54
42
  /** Text that appears in the text field when it has no value set */
55
43
  placeholder?: string;
56
- /** Optional text */
57
- optionalText?: string;
58
- /** Additional text */
59
- additionalText?: string;
60
- /** Invalid text, controls the overall invalid state of the text field */
61
- invalidText?: string;
44
+ /** Invalid state */
45
+ invalid?: boolean;
62
46
  /** Disabled */
63
47
  disabled?: boolean;
64
48
  /** @deprecated Change value handler */
65
49
  onChange?: (e: SyntheticEvent<TSinchInputElement, CustomEvent<string>>) => void;
66
50
  /** Change value handler */
67
51
  'on-change'?: (e: CustomEvent<string>) => void;
52
+ /** Focus handler */
68
53
  'on-focus'?: (e: CustomEvent<void>) => void;
54
+ /** Blur handler */
69
55
  'on-blur'?: (e: CustomEvent<void>) => void;
70
56
  };
package/link/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import '../icons/open-in-new';
2
+ import '../icons/arrow-forward';
2
3
  import type { TSinchLinkElement, TSinchLinkReact } from './types';
3
4
  declare global {
4
5
  namespace JSX {
package/link/index.js CHANGED
@@ -8,8 +8,9 @@ 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/open-in-new';
11
+ import '../icons/arrow-forward';
11
12
  import { defineCustomElement, getBooleanAttribute, getAttribute, updateBooleanAttribute, updateAttribute, NectaryElement, isAttrTrue, getReactEventHandler } from '../utils';
12
- const templateHTML = '<style>:host{display:inline;outline:0}a{font:var(--sinch-font-body);font-size:inherit;line-height:inherit;color:var(--sinch-color-text-link);fill:var(--sinch-color-text-link);--sinch-size-icon:1em}#icon{display:none;margin-left:.2em;vertical-align:-.25em}a:hover{color:var(--sinch-color-tropical-600);fill:var(--sinch-color-tropical-600)}:host([disabled]:not([disabled=false])) a{color:var(--sinch-color-tropical-200);pointer-events:none;cursor:initial;fill:var(--sinch-color-tropical-200)}:host([external]:not([external=false])) #icon{display:inline-block}</style><a><span id="content"></span><sinch-icon-open-in-new id="icon"></sinch-icon-open-in-new></a>';
13
+ 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>';
13
14
  const template = document.createElement('template');
14
15
  template.innerHTML = templateHTML;
15
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 {
@@ -81,6 +82,8 @@ defineCustomElement('sinch-link', (_$anchor = new WeakMap(), _$text = new WeakMa
81
82
  }
82
83
 
83
84
  connectedCallback() {
85
+ this.setAttribute('role', 'link');
86
+
84
87
  _classPrivateFieldGet(this, _$anchor).addEventListener('click', _classPrivateFieldGet(this, _onAnchorClick));
85
88
 
86
89
  _classPrivateFieldGet(this, _$anchor).addEventListener('focus', _classPrivateFieldGet(this, _onAnchorFocus));
@@ -136,6 +139,14 @@ defineCustomElement('sinch-link', (_$anchor = new WeakMap(), _$text = new WeakMa
136
139
  return getBooleanAttribute(this, 'external');
137
140
  }
138
141
 
142
+ set standalone(isstandalone) {
143
+ updateBooleanAttribute(this, 'standalone', isstandalone);
144
+ }
145
+
146
+ get standalone() {
147
+ return getBooleanAttribute(this, 'standalone');
148
+ }
149
+
139
150
  set preventDefault(isPrevented) {
140
151
  updateBooleanAttribute(this, 'preventdefault', isPrevented);
141
152
  }
@@ -145,10 +156,14 @@ defineCustomElement('sinch-link', (_$anchor = new WeakMap(), _$text = new WeakMa
145
156
  }
146
157
 
147
158
  static get observedAttributes() {
148
- return ['text', 'href', 'external', 'disabled'];
159
+ return ['text', 'href', 'external'];
149
160
  }
150
161
 
151
- attributeChangedCallback(name, _, newVal) {
162
+ attributeChangedCallback(name, oldVal, newVal) {
163
+ if (oldVal === newVal) {
164
+ return;
165
+ }
166
+
152
167
  switch (name) {
153
168
  case 'text':
154
169
  {
@@ -156,12 +171,6 @@ defineCustomElement('sinch-link', (_$anchor = new WeakMap(), _$text = new WeakMa
156
171
  break;
157
172
  }
158
173
 
159
- case 'disabled':
160
- {
161
- updateBooleanAttribute(this, 'disabled', isAttrTrue(newVal));
162
- break;
163
- }
164
-
165
174
  case 'href':
166
175
  {
167
176
  updateAttribute(_classPrivateFieldGet(this, _$anchor), 'href', newVal);
@@ -170,9 +179,7 @@ defineCustomElement('sinch-link', (_$anchor = new WeakMap(), _$text = new WeakMa
170
179
 
171
180
  case 'external':
172
181
  {
173
- const isExternal = isAttrTrue(newVal);
174
- updateAttribute(_classPrivateFieldGet(this, _$anchor), 'target', isExternal ? '_blank' : null);
175
- updateBooleanAttribute(this, 'external', isExternal);
182
+ updateAttribute(_classPrivateFieldGet(this, _$anchor), 'target', isAttrTrue(newVal) ? '_blank' : null);
176
183
  break;
177
184
  }
178
185
  }
package/link/types.d.ts CHANGED
@@ -1,26 +1,55 @@
1
1
  import type { TSinchElementReact } from '../types';
2
2
  export declare type TSinchLinkElement = HTMLElement & {
3
+ /** Text content of hyperlink */
3
4
  text: string;
5
+ /** URL that hyperlink point to */
4
6
  href: string;
7
+ /** Disabled */
5
8
  disabled: boolean;
9
+ /** Sets `target="_blank" and a special external icon on the left side */
6
10
  external: boolean;
11
+ /** Special standalone (`display: block`) mode with an arrow icon on the right side */
12
+ standalone: boolean;
13
+ /** Prevents default behaviour on hyperlink click */
7
14
  preventDefault: boolean;
15
+ /** Click event */
8
16
  addEventListener(type: '-click', listener: (e: CustomEvent<void>) => void): void;
17
+ /** Focus event */
9
18
  addEventListener(type: '-focus', listener: (e: CustomEvent<void>) => void): void;
19
+ /** Blur event */
10
20
  addEventListener(type: '-blur', listener: (e: CustomEvent<void>) => void): void;
21
+ /** Text content of hyperlink */
11
22
  setAttribute(name: 'text', value: string): void;
23
+ /** URL that hyperlink point to */
12
24
  setAttribute(name: 'href', value: string): void;
25
+ /** Disabled */
13
26
  setAttribute(name: 'disabled', value: ''): void;
27
+ /** Sets `target="_blank" and a special external icon on the left side */
14
28
  setAttribute(name: 'external', value: ''): void;
29
+ /** Special standalone (`display: block`) mode with an arrow icon on the right side */
30
+ setAttribute(name: 'standalone', value: ''): void;
31
+ /** Prevents default behaviour on hyperlink click */
15
32
  setAttribute(name: 'preventdefault', value: ''): void;
16
33
  };
17
34
  export declare type TSinchLinkReact = TSinchElementReact<TSinchLinkElement> & {
35
+ /** Text content of hyperlink */
18
36
  text: string;
37
+ /** URL that hyperlink point to */
19
38
  href: string;
39
+ /** Disabled */
20
40
  disabled?: boolean;
41
+ /** Sets `target="_blank" and a special external icon on the left side */
21
42
  external?: boolean;
43
+ /** Special standalone (`display: block`) mode with an arrow icon on the right side */
44
+ standalone?: boolean;
45
+ /** Prevents default behaviour on hyperlink click */
22
46
  preventDefault?: boolean;
47
+ /** Label that is used for a11y – might be different from `text` */
48
+ 'aria-label': string;
49
+ /** Click even handler */
23
50
  'on-click'?: (e: CustomEvent<void>) => void;
51
+ /** Focus even handler */
24
52
  'on-focus'?: (e: CustomEvent<void>) => void;
53
+ /** Blur even handler */
25
54
  'on-blur'?: (e: CustomEvent<void>) => void;
26
55
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nectary/components",
3
- "version": "0.36.1",
3
+ "version": "0.38.0",
4
4
  "files": [
5
5
  "theme.css",
6
6
  "**/*/*.js",
@@ -11,7 +11,7 @@
11
11
  "colors.json"
12
12
  ],
13
13
  "scripts": {
14
- "build": "NODE_ENV=production babel . --extensions '.ts' --out-dir . && tsc"
14
+ "build": "NODE_ENV=production babel . --extensions '.ts' --out-dir . && tsc --declaration --emitDeclarationOnly"
15
15
  },
16
16
  "dependencies": {
17
17
  "@babel/runtime": "^7.17.0",
package/popover/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
2
  import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
3
 
4
- var _$target, _$dialog, _isConnected, _resizeThrottle, _originalOverflowValue, _$targetSlot, _$targetOpenSlot, _$targetOpenWrapper, _targetActiveElement, _onExpand, _onCollapse, _isOpen, _onResize, _updateOrientation, _onBackdropMouseDown, _onCancel, _onCloseReactHandler, _dispatchCloseEvent, _onTargetBlur, _onTargetFocus;
4
+ var _$target, _$dialog, _isConnected, _resizeThrottle, _originalOverflowValue, _$targetSlot, _$targetOpenSlot, _$targetOpenWrapper, _targetActiveElement, _onExpand, _onCollapse, _isOpen, _onResize, _updateOrientation, _onBackdropMouseDown, _onCancel, _onCloseReactHandler, _dispatchCloseEvent, _captureActiveElement, _stopPropagation;
5
5
 
6
6
  function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
7
7
 
@@ -18,7 +18,7 @@ import { orientationValues } from './utils';
18
18
  const template = document.createElement('template');
19
19
  template.innerHTML = templateHTML;
20
20
  const POPOVER_OFFSET = 4;
21
- defineCustomElement('sinch-popover', (_$target = new WeakMap(), _$dialog = new WeakMap(), _isConnected = new WeakMap(), _resizeThrottle = new WeakMap(), _originalOverflowValue = new WeakMap(), _$targetSlot = new WeakMap(), _$targetOpenSlot = new WeakMap(), _$targetOpenWrapper = new WeakMap(), _targetActiveElement = new WeakMap(), _onExpand = new WeakSet(), _onCollapse = new WeakSet(), _isOpen = new WeakSet(), _onResize = new WeakMap(), _updateOrientation = new WeakMap(), _onBackdropMouseDown = new WeakMap(), _onCancel = new WeakMap(), _onCloseReactHandler = new WeakMap(), _dispatchCloseEvent = new WeakSet(), _onTargetBlur = new WeakMap(), _onTargetFocus = new WeakMap(), class extends NectaryElement {
21
+ defineCustomElement('sinch-popover', (_$target = new WeakMap(), _$dialog = new WeakMap(), _isConnected = new WeakMap(), _resizeThrottle = new WeakMap(), _originalOverflowValue = new WeakMap(), _$targetSlot = new WeakMap(), _$targetOpenSlot = new WeakMap(), _$targetOpenWrapper = new WeakMap(), _targetActiveElement = new WeakMap(), _onExpand = new WeakSet(), _onCollapse = new WeakSet(), _isOpen = new WeakSet(), _onResize = new WeakMap(), _updateOrientation = new WeakMap(), _onBackdropMouseDown = new WeakMap(), _onCancel = new WeakMap(), _onCloseReactHandler = new WeakMap(), _dispatchCloseEvent = new WeakSet(), _captureActiveElement = new WeakMap(), _stopPropagation = new WeakMap(), class extends NectaryElement {
22
22
  constructor() {
23
23
  super();
24
24
 
@@ -159,23 +159,19 @@ defineCustomElement('sinch-popover', (_$target = new WeakMap(), _$dialog = new W
159
159
  }
160
160
  });
161
161
 
162
- _classPrivateFieldInitSpec(this, _onTargetBlur, {
162
+ _classPrivateFieldInitSpec(this, _captureActiveElement, {
163
163
  writable: true,
164
164
  value: e => {
165
165
  e.stopPropagation();
166
166
 
167
167
  _classPrivateFieldSet(this, _targetActiveElement, e.target);
168
-
169
- _classPrivateFieldGet(this, _$targetOpenSlot).removeEventListener('blur', _classPrivateFieldGet(this, _onTargetBlur), true);
170
168
  }
171
169
  });
172
170
 
173
- _classPrivateFieldInitSpec(this, _onTargetFocus, {
171
+ _classPrivateFieldInitSpec(this, _stopPropagation, {
174
172
  writable: true,
175
173
  value: e => {
176
174
  e.stopPropagation();
177
-
178
- _classPrivateFieldGet(this, _$targetOpenSlot).removeEventListener('focus', _classPrivateFieldGet(this, _onTargetFocus), true);
179
175
  }
180
176
  });
181
177
 
@@ -308,10 +304,12 @@ function _onExpand2() {
308
304
  return;
309
305
  }
310
306
 
311
- if (!this.modal) {
312
- _classPrivateFieldGet(this, _$targetOpenSlot).addEventListener('blur', _classPrivateFieldGet(this, _onTargetBlur), true);
307
+ const isNonModal = !this.modal;
308
+
309
+ _classPrivateFieldGet(this, _$targetSlot).addEventListener('blur', _classPrivateFieldGet(this, _stopPropagation), true);
313
310
 
314
- _classPrivateFieldGet(this, _$targetOpenSlot).addEventListener('focus', _classPrivateFieldGet(this, _onTargetFocus), true);
311
+ if (isNonModal) {
312
+ _classPrivateFieldGet(this, _$targetOpenSlot).addEventListener('blur', _classPrivateFieldGet(this, _captureActiveElement), true);
315
313
 
316
314
  const targetRect = _classPrivateFieldGet(this, _$target).getBoundingClientRect();
317
315
 
@@ -330,11 +328,21 @@ function _onExpand2() {
330
328
 
331
329
  _classPrivateFieldGet(this, _$target).setAttribute('aria-expanded', 'true');
332
330
 
333
- requestAnimationFrame(() => {
334
- _classPrivateFieldGet(this, _targetActiveElement)?.focus();
331
+ _classPrivateFieldGet(this, _$targetSlot).removeEventListener('blur', _classPrivateFieldGet(this, _stopPropagation), true);
335
332
 
336
- _classPrivateFieldSet(this, _targetActiveElement, null);
337
- });
333
+ if (isNonModal) {
334
+ _classPrivateFieldGet(this, _$targetOpenSlot).removeEventListener('blur', _classPrivateFieldGet(this, _captureActiveElement), true);
335
+
336
+ if (_classPrivateFieldGet(this, _targetActiveElement) !== null) {
337
+ requestAnimationFrame(() => {
338
+ _classPrivateFieldGet(this, _$targetOpenSlot).addEventListener('focus', _classPrivateFieldGet(this, _stopPropagation), true);
339
+
340
+ _classPrivateFieldGet(this, _targetActiveElement)?.focus();
341
+
342
+ _classPrivateFieldGet(this, _$targetOpenSlot).removeEventListener('focus', _classPrivateFieldGet(this, _stopPropagation), true);
343
+ });
344
+ }
345
+ }
338
346
 
339
347
  _classPrivateFieldSet(this, _originalOverflowValue, document.body.style.overflow);
340
348
 
@@ -347,6 +355,18 @@ function _onCollapse2() {
347
355
  return;
348
356
  }
349
357
 
358
+ _classPrivateFieldGet(this, _$targetSlot).addEventListener('focus', _classPrivateFieldGet(this, _stopPropagation), true);
359
+
360
+ if (_classPrivateFieldGet(this, _targetActiveElement) !== null) {
361
+ _classPrivateFieldGet(this, _$targetOpenSlot).addEventListener('focus', _classPrivateFieldGet(this, _stopPropagation), true);
362
+
363
+ _classPrivateFieldGet(this, _targetActiveElement).focus();
364
+
365
+ _classPrivateFieldSet(this, _targetActiveElement, null);
366
+
367
+ _classPrivateFieldGet(this, _$targetOpenSlot).removeEventListener('focus', _classPrivateFieldGet(this, _stopPropagation), true);
368
+ }
369
+
350
370
  _classPrivateFieldGet(this, _$targetOpenSlot).assignedElements()[0]?.setAttribute('slot', 'target');
351
371
  _classPrivateFieldGet(this, _$target).style.width = 'unset';
352
372
  _classPrivateFieldGet(this, _$target).style.height = 'unset';
@@ -355,6 +375,8 @@ function _onCollapse2() {
355
375
 
356
376
  _classPrivateFieldGet(this, _$target).setAttribute('aria-expanded', 'false');
357
377
 
378
+ _classPrivateFieldGet(this, _$targetSlot).removeEventListener('focus', _classPrivateFieldGet(this, _stopPropagation), true);
379
+
358
380
  document.body.style.overflow = _classPrivateFieldGet(this, _originalOverflowValue);
359
381
 
360
382
  _classPrivateFieldGet(this, _resizeThrottle).cancel();
@@ -0,0 +1,17 @@
1
+ import '../spinner';
2
+ import '../icons/check-circle';
3
+ import '../icons/report';
4
+ import '../icons/pending-actions';
5
+ import '../icons/text-snippet';
6
+ import '../text';
7
+ import type { TSinchProgressElement, TSinchProgressReact } from './types';
8
+ declare global {
9
+ namespace JSX {
10
+ interface IntrinsicElements {
11
+ 'sinch-progress': TSinchProgressReact;
12
+ }
13
+ }
14
+ interface HTMLElementTagNameMap {
15
+ 'sinch-progress': TSinchProgressElement;
16
+ }
17
+ }
@@ -0,0 +1,87 @@
1
+ import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
2
+ import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
3
+
4
+ var _$bar, _$text;
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
+ import '../spinner';
11
+ import '../icons/check-circle';
12
+ import '../icons/report';
13
+ import '../icons/pending-actions';
14
+ import '../icons/text-snippet';
15
+ import '../text';
16
+ import { defineCustomElement, updateAttribute, NectaryElement, updateBooleanAttribute, getIntegerAttribute, getBooleanAttribute, attrValueToInteger } from '../utils';
17
+ const templateHTML = '<style>:host{display:block}#wrapper{display:flex;align-items:center;height:24px}#bar,#progress{height:8px;border-radius:4px}#progress{background-color:var(--sinch-color-tropical-100);flex:1;min-width:0}#bar{background-color:var(--sinch-color-tropical-500);width:0}#text{display:none;width:46px}:host([detailed]:not([detailed=false])) #text{display:block}</style><div id="wrapper"><sinch-text id="text" type="m"></sinch-text><div id="progress"><div id="bar"></div></div></div>';
18
+ const template = document.createElement('template');
19
+ template.innerHTML = templateHTML;
20
+ defineCustomElement('sinch-progress', (_$bar = new WeakMap(), _$text = new WeakMap(), class extends NectaryElement {
21
+ constructor() {
22
+ super();
23
+
24
+ _classPrivateFieldInitSpec(this, _$bar, {
25
+ writable: true,
26
+ value: void 0
27
+ });
28
+
29
+ _classPrivateFieldInitSpec(this, _$text, {
30
+ writable: true,
31
+ value: void 0
32
+ });
33
+
34
+ const shadowRoot = this.attachShadow();
35
+ shadowRoot.appendChild(template.content.cloneNode(true));
36
+
37
+ _classPrivateFieldSet(this, _$bar, shadowRoot.querySelector('#bar'));
38
+
39
+ _classPrivateFieldSet(this, _$text, shadowRoot.querySelector('#text'));
40
+ }
41
+
42
+ connectedCallback() {
43
+ this.setAttribute('role', 'progressbar');
44
+ }
45
+
46
+ get value() {
47
+ return getIntegerAttribute(this, 'value', 0);
48
+ }
49
+
50
+ set value(value) {
51
+ updateAttribute(this, 'value', value);
52
+ }
53
+
54
+ get detailed() {
55
+ return getBooleanAttribute(this, 'detailed');
56
+ }
57
+
58
+ set detailed(isDetailed) {
59
+ updateBooleanAttribute(this, 'detailed', isDetailed);
60
+ }
61
+
62
+ static get observedAttributes() {
63
+ return ['value'];
64
+ }
65
+
66
+ attributeChangedCallback(name, oldVal, newVal) {
67
+ if (oldVal === newVal) {
68
+ return;
69
+ }
70
+
71
+ switch (name) {
72
+ case 'value':
73
+ {
74
+ const int = attrValueToInteger(newVal, {
75
+ min: 0,
76
+ max: 100
77
+ });
78
+ const intCss = int === null ? '0%' : `${int}%`;
79
+ _classPrivateFieldGet(this, _$bar).style.width = intCss;
80
+ _classPrivateFieldGet(this, _$text).textContent = intCss;
81
+ this.setAttribute('valuenow', int !== null ? String(int) : '0');
82
+ break;
83
+ }
84
+ }
85
+ }
86
+
87
+ }));
@@ -0,0 +1,12 @@
1
+ import type { TSinchElementReact } from '../types';
2
+ export declare type TSinchProgressElement = HTMLElement & {
3
+ value: number;
4
+ detailed: boolean;
5
+ setAttribute(name: 'value', value: string): void;
6
+ setAttribute(name: 'detailed', value: ''): void;
7
+ };
8
+ export declare type TSinchProgressReact = TSinchElementReact<TSinchProgressElement> & {
9
+ value: number;
10
+ detailed?: boolean;
11
+ 'aria-label': string;
12
+ };
@@ -0,0 +1 @@
1
+ export {};
package/search/index.js CHANGED
@@ -12,7 +12,7 @@ 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 { attrValueToPixels, defineCustomElement, getAttribute, getBooleanAttribute, getIntegerAttribute, getRect, NectaryElement, updateAttribute, updateBooleanAttribute, updateIntegerAttribute } from '../utils';
15
- const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{position:relative;width:100%;box-sizing:border-box;--sinch-size-icon:24px}#label{display:none;font:var(--sinch-font-title-s);color:var(--sinch-color-text-default);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:100%;height:24px;margin-bottom:2px}#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%;height:48px;padding:0 44px;padding-right: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)}#input::placeholder{font:var(--sinch-font-body);color:var(--sinch-color-text-muted)}#input:focus{border-color:var(--sinch-color-stormy-600)}#icon-search{position:absolute;left:12px;top:12px;pointer-events:none;--sinch-color-icon:var(--sinch-color-stormy-500)}#clear{position:absolute;right:8px;top:8px;display:none;--sinch-color-icon:red}#clear:focus{--sinch-color-icon:var(--sinch-color-stormy-500)}:host([value]:not([value=""])) #clear{display:flex}:host([value]:not([value=""])) #input{padding-right:44px}#listbox{display:none;position:absolute;z-index:1;left:0;top:calc(100% + 8px);width:100%;box-sizing:border-box;font:var(--sinch-font-body);color:var(--sinch-color-text-default);background-color:var(--sinch-color-snow-100);box-shadow:var(--sinch-elevation-level-2);overflow-y:auto}:host([aria-expanded=true]) #listbox{display:block}:host([label]:not([label=""])) #label{display:block}</style><label id="label" for="input"></label><div id="wrapper"><input id="input" type="text"/><sinch-icon-search id="icon-search"></sinch-icon-search><sinch-icon-button id="clear" small><sinch-icon-close id="icon-close" slot="icon"></sinch-icon-close></sinch-icon-button><div id="listbox"><slot name="option"></slot></div></div>';
15
+ const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{position:relative;width:100%;box-sizing:border-box;--sinch-size-icon:24px}#label{display:none;font:var(--sinch-font-title-s);color:var(--sinch-color-text-default);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:100%;height:24px;margin-bottom:2px}#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%;height:48px;padding:0 44px;padding-right:12px;font:var(--sinch-font-body);color:var(--sinch-color-text-default);background-color:var(--sinch-color-snow-100)}#input::placeholder{font:var(--sinch-font-body);color:var(--sinch-color-text-muted);opacity:1}#input:focus{border-color:var(--sinch-color-stormy-600)}#icon-search{position:absolute;left:12px;top:12px;pointer-events:none;--sinch-color-icon:var(--sinch-color-stormy-500)}#clear{position:absolute;right:8px;top:8px;display:none;--sinch-color-icon:red}#clear:focus{--sinch-color-icon:var(--sinch-color-stormy-500)}:host([value]:not([value=""])) #clear{display:flex}:host([value]:not([value=""])) #input{padding-right:44px}#listbox{display:none;position:absolute;z-index:1;left:0;top:calc(100% + 8px);width:100%;box-sizing:border-box;font:var(--sinch-font-body);color:var(--sinch-color-text-default);background-color:var(--sinch-color-snow-100);box-shadow:var(--sinch-elevation-level-2);overflow-y:auto}:host([aria-expanded=true]) #listbox{display:block}:host([label]:not([label=""])) #label{display:block}</style><label id="label" for="input"></label><div id="wrapper"><input id="input" type="text"/><sinch-icon-search id="icon-search"></sinch-icon-search><sinch-icon-button id="clear" small><sinch-icon-close id="icon-close" slot="icon"></sinch-icon-close></sinch-icon-button><div id="listbox"><slot name="option"></slot></div></div>';
16
16
  import '../icons/search';
17
17
  import '../icons/close';
18
18
  import '../icon-button';