@nectary/components 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/accordion/index.d.ts +21 -0
- package/accordion/index.js +118 -0
- package/accordion-item/index.d.ts +33 -0
- package/accordion-item/index.js +139 -0
- package/alert/index.d.ts +26 -0
- package/alert/index.js +91 -0
- package/alert-button/index.d.ts +23 -0
- package/alert-button/index.js +62 -0
- package/alert-close/index.d.ts +22 -0
- package/alert-close/index.js +41 -0
- package/button/index.d.ts +32 -0
- package/button/index.js +100 -0
- package/checkbox/index.d.ts +29 -0
- package/checkbox/index.js +134 -0
- package/help-tooltip/index.d.ts +15 -0
- package/help-tooltip/index.js +80 -0
- package/icon/cancel/index.d.ts +11 -0
- package/icon/cancel/index.js +4 -0
- package/icon/close/index.d.ts +11 -0
- package/icon/close/index.js +4 -0
- package/icon/create-icon-class.d.ts +308 -0
- package/icon/create-icon-class.js +53 -0
- package/icon/east/index.d.ts +11 -0
- package/icon/east/index.js +4 -0
- package/icon/help-outline/index.d.ts +11 -0
- package/icon/help-outline/index.js +4 -0
- package/icon/more-horiz/index.d.ts +11 -0
- package/icon/more-horiz/index.js +4 -0
- package/icon/more-vert/index.d.ts +11 -0
- package/icon/more-vert/index.js +4 -0
- package/icon/north/index.d.ts +11 -0
- package/icon/north/index.js +4 -0
- package/icon/north-east/index.d.ts +11 -0
- package/icon/north-east/index.js +4 -0
- package/icon/north-west/index.d.ts +11 -0
- package/icon/north-west/index.js +4 -0
- package/icon/open-in-new/index.d.ts +11 -0
- package/icon/open-in-new/index.js +4 -0
- package/icon/south/index.d.ts +11 -0
- package/icon/south/index.js +4 -0
- package/icon/south-east/index.d.ts +11 -0
- package/icon/south-east/index.js +4 -0
- package/icon/south-west/index.d.ts +11 -0
- package/icon/south-west/index.js +4 -0
- package/icon/types.d.ts +7 -0
- package/icon/types.js +1 -0
- package/icon/west/index.d.ts +11 -0
- package/icon/west/index.js +4 -0
- package/icon-branded/barchart-down/index.d.ts +11 -0
- package/icon-branded/barchart-down/index.js +4 -0
- package/icon-branded/barchart-up/index.d.ts +11 -0
- package/icon-branded/barchart-up/index.js +4 -0
- package/icon-branded/campaigns/index.d.ts +11 -0
- package/icon-branded/campaigns/index.js +4 -0
- package/icon-branded/chatbot/index.d.ts +11 -0
- package/icon-branded/chatbot/index.js +4 -0
- package/icon-branded/contact/index.d.ts +11 -0
- package/icon-branded/contact/index.js +4 -0
- package/icon-branded/create-icon-class.d.ts +309 -0
- package/icon-branded/create-icon-class.js +61 -0
- package/icon-branded/home/index.d.ts +11 -0
- package/icon-branded/home/index.js +4 -0
- package/icon-branded/multiple-channels/index.d.ts +11 -0
- package/icon-branded/multiple-channels/index.js +4 -0
- package/icon-branded/rocket/index.d.ts +11 -0
- package/icon-branded/rocket/index.js +4 -0
- package/icon-branded/settings/index.d.ts +11 -0
- package/icon-branded/settings/index.js +4 -0
- package/icon-branded/types.d.ts +9 -0
- package/icon-branded/types.js +1 -0
- package/icon-branded/user/index.d.ts +11 -0
- package/icon-branded/user/index.js +4 -0
- package/icon-branded/users/index.d.ts +11 -0
- package/icon-branded/users/index.js +4 -0
- package/index.d.ts +56 -0
- package/index.js +56 -0
- package/input/index.d.ts +35 -0
- package/input/index.js +203 -0
- package/link/index.d.ts +30 -0
- package/link/index.js +118 -0
- package/logo/create-logo-class.d.ts +309 -0
- package/logo/create-logo-class.js +63 -0
- package/logo/sinch-icon/index.d.ts +11 -0
- package/logo/sinch-icon/index.js +4 -0
- package/logo/sinch-icon-wordmark/index.d.ts +11 -0
- package/logo/sinch-icon-wordmark/index.js +4 -0
- package/logo/types.d.ts +9 -0
- package/logo/types.js +1 -0
- package/package.json +34 -0
- package/radio/index.d.ts +19 -0
- package/radio/index.js +185 -0
- package/radio-option/index.d.ts +28 -0
- package/radio-option/index.js +134 -0
- package/readme.md +172 -0
- package/select/index.d.ts +37 -0
- package/select/index.js +492 -0
- package/select-option/index.d.ts +27 -0
- package/select-option/index.js +107 -0
- package/spinner/index.d.ts +21 -0
- package/spinner/index.js +23 -0
- package/table/index.d.ts +13 -0
- package/table/index.js +18 -0
- package/table-body/index.d.ts +13 -0
- package/table-body/index.js +18 -0
- package/table-cell/index.d.ts +20 -0
- package/table-cell/index.js +27 -0
- package/table-head/index.d.ts +13 -0
- package/table-head/index.js +18 -0
- package/table-head-cell/index.d.ts +24 -0
- package/table-head-cell/index.js +74 -0
- package/table-head-sort/index.d.ts +25 -0
- package/table-head-sort/index.js +92 -0
- package/table-row/index.d.ts +17 -0
- package/table-row/index.js +26 -0
- package/tabs/index.d.ts +19 -0
- package/tabs/index.js +181 -0
- package/tabs-option/index.d.ts +28 -0
- package/tabs-option/index.js +129 -0
- package/tag/index.d.ts +27 -0
- package/tag/index.js +79 -0
- package/tag-close/index.d.ts +24 -0
- package/tag-close/index.js +70 -0
- package/textarea/index.d.ts +35 -0
- package/textarea/index.js +201 -0
- package/theme.css +112 -0
- package/toggle/index.d.ts +31 -0
- package/toggle/index.js +144 -0
- package/tooltip/index.d.ts +26 -0
- package/tooltip/index.js +68 -0
- package/types.d.ts +3 -0
- package/utils.d.ts +31 -0
- package/utils.js +146 -0
package/table/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { defineCustomElement } from '../utils';
|
|
2
|
+
const templateHTML = '<style>:host{display:table;font:var(--sinch-font-body)}</style><slot></slot>';
|
|
3
|
+
const template = document.createElement('template');
|
|
4
|
+
template.innerHTML = templateHTML;
|
|
5
|
+
defineCustomElement('sinch-table', class extends HTMLElement {
|
|
6
|
+
constructor() {
|
|
7
|
+
super();
|
|
8
|
+
const shadowRoot = this.attachShadow({
|
|
9
|
+
mode: 'production' === 'development' ? 'open' : 'closed'
|
|
10
|
+
});
|
|
11
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
connectedCallback() {
|
|
15
|
+
this.setAttribute('role', 'table');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { TSinchElementReact } from '../types';
|
|
2
|
+
export declare type TSinchTableBodyElement = HTMLElement;
|
|
3
|
+
export declare type TSinchTableBodyReact = TSinchElementReact<TSinchTableBodyElement>;
|
|
4
|
+
declare global {
|
|
5
|
+
namespace JSX {
|
|
6
|
+
interface IntrinsicElements {
|
|
7
|
+
'sinch-table-body': TSinchTableBodyReact;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
interface HTMLElementTagNameMap {
|
|
11
|
+
'sinch-table-body': TSinchTableBodyElement;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { defineCustomElement } from '../utils';
|
|
2
|
+
const templateHTML = '<style>:host{display:table-row-group}</style><slot></slot>';
|
|
3
|
+
const template = document.createElement('template');
|
|
4
|
+
template.innerHTML = templateHTML;
|
|
5
|
+
defineCustomElement('sinch-table-body', class extends HTMLElement {
|
|
6
|
+
constructor() {
|
|
7
|
+
super();
|
|
8
|
+
const shadowRoot = this.attachShadow({
|
|
9
|
+
mode: 'production' === 'development' ? 'open' : 'closed'
|
|
10
|
+
});
|
|
11
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
connectedCallback() {
|
|
15
|
+
this.setAttribute('role', 'rowgroup');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { TSinchElementReact } from '../types';
|
|
2
|
+
declare const alignValues: readonly ["start", "center", "end"];
|
|
3
|
+
export declare type TAlignType = typeof alignValues[number];
|
|
4
|
+
export declare type TSinchTableCellElement = HTMLElement & {
|
|
5
|
+
align: TAlignType;
|
|
6
|
+
};
|
|
7
|
+
export declare type TSinchTableCellReact = TSinchElementReact<TSinchTableCellElement> & {
|
|
8
|
+
align?: TAlignType;
|
|
9
|
+
};
|
|
10
|
+
declare global {
|
|
11
|
+
namespace JSX {
|
|
12
|
+
interface IntrinsicElements {
|
|
13
|
+
'sinch-table-cell': TSinchTableCellReact;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
interface HTMLElementTagNameMap {
|
|
17
|
+
'sinch-table-cell': TSinchTableCellElement;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { defineCustomElement, getLiteralAttribute, updateLiteralAttribute } from '../utils';
|
|
2
|
+
const templateHTML = '<style>:host{display:table-cell;vertical-align:top;border-bottom:1px solid var(--sinch-color-snow-600)}#wrapper{display:flex;flex-direction:column;justify-content:center;min-height:48px;box-sizing:border-box;padding:8px 4px}:host(:first-child) #wrapper{padding-left:8px}:host(:last-child) #wrapper{padding-right:8px}:host([align=end]) #wrapper{text-align:end;align-items:flex-end}:host([align=center]) #wrapper{text-align:center;align-items:center}</style><div id="wrapper"><slot></slot></div>';
|
|
3
|
+
const template = document.createElement('template');
|
|
4
|
+
template.innerHTML = templateHTML;
|
|
5
|
+
const alignValues = ['start', 'center', 'end'];
|
|
6
|
+
defineCustomElement('sinch-table-cell', class extends HTMLElement {
|
|
7
|
+
constructor() {
|
|
8
|
+
super();
|
|
9
|
+
const shadowRoot = this.attachShadow({
|
|
10
|
+
mode: 'production' === 'development' ? 'open' : 'closed'
|
|
11
|
+
});
|
|
12
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
connectedCallback() {
|
|
16
|
+
this.setAttribute('role', 'cell');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
set align(value) {
|
|
20
|
+
updateLiteralAttribute(this, alignValues, 'align', value);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
get align() {
|
|
24
|
+
return getLiteralAttribute(this, alignValues, 'align', 'start');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { TSinchElementReact } from '../types';
|
|
2
|
+
export declare type TSinchTableHeadElement = HTMLElement;
|
|
3
|
+
export declare type TSinchTableHeadReact = TSinchElementReact<TSinchTableHeadElement>;
|
|
4
|
+
declare global {
|
|
5
|
+
namespace JSX {
|
|
6
|
+
interface IntrinsicElements {
|
|
7
|
+
'sinch-table-head': TSinchTableHeadReact;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
interface HTMLElementTagNameMap {
|
|
11
|
+
'sinch-table-head': TSinchTableHeadElement;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { defineCustomElement } from '../utils';
|
|
2
|
+
const templateHTML = '<style>:host{display:table-header-group}</style><slot></slot>';
|
|
3
|
+
const template = document.createElement('template');
|
|
4
|
+
template.innerHTML = templateHTML;
|
|
5
|
+
defineCustomElement('sinch-table-head', class extends HTMLElement {
|
|
6
|
+
constructor() {
|
|
7
|
+
super();
|
|
8
|
+
const shadowRoot = this.attachShadow({
|
|
9
|
+
mode: 'production' === 'development' ? 'open' : 'closed'
|
|
10
|
+
});
|
|
11
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
connectedCallback() {
|
|
15
|
+
this.setAttribute('role', 'rowgroup');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { TSinchElementReact } from '../types';
|
|
2
|
+
declare const alignValues: readonly ["start", "center", "end"];
|
|
3
|
+
export declare type TAlignType = typeof alignValues[number];
|
|
4
|
+
export declare type TSinchTableHeaderCellElement = HTMLElement & {
|
|
5
|
+
text: string | null;
|
|
6
|
+
align: TAlignType;
|
|
7
|
+
fit: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare type TSinchTableHeaderCellReact = TSinchElementReact<TSinchTableHeaderCellElement> & {
|
|
10
|
+
text?: string;
|
|
11
|
+
fit?: boolean;
|
|
12
|
+
align?: TAlignType;
|
|
13
|
+
};
|
|
14
|
+
declare global {
|
|
15
|
+
namespace JSX {
|
|
16
|
+
interface IntrinsicElements {
|
|
17
|
+
'sinch-table-head-cell': TSinchTableHeaderCellReact;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
interface HTMLElementTagNameMap {
|
|
21
|
+
'sinch-table-head-cell': TSinchTableHeaderCellElement;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
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, getBooleanAttribute, getLiteralAttribute, updateAttribute, updateBooleanAttribute, updateLiteralAttribute } from '../utils';
|
|
11
|
+
const templateHTML = '<style>:host{display:table-cell;border-bottom:1px solid var(--sinch-color-stormy-200);height:48px;vertical-align:middle;padding:0 6px;--sinch-color-icon:var(--sinch-color-stormy-200)}:host(:first-child){padding-left:8px}:host(:last-child){padding-right:8px}#wrapper{width:100%;height:100%;box-sizing:border-box;font:var(--sinch-font-title-4);color:var(--sinch-color-stormy-200);display:flex;align-items:center;gap:4px;position:relative}#text{flex-shrink:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}:host([align=center])>#wrapper{justify-content:center}:host([align=end]) #text{margin-left:auto}:host(:is([text=""],:not([text])))>#wrapper{display:none}:host([fit]:not([fit=false])){width:1px}::slotted(sinch-help-tooltip){position:relative;z-index:1}</style><slot name="checkbox"></slot><div id="wrapper"><span id="text"></span><slot name="tooltip"></slot><slot name="sort"></slot></div>';
|
|
12
|
+
const template = document.createElement('template');
|
|
13
|
+
template.innerHTML = templateHTML;
|
|
14
|
+
const alignValues = ['start', 'center', 'end'];
|
|
15
|
+
defineCustomElement('sinch-table-head-cell', (_$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: 'production' === 'development' ? 'open' : 'closed'
|
|
26
|
+
});
|
|
27
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
28
|
+
|
|
29
|
+
_classPrivateFieldSet(this, _$text, shadowRoot.querySelector('#text'));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
connectedCallback() {
|
|
33
|
+
this.setAttribute('role', 'columnheader');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
static get observedAttributes() {
|
|
37
|
+
return ['text'];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
attributeChangedCallback(name, oldVal, newVal) {
|
|
41
|
+
switch (name) {
|
|
42
|
+
case 'text':
|
|
43
|
+
{
|
|
44
|
+
_classPrivateFieldGet(this, _$text).textContent = newVal;
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
set text(value) {
|
|
51
|
+
updateAttribute(this, 'text', value);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
get text() {
|
|
55
|
+
return getAttribute(this, 'text', null);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
set align(value) {
|
|
59
|
+
updateLiteralAttribute(this, alignValues, 'align', value);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
get align() {
|
|
63
|
+
return getLiteralAttribute(this, alignValues, 'align', 'start');
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
set fit(isFit) {
|
|
67
|
+
updateBooleanAttribute(this, 'fit', isFit);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
get fit() {
|
|
71
|
+
return getBooleanAttribute(this, 'fit');
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
}));
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import '../icon/north';
|
|
2
|
+
import '../icon/south';
|
|
3
|
+
import type { TSinchElementReact } from '../types';
|
|
4
|
+
import type { FocusEvent, SyntheticEvent } from 'react';
|
|
5
|
+
export declare type TSinchTableHeaderSortElement = HTMLElement & {
|
|
6
|
+
value: boolean;
|
|
7
|
+
focus(): void;
|
|
8
|
+
blur(): void;
|
|
9
|
+
};
|
|
10
|
+
export declare type TSinchTableHeaderSortReact = TSinchElementReact<TSinchTableHeaderSortElement> & {
|
|
11
|
+
value: boolean;
|
|
12
|
+
onChange: (e: SyntheticEvent<TSinchTableHeaderSortElement, CustomEvent<boolean>>) => void;
|
|
13
|
+
onFocus?: (e: FocusEvent<TSinchTableHeaderSortElement>) => void;
|
|
14
|
+
onBlur?: (e: FocusEvent<TSinchTableHeaderSortElement>) => void;
|
|
15
|
+
};
|
|
16
|
+
declare global {
|
|
17
|
+
namespace JSX {
|
|
18
|
+
interface IntrinsicElements {
|
|
19
|
+
'sinch-table-head-sort': TSinchTableHeaderSortReact;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
interface HTMLElementTagNameMap {
|
|
23
|
+
'sinch-table-head-sort': TSinchTableHeaderSortElement;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
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/north';
|
|
12
|
+
import '../icon/south';
|
|
13
|
+
import { defineCustomElement, getBooleanAttribute, isAttrTrue, updateBooleanAttribute } from '../utils';
|
|
14
|
+
const templateHTML = '<style>:host{display:contents}input{all:initial;position:absolute;width:100%;height:100%;box-sizing:border-box;cursor:pointer}#up{display:none}#down{display:block}:host([value]:not([value=false])) #up{display:block}:host([value]:not([value=false])) #down{display:none}</style><sinch-icon-north id="up" size="16"></sinch-icon-north><sinch-icon-south id="down" size="16"></sinch-icon-south><input type="checkbox"/>';
|
|
15
|
+
const template = document.createElement('template');
|
|
16
|
+
template.innerHTML = templateHTML;
|
|
17
|
+
defineCustomElement('sinch-table-head-sort', (_$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: 'production' === 'development' ? 'open' : 'closed'
|
|
40
|
+
});
|
|
41
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
42
|
+
|
|
43
|
+
_classPrivateFieldSet(this, _$input, shadowRoot.querySelector('input'));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
connectedCallback() {
|
|
47
|
+
_classPrivateFieldGet(this, _$input).addEventListener('input', this.onCheckboxInput);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
disconnectedCallback() {
|
|
51
|
+
_classPrivateFieldGet(this, _$input).removeEventListener('input', this.onCheckboxInput);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
get type() {
|
|
55
|
+
return 'text';
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
get nodeName() {
|
|
59
|
+
return 'input';
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
static get observedAttributes() {
|
|
63
|
+
return ['value'];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
attributeChangedCallback(name, _, newVal) {
|
|
67
|
+
switch (name) {
|
|
68
|
+
case 'value':
|
|
69
|
+
{
|
|
70
|
+
_classPrivateFieldGet(this, _$input).checked = isAttrTrue(newVal);
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
set value(isChecked) {
|
|
77
|
+
updateBooleanAttribute(this, 'value', isChecked);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
get value() {
|
|
81
|
+
return getBooleanAttribute(this, 'value');
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
focus() {
|
|
85
|
+
_classPrivateFieldGet(this, _$input).focus();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
blur() {
|
|
89
|
+
_classPrivateFieldGet(this, _$input).blur();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
}));
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { TSinchElementReact } from '../types';
|
|
2
|
+
export declare type TSinchTableRowElement = HTMLElement & {
|
|
3
|
+
sticky: boolean;
|
|
4
|
+
};
|
|
5
|
+
export declare type TSinchTableRowReact = TSinchElementReact<TSinchTableRowElement> & {
|
|
6
|
+
sticky?: boolean;
|
|
7
|
+
};
|
|
8
|
+
declare global {
|
|
9
|
+
namespace JSX {
|
|
10
|
+
interface IntrinsicElements {
|
|
11
|
+
'sinch-table-row': TSinchTableRowReact;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
interface HTMLElementTagNameMap {
|
|
15
|
+
'sinch-table-row': TSinchTableRowElement;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { defineCustomElement, getBooleanAttribute, updateBooleanAttribute } from '../utils';
|
|
2
|
+
const templateHTML = '<style>:host{display:table-row}:host([sticky]) ::slotted(sinch-table-head-cell){position:sticky;top:0;z-index:1;background-color:var(--sinch-color-snow-100)}</style><slot></slot>';
|
|
3
|
+
const template = document.createElement('template');
|
|
4
|
+
template.innerHTML = templateHTML;
|
|
5
|
+
defineCustomElement('sinch-table-row', class extends HTMLElement {
|
|
6
|
+
constructor() {
|
|
7
|
+
super();
|
|
8
|
+
const shadowRoot = this.attachShadow({
|
|
9
|
+
mode: 'production' === 'development' ? 'open' : 'closed'
|
|
10
|
+
});
|
|
11
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
connectedCallback() {
|
|
15
|
+
this.setAttribute('role', 'row');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
set sticky(isSticky) {
|
|
19
|
+
updateBooleanAttribute(this, 'sticky', isSticky);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
get sticky() {
|
|
23
|
+
return getBooleanAttribute(this, 'sticky');
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
});
|
package/tabs/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { TSinchElementReact } from '../types';
|
|
2
|
+
import type { SyntheticEvent } from 'react';
|
|
3
|
+
export declare type TSinchTabsElement = HTMLElement & {
|
|
4
|
+
value: string;
|
|
5
|
+
};
|
|
6
|
+
export declare type TSinchTabsReact = TSinchElementReact<TSinchTabsElement> & {
|
|
7
|
+
value: string;
|
|
8
|
+
onChange: (event: SyntheticEvent<TSinchTabsElement, CustomEvent<string>>) => void;
|
|
9
|
+
};
|
|
10
|
+
declare global {
|
|
11
|
+
namespace JSX {
|
|
12
|
+
interface IntrinsicElements {
|
|
13
|
+
'sinch-tabs': TSinchTabsReact;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
interface HTMLElementTagNameMap {
|
|
17
|
+
'sinch-tabs': TSinchTabsElement;
|
|
18
|
+
}
|
|
19
|
+
}
|
package/tabs/index.js
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
2
|
+
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
3
|
+
|
|
4
|
+
var _$slot, _onOptionKeyDown, _onSlotChange, _onOptionChange;
|
|
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 { isTabsOptionElement } from '../tabs-option';
|
|
11
|
+
import { defineCustomElement, getAttribute, updateAttribute } from '../utils';
|
|
12
|
+
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{display:flex;flex-direction:row;height:60px;width:100%;box-sizing:border-box;overflow-x:auto}</style><div id="wrapper"><slot></slot></div>';
|
|
13
|
+
|
|
14
|
+
const getEnabledRadioElements = $slot => {
|
|
15
|
+
return $slot.assignedElements().filter(opt => isTabsOptionElement(opt) && opt.disabled !== true);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const findSelectedOption = elements => {
|
|
19
|
+
return elements.find(el => el.checked) ?? null;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const getFirstOption = $slot => {
|
|
23
|
+
for (const $option of $slot.assignedElements()) {
|
|
24
|
+
if (isTabsOptionElement($option) && $option.disabled !== true) {
|
|
25
|
+
return $option;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return null;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const getLastOption = $slot => {
|
|
33
|
+
for (const $option of $slot.assignedElements().reverse()) {
|
|
34
|
+
if (isTabsOptionElement($option) && $option.disabled !== true) {
|
|
35
|
+
return $option;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return null;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const getNextOption = $slot => {
|
|
43
|
+
const $options = getEnabledRadioElements($slot);
|
|
44
|
+
const $selectedOption = findSelectedOption($options);
|
|
45
|
+
const currentIndex = $selectedOption !== null ? $options.indexOf($selectedOption) : -1;
|
|
46
|
+
|
|
47
|
+
if (currentIndex < 0) {
|
|
48
|
+
return getFirstOption($slot);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return $options[(currentIndex + 1) % $options.length];
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const getPrevOption = $slot => {
|
|
55
|
+
const $options = getEnabledRadioElements($slot);
|
|
56
|
+
const $selectedOption = findSelectedOption($options);
|
|
57
|
+
const currentIndex = $selectedOption !== null ? $options.indexOf($selectedOption) : -1;
|
|
58
|
+
|
|
59
|
+
if (currentIndex < 0) {
|
|
60
|
+
return getLastOption($slot);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return $options[(currentIndex - 1 + $options.length) % $options.length];
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const template = document.createElement('template');
|
|
67
|
+
template.innerHTML = templateHTML;
|
|
68
|
+
defineCustomElement('sinch-tabs', (_$slot = new WeakMap(), _onOptionKeyDown = new WeakMap(), _onSlotChange = new WeakMap(), _onOptionChange = new WeakMap(), class extends HTMLElement {
|
|
69
|
+
constructor() {
|
|
70
|
+
super();
|
|
71
|
+
|
|
72
|
+
_classPrivateFieldInitSpec(this, _$slot, {
|
|
73
|
+
writable: true,
|
|
74
|
+
value: void 0
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
_classPrivateFieldInitSpec(this, _onOptionKeyDown, {
|
|
78
|
+
writable: true,
|
|
79
|
+
value: e => {
|
|
80
|
+
switch (e.code) {
|
|
81
|
+
case 'ArrowUp':
|
|
82
|
+
case 'ArrowLeft':
|
|
83
|
+
{
|
|
84
|
+
e.preventDefault();
|
|
85
|
+
const $option = getPrevOption(_classPrivateFieldGet(this, _$slot));
|
|
86
|
+
|
|
87
|
+
if ($option !== null) {
|
|
88
|
+
$option.focus();
|
|
89
|
+
this.dispatchChangeEvent($option.value);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
case 'ArrowDown':
|
|
96
|
+
case 'ArrowRight':
|
|
97
|
+
{
|
|
98
|
+
e.preventDefault();
|
|
99
|
+
const $option = getNextOption(_classPrivateFieldGet(this, _$slot));
|
|
100
|
+
|
|
101
|
+
if ($option !== null) {
|
|
102
|
+
$option.focus();
|
|
103
|
+
this.dispatchChangeEvent($option.value);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
_classPrivateFieldInitSpec(this, _onSlotChange, {
|
|
113
|
+
writable: true,
|
|
114
|
+
value: () => {
|
|
115
|
+
this.onValueChange(this.value);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
_classPrivateFieldInitSpec(this, _onOptionChange, {
|
|
120
|
+
writable: true,
|
|
121
|
+
value: e => {
|
|
122
|
+
e.stopPropagation();
|
|
123
|
+
this.dispatchChangeEvent(e.detail);
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
const shadowRoot = this.attachShadow({
|
|
128
|
+
mode: 'production' === 'development' ? 'open' : 'closed',
|
|
129
|
+
delegatesFocus: true
|
|
130
|
+
});
|
|
131
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
132
|
+
shadowRoot.addEventListener('keydown', _classPrivateFieldGet(this, _onOptionKeyDown));
|
|
133
|
+
shadowRoot.addEventListener('change', _classPrivateFieldGet(this, _onOptionChange));
|
|
134
|
+
|
|
135
|
+
_classPrivateFieldSet(this, _$slot, shadowRoot.querySelector('slot'));
|
|
136
|
+
|
|
137
|
+
_classPrivateFieldGet(this, _$slot).addEventListener('slotchange', _classPrivateFieldGet(this, _onSlotChange));
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
static get observedAttributes() {
|
|
141
|
+
return ['value'];
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
get nodeName() {
|
|
145
|
+
return 'select';
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
set value(value) {
|
|
149
|
+
updateAttribute(this, 'value', value);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
get value() {
|
|
153
|
+
return getAttribute(this, 'value', '');
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
attributeChangedCallback(name, oldVal, newVal) {
|
|
157
|
+
switch (name) {
|
|
158
|
+
case 'value':
|
|
159
|
+
{
|
|
160
|
+
this.onValueChange(newVal ?? '');
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
onValueChange(value) {
|
|
167
|
+
for (const $option of _classPrivateFieldGet(this, _$slot).assignedElements()) {
|
|
168
|
+
if (isTabsOptionElement($option)) {
|
|
169
|
+
$option.checked = $option.disabled !== true && $option.value === value;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
dispatchChangeEvent(value) {
|
|
175
|
+
this.dispatchEvent(new CustomEvent('change', {
|
|
176
|
+
detail: value,
|
|
177
|
+
bubbles: true
|
|
178
|
+
}));
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
}));
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { TSinchElementReact } from '../types';
|
|
2
|
+
import type { FocusEvent } from 'react';
|
|
3
|
+
export declare const isTabsOptionElement: (element: EventTarget | Element | null) => element is TSinchTabsOptionElement;
|
|
4
|
+
export declare type TSinchTabsOptionElement = HTMLElement & {
|
|
5
|
+
value: string;
|
|
6
|
+
disabled: boolean;
|
|
7
|
+
checked: boolean;
|
|
8
|
+
text: string;
|
|
9
|
+
focus(): void;
|
|
10
|
+
blur(): void;
|
|
11
|
+
};
|
|
12
|
+
export declare type TSinchTabsOptionReact = TSinchElementReact<TSinchTabsOptionElement> & {
|
|
13
|
+
value: string;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
text: string;
|
|
16
|
+
onFocus?: (e: FocusEvent<TSinchTabsOptionElement>) => void;
|
|
17
|
+
onBlur?: (e: FocusEvent<TSinchTabsOptionElement>) => void;
|
|
18
|
+
};
|
|
19
|
+
declare global {
|
|
20
|
+
namespace JSX {
|
|
21
|
+
interface IntrinsicElements {
|
|
22
|
+
'sinch-tabs-option': TSinchTabsOptionReact;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
interface HTMLElementTagNameMap {
|
|
26
|
+
'sinch-tabs-option': TSinchTabsOptionElement;
|
|
27
|
+
}
|
|
28
|
+
}
|