@nectary/components 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/accordion/index.d.ts +21 -0
- package/accordion/index.js +118 -0
- package/accordion-item/index.d.ts +33 -0
- package/accordion-item/index.js +139 -0
- package/alert/index.d.ts +26 -0
- package/alert/index.js +91 -0
- package/alert-button/index.d.ts +23 -0
- package/alert-button/index.js +62 -0
- package/alert-close/index.d.ts +22 -0
- package/alert-close/index.js +41 -0
- package/button/index.d.ts +32 -0
- package/button/index.js +100 -0
- package/checkbox/index.d.ts +29 -0
- package/checkbox/index.js +134 -0
- package/help-tooltip/index.d.ts +15 -0
- package/help-tooltip/index.js +80 -0
- package/icon/cancel/index.d.ts +11 -0
- package/icon/cancel/index.js +4 -0
- package/icon/close/index.d.ts +11 -0
- package/icon/close/index.js +4 -0
- package/icon/create-icon-class.d.ts +308 -0
- package/icon/create-icon-class.js +53 -0
- package/icon/east/index.d.ts +11 -0
- package/icon/east/index.js +4 -0
- package/icon/help-outline/index.d.ts +11 -0
- package/icon/help-outline/index.js +4 -0
- package/icon/more-horiz/index.d.ts +11 -0
- package/icon/more-horiz/index.js +4 -0
- package/icon/more-vert/index.d.ts +11 -0
- package/icon/more-vert/index.js +4 -0
- package/icon/north/index.d.ts +11 -0
- package/icon/north/index.js +4 -0
- package/icon/north-east/index.d.ts +11 -0
- package/icon/north-east/index.js +4 -0
- package/icon/north-west/index.d.ts +11 -0
- package/icon/north-west/index.js +4 -0
- package/icon/open-in-new/index.d.ts +11 -0
- package/icon/open-in-new/index.js +4 -0
- package/icon/south/index.d.ts +11 -0
- package/icon/south/index.js +4 -0
- package/icon/south-east/index.d.ts +11 -0
- package/icon/south-east/index.js +4 -0
- package/icon/south-west/index.d.ts +11 -0
- package/icon/south-west/index.js +4 -0
- package/icon/types.d.ts +7 -0
- package/icon/types.js +1 -0
- package/icon/west/index.d.ts +11 -0
- package/icon/west/index.js +4 -0
- package/icon-branded/barchart-down/index.d.ts +11 -0
- package/icon-branded/barchart-down/index.js +4 -0
- package/icon-branded/barchart-up/index.d.ts +11 -0
- package/icon-branded/barchart-up/index.js +4 -0
- package/icon-branded/campaigns/index.d.ts +11 -0
- package/icon-branded/campaigns/index.js +4 -0
- package/icon-branded/chatbot/index.d.ts +11 -0
- package/icon-branded/chatbot/index.js +4 -0
- package/icon-branded/contact/index.d.ts +11 -0
- package/icon-branded/contact/index.js +4 -0
- package/icon-branded/create-icon-class.d.ts +309 -0
- package/icon-branded/create-icon-class.js +61 -0
- package/icon-branded/home/index.d.ts +11 -0
- package/icon-branded/home/index.js +4 -0
- package/icon-branded/multiple-channels/index.d.ts +11 -0
- package/icon-branded/multiple-channels/index.js +4 -0
- package/icon-branded/rocket/index.d.ts +11 -0
- package/icon-branded/rocket/index.js +4 -0
- package/icon-branded/settings/index.d.ts +11 -0
- package/icon-branded/settings/index.js +4 -0
- package/icon-branded/types.d.ts +9 -0
- package/icon-branded/types.js +1 -0
- package/icon-branded/user/index.d.ts +11 -0
- package/icon-branded/user/index.js +4 -0
- package/icon-branded/users/index.d.ts +11 -0
- package/icon-branded/users/index.js +4 -0
- package/index.d.ts +56 -0
- package/index.js +56 -0
- package/input/index.d.ts +35 -0
- package/input/index.js +203 -0
- package/link/index.d.ts +30 -0
- package/link/index.js +118 -0
- package/logo/create-logo-class.d.ts +309 -0
- package/logo/create-logo-class.js +63 -0
- package/logo/sinch-icon/index.d.ts +11 -0
- package/logo/sinch-icon/index.js +4 -0
- package/logo/sinch-icon-wordmark/index.d.ts +11 -0
- package/logo/sinch-icon-wordmark/index.js +4 -0
- package/logo/types.d.ts +9 -0
- package/logo/types.js +1 -0
- package/package.json +34 -0
- package/radio/index.d.ts +19 -0
- package/radio/index.js +185 -0
- package/radio-option/index.d.ts +28 -0
- package/radio-option/index.js +134 -0
- package/readme.md +172 -0
- package/select/index.d.ts +37 -0
- package/select/index.js +492 -0
- package/select-option/index.d.ts +27 -0
- package/select-option/index.js +107 -0
- package/spinner/index.d.ts +21 -0
- package/spinner/index.js +23 -0
- package/table/index.d.ts +13 -0
- package/table/index.js +18 -0
- package/table-body/index.d.ts +13 -0
- package/table-body/index.js +18 -0
- package/table-cell/index.d.ts +20 -0
- package/table-cell/index.js +27 -0
- package/table-head/index.d.ts +13 -0
- package/table-head/index.js +18 -0
- package/table-head-cell/index.d.ts +24 -0
- package/table-head-cell/index.js +74 -0
- package/table-head-sort/index.d.ts +25 -0
- package/table-head-sort/index.js +92 -0
- package/table-row/index.d.ts +17 -0
- package/table-row/index.js +26 -0
- package/tabs/index.d.ts +19 -0
- package/tabs/index.js +181 -0
- package/tabs-option/index.d.ts +28 -0
- package/tabs-option/index.js +129 -0
- package/tag/index.d.ts +27 -0
- package/tag/index.js +79 -0
- package/tag-close/index.d.ts +24 -0
- package/tag-close/index.js +70 -0
- package/textarea/index.d.ts +35 -0
- package/textarea/index.js +201 -0
- package/theme.css +112 -0
- package/toggle/index.d.ts +31 -0
- package/toggle/index.js +144 -0
- package/tooltip/index.d.ts +26 -0
- package/tooltip/index.js +68 -0
- package/types.d.ts +3 -0
- package/utils.d.ts +31 -0
- package/utils.js +146 -0
package/button/index.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
|
+
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
|
+
|
|
4
|
+
var _$button, _$text;
|
|
5
|
+
|
|
6
|
+
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
7
|
+
|
|
8
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
9
|
+
|
|
10
|
+
import { defineCustomElement, 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 24px;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}:host([small]:not([small=false]))>button{height:32px;padding:8px 16px;line-height:16px;font-size:14px;gap:8px}</style><button><slot name="icon"></slot><span id="text"></span></button>';
|
|
12
|
+
const buttonTypes = ['primary', 'secondary', 'cta', 'destructive'];
|
|
13
|
+
const template = document.createElement('template');
|
|
14
|
+
template.innerHTML = templateHTML;
|
|
15
|
+
defineCustomElement('sinch-button', (_$button = new WeakMap(), _$text = new WeakMap(), class extends HTMLElement {
|
|
16
|
+
constructor() {
|
|
17
|
+
super();
|
|
18
|
+
|
|
19
|
+
_classPrivateFieldInitSpec(this, _$button, {
|
|
20
|
+
writable: true,
|
|
21
|
+
value: void 0
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
_classPrivateFieldInitSpec(this, _$text, {
|
|
25
|
+
writable: true,
|
|
26
|
+
value: void 0
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const shadowRoot = this.attachShadow({
|
|
30
|
+
mode: 'production' === 'development' ? 'open' : 'closed',
|
|
31
|
+
delegatesFocus: true
|
|
32
|
+
});
|
|
33
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
34
|
+
|
|
35
|
+
_classPrivateFieldSet(this, _$button, shadowRoot.querySelector('button'));
|
|
36
|
+
|
|
37
|
+
_classPrivateFieldSet(this, _$text, shadowRoot.querySelector('#text'));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
static get observedAttributes() {
|
|
41
|
+
return ['text', 'disabled'];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
attributeChangedCallback(name, _, newVal) {
|
|
45
|
+
switch (name) {
|
|
46
|
+
case 'text':
|
|
47
|
+
{
|
|
48
|
+
_classPrivateFieldGet(this, _$text).textContent = newVal;
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
case 'disabled':
|
|
53
|
+
{
|
|
54
|
+
_classPrivateFieldGet(this, _$button).disabled = isAttrTrue(newVal);
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
set type(value) {
|
|
61
|
+
updateLiteralAttribute(this, buttonTypes, 'type', value);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
get type() {
|
|
65
|
+
return getLiteralAttribute(this, buttonTypes, 'type', 'primary');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
set text(value) {
|
|
69
|
+
updateAttribute(this, 'text', value);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
get text() {
|
|
73
|
+
return getAttribute(this, 'text', '');
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
set disabled(isDisabled) {
|
|
77
|
+
updateBooleanAttribute(this, 'disabled', isDisabled);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
get disabled() {
|
|
81
|
+
return getBooleanAttribute(this, 'disabled');
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
set small(isSmall) {
|
|
85
|
+
updateBooleanAttribute(this, 'small', isSmall);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
get small() {
|
|
89
|
+
return getBooleanAttribute(this, 'small');
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
focus() {
|
|
93
|
+
_classPrivateFieldGet(this, _$button).focus();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
blur() {
|
|
97
|
+
_classPrivateFieldGet(this, _$button).blur();
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
}));
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { TSinchElementReact } from '../types';
|
|
2
|
+
import type { FocusEvent, SyntheticEvent } from 'react';
|
|
3
|
+
export declare type TSinchCheckboxElement = HTMLElement & {
|
|
4
|
+
checked: boolean;
|
|
5
|
+
indeterminate: boolean;
|
|
6
|
+
disabled: boolean;
|
|
7
|
+
text: string | null;
|
|
8
|
+
focus(): void;
|
|
9
|
+
blur(): void;
|
|
10
|
+
};
|
|
11
|
+
export declare type TSinchCheckboxReact = TSinchElementReact<TSinchCheckboxElement> & {
|
|
12
|
+
checked?: boolean;
|
|
13
|
+
indeterminate?: boolean;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
text?: string;
|
|
16
|
+
onChange: (event: SyntheticEvent<TSinchCheckboxElement, CustomEvent<boolean>>) => void;
|
|
17
|
+
onFocus?: (e: FocusEvent<TSinchCheckboxElement>) => void;
|
|
18
|
+
onBlur?: (e: FocusEvent<TSinchCheckboxElement>) => void;
|
|
19
|
+
};
|
|
20
|
+
declare global {
|
|
21
|
+
namespace JSX {
|
|
22
|
+
interface IntrinsicElements {
|
|
23
|
+
'sinch-checkbox': TSinchCheckboxReact;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
interface HTMLElementTagNameMap {
|
|
27
|
+
'sinch-checkbox': TSinchCheckboxElement;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
|
+
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
3
|
+
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
4
|
+
|
|
5
|
+
var _$input, _$label;
|
|
6
|
+
|
|
7
|
+
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
8
|
+
|
|
9
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
10
|
+
|
|
11
|
+
import { defineCustomElement, getAttribute, getBooleanAttribute, isAttrTrue, updateAttribute, updateBooleanAttribute } from '../utils';
|
|
12
|
+
const templateHTML = '<style>:host{--sinch-color-icon:var(--sinch-color-snow-100);--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);display:inline-block;vertical-align:middle;outline:0}#wrapper{display:flex;flex-direction:row;box-sizing:border-box;width:100%;height:32px;font:var(--sinch-font-body)}#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}:host([text]:not([text=""])) #label{display:block}:host([disabled]:not([disabled=false])) #label{color:var(--sinch-color-stormy-200)}: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"><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"><line y1="1" x2="12" y2="1" stroke="white" stroke-width="2"/></svg></div><label for="checkbox" id="label"></label></div>';
|
|
13
|
+
const template = document.createElement('template');
|
|
14
|
+
template.innerHTML = templateHTML;
|
|
15
|
+
defineCustomElement('sinch-checkbox', (_$input = new WeakMap(), _$label = new WeakMap(), class extends HTMLElement {
|
|
16
|
+
constructor() {
|
|
17
|
+
super();
|
|
18
|
+
|
|
19
|
+
_classPrivateFieldInitSpec(this, _$input, {
|
|
20
|
+
writable: true,
|
|
21
|
+
value: void 0
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
_classPrivateFieldInitSpec(this, _$label, {
|
|
25
|
+
writable: true,
|
|
26
|
+
value: void 0
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
_defineProperty(this, 'onCheckboxInput', e => {
|
|
30
|
+
e.stopPropagation();
|
|
31
|
+
|
|
32
|
+
const isChecked = _classPrivateFieldGet(this, _$input).checked;
|
|
33
|
+
|
|
34
|
+
_classPrivateFieldGet(this, _$input).checked = this.checked;
|
|
35
|
+
this.dispatchEvent(new CustomEvent('change', {
|
|
36
|
+
detail: isChecked,
|
|
37
|
+
bubbles: true
|
|
38
|
+
}));
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const shadowRoot = this.attachShadow({
|
|
42
|
+
mode: 'production' === 'development' ? 'open' : 'closed',
|
|
43
|
+
delegatesFocus: true
|
|
44
|
+
});
|
|
45
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
46
|
+
|
|
47
|
+
_classPrivateFieldSet(this, _$input, shadowRoot.querySelector('input'));
|
|
48
|
+
|
|
49
|
+
_classPrivateFieldSet(this, _$label, shadowRoot.querySelector('label'));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
connectedCallback() {
|
|
53
|
+
_classPrivateFieldGet(this, _$input).addEventListener('input', this.onCheckboxInput);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
disconnectedCallback() {
|
|
57
|
+
_classPrivateFieldGet(this, _$input).removeEventListener('input', this.onCheckboxInput);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
static get observedAttributes() {
|
|
61
|
+
return ['checked', 'disabled', 'text'];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
get type() {
|
|
65
|
+
return 'text';
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
get nodeName() {
|
|
69
|
+
return 'input';
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
set checked(isChecked) {
|
|
73
|
+
updateBooleanAttribute(this, 'checked', isChecked);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
get checked() {
|
|
77
|
+
return getBooleanAttribute(this, 'checked');
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
set indeterminate(isIndeterminate) {
|
|
81
|
+
updateBooleanAttribute(this, 'indeterminate', isIndeterminate);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
get indeterminate() {
|
|
85
|
+
return getBooleanAttribute(this, 'indeterminate');
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
set disabled(isDisabled) {
|
|
89
|
+
updateBooleanAttribute(this, 'disabled', isDisabled);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
get disabled() {
|
|
93
|
+
return getBooleanAttribute(this, 'disabled');
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
set text(value) {
|
|
97
|
+
updateAttribute(this, 'text', value);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
get text() {
|
|
101
|
+
return getAttribute(this, 'text', null);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
attributeChangedCallback(name, _, newVal) {
|
|
105
|
+
switch (name) {
|
|
106
|
+
case 'text':
|
|
107
|
+
{
|
|
108
|
+
_classPrivateFieldGet(this, _$label).textContent = newVal;
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
case 'checked':
|
|
113
|
+
{
|
|
114
|
+
_classPrivateFieldGet(this, _$input).checked = isAttrTrue(newVal);
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
case 'disabled':
|
|
119
|
+
{
|
|
120
|
+
_classPrivateFieldGet(this, _$input).disabled = isAttrTrue(newVal);
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
focus() {
|
|
127
|
+
_classPrivateFieldGet(this, _$input).focus();
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
blur() {
|
|
131
|
+
_classPrivateFieldGet(this, _$input).blur();
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
}));
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import '../tooltip';
|
|
2
|
+
import '../icon/help-outline';
|
|
3
|
+
import type { TSinchTooltipElement, TSinchTooltipReact } from '../tooltip';
|
|
4
|
+
export declare type TSinchHelpTooltipElement = TSinchTooltipElement;
|
|
5
|
+
export declare type TSinchHelpTooltipReact = TSinchTooltipReact;
|
|
6
|
+
declare global {
|
|
7
|
+
namespace JSX {
|
|
8
|
+
interface IntrinsicElements {
|
|
9
|
+
'sinch-help-tooltip': TSinchHelpTooltipReact;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
interface HTMLElementTagNameMap {
|
|
13
|
+
'sinch-help-tooltip': TSinchHelpTooltipElement;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import '../tooltip';
|
|
2
|
+
import '../icon/help-outline';
|
|
3
|
+
import { defineCustomElement, getAttribute, getBooleanAttribute, getIntegerAttribute, updateAttribute, updateBooleanAttribute, updateIntegerAttribute } from '../utils';
|
|
4
|
+
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle}sinch-tooltip{display:block}</style><sinch-tooltip><sinch-icon-help-outline size="18"></sinch-icon-help-outline></sinch-tooltip>';
|
|
5
|
+
const template = document.createElement('template');
|
|
6
|
+
template.innerHTML = templateHTML;
|
|
7
|
+
defineCustomElement('sinch-help-tooltip', class extends HTMLElement {
|
|
8
|
+
constructor() {
|
|
9
|
+
super();
|
|
10
|
+
const shadowRoot = this.attachShadow({
|
|
11
|
+
mode: 'production' === 'development' ? 'open' : 'closed'
|
|
12
|
+
});
|
|
13
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
14
|
+
this.$tooltip = shadowRoot.querySelector('sinch-tooltip');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
static get observedAttributes() {
|
|
18
|
+
return ['text', 'width', 'orientation', 'inverted'];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
get text() {
|
|
22
|
+
return getAttribute(this, 'text', '');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
set text(value) {
|
|
26
|
+
updateAttribute(this, 'text', value);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
get width() {
|
|
30
|
+
return getIntegerAttribute(this, 'width');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
set width(value) {
|
|
34
|
+
updateIntegerAttribute(this, 'width', value);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
get inverted() {
|
|
38
|
+
return getBooleanAttribute(this, 'inverted');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
set inverted(isInverted) {
|
|
42
|
+
updateBooleanAttribute(this, 'inverted', isInverted);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
get orientation() {
|
|
46
|
+
return getAttribute(this, 'orientation');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
set orientation(value) {
|
|
50
|
+
updateAttribute(this, 'orientation', value);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
attributeChangedCallback(name, _, newVal) {
|
|
54
|
+
switch (name) {
|
|
55
|
+
case 'text':
|
|
56
|
+
{
|
|
57
|
+
updateAttribute(this.$tooltip, 'text', newVal);
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
case 'width':
|
|
62
|
+
{
|
|
63
|
+
updateAttribute(this.$tooltip, 'width', newVal);
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
case 'inverted':
|
|
68
|
+
{
|
|
69
|
+
updateAttribute(this.$tooltip, 'inverted', newVal);
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
case 'orientation':
|
|
74
|
+
{
|
|
75
|
+
updateAttribute(this.$tooltip, 'orientation', newVal);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { TSinchIconElement, TSinchIconReact } from '../types';
|
|
2
|
+
declare global {
|
|
3
|
+
namespace JSX {
|
|
4
|
+
interface IntrinsicElements {
|
|
5
|
+
'sinch-icon-cancel': TSinchIconReact;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
interface HTMLElementTagNameMap {
|
|
9
|
+
'sinch-icon-cancel': TSinchIconElement;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { defineCustomElement } from '../../utils';
|
|
2
|
+
import { createIconClass } from '../create-icon-class';
|
|
3
|
+
const templateHTML = '<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2Zm4.3 14.3a.996.996 0 0 1-1.41 0L12 13.41 9.11 16.3a.996.996 0 1 1-1.41-1.41L10.59 12 7.7 9.11A.996.996 0 1 1 9.11 7.7L12 10.59l2.89-2.89a.996.996 0 1 1 1.41 1.41L13.41 12l2.89 2.89c.38.38.38 1.02 0 1.41Z"/></svg>';
|
|
4
|
+
defineCustomElement('sinch-icon-cancel', createIconClass(templateHTML));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { TSinchIconElement, TSinchIconReact } from '../types';
|
|
2
|
+
declare global {
|
|
3
|
+
namespace JSX {
|
|
4
|
+
interface IntrinsicElements {
|
|
5
|
+
'sinch-icon-close': TSinchIconReact;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
interface HTMLElementTagNameMap {
|
|
9
|
+
'sinch-icon-close': TSinchIconElement;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { defineCustomElement } from '../../utils';
|
|
2
|
+
import { createIconClass } from '../create-icon-class';
|
|
3
|
+
const templateHTML = '<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M18.3 5.71a.996.996 0 0 0-1.41 0L12 10.59 7.11 5.7A.996.996 0 1 0 5.7 7.11L10.59 12 5.7 16.89a.996.996 0 1 0 1.41 1.41L12 13.41l4.89 4.89a.996.996 0 1 0 1.41-1.41L13.41 12l4.89-4.89c.38-.38.38-1.02 0-1.4Z"/></svg>';
|
|
4
|
+
defineCustomElement('sinch-icon-close', createIconClass(templateHTML));
|