@nectary/components 2.1.5 → 2.2.1

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 (52) hide show
  1. package/action-menu/index.js +1 -0
  2. package/action-menu-option/index.js +1 -0
  3. package/avatar/index.js +1 -1
  4. package/button/index.js +3 -2
  5. package/card/index.js +3 -2
  6. package/chip/index.js +2 -1
  7. package/color-menu/index.js +2 -2
  8. package/color-swatch/index.js +1 -1
  9. package/date-picker/index.js +11 -9
  10. package/date-picker/utils.d.ts +1 -0
  11. package/date-picker/utils.js +8 -0
  12. package/dialog/index.js +3 -2
  13. package/emoji/index.js +1 -1
  14. package/emoji-picker/index.js +2 -1
  15. package/field/index.js +1 -0
  16. package/flag/index.js +1 -1
  17. package/help-tooltip/index.js +1 -0
  18. package/icon-button/index.js +3 -2
  19. package/input/index.js +371 -40
  20. package/input/types.d.ts +14 -0
  21. package/input/utils.d.ts +24 -0
  22. package/input/utils.js +302 -1
  23. package/package.json +1 -1
  24. package/pop/index.js +5 -5
  25. package/popover/index.js +1 -0
  26. package/progress-stepper/index.d.ts +11 -0
  27. package/progress-stepper/index.js +209 -0
  28. package/progress-stepper/types.d.ts +22 -0
  29. package/progress-stepper/types.js +1 -0
  30. package/progress-stepper-item/index.d.ts +12 -0
  31. package/progress-stepper-item/index.js +82 -0
  32. package/progress-stepper-item/types.d.ts +23 -0
  33. package/progress-stepper-item/types.js +1 -0
  34. package/progress-stepper-item/utils.d.ts +11 -0
  35. package/progress-stepper-item/utils.js +13 -0
  36. package/select-button/index.js +2 -1
  37. package/select-menu/index.js +2 -1
  38. package/spinner/index.js +1 -0
  39. package/stop-events/index.js +1 -0
  40. package/tabs/index.js +1 -0
  41. package/tag/index.js +1 -1
  42. package/textarea/index.js +2 -1
  43. package/time-picker/index.js +1 -0
  44. package/time-picker/utils.js +2 -15
  45. package/tooltip/index.js +4 -3
  46. package/utils/countries.d.ts +1 -0
  47. package/utils/countries.json +487 -268
  48. package/utils/element.d.ts +1 -1
  49. package/utils/element.js +5 -5
  50. package/utils/event-target.d.ts +1 -0
  51. package/utils/event-target.js +9 -0
  52. package/utils/get-react-event-handler.js +1 -1
@@ -0,0 +1,82 @@
1
+ import '../text';
2
+ import { defineCustomElement, getAttribute, getBooleanAttribute, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
3
+ const templateHTML = '<style>:host{display:block;outline:0}#button{position:relative;display:flex;flex-direction:column;gap:4px;width:100%;height:100%;padding:8px 4px 4px;box-sizing:border-box;cursor:pointer;border-radius:var(--sinch-comp-progress-stepper-step-shape-radius)}:host([data-status=inactive])>#button{cursor:not-allowed}:host([data-status=incomplete]:hover)>#button{background-color:var(--sinch-comp-progress-stepper-step-color-incomplete-background-hover)}:host([data-status=complete]:hover)>#button{background-color:var(--sinch-comp-progress-stepper-step-color-complete-background-hover)}:host([data-status=invalid]:hover)>#button{background-color:var(--sinch-comp-progress-stepper-step-color-invalid-background-hover)}#outline{position:absolute;inset:-2px;border:2px solid var(--sinch-comp-progress-stepper-step-color-outline-focus);border-radius:calc(var(--sinch-comp-progress-stepper-step-shape-radius) + 2px);pointer-events:none;opacity:0}:host(:focus-visible) #outline{opacity:1}#text{flex-shrink:1;flex-basis:auto;min-width:0;transform:translate(0,0);will-change:transform;transition:transform .25s ease-out;padding-right:24px}:host([data-status=incomplete]) #text{--sinch-global-color-text:var(--sinch-comp-progress-stepper-step-color-incomplete-label-default);--sinch-comp-text-font:var(--sinch-comp-progress-stepper-step-font-incomplete-label)}:host([data-status=complete]) #text{--sinch-global-color-text:var(--sinch-comp-progress-stepper-step-color-complete-label-default);--sinch-comp-text-font:var(--sinch-comp-progress-stepper-step-font-complete-label)}:host([data-status=inactive]) #text{--sinch-global-color-text:var(--sinch-comp-progress-stepper-step-color-inactive-label-default);--sinch-comp-text-font:var(--sinch-comp-progress-stepper-step-font-inactive-label)}:host([invalid]) #text{--sinch-global-color-text:var(--sinch-comp-progress-stepper-step-color-invalid-label-default);--sinch-comp-text-font:var(--sinch-comp-progress-stepper-step-font-invalid-label);transform:translate(24px,0)}:host([data-status=incomplete][data-checked]) #text{--sinch-global-color-text:var(--sinch-comp-progress-stepper-step-color-incomplete-current-label-default);--sinch-comp-text-font:var(--sinch-comp-progress-stepper-step-font-incomplete-current-label)}:host([data-status=complete][data-checked]) #text{--sinch-global-color-text:var(--sinch-comp-progress-stepper-step-color-complete-current-label-default);--sinch-comp-text-font:var(--sinch-comp-progress-stepper-step-font-complete-current-label)}:host([invalid][data-checked]) #text{--sinch-global-color-text:var(--sinch-comp-progress-stepper-step-color-invalid-label-default);--sinch-comp-text-font:var(--sinch-comp-progress-stepper-step-font-invalid-current-label)}#icon-error{position:absolute;left:0;top:4px;pointer-events:none;opacity:0;transition:opacity .25s ease-in-out;--sinch-global-color-icon:var(--sinch-comp-progress-stepper-step-color-invalid-icon-default);--sinch-global-size-icon:16px}:host([invalid]) #icon-error{opacity:1}#progress{height:8px;border-radius:4px;transition:background-color .25s ease-in-out}:host([data-status=incomplete]) #progress{background-color:var(--sinch-comp-progress-stepper-step-color-incomplete-progress-background)}:host([data-status=complete]) #progress{background-color:var(--sinch-comp-progress-stepper-step-color-complete-progress-background)}:host([data-status=inactive]) #progress{background-color:var(--sinch-comp-progress-stepper-step-color-inactive-progress-background)}:host([invalid]) #progress{background-color:var(--sinch-comp-progress-stepper-step-color-invalid-progress-background)}#bar{width:8px;height:8px;border-radius:4px;opacity:0;transition:width .25s ease-in-out,opacity .25s ease-in-out}:host([data-status=incomplete]) #bar{background-color:var(--sinch-comp-progress-stepper-step-color-incomplete-progress-bar)}:host([data-status=complete]) #bar{background-color:var(--sinch-comp-progress-stepper-step-color-complete-progress-bar);width:100%}:host([data-status=complete]:not([invalid])) #bar,:host([data-status=incomplete]:not([invalid])) #bar{opacity:1}#label-bar{position:relative}</style><div id="button"><div id="progress"><div id="bar"></div></div><div id="label-bar"><sinch-icon id="icon-error" name="report_problem" aria-hidden="true"></sinch-icon><sinch-text id="text" type="m"></sinch-text></div><div id="outline"></div></div>';
4
+ import { ATTR_PROGRESS_STEPPER_ITEM_ACTIVE_DESCENDANT, ATTR_PROGRESS_STEPPER_ITEM_CHECKED, ATTR_PROGRESS_STEPPER_ITEM_STATUS, isProgressStepperItemActive, isProgressStepperItemActiveDescendant } from './utils';
5
+ const template = document.createElement('template');
6
+ template.innerHTML = templateHTML;
7
+ defineCustomElement('sinch-progress-stepper-item', class extends NectaryElement {
8
+ #$text;
9
+ constructor() {
10
+ super();
11
+ const shadowRoot = this.attachShadow({
12
+ delegatesFocus: false
13
+ });
14
+ shadowRoot.appendChild(template.content.cloneNode(true));
15
+ this.#$text = shadowRoot.querySelector('#text');
16
+ }
17
+ connectedCallback() {
18
+ this.role = 'tab';
19
+ }
20
+ disconnectedCallback() {}
21
+ static get observedAttributes() {
22
+ return ['text', 'invalid', ATTR_PROGRESS_STEPPER_ITEM_STATUS, ATTR_PROGRESS_STEPPER_ITEM_CHECKED, ATTR_PROGRESS_STEPPER_ITEM_ACTIVE_DESCENDANT];
23
+ }
24
+ attributeChangedCallback(name, oldVal, newVal) {
25
+ if (oldVal === newVal) {
26
+ return;
27
+ }
28
+ switch (name) {
29
+ case 'text':
30
+ {
31
+ this.#$text.textContent = newVal;
32
+ break;
33
+ }
34
+ case ATTR_PROGRESS_STEPPER_ITEM_CHECKED:
35
+ {
36
+ updateExplicitBooleanAttribute(this, 'aria-selected', isAttrTrue(newVal));
37
+ break;
38
+ }
39
+ case ATTR_PROGRESS_STEPPER_ITEM_STATUS:
40
+ {
41
+ this.#updateTabIndex();
42
+ break;
43
+ }
44
+ case ATTR_PROGRESS_STEPPER_ITEM_ACTIVE_DESCENDANT:
45
+ {
46
+ this.#updateTabIndex();
47
+ break;
48
+ }
49
+ case 'invalid':
50
+ {
51
+ const isInvalid = isAttrTrue(newVal);
52
+ updateBooleanAttribute(this, 'invalid', isInvalid);
53
+ updateExplicitBooleanAttribute(this, 'aria-invalid', isInvalid);
54
+ break;
55
+ }
56
+ }
57
+ }
58
+ set value(value) {
59
+ updateAttribute(this, 'value', value);
60
+ }
61
+ get value() {
62
+ return getAttribute(this, 'value', '');
63
+ }
64
+ set text(value) {
65
+ updateAttribute(this, 'text', value);
66
+ }
67
+ get text() {
68
+ return getAttribute(this, 'text', '');
69
+ }
70
+ set invalid(isInvalid) {
71
+ updateBooleanAttribute(this, 'invalid', isInvalid);
72
+ }
73
+ get invalid() {
74
+ return getBooleanAttribute(this, 'invalid');
75
+ }
76
+ get focusable() {
77
+ return true;
78
+ }
79
+ #updateTabIndex() {
80
+ this.tabIndex = isProgressStepperItemActiveDescendant(this) && isProgressStepperItemActive(this) ? 0 : -1;
81
+ }
82
+ });
@@ -0,0 +1,23 @@
1
+ import type { TSinchElementReact } from '../types';
2
+ export type TSinchProgressStepperItemElement = HTMLElement & {
3
+ /** Value */
4
+ value: string;
5
+ /** Text */
6
+ text: string;
7
+ /** Invalid */
8
+ invalid: boolean;
9
+ /** Value */
10
+ setAttribute(name: 'value', value: string): void;
11
+ /** Text */
12
+ setAttribute(name: 'text', value: string): void;
13
+ /** Invalid */
14
+ setAttribute(name: 'invalid', value: ''): void;
15
+ };
16
+ export type TSinchProgressStepperItemReact = TSinchElementReact<TSinchProgressStepperItemElement> & {
17
+ /** Value */
18
+ value: string;
19
+ /** Text */
20
+ text: string;
21
+ /** Invalid */
22
+ invalid?: boolean;
23
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ type TSinchProgressStepperItemStatus = 'inactive' | 'incomplete' | 'invalid' | 'complete';
2
+ export declare const ATTR_PROGRESS_STEPPER_ITEM_CHECKED = "data-checked";
3
+ export declare const ATTR_PROGRESS_STEPPER_ITEM_STATUS = "data-status";
4
+ export declare const ATTR_PROGRESS_STEPPER_ITEM_ACTIVE_DESCENDANT = "data-active-descendant";
5
+ export declare const isProgressStepperItemChecked: ($el: Element) => boolean;
6
+ export declare const setProgressStepperItemChecked: ($el: Element, isChecked: boolean) => void;
7
+ export declare const isProgressStepperItemActive: ($el: Element) => boolean;
8
+ export declare const setProgressStepperItemStatus: ($el: Element, status: TSinchProgressStepperItemStatus) => void;
9
+ export declare const isProgressStepperItemActiveDescendant: ($el: Element) => boolean;
10
+ export declare const setProgressStepperItemActiveDescendant: ($el: Element, isActiveDescendant: boolean) => void;
11
+ export {};
@@ -0,0 +1,13 @@
1
+ import { getAttribute, getBooleanAttribute, updateAttribute, updateBooleanAttribute } from '../utils';
2
+ export const ATTR_PROGRESS_STEPPER_ITEM_CHECKED = 'data-checked';
3
+ export const ATTR_PROGRESS_STEPPER_ITEM_STATUS = 'data-status';
4
+ export const ATTR_PROGRESS_STEPPER_ITEM_ACTIVE_DESCENDANT = 'data-active-descendant';
5
+ export const isProgressStepperItemChecked = $el => getBooleanAttribute($el, ATTR_PROGRESS_STEPPER_ITEM_CHECKED);
6
+ export const setProgressStepperItemChecked = ($el, isChecked) => updateBooleanAttribute($el, ATTR_PROGRESS_STEPPER_ITEM_CHECKED, isChecked);
7
+ export const isProgressStepperItemActive = $el => {
8
+ const attrValue = getAttribute($el, ATTR_PROGRESS_STEPPER_ITEM_STATUS);
9
+ return attrValue !== null && attrValue !== 'inactive';
10
+ };
11
+ export const setProgressStepperItemStatus = ($el, status) => updateAttribute($el, ATTR_PROGRESS_STEPPER_ITEM_STATUS, status);
12
+ export const isProgressStepperItemActiveDescendant = $el => getBooleanAttribute($el, ATTR_PROGRESS_STEPPER_ITEM_ACTIVE_DESCENDANT);
13
+ export const setProgressStepperItemActiveDescendant = ($el, isActiveDescendant) => updateBooleanAttribute($el, ATTR_PROGRESS_STEPPER_ITEM_ACTIVE_DESCENDANT, isActiveDescendant);
@@ -64,6 +64,7 @@ defineCustomElement('sinch-select-button', class extends NectaryElement {
64
64
  disconnectedCallback() {
65
65
  super.disconnectedCallback();
66
66
  this.#controller.abort();
67
+ this.#controller = null;
67
68
  }
68
69
  static get observedAttributes() {
69
70
  return ['text', 'placeholder', 'invalid', 'disabled', 'size', 'data-size'];
@@ -158,7 +159,7 @@ defineCustomElement('sinch-select-button', class extends NectaryElement {
158
159
  }
159
160
  };
160
161
  #onSizeUpdate() {
161
- if (!this.isConnected) {
162
+ if (!this.isDomConnected) {
162
163
  return;
163
164
  }
164
165
  const size = this.getAttribute('data-size') ?? DEFAULT_SIZE;
@@ -47,8 +47,9 @@ defineCustomElement('sinch-select-menu', class extends NectaryElement {
47
47
  this.#onOptionSlotChange();
48
48
  }
49
49
  disconnectedCallback() {
50
- this.#controller.abort();
51
50
  this.#searchDebounce.cancel();
51
+ this.#controller.abort();
52
+ this.#controller = null;
52
53
  }
53
54
  static get observedAttributes() {
54
55
  return ['value', 'rows', 'multiple'];
package/spinner/index.js CHANGED
@@ -18,6 +18,7 @@ defineCustomElement('sinch-spinner', class extends NectaryElement {
18
18
  }
19
19
  disconnectedCallback() {
20
20
  this.#controller.abort();
21
+ this.#controller = null;
21
22
  }
22
23
  static get observedAttributes() {
23
24
  return ['size'];
@@ -19,6 +19,7 @@ defineCustomElement('sinch-stop-events', class extends HTMLElement {
19
19
  }
20
20
  disconnectedCallback() {
21
21
  this.#controller.abort();
22
+ this.#controller = null;
22
23
  }
23
24
  #stopEvent = e => {
24
25
  e.stopPropagation();
package/tabs/index.js CHANGED
@@ -29,6 +29,7 @@ defineCustomElement('sinch-tabs', class extends NectaryElement {
29
29
  }
30
30
  disconnectedCallback() {
31
31
  this.#controller.abort();
32
+ this.#controller = null;
32
33
  }
33
34
  static get observedAttributes() {
34
35
  return ['value'];
package/tag/index.js CHANGED
@@ -62,7 +62,7 @@ defineCustomElement('sinch-tag', class extends NectaryElement {
62
62
  }
63
63
  }
64
64
  #updateColor() {
65
- if (!this.isConnected) {
65
+ if (!this.isDomConnected) {
66
66
  return;
67
67
  }
68
68
  const colorName = this.color;
package/textarea/index.js CHANGED
@@ -47,6 +47,7 @@ defineCustomElement('sinch-textarea', class extends NectaryElement {
47
47
  disconnectedCallback() {
48
48
  super.disconnectedCallback();
49
49
  this.#controller.abort();
50
+ this.#controller = null;
50
51
  }
51
52
  static get observedAttributes() {
52
53
  return ['value', 'placeholder', 'invalid', 'disabled', 'rows', 'resizable'];
@@ -203,7 +204,7 @@ defineCustomElement('sinch-textarea', class extends NectaryElement {
203
204
  setClass(this.#$bottomWrapper, 'empty', isEmpty);
204
205
  };
205
206
  #onSizeUpdate() {
206
- if (!this.isConnected) {
207
+ if (!this.isDomConnected) {
207
208
  return;
208
209
  }
209
210
  const size = this.getAttribute('data-size') ?? DEFAULT_SIZE;
@@ -105,6 +105,7 @@ defineCustomElement('sinch-time-picker', class extends NectaryElement {
105
105
  }
106
106
  disconnectedCallback() {
107
107
  this.#controller.abort();
108
+ this.#controller = null;
108
109
  }
109
110
  static get observedAttributes() {
110
111
  return ['value', 'ampm', 'submit-aria-label'];
@@ -6,15 +6,8 @@ export const parseTime = value => {
6
6
  };
7
7
  }
8
8
  const timeParts = value.split(':');
9
- if (timeParts.length < 3) {
10
- return {
11
- hours: 0,
12
- minutes: 0
13
- };
14
- }
15
- const hours = parseInt(timeParts[0]);
16
- const minutes = parseInt(timeParts[1]);
17
- const seconds = parseInt(timeParts[2]);
9
+ const hours = parseInt(timeParts[0] ?? '00');
10
+ const minutes = parseInt(timeParts[1] ?? '00');
18
11
  if (isNaN(hours) || hours > 23 || hours < 0) {
19
12
  return {
20
13
  hours: 0,
@@ -27,12 +20,6 @@ export const parseTime = value => {
27
20
  minutes: 0
28
21
  };
29
22
  }
30
- if (isNaN(seconds) || seconds > 59 || seconds < 0) {
31
- return {
32
- hours: 0,
33
- minutes: 0
34
- };
35
- }
36
23
  return {
37
24
  hours,
38
25
  minutes
package/tooltip/index.js CHANGED
@@ -57,9 +57,10 @@ defineCustomElement('sinch-tooltip', class extends NectaryElement {
57
57
  this.#updateText();
58
58
  }
59
59
  disconnectedCallback() {
60
+ this.#tooltipState.destroy();
60
61
  super.disconnectedCallback();
61
62
  this.#controller.abort();
62
- this.#tooltipState.destroy();
63
+ this.#controller = null;
63
64
  }
64
65
  static get observedAttributes() {
65
66
  return ['text', 'orientation', 'type'];
@@ -191,7 +192,7 @@ defineCustomElement('sinch-tooltip', class extends NectaryElement {
191
192
  setClass(this.#$tip, 'hidden', rectOverlap(targetRect, contentRect));
192
193
  };
193
194
  #updateText() {
194
- if (!this.isConnected) {
195
+ if (!this.isDomConnected) {
195
196
  return;
196
197
  }
197
198
  const text = this.text;
@@ -206,7 +207,7 @@ defineCustomElement('sinch-tooltip', class extends NectaryElement {
206
207
  }
207
208
  }
208
209
  #subscribeMouseEnterEvent() {
209
- if (!this.isConnected || this.#isSubscribed) {
210
+ if (!this.isDomConnected || this.#isSubscribed) {
210
211
  return;
211
212
  }
212
213
  this.#$target.addEventListener('mouseenter', this.#onMouseEnter, {
@@ -1,5 +1,6 @@
1
1
  export type TSinchCountry = {
2
2
  name: string;
3
3
  phoneCode: string;
4
+ phoneMask: string | null;
4
5
  };
5
6
  export declare const countries: Record<string, TSinchCountry>;