@nectary/components 0.8.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.d.ts +21 -0
- package/accordion/index.js +118 -0
- package/accordion-item/index.d.ts +33 -0
- package/accordion-item/index.js +139 -0
- package/alert/index.d.ts +26 -0
- package/alert/index.js +91 -0
- package/alert-button/index.d.ts +23 -0
- package/alert-button/index.js +62 -0
- package/alert-close/index.d.ts +22 -0
- package/alert-close/index.js +41 -0
- package/button/index.d.ts +32 -0
- package/button/index.js +100 -0
- package/checkbox/index.d.ts +29 -0
- package/checkbox/index.js +134 -0
- package/help-tooltip/index.d.ts +15 -0
- package/help-tooltip/index.js +80 -0
- package/icon/cancel/index.d.ts +11 -0
- package/icon/cancel/index.js +4 -0
- package/icon/close/index.d.ts +11 -0
- package/icon/close/index.js +4 -0
- package/icon/create-icon-class.d.ts +308 -0
- package/icon/create-icon-class.js +53 -0
- package/icon/east/index.d.ts +11 -0
- package/icon/east/index.js +4 -0
- package/icon/help-outline/index.d.ts +11 -0
- package/icon/help-outline/index.js +4 -0
- package/icon/more-horiz/index.d.ts +11 -0
- package/icon/more-horiz/index.js +4 -0
- package/icon/more-vert/index.d.ts +11 -0
- package/icon/more-vert/index.js +4 -0
- package/icon/north/index.d.ts +11 -0
- package/icon/north/index.js +4 -0
- package/icon/north-east/index.d.ts +11 -0
- package/icon/north-east/index.js +4 -0
- package/icon/north-west/index.d.ts +11 -0
- package/icon/north-west/index.js +4 -0
- package/icon/open-in-new/index.d.ts +11 -0
- package/icon/open-in-new/index.js +4 -0
- package/icon/south/index.d.ts +11 -0
- package/icon/south/index.js +4 -0
- package/icon/south-east/index.d.ts +11 -0
- package/icon/south-east/index.js +4 -0
- package/icon/south-west/index.d.ts +11 -0
- package/icon/south-west/index.js +4 -0
- package/icon/types.d.ts +7 -0
- package/icon/types.js +1 -0
- package/icon/west/index.d.ts +11 -0
- package/icon/west/index.js +4 -0
- package/icon-branded/barchart-down/index.d.ts +11 -0
- package/icon-branded/barchart-down/index.js +4 -0
- package/icon-branded/barchart-up/index.d.ts +11 -0
- package/icon-branded/barchart-up/index.js +4 -0
- package/icon-branded/campaigns/index.d.ts +11 -0
- package/icon-branded/campaigns/index.js +4 -0
- package/icon-branded/chatbot/index.d.ts +11 -0
- package/icon-branded/chatbot/index.js +4 -0
- package/icon-branded/contact/index.d.ts +11 -0
- package/icon-branded/contact/index.js +4 -0
- package/icon-branded/create-icon-class.d.ts +309 -0
- package/icon-branded/create-icon-class.js +61 -0
- package/icon-branded/home/index.d.ts +11 -0
- package/icon-branded/home/index.js +4 -0
- package/icon-branded/multiple-channels/index.d.ts +11 -0
- package/icon-branded/multiple-channels/index.js +4 -0
- package/icon-branded/rocket/index.d.ts +11 -0
- package/icon-branded/rocket/index.js +4 -0
- package/icon-branded/settings/index.d.ts +11 -0
- package/icon-branded/settings/index.js +4 -0
- package/icon-branded/types.d.ts +9 -0
- package/icon-branded/types.js +1 -0
- package/icon-branded/user/index.d.ts +11 -0
- package/icon-branded/user/index.js +4 -0
- package/icon-branded/users/index.d.ts +11 -0
- package/icon-branded/users/index.js +4 -0
- package/index.d.ts +56 -0
- package/index.js +56 -0
- package/input/index.d.ts +35 -0
- package/input/index.js +203 -0
- package/link/index.d.ts +30 -0
- package/link/index.js +118 -0
- package/logo/create-logo-class.d.ts +309 -0
- package/logo/create-logo-class.js +63 -0
- package/logo/sinch-icon/index.d.ts +11 -0
- package/logo/sinch-icon/index.js +4 -0
- package/logo/sinch-icon-wordmark/index.d.ts +11 -0
- package/logo/sinch-icon-wordmark/index.js +4 -0
- package/logo/types.d.ts +9 -0
- package/logo/types.js +1 -0
- package/package.json +34 -0
- package/radio/index.d.ts +19 -0
- package/radio/index.js +185 -0
- package/radio-option/index.d.ts +28 -0
- package/radio-option/index.js +134 -0
- package/readme.md +172 -0
- package/select/index.d.ts +37 -0
- package/select/index.js +492 -0
- package/select-option/index.d.ts +27 -0
- package/select-option/index.js +107 -0
- package/spinner/index.d.ts +21 -0
- package/spinner/index.js +23 -0
- package/table/index.d.ts +13 -0
- package/table/index.js +18 -0
- package/table-body/index.d.ts +13 -0
- package/table-body/index.js +18 -0
- package/table-cell/index.d.ts +20 -0
- package/table-cell/index.js +27 -0
- package/table-head/index.d.ts +13 -0
- package/table-head/index.js +18 -0
- package/table-head-cell/index.d.ts +24 -0
- package/table-head-cell/index.js +74 -0
- package/table-head-sort/index.d.ts +25 -0
- package/table-head-sort/index.js +92 -0
- package/table-row/index.d.ts +17 -0
- package/table-row/index.js +26 -0
- package/tabs/index.d.ts +19 -0
- package/tabs/index.js +181 -0
- package/tabs-option/index.d.ts +28 -0
- package/tabs-option/index.js +129 -0
- package/tag/index.d.ts +27 -0
- package/tag/index.js +79 -0
- package/tag-close/index.d.ts +24 -0
- package/tag-close/index.js +70 -0
- package/textarea/index.d.ts +35 -0
- package/textarea/index.js +201 -0
- package/theme.css +112 -0
- package/toggle/index.d.ts +31 -0
- package/toggle/index.js +144 -0
- package/tooltip/index.d.ts +26 -0
- package/tooltip/index.js +68 -0
- package/types.d.ts +3 -0
- package/utils.d.ts +31 -0
- package/utils.js +146 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
|
+
|
|
3
|
+
var _onInput;
|
|
4
|
+
|
|
5
|
+
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
6
|
+
|
|
7
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
8
|
+
|
|
9
|
+
import { defineCustomElement, getAttribute, getBooleanAttribute, isAttrTrue, updateAttribute, updateBooleanAttribute } from '../utils';
|
|
10
|
+
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}*{pointer-events:none}#wrapper{display:flex;flex-direction:row;align-items:center;gap:12px;position:relative;width:100%;height:42px;padding:8px 20px;box-sizing:border-box;box-shadow:0 1px 0 0 var(--sinch-color-stormy-100);font:var(--sinch-font-body)}#content{flex-shrink:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}:host([checked]) #wrapper{box-shadow:0 2px 0 0 var(--sinch-color-stormy-500);font:var(--sinch-font-emphasized-body)}input{all:initial;position:absolute;left:0;top:0;box-sizing:border-box;width:100%;height:100%;cursor:pointer}:host([disabled]:not([disabled=false])) #wrapper{color:var(--sinch-color-stormy-100);--sinch-color-icon:var(--sinch-color-stormy-100)}input:disabled{cursor:unset}</style><div id="wrapper"><slot name="icon"></slot><span id="content"></span> <input type="radio"/></div>';
|
|
11
|
+
export const isTabsOptionElement = element => {
|
|
12
|
+
return element instanceof Element && element.tagName === 'SINCH-TABS-OPTION';
|
|
13
|
+
};
|
|
14
|
+
const template = document.createElement('template');
|
|
15
|
+
template.innerHTML = templateHTML;
|
|
16
|
+
defineCustomElement('sinch-tabs-option', (_onInput = new WeakMap(), class extends HTMLElement {
|
|
17
|
+
constructor() {
|
|
18
|
+
super();
|
|
19
|
+
|
|
20
|
+
_classPrivateFieldInitSpec(this, _onInput, {
|
|
21
|
+
writable: true,
|
|
22
|
+
value: e => {
|
|
23
|
+
e.stopPropagation();
|
|
24
|
+
this.$input.checked = false;
|
|
25
|
+
this.dispatchEvent(new CustomEvent('change', {
|
|
26
|
+
bubbles: true,
|
|
27
|
+
detail: this.value
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const shadowRoot = this.attachShadow({
|
|
33
|
+
mode: 'production' === 'development' ? 'open' : 'closed',
|
|
34
|
+
delegatesFocus: true
|
|
35
|
+
});
|
|
36
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
37
|
+
this.$input = shadowRoot.querySelector('input');
|
|
38
|
+
this.$label = shadowRoot.querySelector('#content');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
connectedCallback() {
|
|
42
|
+
this.$input.addEventListener('input', _classPrivateFieldGet(this, _onInput));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
disconnectedCallback() {
|
|
46
|
+
this.$input.removeEventListener('input', _classPrivateFieldGet(this, _onInput));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static get observedAttributes() {
|
|
50
|
+
return ['checked', 'disabled', 'text', 'value'];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
set checked(isChecked) {
|
|
54
|
+
updateBooleanAttribute(this, 'checked', isChecked);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
get checked() {
|
|
58
|
+
return getBooleanAttribute(this, 'checked');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
set value(value) {
|
|
62
|
+
updateAttribute(this, 'value', value);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
get value() {
|
|
66
|
+
return getAttribute(this, 'value', '');
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
set disabled(isDisabled) {
|
|
70
|
+
updateBooleanAttribute(this, 'disabled', isDisabled);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
get disabled() {
|
|
74
|
+
return getBooleanAttribute(this, 'disabled');
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
set text(value) {
|
|
78
|
+
updateAttribute(this, 'text', value);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
get text() {
|
|
82
|
+
return getAttribute(this, 'text', '');
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
attributeChangedCallback(name, _, newVal) {
|
|
86
|
+
switch (name) {
|
|
87
|
+
case 'text':
|
|
88
|
+
{
|
|
89
|
+
this.$label.textContent = newVal;
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
case 'checked':
|
|
94
|
+
{
|
|
95
|
+
const isChecked = isAttrTrue(newVal);
|
|
96
|
+
this.$input.checked = isChecked;
|
|
97
|
+
|
|
98
|
+
if (isChecked) {
|
|
99
|
+
this.scrollIntoView?.({
|
|
100
|
+
block: 'nearest'
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
case 'disabled':
|
|
108
|
+
{
|
|
109
|
+
this.$input.disabled = isAttrTrue(newVal);
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
case 'value':
|
|
114
|
+
{
|
|
115
|
+
this.$input.value = newVal ?? '';
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
focus() {
|
|
122
|
+
this.$input.focus();
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
blur() {
|
|
126
|
+
this.$input.blur();
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
}));
|
package/tag/index.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import '../icon/cancel';
|
|
2
|
+
import type { TSinchElementReact } from '../types';
|
|
3
|
+
declare const categoryValues: readonly ["candy", "bolt", "aqua", "grass", "berry", "orange", "night", "mud", "dirt"];
|
|
4
|
+
export declare type TSinchTagCategory = typeof categoryValues[number];
|
|
5
|
+
export declare type TSinchTagElement = HTMLElement & {
|
|
6
|
+
category: TSinchTagCategory | null;
|
|
7
|
+
text: string;
|
|
8
|
+
inverted: boolean;
|
|
9
|
+
small: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare type TSinchTagReact = TSinchElementReact<TSinchTagElement> & {
|
|
12
|
+
category?: TSinchTagCategory;
|
|
13
|
+
text: string;
|
|
14
|
+
inverted?: boolean;
|
|
15
|
+
small?: boolean;
|
|
16
|
+
};
|
|
17
|
+
declare global {
|
|
18
|
+
namespace JSX {
|
|
19
|
+
interface IntrinsicElements {
|
|
20
|
+
'sinch-tag': TSinchTagReact;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
interface HTMLElementTagNameMap {
|
|
24
|
+
'sinch-tag': TSinchTagElement;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export {};
|
package/tag/index.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
|
+
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
|
+
|
|
4
|
+
var _$text;
|
|
5
|
+
|
|
6
|
+
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
7
|
+
|
|
8
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
9
|
+
|
|
10
|
+
import '../icon/cancel';
|
|
11
|
+
import { defineCustomElement, getBooleanAttribute, getAttribute, getLiteralAttribute, updateBooleanAttribute, updateAttribute, updateLiteralAttribute } from '../utils';
|
|
12
|
+
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{display:flex;flex-direction:row;align-items:center;gap:4px;position:relative;padding:2px 8px;border-radius:12px;font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-default);background-color:var(--sinch-color-snow-600);width:100%;height:24px;box-sizing:border-box;--sinch-color-icon:var(--sinch-color-stormy-400)}:host([category=candy])>#wrapper{background-color:var(--sinch-color-candy-200)}:host([category=bolt])>#wrapper{background-color:var(--sinch-color-bolt-200)}:host([category=aqua])>#wrapper{background-color:var(--sinch-color-aqua-200)}:host([category=grass])>#wrapper{background-color:var(--sinch-color-grass-200)}:host([category=berry])>#wrapper{background-color:var(--sinch-color-berry-200)}:host([category=orange])>#wrapper{background-color:var(--sinch-color-orange-200)}:host([category=night])>#wrapper{background-color:var(--sinch-color-night-200)}:host([category=mud])>#wrapper{background-color:var(--sinch-color-mud-200)}:host([category=dirt])>#wrapper{background-color:var(--sinch-color-dirt-200)}:host([inverted]:not([inverted=false]))>#wrapper{background-color:var(--sinch-color-stormy-500);color:var(--sinch-color-snow-100);--sinch-color-icon:var(--sinch-color-snow-100)}:host([small]:not([small=false])) #wrapper{height:20px;border-radius:10px;padding:0 8px}#text{text-overflow:ellipsis;white-space:nowrap;overflow:auto;flex:1}</style><div id="wrapper"><slot name="icon"></slot><span id="text"></span><slot name="close"></slot></div>';
|
|
13
|
+
const categoryValues = ['candy', 'bolt', 'aqua', 'grass', 'berry', 'orange', 'night', 'mud', 'dirt'];
|
|
14
|
+
const template = document.createElement('template');
|
|
15
|
+
template.innerHTML = templateHTML;
|
|
16
|
+
defineCustomElement('sinch-tag', (_$text = new WeakMap(), class extends HTMLElement {
|
|
17
|
+
constructor() {
|
|
18
|
+
super();
|
|
19
|
+
|
|
20
|
+
_classPrivateFieldInitSpec(this, _$text, {
|
|
21
|
+
writable: true,
|
|
22
|
+
value: void 0
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const shadowRoot = this.attachShadow({
|
|
26
|
+
mode: 'production' === 'development' ? 'open' : 'closed'
|
|
27
|
+
});
|
|
28
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
29
|
+
|
|
30
|
+
_classPrivateFieldSet(this, _$text, shadowRoot.querySelector('#text'));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
get category() {
|
|
34
|
+
return getLiteralAttribute(this, categoryValues, 'category', null);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
set category(value) {
|
|
38
|
+
updateLiteralAttribute(this, categoryValues, 'category', value);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
get text() {
|
|
42
|
+
return getAttribute(this, 'text', '');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
set text(value) {
|
|
46
|
+
updateAttribute(this, 'text', value);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
get inverted() {
|
|
50
|
+
return getBooleanAttribute(this, 'inverted');
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
set inverted(isInverted) {
|
|
54
|
+
updateBooleanAttribute(this, 'inverted', isInverted);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
get small() {
|
|
58
|
+
return getBooleanAttribute(this, 'small');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
set small(isSmall) {
|
|
62
|
+
updateBooleanAttribute(this, 'small', isSmall);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
static get observedAttributes() {
|
|
66
|
+
return ['text'];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
attributeChangedCallback(name, _, newVal) {
|
|
70
|
+
switch (name) {
|
|
71
|
+
case 'text':
|
|
72
|
+
{
|
|
73
|
+
_classPrivateFieldGet(this, _$text).textContent = newVal;
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
}));
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import '../icon/cancel';
|
|
2
|
+
import type { TSinchElementReact } from '../types';
|
|
3
|
+
import type { FocusEvent, MouseEvent } from 'react';
|
|
4
|
+
export declare type TSinchTagCloseElement = HTMLElement & {
|
|
5
|
+
small: boolean;
|
|
6
|
+
focus(): void;
|
|
7
|
+
blur(): void;
|
|
8
|
+
};
|
|
9
|
+
export declare type TSinchTagCloseReact = TSinchElementReact<TSinchTagCloseElement> & {
|
|
10
|
+
small?: boolean;
|
|
11
|
+
onClick?: (e: MouseEvent<TSinchTagCloseElement>) => void;
|
|
12
|
+
onFocus?: (e: FocusEvent<TSinchTagCloseElement>) => void;
|
|
13
|
+
onBlur?: (e: FocusEvent<TSinchTagCloseElement>) => void;
|
|
14
|
+
};
|
|
15
|
+
declare global {
|
|
16
|
+
namespace JSX {
|
|
17
|
+
interface IntrinsicElements {
|
|
18
|
+
'sinch-tag-close': TSinchTagCloseReact;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
interface HTMLElementTagNameMap {
|
|
22
|
+
'sinch-tag-close': TSinchTagCloseElement;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
|
+
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
|
+
|
|
4
|
+
var _$icon, _$button;
|
|
5
|
+
|
|
6
|
+
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
7
|
+
|
|
8
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
9
|
+
|
|
10
|
+
import '../icon/cancel';
|
|
11
|
+
import { defineCustomElement, getBooleanAttribute, updateAttribute, isAttrTrue } from '../utils';
|
|
12
|
+
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{position:relative;width:14px;height:14px}:host([small]:not([small=false])) #wrapper{width:12px;height:12px}button{all:initial;position:absolute;display:flex;align-items:center;justify-content:center;width:24px;height:24px;box-sizing:border-box;left:50%;top:50%;transform:translateX(-50%) translateY(-50%);cursor:pointer}button>*{pointer-events:none}</style><div id="wrapper"><button><sinch-icon-cancel></sinch-icon-cancel></button></div>';
|
|
13
|
+
const template = document.createElement('template');
|
|
14
|
+
template.innerHTML = templateHTML;
|
|
15
|
+
defineCustomElement('sinch-tag-close', (_$icon = new WeakMap(), _$button = new WeakMap(), class extends HTMLElement {
|
|
16
|
+
constructor() {
|
|
17
|
+
super();
|
|
18
|
+
|
|
19
|
+
_classPrivateFieldInitSpec(this, _$icon, {
|
|
20
|
+
writable: true,
|
|
21
|
+
value: void 0
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
_classPrivateFieldInitSpec(this, _$button, {
|
|
25
|
+
writable: true,
|
|
26
|
+
value: void 0
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const shadowRoot = this.attachShadow({
|
|
30
|
+
mode: 'production' === 'development' ? 'open' : 'closed',
|
|
31
|
+
delegatesFocus: true
|
|
32
|
+
});
|
|
33
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
34
|
+
|
|
35
|
+
_classPrivateFieldSet(this, _$icon, shadowRoot.querySelector('sinch-icon-cancel'));
|
|
36
|
+
|
|
37
|
+
_classPrivateFieldSet(this, _$button, shadowRoot.querySelector('button'));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
get small() {
|
|
41
|
+
return getBooleanAttribute(this, 'small');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
set small(isSmall) {
|
|
45
|
+
updateAttribute(this, 'small', isSmall);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
static get observedAttributes() {
|
|
49
|
+
return ['small'];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
attributeChangedCallback(name, _, newVal) {
|
|
53
|
+
switch (name) {
|
|
54
|
+
case 'small':
|
|
55
|
+
{
|
|
56
|
+
updateAttribute(_classPrivateFieldGet(this, _$icon), 'size', isAttrTrue(newVal) ? 12 : 14);
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
focus() {
|
|
63
|
+
_classPrivateFieldGet(this, _$button).focus();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
blur() {
|
|
67
|
+
_classPrivateFieldGet(this, _$button).blur();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
}));
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { TSinchElementReact } from '../types';
|
|
2
|
+
import type { FocusEvent, SyntheticEvent } from 'react';
|
|
3
|
+
export declare type TSinchTextareaElement = HTMLElement & {
|
|
4
|
+
value: string;
|
|
5
|
+
label: string;
|
|
6
|
+
placeholder: string | null;
|
|
7
|
+
optionalText: string | null;
|
|
8
|
+
invalidText: string | null;
|
|
9
|
+
additionalText: string | null;
|
|
10
|
+
disabled: boolean;
|
|
11
|
+
focus(): void;
|
|
12
|
+
blur(): void;
|
|
13
|
+
};
|
|
14
|
+
export declare type TSinchTextareaReact = TSinchElementReact<TSinchTextareaElement> & {
|
|
15
|
+
value: string;
|
|
16
|
+
label: string;
|
|
17
|
+
placeholder?: string;
|
|
18
|
+
optionalText?: string;
|
|
19
|
+
invalidText?: string;
|
|
20
|
+
additionalText?: string;
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
onChange: (e: SyntheticEvent<TSinchTextareaElement, CustomEvent<string>>) => void;
|
|
23
|
+
onFocus?: (e: FocusEvent<TSinchTextareaElement>) => void;
|
|
24
|
+
onBlur?: (e: FocusEvent<TSinchTextareaElement>) => void;
|
|
25
|
+
};
|
|
26
|
+
declare global {
|
|
27
|
+
namespace JSX {
|
|
28
|
+
interface IntrinsicElements {
|
|
29
|
+
'sinch-textarea': TSinchTextareaReact;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
interface HTMLElementTagNameMap {
|
|
33
|
+
'sinch-textarea': TSinchTextareaElement;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
|
+
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
|
+
|
|
4
|
+
var _$input, _$label, _$optionalText, _$additionalText, _$invalidText, _onInput;
|
|
5
|
+
|
|
6
|
+
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
7
|
+
|
|
8
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
9
|
+
|
|
10
|
+
import { defineCustomElement, getAttribute, getBooleanAttribute, isAttrTrue, updateAttribute, updateBooleanAttribute } from '../utils';
|
|
11
|
+
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{width:100%;box-sizing:border-box}#input{all:initial;border:1px solid var(--sinch-color-stormy-200);box-sizing:border-box;border-radius:2px;width:100%;min-height:86px;margin:2px 0;padding:8px 12px;font:var(--sinch-font-body);color:var(--sinch-color-text-default);caret-color:var(--sinch-caret-color,auto);resize:vertical}#input::placeholder{font:var(--sinch-font-body);color:var(--sinch-color-text-muted)}#input:disabled{border-color:var(--sinch-color-snow-500);color:var(--sinch-color-stormy-100)}#input:disabled::placeholder{color:var(--sinch-color-snow-500)}#input:focus{border-color:var(--sinch-color-stormy-300)}:host([invalidtext]:not([invalidtext=""])) #input:not(:disabled){border-color:var(--sinch-color-text-invalid)}#bottom,#top{display:flex;align-items:baseline}#top{height:24px}#bottom{height:20px}#additional,#invalid,#label,#optional{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#label{font:var(--sinch-font-title-4);color:var(--sinch-color-text-default)}#optional{flex:1;text-align:right;font:var(--sinch-font-small-text);color:var(--sinch-color-text-muted)}#additional{flex:1;text-align:right;font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-muted)}#invalid{font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-invalid)}::slotted(sinch-help-tooltip){align-self:center;margin:0 8px}:host([disabled]:not([disabled=false])) :is(#label,#additional,#optional,#invalid){color:var(--sinch-color-stormy-100)}:host([disabled]:not([disabled=false])) ::slotted(sinch-help-tooltip){fill:var(--sinch-color-stormy-100)}</style><div id="wrapper"><div id="top"><label id="label" for="input"></label><slot name="tooltip"></slot><span id="optional"></span></div><textarea id="input" rows="3"></textarea><div id="bottom"><span id="invalid"></span> <span id="additional"></span></div></div>';
|
|
12
|
+
const template = document.createElement('template');
|
|
13
|
+
template.innerHTML = templateHTML;
|
|
14
|
+
defineCustomElement('sinch-textarea', (_$input = new WeakMap(), _$label = new WeakMap(), _$optionalText = new WeakMap(), _$additionalText = new WeakMap(), _$invalidText = new WeakMap(), _onInput = new WeakMap(), class extends HTMLElement {
|
|
15
|
+
constructor() {
|
|
16
|
+
super();
|
|
17
|
+
|
|
18
|
+
_classPrivateFieldInitSpec(this, _$input, {
|
|
19
|
+
writable: true,
|
|
20
|
+
value: void 0
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
_classPrivateFieldInitSpec(this, _$label, {
|
|
24
|
+
writable: true,
|
|
25
|
+
value: void 0
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
_classPrivateFieldInitSpec(this, _$optionalText, {
|
|
29
|
+
writable: true,
|
|
30
|
+
value: void 0
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
_classPrivateFieldInitSpec(this, _$additionalText, {
|
|
34
|
+
writable: true,
|
|
35
|
+
value: void 0
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
_classPrivateFieldInitSpec(this, _$invalidText, {
|
|
39
|
+
writable: true,
|
|
40
|
+
value: void 0
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
_classPrivateFieldInitSpec(this, _onInput, {
|
|
44
|
+
writable: true,
|
|
45
|
+
value: e => {
|
|
46
|
+
e.stopPropagation();
|
|
47
|
+
|
|
48
|
+
const value = _classPrivateFieldGet(this, _$input).value;
|
|
49
|
+
|
|
50
|
+
_classPrivateFieldGet(this, _$input).value = this.value;
|
|
51
|
+
this.dispatchEvent(new CustomEvent('change', {
|
|
52
|
+
detail: value,
|
|
53
|
+
bubbles: true
|
|
54
|
+
}));
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const shadowRoot = this.attachShadow({
|
|
59
|
+
mode: 'production' === 'development' ? 'open' : 'closed',
|
|
60
|
+
delegatesFocus: true
|
|
61
|
+
});
|
|
62
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
63
|
+
|
|
64
|
+
_classPrivateFieldSet(this, _$input, shadowRoot.querySelector('#input'));
|
|
65
|
+
|
|
66
|
+
_classPrivateFieldSet(this, _$label, shadowRoot.querySelector('#label'));
|
|
67
|
+
|
|
68
|
+
_classPrivateFieldSet(this, _$optionalText, shadowRoot.querySelector('#optional'));
|
|
69
|
+
|
|
70
|
+
_classPrivateFieldSet(this, _$additionalText, shadowRoot.querySelector('#additional'));
|
|
71
|
+
|
|
72
|
+
_classPrivateFieldSet(this, _$invalidText, shadowRoot.querySelector('#invalid'));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
connectedCallback() {
|
|
76
|
+
_classPrivateFieldGet(this, _$input).addEventListener('input', _classPrivateFieldGet(this, _onInput));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
disconnectedCallback() {
|
|
80
|
+
_classPrivateFieldGet(this, _$input).removeEventListener('input', _classPrivateFieldGet(this, _onInput));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
static get observedAttributes() {
|
|
84
|
+
return ['value', 'placeholder', 'label', 'optionaltext', 'additionaltext', 'invalidtext', 'disabled'];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
attributeChangedCallback(name, _, newVal) {
|
|
88
|
+
switch (name) {
|
|
89
|
+
case 'value':
|
|
90
|
+
{
|
|
91
|
+
_classPrivateFieldGet(this, _$input).value = newVal ?? '';
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
case 'label':
|
|
96
|
+
{
|
|
97
|
+
_classPrivateFieldGet(this, _$label).textContent = newVal;
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
case 'placeholder':
|
|
102
|
+
{
|
|
103
|
+
_classPrivateFieldGet(this, _$input).placeholder = newVal ?? '';
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
case 'optionaltext':
|
|
108
|
+
{
|
|
109
|
+
_classPrivateFieldGet(this, _$optionalText).textContent = newVal;
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
case 'additionaltext':
|
|
114
|
+
{
|
|
115
|
+
_classPrivateFieldGet(this, _$additionalText).textContent = newVal;
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
case 'invalidtext':
|
|
120
|
+
{
|
|
121
|
+
_classPrivateFieldGet(this, _$invalidText).textContent = newVal;
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
case 'disabled':
|
|
126
|
+
{
|
|
127
|
+
_classPrivateFieldGet(this, _$input).disabled = isAttrTrue(newVal);
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
get nodeName() {
|
|
134
|
+
return 'textarea';
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
set value(value) {
|
|
138
|
+
updateAttribute(this, 'value', value);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
get value() {
|
|
142
|
+
return getAttribute(this, 'value', '');
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
set placeholder(value) {
|
|
146
|
+
updateAttribute(this, 'placeholder', value);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
get placeholder() {
|
|
150
|
+
return getAttribute(this, 'placeholder', null);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
set label(value) {
|
|
154
|
+
updateAttribute(this, 'label', value);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
get label() {
|
|
158
|
+
return getAttribute(this, 'label', '');
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
set optionalText(value) {
|
|
162
|
+
updateAttribute(this, 'optionaltext', value);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
get optionalText() {
|
|
166
|
+
return getAttribute(this, 'optionaltext', null);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
set additionalText(value) {
|
|
170
|
+
updateAttribute(this, 'additionaltext', value);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
get additionalText() {
|
|
174
|
+
return getAttribute(this, 'additionaltext', null);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
set invalidText(value) {
|
|
178
|
+
updateAttribute(this, 'invalidtext', value);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
get invalidText() {
|
|
182
|
+
return getAttribute(this, 'invalidtext', null);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
set disabled(isDisabled) {
|
|
186
|
+
updateBooleanAttribute(this, 'disabled', isDisabled);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
get disabled() {
|
|
190
|
+
return getBooleanAttribute(this, 'disabled');
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
focus() {
|
|
194
|
+
_classPrivateFieldGet(this, _$input).focus();
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
blur() {
|
|
198
|
+
_classPrivateFieldGet(this, _$input).blur();
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
}));
|
package/theme.css
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--sinch-theme: 1;
|
|
3
|
+
--sinch-color-honey-700: #CC8800;
|
|
4
|
+
--sinch-color-honey-600: #FFAA00;
|
|
5
|
+
--sinch-color-honey-500: #FFBE3C;
|
|
6
|
+
--sinch-color-honey-400: #FFCC66;
|
|
7
|
+
--sinch-color-honey-300: #FFDD99;
|
|
8
|
+
--sinch-color-honey-200: #FFEECC;
|
|
9
|
+
--sinch-color-honey-100: #FFF7E6;
|
|
10
|
+
--sinch-color-tropical-700: #003D3D;
|
|
11
|
+
--sinch-color-tropical-600: #005757;
|
|
12
|
+
--sinch-color-tropical-500: #007171;
|
|
13
|
+
--sinch-color-tropical-400: #338D8D;
|
|
14
|
+
--sinch-color-tropical-300: #66AAAA;
|
|
15
|
+
--sinch-color-tropical-200: #99C6C6;
|
|
16
|
+
--sinch-color-tropical-100: #CCE3E3;
|
|
17
|
+
--sinch-color-stormy-600: #061927;
|
|
18
|
+
--sinch-color-stormy-500: #0A273D;
|
|
19
|
+
--sinch-color-stormy-400: #3B5264;
|
|
20
|
+
--sinch-color-stormy-300: #677784;
|
|
21
|
+
--sinch-color-stormy-200: #7F8F99;
|
|
22
|
+
--sinch-color-stormy-100: #9CA8B0;
|
|
23
|
+
--sinch-color-snow-800: #C6CDD2;
|
|
24
|
+
--sinch-color-snow-700: #D4DADD;
|
|
25
|
+
--sinch-color-snow-600: #E3E6E8;
|
|
26
|
+
--sinch-color-snow-500: #F1F3F4;
|
|
27
|
+
--sinch-color-snow-100: #FFFFFF;
|
|
28
|
+
--sinch-color-raspberry-700: #881125;
|
|
29
|
+
--sinch-color-raspberry-600: #B61631;
|
|
30
|
+
--sinch-color-raspberry-500: #E31C3D;
|
|
31
|
+
--sinch-color-raspberry-400: #E94964;
|
|
32
|
+
--sinch-color-raspberry-300: #EE778B;
|
|
33
|
+
--sinch-color-raspberry-200: #F4A4B1;
|
|
34
|
+
--sinch-color-raspberry-100: #F9D2D8;
|
|
35
|
+
--sinch-color-text-default: #0A273D;
|
|
36
|
+
--sinch-color-text-inverted: #FFFFFF;
|
|
37
|
+
--sinch-color-text-muted: #677784;
|
|
38
|
+
--sinch-color-text-link: #007171;
|
|
39
|
+
--sinch-color-text-invalid: #E31C3D;
|
|
40
|
+
--sinch-color-error-800: #57000E;
|
|
41
|
+
--sinch-color-error-500: #E31C3D;
|
|
42
|
+
--sinch-color-error-200: #FCD7D4;
|
|
43
|
+
--sinch-color-success-700: #005419;
|
|
44
|
+
--sinch-color-success-500: #2E8540;
|
|
45
|
+
--sinch-color-success-200: #D7F1D8;
|
|
46
|
+
--sinch-color-informative-700: #003B7E;
|
|
47
|
+
--sinch-color-informative-500: #2071CE;
|
|
48
|
+
--sinch-color-informative-200: #D5E5F8;
|
|
49
|
+
--sinch-color-warning-700: #9C2E00;
|
|
50
|
+
--sinch-color-warning-500: #F35B1C;
|
|
51
|
+
--sinch-color-warning-200: #FFE8D6;
|
|
52
|
+
--sinch-color-night-400: #3247E9;
|
|
53
|
+
--sinch-color-night-200: #D1D6FA;
|
|
54
|
+
--sinch-color-aqua-400: #3DAED8;
|
|
55
|
+
--sinch-color-aqua-200: #AADBEE;
|
|
56
|
+
--sinch-color-grass-400: #39B93D;
|
|
57
|
+
--sinch-color-grass-200: #B4E4B5;
|
|
58
|
+
--sinch-color-dirt-400: #828282;
|
|
59
|
+
--sinch-color-dirt-200: #E0DDDC;
|
|
60
|
+
--sinch-color-berry-400: #F95252;
|
|
61
|
+
--sinch-color-berry-200: #FCA7A7;
|
|
62
|
+
--sinch-color-candy-400: #E467C3;
|
|
63
|
+
--sinch-color-candy-200: #F6CBEA;
|
|
64
|
+
--sinch-color-mud-400: #8B6559;
|
|
65
|
+
--sinch-color-mud-200: #D7C6C1;
|
|
66
|
+
--sinch-color-orange-400: #FF8C34;
|
|
67
|
+
--sinch-color-orange-200: #FFD4B3;
|
|
68
|
+
--sinch-color-bolt-400: #FFBE3C;
|
|
69
|
+
--sinch-color-bolt-200: #FFE6B3;
|
|
70
|
+
--sinch-color-transparent: transparent;
|
|
71
|
+
--sinch-font-hero: 700 56px/72px "Gilroy", "Arial", "sans-serif";
|
|
72
|
+
--sinch-font-title-1: 600 40px/48px "Gilroy", "Arial", "sans-serif";
|
|
73
|
+
--sinch-font-title-2: 600 24px/32px "Gilroy", "Arial", "sans-serif";
|
|
74
|
+
--sinch-font-title-3: 600 20px/24px "Gilroy", "Arial", "sans-serif";
|
|
75
|
+
--sinch-font-title-4: 600 16px/24px "Gilroy", "Arial", "sans-serif";
|
|
76
|
+
--sinch-font-title-5: 700 16px/24px "Gilroy", "Arial", "sans-serif";
|
|
77
|
+
--sinch-font-body: 400 16px/24px "Gilroy", "Arial", "sans-serif";
|
|
78
|
+
--sinch-font-emphasized-body: 600 16px/24px "Gilroy", "Arial", "sans-serif";
|
|
79
|
+
--sinch-font-small-text: 400 14px/22px "Gilroy", "Arial", "sans-serif";
|
|
80
|
+
--sinch-font-extra-small-text: 400 12px/20px "Gilroy", "Arial", "sans-serif";
|
|
81
|
+
--sinch-font-monospace: 400 16px/24px "monospace";
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
@font-face {
|
|
85
|
+
font-family: "Gilroy";
|
|
86
|
+
font-weight: 400;
|
|
87
|
+
font-style: normal;
|
|
88
|
+
src:
|
|
89
|
+
local("Gilroy-Regular"),
|
|
90
|
+
url("https://d2vu40klajma73.cloudfront.net/Gilroy-Regular.woff2") format("woff2"),
|
|
91
|
+
url("https://d2vu40klajma73.cloudfront.net/Gilroy-Regular.woff") format("woff");
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
@font-face {
|
|
95
|
+
font-family: "Gilroy";
|
|
96
|
+
font-weight: 600;
|
|
97
|
+
font-style: normal;
|
|
98
|
+
src:
|
|
99
|
+
local("Gilroy-SemiBold"),
|
|
100
|
+
url("https://d2vu40klajma73.cloudfront.net/Gilroy-SemiBold.woff2") format("woff2"),
|
|
101
|
+
url("https://d2vu40klajma73.cloudfront.net/Gilroy-SemiBold.woff") format("woff");
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
@font-face {
|
|
105
|
+
font-family: "Gilroy";
|
|
106
|
+
font-weight: 700;
|
|
107
|
+
font-style: normal;
|
|
108
|
+
src:
|
|
109
|
+
local("Gilroy-Bold"),
|
|
110
|
+
url("https://d2vu40klajma73.cloudfront.net/Gilroy-Bold.woff2") format("woff2"),
|
|
111
|
+
url("https://d2vu40klajma73.cloudfront.net/Gilroy-Bold.woff") format("woff");
|
|
112
|
+
}
|