@nectary/components 1.4.0 → 2.0.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-option/index.js +2 -2
- package/alert/index.js +2 -12
- package/avatar/index.js +1 -1
- package/avatar/utils.js +3 -3
- package/badge/index.js +41 -67
- package/badge/types.d.ts +0 -4
- package/badge/utils.d.ts +0 -3
- package/badge/utils.js +0 -11
- package/button/index.js +1 -1
- package/button/types.d.ts +2 -2
- 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.js +3 -24
- package/checkbox/index.js +31 -30
- package/checkbox/types.d.ts +0 -3
- package/chip/index.js +34 -27
- package/chip/utils.js +3 -3
- package/code-tag/index.js +1 -1
- package/color-menu/index.d.ts +0 -3
- package/color-menu/index.js +50 -99
- 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 +1 -1
- package/color-swatch/utils.js +3 -3
- package/date-picker/index.js +2 -21
- package/date-picker/types.d.ts +0 -3
- package/dialog/index.js +2 -5
- 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 +32 -23
- package/field/index.js +39 -32
- package/file-drop/index.js +1 -1
- package/file-status/index.js +2 -16
- package/flag/index.js +1 -1
- package/grid/index.js +1 -1
- package/help-tooltip/index.js +3 -12
- 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 +1 -1
- package/inline-alert/index.js +19 -29
- package/input/index.d.ts +0 -3
- package/input/index.js +12 -46
- package/input/types.d.ts +1 -5
- package/link/index.js +35 -37
- package/list-item/index.js +1 -1
- package/package.json +10 -9
- package/pagination/index.js +8 -21
- package/pagination/types.d.ts +0 -3
- package/pop/index.js +16 -13
- package/popover/index.js +44 -50
- 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 +1 -1
- package/segment/index.js +2 -3
- 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 +7 -12
- package/select-menu/index.js +12 -5
- 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 +1 -1
- 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 +16 -8
- package/tag/utils.js +3 -3
- package/text/index.js +30 -20
- 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 -8
- package/time-picker/types.d.ts +0 -3
- package/title/index.js +30 -22
- package/toast/index.js +20 -30
- package/toggle/index.js +33 -30
- package/toggle/types.d.ts +0 -3
- package/tooltip/index.js +2 -8
- package/tooltip/types.d.ts +0 -12
- 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/file-status/index.js
CHANGED
|
@@ -1,28 +1,25 @@
|
|
|
1
1
|
import '../spinner';
|
|
2
2
|
import '../icon';
|
|
3
3
|
import '../text';
|
|
4
|
-
import { defineCustomElement, getAttribute, getLiteralAttribute, updateAttribute, updateLiteralAttribute, NectaryElement, updateBooleanAttribute
|
|
5
|
-
const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:row;align-items:flex-start;padding:12px 16px;box-sizing:border-box;min-height:48px;min-width:148px;background-color:var(--sinch-color-
|
|
4
|
+
import { defineCustomElement, getAttribute, getLiteralAttribute, updateAttribute, updateLiteralAttribute, NectaryElement, updateBooleanAttribute } from '../utils';
|
|
5
|
+
const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:row;align-items:flex-start;padding:12px 16px;box-sizing:border-box;min-height:48px;min-width:148px;border-radius:var(--sinch-comp-file-status-shape-radius)}:host([type=error]) #wrapper{background-color:var(--sinch-comp-file-status-color-error-background)}:host([type=success]) #wrapper{background-color:var(--sinch-comp-file-status-color-success-background)}:host([type=pending]) #wrapper{background-color:var(--sinch-comp-file-status-color-pending-background)}:host([type=progress]) #wrapper{background-color:var(--sinch-comp-file-status-color-progress-background)}:host([type=loading]) #wrapper{background-color:var(--sinch-comp-file-status-color-loading-background)}#content-wrapper{display:flex;flex-direction:column;gap:8px;flex:1;min-width:0;min-height:24px;margin-left:16px}:host([type=error]) #filename{--sinch-global-color-text:var(--sinch-comp-file-status-color-error-text)}:host([type=success]) #filename{--sinch-global-color-text:var(--sinch-comp-file-status-color-success-text)}:host([type=pending]) #filename{--sinch-global-color-text:var(--sinch-comp-file-status-color-pending-text)}:host([type=progress]) #filename{--sinch-global-color-text:var(--sinch-comp-file-status-color-progress-text)}:host([type=loading]) #filename{--sinch-global-color-text:var(--sinch-comp-file-status-color-loading-text)}#action{display:flex;gap:4px;height:32px;margin-top:-4px;margin-bottom:-4px}#icon-error,#icon-loading,#icon-pending,#icon-progress,#icon-success{display:none}#icon-pending{--sinch-global-color-icon:var(--sinch-comp-file-status-color-pending-icon)}#icon-success{--sinch-global-color-icon:var(--sinch-comp-file-status-color-success-icon)}#icon-progress{--sinch-global-color-icon:var(--sinch-comp-file-status-color-progress-icon)}#icon-error{--sinch-global-color-icon:var(--sinch-comp-file-status-color-error-icon)}#icon-loading{--sinch-global-color-icon:var(--sinch-comp-file-status-color-loading-icon)}:host([type=error]) #icon-error,:host([type=loading]) #icon-loading,:host([type=pending]) #icon-pending,:host([type=progress]) #icon-progress,:host([type=success]) #icon-success{display:block}</style><div id="wrapper"><sinch-spinner id="icon-loading" size="m"></sinch-spinner><sinch-icon id="icon-pending" name="pending_actions"></sinch-icon><sinch-icon id="icon-success" name="check_circle"></sinch-icon><sinch-icon id="icon-progress" name="text_snippet"></sinch-icon><sinch-icon id="icon-error" name="report"></sinch-icon><div id="content-wrapper"><sinch-text id="filename" type="m" ellipsis></sinch-text><slot name="content"></slot></div><div id="action"><slot name="action"></slot></div></div>';
|
|
6
6
|
import { assertType, typeValues } from './utils';
|
|
7
7
|
const template = document.createElement('template');
|
|
8
8
|
template.innerHTML = templateHTML;
|
|
9
9
|
defineCustomElement('sinch-file-status', class extends NectaryElement {
|
|
10
10
|
#$filename;
|
|
11
11
|
#$contentSlot;
|
|
12
|
-
#$icon;
|
|
13
12
|
constructor() {
|
|
14
13
|
super();
|
|
15
14
|
const shadowRoot = this.attachShadow();
|
|
16
15
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
17
16
|
this.#$filename = shadowRoot.querySelector('#filename');
|
|
18
17
|
this.#$contentSlot = shadowRoot.querySelector('slot[name="content"]');
|
|
19
|
-
this.#$icon = shadowRoot.querySelector('#icon');
|
|
20
18
|
}
|
|
21
19
|
connectedCallback() {
|
|
22
20
|
super.connectedCallback();
|
|
23
21
|
this.#$contentSlot.addEventListener('slotchange', this.#onContentSlotChange);
|
|
24
22
|
this.#onContentSlotChange();
|
|
25
|
-
this.#updateIcon();
|
|
26
23
|
}
|
|
27
24
|
disconnectedCallback() {
|
|
28
25
|
super.disconnectedCallback();
|
|
@@ -53,7 +50,6 @@ defineCustomElement('sinch-file-status', class extends NectaryElement {
|
|
|
53
50
|
if ('production' !== 'production') {
|
|
54
51
|
assertType(newVal);
|
|
55
52
|
}
|
|
56
|
-
this.#updateIcon();
|
|
57
53
|
break;
|
|
58
54
|
}
|
|
59
55
|
case 'filename':
|
|
@@ -63,16 +59,6 @@ defineCustomElement('sinch-file-status', class extends NectaryElement {
|
|
|
63
59
|
}
|
|
64
60
|
}
|
|
65
61
|
}
|
|
66
|
-
#updateIcon() {
|
|
67
|
-
if (!this.isConnected) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
const type = this.type;
|
|
71
|
-
if (type === 'loading') {
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
updateAttribute(this.#$icon, 'name', getCssVar(this, `--sinch-file-status-icon-${type}`));
|
|
75
|
-
}
|
|
76
62
|
#onContentSlotChange = () => {
|
|
77
63
|
updateBooleanAttribute(this.#$filename, 'emphasized', this.#$contentSlot.assignedElements().length > 0);
|
|
78
64
|
};
|
package/flag/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineCustomElement, getAttribute, NectaryElement, updateAttribute } from '../utils';
|
|
2
|
-
const templateHTML = '<style>:host{display:contents}#image{pointer-events:none;width:var(--sinch-size-icon,48px);height:var(--sinch-size-icon,48px);object-fit:contain}</style><img id="image" src="" alt="" loading="lazy"/>';
|
|
2
|
+
const templateHTML = '<style>:host{display:contents}#image{pointer-events:none;width:var(--sinch-global-size-icon,48px);height:var(--sinch-global-size-icon,48px);object-fit:contain}</style><img id="image" src="" alt="" loading="lazy"/>';
|
|
3
3
|
import { getFlagUrl } from './utils';
|
|
4
4
|
const template = document.createElement('template');
|
|
5
5
|
template.innerHTML = templateHTML;
|
package/grid/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineCustomElement, NectaryElement } from '../utils';
|
|
2
|
-
const templateHTML = '<style>:host{--sinch-grid-gutter:24px;--sinch-grid-margin:32px;--sinch-grid-num-columns:12;display:grid;grid-template-columns:repeat(var(--sinch-grid-num-columns),minmax(0,1fr));grid-column-gap:var(--sinch-grid-gutter);grid-row-gap:var(--sinch-grid-gutter);padding:var(--sinch-grid-margin)}@media only screen and (max-width:1439px){:host{--sinch-grid-gutter:24px;--sinch-grid-margin:24px;--sinch-grid-num-columns:12}}@media only screen and (max-width:1023px){:host{--sinch-grid-gutter:24px;--sinch-grid-margin:24px;--sinch-grid-num-columns:8}}@media only screen and (max-width:767px){:host{--sinch-grid-gutter:16px;--sinch-grid-margin:16px;--sinch-grid-num-columns:4}}</style><slot name="item"></slot>';
|
|
2
|
+
const templateHTML = '<style>:host{--sinch-comp-grid-gutter:24px;--sinch-comp-grid-margin:32px;--sinch-comp-grid-num-columns:12;display:grid;grid-template-columns:repeat(var(--sinch-comp-grid-num-columns),minmax(0,1fr));grid-column-gap:var(--sinch-comp-grid-gutter);grid-row-gap:var(--sinch-comp-grid-gutter);padding:var(--sinch-comp-grid-margin)}@media only screen and (max-width:1439px){:host{--sinch-comp-grid-gutter:24px;--sinch-comp-grid-margin:24px;--sinch-comp-grid-num-columns:12}}@media only screen and (max-width:1023px){:host{--sinch-comp-grid-gutter:24px;--sinch-comp-grid-margin:24px;--sinch-comp-grid-num-columns:8}}@media only screen and (max-width:767px){:host{--sinch-comp-grid-gutter:16px;--sinch-comp-grid-margin:16px;--sinch-comp-grid-num-columns:4}}</style><slot name="item"></slot>';
|
|
3
3
|
const template = document.createElement('template');
|
|
4
4
|
template.innerHTML = templateHTML;
|
|
5
5
|
defineCustomElement('sinch-grid', class extends NectaryElement {
|
package/help-tooltip/index.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import '../tooltip';
|
|
2
2
|
import '../icon';
|
|
3
|
-
import { defineCustomElement, getAttribute,
|
|
4
|
-
const templateHTML = '<style>:host{display:contents}#icon{--sinch-size-icon:18px;--sinch-
|
|
3
|
+
import { defineCustomElement, getAttribute, getIntegerAttribute, getReactEventHandler, NectaryElement, updateAttribute, updateIntegerAttribute } from '../utils';
|
|
4
|
+
const templateHTML = '<style>:host{display:contents;--sinch-comp-help-tooltip-color-icon:var(--sinch-sys-color-text-default)}#icon{--sinch-global-size-icon:18px;--sinch-global-color-icon:var(--sinch-comp-help-tooltip-color-icon);--sinch-comp-icon-font-variation-settings:"FILL" 0}</style><sinch-tooltip type="fast"><sinch-icon id="icon" name="help"></sinch-icon></sinch-tooltip>';
|
|
5
5
|
const template = document.createElement('template');
|
|
6
6
|
template.innerHTML = templateHTML;
|
|
7
7
|
defineCustomElement('sinch-help-tooltip', class extends NectaryElement {
|
|
8
|
-
#$icon;
|
|
9
8
|
#$tooltip;
|
|
10
9
|
#controller = null;
|
|
11
10
|
constructor() {
|
|
@@ -13,7 +12,6 @@ defineCustomElement('sinch-help-tooltip', class extends NectaryElement {
|
|
|
13
12
|
const shadowRoot = this.attachShadow();
|
|
14
13
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
15
14
|
this.#$tooltip = shadowRoot.querySelector('sinch-tooltip');
|
|
16
|
-
this.#$icon = shadowRoot.querySelector('#icon');
|
|
17
15
|
}
|
|
18
16
|
connectedCallback() {
|
|
19
17
|
super.connectedCallback();
|
|
@@ -25,14 +23,13 @@ defineCustomElement('sinch-help-tooltip', class extends NectaryElement {
|
|
|
25
23
|
this.#$tooltip.addEventListener('-hide', this.#onTooltipHide, options);
|
|
26
24
|
this.addEventListener('-show', this.#onTooltipShowReactHandler, options);
|
|
27
25
|
this.addEventListener('-hide', this.#onTooltipHideReactHandler, options);
|
|
28
|
-
updateAttribute(this.#$icon, 'name', getCssVar(this, '--sinch-help-tooltip-icon-help'));
|
|
29
26
|
}
|
|
30
27
|
disconnectedCallback() {
|
|
31
28
|
super.disconnectedCallback();
|
|
32
29
|
this.#controller.abort();
|
|
33
30
|
}
|
|
34
31
|
static get observedAttributes() {
|
|
35
|
-
return ['text', 'width', 'orientation'
|
|
32
|
+
return ['text', 'width', 'orientation'];
|
|
36
33
|
}
|
|
37
34
|
attributeChangedCallback(name, _, newVal) {
|
|
38
35
|
updateAttribute(this.#$tooltip, name, newVal);
|
|
@@ -49,12 +46,6 @@ defineCustomElement('sinch-help-tooltip', class extends NectaryElement {
|
|
|
49
46
|
set width(value) {
|
|
50
47
|
updateIntegerAttribute(this, 'width', value);
|
|
51
48
|
}
|
|
52
|
-
get inverted() {
|
|
53
|
-
return getBooleanAttribute(this, 'inverted');
|
|
54
|
-
}
|
|
55
|
-
set inverted(isInverted) {
|
|
56
|
-
updateBooleanAttribute(this, 'inverted', isInverted);
|
|
57
|
-
}
|
|
58
49
|
get orientation() {
|
|
59
50
|
return getAttribute(this, 'orientation', 'top');
|
|
60
51
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { clampNumber, defineCustomElement, getAttribute, getIntegerAttribute, NectaryElement, updateAttribute } from '../utils';
|
|
2
|
-
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{position:relative;display:flex;flex-direction:row;gap:28px;width:fit-content}#progress{position:absolute;height:1px;background-color:var(--sinch-color-
|
|
2
|
+
const templateHTML = '<style>:host{display:block;outline:0;--sinch-comp-horizontal-stepper-color-background-default:var(--sinch-sys-color-container-contrast-primary-default);--sinch-comp-horizontal-stepper-color-background-visited-skip:var(--sinch-sys-color-container-contrast-primary-default);--sinch-comp-horizontal-stepper-color-background-active:var(--sinch-ref-color-main-stormy-400);--sinch-comp-horizontal-stepper-color-background-visited:var(--sinch-ref-color-main-snow-700);--sinch-comp-horizontal-stepper-color-background-visited-error:var(--sinch-sys-color-feedback-invalid-background);--sinch-comp-horizontal-stepper-color-border-default:transparent;--sinch-comp-horizontal-stepper-color-border-visited-skip:var(--sinch-ref-color-main-stormy-400);--sinch-comp-horizontal-stepper-color-border-active:transparent;--sinch-comp-horizontal-stepper-color-border-visited:var(--sinch-ref-color-main-stormy-400);--sinch-comp-horizontal-stepper-color-border-visited-error:var(--sinch-ref-color-main-stormy-400);--sinch-comp-horizontal-stepper-color-icon-default:var(--sinch-ref-color-main-stormy-700);--sinch-comp-horizontal-stepper-color-icon-visited-skip:var(--sinch-ref-color-main-stormy-700);--sinch-comp-horizontal-stepper-color-icon-active:var(--sinch-ref-color-main-snow-100);--sinch-comp-horizontal-stepper-color-icon-visited:var(--sinch-ref-color-main-stormy-700);--sinch-comp-horizontal-stepper-color-icon-visited-error:var(--sinch-ref-color-main-stormy-700);--sinch-comp-horizontal-stepper-color-label:var(--sinch-sys-color-text-default);--sinch-comp-horizontal-stepper-color-description:var(--sinch-sys-color-text-muted);--sinch-comp-horizontal-stepper-color-progress:var(--sinch-ref-color-main-snow-700);--sinch-comp-horizontal-stepper-color-progress-visited:var(--sinch-ref-color-main-stormy-400)}#wrapper{position:relative;display:flex;flex-direction:row;gap:28px;width:fit-content}#progress{position:absolute;height:1px;background-color:var(--sinch-comp-horizontal-stepper-color-progress);left:72px;right:72px;top:16px;transform:translateY(-50%)}#bar{position:absolute;height:1px;background-color:var(--sinch-comp-horizontal-stepper-color-progress-visited);left:0;top:0}</style><div id="wrapper"><div id="progress"><div id="bar"></div></div><slot></slot></div>';
|
|
3
3
|
const template = document.createElement('template');
|
|
4
4
|
template.innerHTML = templateHTML;
|
|
5
5
|
defineCustomElement('sinch-horizontal-stepper', class extends NectaryElement {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import '../icon';
|
|
2
|
-
import
|
|
3
|
-
|
|
2
|
+
import '../title';
|
|
3
|
+
import '../text';
|
|
4
|
+
import { defineCustomElement, getAttribute, getLiteralAttribute, NectaryElement, updateAttribute, updateLiteralAttribute } from '../utils';
|
|
5
|
+
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{width:144px;min-height:64px;display:flex;flex-direction:column}#circle{position:relative;display:flex;align-items:center;justify-content:center;align-self:center;width:32px;height:32px;background-color:var(--sinch-local-color-background);font:var(--sinch-sys-font-desktop-title-s);line-height:32px;text-align:center;color:var(--sinch-local-color-text);border:1px solid var(--sinch-local-color-border);border-radius:50%;box-sizing:border-box;--sinch-local-color-background:var(--sinch-comp-horizontal-stepper-color-background-default);--sinch-local-color-border:var(--sinch-comp-horizontal-stepper-color-border-default);--sinch-local-color-text:var(--sinch-comp-horizontal-stepper-color-icon-default);--sinch-local-color-icon:var(--sinch-comp-horizontal-stepper-color-icon-default);--sinch-global-size-icon:20px}:host([data-progress=active]) #circle{--sinch-local-color-background:var(--sinch-comp-horizontal-stepper-color-background-active);--sinch-local-color-border:var(--sinch-comp-horizontal-stepper-color-border-active);--sinch-local-color-text:var(--sinch-comp-horizontal-stepper-color-icon-active);--sinch-local-color-icon:var(--sinch-comp-horizontal-stepper-color-icon-active)}:host([data-progress=done]) #circle{--sinch-local-color-background:var(--sinch-comp-horizontal-stepper-color-background-visited);--sinch-local-color-border:var(--sinch-comp-horizontal-stepper-color-border-visited);--sinch-local-color-text:var(--sinch-comp-horizontal-stepper-color-icon-visited);--sinch-local-color-icon:var(--sinch-comp-horizontal-stepper-color-icon-visited)}:host([data-progress=done][status=error]) #circle{--sinch-local-color-background:var(--sinch-comp-horizontal-stepper-color-background-visited-error);--sinch-local-color-border:var(--sinch-comp-horizontal-stepper-color-border-visited-error);--sinch-local-color-text:var(--sinch-comp-horizontal-stepper-color-icon-visited-error);--sinch-local-color-icon:var(--sinch-comp-horizontal-stepper-color-icon-visited-error)}:host([data-progress=done][status=skip]) #circle{--sinch-local-color-background:var(--sinch-comp-horizontal-stepper-color-background-visited-skip);--sinch-local-color-border:var(--sinch-comp-horizontal-stepper-color-border-visited-skip);--sinch-local-color-text:var(--sinch-comp-horizontal-stepper-color-icon-visited-skip);--sinch-local-color-icon:var(--sinch-comp-horizontal-stepper-color-icon-visited-skip)}#icon-error,#icon-success{display:none}:host([data-progress=done]:not([status])) #icon-success{display:block}:host([data-progress=done][status=error]) #icon-error{display:block}:host([data-progress=done]:not([status=skip])) #circle-text{display:none}#label{text-align:center;margin-top:8px;--sinch-global-color-text:var(--sinch-comp-horizontal-stepper-color-label)}#description{text-align:center;--sinch-global-color-text:var(--sinch-comp-horizontal-stepper-color-description)}</style><div id="wrapper"><div id="circle" aria-hidden="true"><sinch-icon id="icon-success" name="check"></sinch-icon><sinch-icon id="icon-error" name="exclamation"></sinch-icon><span id="circle-text"></span></div><sinch-title id="label" type="s" ellipsis></sinch-title><sinch-text id="description" type="xs" ellipsis></sinch-text></div>';
|
|
4
6
|
import { statusValues } from './utils';
|
|
5
7
|
const template = document.createElement('template');
|
|
6
8
|
template.innerHTML = templateHTML;
|
|
@@ -8,8 +10,6 @@ defineCustomElement('sinch-horizontal-stepper-item', class extends NectaryElemen
|
|
|
8
10
|
#$label;
|
|
9
11
|
#$description;
|
|
10
12
|
#$circleText;
|
|
11
|
-
#$iconSuccess;
|
|
12
|
-
#$iconError;
|
|
13
13
|
constructor() {
|
|
14
14
|
super();
|
|
15
15
|
const shadowRoot = this.attachShadow();
|
|
@@ -17,22 +17,18 @@ defineCustomElement('sinch-horizontal-stepper-item', class extends NectaryElemen
|
|
|
17
17
|
this.#$label = shadowRoot.querySelector('#label');
|
|
18
18
|
this.#$description = shadowRoot.querySelector('#description');
|
|
19
19
|
this.#$circleText = shadowRoot.querySelector('#circle-text');
|
|
20
|
-
this.#$iconSuccess = shadowRoot.querySelector('#icon-success');
|
|
21
|
-
this.#$iconError = shadowRoot.querySelector('#icon-error');
|
|
22
|
-
}
|
|
23
|
-
connectedCallback() {
|
|
24
|
-
const [successName, errorName] = getCssVars(this, ['--sinch-horizontal-stepper-icon-success', '--sinch-horizontal-stepper-icon-error']);
|
|
25
|
-
updateAttribute(this.#$iconSuccess, 'name', successName);
|
|
26
|
-
updateAttribute(this.#$iconError, 'name', errorName);
|
|
27
20
|
}
|
|
28
21
|
static get observedAttributes() {
|
|
29
22
|
return ['label', 'description', 'data-index'];
|
|
30
23
|
}
|
|
31
24
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
25
|
+
if (oldVal === newVal) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
32
28
|
switch (name) {
|
|
33
29
|
case 'label':
|
|
34
30
|
{
|
|
35
|
-
this.#$label
|
|
31
|
+
updateAttribute(this.#$label, 'text', newVal);
|
|
36
32
|
break;
|
|
37
33
|
}
|
|
38
34
|
case 'description':
|
package/icon/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineCustomElement, getAttribute, NectaryElement, updateAttribute } from '../utils';
|
|
2
|
-
const templateHTML = '<style>:host{display:inline-block}#icon{display:block;font-family:var(--sinch-icon-font-family);font-weight:var(--sinch-icon-font-weight);font-size:var(--sinch-size-icon, 24px);font-feature-settings:var(--sinch-icon-font-feature-settings);font-variation-settings:var(--sinch-icon-font-variation-settings);-webkit-font-smoothing:antialiased;line-height:1;white-space:nowrap;width:var(--sinch-size-icon,24px);height:var(--sinch-size-icon,24px);color:var(--sinch-color-icon,var(--sinch-color-
|
|
2
|
+
const templateHTML = '<style>:host{display:inline-block}#icon{display:block;font-family:var(--sinch-comp-icon-font-family);font-weight:var(--sinch-comp-icon-font-weight);font-size:var(--sinch-global-size-icon, 24px);font-feature-settings:var(--sinch-comp-icon-font-feature-settings);font-variation-settings:var(--sinch-comp-icon-font-variation-settings);-webkit-font-smoothing:antialiased;line-height:1;white-space:nowrap;width:var(--sinch-global-size-icon,24px);height:var(--sinch-global-size-icon,24px);color:var(--sinch-global-color-icon,var(--sinch-sys-color-text-default));user-select:none}</style><span id="icon" role="img"></span>';
|
|
3
3
|
const template = document.createElement('template');
|
|
4
4
|
template.innerHTML = templateHTML;
|
|
5
5
|
defineCustomElement('sinch-icon', class extends NectaryElement {
|
package/icon-button/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import '../tooltip';
|
|
2
2
|
import { defineCustomElement, getBooleanAttribute, getLiteralAttribute, getReactEventHandler, isAttrTrue, NectaryElement, subscribeContext, updateAttribute, updateBooleanAttribute, updateLiteralAttribute, Context, getAttribute } from '../utils';
|
|
3
3
|
import { assertSizeEx, DEFAULT_SIZE, sizeExValues } from '../utils/size';
|
|
4
|
-
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0
|
|
4
|
+
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#button{all:initial;display:block;position:relative;width:var(--sinch-local-size);height:var(--sinch-local-size);cursor:pointer;contain:size;--sinch-global-color-icon:var(--sinch-local-color-icon)}#button:disabled{cursor:initial}:host([data-size="l"]) #button{--sinch-local-size:var(--sinch-comp-icon-button-size-container-l);--sinch-global-size-icon:var(--sinch-comp-icon-button-size-icon-l);--sinch-local-shape-radius:var(--sinch-comp-icon-button-shape-radius-size-l)}#button,:host([data-size="m"]) #button{--sinch-local-size:var(--sinch-comp-icon-button-size-container-m);--sinch-global-size-icon:var(--sinch-comp-icon-button-size-icon-m);--sinch-local-shape-radius:var(--sinch-comp-icon-button-shape-radius-size-m)}:host([data-size="s"]) #button{--sinch-local-size:var(--sinch-comp-icon-button-size-container-s);--sinch-global-size-icon:var(--sinch-comp-icon-button-size-icon-s);--sinch-local-shape-radius:var(--sinch-comp-icon-button-shape-radius-size-s)}:host([data-size=xs]) #button{--sinch-local-size:var(--sinch-comp-icon-button-size-container-xs);--sinch-global-size-icon:var(--sinch-comp-icon-button-size-icon-xs);--sinch-local-shape-radius:var(--sinch-comp-icon-button-shape-radius-size-xs)}:host([type=primary]) #button{--sinch-local-color-background:var(--sinch-comp-icon-button-color-primary-default-background-initial);--sinch-local-color-border:var(--sinch-comp-icon-button-color-primary-default-border-initial);--sinch-local-color-icon:var(--sinch-comp-icon-button-color-primary-default-icon-initial);--sinch-local-shadow:var(--sinch-comp-icon-button-shadow-primary-initial);--sinch-local-color-outline:var(--sinch-comp-icon-button-color-primary-default-outline-focus)}:host([type=secondary]) #button{--sinch-local-color-background:var(--sinch-comp-icon-button-color-secondary-default-background-initial);--sinch-local-color-border:var(--sinch-comp-icon-button-color-secondary-default-border-initial);--sinch-local-color-icon:var(--sinch-comp-icon-button-color-secondary-default-icon-initial);--sinch-local-shadow:var(--sinch-comp-icon-button-shadow-secondary-initial);--sinch-local-color-outline:var(--sinch-comp-icon-button-color-secondary-default-outline-focus)}#button,:host([type=tertiary]) #button{--sinch-local-color-background:var(--sinch-comp-icon-button-color-tertiary-default-background-initial);--sinch-local-color-border:var(--sinch-comp-icon-button-color-tertiary-default-border-initial);--sinch-local-color-icon:var(--sinch-comp-icon-button-color-tertiary-default-icon-initial);--sinch-local-shadow:var(--sinch-comp-icon-button-shadow-tertiary-initial);--sinch-local-color-outline:var(--sinch-comp-icon-button-color-tertiary-default-outline-focus)}:host([type=primary]) #button:disabled{--sinch-local-color-background:var(--sinch-comp-icon-button-color-primary-disabled-background-initial);--sinch-local-color-border:var(--sinch-comp-icon-button-color-primary-disabled-border-initial);--sinch-local-color-icon:var(--sinch-comp-icon-button-color-primary-disabled-icon-initial);--sinch-local-shadow:var(--sinch-comp-icon-button-shadow-primary-disabled)}:host([type=secondary]) #button:disabled{--sinch-local-color-background:var(--sinch-comp-icon-button-color-secondary-disabled-background-initial);--sinch-local-color-border:var(--sinch-comp-icon-button-color-secondary-disabled-border-initial);--sinch-local-color-icon:var(--sinch-comp-icon-button-color-secondary-disabled-icon-initial);--sinch-local-shadow:var(--sinch-comp-icon-button-shadow-secondary-disabled)}#button:disabled,:host([type=tertiary]) #button:disabled{--sinch-local-color-background:var(--sinch-comp-icon-button-color-tertiary-disabled-background-initial);--sinch-local-color-border:var(--sinch-comp-icon-button-color-tertiary-disabled-border-initial);--sinch-local-color-icon:var(--sinch-comp-icon-button-color-tertiary-disabled-icon-initial);--sinch-local-shadow:var(--sinch-comp-icon-button-shadow-tertiary-disabled)}:host([type=primary]) #button:focus{--sinch-local-shadow:var(--sinch-comp-icon-button-shadow-primary-focus)}:host([type=secondary]) #button:focus{--sinch-local-shadow:var(--sinch-comp-icon-button-shadow-secondary-focus)}#button:focus,:host([type=tertiary]) #button:focus{--sinch-local-shadow:var(--sinch-comp-icon-button-shadow-tertiary-focus)}:host([type=primary]) #button:enabled:hover{--sinch-local-color-background:var(--sinch-comp-icon-button-color-primary-default-background-hover);--sinch-local-shadow:var(--sinch-comp-icon-button-shadow-primary-hover)}:host([type=secondary]) #button:enabled:hover{--sinch-local-color-background:var(--sinch-comp-icon-button-color-secondary-default-background-hover);--sinch-local-shadow:var(--sinch-comp-icon-button-shadow-secondary-hover)}#button:enabled:hover,:host([type=tertiary]) #button:enabled:hover{--sinch-local-color-background:var(--sinch-comp-icon-button-color-tertiary-default-background-hover);--sinch-local-shadow:var(--sinch-comp-icon-button-shadow-tertiary-hover)}:host([type=primary]) #button:enabled:active{--sinch-local-color-background:var(--sinch-comp-icon-button-color-primary-default-background-active);--sinch-local-shadow:var(--sinch-comp-icon-button-shadow-primary-active)}:host([type=secondary]) #button:enabled:active{--sinch-local-color-background:var(--sinch-comp-icon-button-color-secondary-default-background-active);--sinch-local-shadow:var(--sinch-comp-icon-button-shadow-secondary-active)}#button:enabled:active,:host([type=tertiary]) #button:enabled:active{--sinch-local-color-background:var(--sinch-comp-icon-button-color-tertiary-default-background-active);--sinch-local-shadow:var(--sinch-comp-icon-button-shadow-tertiary-active)}#button::before{content:"";position:absolute;inset:0;background-color:var(--sinch-local-color-background);border:1px solid var(--sinch-local-color-border);border-radius:var(--sinch-local-shape-radius);box-shadow:var(--sinch-local-shadow);pointer-events:none}#button:focus-visible::after{content:"";position:absolute;inset:-3px;border:2px solid var(--sinch-local-color-outline);border-radius:calc(var(--sinch-local-shape-radius) + 3px);pointer-events:none}#content{position:relative;display:flex;align-items:center;justify-content:center;width:var(100%);height:var(100%)}</style><sinch-tooltip id="tooltip"><button id="button"><div id="content"><slot name="icon"></slot></div></button></sinch-tooltip>';
|
|
5
5
|
import { assertType, typeValues } from './utils';
|
|
6
6
|
const template = document.createElement('template');
|
|
7
7
|
template.innerHTML = templateHTML;
|
package/inline-alert/index.js
CHANGED
|
@@ -2,13 +2,12 @@ import '../icon';
|
|
|
2
2
|
import '../rich-text';
|
|
3
3
|
import '../text';
|
|
4
4
|
import '../title';
|
|
5
|
-
import { defineCustomElement, getAttribute, getLiteralAttribute, updateAttribute, updateLiteralAttribute, NectaryElement, setClass
|
|
6
|
-
const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:row;align-items:flex-start;padding:16px;border-radius:var(--sinch-shape-radius
|
|
5
|
+
import { defineCustomElement, getAttribute, getLiteralAttribute, updateAttribute, updateLiteralAttribute, NectaryElement, setClass } from '../utils';
|
|
6
|
+
const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:row;align-items:flex-start;padding:16px;border-radius:var(--sinch-comp-inline-alert-shape-radius);box-sizing:border-box;width:100%}:host([type=success]) #wrapper{background-color:var(--sinch-comp-inline-alert-color-success-default-background)}:host([type=warn]) #wrapper{background-color:var(--sinch-comp-inline-alert-color-warning-default-background)}:host([type=error]) #wrapper{background-color:var(--sinch-comp-inline-alert-color-error-default-background)}:host([type=info]) #wrapper{background-color:var(--sinch-comp-inline-alert-color-info-default-background)}#icon-error,#icon-info,#icon-success,#icon-warn{display:none}#icon-success{--sinch-global-color-icon:var(--sinch-comp-inline-alert-color-success-default-icon)}#icon-warn{--sinch-global-color-icon:var(--sinch-comp-inline-alert-color-warning-default-icon)}#icon-error{--sinch-global-color-icon:var(--sinch-comp-inline-alert-color-error-default-icon)}#icon-info{--sinch-global-color-icon:var(--sinch-comp-inline-alert-color-info-default-icon)}:host([type=error]) #icon-error,:host([type=info]) #icon-info,:host([type=success]) #icon-success,:host([type=warn]) #icon-warn{display:block}#body-wrapper{display:flex;flex-direction:column;align-items:flex-start;margin-left:8px;min-width:0;flex:1}#caption{align-self:stretch;--sinch-comp-title-font:var(--sinch-comp-inline-alert-font-title)}:host([type=success]) #caption{--sinch-global-color-text:var(--sinch-comp-inline-alert-color-success-default-text)}:host([type=warn]) #caption{--sinch-global-color-text:var(--sinch-comp-inline-alert-color-warning-default-text)}:host([type=error]) #caption{--sinch-global-color-text:var(--sinch-comp-inline-alert-color-error-default-text)}:host([type=info]) #caption{--sinch-global-color-text:var(--sinch-comp-inline-alert-color-info-default-text)}#text{display:flex;flex-direction:column;gap:8px;margin-top:4px;align-self:stretch;--sinch-comp-rich-text-font:var(--sinch-comp-inline-alert-font-body)}:host([type=success]) #text{--sinch-global-color-text:var(--sinch-comp-inline-alert-color-success-default-text)}:host([type=warn]) #text{--sinch-global-color-text:var(--sinch-comp-inline-alert-color-warning-default-text)}:host([type=error]) #text{--sinch-global-color-text:var(--sinch-comp-inline-alert-color-error-default-text)}:host([type=info]) #text{--sinch-global-color-text:var(--sinch-comp-inline-alert-color-info-default-text)}#action{display:flex;margin-top:16px;min-width:0}#action.empty{display:none}#close{margin-left:16px}#close.empty{display:none}</style><div id="wrapper"><sinch-icon id="icon-info" name="info"></sinch-icon><sinch-icon id="icon-success" name="check_circle"></sinch-icon><sinch-icon id="icon-warn" name="report_problem"></sinch-icon><sinch-icon id="icon-error" name="report"></sinch-icon><div id="body-wrapper"><sinch-title id="caption" level="3" type="s" ellipsis></sinch-title><sinch-rich-text id="text"></sinch-rich-text><div id="action"><slot name="action"></slot></div></div><div id="close"><slot name="close"></slot></div></div>';
|
|
7
7
|
import { assertType, typeValues } from './utils';
|
|
8
8
|
const template = document.createElement('template');
|
|
9
9
|
template.innerHTML = templateHTML;
|
|
10
10
|
defineCustomElement('sinch-inline-alert', class extends NectaryElement {
|
|
11
|
-
#$icon;
|
|
12
11
|
#$text;
|
|
13
12
|
#$caption;
|
|
14
13
|
#$closeWrapper;
|
|
@@ -19,7 +18,6 @@ defineCustomElement('sinch-inline-alert', class extends NectaryElement {
|
|
|
19
18
|
super();
|
|
20
19
|
const shadowRoot = this.attachShadow();
|
|
21
20
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
22
|
-
this.#$icon = shadowRoot.querySelector('#icon');
|
|
23
21
|
this.#$text = shadowRoot.querySelector('#text');
|
|
24
22
|
this.#$caption = shadowRoot.querySelector('#caption');
|
|
25
23
|
this.#$closeWrapper = shadowRoot.querySelector('#close');
|
|
@@ -35,31 +33,12 @@ defineCustomElement('sinch-inline-alert', class extends NectaryElement {
|
|
|
35
33
|
this.#$actionSlot.addEventListener('slotchange', this.#onActionSlotChange);
|
|
36
34
|
this.#onCloseSlotChange();
|
|
37
35
|
this.#onActionSlotChange();
|
|
38
|
-
this.#updateIcon();
|
|
39
36
|
}
|
|
40
37
|
disconnectedCallback() {
|
|
41
38
|
super.disconnectedCallback();
|
|
42
39
|
this.#$closeSlot.removeEventListener('slotchange', this.#onCloseSlotChange);
|
|
43
40
|
this.#$actionSlot.removeEventListener('slotchange', this.#onActionSlotChange);
|
|
44
41
|
}
|
|
45
|
-
get type() {
|
|
46
|
-
return getLiteralAttribute(this, typeValues, 'type');
|
|
47
|
-
}
|
|
48
|
-
set type(value) {
|
|
49
|
-
updateLiteralAttribute(this, typeValues, 'type', value);
|
|
50
|
-
}
|
|
51
|
-
get text() {
|
|
52
|
-
return getAttribute(this, 'text', '');
|
|
53
|
-
}
|
|
54
|
-
set text(value) {
|
|
55
|
-
updateAttribute(this, 'text', value);
|
|
56
|
-
}
|
|
57
|
-
get caption() {
|
|
58
|
-
return getAttribute(this, 'caption', '');
|
|
59
|
-
}
|
|
60
|
-
set caption(value) {
|
|
61
|
-
updateAttribute(this, 'caption', value);
|
|
62
|
-
}
|
|
63
42
|
static get observedAttributes() {
|
|
64
43
|
return ['text', 'caption', 'type'];
|
|
65
44
|
}
|
|
@@ -70,7 +49,6 @@ defineCustomElement('sinch-inline-alert', class extends NectaryElement {
|
|
|
70
49
|
if ('production' !== 'production') {
|
|
71
50
|
assertType(newVal);
|
|
72
51
|
}
|
|
73
|
-
this.#updateIcon();
|
|
74
52
|
break;
|
|
75
53
|
}
|
|
76
54
|
case 'text':
|
|
@@ -85,11 +63,23 @@ defineCustomElement('sinch-inline-alert', class extends NectaryElement {
|
|
|
85
63
|
}
|
|
86
64
|
}
|
|
87
65
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
66
|
+
get type() {
|
|
67
|
+
return getLiteralAttribute(this, typeValues, 'type');
|
|
68
|
+
}
|
|
69
|
+
set type(value) {
|
|
70
|
+
updateLiteralAttribute(this, typeValues, 'type', value);
|
|
71
|
+
}
|
|
72
|
+
get text() {
|
|
73
|
+
return getAttribute(this, 'text', '');
|
|
74
|
+
}
|
|
75
|
+
set text(value) {
|
|
76
|
+
updateAttribute(this, 'text', value);
|
|
77
|
+
}
|
|
78
|
+
get caption() {
|
|
79
|
+
return getAttribute(this, 'caption', '');
|
|
80
|
+
}
|
|
81
|
+
set caption(value) {
|
|
82
|
+
updateAttribute(this, 'caption', value);
|
|
93
83
|
}
|
|
94
84
|
#onCloseSlotChange = () => {
|
|
95
85
|
setClass(this.#$closeWrapper, 'empty', this.#$closeSlot.assignedElements().length === 0);
|
package/input/index.d.ts
CHANGED
package/input/index.js
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
import '../
|
|
2
|
-
import '../icon';
|
|
3
|
-
import '../stop-events';
|
|
4
|
-
import { Context, defineCustomElement, getAttribute, getBooleanAttribute, getCssVar, getLiteralAttribute, getReactEventHandler, getRect, isAttrTrue, NectaryElement, setClass, subscribeContext, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute, updateLiteralAttribute } from '../utils';
|
|
1
|
+
import { Context, defineCustomElement, getAttribute, getBooleanAttribute, getLiteralAttribute, getReactEventHandler, isAttrTrue, NectaryElement, setClass, subscribeContext, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute, updateLiteralAttribute } from '../utils';
|
|
5
2
|
import { assertSize, DEFAULT_SIZE, sizeValues } from '../utils/size';
|
|
6
|
-
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle}:
|
|
3
|
+
const templateHTML = '<style>:host{all:initial;display:inline-block;vertical-align:middle}#wrapper{position:relative;display:flex;flex-direction:row;align-items:center;box-sizing:border-box;border-radius:var(--sinch-local-shape-radius);width:100%;height:var(--sinch-local-size);background-color:var(--sinch-comp-input-color-default-background-initial);--sinch-local-size:var(--sinch-comp-input-size-container-m);--sinch-global-size-icon:var(--sinch-comp-input-size-icon-m);--sinch-local-shape-radius:var(--sinch-comp-input-shape-radius-size-m)}:host([data-size="l"])>#wrapper{--sinch-local-size:var(--sinch-comp-input-size-container-l);--sinch-global-size-icon:var(--sinch-comp-input-size-icon-l);--sinch-local-shape-radius:var(--sinch-comp-input-shape-radius-size-l)}:host([data-size="m"])>#wrapper{--sinch-local-size:var(--sinch-comp-input-size-container-m);--sinch-global-size-icon:var(--sinch-comp-input-size-icon-m);--sinch-local-shape-radius:var(--sinch-comp-input-shape-radius-size-m)}:host([data-size="s"])>#wrapper{--sinch-local-size:var(--sinch-comp-input-size-container-s);--sinch-global-size-icon:var(--sinch-comp-input-size-icon-s);--sinch-local-shape-radius:var(--sinch-comp-input-shape-radius-size-s)}#input{all:initial;flex:1;flex-basis:0;min-width:0;height:100%;padding:0 12px;font:var(--sinch-comp-input-font-input);color:var(--sinch-comp-input-color-default-text-initial)}#input::placeholder{font:var(--sinch-comp-input-font-placeholder);color:var(--sinch-comp-input-color-default-text-placeholder);opacity:1}#border{position:absolute;border:1px solid var(--sinch-comp-input-color-default-border-initial);border-radius:var(--sinch-local-shape-radius);inset:0;pointer-events:none}#input:disabled{color:var(--sinch-comp-input-color-disabled-text-initial);-webkit-text-fill-color:var(--sinch-comp-input-color-disabled-text-initial)}#input:disabled+#border{border-color:var(--sinch-comp-input-color-disabled-border-initial)}#input:focus+#border{border-color:var(--sinch-comp-input-color-default-border-focus);border-width:2px}:host([invalid]:not(:focus-within)) #input:enabled+#border{border-color:var(--sinch-comp-input-color-invalid-border-initial)}#input[type=password]{font-size:1.5em;letter-spacing:.1em}#icon-wrapper{position:relative;height:100%}#icon{position:absolute;display:flex;align-items:center;left:12px;top:0;bottom:0;pointer-events:none;--sinch-global-color-icon:var(--sinch-comp-input-color-default-icon-initial)}:host([disabled]) #icon{--sinch-global-color-icon:var(--sinch-comp-input-color-disabled-icon-initial)}#icon-wrapper.empty{display:none}#icon-wrapper.empty~#input{padding-left:12px}#icon-wrapper:not(.empty)~#input{padding-left:calc(var(--sinch-global-size-icon) + 20px)}#right{display:flex;flex-direction:row;align-self:stretch;align-items:center;gap:4px;padding-right:4px}#right.empty{display:none}#left{display:flex;flex-direction:row;align-self:stretch;align-items:center;gap:4px;padding-left:4px}#left.empty{display:none}</style><div id="wrapper"><div id="left"><slot name="left"></slot></div><div id="icon-wrapper"><div id="icon"><slot name="icon"></slot></div></div><input id="input" type="text"/><div id="border"></div><div id="right"><slot name="right"></slot></div></div>';
|
|
7
4
|
import { assertType, inputTypes } from './utils';
|
|
8
5
|
const template = document.createElement('template');
|
|
9
6
|
template.innerHTML = templateHTML;
|
|
10
7
|
defineCustomElement('sinch-input', class extends NectaryElement {
|
|
11
8
|
#$input;
|
|
12
|
-
#$clear;
|
|
13
|
-
#$iconClear;
|
|
14
9
|
#$iconSlot;
|
|
15
10
|
#$iconWrapper;
|
|
16
11
|
#$rightSlot;
|
|
@@ -35,8 +30,6 @@ defineCustomElement('sinch-input', class extends NectaryElement {
|
|
|
35
30
|
this.#$rightWrapper = shadowRoot.querySelector('#right');
|
|
36
31
|
this.#$leftSlot = shadowRoot.querySelector('slot[name="left"]');
|
|
37
32
|
this.#$leftWrapper = shadowRoot.querySelector('#left');
|
|
38
|
-
this.#$clear = shadowRoot.querySelector('#clear');
|
|
39
|
-
this.#$iconClear = shadowRoot.querySelector('#icon-clear');
|
|
40
33
|
this.#$wrapper = shadowRoot.querySelector('#wrapper');
|
|
41
34
|
this.#sizeContext = new Context(this.#$wrapper, 'size');
|
|
42
35
|
}
|
|
@@ -53,17 +46,12 @@ defineCustomElement('sinch-input', class extends NectaryElement {
|
|
|
53
46
|
this.#$input.addEventListener('keydown', this.#onSelectionChange, options);
|
|
54
47
|
this.#$input.addEventListener('focus', this.#onInputFocus, options);
|
|
55
48
|
this.#$input.addEventListener('blur', this.#onInputBlur, options);
|
|
56
|
-
this.#$clear.addEventListener('click', this.#onClearButtonClick, options);
|
|
57
|
-
this.#$clear.addEventListener('blur', this.#onClearButtonBlur, options);
|
|
58
|
-
this.#$clear.addEventListener('-tooltip-show', this.#onClearButtonTooltipShow, options);
|
|
59
|
-
this.#$clear.addEventListener('-tooltip-hide', this.#onClearButtonTooltipHide, options);
|
|
60
49
|
this.#$iconSlot.addEventListener('slotchange', this.#onIconSlotChange, options);
|
|
61
50
|
this.#$leftSlot.addEventListener('slotchange', this.#onLeftSlotChange, options);
|
|
62
51
|
this.#$rightSlot.addEventListener('slotchange', this.#onRightSlotChange, options);
|
|
63
52
|
this.addEventListener('-change', this.#onChangeReactHandler, options);
|
|
64
53
|
this.addEventListener('-focus', this.#onFocusReactHandler, options);
|
|
65
54
|
this.addEventListener('-blur', this.#onBlurReactHandler, options);
|
|
66
|
-
updateAttribute(this.#$iconClear, 'name', getCssVar(this, '--sinch-input-icon-clear'));
|
|
67
55
|
this.#sizeContext.listen(this.#controller.signal);
|
|
68
56
|
subscribeContext(this, 'size', this.#onContextSize, this.#controller.signal);
|
|
69
57
|
this.#onIconSlotChange();
|
|
@@ -78,7 +66,10 @@ defineCustomElement('sinch-input', class extends NectaryElement {
|
|
|
78
66
|
static get observedAttributes() {
|
|
79
67
|
return ['type', 'value', 'placeholder', 'invalid', 'disabled', 'size', 'autocomplete', 'data-size'];
|
|
80
68
|
}
|
|
81
|
-
attributeChangedCallback(name,
|
|
69
|
+
attributeChangedCallback(name, oldVal, newVal) {
|
|
70
|
+
if (oldVal === newVal) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
82
73
|
switch (name) {
|
|
83
74
|
case 'type':
|
|
84
75
|
{
|
|
@@ -112,14 +103,16 @@ defineCustomElement('sinch-input', class extends NectaryElement {
|
|
|
112
103
|
}
|
|
113
104
|
case 'invalid':
|
|
114
105
|
{
|
|
115
|
-
|
|
106
|
+
const isInvalid = isAttrTrue(newVal);
|
|
107
|
+
updateExplicitBooleanAttribute(this, 'aria-invalid', isInvalid);
|
|
108
|
+
updateBooleanAttribute(this, name, isInvalid);
|
|
116
109
|
break;
|
|
117
110
|
}
|
|
118
111
|
case 'disabled':
|
|
119
112
|
{
|
|
120
113
|
const isDisabled = isAttrTrue(newVal);
|
|
121
114
|
this.#$input.disabled = isDisabled;
|
|
122
|
-
updateBooleanAttribute(this,
|
|
115
|
+
updateBooleanAttribute(this, name, isDisabled);
|
|
123
116
|
break;
|
|
124
117
|
}
|
|
125
118
|
case 'size':
|
|
@@ -137,13 +130,10 @@ defineCustomElement('sinch-input', class extends NectaryElement {
|
|
|
137
130
|
}
|
|
138
131
|
case 'autocomplete':
|
|
139
132
|
{
|
|
140
|
-
updateAttribute(this.#$input,
|
|
133
|
+
updateAttribute(this.#$input, name, newVal);
|
|
141
134
|
}
|
|
142
135
|
}
|
|
143
136
|
}
|
|
144
|
-
get nodeName() {
|
|
145
|
-
return 'input';
|
|
146
|
-
}
|
|
147
137
|
set type(value) {
|
|
148
138
|
updateAttribute(this, 'type', value);
|
|
149
139
|
}
|
|
@@ -204,9 +194,6 @@ defineCustomElement('sinch-input', class extends NectaryElement {
|
|
|
204
194
|
set selectionDirection(value) {
|
|
205
195
|
this.#$input.selectionDirection = value;
|
|
206
196
|
}
|
|
207
|
-
get clearButtonRect() {
|
|
208
|
-
return getRect(this.#$clear);
|
|
209
|
-
}
|
|
210
197
|
get focusable() {
|
|
211
198
|
return true;
|
|
212
199
|
}
|
|
@@ -279,14 +266,10 @@ defineCustomElement('sinch-input', class extends NectaryElement {
|
|
|
279
266
|
setClass(this.#$rightWrapper, 'empty', isEmpty);
|
|
280
267
|
};
|
|
281
268
|
#onInputFocus = () => {
|
|
282
|
-
this.#$clear.setAttribute('data-focus', '');
|
|
283
269
|
this.dispatchEvent(new CustomEvent('-focus'));
|
|
284
270
|
};
|
|
285
|
-
#onInputBlur =
|
|
271
|
+
#onInputBlur = () => {
|
|
286
272
|
this.dispatchEvent(new CustomEvent('-blur'));
|
|
287
|
-
if (e.relatedTarget !== this.#$clear) {
|
|
288
|
-
this.#$clear.removeAttribute('data-focus');
|
|
289
|
-
}
|
|
290
273
|
};
|
|
291
274
|
#onSizeUpdate() {
|
|
292
275
|
if (!this.isConnected) {
|
|
@@ -295,23 +278,6 @@ defineCustomElement('sinch-input', class extends NectaryElement {
|
|
|
295
278
|
const size = this.getAttribute('data-size') ?? DEFAULT_SIZE;
|
|
296
279
|
this.#sizeContext.dispatch(size);
|
|
297
280
|
}
|
|
298
|
-
#onClearButtonClick = () => {
|
|
299
|
-
this.#$input.value = '';
|
|
300
|
-
this.#$input.focus();
|
|
301
|
-
this.#handleInput();
|
|
302
|
-
};
|
|
303
|
-
#onClearButtonBlur = e => {
|
|
304
|
-
if (e.relatedTarget !== this.#$input) {
|
|
305
|
-
this.#$clear.removeAttribute('data-focus');
|
|
306
|
-
}
|
|
307
|
-
};
|
|
308
|
-
#onClearButtonTooltipShow = () => {
|
|
309
|
-
this.#$clear.setAttribute('data-tooltip', '');
|
|
310
|
-
};
|
|
311
|
-
#onClearButtonTooltipHide = () => {
|
|
312
|
-
this.#$input.focus();
|
|
313
|
-
this.#$clear.removeAttribute('data-tooltip');
|
|
314
|
-
};
|
|
315
281
|
#onChangeReactHandler = e => {
|
|
316
282
|
getReactEventHandler(this, 'on-change')?.(e);
|
|
317
283
|
};
|
package/input/types.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TSinchElementReact } from '../types';
|
|
2
2
|
import type { TSinchSize } from '../utils/size';
|
|
3
|
-
import type { SyntheticEvent } from 'react';
|
|
4
3
|
export type TSinchInputType = 'text' | 'password';
|
|
5
4
|
export type TSinchInputElement = HTMLElement & {
|
|
6
5
|
/** Text field type, `text` by default */
|
|
@@ -20,7 +19,6 @@ export type TSinchInputElement = HTMLElement & {
|
|
|
20
19
|
selectionStart: number | null;
|
|
21
20
|
selectionEnd: number | null;
|
|
22
21
|
selectionDirection: 'forward' | 'backward' | 'none' | null;
|
|
23
|
-
readonly clearButtonRect: TRect;
|
|
24
22
|
/** Change value event */
|
|
25
23
|
addEventListener(type: '-change', listener: (e: CustomEvent<string>) => void): void;
|
|
26
24
|
/** Focus event */
|
|
@@ -59,8 +57,6 @@ export type TSinchInputReact = TSinchElementReact<TSinchInputElement> & {
|
|
|
59
57
|
disabled?: boolean;
|
|
60
58
|
/** Size, `m` by default */
|
|
61
59
|
size?: TSinchSize;
|
|
62
|
-
/** @deprecated Change value handler */
|
|
63
|
-
onChange?: (e: SyntheticEvent<TSinchInputElement, CustomEvent<string>>) => void;
|
|
64
60
|
/** Change value handler */
|
|
65
61
|
'on-change'?: (e: CustomEvent<string>) => void;
|
|
66
62
|
/** Focus handler */
|