@nectary/components 0.16.1 → 0.18.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/colors.json +69 -0
- package/icon-button/index.d.ts +2 -0
- package/icon-button/index.js +9 -1
- package/index.d.ts +3 -0
- package/index.js +4 -1
- package/input/index.d.ts +3 -0
- package/input/index.js +31 -9
- package/package.json +3 -2
- package/search/index.d.ts +1 -0
- package/search/index.js +2 -1
- package/segment/index.d.ts +20 -0
- package/segment/index.js +62 -0
- package/segment-collapse/index.d.ts +26 -0
- package/segment-collapse/index.js +94 -0
- package/textarea/index.d.ts +7 -0
- package/textarea/index.js +56 -12
|
@@ -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/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/icon-button/index.d.ts
CHANGED
|
@@ -2,12 +2,14 @@ import type { TSinchElementReact } from '../types';
|
|
|
2
2
|
import type { FocusEvent, MouseEvent } from 'react';
|
|
3
3
|
export declare type TSinchIconButtonElement = HTMLElement & {
|
|
4
4
|
disabled: boolean;
|
|
5
|
+
small: boolean;
|
|
5
6
|
focus(): void;
|
|
6
7
|
blur(): void;
|
|
7
8
|
};
|
|
8
9
|
export declare type TSinchIconButtonReact = TSinchElementReact<TSinchIconButtonElement> & {
|
|
9
10
|
'aria-label': string;
|
|
10
11
|
disabled?: boolean;
|
|
12
|
+
small?: boolean;
|
|
11
13
|
onClick: (e: MouseEvent<TSinchIconButtonElement>) => void;
|
|
12
14
|
onFocus?: (e: FocusEvent<TSinchIconButtonElement>) => void;
|
|
13
15
|
onBlur?: (e: FocusEvent<TSinchIconButtonElement>) => void;
|
package/icon-button/index.js
CHANGED
|
@@ -8,7 +8,7 @@ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedec
|
|
|
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
10
|
import { defineCustomElement, getBooleanAttribute, isAttrTrue, updateBooleanAttribute } from '../utils';
|
|
11
|
-
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}button{all:initial;display:flex;align-items:center;justify-content:center;box-sizing:border-box;width:48px;height:48px;border-radius:4px;background-color:transparent;box-shadow:0 0 0 1px transparent inset;cursor:pointer;--sinch-size-icon:24px;--sinch-color-icon:var(--sinch-color-stormy-500)}button:focus{box-shadow:0 0 0 1px var(--sinch-color-stormy-500) inset}button:hover{background-color:var(--sinch-color-snow-500)}button:active{background-color:var(--sinch-color-snow-600)}button:disabled{background-color:transparent;cursor:initial;--sinch-color-spinner-bg:var(--sinch-color-snow-200);--sinch-color-spinner-fg:var(--sinch-color-stormy-200);--sinch-color-icon:var(--sinch-color-stormy-100)}button>*{pointer-events:none}</style><button><slot name="icon"></slot></button>';
|
|
11
|
+
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}button{all:initial;display:flex;align-items:center;justify-content:center;box-sizing:border-box;width:48px;height:48px;border-radius:4px;background-color:transparent;box-shadow:0 0 0 1px transparent inset;cursor:pointer;--sinch-size-icon:24px;--sinch-color-icon:var(--sinch-color-stormy-500)}button:focus{box-shadow:0 0 0 1px var(--sinch-color-stormy-500) inset}button:hover{background-color:var(--sinch-color-snow-500)}button:active{background-color:var(--sinch-color-snow-600)}button:disabled{background-color:transparent;cursor:initial;--sinch-color-spinner-bg:var(--sinch-color-snow-200);--sinch-color-spinner-fg:var(--sinch-color-stormy-200);--sinch-color-icon:var(--sinch-color-stormy-100)}:host([small]:not([small=false]))>button{width:32px;height:32px}button>*{pointer-events:none}</style><button><slot name="icon"></slot></button>';
|
|
12
12
|
const template = document.createElement('template');
|
|
13
13
|
template.innerHTML = templateHTML;
|
|
14
14
|
defineCustomElement('sinch-icon-button', (_$button = new WeakMap(), class extends HTMLElement {
|
|
@@ -55,6 +55,14 @@ defineCustomElement('sinch-icon-button', (_$button = new WeakMap(), class extend
|
|
|
55
55
|
return getBooleanAttribute(this, 'disabled');
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
set small(isSmall) {
|
|
59
|
+
updateBooleanAttribute(this, 'small', isSmall);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
get small() {
|
|
63
|
+
return getBooleanAttribute(this, 'small');
|
|
64
|
+
}
|
|
65
|
+
|
|
58
66
|
focus() {
|
|
59
67
|
_classPrivateFieldGet(this, _$button).focus();
|
|
60
68
|
}
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
2
|
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
3
|
|
|
4
|
-
var _$input, _$label, _$optionalText, _$additionalText, _$invalidText, _selectionStart, _selectionEnd, _isPendingDk,
|
|
4
|
+
var _$input, _$label, _$optionalText, _$additionalText, _$invalidText, _selectionStart, _selectionEnd, _isPendingDk, _onCompositionStart, _onInput;
|
|
5
5
|
|
|
6
6
|
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
7
7
|
|
|
@@ -12,7 +12,7 @@ const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;ou
|
|
|
12
12
|
const inputTypes = ['text', 'password'];
|
|
13
13
|
const template = document.createElement('template');
|
|
14
14
|
template.innerHTML = templateHTML;
|
|
15
|
-
defineCustomElement('sinch-input', (_$input = new WeakMap(), _$label = new WeakMap(), _$optionalText = new WeakMap(), _$additionalText = new WeakMap(), _$invalidText = new WeakMap(), _selectionStart = new WeakMap(), _selectionEnd = new WeakMap(), _isPendingDk = new WeakMap(),
|
|
15
|
+
defineCustomElement('sinch-input', (_$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 {
|
|
16
16
|
constructor() {
|
|
17
17
|
super();
|
|
18
18
|
|
|
@@ -56,12 +56,10 @@ defineCustomElement('sinch-input', (_$input = new WeakMap(), _$label = new WeakM
|
|
|
56
56
|
value: false
|
|
57
57
|
});
|
|
58
58
|
|
|
59
|
-
_classPrivateFieldInitSpec(this,
|
|
59
|
+
_classPrivateFieldInitSpec(this, _onCompositionStart, {
|
|
60
60
|
writable: true,
|
|
61
|
-
value:
|
|
62
|
-
|
|
63
|
-
_classPrivateFieldSet(this, _isPendingDk, true);
|
|
64
|
-
}
|
|
61
|
+
value: () => {
|
|
62
|
+
_classPrivateFieldSet(this, _isPendingDk, true);
|
|
65
63
|
}
|
|
66
64
|
});
|
|
67
65
|
|
|
@@ -129,13 +127,13 @@ defineCustomElement('sinch-input', (_$input = new WeakMap(), _$label = new WeakM
|
|
|
129
127
|
|
|
130
128
|
_classPrivateFieldGet(this, _$input).addEventListener('input', _classPrivateFieldGet(this, _onInput));
|
|
131
129
|
|
|
132
|
-
_classPrivateFieldGet(this, _$input).addEventListener('
|
|
130
|
+
_classPrivateFieldGet(this, _$input).addEventListener('compositionstart', _classPrivateFieldGet(this, _onCompositionStart));
|
|
133
131
|
}
|
|
134
132
|
|
|
135
133
|
disconnectedCallback() {
|
|
136
134
|
_classPrivateFieldGet(this, _$input).removeEventListener('input', _classPrivateFieldGet(this, _onInput));
|
|
137
135
|
|
|
138
|
-
_classPrivateFieldGet(this, _$input).removeEventListener('
|
|
136
|
+
_classPrivateFieldGet(this, _$input).removeEventListener('compositionstart', _classPrivateFieldGet(this, _onCompositionStart));
|
|
139
137
|
}
|
|
140
138
|
|
|
141
139
|
static get observedAttributes() {
|
|
@@ -210,6 +208,30 @@ defineCustomElement('sinch-input', (_$input = new WeakMap(), _$label = new WeakM
|
|
|
210
208
|
return getBooleanAttribute(this, 'disabled');
|
|
211
209
|
}
|
|
212
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
|
+
|
|
213
235
|
attributeChangedCallback(name, _, newVal) {
|
|
214
236
|
switch (name) {
|
|
215
237
|
case 'type':
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nectary/components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.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 => {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { TSinchElementReact } from '../types';
|
|
2
|
+
declare type TSinchSegmentElement = HTMLElement & {
|
|
3
|
+
caption: string;
|
|
4
|
+
collapsed: boolean;
|
|
5
|
+
};
|
|
6
|
+
declare type TSinchSegmentReact = TSinchElementReact<TSinchSegmentElement> & {
|
|
7
|
+
caption: string;
|
|
8
|
+
collapsed?: boolean;
|
|
9
|
+
};
|
|
10
|
+
declare global {
|
|
11
|
+
namespace JSX {
|
|
12
|
+
interface IntrinsicElements {
|
|
13
|
+
'sinch-segment': TSinchSegmentReact;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
interface HTMLElementTagNameMap {
|
|
17
|
+
'sinch-segment': TSinchSegmentElement;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export {};
|
package/segment/index.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
|
+
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
|
+
|
|
4
|
+
var _$caption;
|
|
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, updateAttribute, updateBooleanAttribute } from '../utils';
|
|
11
|
+
const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:column;width:100%;border-radius:4px;box-sizing:border-box;background-color:var(--sinch-color-snow-100);color:var(--sinch-color-text-default);font:var(--sinch-font-body);border:none;box-shadow:1px 2px 8px rgb(0 0 0 / 10%)}#header{position:relative;display:flex;flex-direction:row;align-items:center;gap:16px;height:32px;padding:24px 32px 16px;--sinch-size-icon:32px}#caption{font:var(--sinch-font-title-2);color:var(--sinch-color-text-default);flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#content-wrapper{padding:0 32px}#action{display:flex;flex-direction:row;justify-content:flex-end;gap:16px;padding:16px 32px 24px}#info{position:relative;display:flex;flex-direction:row;align-items:center;gap:16px;z-index:1}:host([collapsed]:not([collapsed=false])) :is(#content-wrapper,#action){display:none}:host([collapsed]:not([collapsed=false])) #header{padding-bottom:24px}</style><div id="wrapper"><div id="header"><slot name="icon"></slot><span id="caption"></span><div id="info"><slot name="info"></slot></div><slot name="collapse"></slot></div><div id="content-wrapper"><slot name="content"></slot></div><div id="action"><slot name="action"></slot></div></div>';
|
|
12
|
+
const template = document.createElement('template');
|
|
13
|
+
template.innerHTML = templateHTML;
|
|
14
|
+
defineCustomElement('sinch-segment', (_$caption = new WeakMap(), class extends HTMLElement {
|
|
15
|
+
constructor() {
|
|
16
|
+
super();
|
|
17
|
+
|
|
18
|
+
_classPrivateFieldInitSpec(this, _$caption, {
|
|
19
|
+
writable: true,
|
|
20
|
+
value: void 0
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const shadowRoot = this.attachShadow({
|
|
24
|
+
mode: 'closed',
|
|
25
|
+
delegatesFocus: true
|
|
26
|
+
});
|
|
27
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
28
|
+
|
|
29
|
+
_classPrivateFieldSet(this, _$caption, shadowRoot.querySelector('#caption'));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
static get observedAttributes() {
|
|
33
|
+
return ['caption'];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
attributeChangedCallback(name, _, newVal) {
|
|
37
|
+
switch (name) {
|
|
38
|
+
case 'caption':
|
|
39
|
+
{
|
|
40
|
+
_classPrivateFieldGet(this, _$caption).textContent = newVal;
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
set caption(caption) {
|
|
47
|
+
updateAttribute(this, 'caption', caption);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
get caption() {
|
|
51
|
+
return getAttribute(this, 'caption', '');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
set collapsed(isChecked) {
|
|
55
|
+
updateBooleanAttribute(this, 'collapsed', isChecked);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
get collapsed() {
|
|
59
|
+
return getBooleanAttribute(this, 'collapsed');
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
}));
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import '../icon/expand-less';
|
|
2
|
+
import '../icon/expand-more';
|
|
3
|
+
import type { TSinchElementReact } from '../types';
|
|
4
|
+
import type { FocusEvent, SyntheticEvent } from 'react';
|
|
5
|
+
export declare type TSinchSegmentExpandElement = HTMLElement & {
|
|
6
|
+
value: boolean;
|
|
7
|
+
focus(): void;
|
|
8
|
+
blur(): void;
|
|
9
|
+
};
|
|
10
|
+
export declare type TSinchSegmentExpandReact = TSinchElementReact<TSinchSegmentExpandElement> & {
|
|
11
|
+
value: boolean;
|
|
12
|
+
'aria-label': string;
|
|
13
|
+
onChange: (e: SyntheticEvent<TSinchSegmentExpandElement, CustomEvent<boolean>>) => void;
|
|
14
|
+
onFocus?: (e: FocusEvent<TSinchSegmentExpandElement>) => void;
|
|
15
|
+
onBlur?: (e: FocusEvent<TSinchSegmentExpandElement>) => void;
|
|
16
|
+
};
|
|
17
|
+
declare global {
|
|
18
|
+
namespace JSX {
|
|
19
|
+
interface IntrinsicElements {
|
|
20
|
+
'sinch-segment-collapse': TSinchSegmentExpandReact;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
interface HTMLElementTagNameMap {
|
|
24
|
+
'sinch-segment-collapse': TSinchSegmentExpandElement;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
|
+
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
3
|
+
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
4
|
+
|
|
5
|
+
var _$input;
|
|
6
|
+
|
|
7
|
+
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
8
|
+
|
|
9
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
10
|
+
|
|
11
|
+
import '../icon/expand-less';
|
|
12
|
+
import '../icon/expand-more';
|
|
13
|
+
import { defineCustomElement, getBooleanAttribute, isAttrTrue, updateBooleanAttribute } from '../utils';
|
|
14
|
+
const templateHTML = '<style>:host{display:contents;--sinch-size-icon:32px}input{all:initial;position:absolute;left:0;top:0;width:100%;height:100%;box-sizing:border-box;cursor:pointer}input:focus~sinch-icon-expand-less,input:focus~sinch-icon-expand-more{border-radius:4px;box-shadow:0 0 0 1px var(--sinch-color-stormy-500) inset}#up{display:block}#down{display:none}:host([value]:not([value=false])) #up{display:none}:host([value]:not([value=false])) #down{display:block}</style><input type="checkbox"/><sinch-icon-expand-less id="up"></sinch-icon-expand-less><sinch-icon-expand-more id="down"></sinch-icon-expand-more>';
|
|
15
|
+
const template = document.createElement('template');
|
|
16
|
+
template.innerHTML = templateHTML;
|
|
17
|
+
defineCustomElement('sinch-segment-collapse', (_$input = new WeakMap(), class extends HTMLElement {
|
|
18
|
+
constructor() {
|
|
19
|
+
super();
|
|
20
|
+
|
|
21
|
+
_classPrivateFieldInitSpec(this, _$input, {
|
|
22
|
+
writable: true,
|
|
23
|
+
value: void 0
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
_defineProperty(this, 'onCheckboxInput', e => {
|
|
27
|
+
e.stopPropagation();
|
|
28
|
+
|
|
29
|
+
const isChecked = _classPrivateFieldGet(this, _$input).checked;
|
|
30
|
+
|
|
31
|
+
_classPrivateFieldGet(this, _$input).checked = this.value;
|
|
32
|
+
this.dispatchEvent(new CustomEvent('change', {
|
|
33
|
+
detail: isChecked,
|
|
34
|
+
bubbles: true
|
|
35
|
+
}));
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const shadowRoot = this.attachShadow({
|
|
39
|
+
mode: 'closed'
|
|
40
|
+
});
|
|
41
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
42
|
+
|
|
43
|
+
_classPrivateFieldSet(this, _$input, shadowRoot.querySelector('input'));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
connectedCallback() {
|
|
47
|
+
this.setAttribute('role', 'checkbox');
|
|
48
|
+
|
|
49
|
+
_classPrivateFieldGet(this, _$input).addEventListener('input', this.onCheckboxInput);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
disconnectedCallback() {
|
|
53
|
+
_classPrivateFieldGet(this, _$input).removeEventListener('input', this.onCheckboxInput);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
get type() {
|
|
57
|
+
return 'text';
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
get nodeName() {
|
|
61
|
+
return 'input';
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
static get observedAttributes() {
|
|
65
|
+
return ['value'];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
attributeChangedCallback(name, _, newVal) {
|
|
69
|
+
switch (name) {
|
|
70
|
+
case 'value':
|
|
71
|
+
{
|
|
72
|
+
_classPrivateFieldGet(this, _$input).checked = isAttrTrue(newVal);
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
set value(isChecked) {
|
|
79
|
+
updateBooleanAttribute(this, 'value', isChecked);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
get value() {
|
|
83
|
+
return getBooleanAttribute(this, 'value');
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
focus() {
|
|
87
|
+
_classPrivateFieldGet(this, _$input).focus();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
blur() {
|
|
91
|
+
_classPrivateFieldGet(this, _$input).blur();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
}));
|
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
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
2
|
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
3
|
|
|
4
|
-
var _$input, _$label, _$optionalText, _$additionalText, _$invalidText, _selectionStart, _selectionEnd, _isPendingDk,
|
|
4
|
+
var _$input, _$label, _$optionalText, _$additionalText, _$invalidText, _selectionStart, _selectionEnd, _isPendingDk, _onCompositionStart, _onInput;
|
|
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 { 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
|
-
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(),
|
|
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 {
|
|
15
15
|
constructor() {
|
|
16
16
|
super();
|
|
17
17
|
|
|
@@ -55,12 +55,10 @@ defineCustomElement('sinch-textarea', (_$input = new WeakMap(), _$label = new We
|
|
|
55
55
|
value: false
|
|
56
56
|
});
|
|
57
57
|
|
|
58
|
-
_classPrivateFieldInitSpec(this,
|
|
58
|
+
_classPrivateFieldInitSpec(this, _onCompositionStart, {
|
|
59
59
|
writable: true,
|
|
60
|
-
value:
|
|
61
|
-
|
|
62
|
-
_classPrivateFieldSet(this, _isPendingDk, true);
|
|
63
|
-
}
|
|
60
|
+
value: () => {
|
|
61
|
+
_classPrivateFieldSet(this, _isPendingDk, true);
|
|
64
62
|
}
|
|
65
63
|
});
|
|
66
64
|
|
|
@@ -129,17 +127,17 @@ defineCustomElement('sinch-textarea', (_$input = new WeakMap(), _$label = new We
|
|
|
129
127
|
|
|
130
128
|
_classPrivateFieldGet(this, _$input).addEventListener('input', _classPrivateFieldGet(this, _onInput));
|
|
131
129
|
|
|
132
|
-
_classPrivateFieldGet(this, _$input).addEventListener('
|
|
130
|
+
_classPrivateFieldGet(this, _$input).addEventListener('compositionstart', _classPrivateFieldGet(this, _onCompositionStart));
|
|
133
131
|
}
|
|
134
132
|
|
|
135
133
|
disconnectedCallback() {
|
|
136
134
|
_classPrivateFieldGet(this, _$input).removeEventListener('input', _classPrivateFieldGet(this, _onInput));
|
|
137
135
|
|
|
138
|
-
_classPrivateFieldGet(this, _$input).removeEventListener('
|
|
136
|
+
_classPrivateFieldGet(this, _$input).removeEventListener('compositionstart', _classPrivateFieldGet(this, _onCompositionStart));
|
|
139
137
|
}
|
|
140
138
|
|
|
141
139
|
static get observedAttributes() {
|
|
142
|
-
return ['value', 'placeholder', 'label', 'optionaltext', 'additionaltext', 'invalidtext', 'disabled'];
|
|
140
|
+
return ['value', 'placeholder', 'label', 'optionaltext', 'additionaltext', 'invalidtext', 'disabled', 'rows'];
|
|
143
141
|
}
|
|
144
142
|
|
|
145
143
|
attributeChangedCallback(name, _, newVal) {
|
|
@@ -197,6 +195,12 @@ defineCustomElement('sinch-textarea', (_$input = new WeakMap(), _$label = new We
|
|
|
197
195
|
_classPrivateFieldGet(this, _$input).disabled = isAttrTrue(newVal);
|
|
198
196
|
break;
|
|
199
197
|
}
|
|
198
|
+
|
|
199
|
+
case 'rows':
|
|
200
|
+
{
|
|
201
|
+
updateAttribute(_classPrivateFieldGet(this, _$input), 'rows', newVal);
|
|
202
|
+
break;
|
|
203
|
+
}
|
|
200
204
|
}
|
|
201
205
|
}
|
|
202
206
|
|
|
@@ -260,6 +264,46 @@ defineCustomElement('sinch-textarea', (_$input = new WeakMap(), _$label = new We
|
|
|
260
264
|
return getBooleanAttribute(this, 'disabled');
|
|
261
265
|
}
|
|
262
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
|
+
|
|
263
307
|
focus() {
|
|
264
308
|
_classPrivateFieldGet(this, _$input).focus();
|
|
265
309
|
}
|