@nectary/components 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/accordion/index.d.ts +21 -0
- package/accordion/index.js +118 -0
- package/accordion-item/index.d.ts +33 -0
- package/accordion-item/index.js +139 -0
- package/alert/index.d.ts +26 -0
- package/alert/index.js +91 -0
- package/alert-button/index.d.ts +23 -0
- package/alert-button/index.js +62 -0
- package/alert-close/index.d.ts +22 -0
- package/alert-close/index.js +41 -0
- package/button/index.d.ts +32 -0
- package/button/index.js +100 -0
- package/checkbox/index.d.ts +29 -0
- package/checkbox/index.js +134 -0
- package/help-tooltip/index.d.ts +15 -0
- package/help-tooltip/index.js +80 -0
- package/icon/cancel/index.d.ts +11 -0
- package/icon/cancel/index.js +4 -0
- package/icon/close/index.d.ts +11 -0
- package/icon/close/index.js +4 -0
- package/icon/create-icon-class.d.ts +308 -0
- package/icon/create-icon-class.js +53 -0
- package/icon/east/index.d.ts +11 -0
- package/icon/east/index.js +4 -0
- package/icon/help-outline/index.d.ts +11 -0
- package/icon/help-outline/index.js +4 -0
- package/icon/more-horiz/index.d.ts +11 -0
- package/icon/more-horiz/index.js +4 -0
- package/icon/more-vert/index.d.ts +11 -0
- package/icon/more-vert/index.js +4 -0
- package/icon/north/index.d.ts +11 -0
- package/icon/north/index.js +4 -0
- package/icon/north-east/index.d.ts +11 -0
- package/icon/north-east/index.js +4 -0
- package/icon/north-west/index.d.ts +11 -0
- package/icon/north-west/index.js +4 -0
- package/icon/open-in-new/index.d.ts +11 -0
- package/icon/open-in-new/index.js +4 -0
- package/icon/south/index.d.ts +11 -0
- package/icon/south/index.js +4 -0
- package/icon/south-east/index.d.ts +11 -0
- package/icon/south-east/index.js +4 -0
- package/icon/south-west/index.d.ts +11 -0
- package/icon/south-west/index.js +4 -0
- package/icon/types.d.ts +7 -0
- package/icon/types.js +1 -0
- package/icon/west/index.d.ts +11 -0
- package/icon/west/index.js +4 -0
- package/icon-branded/barchart-down/index.d.ts +11 -0
- package/icon-branded/barchart-down/index.js +4 -0
- package/icon-branded/barchart-up/index.d.ts +11 -0
- package/icon-branded/barchart-up/index.js +4 -0
- package/icon-branded/campaigns/index.d.ts +11 -0
- package/icon-branded/campaigns/index.js +4 -0
- package/icon-branded/chatbot/index.d.ts +11 -0
- package/icon-branded/chatbot/index.js +4 -0
- package/icon-branded/contact/index.d.ts +11 -0
- package/icon-branded/contact/index.js +4 -0
- package/icon-branded/create-icon-class.d.ts +309 -0
- package/icon-branded/create-icon-class.js +61 -0
- package/icon-branded/home/index.d.ts +11 -0
- package/icon-branded/home/index.js +4 -0
- package/icon-branded/multiple-channels/index.d.ts +11 -0
- package/icon-branded/multiple-channels/index.js +4 -0
- package/icon-branded/rocket/index.d.ts +11 -0
- package/icon-branded/rocket/index.js +4 -0
- package/icon-branded/settings/index.d.ts +11 -0
- package/icon-branded/settings/index.js +4 -0
- package/icon-branded/types.d.ts +9 -0
- package/icon-branded/types.js +1 -0
- package/icon-branded/user/index.d.ts +11 -0
- package/icon-branded/user/index.js +4 -0
- package/icon-branded/users/index.d.ts +11 -0
- package/icon-branded/users/index.js +4 -0
- package/index.d.ts +56 -0
- package/index.js +56 -0
- package/input/index.d.ts +35 -0
- package/input/index.js +203 -0
- package/link/index.d.ts +30 -0
- package/link/index.js +118 -0
- package/logo/create-logo-class.d.ts +309 -0
- package/logo/create-logo-class.js +63 -0
- package/logo/sinch-icon/index.d.ts +11 -0
- package/logo/sinch-icon/index.js +4 -0
- package/logo/sinch-icon-wordmark/index.d.ts +11 -0
- package/logo/sinch-icon-wordmark/index.js +4 -0
- package/logo/types.d.ts +9 -0
- package/logo/types.js +1 -0
- package/package.json +34 -0
- package/radio/index.d.ts +19 -0
- package/radio/index.js +185 -0
- package/radio-option/index.d.ts +28 -0
- package/radio-option/index.js +134 -0
- package/readme.md +172 -0
- package/select/index.d.ts +37 -0
- package/select/index.js +492 -0
- package/select-option/index.d.ts +27 -0
- package/select-option/index.js +107 -0
- package/spinner/index.d.ts +21 -0
- package/spinner/index.js +23 -0
- package/table/index.d.ts +13 -0
- package/table/index.js +18 -0
- package/table-body/index.d.ts +13 -0
- package/table-body/index.js +18 -0
- package/table-cell/index.d.ts +20 -0
- package/table-cell/index.js +27 -0
- package/table-head/index.d.ts +13 -0
- package/table-head/index.js +18 -0
- package/table-head-cell/index.d.ts +24 -0
- package/table-head-cell/index.js +74 -0
- package/table-head-sort/index.d.ts +25 -0
- package/table-head-sort/index.js +92 -0
- package/table-row/index.d.ts +17 -0
- package/table-row/index.js +26 -0
- package/tabs/index.d.ts +19 -0
- package/tabs/index.js +181 -0
- package/tabs-option/index.d.ts +28 -0
- package/tabs-option/index.js +129 -0
- package/tag/index.d.ts +27 -0
- package/tag/index.js +79 -0
- package/tag-close/index.d.ts +24 -0
- package/tag-close/index.js +70 -0
- package/textarea/index.d.ts +35 -0
- package/textarea/index.js +201 -0
- package/theme.css +112 -0
- package/toggle/index.d.ts +31 -0
- package/toggle/index.js +144 -0
- package/tooltip/index.d.ts +26 -0
- package/tooltip/index.js +68 -0
- package/types.d.ts +3 -0
- package/utils.d.ts +31 -0
- package/utils.js +146 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { TSinchElementReact } from '../types';
|
|
2
|
+
import type { SyntheticEvent } from 'react';
|
|
3
|
+
export declare type TSinchAccordionElement = HTMLElement & {
|
|
4
|
+
value: string;
|
|
5
|
+
multiple: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare type TSinchAccordionReact = TSinchElementReact<TSinchAccordionElement> & {
|
|
8
|
+
multiple?: boolean;
|
|
9
|
+
value: string;
|
|
10
|
+
onChange: (e: SyntheticEvent<TSinchAccordionElement, CustomEvent<string>>) => void;
|
|
11
|
+
};
|
|
12
|
+
declare global {
|
|
13
|
+
namespace JSX {
|
|
14
|
+
interface IntrinsicElements {
|
|
15
|
+
'sinch-accordion': TSinchAccordionReact;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
interface HTMLElementTagNameMap {
|
|
19
|
+
'sinch-accordion': TSinchAccordionElement;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
2
|
+
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
3
|
+
|
|
4
|
+
var _$slot, _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 { isAccordionItemElement } from '../accordion-item';
|
|
11
|
+
import { defineCustomElement, getAttribute, getBooleanAttribute, getCSVSet, getFirstCSValue, updateAttribute, updateBooleanAttribute, updateCSV } from '../utils';
|
|
12
|
+
const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:column;box-sizing:border-box;width:100%;height:100%}::slotted(sinch-accordion-item){flex-shrink:1}</style><div id="wrapper"><slot></slot></div>';
|
|
13
|
+
const template = document.createElement('template');
|
|
14
|
+
template.innerHTML = templateHTML;
|
|
15
|
+
defineCustomElement('sinch-accordion', (_$slot = new WeakMap(), _onSlotChange = new WeakMap(), _onOptionChange = new WeakMap(), class extends HTMLElement {
|
|
16
|
+
constructor() {
|
|
17
|
+
super();
|
|
18
|
+
|
|
19
|
+
_classPrivateFieldInitSpec(this, _$slot, {
|
|
20
|
+
writable: true,
|
|
21
|
+
value: void 0
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
_classPrivateFieldInitSpec(this, _onSlotChange, {
|
|
25
|
+
writable: true,
|
|
26
|
+
value: () => {
|
|
27
|
+
this.onValueChange(this.value);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
_classPrivateFieldInitSpec(this, _onOptionChange, {
|
|
32
|
+
writable: true,
|
|
33
|
+
value: e => {
|
|
34
|
+
e.stopPropagation();
|
|
35
|
+
|
|
36
|
+
if (!isAccordionItemElement(e.target)) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const {
|
|
41
|
+
value,
|
|
42
|
+
isChecked
|
|
43
|
+
} = e.detail;
|
|
44
|
+
const csv = updateCSV(this.multiple ? this.value : value, value, isChecked);
|
|
45
|
+
this.dispatchEvent(new CustomEvent('change', {
|
|
46
|
+
detail: csv,
|
|
47
|
+
bubbles: true
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const shadowRoot = this.attachShadow({
|
|
53
|
+
mode: 'production' === 'development' ? 'open' : 'closed',
|
|
54
|
+
delegatesFocus: true
|
|
55
|
+
});
|
|
56
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
57
|
+
shadowRoot.addEventListener('change', _classPrivateFieldGet(this, _onOptionChange));
|
|
58
|
+
|
|
59
|
+
_classPrivateFieldSet(this, _$slot, shadowRoot.querySelector('slot'));
|
|
60
|
+
|
|
61
|
+
_classPrivateFieldGet(this, _$slot).addEventListener('slotchange', _classPrivateFieldGet(this, _onSlotChange));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
static get observedAttributes() {
|
|
65
|
+
return ['value'];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
get nodeName() {
|
|
69
|
+
return 'select';
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
set value(value) {
|
|
73
|
+
updateAttribute(this, 'value', value);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
get value() {
|
|
77
|
+
return getAttribute(this, 'value', '');
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
set multiple(isMultiple) {
|
|
81
|
+
updateBooleanAttribute(this, 'multiple', isMultiple);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
get multiple() {
|
|
85
|
+
return getBooleanAttribute(this, 'multiple');
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
attributeChangedCallback(name, oldVal, newVal) {
|
|
89
|
+
switch (name) {
|
|
90
|
+
case 'value':
|
|
91
|
+
{
|
|
92
|
+
this.onValueChange(newVal ?? '');
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
onValueChange(csv) {
|
|
99
|
+
if (this.multiple) {
|
|
100
|
+
const values = getCSVSet(csv);
|
|
101
|
+
|
|
102
|
+
for (const $option of _classPrivateFieldGet(this, _$slot).assignedElements()) {
|
|
103
|
+
if (isAccordionItemElement($option)) {
|
|
104
|
+
$option.checked = $option.disabled !== true && values.has($option.value);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
} else {
|
|
108
|
+
const value = getFirstCSValue(csv);
|
|
109
|
+
|
|
110
|
+
for (const $option of _classPrivateFieldGet(this, _$slot).assignedElements()) {
|
|
111
|
+
if (isAccordionItemElement($option)) {
|
|
112
|
+
$option.checked = $option.disabled !== true && $option.value === value;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
}));
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { TSinchElementReact } from '../types';
|
|
2
|
+
import type { FocusEvent } from 'react';
|
|
3
|
+
export declare const isAccordionItemElement: (element: EventTarget | Element | null) => element is TSinchAccordionItemElement;
|
|
4
|
+
declare const statusValues: readonly ["info", "success", "warn", "error"];
|
|
5
|
+
export declare type TSinchAccordionStatusType = typeof statusValues[number];
|
|
6
|
+
export declare type TSinchAccordionItemElement = HTMLElement & {
|
|
7
|
+
value: string;
|
|
8
|
+
label: string;
|
|
9
|
+
disabled: boolean;
|
|
10
|
+
checked: boolean;
|
|
11
|
+
status: TSinchAccordionStatusType | null;
|
|
12
|
+
focus(): void;
|
|
13
|
+
blur(): void;
|
|
14
|
+
};
|
|
15
|
+
export declare type TSinchAccordionItemReact = TSinchElementReact<TSinchAccordionItemElement> & {
|
|
16
|
+
value: string;
|
|
17
|
+
label: string;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
status?: TSinchAccordionStatusType;
|
|
20
|
+
onFocus?: (e: FocusEvent<TSinchAccordionItemElement>) => void;
|
|
21
|
+
onBlur?: (e: FocusEvent<TSinchAccordionItemElement>) => void;
|
|
22
|
+
};
|
|
23
|
+
declare global {
|
|
24
|
+
namespace JSX {
|
|
25
|
+
interface IntrinsicElements {
|
|
26
|
+
'sinch-accordion-item': TSinchAccordionItemReact;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
interface HTMLElementTagNameMap {
|
|
30
|
+
'sinch-accordion-item': TSinchAccordionItemElement;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
|
+
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
|
+
|
|
4
|
+
var _$button, _$labelContent, _onButtonClick;
|
|
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, 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)}#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)}#content{flex:1;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}#box{display:none;overflow-y:auto;flex-shrink:1;min-height:0;padding:0 8px 18px;font:var(--sinch-font-body)}#button[aria-expanded=true]>#dropdown-icon{transform:rotate(180deg)}#button[aria-expanded=true]+#box{display:block}</style><div id="wrapper"><button id="button" aria-haspopup="box" aria-expanded="false" aria-labelledby="button"><slot name="icon"></slot><span id="content"></span> <svg id="dropdown-icon" width="12" height="8"><path d="M1.41.59 6 5.17 10.59.59 12 2 6 8 0 2 1.41.59Z"/></svg></button><div id="box"><slot name="content"></slot></div></div>';
|
|
12
|
+
export const isAccordionItemElement = element => {
|
|
13
|
+
return element instanceof Element && element.tagName === 'SINCH-ACCORDION-ITEM';
|
|
14
|
+
};
|
|
15
|
+
const statusValues = ['info', 'success', 'warn', 'error'];
|
|
16
|
+
const template = document.createElement('template');
|
|
17
|
+
template.innerHTML = templateHTML;
|
|
18
|
+
defineCustomElement('sinch-accordion-item', (_$button = new WeakMap(), _$labelContent = new WeakMap(), _onButtonClick = new WeakMap(), class extends HTMLElement {
|
|
19
|
+
constructor() {
|
|
20
|
+
super();
|
|
21
|
+
|
|
22
|
+
_classPrivateFieldInitSpec(this, _$button, {
|
|
23
|
+
writable: true,
|
|
24
|
+
value: void 0
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
_classPrivateFieldInitSpec(this, _$labelContent, {
|
|
28
|
+
writable: true,
|
|
29
|
+
value: void 0
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
_classPrivateFieldInitSpec(this, _onButtonClick, {
|
|
33
|
+
writable: true,
|
|
34
|
+
value: e => {
|
|
35
|
+
e.stopPropagation();
|
|
36
|
+
this.dispatchEvent(new CustomEvent('change', {
|
|
37
|
+
bubbles: true,
|
|
38
|
+
detail: {
|
|
39
|
+
value: this.value,
|
|
40
|
+
isChecked: !this.checked
|
|
41
|
+
}
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const shadowRoot = this.attachShadow({
|
|
47
|
+
mode: 'production' === 'development' ? 'open' : 'closed',
|
|
48
|
+
delegatesFocus: true
|
|
49
|
+
});
|
|
50
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
51
|
+
|
|
52
|
+
_classPrivateFieldSet(this, _$button, shadowRoot.querySelector('#button'));
|
|
53
|
+
|
|
54
|
+
_classPrivateFieldSet(this, _$labelContent, shadowRoot.querySelector('#content'));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
connectedCallback() {
|
|
58
|
+
_classPrivateFieldGet(this, _$button).addEventListener('click', _classPrivateFieldGet(this, _onButtonClick));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
disconnectedCallback() {
|
|
62
|
+
_classPrivateFieldGet(this, _$button).removeEventListener('click', _classPrivateFieldGet(this, _onButtonClick));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
static get observedAttributes() {
|
|
66
|
+
return ['label', 'disabled', 'checked'];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
set value(value) {
|
|
70
|
+
updateAttribute(this, 'value', value);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
get value() {
|
|
74
|
+
return getAttribute(this, 'value', '');
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
set label(value) {
|
|
78
|
+
updateAttribute(this, 'label', value);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
get label() {
|
|
82
|
+
return getAttribute(this, 'label', '');
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
set checked(isChecked) {
|
|
86
|
+
updateBooleanAttribute(this, 'checked', isChecked);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
get checked() {
|
|
90
|
+
return getBooleanAttribute(this, 'checked');
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
set disabled(isDisabled) {
|
|
94
|
+
updateBooleanAttribute(this, 'disabled', isDisabled);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
get disabled() {
|
|
98
|
+
return getBooleanAttribute(this, 'disabled');
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
get status() {
|
|
102
|
+
return getLiteralAttribute(this, statusValues, 'status', null);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
set status(value) {
|
|
106
|
+
updateLiteralAttribute(this, statusValues, 'status', value);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
attributeChangedCallback(name, oldVal, newVal) {
|
|
110
|
+
switch (name) {
|
|
111
|
+
case 'label':
|
|
112
|
+
{
|
|
113
|
+
_classPrivateFieldGet(this, _$labelContent).textContent = newVal;
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
case 'disabled':
|
|
118
|
+
{
|
|
119
|
+
_classPrivateFieldGet(this, _$button).disabled = isAttrTrue(newVal);
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
case 'checked':
|
|
124
|
+
{
|
|
125
|
+
updateAttribute(_classPrivateFieldGet(this, _$button), 'aria-expanded', isAttrTrue(newVal));
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
focus() {
|
|
132
|
+
_classPrivateFieldGet(this, _$button).focus();
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
blur() {
|
|
136
|
+
_classPrivateFieldGet(this, _$button).blur();
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
}));
|
package/alert/index.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { TSinchElementReact } from '../types';
|
|
2
|
+
declare const typeValues: readonly ["info", "success", "warn", "error"];
|
|
3
|
+
export declare type TSinchAlertType = typeof typeValues[number];
|
|
4
|
+
export declare type TSinchAlertElement = HTMLElement & {
|
|
5
|
+
type: TSinchAlertType;
|
|
6
|
+
text: string;
|
|
7
|
+
title: string;
|
|
8
|
+
multiline: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare type TSinchAlertReact = TSinchElementReact<TSinchAlertElement> & {
|
|
11
|
+
type: TSinchAlertType;
|
|
12
|
+
text: string;
|
|
13
|
+
title?: string;
|
|
14
|
+
multiline?: boolean;
|
|
15
|
+
};
|
|
16
|
+
declare global {
|
|
17
|
+
namespace JSX {
|
|
18
|
+
interface IntrinsicElements {
|
|
19
|
+
'sinch-alert': TSinchAlertReact;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
interface HTMLElementTagNameMap {
|
|
23
|
+
'sinch-alert': TSinchAlertElement;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export {};
|
package/alert/index.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
|
+
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
|
+
|
|
4
|
+
var _$text, _$title;
|
|
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, getBooleanAttribute, getAttribute, getLiteralAttribute, updateBooleanAttribute, updateAttribute, updateLiteralAttribute } from '../utils';
|
|
11
|
+
const templateHTML = '<style>:host{--sinch-color-alert-info-background:#D5E5F8;--sinch-color-alert-success-background:#D7F1D8;--sinch-color-alert-warn-background:#FFE8D6;--sinch-color-alert-error-background:#FCD7D4;display:block}#wrapper{display:flex;flex-direction:row;column-gap:12px;align-items:center;position:relative;padding:12px 18px;border-radius:4px;font:var(--sinch-font-body);color:var(--sinch-color-stormy-600);background-color:var(--sinch-color-alert-info-background);box-sizing:border-box;width:100%;min-height:56px}#body-wrapper{display:flex;flex-direction:row;align-items:center;column-gap:12px;flex:1;min-width:0}#title{display:none;font:var(--sinch-font-title-4);margin:0;margin-bottom:4px}#text{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin:0;flex:1;min-width:0}:is(#icon-info,#icon-success,#icon-warn,#icon-error){display:none}:host([type=success]) #wrapper{background-color:var(--sinch-color-alert-success-background)}:host([type=warn]) #wrapper{background-color:var(--sinch-color-alert-warn-background)}:host([type=error]) #wrapper{background-color:var(--sinch-color-alert-error-background)}:host([type=info]) #wrapper{background-color:var(--sinch-color-alert-info-background)}:host([type=success]) #icon-success{display:block}:host([type=warn]) #icon-warn{display:block}:host([type=error]) #icon-error{display:block}:host(:is([type=info],:not([type]))) #icon-info{display:block}:host([multiline]:not([multiline=false])) #wrapper{align-items:flex-start;padding:16px 18px}:host([multiline]:not([multiline=false])) #body-wrapper{flex-direction:column;align-items:flex-start}:host([multiline]:not([multiline=false])) #title{display:block}:host([multiline]:not([multiline=false])) :is(#icon-info,#icon-success,#icon-warn,#icon-error){margin-top:2px}:host([multiline]:not([multiline=false])) #text{overflow:unset;text-overflow:unset;white-space:unset}:host([multiline]:not([multiline=false])) ::slotted(sinch-alert-button){margin-top:10px}</style><div id="wrapper"><svg id="icon-info" width="20" height="20" viewBox="0 0 20 20"><path d="M10 0C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0Zm0 15c-.55 0-1-.45-1-1v-4c0-.55.45-1 1-1s1 .45 1 1v4c0 .55-.45 1-1 1Zm1-8H9V5h2v2Z" fill="#2071CE"/></svg> <svg id="icon-success" width="20" height="20" viewBox="0 0 20 20"><path d="M10 0C4.48 0 0 4.48 0 10s4.48 10 10 10 10-4.48 10-10S15.52 0 10 0ZM7.29 14.29 3.7 10.7a.996.996 0 1 1 1.41-1.41L8 12.17l6.88-6.88a.996.996 0 1 1 1.41 1.41L8.7 14.29a.996.996 0 0 1-1.41 0Z" fill="#2E8540"/></svg> <svg id="icon-warn" width="20" height="20" viewBox="0 0 20 20"><path d="M2.47 18h15.06c1.54 0 2.5-1.67 1.73-3L11.73 1.99c-.77-1.33-2.69-1.33-3.46 0L.74 15c-.77 1.33.19 3 1.73 3ZM10 11c-.55 0-1-.45-1-1V8c0-.55.45-1 1-1s1 .45 1 1v2c0 .55-.45 1-1 1Zm1 4H9v-2h2v2Z" fill="#FF8C34"/></svg> <svg id="icon-error" width="20" height="20" viewBox="0 0 18 18"><path d="M12.32 0H5.68c-.26 0-.52.11-.7.29L.29 4.98c-.18.18-.29.44-.29.7v6.63c0 .27.11.52.29.71l4.68 4.68c.19.19.45.3.71.3h6.63c.27 0 .52-.11.71-.29l4.68-4.68a.99.99 0 0 0 .29-.71V5.68c0-.27-.11-.52-.29-.71L13.02.29c-.18-.18-.44-.29-.7-.29ZM9 14.3c-.72 0-1.3-.58-1.3-1.3 0-.72.58-1.3 1.3-1.3.72 0 1.3.58 1.3 1.3 0 .72-.58 1.3-1.3 1.3ZM9 10c-.55 0-1-.45-1-1V5c0-.55.45-1 1-1s1 .45 1 1v4c0 .55-.45 1-1 1Z" fill="#E31C3D"/></svg><div id="body-wrapper"><p id="title"></p><p id="text"></p><slot name="button"></slot></div><slot name="close"></slot></div>';
|
|
12
|
+
const typeValues = ['info', 'success', 'warn', 'error'];
|
|
13
|
+
const template = document.createElement('template');
|
|
14
|
+
template.innerHTML = templateHTML;
|
|
15
|
+
defineCustomElement('sinch-alert', (_$text = new WeakMap(), _$title = new WeakMap(), class extends HTMLElement {
|
|
16
|
+
constructor() {
|
|
17
|
+
super();
|
|
18
|
+
|
|
19
|
+
_classPrivateFieldInitSpec(this, _$text, {
|
|
20
|
+
writable: true,
|
|
21
|
+
value: void 0
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
_classPrivateFieldInitSpec(this, _$title, {
|
|
25
|
+
writable: true,
|
|
26
|
+
value: void 0
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const shadowRoot = this.attachShadow({
|
|
30
|
+
mode: 'production' === 'development' ? 'open' : 'closed'
|
|
31
|
+
});
|
|
32
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
33
|
+
|
|
34
|
+
_classPrivateFieldSet(this, _$text, shadowRoot.querySelector('#text'));
|
|
35
|
+
|
|
36
|
+
_classPrivateFieldSet(this, _$title, shadowRoot.querySelector('#title'));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
get type() {
|
|
40
|
+
return getLiteralAttribute(this, typeValues, 'type');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
set type(value) {
|
|
44
|
+
updateLiteralAttribute(this, typeValues, 'type', value);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
get text() {
|
|
48
|
+
return getAttribute(this, 'text', '');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
set text(value) {
|
|
52
|
+
updateAttribute(this, 'text', value);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
get title() {
|
|
56
|
+
return getAttribute(this, 'title', '');
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
set title(value) {
|
|
60
|
+
updateAttribute(this, 'title', value);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
get multiline() {
|
|
64
|
+
return getBooleanAttribute(this, 'multiline');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
set multiline(isMultiline) {
|
|
68
|
+
updateBooleanAttribute(this, 'multiline', isMultiline);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
static get observedAttributes() {
|
|
72
|
+
return ['text', 'title'];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
attributeChangedCallback(name, _, newVal) {
|
|
76
|
+
switch (name) {
|
|
77
|
+
case 'text':
|
|
78
|
+
{
|
|
79
|
+
_classPrivateFieldGet(this, _$text).textContent = newVal;
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
case 'title':
|
|
84
|
+
{
|
|
85
|
+
_classPrivateFieldGet(this, _$title).textContent = newVal;
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
}));
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { TSinchElementReact } from '../types';
|
|
2
|
+
import type { FocusEvent, MouseEvent } from 'react';
|
|
3
|
+
export declare type TSinchAlertButtonElement = HTMLElement & {
|
|
4
|
+
text: string;
|
|
5
|
+
focus(): void;
|
|
6
|
+
blur(): void;
|
|
7
|
+
};
|
|
8
|
+
export declare type TSinchAlertButtonReact = TSinchElementReact<TSinchAlertButtonElement> & {
|
|
9
|
+
text: string;
|
|
10
|
+
onClick?: (e: MouseEvent<TSinchAlertButtonElement>) => void;
|
|
11
|
+
onFocus?: (e: FocusEvent<TSinchAlertButtonElement>) => void;
|
|
12
|
+
onBlur?: (e: FocusEvent<TSinchAlertButtonElement>) => void;
|
|
13
|
+
};
|
|
14
|
+
declare global {
|
|
15
|
+
namespace JSX {
|
|
16
|
+
interface IntrinsicElements {
|
|
17
|
+
'sinch-alert-button': TSinchAlertButtonReact;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
interface HTMLElementTagNameMap {
|
|
21
|
+
'sinch-alert-button': TSinchAlertButtonElement;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
|
+
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
|
+
|
|
4
|
+
var _$button;
|
|
5
|
+
|
|
6
|
+
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
7
|
+
|
|
8
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
9
|
+
|
|
10
|
+
import { defineCustomElement, getAttribute, updateAttribute } from '../utils';
|
|
11
|
+
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}button{all:initial;padding:9px 16px;border:1px solid var(--sinch-color-stormy-500);border-radius:4px;font:var(--sinch-font-body);font-size:14px;line-height:14px;color:var(--sinch-color-stormy-500);white-space:nowrap;text-overflow:ellipsis;overflow:hidden;cursor:pointer;height:32px;box-sizing:border-box}</style><button></button>';
|
|
12
|
+
const template = document.createElement('template');
|
|
13
|
+
template.innerHTML = templateHTML;
|
|
14
|
+
defineCustomElement('sinch-alert-button', (_$button = new WeakMap(), class extends HTMLElement {
|
|
15
|
+
constructor() {
|
|
16
|
+
super();
|
|
17
|
+
|
|
18
|
+
_classPrivateFieldInitSpec(this, _$button, {
|
|
19
|
+
writable: true,
|
|
20
|
+
value: void 0
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const shadowRoot = this.attachShadow({
|
|
24
|
+
mode: 'production' === 'development' ? 'open' : 'closed',
|
|
25
|
+
delegatesFocus: true
|
|
26
|
+
});
|
|
27
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
28
|
+
|
|
29
|
+
_classPrivateFieldSet(this, _$button, shadowRoot.querySelector('button'));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
get text() {
|
|
33
|
+
return getAttribute(this, 'text', '');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
set text(value) {
|
|
37
|
+
updateAttribute(this, 'text', value);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
static get observedAttributes() {
|
|
41
|
+
return ['text'];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
attributeChangedCallback(name, _, newVal) {
|
|
45
|
+
switch (name) {
|
|
46
|
+
case 'text':
|
|
47
|
+
{
|
|
48
|
+
_classPrivateFieldGet(this, _$button).textContent = newVal;
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
focus() {
|
|
55
|
+
_classPrivateFieldGet(this, _$button).focus();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
blur() {
|
|
59
|
+
_classPrivateFieldGet(this, _$button).blur();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
}));
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import '../icon/close';
|
|
2
|
+
import type { TSinchElementReact } from '../types';
|
|
3
|
+
import type { FocusEvent, MouseEvent } from 'react';
|
|
4
|
+
export declare type TSinchAlertCloseElement = HTMLElement & {
|
|
5
|
+
focus(): void;
|
|
6
|
+
blur(): void;
|
|
7
|
+
};
|
|
8
|
+
export declare type TSinchAlertCloseReact = TSinchElementReact<TSinchAlertCloseElement> & {
|
|
9
|
+
onClick?: (e: MouseEvent<TSinchAlertCloseElement>) => void;
|
|
10
|
+
onFocus?: (e: FocusEvent<TSinchAlertCloseElement>) => void;
|
|
11
|
+
onBlur?: (e: FocusEvent<TSinchAlertCloseElement>) => void;
|
|
12
|
+
};
|
|
13
|
+
declare global {
|
|
14
|
+
namespace JSX {
|
|
15
|
+
interface IntrinsicElements {
|
|
16
|
+
'sinch-alert-close': TSinchAlertCloseReact;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
interface HTMLElementTagNameMap {
|
|
20
|
+
'sinch-alert-close': TSinchAlertCloseElement;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
|
+
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
|
+
|
|
4
|
+
var _$button;
|
|
5
|
+
|
|
6
|
+
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
7
|
+
|
|
8
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
9
|
+
|
|
10
|
+
import '../icon/close';
|
|
11
|
+
import { defineCustomElement } from '../utils';
|
|
12
|
+
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}button{all:initial;display:block;width:24px;height:24px;box-sizing:border-box;cursor:pointer}sinch-icon-close{display:block;pointer-events:none}</style><button><sinch-icon-close size="24"></sinch-icon-close></button>';
|
|
13
|
+
const template = document.createElement('template');
|
|
14
|
+
template.innerHTML = templateHTML;
|
|
15
|
+
defineCustomElement('sinch-alert-close', (_$button = new WeakMap(), class extends HTMLElement {
|
|
16
|
+
constructor() {
|
|
17
|
+
super();
|
|
18
|
+
|
|
19
|
+
_classPrivateFieldInitSpec(this, _$button, {
|
|
20
|
+
writable: true,
|
|
21
|
+
value: void 0
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const shadowRoot = this.attachShadow({
|
|
25
|
+
mode: 'production' === 'development' ? 'open' : 'closed',
|
|
26
|
+
delegatesFocus: true
|
|
27
|
+
});
|
|
28
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
29
|
+
|
|
30
|
+
_classPrivateFieldSet(this, _$button, shadowRoot.querySelector('button'));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
focus() {
|
|
34
|
+
_classPrivateFieldGet(this, _$button).focus();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
blur() {
|
|
38
|
+
_classPrivateFieldGet(this, _$button).blur();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
}));
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { TSinchElementReact } from '../types';
|
|
2
|
+
import type { FocusEvent, MouseEvent } from 'react';
|
|
3
|
+
declare const buttonTypes: readonly ["primary", "secondary", "cta", "destructive"];
|
|
4
|
+
export declare type TSinchButtonType = typeof buttonTypes[number];
|
|
5
|
+
export declare type TSinchButtonElement = HTMLElement & {
|
|
6
|
+
type: TSinchButtonType;
|
|
7
|
+
text: string;
|
|
8
|
+
disabled: boolean;
|
|
9
|
+
small: boolean;
|
|
10
|
+
focus(): void;
|
|
11
|
+
blur(): void;
|
|
12
|
+
};
|
|
13
|
+
export declare type TSinchButtonReact = TSinchElementReact<TSinchButtonElement> & {
|
|
14
|
+
type: TSinchButtonType;
|
|
15
|
+
text: string;
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
small?: boolean;
|
|
18
|
+
onClick: (e: MouseEvent<TSinchButtonElement>) => void;
|
|
19
|
+
onFocus?: (e: FocusEvent<TSinchButtonElement>) => void;
|
|
20
|
+
onBlur?: (e: FocusEvent<TSinchButtonElement>) => void;
|
|
21
|
+
};
|
|
22
|
+
declare global {
|
|
23
|
+
namespace JSX {
|
|
24
|
+
interface IntrinsicElements {
|
|
25
|
+
'sinch-button': TSinchButtonReact;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
interface HTMLElementTagNameMap {
|
|
29
|
+
'sinch-button': TSinchButtonElement;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export {};
|