@nectary/components 0.8.1 → 0.10.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/checkbox/index.d.ts +3 -0
- package/checkbox/index.js +27 -18
- 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-ios/index.d.ts +11 -0
- package/icon/arrow-back-ios/index.js +4 -0
- package/icon/arrow-forward-ios/index.d.ts +11 -0
- package/icon/arrow-forward-ios/index.js +4 -0
- package/icon/cancel/index.js +1 -1
- package/icon/chevron-left/index.d.ts +11 -0
- package/icon/chevron-left/index.js +4 -0
- package/icon/chevron-right/index.d.ts +11 -0
- package/icon/chevron-right/index.js +4 -0
- package/icon/close/index.js +1 -1
- package/icon/create-icon-class.js +1 -1
- package/icon/east/index.js +1 -1
- package/icon/expand-less/index.d.ts +11 -0
- package/icon/expand-less/index.js +4 -0
- package/icon/expand-more/index.d.ts +11 -0
- package/icon/expand-more/index.js +4 -0
- package/icon/help-outline/index.js +1 -1
- package/icon/keyboard-arrow-down/index.d.ts +11 -0
- package/icon/keyboard-arrow-down/index.js +4 -0
- package/icon/keyboard-arrow-left/index.d.ts +11 -0
- package/icon/keyboard-arrow-left/index.js +4 -0
- package/icon/keyboard-arrow-right/index.d.ts +11 -0
- package/icon/keyboard-arrow-right/index.js +4 -0
- package/icon/keyboard-arrow-up/index.d.ts +11 -0
- package/icon/keyboard-arrow-up/index.js +4 -0
- 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/index.d.ts +13 -0
- package/index.js +13 -0
- 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.d.ts +27 -0
- package/pagination/index.js +219 -0
- 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 +3 -0
- 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
package/accordion/index.js
CHANGED
|
@@ -50,7 +50,7 @@ defineCustomElement('sinch-accordion', (_$slot = new WeakMap(), _onSlotChange =
|
|
|
50
50
|
});
|
|
51
51
|
|
|
52
52
|
const shadowRoot = this.attachShadow({
|
|
53
|
-
mode: '
|
|
53
|
+
mode: 'closed',
|
|
54
54
|
delegatesFocus: true
|
|
55
55
|
});
|
|
56
56
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
@@ -65,6 +65,10 @@ defineCustomElement('sinch-accordion', (_$slot = new WeakMap(), _onSlotChange =
|
|
|
65
65
|
return ['value'];
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
connectedCallback() {
|
|
69
|
+
this.setAttribute('aria-label', 'accordion');
|
|
70
|
+
}
|
|
71
|
+
|
|
68
72
|
get nodeName() {
|
|
69
73
|
return 'select';
|
|
70
74
|
}
|
package/accordion-item/index.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
2
|
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
3
|
|
|
4
|
-
var _$button, _$
|
|
4
|
+
var _$button, _$buttonContent, _onButtonClick;
|
|
5
5
|
|
|
6
6
|
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
7
7
|
|
|
8
8
|
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
9
9
|
|
|
10
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)}#
|
|
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)}#title{flex:1;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}#content{display:none;overflow-y:auto;flex-shrink:1;min-height:0;padding:0 8px 18px;font:var(--sinch-font-body);color:var(--sinch-color-text-default)}#button[aria-expanded=true]>#dropdown-icon{transform:rotate(180deg)}#button[aria-expanded=true]+#content{display:block}</style><div id="wrapper"><button id="button" aria-controls="content" aria-expanded="false"><slot name="icon"></slot><span id="title"></span> <svg id="dropdown-icon" width="12" height="8" aria-hidden="true"><path d="M1.41.59 6 5.17 10.59.59 12 2 6 8 0 2 1.41.59Z"/></svg></button><div id="content" role="region" aria-labelledby="button"><slot name="content"></slot></div></div>';
|
|
12
12
|
export const isAccordionItemElement = element => {
|
|
13
13
|
return element instanceof Element && element.tagName === 'SINCH-ACCORDION-ITEM';
|
|
14
14
|
};
|
|
15
15
|
const statusValues = ['info', 'success', 'warn', 'error'];
|
|
16
16
|
const template = document.createElement('template');
|
|
17
17
|
template.innerHTML = templateHTML;
|
|
18
|
-
defineCustomElement('sinch-accordion-item', (_$button = new WeakMap(), _$
|
|
18
|
+
defineCustomElement('sinch-accordion-item', (_$button = new WeakMap(), _$buttonContent = new WeakMap(), _onButtonClick = new WeakMap(), class extends HTMLElement {
|
|
19
19
|
constructor() {
|
|
20
20
|
super();
|
|
21
21
|
|
|
@@ -24,7 +24,7 @@ defineCustomElement('sinch-accordion-item', (_$button = new WeakMap(), _$labelCo
|
|
|
24
24
|
value: void 0
|
|
25
25
|
});
|
|
26
26
|
|
|
27
|
-
_classPrivateFieldInitSpec(this, _$
|
|
27
|
+
_classPrivateFieldInitSpec(this, _$buttonContent, {
|
|
28
28
|
writable: true,
|
|
29
29
|
value: void 0
|
|
30
30
|
});
|
|
@@ -44,14 +44,14 @@ defineCustomElement('sinch-accordion-item', (_$button = new WeakMap(), _$labelCo
|
|
|
44
44
|
});
|
|
45
45
|
|
|
46
46
|
const shadowRoot = this.attachShadow({
|
|
47
|
-
mode: '
|
|
47
|
+
mode: 'closed',
|
|
48
48
|
delegatesFocus: true
|
|
49
49
|
});
|
|
50
50
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
51
51
|
|
|
52
52
|
_classPrivateFieldSet(this, _$button, shadowRoot.querySelector('#button'));
|
|
53
53
|
|
|
54
|
-
_classPrivateFieldSet(this, _$
|
|
54
|
+
_classPrivateFieldSet(this, _$buttonContent, shadowRoot.querySelector('#title'));
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
connectedCallback() {
|
|
@@ -110,7 +110,7 @@ defineCustomElement('sinch-accordion-item', (_$button = new WeakMap(), _$labelCo
|
|
|
110
110
|
switch (name) {
|
|
111
111
|
case 'label':
|
|
112
112
|
{
|
|
113
|
-
_classPrivateFieldGet(this, _$
|
|
113
|
+
_classPrivateFieldGet(this, _$buttonContent).textContent = newVal;
|
|
114
114
|
break;
|
|
115
115
|
}
|
|
116
116
|
|
package/alert/index.js
CHANGED
|
@@ -8,7 +8,7 @@ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedec
|
|
|
8
8
|
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
9
9
|
|
|
10
10
|
import { defineCustomElement, getBooleanAttribute, 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>';
|
|
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" aria-hidden="true"><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" aria-hidden="true"><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" aria-hidden="true"><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" aria-hidden="true"><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
12
|
const typeValues = ['info', 'success', 'warn', 'error'];
|
|
13
13
|
const template = document.createElement('template');
|
|
14
14
|
template.innerHTML = templateHTML;
|
|
@@ -27,7 +27,7 @@ defineCustomElement('sinch-alert', (_$text = new WeakMap(), _$title = new WeakMa
|
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
const shadowRoot = this.attachShadow({
|
|
30
|
-
mode: '
|
|
30
|
+
mode: 'closed'
|
|
31
31
|
});
|
|
32
32
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
33
33
|
|
package/alert-button/index.js
CHANGED
|
@@ -21,7 +21,7 @@ defineCustomElement('sinch-alert-button', (_$button = new WeakMap(), class exten
|
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
const shadowRoot = this.attachShadow({
|
|
24
|
-
mode: '
|
|
24
|
+
mode: 'closed',
|
|
25
25
|
delegatesFocus: true
|
|
26
26
|
});
|
|
27
27
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
package/alert-close/index.js
CHANGED
|
@@ -9,7 +9,7 @@ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollect
|
|
|
9
9
|
|
|
10
10
|
import '../icon/close';
|
|
11
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>';
|
|
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 aria-label="close"><sinch-icon-close size="24"></sinch-icon-close></button>';
|
|
13
13
|
const template = document.createElement('template');
|
|
14
14
|
template.innerHTML = templateHTML;
|
|
15
15
|
defineCustomElement('sinch-alert-close', (_$button = new WeakMap(), class extends HTMLElement {
|
|
@@ -22,7 +22,7 @@ defineCustomElement('sinch-alert-close', (_$button = new WeakMap(), class extend
|
|
|
22
22
|
});
|
|
23
23
|
|
|
24
24
|
const shadowRoot = this.attachShadow({
|
|
25
|
-
mode: '
|
|
25
|
+
mode: 'closed',
|
|
26
26
|
delegatesFocus: true
|
|
27
27
|
});
|
|
28
28
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
package/button/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { TSinchElementReact } from '../types';
|
|
2
2
|
import type { FocusEvent, MouseEvent } from 'react';
|
|
3
|
-
declare const buttonTypes: readonly ["primary", "secondary", "cta", "destructive"];
|
|
3
|
+
declare const buttonTypes: readonly ["primary", "secondary", "cta-primary", "cta-secondary", "destructive"];
|
|
4
4
|
export declare type TSinchButtonType = typeof buttonTypes[number];
|
|
5
5
|
export declare type TSinchButtonElement = HTMLElement & {
|
|
6
6
|
type: TSinchButtonType;
|
|
@@ -13,6 +13,7 @@ export declare type TSinchButtonElement = HTMLElement & {
|
|
|
13
13
|
export declare type TSinchButtonReact = TSinchElementReact<TSinchButtonElement> & {
|
|
14
14
|
type: TSinchButtonType;
|
|
15
15
|
text: string;
|
|
16
|
+
'aria-label': string;
|
|
16
17
|
disabled?: boolean;
|
|
17
18
|
small?: boolean;
|
|
18
19
|
onClick: (e: MouseEvent<TSinchButtonElement>) => void;
|
package/button/index.js
CHANGED
|
@@ -8,8 +8,8 @@ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedec
|
|
|
8
8
|
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
9
9
|
|
|
10
10
|
import { defineCustomElement, getBooleanAttribute, getAttribute, getLiteralAttribute, isAttrTrue, updateBooleanAttribute, updateAttribute, updateLiteralAttribute } from '../utils';
|
|
11
|
-
const templateHTML = '<style>:host{--sinch-color-button-background:var(--sinch-color-tropical-500);--sinch-color-button-background-hover:var(--sinch-color-tropical-400);--sinch-color-button-background-focus:var(--sinch-color-tropical-500);--sinch-color-button-background-active:var(--sinch-color-tropical-600);--sinch-color-button-background-disabled:var(--sinch-color-tropical-100);--sinch-color-button-text:var(--sinch-color-text-inverted);--sinch-color-button-text-disabled:var(--sinch-color-text-inverted);--sinch-color-button-border:var(--sinch-color-transparent);--sinch-color-button-border-hover:var(--sinch-color-transparent);--sinch-color-button-border-focus:var(--sinch-color-tropical-700);--sinch-color-button-border-active:var(--sinch-color-transparent);--sinch-color-button-border-disabled:var(--sinch-color-transparent);--sinch-color-spinner-bg:var(--sinch-color-tropical-300);--sinch-color-spinner-fg:var(--sinch-color-snow-100);--sinch-color-icon:var(--sinch-color-text-inverted);display:inline-block;vertical-align:middle;outline:0}:host([type=secondary]){--sinch-color-button-background:var(--sinch-color-snow-100);--sinch-color-button-background-hover:var(--sinch-color-tropical-100);--sinch-color-button-background-focus:var(--sinch-color-snow-100);--sinch-color-button-background-active:var(--sinch-color-tropical-100);--sinch-color-button-background-disabled:var(--sinch-color-snow-100);--sinch-color-button-text:var(--sinch-color-tropical-500);--sinch-color-button-text-disabled:var(--sinch-color-tropical-100);--sinch-color-button-border:var(--sinch-color-tropical-500);--sinch-color-button-border-hover:var(--sinch-color-tropical-500);--sinch-color-button-border-focus:var(--sinch-color-tropical-700);--sinch-color-button-border-active:var(--sinch-color-tropical-500);--sinch-color-button-border-disabled:var(--sinch-color-tropical-100);--sinch-color-spinner-bg:var(--sinch-color-tropical-100);--sinch-color-spinner-fg:var(--sinch-color-tropical-500);--sinch-color-icon:var(--sinch-color-tropical-500)}:host([type=secondary]) button:is(:hover,:active){--sinch-color-spinner-bg:var(--sinch-color-tropical-300);--sinch-color-spinner-fg:var(--sinch-color-snow-100)}:host([type=secondary]) button:disabled{--sinch-color-spinner-bg:var(--sinch-color-tropical-200);--sinch-color-spinner-fg:var(--sinch-color-tropical-400)}:host([type=cta]){--sinch-color-button-background:var(--sinch-color-honey-500);--sinch-color-button-background-hover:var(--sinch-color-honey-400);--sinch-color-button-background-focus:var(--sinch-color-honey-500);--sinch-color-button-background-active:var(--sinch-color-honey-600);--sinch-color-button-background-disabled:var(--sinch-color-honey-100);--sinch-color-button-text:var(--sinch-color-text-default);--sinch-color-button-text-disabled:var(--sinch-color-stormy-300);--sinch-color-button-border:var(--sinch-color-transparent);--sinch-color-button-border-hover:var(--sinch-color-transparent);--sinch-color-button-border-focus:var(--sinch-color-text-default);--sinch-color-button-border-active:var(--sinch-color-transparent);--sinch-color-button-border-disabled:var(--sinch-color-transparent);--sinch-color-spinner-bg:var(--sinch-color-honey-700);--sinch-color-spinner-fg:var(--sinch-color-stormy-600);--sinch-color-icon:var(--sinch-color-text-default)}:host([type=cta]) button:disabled{--sinch-color-spinner-bg:var(--sinch-color-snow-100);--sinch-color-spinner-fg:var(--sinch-color-stormy-300)}:host([type=destructive]){--sinch-color-button-background:var(--sinch-color-snow-100);--sinch-color-button-background-hover:var(--sinch-color-error-200);--sinch-color-button-background-focus:var(--sinch-color-snow-100);--sinch-color-button-background-active:var(--sinch-color-error-200);--sinch-color-button-background-disabled:var(--sinch-color-snow-100);--sinch-color-button-text:var(--sinch-color-text-invalid);--sinch-color-button-text-disabled:var(--sinch-color-error-200);--sinch-color-button-border:var(--sinch-color-error-500);--sinch-color-button-border-hover:var(--sinch-color-error-500);--sinch-color-button-border-focus:var(--sinch-color-error-800);--sinch-color-button-border-active:var(--sinch-color-error-500);--sinch-color-button-border-disabled:var(--sinch-color-error-200);--sinch-color-spinner-bg:var(--sinch-color-raspberry-100);--sinch-color-spinner-fg:var(--sinch-color-raspberry-500);--sinch-color-icon:var(--sinch-color-text-invalid)}:host([type=destructive]) button:is(:hover,:active){--sinch-color-spinner-bg:var(--sinch-color-raspberry-200);--sinch-color-spinner-fg:var(--sinch-color-raspberry-500)}:host([type=destructive]) button:disabled{--sinch-color-spinner-bg:var(--sinch-color-raspberry-100);--sinch-color-spinner-fg:var(--sinch-color-raspberry-500)}button{all:initial;display:flex;align-items:center;justify-content:center;gap:15px;box-sizing:border-box;width:100%;height:48px;padding:12px
|
|
12
|
-
const buttonTypes = ['primary', 'secondary', 'cta', 'destructive'];
|
|
11
|
+
const templateHTML = '<style>:host{--sinch-color-button-background:var(--sinch-color-tropical-500);--sinch-color-button-background-hover:var(--sinch-color-tropical-400);--sinch-color-button-background-focus:var(--sinch-color-tropical-500);--sinch-color-button-background-active:var(--sinch-color-tropical-600);--sinch-color-button-background-disabled:var(--sinch-color-tropical-100);--sinch-color-button-text:var(--sinch-color-text-inverted);--sinch-color-button-text-disabled:var(--sinch-color-text-inverted);--sinch-color-button-border:var(--sinch-color-transparent);--sinch-color-button-border-hover:var(--sinch-color-transparent);--sinch-color-button-border-focus:var(--sinch-color-tropical-700);--sinch-color-button-border-active:var(--sinch-color-transparent);--sinch-color-button-border-disabled:var(--sinch-color-transparent);--sinch-color-spinner-bg:var(--sinch-color-tropical-300);--sinch-color-spinner-fg:var(--sinch-color-snow-100);--sinch-color-icon:var(--sinch-color-text-inverted);display:inline-block;vertical-align:middle;outline:0}:host([type=secondary]){--sinch-color-button-background:var(--sinch-color-snow-100);--sinch-color-button-background-hover:var(--sinch-color-tropical-100);--sinch-color-button-background-focus:var(--sinch-color-snow-100);--sinch-color-button-background-active:var(--sinch-color-tropical-100);--sinch-color-button-background-disabled:var(--sinch-color-snow-100);--sinch-color-button-text:var(--sinch-color-tropical-500);--sinch-color-button-text-disabled:var(--sinch-color-tropical-100);--sinch-color-button-border:var(--sinch-color-tropical-500);--sinch-color-button-border-hover:var(--sinch-color-tropical-500);--sinch-color-button-border-focus:var(--sinch-color-tropical-700);--sinch-color-button-border-active:var(--sinch-color-tropical-500);--sinch-color-button-border-disabled:var(--sinch-color-tropical-100);--sinch-color-spinner-bg:var(--sinch-color-tropical-100);--sinch-color-spinner-fg:var(--sinch-color-tropical-500);--sinch-color-icon:var(--sinch-color-tropical-500)}:host([type=secondary]) button:is(:hover,:active){--sinch-color-spinner-bg:var(--sinch-color-tropical-300);--sinch-color-spinner-fg:var(--sinch-color-snow-100)}:host([type=secondary]) button:disabled{--sinch-color-spinner-bg:var(--sinch-color-tropical-200);--sinch-color-spinner-fg:var(--sinch-color-tropical-400)}:host([type=cta-primary]){--sinch-color-button-background:var(--sinch-color-honey-500);--sinch-color-button-background-hover:var(--sinch-color-honey-400);--sinch-color-button-background-focus:var(--sinch-color-honey-500);--sinch-color-button-background-active:var(--sinch-color-honey-600);--sinch-color-button-background-disabled:var(--sinch-color-honey-100);--sinch-color-button-text:var(--sinch-color-text-default);--sinch-color-button-text-disabled:var(--sinch-color-stormy-300);--sinch-color-button-border:var(--sinch-color-transparent);--sinch-color-button-border-hover:var(--sinch-color-transparent);--sinch-color-button-border-focus:var(--sinch-color-text-default);--sinch-color-button-border-active:var(--sinch-color-transparent);--sinch-color-button-border-disabled:var(--sinch-color-transparent);--sinch-color-spinner-bg:var(--sinch-color-honey-700);--sinch-color-spinner-fg:var(--sinch-color-stormy-600);--sinch-color-icon:var(--sinch-color-text-default)}:host([type=cta-primary]) button:disabled{--sinch-color-spinner-bg:var(--sinch-color-snow-100);--sinch-color-spinner-fg:var(--sinch-color-stormy-300)}:host([type=cta-secondary]){--sinch-color-button-background:var(--sinch-color-snow-100);--sinch-color-button-background-hover:var(--sinch-color-snow-500);--sinch-color-button-background-focus:var(--sinch-color-snow-100);--sinch-color-button-background-active:var(--sinch-color-snow-500);--sinch-color-button-background-disabled:var(--sinch-color-snow-100);--sinch-color-button-text:var(--sinch-color-stormy-500);--sinch-color-button-text-disabled:var(--sinch-color-stormy-200);--sinch-color-button-border:var(--sinch-color-stormy-500);--sinch-color-button-border-hover:var(--sinch-color-stormy-500);--sinch-color-button-border-focus:var(--sinch-color-stormy-500);--sinch-color-button-border-active:var(--sinch-color-stormy-500);--sinch-color-button-border-disabled:var(--sinch-color-stormy-200);--sinch-color-spinner-bg:var(--sinch-color-snow-800);--sinch-color-spinner-fg:var(--sinch-color-stormy-600);--sinch-color-icon:var(--sinch-color-stormy-500)}:host([type=cta-secondary]) button:disabled{--sinch-color-spinner-bg:var(--sinch-color-snow-600);--sinch-color-spinner-fg:var(--sinch-color-stormy-200);--sinch-color-icon:var(--sinch-color-stormy-200)}:host([type=destructive]){--sinch-color-button-background:var(--sinch-color-snow-100);--sinch-color-button-background-hover:var(--sinch-color-error-200);--sinch-color-button-background-focus:var(--sinch-color-snow-100);--sinch-color-button-background-active:var(--sinch-color-error-200);--sinch-color-button-background-disabled:var(--sinch-color-snow-100);--sinch-color-button-text:var(--sinch-color-text-invalid);--sinch-color-button-text-disabled:var(--sinch-color-error-200);--sinch-color-button-border:var(--sinch-color-error-500);--sinch-color-button-border-hover:var(--sinch-color-error-500);--sinch-color-button-border-focus:var(--sinch-color-error-800);--sinch-color-button-border-active:var(--sinch-color-error-500);--sinch-color-button-border-disabled:var(--sinch-color-error-200);--sinch-color-spinner-bg:var(--sinch-color-raspberry-100);--sinch-color-spinner-fg:var(--sinch-color-raspberry-500);--sinch-color-icon:var(--sinch-color-text-invalid)}:host([type=destructive]) button:is(:hover,:active){--sinch-color-spinner-bg:var(--sinch-color-raspberry-200);--sinch-color-spinner-fg:var(--sinch-color-raspberry-500)}:host([type=destructive]) button:disabled{--sinch-color-spinner-bg:var(--sinch-color-raspberry-100);--sinch-color-spinner-fg:var(--sinch-color-raspberry-500)}button{all:initial;display:flex;align-items:center;justify-content:center;gap:15px;box-sizing:border-box;width:100%;height:48px;padding:12px;border-radius:4px;font:var(--sinch-font-title-4);color:var(--sinch-color-button-text);background-color:var(--sinch-color-button-background);box-shadow:0 0 0 1px var(--sinch-color-button-border) inset;cursor:pointer}button:focus{background-color:var(--sinch-color-button-background-focus);box-shadow:0 0 0 2px var(--sinch-color-button-border-focus) inset}button:hover{background-color:var(--sinch-color-button-background-hover);box-shadow:0 0 0 1px var(--sinch-color-button-border-hover) inset}button:active{background-color:var(--sinch-color-button-background-active);box-shadow:0 0 0 2px var(--sinch-color-button-border-active) inset}button:disabled{color:var(--sinch-color-button-text-disabled);background-color:var(--sinch-color-button-background-disabled);box-shadow:0 0 0 1px var(--sinch-color-button-border-disabled) inset;cursor:initial;--sinch-color-spinner-bg:var(--sinch-color-snow-100);--sinch-color-spinner-fg:var(--sinch-color-tropical-200);--sinch-color-icon:var(--sinch-color-button-text-disabled)}button>*{pointer-events:none}#text{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;display:none}:host([text]:not([text=""])) #text{display:initial}:host([text]:not([text=""])) button{padding:12px 24px}:host([small]:not([small=false]))>button{height:32px;padding:8px;line-height:16px;font-size:14px;gap:8px}:host([text]:not([text=""])[small]:not([small=false])) button{padding:8px 16px}</style><button><slot name="icon"></slot><span id="text"></span></button>';
|
|
12
|
+
const buttonTypes = ['primary', 'secondary', 'cta-primary', 'cta-secondary', 'destructive'];
|
|
13
13
|
const template = document.createElement('template');
|
|
14
14
|
template.innerHTML = templateHTML;
|
|
15
15
|
defineCustomElement('sinch-button', (_$button = new WeakMap(), _$text = new WeakMap(), class extends HTMLElement {
|
|
@@ -27,7 +27,7 @@ defineCustomElement('sinch-button', (_$button = new WeakMap(), _$text = new Weak
|
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
const shadowRoot = this.attachShadow({
|
|
30
|
-
mode: '
|
|
30
|
+
mode: 'closed',
|
|
31
31
|
delegatesFocus: true
|
|
32
32
|
});
|
|
33
33
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
@@ -37,6 +37,10 @@ defineCustomElement('sinch-button', (_$button = new WeakMap(), _$text = new Weak
|
|
|
37
37
|
_classPrivateFieldSet(this, _$text, shadowRoot.querySelector('#text'));
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
connectedCallback() {
|
|
41
|
+
this.setAttribute('role', 'button');
|
|
42
|
+
}
|
|
43
|
+
|
|
40
44
|
static get observedAttributes() {
|
|
41
45
|
return ['text', 'disabled'];
|
|
42
46
|
}
|
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,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 {};
|