@nectary/components 1.4.0 → 2.1.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/accordion/index.js +0 -3
- package/accordion/types.d.ts +0 -3
- package/accordion-item/index.d.ts +2 -0
- package/accordion-item/index.js +33 -34
- package/action-menu/index.js +5 -1
- package/action-menu-option/index.js +2 -2
- package/alert/index.js +4 -21
- package/alert/utils.d.ts +0 -3
- package/alert/utils.js +1 -6
- package/avatar/index.js +5 -21
- package/avatar/utils.d.ts +0 -4
- package/avatar/utils.js +2 -15
- package/badge/index.js +36 -68
- package/badge/types.d.ts +0 -4
- package/badge/utils.d.ts +0 -6
- package/badge/utils.js +1 -17
- package/button/index.js +25 -27
- package/button/types.d.ts +2 -2
- package/button/utils.d.ts +0 -3
- package/button/utils.js +1 -9
- package/card/index.js +5 -16
- package/card/types.d.ts +0 -6
- package/card-container/index.js +1 -1
- package/chat-block/index.js +1 -1
- package/chat-bubble/index.d.ts +0 -1
- package/chat-bubble/index.js +3 -25
- package/checkbox/index.js +32 -33
- package/checkbox/types.d.ts +0 -3
- package/chip/index.js +54 -44
- package/chip/utils.d.ts +0 -1
- package/chip/utils.js +2 -7
- package/code-tag/index.js +1 -1
- package/color-menu/index.d.ts +0 -3
- package/color-menu/index.js +55 -101
- package/color-menu/types.d.ts +0 -4
- package/color-menu-option/index.d.ts +14 -0
- package/color-menu-option/index.js +52 -0
- package/color-menu-option/types.d.ts +9 -0
- package/color-menu-option/utils.d.ts +1 -0
- package/color-menu-option/utils.js +11 -0
- package/color-swatch/index.js +2 -5
- package/color-swatch/utils.d.ts +0 -1
- package/color-swatch/utils.js +2 -7
- package/date-picker/index.js +3 -40
- package/date-picker/types.d.ts +0 -3
- package/date-picker/utils.d.ts +0 -8
- package/date-picker/utils.js +0 -20
- package/dialog/index.js +2 -6
- package/dialog/types.d.ts +0 -2
- package/emoji/index.js +1 -1
- package/emoji-picker/index.d.ts +1 -0
- package/emoji-picker/index.js +36 -34
- package/field/index.js +39 -32
- package/file-drop/index.js +1 -1
- package/file-status/index.js +4 -25
- package/file-status/utils.d.ts +0 -3
- package/file-status/utils.js +1 -6
- package/flag/index.js +1 -1
- package/grid/index.js +1 -1
- package/help-tooltip/index.d.ts +0 -1
- package/help-tooltip/index.js +3 -13
- package/horizontal-stepper/index.js +1 -1
- package/horizontal-stepper-item/index.d.ts +2 -0
- package/horizontal-stepper-item/index.js +8 -12
- package/icon/index.js +1 -1
- package/icon-button/index.js +23 -27
- package/icon-button/utils.d.ts +0 -3
- package/icon-button/utils.js +1 -9
- package/inline-alert/index.js +20 -37
- package/inline-alert/utils.d.ts +0 -3
- package/inline-alert/utils.js +1 -6
- package/input/index.d.ts +0 -3
- package/input/index.js +22 -58
- package/input/types.d.ts +1 -5
- package/input/utils.d.ts +0 -3
- package/input/utils.js +1 -6
- package/link/index.js +35 -37
- package/list-item/index.js +1 -1
- package/package.json +11 -11
- package/pagination/index.js +8 -21
- package/pagination/types.d.ts +0 -3
- package/pop/index.js +39 -38
- package/pop/utils.d.ts +0 -3
- package/pop/utils.js +0 -5
- package/popover/index.js +42 -51
- package/popover/utils.d.ts +0 -3
- package/popover/utils.js +0 -5
- package/progress/index.js +20 -15
- package/radio/index.js +19 -6
- package/radio/types.d.ts +3 -3
- package/radio-option/index.js +35 -27
- package/rich-text/index.js +3 -10
- package/rich-text/utils.d.ts +0 -3
- package/rich-text/utils.js +1 -6
- package/segment/index.js +3 -7
- package/segment-collapse/index.js +2 -11
- package/segment-collapse/types.d.ts +0 -3
- package/segmented-control/index.js +0 -3
- package/segmented-control/types.d.ts +0 -3
- package/segmented-control-option/index.js +20 -19
- package/segmented-icon-control/index.js +1 -4
- package/segmented-icon-control/types.d.ts +0 -3
- package/segmented-icon-control-option/index.js +18 -14
- package/select-button/index.js +29 -31
- package/select-menu/index.js +18 -8
- package/select-menu-option/index.js +2 -5
- package/skeleton/index.js +1 -1
- package/skeleton-item/index.js +1 -1
- package/spinner/index.js +3 -10
- package/table/index.js +1 -1
- package/table-body/index.js +1 -1
- package/table-cell/index.js +1 -1
- package/table-head-cell/index.d.ts +1 -0
- package/table-head-cell/index.js +12 -3
- package/table-row/index.js +18 -2
- package/tabs/index.js +1 -4
- package/tabs/types.d.ts +0 -3
- package/tabs-icon-option/index.js +4 -2
- package/tabs-option/index.js +25 -20
- package/tag/index.js +17 -12
- package/tag/utils.d.ts +0 -1
- package/tag/utils.js +2 -7
- package/text/index.js +24 -21
- package/text/utils.d.ts +0 -3
- package/text/utils.js +1 -6
- package/textarea/index.js +10 -6
- package/textarea/types.d.ts +0 -3
- package/tile-control/index.js +23 -25
- package/tile-control/types.d.ts +0 -3
- package/tile-control-option/index.js +1 -1
- package/time-picker/index.js +2 -11
- package/time-picker/types.d.ts +0 -3
- package/time-picker/utils.d.ts +1 -1
- package/time-picker/utils.js +17 -5
- package/title/index.js +28 -30
- package/title/utils.d.ts +0 -7
- package/title/utils.js +1 -29
- package/toast/index.js +22 -39
- package/toast/utils.d.ts +0 -3
- package/toast/utils.js +1 -6
- package/toggle/index.js +33 -30
- package/toggle/types.d.ts +0 -3
- package/tooltip/index.js +3 -15
- package/tooltip/types.d.ts +0 -12
- package/tooltip/utils.d.ts +0 -5
- package/tooltip/utils.js +0 -10
- package/utils/dom.js +0 -5
- package/utils/element.js +2 -2
- package/utils/size.d.ts +0 -5
- package/utils/size.js +1 -17
- package/vertical-stepper/index.js +1 -1
- package/vertical-stepper-item/index.d.ts +2 -0
- package/vertical-stepper-item/index.js +8 -12
- package/logo/create-logo-class.d.ts +0 -1
- package/logo/create-logo-class.js +0 -52
- package/logo/engage-icon/index.d.ts +0 -11
- package/logo/engage-icon/index.js +0 -4
- package/logo/engage-icon-wordmark/index.d.ts +0 -11
- package/logo/engage-icon-wordmark/index.js +0 -4
- package/logo/sinch-icon/index.d.ts +0 -11
- package/logo/sinch-icon/index.js +0 -4
- package/logo/sinch-icon-wordmark/index.d.ts +0 -11
- package/logo/sinch-icon-wordmark/index.js +0 -4
- package/logo/types.d.ts +0 -11
- package/theme/accordion-item.css +0 -4
- package/theme/alert.css +0 -6
- package/theme/avatar.css +0 -25
- package/theme/badge.css +0 -15
- package/theme/button.css +0 -146
- package/theme/chat.css +0 -9
- package/theme/chip.css +0 -68
- package/theme/color-menu.css +0 -4
- package/theme/color-swatch.css +0 -71
- package/theme/colors.d.ts +0 -4
- package/theme/colors.js +0 -4
- package/theme/contextual.css +0 -40
- package/theme/date-picker.css +0 -7
- package/theme/dialog.css +0 -4
- package/theme/elevation.css +0 -7
- package/theme/emoji-picker.css +0 -13
- package/theme/emoji.css +0 -5
- package/theme/file-status.css +0 -7
- package/theme/flag.css +0 -4
- package/theme/fonts.css +0 -86
- package/theme/fonts.json +0 -89
- package/theme/help-tooltip.css +0 -5
- package/theme/horizontal-stepper.css +0 -5
- package/theme/icon-button.css +0 -68
- package/theme/icon.css +0 -7
- package/theme/index.css +0 -4
- package/theme/index.d.ts +0 -39
- package/theme/index.js +0 -39
- package/theme/inline-alert.css +0 -7
- package/theme/input.css +0 -10
- package/theme/link.css +0 -5
- package/theme/pagination.css +0 -5
- package/theme/palette.css +0 -90
- package/theme/segment.css +0 -4
- package/theme/select-button.css +0 -10
- package/theme/select-menu.css +0 -6
- package/theme/shapes.css +0 -8
- package/theme/size.css +0 -9
- package/theme/spinner.css +0 -7
- package/theme/tag.css +0 -67
- package/theme/time-picker.css +0 -4
- package/theme/toast.css +0 -7
- package/theme/typography.css +0 -16
- package/theme/vertical-stepper.css +0 -5
- /package/{logo → color-menu-option}/types.js +0 -0
package/accordion/index.js
CHANGED
|
@@ -24,9 +24,6 @@ defineCustomElement('sinch-accordion', class extends NectaryElement {
|
|
|
24
24
|
this.#$slot.removeEventListener('option-change', this.#onOptionChange);
|
|
25
25
|
this.removeEventListener('-change', this.#onChangeReactHandler);
|
|
26
26
|
}
|
|
27
|
-
get nodeName() {
|
|
28
|
-
return 'select';
|
|
29
|
-
}
|
|
30
27
|
set value(value) {
|
|
31
28
|
updateAttribute(this, 'value', value);
|
|
32
29
|
}
|
package/accordion/types.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { TSinchElementReact } from '../types';
|
|
2
|
-
import type { SyntheticEvent } from 'react';
|
|
3
2
|
export type TSinchAccordionElement = HTMLElement & {
|
|
4
3
|
/** Value */
|
|
5
4
|
value: string;
|
|
@@ -17,8 +16,6 @@ export type TSinchAccordionReact = TSinchElementReact<TSinchAccordionElement> &
|
|
|
17
16
|
value: string;
|
|
18
17
|
multiple?: boolean;
|
|
19
18
|
/** Allows to expand multiple items simultanously */
|
|
20
|
-
/** @deprecated */
|
|
21
|
-
onChange?: (e: SyntheticEvent<TSinchAccordionElement, CustomEvent<string>>) => void;
|
|
22
19
|
/** Change value handler */
|
|
23
20
|
'on-change'?: (e: CustomEvent<string>) => void;
|
|
24
21
|
};
|
package/accordion-item/index.js
CHANGED
|
@@ -1,26 +1,25 @@
|
|
|
1
1
|
import '../icon';
|
|
2
|
-
import
|
|
3
|
-
|
|
2
|
+
import '../title';
|
|
3
|
+
import '../text';
|
|
4
|
+
import { defineCustomElement, getAttribute, getBooleanAttribute, getLiteralAttribute, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute, updateLiteralAttribute } from '../utils';
|
|
5
|
+
const templateHTML = '<style>:host{display:block;outline:0;min-height:48px}#wrapper{display:flex;flex-direction:column;position:relative;width:100%;height:100%;box-sizing:border-box;overflow:hidden;border-bottom:1px solid var(--sinch-comp-accordion-color-default-border-initial)}#button{all:initial;cursor:pointer;display:flex;align-items:center;gap:8px;box-sizing:border-box;width:100%;height:48px;padding:12px 8px;--sinch-global-color-icon:var(--sinch-comp-accordion-color-default-icon-initial);--sinch-global-size-icon:var(--sinch-comp-accordion-size-icon)}#button>*{pointer-events:none}#button:disabled{cursor:initial;--sinch-global-color-icon:var(--sinch-comp-accordion-color-disabled-icon-initial)}#button::before{width:8px;height:8px;border-radius:50%;margin-left:2px;margin-right:8px}:host([status=success]) #button::before{content:"";background-color:var(--sinch-comp-accordion-color-default-status-success)}:host([status=warn]) #button::before{content:"";background-color:var(--sinch-comp-accordion-color-default-status-warning)}:host([status=error]) #button::before{content:"";background-color:var(--sinch-comp-accordion-color-default-status-error)}:host([status=info]) #button::before{content:"";background-color:var(--sinch-comp-accordion-color-default-status-info)}#title{flex:1;min-width:0;--sinch-comp-title-font:var(--sinch-comp-accordion-font-title);--sinch-global-color-text:var(--sinch-comp-accordion-color-default-title-initial)}#button:disabled>#title{--sinch-global-color-text:var(--sinch-comp-accordion-color-disabled-title-initial)}#content{display:none;overflow-y:auto;flex-shrink:1;min-height:0;padding:0 8px 18px}#dropdown-icon{transform:rotate(0)}#button[aria-expanded=true]>#dropdown-icon{transform:rotate(180deg)}#button[aria-expanded=true]+#content{display:block}#optional{--sinch-comp-text-font:var(--sinch-comp-accordion-font-optional-text);--sinch-global-color-text:var(--sinch-comp-accordion-color-default-optional-text-initial)}#button:disabled>#optional{--sinch-global-color-text:var(--sinch-comp-accordion-color-disabled-optional-text-initial)}</style><div id="wrapper"><button id="button" aria-controls="content" aria-expanded="false"><slot name="icon"></slot><sinch-title id="title" level="3" type="m" ellipsis></sinch-title><sinch-text id="optional" type="m"></sinch-text><sinch-icon id="dropdown-icon" name="keyboard_arrow_down"></sinch-icon></button><div id="content" role="region" aria-labelledby="button"><slot name="content"></slot></div></div>';
|
|
4
6
|
import { statusValues } from './utils';
|
|
5
7
|
const template = document.createElement('template');
|
|
6
8
|
template.innerHTML = templateHTML;
|
|
7
9
|
defineCustomElement('sinch-accordion-item', class extends NectaryElement {
|
|
8
10
|
#$button;
|
|
9
|
-
#$
|
|
10
|
-
#$buttonContent;
|
|
11
|
+
#$title;
|
|
11
12
|
#$optionalText;
|
|
12
13
|
constructor() {
|
|
13
14
|
super();
|
|
14
15
|
const shadowRoot = this.attachShadow();
|
|
15
16
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
16
17
|
this.#$button = shadowRoot.querySelector('#button');
|
|
17
|
-
this.#$
|
|
18
|
-
this.#$buttonContent = shadowRoot.querySelector('#title');
|
|
18
|
+
this.#$title = shadowRoot.querySelector('#title');
|
|
19
19
|
this.#$optionalText = shadowRoot.querySelector('#optional');
|
|
20
20
|
}
|
|
21
21
|
connectedCallback() {
|
|
22
22
|
this.#$button.addEventListener('click', this.#onButtonClick);
|
|
23
|
-
updateAttribute(this.#$icon, 'name', getCssVar(this, '--sinch-accordion-item-icon-dropdown'));
|
|
24
23
|
}
|
|
25
24
|
disconnectedCallback() {
|
|
26
25
|
this.#$button.removeEventListener('click', this.#onButtonClick);
|
|
@@ -28,6 +27,33 @@ defineCustomElement('sinch-accordion-item', class extends NectaryElement {
|
|
|
28
27
|
static get observedAttributes() {
|
|
29
28
|
return ['label', 'disabled', 'data-checked', 'optionaltext'];
|
|
30
29
|
}
|
|
30
|
+
attributeChangedCallback(name, oldVal, newVal) {
|
|
31
|
+
if (oldVal === newVal) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
switch (name) {
|
|
35
|
+
case 'label':
|
|
36
|
+
{
|
|
37
|
+
updateAttribute(this.#$title, 'text', newVal);
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
case 'disabled':
|
|
41
|
+
{
|
|
42
|
+
this.#$button.disabled = isAttrTrue(newVal);
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
case 'data-checked':
|
|
46
|
+
{
|
|
47
|
+
updateExplicitBooleanAttribute(this.#$button, 'aria-expanded', isAttrTrue(newVal));
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
case 'optionaltext':
|
|
51
|
+
{
|
|
52
|
+
this.#$optionalText.textContent = newVal;
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
31
57
|
set value(value) {
|
|
32
58
|
updateAttribute(this, 'value', value);
|
|
33
59
|
}
|
|
@@ -58,33 +84,6 @@ defineCustomElement('sinch-accordion-item', class extends NectaryElement {
|
|
|
58
84
|
get optionalText() {
|
|
59
85
|
return getAttribute(this, 'optionaltext');
|
|
60
86
|
}
|
|
61
|
-
attributeChangedCallback(name, oldVal, newVal) {
|
|
62
|
-
if (oldVal === newVal) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
switch (name) {
|
|
66
|
-
case 'label':
|
|
67
|
-
{
|
|
68
|
-
this.#$buttonContent.textContent = newVal;
|
|
69
|
-
break;
|
|
70
|
-
}
|
|
71
|
-
case 'disabled':
|
|
72
|
-
{
|
|
73
|
-
this.#$button.disabled = isAttrTrue(newVal);
|
|
74
|
-
break;
|
|
75
|
-
}
|
|
76
|
-
case 'data-checked':
|
|
77
|
-
{
|
|
78
|
-
updateExplicitBooleanAttribute(this.#$button, 'aria-expanded', isAttrTrue(newVal));
|
|
79
|
-
break;
|
|
80
|
-
}
|
|
81
|
-
case 'optionaltext':
|
|
82
|
-
{
|
|
83
|
-
this.#$optionalText.textContent = newVal;
|
|
84
|
-
break;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
87
|
#onButtonClick = e => {
|
|
89
88
|
e.stopPropagation();
|
|
90
89
|
this.dispatchEvent(new CustomEvent('option-change', {
|
package/action-menu/index.js
CHANGED
|
@@ -10,7 +10,9 @@ defineCustomElement('sinch-action-menu', class extends NectaryElement {
|
|
|
10
10
|
#controller = null;
|
|
11
11
|
constructor() {
|
|
12
12
|
super();
|
|
13
|
-
const shadowRoot = this.attachShadow(
|
|
13
|
+
const shadowRoot = this.attachShadow({
|
|
14
|
+
delegatesFocus: false
|
|
15
|
+
});
|
|
14
16
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
15
17
|
this.#$optionSlot = shadowRoot.querySelector('slot');
|
|
16
18
|
this.#$listbox = shadowRoot.querySelector('#listbox');
|
|
@@ -65,6 +67,7 @@ defineCustomElement('sinch-action-menu', class extends NectaryElement {
|
|
|
65
67
|
this.#selectOption(null);
|
|
66
68
|
};
|
|
67
69
|
#onListboxClick = e => {
|
|
70
|
+
this.focus();
|
|
68
71
|
if (isSinchActionMenuOption(e.target)) {
|
|
69
72
|
this.#selectOption(e.target);
|
|
70
73
|
}
|
|
@@ -87,6 +90,7 @@ defineCustomElement('sinch-action-menu', class extends NectaryElement {
|
|
|
87
90
|
#handleKeydown(e) {
|
|
88
91
|
switch (e.code) {
|
|
89
92
|
case 'Enter':
|
|
93
|
+
case 'Space':
|
|
90
94
|
{
|
|
91
95
|
const $opt = this.#findSelectedOption();
|
|
92
96
|
if ($opt !== null) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import '../text';
|
|
2
2
|
import { defineCustomElement, getAttribute, getBooleanAttribute, getReactEventHandler, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
|
|
3
|
-
const templateHTML = '<style>:host{display:block}#wrapper{all:initial;display:flex;position:relative;box-sizing:border-box;height:40px;width:100%;padding:8px 16px;align-items:center;gap:10px;user-select:none;cursor:pointer;color:var(--sinch-color-text-default);--sinch-color-icon:var(--sinch-color-
|
|
3
|
+
const templateHTML = '<style>:host{display:block}#wrapper{all:initial;display:flex;position:relative;box-sizing:border-box;height:40px;width:100%;padding:8px 16px;align-items:center;gap:10px;user-select:none;cursor:pointer;background-color:var(--sinch-comp-action-menu-color-default-background-initial);--sinch-global-color-text:var(--sinch-comp-action-menu-color-default-text-initial);--sinch-global-color-icon:var(--sinch-comp-action-menu-color-default-icon-initial);--sinch-global-size-icon:var(--sinch-comp-action-menu-size-icon)}:host([data-selected])>#wrapper{background-color:var(--sinch-comp-action-menu-color-default-background-selected)}:host(:hover)>#wrapper{background-color:var(--sinch-comp-action-menu-color-default-background-hover)}:host([disabled])>#wrapper{cursor:initial;pointer-events:none;background-color:var(--sinch-comp-action-menu-color-disabled-background-initial);--sinch-global-color-text:var(--sinch-comp-action-menu-color-disabled-text-initial);--sinch-global-color-icon:var(--sinch-comp-action-menu-color-disabled-icon-initial)}#content{flex:1;min-width:0;--sinch-comp-text-font:var(--sinch-comp-action-menu-font-option)}::slotted(*){margin-left:-6px}</style><div id="wrapper"><slot name="icon"></slot><sinch-text id="content" type="m" ellipsis></sinch-text></div>';
|
|
4
4
|
const template = document.createElement('template');
|
|
5
5
|
template.innerHTML = templateHTML;
|
|
6
6
|
defineCustomElement('sinch-action-menu-option', class ActionMenuOption extends NectaryElement {
|
|
@@ -45,7 +45,7 @@ defineCustomElement('sinch-action-menu-option', class ActionMenuOption extends N
|
|
|
45
45
|
}
|
|
46
46
|
case 'disabled':
|
|
47
47
|
{
|
|
48
|
-
updateBooleanAttribute(this,
|
|
48
|
+
updateBooleanAttribute(this, name, isAttrTrue(newVal));
|
|
49
49
|
break;
|
|
50
50
|
}
|
|
51
51
|
case 'data-selected':
|
package/alert/index.js
CHANGED
|
@@ -1,25 +1,22 @@
|
|
|
1
1
|
import '../icon';
|
|
2
2
|
import '../rich-text';
|
|
3
3
|
import '../text';
|
|
4
|
-
import { defineCustomElement, getAttribute, getLiteralAttribute, updateAttribute, updateLiteralAttribute, NectaryElement
|
|
5
|
-
const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:row;gap:8px;align-items:center;padding:8px 16px;box-sizing:border-box;width:100%;min-height:48px}#
|
|
6
|
-
import {
|
|
4
|
+
import { defineCustomElement, getAttribute, getLiteralAttribute, updateAttribute, updateLiteralAttribute, NectaryElement } from '../utils';
|
|
5
|
+
const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:row;gap:8px;align-items:center;padding:8px 16px;box-sizing:border-box;width:100%;min-height:48px}:host([type=warn]) #wrapper{background-color:var(--sinch-comp-alert-color-warning-default-background)}:host([type=error]) #wrapper{background-color:var(--sinch-comp-alert-color-error-default-background)}:host([type=info]) #wrapper{background-color:var(--sinch-comp-alert-color-info-default-background)}#icon-error,#icon-info,#icon-warn{display:none}#icon-warn{--sinch-global-color-icon:var(--sinch-comp-alert-color-warning-default-icon)}#icon-error{--sinch-global-color-icon:var(--sinch-comp-alert-color-error-default-icon)}#icon-info{--sinch-global-color-icon:var(--sinch-comp-alert-color-info-default-icon)}:host([type=error]) #icon-error,:host([type=info]) #icon-info,:host([type=warn]) #icon-warn{display:block}#text{display:flex;flex-direction:column;gap:8px;flex:1;min-width:0;--sinch-comp-rich-text-font:var(--sinch-comp-alert-font-body)}:host([type=warn]) #text{--sinch-global-color-text:var(--sinch-comp-alert-color-warning-default-text)}:host([type=error]) #text{--sinch-global-color-text:var(--sinch-comp-alert-color-error-default-text)}:host([type=info]) #text{--sinch-global-color-text:var(--sinch-comp-alert-color-info-default-text)}</style><div id="wrapper"><sinch-icon id="icon-info" name="info"></sinch-icon><sinch-icon id="icon-warn" name="report_problem"></sinch-icon><sinch-icon id="icon-error" name="report"></sinch-icon><sinch-rich-text id="text"></sinch-rich-text><slot name="action"></slot><slot name="close"></slot></div>';
|
|
6
|
+
import { typeValues } from './utils';
|
|
7
7
|
const template = document.createElement('template');
|
|
8
8
|
template.innerHTML = templateHTML;
|
|
9
9
|
defineCustomElement('sinch-alert', class extends NectaryElement {
|
|
10
10
|
#$text;
|
|
11
|
-
#$icon;
|
|
12
11
|
constructor() {
|
|
13
12
|
super();
|
|
14
13
|
const shadowRoot = this.attachShadow();
|
|
15
14
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
16
15
|
this.#$text = shadowRoot.querySelector('#text');
|
|
17
|
-
this.#$icon = shadowRoot.querySelector('#icon');
|
|
18
16
|
}
|
|
19
17
|
connectedCallback() {
|
|
20
18
|
super.connectedCallback();
|
|
21
19
|
this.setAttribute('role', 'alert');
|
|
22
|
-
this.#updateIcon();
|
|
23
20
|
}
|
|
24
21
|
disconnectedCallback() {
|
|
25
22
|
super.disconnectedCallback();
|
|
@@ -37,18 +34,10 @@ defineCustomElement('sinch-alert', class extends NectaryElement {
|
|
|
37
34
|
updateAttribute(this, 'text', value);
|
|
38
35
|
}
|
|
39
36
|
static get observedAttributes() {
|
|
40
|
-
return ['text'
|
|
37
|
+
return ['text'];
|
|
41
38
|
}
|
|
42
39
|
attributeChangedCallback(name, _, newVal) {
|
|
43
40
|
switch (name) {
|
|
44
|
-
case 'type':
|
|
45
|
-
{
|
|
46
|
-
if ('production' !== 'production') {
|
|
47
|
-
assertType(newVal);
|
|
48
|
-
}
|
|
49
|
-
this.#updateIcon();
|
|
50
|
-
break;
|
|
51
|
-
}
|
|
52
41
|
case 'text':
|
|
53
42
|
{
|
|
54
43
|
updateAttribute(this.#$text, 'text', newVal);
|
|
@@ -56,10 +45,4 @@ defineCustomElement('sinch-alert', class extends NectaryElement {
|
|
|
56
45
|
}
|
|
57
46
|
}
|
|
58
47
|
}
|
|
59
|
-
#updateIcon() {
|
|
60
|
-
if (!this.isConnected) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
updateAttribute(this.#$icon, 'name', getCssVar(this, `--sinch-alert-icon-${this.type}`));
|
|
64
|
-
}
|
|
65
48
|
});
|
package/alert/utils.d.ts
CHANGED
package/alert/utils.js
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
export const typeValues = ['info', 'warn', 'error'];
|
|
2
|
-
export const assertType = value => {
|
|
3
|
-
if (value === null || !typeValues.includes(value)) {
|
|
4
|
-
throw new Error(`sinch-alert: invalid type attribute: ${value}`);
|
|
5
|
-
}
|
|
6
|
-
};
|
|
1
|
+
export const typeValues = ['info', 'warn', 'error'];
|
package/avatar/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineCustomElement, getAttribute, getLiteralAttribute, NectaryElement, updateAttribute, updateLiteralAttribute } from '../utils';
|
|
2
|
-
import {
|
|
3
|
-
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{position:relative;width:
|
|
4
|
-
import {
|
|
2
|
+
import { DEFAULT_SIZE, sizeValues } from '../utils/size';
|
|
3
|
+
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{position:relative;width:var(--sinch-local-size);height:var(--sinch-local-size);background-color:var(--sinch-comp-avatar-border-color-default-initial);border-radius:var(--sinch-comp-avatar-shape-radius);--sinch-local-size:var(--sinch-comp-avatar-size-m)}:host([size="l"]) #wrapper{--sinch-local-size:var(--sinch-comp-avatar-size-l)}:host([size="s"]) #wrapper{--sinch-local-size:var(--sinch-comp-avatar-size-s)}#text{display:block;width:100%;height:100%;font:var(--sinch-comp-avatar-container-font-size-m-text);line-height:calc(var(--sinch-local-size) - 2px);text-transform:uppercase;text-align:center}:host([size="l"]) #text{font:var(--sinch-comp-avatar-container-font-size-l-text);line-height:calc(var(--sinch-local-size) - 2px)}:host([size="s"]) #text{font:var(--sinch-comp-avatar-container-font-size-s-text);line-height:calc(var(--sinch-local-size) - 2px)}#circle{position:relative;width:calc(100% - 2px);height:calc(100% - 2px);left:1px;top:1px;border-radius:50%;-webkit-mask:linear-gradient(#fff,#000);mask:linear-gradient(#fff,#000);background-color:var(--sinch-comp-avatar-container-color-default-background);color:var(--sinch-comp-avatar-container-color-default-foreground)}#image{display:none;position:absolute;left:0;top:0;width:100%;height:100%;object-fit:contain}:host([src]:not([src=""])) #image{display:block}#status-wrapper{position:absolute;left:calc(85% - 5px);top:calc(85% - 5px);width:10px;height:10px;padding:1px;box-sizing:border-box;border-radius:50%;background-color:var(--sinch-comp-avatar-border-color-default-initial);display:none;pointer-events:none}#status{width:8px;height:8px;border-radius:50%}:host([status=away]) #status-wrapper,:host([status=busy]) #status-wrapper,:host([status=offline]) #status-wrapper,:host([status=online]) #status-wrapper{display:block}:host([status=online]) #status{background-color:var(--sinch-comp-avatar-status-color-online-default-background)}:host([status=away]) #status{background-color:var(--sinch-comp-avatar-status-color-away-default-background)}:host([status=busy]) #status{background-color:var(--sinch-comp-avatar-status-color-busy-default-background)}:host([status=offline]) #status{background-color:var(--sinch-comp-avatar-status-color-offline-default-background)}</style><div id="wrapper"><div id="circle"><span id="text"></span><img id="image" alt=""/></div><div id="status-wrapper"><div id="status"></div></div></div>';
|
|
4
|
+
import { getAvatarColorBg, getAvatarColorFg, statusValues } from './utils';
|
|
5
5
|
const template = document.createElement('template');
|
|
6
6
|
template.innerHTML = templateHTML;
|
|
7
7
|
defineCustomElement('sinch-avatar', class extends NectaryElement {
|
|
@@ -51,7 +51,7 @@ defineCustomElement('sinch-avatar', class extends NectaryElement {
|
|
|
51
51
|
updateLiteralAttribute(this, statusValues, 'status', value);
|
|
52
52
|
}
|
|
53
53
|
static get observedAttributes() {
|
|
54
|
-
return ['alt', 'src', '
|
|
54
|
+
return ['alt', 'src', 'color'];
|
|
55
55
|
}
|
|
56
56
|
attributeChangedCallback(name, _, newVal) {
|
|
57
57
|
switch (name) {
|
|
@@ -66,23 +66,10 @@ defineCustomElement('sinch-avatar', class extends NectaryElement {
|
|
|
66
66
|
this.#$image.src = newVal ?? '';
|
|
67
67
|
break;
|
|
68
68
|
}
|
|
69
|
-
case 'size':
|
|
70
|
-
{
|
|
71
|
-
if ('production' !== 'production') {
|
|
72
|
-
assertSize(newVal, 'sinch-avatar');
|
|
73
|
-
}
|
|
74
|
-
break;
|
|
75
|
-
}
|
|
76
|
-
case 'status':
|
|
77
|
-
{
|
|
78
|
-
if ('production' !== 'production') {
|
|
79
|
-
assertStatus(newVal);
|
|
80
|
-
}
|
|
81
|
-
break;
|
|
82
|
-
}
|
|
83
69
|
case 'color':
|
|
84
70
|
{
|
|
85
71
|
this.#updateColor();
|
|
72
|
+
break;
|
|
86
73
|
}
|
|
87
74
|
}
|
|
88
75
|
}
|
|
@@ -92,9 +79,6 @@ defineCustomElement('sinch-avatar', class extends NectaryElement {
|
|
|
92
79
|
}
|
|
93
80
|
const colorName = this.color;
|
|
94
81
|
if (colorName !== null && colorName.length > 0) {
|
|
95
|
-
if ('production' !== 'production') {
|
|
96
|
-
assertAvatarColor(this, colorName);
|
|
97
|
-
}
|
|
98
82
|
const bg = getAvatarColorBg(colorName);
|
|
99
83
|
const fg = getAvatarColorFg(colorName);
|
|
100
84
|
this.#$circle.style.setProperty('background-color', bg);
|
package/avatar/utils.d.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import type { TSinchAvatarStatus } from './types';
|
|
2
2
|
export declare const statusValues: readonly TSinchAvatarStatus[];
|
|
3
|
-
type TAssertStatus = (value: string | null) => asserts value is TSinchAvatarStatus;
|
|
4
|
-
export declare const assertStatus: TAssertStatus;
|
|
5
3
|
export declare const getAvatarColorBg: (id: string) => string;
|
|
6
4
|
export declare const getAvatarColorFg: (id: string) => string;
|
|
7
|
-
export declare const assertAvatarColor: (root: Element, id: string | null) => void;
|
|
8
|
-
export {};
|
package/avatar/utils.js
CHANGED
|
@@ -1,20 +1,7 @@
|
|
|
1
1
|
export const statusValues = ['online', 'busy', 'away', 'offline'];
|
|
2
|
-
export const assertStatus = value => {
|
|
3
|
-
if (value === null || value.length === 0) {
|
|
4
|
-
return;
|
|
5
|
-
}
|
|
6
|
-
if (!statusValues.includes(value)) {
|
|
7
|
-
throw new Error(`sinch-avatar: invalid status attribute: ${value}`);
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
2
|
export const getAvatarColorBg = id => {
|
|
11
|
-
return `var(--sinch-avatar-color-${id}-
|
|
3
|
+
return `var(--sinch-comp-avatar-container-color-${id}-background)`;
|
|
12
4
|
};
|
|
13
5
|
export const getAvatarColorFg = id => {
|
|
14
|
-
return `var(--sinch-avatar-color-${id}-
|
|
15
|
-
};
|
|
16
|
-
export const assertAvatarColor = (root, id) => {
|
|
17
|
-
if (id === null || window.getComputedStyle(root).getPropertyValue(`--sinch-avatar-color-${id}-bg`).length === 0) {
|
|
18
|
-
throw new Error(`Invalid sinch-avatar color name: ${id}`);
|
|
19
|
-
}
|
|
6
|
+
return `var(--sinch-comp-avatar-container-color-${id}-foreground)`;
|
|
20
7
|
};
|
package/badge/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { defineCustomElement, getAttribute, getBooleanAttribute, getLiteralAttribute, getRect, NectaryElement, setClass, updateAttribute, updateBooleanAttribute, updateLiteralAttribute } from '../utils';
|
|
2
|
-
import {
|
|
3
|
-
const templateHTML = '<style>:host{display:inline-flex;flex-direction:column;position:relative}#badge-wrapper{position:absolute;left:0;top:0;width:fit-content;border-radius:
|
|
4
|
-
import {
|
|
1
|
+
import { defineCustomElement, getAttribute, getBooleanAttribute, getLiteralAttribute, getRect, isAttrTrue, NectaryElement, setClass, updateAttribute, updateBooleanAttribute, updateLiteralAttribute } from '../utils';
|
|
2
|
+
import { DEFAULT_SIZE, sizeValues } from '../utils/size';
|
|
3
|
+
const templateHTML = '<style>:host{display:inline-flex;flex-direction:column;position:relative}#badge-wrapper{position:absolute;left:0;top:0;width:fit-content;border-radius:var(--sinch-comp-badge-shape-radius);padding:1px;pointer-events:none;background-color:var(--sinch-comp-badge-color-border)}#badge{box-sizing:border-box;color:var(--sinch-comp-badge-color-text);background-color:var(--sinch-comp-badge-color-background);width:20px;height:20px;border-radius:var(--sinch-comp-badge-shape-radius)}#badge.long{width:fit-content;padding:0 5px}#text{display:block;width:100%;height:100%;text-align:center;font:var(--sinch-comp-badge-font-size-l);line-height:20px;text-rendering:optimizelegibility}:host([size="m"]) #badge-wrapper{left:calc(100% - 8px);top:-8px}:host([size="m"]) #badge{width:14px;height:14px}:host([size="m"]) #badge.long{width:fit-content;padding:0 3px}:host([size="m"]) #text{font:var(--sinch-comp-badge-font-size-m);line-height:14px}:host([size="s"]) #badge{width:8px;height:8px;padding:0}:host([size="s"]) #text{display:none}:host([hidden]) #badge-wrapper{display:none}</style><slot id="slot"></slot><div id="badge-wrapper"><div id="badge"><span id="text"></span></div></div>';
|
|
4
|
+
import { modeValues } from './utils';
|
|
5
5
|
const template = document.createElement('template');
|
|
6
6
|
template.innerHTML = templateHTML;
|
|
7
7
|
defineCustomElement('sinch-badge', class extends NectaryElement {
|
|
@@ -20,13 +20,44 @@ defineCustomElement('sinch-badge', class extends NectaryElement {
|
|
|
20
20
|
}
|
|
21
21
|
connectedCallback() {
|
|
22
22
|
super.connectedCallback();
|
|
23
|
-
this.#updateColor();
|
|
24
23
|
this.#observer.observe(this);
|
|
25
24
|
}
|
|
26
25
|
disconnectedCallback() {
|
|
27
26
|
super.disconnectedCallback();
|
|
28
27
|
this.#observer.unobserve(this);
|
|
29
28
|
}
|
|
29
|
+
static get observedAttributes() {
|
|
30
|
+
return ['text', 'size', 'mode', 'hidden'];
|
|
31
|
+
}
|
|
32
|
+
attributeChangedCallback(name, oldVal, newVal) {
|
|
33
|
+
if (oldVal === newVal) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
switch (name) {
|
|
37
|
+
case 'text':
|
|
38
|
+
{
|
|
39
|
+
this.#$text.textContent = newVal;
|
|
40
|
+
setClass(this.#$badge, 'long', newVal !== null && newVal.length > 1);
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
case 'size':
|
|
44
|
+
{
|
|
45
|
+
this.#updatePosition();
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
case 'mode':
|
|
49
|
+
{
|
|
50
|
+
this.#updatePosition();
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
case 'hidden':
|
|
54
|
+
{
|
|
55
|
+
this.#updatePosition();
|
|
56
|
+
updateBooleanAttribute(this, name, isAttrTrue(newVal));
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
30
61
|
get text() {
|
|
31
62
|
return getAttribute(this, 'text', '');
|
|
32
63
|
}
|
|
@@ -45,12 +76,6 @@ defineCustomElement('sinch-badge', class extends NectaryElement {
|
|
|
45
76
|
set mode(value) {
|
|
46
77
|
updateLiteralAttribute(this, modeValues, 'mode', value);
|
|
47
78
|
}
|
|
48
|
-
get color() {
|
|
49
|
-
return getAttribute(this, 'color');
|
|
50
|
-
}
|
|
51
|
-
set color(value) {
|
|
52
|
-
updateAttribute(this, 'color', value);
|
|
53
|
-
}
|
|
54
79
|
get hidden() {
|
|
55
80
|
return getBooleanAttribute(this, 'hidden');
|
|
56
81
|
}
|
|
@@ -69,63 +94,6 @@ defineCustomElement('sinch-badge', class extends NectaryElement {
|
|
|
69
94
|
}
|
|
70
95
|
return getRect(this.#$badgeWrapper);
|
|
71
96
|
}
|
|
72
|
-
static get observedAttributes() {
|
|
73
|
-
return ['text', 'size', 'mode', 'color', 'hidden'];
|
|
74
|
-
}
|
|
75
|
-
attributeChangedCallback(name, _, newVal) {
|
|
76
|
-
switch (name) {
|
|
77
|
-
case 'text':
|
|
78
|
-
{
|
|
79
|
-
this.#$text.textContent = newVal;
|
|
80
|
-
setClass(this.#$badge, 'long', newVal !== null && newVal.length > 1);
|
|
81
|
-
break;
|
|
82
|
-
}
|
|
83
|
-
case 'size':
|
|
84
|
-
{
|
|
85
|
-
if ('production' !== 'production') {
|
|
86
|
-
assertSize(newVal, 'sinch-badge');
|
|
87
|
-
}
|
|
88
|
-
this.#updatePosition();
|
|
89
|
-
break;
|
|
90
|
-
}
|
|
91
|
-
case 'mode':
|
|
92
|
-
{
|
|
93
|
-
if ('production' !== 'production') {
|
|
94
|
-
assertMode(newVal);
|
|
95
|
-
}
|
|
96
|
-
this.#updatePosition();
|
|
97
|
-
break;
|
|
98
|
-
}
|
|
99
|
-
case 'color':
|
|
100
|
-
{
|
|
101
|
-
this.#updateColor();
|
|
102
|
-
break;
|
|
103
|
-
}
|
|
104
|
-
case 'hidden':
|
|
105
|
-
{
|
|
106
|
-
this.#updatePosition();
|
|
107
|
-
break;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
#updateColor() {
|
|
112
|
-
if (!this.isConnected) {
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
const colorName = this.color;
|
|
116
|
-
if (colorName !== null && colorName.length > 0) {
|
|
117
|
-
if ('production' !== 'production') {
|
|
118
|
-
assertBadgeColor(this, colorName);
|
|
119
|
-
}
|
|
120
|
-
const bg = getBadgeColorBg(colorName);
|
|
121
|
-
const fg = getBadgeColorFg(colorName);
|
|
122
|
-
this.#$badge.style.setProperty('background-color', bg);
|
|
123
|
-
this.#$badge.style.setProperty('color', fg);
|
|
124
|
-
} else {
|
|
125
|
-
this.#$badge.style.removeProperty('background-color');
|
|
126
|
-
this.#$badge.style.removeProperty('color');
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
97
|
#updatePosition() {
|
|
130
98
|
if (this.hidden) {
|
|
131
99
|
return;
|
package/badge/types.d.ts
CHANGED
|
@@ -8,8 +8,6 @@ export type TSinchBadgeElement = HTMLElement & {
|
|
|
8
8
|
size: TSinchSize;
|
|
9
9
|
/** Mode, `square` by default */
|
|
10
10
|
mode: TSinchBadgeMode;
|
|
11
|
-
/** Color */
|
|
12
|
-
color: string | null;
|
|
13
11
|
/** Hidden */
|
|
14
12
|
hidden: boolean;
|
|
15
13
|
readonly badgeRect: TRect;
|
|
@@ -31,8 +29,6 @@ export type TSinchBadgeReact = TSinchElementReact<TSinchBadgeElement> & {
|
|
|
31
29
|
size?: TSinchSize;
|
|
32
30
|
/** Mode, `square` by default */
|
|
33
31
|
mode?: TSinchBadgeMode;
|
|
34
|
-
/** Color */
|
|
35
|
-
color?: string;
|
|
36
32
|
/** Hidden */
|
|
37
33
|
hidden?: boolean;
|
|
38
34
|
};
|
package/badge/utils.d.ts
CHANGED
|
@@ -1,8 +1,2 @@
|
|
|
1
1
|
import type { TSinchBadgeMode } from './types';
|
|
2
2
|
export declare const modeValues: readonly TSinchBadgeMode[];
|
|
3
|
-
type TAssertMode = (value: string | null) => asserts value is TSinchBadgeMode;
|
|
4
|
-
export declare const assertMode: TAssertMode;
|
|
5
|
-
export declare const getBadgeColorBg: (id: string) => string;
|
|
6
|
-
export declare const getBadgeColorFg: (id: string) => string;
|
|
7
|
-
export declare const assertBadgeColor: (root: Element, id: string | null) => void;
|
|
8
|
-
export {};
|
package/badge/utils.js
CHANGED
|
@@ -1,17 +1 @@
|
|
|
1
|
-
export const modeValues = ['square', 'circle'];
|
|
2
|
-
export const assertMode = value => {
|
|
3
|
-
if (value === null || !modeValues.includes(value)) {
|
|
4
|
-
throw new Error(`sinch-badge: invalid mode attribute: ${value}`);
|
|
5
|
-
}
|
|
6
|
-
};
|
|
7
|
-
export const getBadgeColorBg = id => {
|
|
8
|
-
return `var(--sinch-badge-color-${id}-bg)`;
|
|
9
|
-
};
|
|
10
|
-
export const getBadgeColorFg = id => {
|
|
11
|
-
return `var(--sinch-badge-color-${id}-fg)`;
|
|
12
|
-
};
|
|
13
|
-
export const assertBadgeColor = (root, id) => {
|
|
14
|
-
if (id === null || window.getComputedStyle(root).getPropertyValue(`--sinch-badge-color-${id}-bg`).length === 0) {
|
|
15
|
-
throw new Error(`Invalid sinch-badge color name: ${id}`);
|
|
16
|
-
}
|
|
17
|
-
};
|
|
1
|
+
export const modeValues = ['square', 'circle'];
|