@nectary/components 0.17.0 → 0.19.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-item/index.d.ts +3 -0
- package/accordion-item/index.js +26 -4
- package/avatar/index.d.ts +29 -0
- package/avatar/index.js +94 -0
- package/chat/index.d.ts +13 -0
- package/chat/index.js +15 -0
- package/chat-avatar/index.d.ts +21 -0
- package/chat-avatar/index.js +69 -0
- package/chat-block/index.d.ts +24 -0
- package/chat-block/index.js +148 -0
- package/chat-bubble/index.d.ts +20 -0
- package/chat-bubble/index.js +59 -0
- package/colors.json +69 -0
- package/dialog/index.js +3 -2
- package/dropdown/index.js +3 -1
- package/index.d.ts +5 -0
- package/index.js +6 -1
- package/input/index.d.ts +3 -0
- package/input/index.js +24 -0
- package/package.json +3 -2
- package/search/index.d.ts +1 -0
- package/search/index.js +2 -1
- package/textarea/index.d.ts +7 -0
- package/textarea/index.js +49 -3
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import '../icon/keyboard-arrow-down';
|
|
1
2
|
import type { TSinchElementReact } from '../types';
|
|
2
3
|
import type { FocusEvent } from 'react';
|
|
3
4
|
export declare const isAccordionItemElement: (element: EventTarget | Element | null) => element is TSinchAccordionItemElement;
|
|
@@ -6,6 +7,7 @@ export declare type TSinchAccordionStatusType = typeof statusValues[number];
|
|
|
6
7
|
export declare type TSinchAccordionItemElement = HTMLElement & {
|
|
7
8
|
value: string;
|
|
8
9
|
label: string;
|
|
10
|
+
optionalText: string | null;
|
|
9
11
|
disabled: boolean;
|
|
10
12
|
checked: boolean;
|
|
11
13
|
status: TSinchAccordionStatusType | null;
|
|
@@ -15,6 +17,7 @@ export declare type TSinchAccordionItemElement = HTMLElement & {
|
|
|
15
17
|
export declare type TSinchAccordionItemReact = TSinchElementReact<TSinchAccordionItemElement> & {
|
|
16
18
|
value: string;
|
|
17
19
|
label: string;
|
|
20
|
+
optionalText?: string;
|
|
18
21
|
disabled?: boolean;
|
|
19
22
|
status?: TSinchAccordionStatusType;
|
|
20
23
|
onFocus?: (e: FocusEvent<TSinchAccordionItemElement>) => void;
|
package/accordion-item/index.js
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
2
|
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
3
|
|
|
4
|
-
var _$button, _$buttonContent, _onButtonClick;
|
|
4
|
+
var _$button, _$buttonContent, _$optionalText, _onButtonClick;
|
|
5
5
|
|
|
6
6
|
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
7
7
|
|
|
8
8
|
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
9
9
|
|
|
10
|
+
import '../icon/keyboard-arrow-down';
|
|
10
11
|
import { defineCustomElement, getAttribute, getBooleanAttribute, getLiteralAttribute, isAttrTrue, updateAttribute, updateBooleanAttribute, updateLiteralAttribute } from '../utils';
|
|
11
|
-
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-color-stormy-200);--sinch-size-icon:16px}#button{all:initial;cursor:pointer;display:flex;align-items:center;gap:8px;box-sizing:border-box;width:100%;height:48px;padding:12px 8px;font:var(--sinch-font-title-4);color:var(--sinch-color-text-default);fill:var(--sinch-color-stormy-500)}#button>*{pointer-events:none}#button:disabled{cursor:initial;color:var(--sinch-color-stormy-100);fill:var(--sinch-color-stormy-100)}#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-color-success-500)}:host([status=warn]) #button::before{content:"";background-color:var(--sinch-color-warning-500)}:host([status=error]) #button::before{content:"";background-color:var(--sinch-color-error-500)}:host([status=info]) #button::before{content:"";background-color:var(--sinch-color-informative-500)}#title{flex:1;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}#content{display:none;overflow-y:auto;flex-shrink:1;min-height:0;padding:0 8px 18px;font:var(--sinch-font-body);color:var(--sinch-color-text-default)}#button[aria-expanded=true]>#dropdown-icon{transform:rotate(180deg)}#button[aria-expanded=true]+#content{display:block}</style><div id="wrapper"><button id="button" aria-controls="content" aria-expanded="false"><slot name="icon"></slot><span id="title"></span> <
|
|
12
|
+
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-color-stormy-200);--sinch-size-icon:16px}#button{all:initial;cursor:pointer;display:flex;align-items:center;gap:8px;box-sizing:border-box;width:100%;height:48px;padding:12px 8px;font:var(--sinch-font-title-4);color:var(--sinch-color-text-default);fill:var(--sinch-color-stormy-500)}#button>*{pointer-events:none}#button:disabled{cursor:initial;color:var(--sinch-color-stormy-100);fill:var(--sinch-color-stormy-100)}#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-color-success-500)}:host([status=warn]) #button::before{content:"";background-color:var(--sinch-color-warning-500)}:host([status=error]) #button::before{content:"";background-color:var(--sinch-color-error-500)}:host([status=info]) #button::before{content:"";background-color:var(--sinch-color-informative-500)}#title{flex:1;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}#content{display:none;overflow-y:auto;flex-shrink:1;min-height:0;padding:0 8px 18px;font:var(--sinch-font-body);color:var(--sinch-color-text-default)}#dropdown-icon{--sinch-size-icon:24px}#button[aria-expanded=true]>#dropdown-icon{transform:rotate(180deg)}#button[aria-expanded=true]+#content{display:block}#optional{font:var(--sinch-font-small-text);color:var(--sinch-color-stormy-300)}</style><div id="wrapper"><button id="button" aria-controls="content" aria-expanded="false"><slot name="icon"></slot><span id="title"></span> <span id="optional"></span><sinch-icon-keyboard-arrow-down id="dropdown-icon"></sinch-icon-keyboard-arrow-down></button><div id="content" role="region" aria-labelledby="button"><slot name="content"></slot></div></div>';
|
|
12
13
|
export const isAccordionItemElement = element => {
|
|
13
14
|
return element instanceof Element && element.tagName === 'SINCH-ACCORDION-ITEM';
|
|
14
15
|
};
|
|
15
16
|
const statusValues = ['info', 'success', 'warn', 'error'];
|
|
16
17
|
const template = document.createElement('template');
|
|
17
18
|
template.innerHTML = templateHTML;
|
|
18
|
-
defineCustomElement('sinch-accordion-item', (_$button = new WeakMap(), _$buttonContent = new WeakMap(), _onButtonClick = new WeakMap(), class extends HTMLElement {
|
|
19
|
+
defineCustomElement('sinch-accordion-item', (_$button = new WeakMap(), _$buttonContent = new WeakMap(), _$optionalText = new WeakMap(), _onButtonClick = new WeakMap(), class extends HTMLElement {
|
|
19
20
|
constructor() {
|
|
20
21
|
super();
|
|
21
22
|
|
|
@@ -29,6 +30,11 @@ defineCustomElement('sinch-accordion-item', (_$button = new WeakMap(), _$buttonC
|
|
|
29
30
|
value: void 0
|
|
30
31
|
});
|
|
31
32
|
|
|
33
|
+
_classPrivateFieldInitSpec(this, _$optionalText, {
|
|
34
|
+
writable: true,
|
|
35
|
+
value: void 0
|
|
36
|
+
});
|
|
37
|
+
|
|
32
38
|
_classPrivateFieldInitSpec(this, _onButtonClick, {
|
|
33
39
|
writable: true,
|
|
34
40
|
value: e => {
|
|
@@ -52,6 +58,8 @@ defineCustomElement('sinch-accordion-item', (_$button = new WeakMap(), _$buttonC
|
|
|
52
58
|
_classPrivateFieldSet(this, _$button, shadowRoot.querySelector('#button'));
|
|
53
59
|
|
|
54
60
|
_classPrivateFieldSet(this, _$buttonContent, shadowRoot.querySelector('#title'));
|
|
61
|
+
|
|
62
|
+
_classPrivateFieldSet(this, _$optionalText, shadowRoot.querySelector('#optional'));
|
|
55
63
|
}
|
|
56
64
|
|
|
57
65
|
connectedCallback() {
|
|
@@ -63,7 +71,7 @@ defineCustomElement('sinch-accordion-item', (_$button = new WeakMap(), _$buttonC
|
|
|
63
71
|
}
|
|
64
72
|
|
|
65
73
|
static get observedAttributes() {
|
|
66
|
-
return ['label', 'disabled', 'checked'];
|
|
74
|
+
return ['label', 'disabled', 'checked', 'optionaltext'];
|
|
67
75
|
}
|
|
68
76
|
|
|
69
77
|
set value(value) {
|
|
@@ -106,6 +114,14 @@ defineCustomElement('sinch-accordion-item', (_$button = new WeakMap(), _$buttonC
|
|
|
106
114
|
updateLiteralAttribute(this, statusValues, 'status', value);
|
|
107
115
|
}
|
|
108
116
|
|
|
117
|
+
set optionalText(value) {
|
|
118
|
+
updateAttribute(this, 'optionaltext', value);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
get optionalText() {
|
|
122
|
+
return getAttribute(this, 'optionaltext', null);
|
|
123
|
+
}
|
|
124
|
+
|
|
109
125
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
110
126
|
switch (name) {
|
|
111
127
|
case 'label':
|
|
@@ -125,6 +141,12 @@ defineCustomElement('sinch-accordion-item', (_$button = new WeakMap(), _$buttonC
|
|
|
125
141
|
updateAttribute(_classPrivateFieldGet(this, _$button), 'aria-expanded', isAttrTrue(newVal));
|
|
126
142
|
break;
|
|
127
143
|
}
|
|
144
|
+
|
|
145
|
+
case 'optionaltext':
|
|
146
|
+
{
|
|
147
|
+
_classPrivateFieldGet(this, _$optionalText).textContent = newVal;
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
128
150
|
}
|
|
129
151
|
}
|
|
130
152
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import '../icon/cancel';
|
|
2
|
+
import type { TSinchElementReact } from '../types';
|
|
3
|
+
declare const backgroundValues: readonly ["grey", "yellow", "blue"];
|
|
4
|
+
declare const sizeValues: readonly ["l", "m", "s"];
|
|
5
|
+
export declare type TSinchAvatarBackground = typeof backgroundValues[number];
|
|
6
|
+
export declare type TSinchAvatarSize = typeof sizeValues[number];
|
|
7
|
+
export declare type TSinchAvatarElement = HTMLElement & {
|
|
8
|
+
alt: string;
|
|
9
|
+
src: string | null;
|
|
10
|
+
background: TSinchAvatarBackground;
|
|
11
|
+
size: TSinchAvatarSize;
|
|
12
|
+
};
|
|
13
|
+
export declare type TSinchAvatarReact = TSinchElementReact<TSinchAvatarElement> & {
|
|
14
|
+
alt: string;
|
|
15
|
+
src?: string;
|
|
16
|
+
background?: TSinchAvatarBackground;
|
|
17
|
+
size?: TSinchAvatarSize;
|
|
18
|
+
};
|
|
19
|
+
declare global {
|
|
20
|
+
namespace JSX {
|
|
21
|
+
interface IntrinsicElements {
|
|
22
|
+
'sinch-avatar': TSinchAvatarReact;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
interface HTMLElementTagNameMap {
|
|
26
|
+
'sinch-avatar': TSinchAvatarElement;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export {};
|
package/avatar/index.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
|
+
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
|
+
|
|
4
|
+
var _$text, _$image;
|
|
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, getAttribute, getLiteralAttribute, updateAttribute, updateLiteralAttribute } from '../utils';
|
|
12
|
+
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{position:relative;width:32px;height:32px;font:var(--sinch-font-title-5);line-height:30px;color:var(--sinch-color-text-default);background-color:var(--sinch-color-snow-700);text-align:center;border-radius:50%;border:1px solid var(--sinch-color-snow-100);box-sizing:border-box;overflow:hidden}:host([background=blue]) #wrapper{background-color:var(--sinch-color-stormy-500);color:var(--sinch-color-snow-100)}:host([background=yellow]) #wrapper{background-color:var(--sinch-color-honey-500)}:host([size="l"]) #wrapper{width:40px;height:40px;font:var(--sinch-font-title-4);line-height:38px}:host([size="s"]) #wrapper{width:24px;height:24px;font:var(--sinch-font-extra-small-text);line-height:22px}#text{display:block;width:100%;height:100%;box-sizing:border-box}#image{display:none;width:100%;height:100%;object-fit:contain;position:absolute;left:0;top:0}:host([src]:not([src=""])) #image{display:block}</style><div id="wrapper"><span id="text"></span><img id="image" alt=""/></div>';
|
|
13
|
+
const backgroundValues = ['grey', 'yellow', 'blue'];
|
|
14
|
+
const sizeValues = ['l', 'm', 's'];
|
|
15
|
+
const template = document.createElement('template');
|
|
16
|
+
template.innerHTML = templateHTML;
|
|
17
|
+
defineCustomElement('sinch-avatar', (_$text = new WeakMap(), _$image = new WeakMap(), class extends HTMLElement {
|
|
18
|
+
constructor() {
|
|
19
|
+
super();
|
|
20
|
+
|
|
21
|
+
_classPrivateFieldInitSpec(this, _$text, {
|
|
22
|
+
writable: true,
|
|
23
|
+
value: void 0
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
_classPrivateFieldInitSpec(this, _$image, {
|
|
27
|
+
writable: true,
|
|
28
|
+
value: void 0
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const shadowRoot = this.attachShadow({
|
|
32
|
+
mode: 'closed'
|
|
33
|
+
});
|
|
34
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
35
|
+
|
|
36
|
+
_classPrivateFieldSet(this, _$text, shadowRoot.querySelector('#text'));
|
|
37
|
+
|
|
38
|
+
_classPrivateFieldSet(this, _$image, shadowRoot.querySelector('#image'));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
get src() {
|
|
42
|
+
return getAttribute(this, 'src', null);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
set src(value) {
|
|
46
|
+
updateAttribute(this, 'src', value);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
get alt() {
|
|
50
|
+
return getAttribute(this, 'alt', '');
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
set alt(value) {
|
|
54
|
+
updateAttribute(this, 'alt', value);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
get background() {
|
|
58
|
+
return getLiteralAttribute(this, backgroundValues, 'background', 'grey');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
set background(value) {
|
|
62
|
+
updateLiteralAttribute(this, backgroundValues, 'background', value);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
get size() {
|
|
66
|
+
return getLiteralAttribute(this, sizeValues, 'size', 'm');
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
set size(value) {
|
|
70
|
+
updateLiteralAttribute(this, sizeValues, 'size', value);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
static get observedAttributes() {
|
|
74
|
+
return ['alt', 'src'];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
attributeChangedCallback(name, _, newVal) {
|
|
78
|
+
switch (name) {
|
|
79
|
+
case 'alt':
|
|
80
|
+
{
|
|
81
|
+
_classPrivateFieldGet(this, _$text).textContent = newVal;
|
|
82
|
+
_classPrivateFieldGet(this, _$image).alt = newVal ?? '';
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
case 'src':
|
|
87
|
+
{
|
|
88
|
+
_classPrivateFieldGet(this, _$image).src = newVal ?? '';
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
}));
|
package/chat/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { TSinchElementReact } from '../types';
|
|
2
|
+
export declare type TSinchChatElement = HTMLElement & {};
|
|
3
|
+
export declare type TSinchChatReact = TSinchElementReact<TSinchChatElement> & {};
|
|
4
|
+
declare global {
|
|
5
|
+
namespace JSX {
|
|
6
|
+
interface IntrinsicElements {
|
|
7
|
+
'sinch-chat': TSinchChatReact;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
interface HTMLElementTagNameMap {
|
|
11
|
+
'sinch-chat': TSinchChatElement;
|
|
12
|
+
}
|
|
13
|
+
}
|
package/chat/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { defineCustomElement } from '../utils';
|
|
2
|
+
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{display:flex;flex-direction:column;gap:32px;box-sizing:border-box;width:100%}</style><div id="wrapper"><slot></slot></div>';
|
|
3
|
+
const template = document.createElement('template');
|
|
4
|
+
template.innerHTML = templateHTML;
|
|
5
|
+
defineCustomElement('sinch-chat', class extends HTMLElement {
|
|
6
|
+
constructor() {
|
|
7
|
+
super();
|
|
8
|
+
const shadowRoot = this.attachShadow({
|
|
9
|
+
mode: 'closed',
|
|
10
|
+
delegatesFocus: true
|
|
11
|
+
});
|
|
12
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import '../avatar';
|
|
2
|
+
import type { TSinchAvatarElement, TSinchAvatarReact } from '../avatar';
|
|
3
|
+
import type { TSinchElementReact } from '../types';
|
|
4
|
+
export declare type TSinchChatAvatarElement = HTMLElement & {
|
|
5
|
+
alt: TSinchAvatarElement['alt'];
|
|
6
|
+
src: TSinchAvatarElement['src'];
|
|
7
|
+
};
|
|
8
|
+
export declare type TSinchChatAvatarReact = TSinchElementReact<TSinchChatAvatarElement> & {
|
|
9
|
+
alt: TSinchAvatarReact['alt'];
|
|
10
|
+
src?: TSinchAvatarReact['src'];
|
|
11
|
+
};
|
|
12
|
+
declare global {
|
|
13
|
+
namespace JSX {
|
|
14
|
+
interface IntrinsicElements {
|
|
15
|
+
'sinch-chat-avatar': TSinchChatAvatarReact;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
interface HTMLElementTagNameMap {
|
|
19
|
+
'sinch-chat-avatar': TSinchChatAvatarElement;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
|
+
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
|
+
|
|
4
|
+
var _$avatar;
|
|
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 '../avatar';
|
|
11
|
+
import { defineCustomElement, getAttribute, updateAttribute } from '../utils';
|
|
12
|
+
const templateHTML = '<style>:host{display:contents}</style><sinch-avatar background="blue" size="l"></sinch-avatar>';
|
|
13
|
+
const template = document.createElement('template');
|
|
14
|
+
template.innerHTML = templateHTML;
|
|
15
|
+
defineCustomElement('sinch-chat-avatar', (_$avatar = new WeakMap(), class extends HTMLElement {
|
|
16
|
+
constructor() {
|
|
17
|
+
super();
|
|
18
|
+
|
|
19
|
+
_classPrivateFieldInitSpec(this, _$avatar, {
|
|
20
|
+
writable: true,
|
|
21
|
+
value: void 0
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const shadowRoot = this.attachShadow({
|
|
25
|
+
mode: 'closed',
|
|
26
|
+
delegatesFocus: true
|
|
27
|
+
});
|
|
28
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
29
|
+
|
|
30
|
+
_classPrivateFieldSet(this, _$avatar, shadowRoot.querySelector('sinch-avatar'));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
static get observedAttributes() {
|
|
34
|
+
return ['src', 'alt'];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
attributeChangedCallback(name, _, newVal) {
|
|
38
|
+
switch (name) {
|
|
39
|
+
case 'src':
|
|
40
|
+
{
|
|
41
|
+
updateAttribute(_classPrivateFieldGet(this, _$avatar), 'src', newVal);
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
case 'alt':
|
|
46
|
+
{
|
|
47
|
+
updateAttribute(_classPrivateFieldGet(this, _$avatar), 'alt', newVal);
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
get src() {
|
|
54
|
+
return getAttribute(this, 'src', null);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
set src(value) {
|
|
58
|
+
updateAttribute(this, 'src', value);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
get alt() {
|
|
62
|
+
return getAttribute(this, 'alt', '');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
set alt(value) {
|
|
66
|
+
updateAttribute(this, 'alt', value);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
}));
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { TSinchChatBubbleType } from '../chat-bubble';
|
|
2
|
+
import type { TSinchElementReact } from '../types';
|
|
3
|
+
export declare type TSinchChatBlockElement = HTMLElement & {
|
|
4
|
+
type: TSinchChatBubbleType | null;
|
|
5
|
+
firstName: string | null;
|
|
6
|
+
lastName: string | null;
|
|
7
|
+
timestamp: string | null;
|
|
8
|
+
};
|
|
9
|
+
export declare type TSinchChatBlockReact = TSinchElementReact<TSinchChatBlockElement> & {
|
|
10
|
+
type: TSinchChatBubbleType;
|
|
11
|
+
firstName?: string;
|
|
12
|
+
lastName?: string;
|
|
13
|
+
timestamp?: string;
|
|
14
|
+
};
|
|
15
|
+
declare global {
|
|
16
|
+
namespace JSX {
|
|
17
|
+
interface IntrinsicElements {
|
|
18
|
+
'sinch-chat-block': TSinchChatBlockReact;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
interface HTMLElementTagNameMap {
|
|
22
|
+
'sinch-chat-block': TSinchChatBlockElement;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
|
+
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
|
+
|
|
4
|
+
var _$firstName, _$lastName, _$timeStamp, _$bubbleSlot, _onBubbleSlotChange, _updateBubbleTypes;
|
|
5
|
+
|
|
6
|
+
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
|
7
|
+
|
|
8
|
+
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
9
|
+
|
|
10
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
11
|
+
|
|
12
|
+
function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
|
|
13
|
+
|
|
14
|
+
import { typeValues } from '../chat-bubble';
|
|
15
|
+
import { defineCustomElement, getAttribute, getLiteralAttribute, updateAttribute, updateLiteralAttribute } from '../utils';
|
|
16
|
+
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{position:relative;display:flex;flex-direction:column;gap:4px;align-items:flex-end;padding-left:56px}#stamp{display:flex;gap:4px;margin:0;font:var(--sinch-font-extra-small-text);color:var(--sinch-color-stormy-400)}#avatar{display:none;position:absolute;left:0;top:24px}:host([type=customer])>#wrapper{align-items:flex-start}:host([type=customer]) #avatar{display:block}</style><div id="wrapper"><div id="avatar"><slot name="avatar"></slot></div><p id="stamp"><span id="firstname"></span><span id="lastname"></span>•<span id="time"></span></p><slot name="bubble"></slot></div>';
|
|
17
|
+
const template = document.createElement('template');
|
|
18
|
+
template.innerHTML = templateHTML;
|
|
19
|
+
defineCustomElement('sinch-chat-block', (_$firstName = new WeakMap(), _$lastName = new WeakMap(), _$timeStamp = new WeakMap(), _$bubbleSlot = new WeakMap(), _onBubbleSlotChange = new WeakMap(), _updateBubbleTypes = new WeakSet(), class extends HTMLElement {
|
|
20
|
+
constructor() {
|
|
21
|
+
super();
|
|
22
|
+
|
|
23
|
+
_classPrivateMethodInitSpec(this, _updateBubbleTypes);
|
|
24
|
+
|
|
25
|
+
_classPrivateFieldInitSpec(this, _$firstName, {
|
|
26
|
+
writable: true,
|
|
27
|
+
value: void 0
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
_classPrivateFieldInitSpec(this, _$lastName, {
|
|
31
|
+
writable: true,
|
|
32
|
+
value: void 0
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
_classPrivateFieldInitSpec(this, _$timeStamp, {
|
|
36
|
+
writable: true,
|
|
37
|
+
value: void 0
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
_classPrivateFieldInitSpec(this, _$bubbleSlot, {
|
|
41
|
+
writable: true,
|
|
42
|
+
value: void 0
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
_classPrivateFieldInitSpec(this, _onBubbleSlotChange, {
|
|
46
|
+
writable: true,
|
|
47
|
+
value: () => {
|
|
48
|
+
_classPrivateMethodGet(this, _updateBubbleTypes, _updateBubbleTypes2).call(this);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const shadowRoot = this.attachShadow({
|
|
53
|
+
mode: 'closed',
|
|
54
|
+
delegatesFocus: true
|
|
55
|
+
});
|
|
56
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
57
|
+
|
|
58
|
+
_classPrivateFieldSet(this, _$firstName, shadowRoot.querySelector('#firstname'));
|
|
59
|
+
|
|
60
|
+
_classPrivateFieldSet(this, _$lastName, shadowRoot.querySelector('#lastname'));
|
|
61
|
+
|
|
62
|
+
_classPrivateFieldSet(this, _$timeStamp, shadowRoot.querySelector('#time'));
|
|
63
|
+
|
|
64
|
+
_classPrivateFieldSet(this, _$bubbleSlot, shadowRoot.querySelector('slot[name="bubble"]'));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
connectedCallback() {
|
|
68
|
+
_classPrivateFieldGet(this, _$bubbleSlot).addEventListener('slotchange', _classPrivateFieldGet(this, _onBubbleSlotChange));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
disconnectedCallback() {
|
|
72
|
+
_classPrivateFieldGet(this, _$bubbleSlot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onBubbleSlotChange));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
static get observedAttributes() {
|
|
76
|
+
return ['firstname', 'lastname', 'timestamp', 'type'];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
attributeChangedCallback(name, _, newVal) {
|
|
80
|
+
switch (name) {
|
|
81
|
+
case 'firstname':
|
|
82
|
+
{
|
|
83
|
+
_classPrivateFieldGet(this, _$firstName).textContent = newVal;
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
case 'lastname':
|
|
88
|
+
{
|
|
89
|
+
_classPrivateFieldGet(this, _$lastName).textContent = newVal;
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
case 'timestamp':
|
|
94
|
+
{
|
|
95
|
+
_classPrivateFieldGet(this, _$timeStamp).textContent = newVal;
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
case 'type':
|
|
100
|
+
{
|
|
101
|
+
_classPrivateMethodGet(this, _updateBubbleTypes, _updateBubbleTypes2).call(this);
|
|
102
|
+
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
set type(value) {
|
|
109
|
+
updateLiteralAttribute(this, typeValues, 'type', value);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
get type() {
|
|
113
|
+
return getLiteralAttribute(this, typeValues, 'type', null);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
set firstName(value) {
|
|
117
|
+
updateAttribute(this, 'firstname', value);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
get firstName() {
|
|
121
|
+
return getAttribute(this, 'firstname', null);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
set lastName(value) {
|
|
125
|
+
updateAttribute(this, 'lastname', value);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
get lastName() {
|
|
129
|
+
return getAttribute(this, 'lastname', null);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
set timestamp(value) {
|
|
133
|
+
updateAttribute(this, 'timestamp', value);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
get timestamp() {
|
|
137
|
+
return getAttribute(this, 'timestamp', null);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
}));
|
|
141
|
+
|
|
142
|
+
function _updateBubbleTypes2() {
|
|
143
|
+
const typeValue = getAttribute(this, 'type');
|
|
144
|
+
|
|
145
|
+
_classPrivateFieldGet(this, _$bubbleSlot).assignedElements().forEach(el => {
|
|
146
|
+
updateAttribute(el, 'data-type', typeValue);
|
|
147
|
+
});
|
|
148
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { TSinchElementReact } from '../types';
|
|
2
|
+
export declare const typeValues: readonly ["customer", "agent", "agent-prev"];
|
|
3
|
+
export declare type TSinchChatBubbleType = typeof typeValues[number];
|
|
4
|
+
export declare type TSinchChatBubbleElement = HTMLElement & {
|
|
5
|
+
readonly type: TSinchChatBubbleType | null;
|
|
6
|
+
text: string;
|
|
7
|
+
};
|
|
8
|
+
export declare type TSinchChatBubbleReact = TSinchElementReact<TSinchChatBubbleElement> & {
|
|
9
|
+
text: string;
|
|
10
|
+
};
|
|
11
|
+
declare global {
|
|
12
|
+
namespace JSX {
|
|
13
|
+
interface IntrinsicElements {
|
|
14
|
+
'sinch-chat-bubble': TSinchChatBubbleReact;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
interface HTMLElementTagNameMap {
|
|
18
|
+
'sinch-chat-bubble': TSinchChatBubbleElement;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
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 { defineCustomElement, getAttribute, getLiteralAttribute, updateAttribute } from '../utils';
|
|
11
|
+
const templateHTML = '<style>:host{display:block;outline:0}#text{padding:12px 16px;border-radius:16px;font:var(--sinch-font-body);color:var(--sinch-color-stormy-500);margin:0;max-width:595px;box-sizing:border-box}:host([data-type=customer])>#text{background-color:var(--sinch-color-snow-500);border-top-left-radius:0}:host([data-type=agent-prev])>#text{background-color:var(--sinch-color-snow-700);border-top-right-radius:0}:host([data-type=agent])>#text{background-color:var(--sinch-color-honey-200);border-top-right-radius:0}</style><p id="text"></p>';
|
|
12
|
+
export const typeValues = ['customer', 'agent', 'agent-prev'];
|
|
13
|
+
const template = document.createElement('template');
|
|
14
|
+
template.innerHTML = templateHTML;
|
|
15
|
+
defineCustomElement('sinch-chat-bubble', (_$text = new WeakMap(), class extends HTMLElement {
|
|
16
|
+
constructor() {
|
|
17
|
+
super();
|
|
18
|
+
|
|
19
|
+
_classPrivateFieldInitSpec(this, _$text, {
|
|
20
|
+
writable: true,
|
|
21
|
+
value: void 0
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const shadowRoot = this.attachShadow({
|
|
25
|
+
mode: 'closed',
|
|
26
|
+
delegatesFocus: true
|
|
27
|
+
});
|
|
28
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
29
|
+
|
|
30
|
+
_classPrivateFieldSet(this, _$text, shadowRoot.querySelector('#text'));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
static get observedAttributes() {
|
|
34
|
+
return ['text'];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
attributeChangedCallback(name, _, newVal) {
|
|
38
|
+
switch (name) {
|
|
39
|
+
case 'text':
|
|
40
|
+
{
|
|
41
|
+
_classPrivateFieldGet(this, _$text).textContent = newVal;
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
set text(value) {
|
|
48
|
+
updateAttribute(this, 'text', value);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
get text() {
|
|
52
|
+
return getAttribute(this, 'text', '');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
get type() {
|
|
56
|
+
return getLiteralAttribute(this, typeValues, 'data-type', null);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
}));
|
package/colors.json
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"colorHoney700": "#CC8800",
|
|
3
|
+
"colorHoney600": "#FFAA00",
|
|
4
|
+
"colorHoney500": "#FFBE3C",
|
|
5
|
+
"colorHoney400": "#FFCC66",
|
|
6
|
+
"colorHoney300": "#FFDD99",
|
|
7
|
+
"colorHoney200": "#FFEECC",
|
|
8
|
+
"colorHoney100": "#FFF7E6",
|
|
9
|
+
"colorTropical700": "#003D3D",
|
|
10
|
+
"colorTropical600": "#005757",
|
|
11
|
+
"colorTropical500": "#007171",
|
|
12
|
+
"colorTropical400": "#338D8D",
|
|
13
|
+
"colorTropical300": "#66AAAA",
|
|
14
|
+
"colorTropical200": "#99C6C6",
|
|
15
|
+
"colorTropical100": "#CCE3E3",
|
|
16
|
+
"colorStormy600": "#061927",
|
|
17
|
+
"colorStormy500": "#0A273D",
|
|
18
|
+
"colorStormy400": "#3B5264",
|
|
19
|
+
"colorStormy300": "#677784",
|
|
20
|
+
"colorStormy200": "#7F8F99",
|
|
21
|
+
"colorStormy100": "#9CA8B0",
|
|
22
|
+
"colorSnow800": "#C6CDD2",
|
|
23
|
+
"colorSnow700": "#D4DADD",
|
|
24
|
+
"colorSnow600": "#E3E6E8",
|
|
25
|
+
"colorSnow500": "#F1F3F4",
|
|
26
|
+
"colorSnow100": "#FFFFFF",
|
|
27
|
+
"colorRaspberry700": "#881125",
|
|
28
|
+
"colorRaspberry600": "#B61631",
|
|
29
|
+
"colorRaspberry500": "#E31C3D",
|
|
30
|
+
"colorRaspberry400": "#E94964",
|
|
31
|
+
"colorRaspberry300": "#EE778B",
|
|
32
|
+
"colorRaspberry200": "#F4A4B1",
|
|
33
|
+
"colorRaspberry100": "#F9D2D8",
|
|
34
|
+
"colorTextDefault": "#0A273D",
|
|
35
|
+
"colorTextInverted": "#FFFFFF",
|
|
36
|
+
"colorTextMuted": "#677784",
|
|
37
|
+
"colorTextLink": "#007171",
|
|
38
|
+
"colorTextInvalid": "#E31C3D",
|
|
39
|
+
"colorError800": "#57000E",
|
|
40
|
+
"colorError500": "#E31C3D",
|
|
41
|
+
"colorError200": "#FCD7D4",
|
|
42
|
+
"colorSuccess700": "#005419",
|
|
43
|
+
"colorSuccess500": "#2E8540",
|
|
44
|
+
"colorSuccess200": "#D7F1D8",
|
|
45
|
+
"colorInformative700": "#003B7E",
|
|
46
|
+
"colorInformative500": "#2071CE",
|
|
47
|
+
"colorInformative200": "#D5E5F8",
|
|
48
|
+
"colorWarning700": "#9C2E00",
|
|
49
|
+
"colorWarning500": "#F35B1C",
|
|
50
|
+
"colorWarning200": "#FFE8D6",
|
|
51
|
+
"colorNight400": "#3247E9",
|
|
52
|
+
"colorNight200": "#D1D6FA",
|
|
53
|
+
"colorAqua400": "#3DAED8",
|
|
54
|
+
"colorAqua200": "#AADBEE",
|
|
55
|
+
"colorGrass400": "#39B93D",
|
|
56
|
+
"colorGrass200": "#B4E4B5",
|
|
57
|
+
"colorDirt400": "#828282",
|
|
58
|
+
"colorDirt200": "#E0DDDC",
|
|
59
|
+
"colorBerry400": "#F95252",
|
|
60
|
+
"colorBerry200": "#FCA7A7",
|
|
61
|
+
"colorCandy400": "#E467C3",
|
|
62
|
+
"colorCandy200": "#F6CBEA",
|
|
63
|
+
"colorMud400": "#8B6559",
|
|
64
|
+
"colorMud200": "#D7C6C1",
|
|
65
|
+
"colorOrange400": "#FF8C34",
|
|
66
|
+
"colorOrange200": "#FFD4B3",
|
|
67
|
+
"colorBolt400": "#FFBE3C",
|
|
68
|
+
"colorBolt200": "#FFE6B3"
|
|
69
|
+
}
|
package/dialog/index.js
CHANGED
|
@@ -78,7 +78,6 @@ defineCustomElement('sinch-dialog', (_$dialog = new WeakMap(), _$closeButton = n
|
|
|
78
78
|
_classPrivateFieldInitSpec(this, _onBackdropClick, {
|
|
79
79
|
writable: true,
|
|
80
80
|
value: e => {
|
|
81
|
-
e.stopPropagation();
|
|
82
81
|
const rect = this.dialogRect;
|
|
83
82
|
const isInside = e.x >= rect.x && e.x < rect.x + rect.width && e.y >= rect.y && e.y < rect.y + rect.height;
|
|
84
83
|
|
|
@@ -187,7 +186,9 @@ function _dispatchCloseEvent2() {
|
|
|
187
186
|
|
|
188
187
|
function _setOpen2(isOpen) {
|
|
189
188
|
if (isOpen) {
|
|
190
|
-
_classPrivateFieldGet(this, _$dialog)
|
|
189
|
+
if (!getBooleanAttribute(_classPrivateFieldGet(this, _$dialog), 'open')) {
|
|
190
|
+
_classPrivateFieldGet(this, _$dialog).showModal();
|
|
191
|
+
}
|
|
191
192
|
} else {
|
|
192
193
|
_classPrivateFieldGet(this, _$dialog).close();
|
|
193
194
|
}
|
package/dropdown/index.js
CHANGED
|
@@ -285,7 +285,9 @@ defineCustomElement('sinch-dropdown', (_$button = new WeakMap(), _$optionSlot =
|
|
|
285
285
|
|
|
286
286
|
function _setOpen2(isOpen) {
|
|
287
287
|
if (isOpen) {
|
|
288
|
-
_classPrivateFieldGet(this, _$listbox)
|
|
288
|
+
if (!getBooleanAttribute(_classPrivateFieldGet(this, _$listbox), 'open')) {
|
|
289
|
+
_classPrivateFieldGet(this, _$listbox).showModal();
|
|
290
|
+
}
|
|
289
291
|
} else {
|
|
290
292
|
_classPrivateFieldGet(this, _$listbox).close();
|
|
291
293
|
}
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -137,4 +137,9 @@ import './icon-button';
|
|
|
137
137
|
import './search';
|
|
138
138
|
import './search-option';
|
|
139
139
|
import './segment';
|
|
140
|
-
import './segment-collapse';
|
|
140
|
+
import './segment-collapse';
|
|
141
|
+
import './avatar';
|
|
142
|
+
import './chat-avatar';
|
|
143
|
+
import './chat-bubble';
|
|
144
|
+
import './chat-block';
|
|
145
|
+
import './chat';
|
package/input/index.d.ts
CHANGED
|
@@ -11,6 +11,9 @@ export declare type TSinchInputElement = HTMLElement & {
|
|
|
11
11
|
invalidText: string | null;
|
|
12
12
|
additionalText: string | null;
|
|
13
13
|
disabled: boolean;
|
|
14
|
+
selectionStart: HTMLInputElement['selectionStart'];
|
|
15
|
+
selectionEnd: HTMLInputElement['selectionEnd'];
|
|
16
|
+
selectionDirection: HTMLInputElement['selectionDirection'];
|
|
14
17
|
focus(): void;
|
|
15
18
|
blur(): void;
|
|
16
19
|
};
|
package/input/index.js
CHANGED
|
@@ -208,6 +208,30 @@ defineCustomElement('sinch-input', (_$input = new WeakMap(), _$label = new WeakM
|
|
|
208
208
|
return getBooleanAttribute(this, 'disabled');
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
+
get selectionStart() {
|
|
212
|
+
return _classPrivateFieldGet(this, _$input).selectionStart;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
set selectionStart(value) {
|
|
216
|
+
_classPrivateFieldGet(this, _$input).selectionStart = value;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
get selectionEnd() {
|
|
220
|
+
return _classPrivateFieldGet(this, _$input).selectionEnd;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
set selectionEnd(value) {
|
|
224
|
+
_classPrivateFieldGet(this, _$input).selectionEnd = value;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
get selectionDirection() {
|
|
228
|
+
return _classPrivateFieldGet(this, _$input).selectionDirection;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
set selectionDirection(value) {
|
|
232
|
+
_classPrivateFieldGet(this, _$input).selectionDirection = value;
|
|
233
|
+
}
|
|
234
|
+
|
|
211
235
|
attributeChangedCallback(name, _, newVal) {
|
|
212
236
|
switch (name) {
|
|
213
237
|
case 'type':
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nectary/components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"files": [
|
|
5
5
|
"theme.css",
|
|
6
6
|
"**/*/*.js",
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
"utils.d.ts",
|
|
10
10
|
"index.js",
|
|
11
11
|
"index.d.ts",
|
|
12
|
-
"types.d.ts"
|
|
12
|
+
"types.d.ts",
|
|
13
|
+
"colors.json"
|
|
13
14
|
],
|
|
14
15
|
"scripts": {
|
|
15
16
|
"prebuild": "rimraf utils.{js,d.ts} index.{js,d.ts} */*.{js,d.ts} */**/*.{js,d.ts}",
|
package/search/index.d.ts
CHANGED
package/search/index.js
CHANGED
|
@@ -13,9 +13,10 @@ function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(
|
|
|
13
13
|
|
|
14
14
|
import { isSearchOptionElement } from '../search-option';
|
|
15
15
|
import { attrValueToPixels, defineCustomElement, getAttribute, getIntegerAttribute, getRect, updateAttribute, updateIntegerAttribute } from '../utils';
|
|
16
|
-
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{position:relative;width:100%;box-sizing:border-box;--sinch-size-icon:24px}#label{display:none;font:var(--sinch-font-title-4);color:var(--sinch-color-text-default);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:100%;height:24px;margin-bottom:2px}#input{all:initial;display:block;border:1px solid var(--sinch-color-stormy-200);box-sizing:border-box;border-radius:4px;width:100%;height:48px;padding:0 44px;font:var(--sinch-font-body);color:var(--sinch-color-text-default);caret-color:var(--sinch-caret-color,auto)}#input::placeholder{font:var(--sinch-font-body);color:var(--sinch-color-text-muted)}#input:focus{border-color:var(--sinch-color-stormy-600)}#icon-search{position:absolute;left:12px;top:12px;pointer-events:none;--sinch-color-icon:var(--sinch-color-stormy-500)}#clear{
|
|
16
|
+
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{position:relative;width:100%;box-sizing:border-box;--sinch-size-icon:24px}#label{display:none;font:var(--sinch-font-title-4);color:var(--sinch-color-text-default);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:100%;height:24px;margin-bottom:2px}#input{all:initial;display:block;border:1px solid var(--sinch-color-stormy-200);box-sizing:border-box;border-radius:4px;width:100%;height:48px;padding:0 44px;padding-right:12px;font:var(--sinch-font-body);color:var(--sinch-color-text-default);caret-color:var(--sinch-caret-color,auto)}#input::placeholder{font:var(--sinch-font-body);color:var(--sinch-color-text-muted)}#input:focus{border-color:var(--sinch-color-stormy-600)}#icon-search{position:absolute;left:12px;top:12px;pointer-events:none;--sinch-color-icon:var(--sinch-color-stormy-500)}#clear{position:absolute;right:8px;top:8px;display:none;--sinch-color-icon:red}#clear:focus{--sinch-color-icon:var(--sinch-color-stormy-500)}:host([value]:not([value=""])) #clear{display:flex}:host([value]:not([value=""])) #input{padding-right:44px}#listbox{display:none;position:absolute;z-index:1;left:0;top:calc(100% + 8px);width:100%;box-sizing:border-box;font:var(--sinch-font-body);color:var(--sinch-color-text-default);background-color:var(--sinch-color-snow-100);box-shadow:1px 2px 4px rgb(0 0 0 / 15%);overflow-y:auto;contain:content}:host([aria-expanded=true]) #listbox{display:block}:host([label]:not([label=""])) #label{display:block}</style><label id="label" for="input"></label><div id="wrapper"><input id="input" type="text"/><sinch-icon-search id="icon-search"></sinch-icon-search><sinch-icon-button id="clear" small><sinch-icon-close id="icon-close" slot="icon"></sinch-icon-close></sinch-icon-button><div id="listbox"><slot name="option"></slot></div></div>';
|
|
17
17
|
import '../icon/search';
|
|
18
18
|
import '../icon/close';
|
|
19
|
+
import '../icon-button';
|
|
19
20
|
const ITEM_HEIGHT = 40;
|
|
20
21
|
|
|
21
22
|
const findSelectedOption = elements => {
|
package/textarea/index.d.ts
CHANGED
|
@@ -8,6 +8,11 @@ export declare type TSinchTextareaElement = HTMLElement & {
|
|
|
8
8
|
invalidText: string | null;
|
|
9
9
|
additionalText: string | null;
|
|
10
10
|
disabled: boolean;
|
|
11
|
+
selectionStart: HTMLTextAreaElement['selectionStart'];
|
|
12
|
+
selectionEnd: HTMLTextAreaElement['selectionEnd'];
|
|
13
|
+
selectionDirection: HTMLTextAreaElement['selectionDirection'];
|
|
14
|
+
rows: HTMLTextAreaElement['rows'];
|
|
15
|
+
resizable: boolean;
|
|
11
16
|
focus(): void;
|
|
12
17
|
blur(): void;
|
|
13
18
|
};
|
|
@@ -20,6 +25,8 @@ export declare type TSinchTextareaReact = TSinchElementReact<TSinchTextareaEleme
|
|
|
20
25
|
additionalText?: string;
|
|
21
26
|
disabled?: boolean;
|
|
22
27
|
'aria-label': string;
|
|
28
|
+
rows?: number;
|
|
29
|
+
resizable?: boolean;
|
|
23
30
|
onChange: (e: SyntheticEvent<TSinchTextareaElement, CustomEvent<string>>) => void;
|
|
24
31
|
onKeyPress?: DOMAttributes<TSinchTextareaElement>['onKeyPress'];
|
|
25
32
|
onFocus?: (e: FocusEvent<TSinchTextareaElement>) => void;
|
package/textarea/index.js
CHANGED
|
@@ -7,8 +7,8 @@ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedec
|
|
|
7
7
|
|
|
8
8
|
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
9
9
|
|
|
10
|
-
import { defineCustomElement, getAttribute, getBooleanAttribute, isAttrTrue, updateAttribute, updateBooleanAttribute } from '../utils';
|
|
11
|
-
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0;--sinch-color-icon:var(--sinch-color-stormy-500)}#wrapper{width:100%;box-sizing:border-box}#input{all:initial;border:1px solid var(--sinch-color-stormy-200);box-sizing:border-box;border-radius:4px;width:100%;
|
|
10
|
+
import { defineCustomElement, getAttribute, getBooleanAttribute, getIntegerAttribute, isAttrTrue, updateAttribute, updateBooleanAttribute } from '../utils';
|
|
11
|
+
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0;--sinch-color-icon:var(--sinch-color-stormy-500)}#wrapper{width:100%;box-sizing:border-box}#input{all:initial;border:1px solid var(--sinch-color-stormy-200);box-sizing:border-box;border-radius:4px;width:100%;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:none}#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-600)}:host([resizable]:not([resizable=false])) #input{resize:vertical}: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])){--sinch-color-icon: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"></textarea><div id="bottom"><span id="invalid"></span> <span id="additional"></span></div></div>';
|
|
12
12
|
const template = document.createElement('template');
|
|
13
13
|
template.innerHTML = templateHTML;
|
|
14
14
|
defineCustomElement('sinch-textarea', (_$input = new WeakMap(), _$label = new WeakMap(), _$optionalText = new WeakMap(), _$additionalText = new WeakMap(), _$invalidText = new WeakMap(), _selectionStart = new WeakMap(), _selectionEnd = new WeakMap(), _isPendingDk = new WeakMap(), _onCompositionStart = new WeakMap(), _onInput = new WeakMap(), class extends HTMLElement {
|
|
@@ -137,7 +137,7 @@ defineCustomElement('sinch-textarea', (_$input = new WeakMap(), _$label = new We
|
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
static get observedAttributes() {
|
|
140
|
-
return ['value', 'placeholder', 'label', 'optionaltext', 'additionaltext', 'invalidtext', 'disabled'];
|
|
140
|
+
return ['value', 'placeholder', 'label', 'optionaltext', 'additionaltext', 'invalidtext', 'disabled', 'rows'];
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
attributeChangedCallback(name, _, newVal) {
|
|
@@ -195,6 +195,12 @@ defineCustomElement('sinch-textarea', (_$input = new WeakMap(), _$label = new We
|
|
|
195
195
|
_classPrivateFieldGet(this, _$input).disabled = isAttrTrue(newVal);
|
|
196
196
|
break;
|
|
197
197
|
}
|
|
198
|
+
|
|
199
|
+
case 'rows':
|
|
200
|
+
{
|
|
201
|
+
updateAttribute(_classPrivateFieldGet(this, _$input), 'rows', newVal);
|
|
202
|
+
break;
|
|
203
|
+
}
|
|
198
204
|
}
|
|
199
205
|
}
|
|
200
206
|
|
|
@@ -258,6 +264,46 @@ defineCustomElement('sinch-textarea', (_$input = new WeakMap(), _$label = new We
|
|
|
258
264
|
return getBooleanAttribute(this, 'disabled');
|
|
259
265
|
}
|
|
260
266
|
|
|
267
|
+
set resizable(isResizable) {
|
|
268
|
+
updateBooleanAttribute(this, 'resizable', isResizable);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
get resizable() {
|
|
272
|
+
return getBooleanAttribute(this, 'resizable');
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
set rows(value) {
|
|
276
|
+
updateAttribute(this, 'rows', value);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
get rows() {
|
|
280
|
+
return getIntegerAttribute(this, 'rows', 0);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
get selectionStart() {
|
|
284
|
+
return _classPrivateFieldGet(this, _$input).selectionStart;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
set selectionStart(value) {
|
|
288
|
+
_classPrivateFieldGet(this, _$input).selectionStart = value;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
get selectionEnd() {
|
|
292
|
+
return _classPrivateFieldGet(this, _$input).selectionEnd;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
set selectionEnd(value) {
|
|
296
|
+
_classPrivateFieldGet(this, _$input).selectionEnd = value;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
get selectionDirection() {
|
|
300
|
+
return _classPrivateFieldGet(this, _$input).selectionDirection;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
set selectionDirection(value) {
|
|
304
|
+
_classPrivateFieldGet(this, _$input).selectionDirection = value;
|
|
305
|
+
}
|
|
306
|
+
|
|
261
307
|
focus() {
|
|
262
308
|
_classPrivateFieldGet(this, _$input).focus();
|
|
263
309
|
}
|