@nectary/components 2.1.5 → 2.2.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.
- package/action-menu/index.js +1 -0
- package/action-menu-option/index.js +1 -0
- package/avatar/index.js +1 -1
- package/button/index.js +3 -2
- package/card/index.js +3 -2
- package/chip/index.js +2 -1
- package/color-menu/index.js +2 -2
- package/color-swatch/index.js +1 -1
- package/date-picker/index.js +11 -9
- package/date-picker/utils.d.ts +1 -0
- package/date-picker/utils.js +8 -0
- package/dialog/index.js +3 -2
- package/emoji/index.js +1 -1
- package/emoji-picker/index.js +2 -1
- package/field/index.js +1 -0
- package/flag/index.js +1 -1
- package/help-tooltip/index.js +1 -0
- package/icon-button/index.js +3 -2
- package/input/index.js +371 -40
- package/input/types.d.ts +14 -0
- package/input/utils.d.ts +24 -0
- package/input/utils.js +302 -1
- package/package.json +1 -1
- package/pop/index.js +5 -5
- package/popover/index.js +1 -0
- package/progress-stepper/index.d.ts +11 -0
- package/progress-stepper/index.js +209 -0
- package/progress-stepper/types.d.ts +22 -0
- package/progress-stepper/types.js +1 -0
- package/progress-stepper-item/index.d.ts +12 -0
- package/progress-stepper-item/index.js +82 -0
- package/progress-stepper-item/types.d.ts +23 -0
- package/progress-stepper-item/types.js +1 -0
- package/progress-stepper-item/utils.d.ts +11 -0
- package/progress-stepper-item/utils.js +13 -0
- package/select-button/index.js +2 -1
- package/select-menu/index.js +2 -1
- package/spinner/index.js +1 -0
- package/stop-events/index.js +1 -0
- package/tabs/index.js +1 -0
- package/tag/index.js +1 -1
- package/textarea/index.js +2 -1
- package/time-picker/index.js +1 -0
- package/time-picker/utils.js +2 -15
- package/tooltip/index.js +4 -3
- package/utils/countries.d.ts +1 -0
- package/utils/countries.json +487 -268
- package/utils/element.d.ts +1 -1
- package/utils/element.js +5 -5
- package/utils/event-target.d.ts +1 -0
- package/utils/event-target.js +9 -0
- 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);
|
package/select-button/index.js
CHANGED
|
@@ -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.
|
|
162
|
+
if (!this.isDomConnected) {
|
|
162
163
|
return;
|
|
163
164
|
}
|
|
164
165
|
const size = this.getAttribute('data-size') ?? DEFAULT_SIZE;
|
package/select-menu/index.js
CHANGED
|
@@ -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
package/stop-events/index.js
CHANGED
package/tabs/index.js
CHANGED
package/tag/index.js
CHANGED
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.
|
|
207
|
+
if (!this.isDomConnected) {
|
|
207
208
|
return;
|
|
208
209
|
}
|
|
209
210
|
const size = this.getAttribute('data-size') ?? DEFAULT_SIZE;
|
package/time-picker/index.js
CHANGED
|
@@ -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'];
|
package/time-picker/utils.js
CHANGED
|
@@ -6,15 +6,8 @@ export const parseTime = value => {
|
|
|
6
6
|
};
|
|
7
7
|
}
|
|
8
8
|
const timeParts = value.split(':');
|
|
9
|
-
|
|
10
|
-
|
|
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.#
|
|
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.
|
|
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.
|
|
210
|
+
if (!this.isDomConnected || this.#isSubscribed) {
|
|
210
211
|
return;
|
|
211
212
|
}
|
|
212
213
|
this.#$target.addEventListener('mouseenter', this.#onMouseEnter, {
|