@nectary/components 0.9.0 → 0.11.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.js +5 -1
- package/accordion-item/index.js +7 -7
- package/alert/index.js +2 -2
- package/alert-button/index.js +1 -1
- package/alert-close/index.js +2 -2
- package/button/index.d.ts +2 -1
- package/button/index.js +7 -3
- package/card/index.d.ts +23 -0
- package/card/index.js +164 -0
- package/card-button/index.d.ts +27 -0
- package/card-button/index.js +83 -0
- package/card-link/index.d.ts +29 -0
- package/card-link/index.js +121 -0
- package/checkbox/index.d.ts +3 -0
- package/checkbox/index.js +27 -18
- package/dialog/index.d.ts +23 -0
- package/dialog/index.js +181 -0
- package/dropdown/index.d.ts +34 -0
- package/dropdown/index.js +451 -0
- package/dropdown-option/index.d.ts +44 -0
- package/dropdown-option/index.js +116 -0
- package/help-tooltip/index.js +5 -1
- package/icon/arrow-back/index.d.ts +11 -0
- package/icon/arrow-back/index.js +4 -0
- package/icon/arrow-downward/index.d.ts +11 -0
- package/icon/arrow-downward/index.js +4 -0
- package/icon/arrow-forward/index.d.ts +11 -0
- package/icon/arrow-forward/index.js +4 -0
- package/icon/arrow-upward/index.d.ts +11 -0
- package/icon/arrow-upward/index.js +4 -0
- package/icon/cancel/index.js +1 -1
- package/icon/close/index.js +1 -1
- package/icon/create-icon-class.js +1 -1
- package/icon/east/index.js +1 -1
- package/icon/help-outline/index.js +1 -1
- package/icon/more-horiz/index.js +1 -1
- package/icon/more-vert/index.js +1 -1
- package/icon/north/index.js +1 -1
- package/icon/north-east/index.js +1 -1
- package/icon/north-west/index.js +1 -1
- package/icon/open-in-new/index.js +1 -1
- package/icon/south/index.js +1 -1
- package/icon/south-east/index.js +1 -1
- package/icon/south-west/index.js +1 -1
- package/icon/west/index.js +1 -1
- package/icon-branded/barchart-down/index.js +1 -1
- package/icon-branded/barchart-up/index.js +1 -1
- package/icon-branded/campaigns/index.js +1 -1
- package/icon-branded/chatbot/index.js +1 -1
- package/icon-branded/contact/index.js +1 -1
- package/icon-branded/create-icon-class.js +1 -1
- package/icon-branded/home/index.js +1 -1
- package/icon-branded/multiple-channels/index.js +1 -1
- package/icon-branded/rocket/index.js +1 -1
- package/icon-branded/settings/index.js +1 -1
- package/icon-branded/user/index.js +1 -1
- package/icon-branded/users/index.js +1 -1
- package/illustration/create-illustration-class.d.ts +308 -0
- package/illustration/create-illustration-class.js +53 -0
- package/illustration/phone-and-cat/index.d.ts +11 -0
- package/illustration/phone-and-cat/index.js +4 -0
- package/illustration/types.d.ts +7 -0
- package/illustration/types.js +1 -0
- package/index.d.ts +11 -0
- package/index.js +12 -1
- package/input/index.d.ts +3 -1
- package/input/index.js +59 -11
- package/link/index.js +2 -2
- package/logo/create-logo-class.js +1 -1
- package/logo/sinch-icon/index.js +1 -1
- package/logo/sinch-icon-wordmark/index.js +1 -1
- package/package.json +1 -1
- package/pagination/index.js +1 -6
- package/radio/index.d.ts +1 -0
- package/radio/index.js +97 -71
- package/radio-option/index.d.ts +1 -0
- package/radio-option/index.js +4 -1
- package/select/index.d.ts +4 -1
- package/select/index.js +72 -265
- package/select-option/index.d.ts +3 -17
- package/select-option/index.js +4 -103
- package/spinner/index.js +1 -1
- package/table/index.js +1 -1
- package/table-body/index.js +1 -1
- package/table-cell/index.js +1 -1
- package/table-head/index.js +1 -1
- package/table-head-cell/index.js +3 -2
- package/table-head-sort/index.d.ts +1 -0
- package/table-head-sort/index.js +3 -1
- package/table-row/index.js +1 -1
- package/tabs/index.d.ts +1 -0
- package/tabs/index.js +96 -66
- package/tabs-option/index.d.ts +1 -0
- package/tabs-option/index.js +4 -2
- package/tag/index.js +1 -1
- package/tag-close/index.js +2 -2
- package/textarea/index.d.ts +3 -1
- package/textarea/index.js +58 -11
- package/theme.css +6 -2
- package/toggle/index.d.ts +1 -0
- package/toggle/index.js +4 -5
- package/tooltip/index.d.ts +2 -1
- package/tooltip/index.js +7 -3
- package/types.d.ts +7 -0
- package/utils.d.ts +3 -0
- package/utils.js +17 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
|
+
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
|
+
|
|
4
|
+
var _$anchor, _$text, _onClick;
|
|
5
|
+
|
|
6
|
+
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
7
|
+
|
|
8
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
9
|
+
|
|
10
|
+
import '../icon/cancel';
|
|
11
|
+
import { defineCustomElement, getBooleanAttribute, getAttribute, updateBooleanAttribute, updateAttribute } from '../utils';
|
|
12
|
+
const templateHTML = '<style>:host{display:inline;outline:0}a{display:flex;flex-direction:row;gap:8px;font:var(--sinch-font-emphasized-body);color:var(--sinch-color-tropical-500);text-decoration:none;outline:0;--sinch-color-icon:var(--sinch-color-tropical-500)}a:hover{color:var(--sinch-color-tropical-600);fill:var(--sinch-color-tropical-600)}:host([disabled]:not([disabled=false])) a{color:var(--sinch-color-tropical-300);pointer-events:none;cursor:initial;--sinch-color-icon:var(--sinch-color-tropical-300)}span{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0;flex-shrink:1}</style><a><span></span><sinch-icon-arrow-forward size="24"></sinch-icon-arrow-forward></a>';
|
|
13
|
+
export const isSinchCardLinkElement = el => {
|
|
14
|
+
return el.tagName === 'SINCH-CARD-LINK';
|
|
15
|
+
};
|
|
16
|
+
const template = document.createElement('template');
|
|
17
|
+
template.innerHTML = templateHTML;
|
|
18
|
+
defineCustomElement('sinch-card-link', (_$anchor = new WeakMap(), _$text = new WeakMap(), _onClick = new WeakMap(), class extends HTMLElement {
|
|
19
|
+
constructor() {
|
|
20
|
+
super();
|
|
21
|
+
|
|
22
|
+
_classPrivateFieldInitSpec(this, _$anchor, {
|
|
23
|
+
writable: true,
|
|
24
|
+
value: void 0
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
_classPrivateFieldInitSpec(this, _$text, {
|
|
28
|
+
writable: true,
|
|
29
|
+
value: void 0
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
_classPrivateFieldInitSpec(this, _onClick, {
|
|
33
|
+
writable: true,
|
|
34
|
+
value: e => {
|
|
35
|
+
if (this.disabled) {
|
|
36
|
+
e.preventDefault();
|
|
37
|
+
e.stopPropagation();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const shadowRoot = this.attachShadow({
|
|
43
|
+
mode: 'closed',
|
|
44
|
+
delegatesFocus: true
|
|
45
|
+
});
|
|
46
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
47
|
+
|
|
48
|
+
_classPrivateFieldSet(this, _$anchor, shadowRoot.querySelector('a'));
|
|
49
|
+
|
|
50
|
+
_classPrivateFieldSet(this, _$text, shadowRoot.querySelector('span'));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
connectedCallback() {
|
|
54
|
+
_classPrivateFieldGet(this, _$anchor).addEventListener('click', _classPrivateFieldGet(this, _onClick));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
disconnectedCallback() {
|
|
58
|
+
_classPrivateFieldGet(this, _$anchor).removeEventListener('click', _classPrivateFieldGet(this, _onClick));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
get text() {
|
|
62
|
+
return getAttribute(this, 'text', '');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
set text(value) {
|
|
66
|
+
updateAttribute(this, 'text', value);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
get href() {
|
|
70
|
+
return getAttribute(this, 'href', '');
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
set href(value) {
|
|
74
|
+
updateAttribute(this, 'href', value);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
set disabled(isDisabled) {
|
|
78
|
+
updateBooleanAttribute(this, 'disabled', isDisabled);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
get disabled() {
|
|
82
|
+
return getBooleanAttribute(this, 'disabled');
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
set external(isExternal) {
|
|
86
|
+
updateBooleanAttribute(this, 'external', isExternal);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
get external() {
|
|
90
|
+
return getBooleanAttribute(this, 'external');
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
static get observedAttributes() {
|
|
94
|
+
return ['text', 'href'];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
attributeChangedCallback(name, _, newVal) {
|
|
98
|
+
switch (name) {
|
|
99
|
+
case 'text':
|
|
100
|
+
{
|
|
101
|
+
_classPrivateFieldGet(this, _$text).textContent = newVal;
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
case 'href':
|
|
106
|
+
{
|
|
107
|
+
updateAttribute(_classPrivateFieldGet(this, _$anchor), 'href', newVal);
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
focus() {
|
|
114
|
+
_classPrivateFieldGet(this, _$anchor).focus();
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
blur() {
|
|
118
|
+
_classPrivateFieldGet(this, _$anchor).blur();
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
}));
|
package/checkbox/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export declare type TSinchCheckboxElement = HTMLElement & {
|
|
|
4
4
|
checked: boolean;
|
|
5
5
|
indeterminate: boolean;
|
|
6
6
|
disabled: boolean;
|
|
7
|
+
invalid: boolean;
|
|
7
8
|
text: string | null;
|
|
8
9
|
focus(): void;
|
|
9
10
|
blur(): void;
|
|
@@ -12,7 +13,9 @@ export declare type TSinchCheckboxReact = TSinchElementReact<TSinchCheckboxEleme
|
|
|
12
13
|
checked?: boolean;
|
|
13
14
|
indeterminate?: boolean;
|
|
14
15
|
disabled?: boolean;
|
|
16
|
+
invalid?: boolean;
|
|
15
17
|
text?: string;
|
|
18
|
+
'aria-label': string;
|
|
16
19
|
onChange: (event: SyntheticEvent<TSinchCheckboxElement, CustomEvent<boolean>>) => void;
|
|
17
20
|
onFocus?: (e: FocusEvent<TSinchCheckboxElement>) => void;
|
|
18
21
|
onBlur?: (e: FocusEvent<TSinchCheckboxElement>) => void;
|
package/checkbox/index.js
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
1
|
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
3
2
|
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
4
3
|
|
|
5
|
-
var _$input, _$label;
|
|
4
|
+
var _$input, _$label, _onCheckboxInput;
|
|
6
5
|
|
|
7
6
|
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
8
7
|
|
|
9
8
|
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
10
9
|
|
|
11
10
|
import { defineCustomElement, getAttribute, getBooleanAttribute, isAttrTrue, updateAttribute, updateBooleanAttribute } from '../utils';
|
|
12
|
-
const templateHTML = '<style>:host{--sinch-color-
|
|
11
|
+
const templateHTML = '<style>:host{--sinch-color-checkbox-circle:var(--sinch-color-transparent);--sinch-color-checkbox-background:var(--sinch-color-snow-100);--sinch-color-checkbox-border:var(--sinch-color-stormy-300);--sinch-color-checkbox-circle-checked:var(--sinch-color-transparent);--sinch-color-checkbox-background-checked:var(--sinch-color-tropical-500);--sinch-color-checkbox-border-checked:var(--sinch-color-tropical-500);--sinch-color-checkbox-circle-hover:var(--sinch-color-snow-500);--sinch-color-checkbox-background-hover:var(--sinch-color-snow-100);--sinch-color-checkbox-border-hover:var(--sinch-color-stormy-300);--sinch-color-checkbox-circle-hover-checked:var(--sinch-color-tropical-100);--sinch-color-checkbox-background-hover-checked:var(--sinch-color-tropical-500);--sinch-color-checkbox-border-hover-checked:var(--sinch-color-tropical-500);--sinch-color-checkbox-circle-focus:var(--sinch-color-snow-800);--sinch-color-checkbox-background-focus:var(--sinch-color-snow-100);--sinch-color-checkbox-border-focus:var(--sinch-color-stormy-300);--sinch-color-checkbox-circle-focus-checked:var(--sinch-color-tropical-200);--sinch-color-checkbox-background-focus-checked:var(--sinch-color-tropical-500);--sinch-color-checkbox-border-focus-checked:var(--sinch-color-tropical-500);--sinch-color-checkbox-circle-active:var(--sinch-color-stormy-100);--sinch-color-checkbox-background-active:var(--sinch-color-snow-100);--sinch-color-checkbox-border-active:var(--sinch-color-stormy-300);--sinch-color-checkbox-circle-active-checked:var(--sinch-color-tropical-300);--sinch-color-checkbox-background-active-checked:var(--sinch-color-tropical-500);--sinch-color-checkbox-border-active-checked:var(--sinch-color-tropical-500);--sinch-color-checkbox-circle-disabled:var(--sinch-color-transparent);--sinch-color-checkbox-background-disabled:var(--sinch-color-snow-100);--sinch-color-checkbox-border-disabled:var(--sinch-color-stormy-100);--sinch-color-checkbox-circle-disabled-checked:var(--sinch-color-transparent);--sinch-color-checkbox-background-disabled-checked:var(--sinch-color-stormy-100);--sinch-color-checkbox-border-disabled-checked:var(--sinch-color-stormy-100);--sinch-color-checkbox-text:var(--sinch-color-text-default);--sinch-color-checkbox-text-disabled:var(--sinch-color-stormy-200);display:inline-block;vertical-align:middle;outline:0}:host([invalid]:not([invalid=false])){--sinch-color-checkbox-border:var(--sinch-color-raspberry-500);--sinch-color-checkbox-background-checked:var(--sinch-color-raspberry-500);--sinch-color-checkbox-border-checked:var(--sinch-color-raspberry-500);--sinch-color-checkbox-border-hover:var(--sinch-color-raspberry-500);--sinch-color-checkbox-circle-hover-checked:var(--sinch-color-raspberry-100);--sinch-color-checkbox-background-hover-checked:var(--sinch-color-raspberry-500);--sinch-color-checkbox-border-hover-checked:var(--sinch-color-raspberry-500);--sinch-color-checkbox-border-focus:var(--sinch-color-raspberry-500);--sinch-color-checkbox-circle-focus-checked:var(--sinch-color-raspberry-200);--sinch-color-checkbox-background-focus-checked:var(--sinch-color-raspberry-500);--sinch-color-checkbox-border-focus-checked:var(--sinch-color-raspberry-500);--sinch-color-checkbox-border-active:var(--sinch-color-raspberry-500);--sinch-color-checkbox-circle-active-checked:var(--sinch-color-raspberry-300);--sinch-color-checkbox-background-active-checked:var(--sinch-color-raspberry-500);--sinch-color-checkbox-border-active-checked:var(--sinch-color-raspberry-500);--sinch-color-checkbox-border-disabled:var(--sinch-color-raspberry-200);--sinch-color-checkbox-background-disabled-checked:var(--sinch-color-raspberry-200);--sinch-color-checkbox-border-disabled-checked:var(--sinch-color-raspberry-200);--sinch-color-checkbox-text:var(--sinch-color-text-invalid);--sinch-color-checkbox-text-disabled:var(--sinch-color-raspberry-200)}#wrapper{display:flex;flex-direction:row;box-sizing:border-box;width:100%;height:32px}#checkbox{all:initial;display:block;width:32px;height:32px;cursor:pointer}#checkbox:disabled{cursor:initial}#icon-container{position:relative;width:32px;height:32px}#checkbox::before{content:"";position:absolute;top:0;left:0;width:32px;height:32px;border-radius:16px;pointer-events:none;background-color:var(--sinch-color-checkbox-circle);transition:background-color .1s linear}#checkbox::after{content:"";position:absolute;top:7px;left:7px;width:18px;height:18px;border-radius:2px;pointer-events:none;background-color:var(--sinch-color-checkbox-background);box-shadow:0 0 0 2px var(--sinch-color-checkbox-border) inset;transition:background-color .1s linear}#icon-checkmark{position:absolute;left:9px;top:10px;transition:opacity .1s linear;opacity:0%;pointer-events:none}#icon-indeterminate{position:absolute;left:10px;top:15px;transition:opacity .1s linear;opacity:0%;pointer-events:none}@media (prefers-reduced-motion){#checkbox::after,#checkbox::before,#icon-checkmark,#icon-indeterminate{transition:none}}#label{display:none;flex:1;align-self:center;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;padding-left:6px;font:var(--sinch-font-body);color:var(--sinch-color-checkbox-text)}:host([text]:not([text=""])) #label{display:block}:host([disabled]:not([disabled=false])) #label{color:var(--sinch-color-checkbox-text-disabled)}:host(:is(:not([indeterminate]),[indeterminate=false])) #checkbox:checked~#icon-checkmark{opacity:100%}:host([indeterminate]:not([indeterminate=false])) #checkbox:checked~#icon-indeterminate{opacity:100%}#checkbox:checked::before{background-color:var(--sinch-color-checkbox-circle-checked)}#checkbox:checked::after{background-color:var(--sinch-color-checkbox-background-checked);box-shadow:0 0 0 2px var(--sinch-color-checkbox-border-checked) inset}#checkbox:focus::before{background-color:var(--sinch-color-checkbox-circle-focus)}#checkbox:focus::after{background-color:var(--sinch-color-checkbox-background-focus);box-shadow:0 0 0 2px var(--sinch-color-checkbox-border-focus) inset}#checkbox:hover::before{background-color:var(--sinch-color-checkbox-circle-hover)}#checkbox:hover::after{background-color:var(--sinch-color-checkbox-background-hover);box-shadow:0 0 0 2px var(--sinch-color-checkbox-border-hover) inset}#checkbox:active::before{background-color:var(--sinch-color-checkbox-circle-active)}#checkbox:active::after{background-color:var(--sinch-color-checkbox-background-active);box-shadow:0 0 0 2px var(--sinch-color-checkbox-border-active) inset}#checkbox:disabled::before{background-color:var(--sinch-color-checkbox-circle-disabled)}#checkbox:disabled::after{background-color:var(--sinch-color-checkbox-background-disabled);box-shadow:0 0 0 2px var(--sinch-color-checkbox-border-disabled) inset}#checkbox:focus:checked::before{background-color:var(--sinch-color-checkbox-circle-focus-checked)}#checkbox:focus:checked::after{background-color:var(--sinch-color-checkbox-background-focus-checked);box-shadow:0 0 0 2px var(--sinch-color-checkbox-border-focus-checked) inset}#checkbox:hover:checked::before{background-color:var(--sinch-color-checkbox-circle-hover-checked)}#checkbox:hover:checked::after{background-color:var(--sinch-color-checkbox-background-hover-checked);box-shadow:0 0 0 2px var(--sinch-color-checkbox-border-hover-checked) inset}#checkbox:active:checked::before{background-color:var(--sinch-color-checkbox-circle-active-checked)}#checkbox:active:checked::after{background-color:var(--sinch-color-checkbox-background-active-checked);box-shadow:0 0 0 2px var(--sinch-color-checkbox-border-active-checked) inset}#checkbox:disabled:checked::before{background-color:var(--sinch-color-checkbox-circle-disabled-checked)}#checkbox:disabled:checked::after{background-color:var(--sinch-color-checkbox-background-disabled-checked);box-shadow:0 0 0 2px var(--sinch-color-checkbox-border-disabled-checked) inset}</style><div id="wrapper"><div id="icon-container"><input id="checkbox" type="checkbox"/> <svg id="icon-checkmark" width="14" height="11" aria-hidden="true"><path d="M14 1.99999L12.59 0.579987L4.98995 8.17L1.49997 4.5L0.0799694 5.91L4.98995 11L14 1.99999Z" fill="white"/></svg> <svg id="icon-indeterminate" width="12" height="2" aria-hidden="true"><line y1="1" x2="12" y2="1" stroke="white" stroke-width="2"/></svg></div><label for="checkbox" id="label"></label></div>';
|
|
13
12
|
const template = document.createElement('template');
|
|
14
13
|
template.innerHTML = templateHTML;
|
|
15
|
-
defineCustomElement('sinch-checkbox', (_$input = new WeakMap(), _$label = new WeakMap(), class extends HTMLElement {
|
|
14
|
+
defineCustomElement('sinch-checkbox', (_$input = new WeakMap(), _$label = new WeakMap(), _onCheckboxInput = new WeakMap(), class extends HTMLElement {
|
|
16
15
|
constructor() {
|
|
17
16
|
super();
|
|
18
17
|
|
|
@@ -26,20 +25,23 @@ defineCustomElement('sinch-checkbox', (_$input = new WeakMap(), _$label = new We
|
|
|
26
25
|
value: void 0
|
|
27
26
|
});
|
|
28
27
|
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
_classPrivateFieldInitSpec(this, _onCheckboxInput, {
|
|
29
|
+
writable: true,
|
|
30
|
+
value: e => {
|
|
31
|
+
e.stopPropagation();
|
|
31
32
|
|
|
32
|
-
|
|
33
|
+
const isChecked = _classPrivateFieldGet(this, _$input).checked;
|
|
33
34
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
_classPrivateFieldGet(this, _$input).checked = this.checked;
|
|
36
|
+
this.dispatchEvent(new CustomEvent('change', {
|
|
37
|
+
detail: isChecked,
|
|
38
|
+
bubbles: true
|
|
39
|
+
}));
|
|
40
|
+
}
|
|
39
41
|
});
|
|
40
42
|
|
|
41
43
|
const shadowRoot = this.attachShadow({
|
|
42
|
-
mode: '
|
|
44
|
+
mode: 'closed',
|
|
43
45
|
delegatesFocus: true
|
|
44
46
|
});
|
|
45
47
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
@@ -47,14 +49,12 @@ defineCustomElement('sinch-checkbox', (_$input = new WeakMap(), _$label = new We
|
|
|
47
49
|
_classPrivateFieldSet(this, _$input, shadowRoot.querySelector('input'));
|
|
48
50
|
|
|
49
51
|
_classPrivateFieldSet(this, _$label, shadowRoot.querySelector('label'));
|
|
50
|
-
}
|
|
51
52
|
|
|
52
|
-
|
|
53
|
-
_classPrivateFieldGet(this, _$input).addEventListener('input', this.onCheckboxInput);
|
|
53
|
+
_classPrivateFieldGet(this, _$input).addEventListener('input', _classPrivateFieldGet(this, _onCheckboxInput));
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
connectedCallback() {
|
|
57
|
+
this.setAttribute('role', 'checkbox');
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
static get observedAttributes() {
|
|
@@ -93,6 +93,14 @@ defineCustomElement('sinch-checkbox', (_$input = new WeakMap(), _$label = new We
|
|
|
93
93
|
return getBooleanAttribute(this, 'disabled');
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
+
set invalid(isInvalid) {
|
|
97
|
+
updateBooleanAttribute(this, 'invalid', isInvalid);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
get invalid() {
|
|
101
|
+
return getBooleanAttribute(this, 'invalid');
|
|
102
|
+
}
|
|
103
|
+
|
|
96
104
|
set text(value) {
|
|
97
105
|
updateAttribute(this, 'text', value);
|
|
98
106
|
}
|
|
@@ -112,6 +120,7 @@ defineCustomElement('sinch-checkbox', (_$input = new WeakMap(), _$label = new We
|
|
|
112
120
|
case 'checked':
|
|
113
121
|
{
|
|
114
122
|
_classPrivateFieldGet(this, _$input).checked = isAttrTrue(newVal);
|
|
123
|
+
updateAttribute(this, 'aria-checked', isAttrTrue(newVal));
|
|
115
124
|
break;
|
|
116
125
|
}
|
|
117
126
|
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { TRect, TSinchElementReact } from '../types';
|
|
2
|
+
import type { SyntheticEvent } from 'react';
|
|
3
|
+
declare type TSinchDialogElement = HTMLElement & {
|
|
4
|
+
title: string;
|
|
5
|
+
readonly dialogRect: TRect;
|
|
6
|
+
readonly closeButtonRect: TRect;
|
|
7
|
+
};
|
|
8
|
+
declare type TSinchDialogReact = TSinchElementReact<TSinchDialogElement> & {
|
|
9
|
+
title: string;
|
|
10
|
+
'aria-label': string;
|
|
11
|
+
onClose: (event: SyntheticEvent<TSinchDialogElement, CustomEvent<void>>) => void;
|
|
12
|
+
};
|
|
13
|
+
declare global {
|
|
14
|
+
namespace JSX {
|
|
15
|
+
interface IntrinsicElements {
|
|
16
|
+
'sinch-dialog': TSinchDialogReact;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
interface HTMLElementTagNameMap {
|
|
20
|
+
'sinch-dialog': TSinchDialogElement;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export {};
|
package/dialog/index.js
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
|
+
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
|
+
|
|
4
|
+
var _$main, _$closeButton, _$backDrop, _$title, _$prevActiveElement, _focusIn, _onCloseByMouse, _onCloseByEsc, _onClose, _onCloseReactHandler;
|
|
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, getRect, updateAttribute } from '../utils';
|
|
11
|
+
const templateHTML = '<style>#wrapper{position:fixed;top:0;left:0;height:100vh;width:100vw;color:var(--sinch-color-text-default);font:var(--sinch-font-body);z-index:1}#backdrop{background-color:#000;position:absolute;left:0;top:0;opacity:55%;width:100%;height:100%}#main{display:flex;flex-direction:column;position:relative;left:50%;top:50%;transform:translateX(-50%) translateY(-50%);padding:24px;width:100%;max-width:512px;border-radius:4px;box-sizing:border-box;background-color:var(--sinch-color-snow-100)}#header{display:flex;flex-direction:row;justify-content:space-between;align-content:center;margin-bottom:16px}#title{font:var(--sinch-font-title-3);color:var(--sinch-color-text-default)}#content-wrapper{max-height:50vh;overflow-y:auto;margin-top:16px}#close{all:initial;cursor:pointer}#buttons{display:flex;flex-direction:row;justify-content:flex-end;gap:16px;margin-top:24px}</style><div id="wrapper"><div id="backdrop"></div><div id="main"><div id="header"><span id="title"></span> <button id="close"><sinch-icon-close size="24"></sinch-icon-close></button></div><div id="content-wrapper"><slot name="content"></slot></div><div id="buttons"><slot name="buttons"></slot></div></div></div>';
|
|
12
|
+
const template = document.createElement('template');
|
|
13
|
+
template.innerHTML = templateHTML;
|
|
14
|
+
|
|
15
|
+
const getReactEventHandler = ($element, handlerName) => {
|
|
16
|
+
for (const key in $element) {
|
|
17
|
+
if (key.startsWith('__reactProps$')) {
|
|
18
|
+
return $element[key][handlerName];
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return null;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
defineCustomElement('sinch-dialog', (_$main = new WeakMap(), _$closeButton = new WeakMap(), _$backDrop = new WeakMap(), _$title = new WeakMap(), _$prevActiveElement = new WeakMap(), _focusIn = new WeakMap(), _onCloseByMouse = new WeakMap(), _onCloseByEsc = new WeakMap(), _onClose = new WeakMap(), _onCloseReactHandler = new WeakMap(), class extends HTMLElement {
|
|
26
|
+
constructor() {
|
|
27
|
+
super();
|
|
28
|
+
|
|
29
|
+
_classPrivateFieldInitSpec(this, _$main, {
|
|
30
|
+
writable: true,
|
|
31
|
+
value: void 0
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
_classPrivateFieldInitSpec(this, _$closeButton, {
|
|
35
|
+
writable: true,
|
|
36
|
+
value: void 0
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
_classPrivateFieldInitSpec(this, _$backDrop, {
|
|
40
|
+
writable: true,
|
|
41
|
+
value: void 0
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
_classPrivateFieldInitSpec(this, _$title, {
|
|
45
|
+
writable: true,
|
|
46
|
+
value: void 0
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
_classPrivateFieldInitSpec(this, _$prevActiveElement, {
|
|
50
|
+
writable: true,
|
|
51
|
+
value: null
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
_classPrivateFieldInitSpec(this, _focusIn, {
|
|
55
|
+
writable: true,
|
|
56
|
+
value: e => {
|
|
57
|
+
if (e.target === this) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (!this.contains(e.target)) {
|
|
62
|
+
_classPrivateFieldGet(this, _$closeButton).focus();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
_classPrivateFieldInitSpec(this, _onCloseByMouse, {
|
|
68
|
+
writable: true,
|
|
69
|
+
value: e => {
|
|
70
|
+
e.stopPropagation();
|
|
71
|
+
|
|
72
|
+
_classPrivateFieldGet(this, _onClose).call(this);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
_classPrivateFieldInitSpec(this, _onCloseByEsc, {
|
|
77
|
+
writable: true,
|
|
78
|
+
value: e => {
|
|
79
|
+
switch (e.key) {
|
|
80
|
+
case 'Escape':
|
|
81
|
+
{
|
|
82
|
+
e.preventDefault();
|
|
83
|
+
e.stopPropagation();
|
|
84
|
+
|
|
85
|
+
_classPrivateFieldGet(this, _onClose).call(this);
|
|
86
|
+
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
_classPrivateFieldInitSpec(this, _onClose, {
|
|
94
|
+
writable: true,
|
|
95
|
+
value: () => {
|
|
96
|
+
_classPrivateFieldGet(this, _$prevActiveElement)?.focus();
|
|
97
|
+
this.dispatchEvent(new CustomEvent('close', {
|
|
98
|
+
bubbles: true
|
|
99
|
+
}));
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
_classPrivateFieldInitSpec(this, _onCloseReactHandler, {
|
|
104
|
+
writable: true,
|
|
105
|
+
value: () => {
|
|
106
|
+
getReactEventHandler(this, 'onClose')?.();
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
const shadowRoot = this.attachShadow({
|
|
111
|
+
mode: 'closed',
|
|
112
|
+
delegatesFocus: true
|
|
113
|
+
});
|
|
114
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
115
|
+
|
|
116
|
+
_classPrivateFieldSet(this, _$main, shadowRoot.querySelector('#main'));
|
|
117
|
+
|
|
118
|
+
_classPrivateFieldSet(this, _$closeButton, shadowRoot.querySelector('#close'));
|
|
119
|
+
|
|
120
|
+
_classPrivateFieldSet(this, _$backDrop, shadowRoot.querySelector('#backdrop'));
|
|
121
|
+
|
|
122
|
+
_classPrivateFieldSet(this, _$title, shadowRoot.querySelector('#title'));
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
static get observedAttributes() {
|
|
126
|
+
return ['title'];
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
attributeChangedCallback(name, _, newVal) {
|
|
130
|
+
switch (name) {
|
|
131
|
+
case 'title':
|
|
132
|
+
{
|
|
133
|
+
_classPrivateFieldGet(this, _$title).textContent = newVal;
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
set title(title) {
|
|
140
|
+
updateAttribute(this, 'title', title);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
get title() {
|
|
144
|
+
return getAttribute(this, 'title', '');
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
connectedCallback() {
|
|
148
|
+
this.setAttribute('role', 'dialog');
|
|
149
|
+
|
|
150
|
+
_classPrivateFieldSet(this, _$prevActiveElement, document.activeElement);
|
|
151
|
+
|
|
152
|
+
_classPrivateFieldGet(this, _$closeButton).addEventListener('click', _classPrivateFieldGet(this, _onCloseByMouse));
|
|
153
|
+
|
|
154
|
+
_classPrivateFieldGet(this, _$backDrop).addEventListener('click', _classPrivateFieldGet(this, _onCloseByMouse));
|
|
155
|
+
|
|
156
|
+
this.addEventListener('keydown', _classPrivateFieldGet(this, _onCloseByEsc));
|
|
157
|
+
this.addEventListener('close', _classPrivateFieldGet(this, _onCloseReactHandler));
|
|
158
|
+
document.addEventListener('focusin', _classPrivateFieldGet(this, _focusIn));
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
disconnectedCallback() {
|
|
162
|
+
_classPrivateFieldSet(this, _$prevActiveElement, null);
|
|
163
|
+
|
|
164
|
+
_classPrivateFieldGet(this, _$closeButton).removeEventListener('click', _classPrivateFieldGet(this, _onCloseByMouse));
|
|
165
|
+
|
|
166
|
+
_classPrivateFieldGet(this, _$backDrop).removeEventListener('click', _classPrivateFieldGet(this, _onCloseByMouse));
|
|
167
|
+
|
|
168
|
+
this.removeEventListener('keydown', _classPrivateFieldGet(this, _onCloseByEsc));
|
|
169
|
+
this.removeEventListener('close', _classPrivateFieldGet(this, _onCloseReactHandler));
|
|
170
|
+
document.removeEventListener('focusin', _classPrivateFieldGet(this, _focusIn));
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
get dialogRect() {
|
|
174
|
+
return getRect(_classPrivateFieldGet(this, _$main));
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
get closeButtonRect() {
|
|
178
|
+
return getRect(_classPrivateFieldGet(this, _$closeButton));
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
}));
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { TRect, TSinchElementReact } from '../types';
|
|
2
|
+
import type { FocusEvent, SyntheticEvent } from 'react';
|
|
3
|
+
declare const orientationValues: readonly ["top-left", "top-right", "bottom-left", "bottom-right"];
|
|
4
|
+
export declare type TSinchDropdownOrientation = typeof orientationValues[number];
|
|
5
|
+
export declare type TSinchDropdownElement = HTMLElement & {
|
|
6
|
+
orientation: TSinchDropdownOrientation;
|
|
7
|
+
value: string;
|
|
8
|
+
disabled: boolean;
|
|
9
|
+
maxVisibleItems: number | null;
|
|
10
|
+
readonly dropdownRect: TRect;
|
|
11
|
+
focus(): void;
|
|
12
|
+
blur(): void;
|
|
13
|
+
};
|
|
14
|
+
export declare type TSinchDropdownReact = TSinchElementReact<TSinchDropdownElement> & {
|
|
15
|
+
orientation?: TSinchDropdownOrientation;
|
|
16
|
+
value: string;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
maxVisibleItems?: number;
|
|
19
|
+
'aria-label': string;
|
|
20
|
+
onChange: (e: SyntheticEvent<TSinchDropdownElement, CustomEvent<string>>) => void;
|
|
21
|
+
onFocus?: (e: FocusEvent<TSinchDropdownElement>) => void;
|
|
22
|
+
onBlur?: (e: FocusEvent<TSinchDropdownElement>) => void;
|
|
23
|
+
};
|
|
24
|
+
declare global {
|
|
25
|
+
namespace JSX {
|
|
26
|
+
interface IntrinsicElements {
|
|
27
|
+
'sinch-dropdown': TSinchDropdownReact;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
interface HTMLElementTagNameMap {
|
|
31
|
+
'sinch-dropdown': TSinchDropdownElement;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export {};
|