@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/index.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import './theme.css';
|
|
2
|
+
import './accordion';
|
|
3
|
+
import './accordion-item';
|
|
4
|
+
import './alert';
|
|
5
|
+
import './alert-button';
|
|
6
|
+
import './alert-close';
|
|
7
|
+
import './button';
|
|
8
|
+
import './checkbox';
|
|
9
|
+
import './input';
|
|
10
|
+
import './help-tooltip';
|
|
11
|
+
import './link';
|
|
12
|
+
import './select';
|
|
13
|
+
import './select-option';
|
|
14
|
+
import './radio';
|
|
15
|
+
import './radio-option';
|
|
16
|
+
import './tabs';
|
|
17
|
+
import './tag';
|
|
18
|
+
import './tag-close';
|
|
19
|
+
import './textarea';
|
|
20
|
+
import './toggle';
|
|
21
|
+
import './tooltip';
|
|
22
|
+
import './icon/cancel';
|
|
23
|
+
import './icon/close';
|
|
24
|
+
import './icon/east';
|
|
25
|
+
import './icon/help-outline';
|
|
26
|
+
import './icon/more-horiz';
|
|
27
|
+
import './icon/more-vert';
|
|
28
|
+
import './icon/north';
|
|
29
|
+
import './icon/north-east';
|
|
30
|
+
import './icon/north-west';
|
|
31
|
+
import './icon/open-in-new';
|
|
32
|
+
import './icon/south';
|
|
33
|
+
import './icon/south-east';
|
|
34
|
+
import './icon/south-west';
|
|
35
|
+
import './icon/west';
|
|
36
|
+
import './table';
|
|
37
|
+
import './table-cell';
|
|
38
|
+
import './table-head';
|
|
39
|
+
import './table-head-cell';
|
|
40
|
+
import './table-head-sort';
|
|
41
|
+
import './table-body';
|
|
42
|
+
import './table-row';
|
|
43
|
+
import './spinner';
|
|
44
|
+
import './logo/sinch-icon';
|
|
45
|
+
import './logo/sinch-icon-wordmark';
|
|
46
|
+
import './icon-branded/barchart-down';
|
|
47
|
+
import './icon-branded/barchart-up';
|
|
48
|
+
import './icon-branded/campaigns';
|
|
49
|
+
import './icon-branded/chatbot';
|
|
50
|
+
import './icon-branded/contact';
|
|
51
|
+
import './icon-branded/home';
|
|
52
|
+
import './icon-branded/multiple-channels';
|
|
53
|
+
import './icon-branded/rocket';
|
|
54
|
+
import './icon-branded/settings';
|
|
55
|
+
import './icon-branded/user';
|
|
56
|
+
import './icon-branded/users';
|
package/input/index.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { TSinchElementReact } from '../types';
|
|
2
|
+
import type { FocusEvent, SyntheticEvent } from 'react';
|
|
3
|
+
export declare type TSinchInputElement = HTMLElement & {
|
|
4
|
+
value: string;
|
|
5
|
+
label: string;
|
|
6
|
+
placeholder: string | null;
|
|
7
|
+
optionalText: string | null;
|
|
8
|
+
invalidText: string | null;
|
|
9
|
+
additionalText: string | null;
|
|
10
|
+
disabled: boolean;
|
|
11
|
+
focus(): void;
|
|
12
|
+
blur(): void;
|
|
13
|
+
};
|
|
14
|
+
export declare type TSinchInputReact = TSinchElementReact<TSinchInputElement> & {
|
|
15
|
+
value: string;
|
|
16
|
+
label: string;
|
|
17
|
+
placeholder?: string;
|
|
18
|
+
optionalText?: string;
|
|
19
|
+
invalidText?: string;
|
|
20
|
+
additionalText?: string;
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
onChange: (e: SyntheticEvent<TSinchInputElement, CustomEvent<string>>) => void;
|
|
23
|
+
onFocus?: (e: FocusEvent<TSinchInputElement>) => void;
|
|
24
|
+
onBlur?: (e: FocusEvent<TSinchInputElement>) => void;
|
|
25
|
+
};
|
|
26
|
+
declare global {
|
|
27
|
+
namespace JSX {
|
|
28
|
+
interface IntrinsicElements {
|
|
29
|
+
'sinch-input': TSinchInputReact;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
interface HTMLElementTagNameMap {
|
|
33
|
+
'sinch-input': TSinchInputElement;
|
|
34
|
+
}
|
|
35
|
+
}
|
package/input/index.js
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
|
+
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
|
+
|
|
4
|
+
var _$input, _$label, _$optionalText, _$additionalText, _$invalidText, _onInput;
|
|
5
|
+
|
|
6
|
+
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
7
|
+
|
|
8
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
9
|
+
|
|
10
|
+
import { defineCustomElement, getAttribute, getBooleanAttribute, isAttrTrue, updateAttribute, updateBooleanAttribute } from '../utils';
|
|
11
|
+
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{width:100%;box-sizing:border-box}#input{all:initial;border:1px solid var(--sinch-color-stormy-200);box-sizing:border-box;border-radius:2px;width:100%;height:48px;margin:2px 0;padding:0 12px;font:var(--sinch-font-body);color:var(--sinch-color-text-default);caret-color:var(--sinch-caret-color,auto)}#input::placeholder{font:var(--sinch-font-body);color:var(--sinch-color-text-muted)}#input:disabled{border-color:var(--sinch-color-snow-500);color:var(--sinch-color-stormy-100)}#input:disabled::placeholder{color:var(--sinch-color-snow-500)}#input:focus{border-color:var(--sinch-color-stormy-300)}:host([invalidtext]:not([invalidtext=""])) #input:not(:disabled){border-color:var(--sinch-color-text-invalid)}#bottom,#top{display:flex;align-items:baseline}#top{height:24px}#bottom{height:20px}#additional,#invalid,#label,#optional{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#label{font:var(--sinch-font-title-4);color:var(--sinch-color-text-default)}#optional{flex:1;text-align:right;font:var(--sinch-font-small-text);color:var(--sinch-color-text-muted)}#additional{flex:1;text-align:right;font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-muted)}#invalid{font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-invalid)}::slotted(sinch-help-tooltip){align-self:center;margin:0 8px}:host([disabled]:not([disabled=false])) :is(#label,#additional,#optional,#invalid){color:var(--sinch-color-stormy-100)}:host([disabled]:not([disabled=false])) ::slotted(sinch-help-tooltip){fill:var(--sinch-color-stormy-100)}</style><div id="wrapper"><div id="top"><label id="label" for="input"></label><slot name="tooltip"></slot><span id="optional"></span></div><input id="input" type="text"/><div id="bottom"><span id="invalid"></span> <span id="additional"></span></div></div>';
|
|
12
|
+
const template = document.createElement('template');
|
|
13
|
+
template.innerHTML = templateHTML;
|
|
14
|
+
defineCustomElement('sinch-input', (_$input = new WeakMap(), _$label = new WeakMap(), _$optionalText = new WeakMap(), _$additionalText = new WeakMap(), _$invalidText = new WeakMap(), _onInput = new WeakMap(), class extends HTMLElement {
|
|
15
|
+
constructor() {
|
|
16
|
+
super();
|
|
17
|
+
|
|
18
|
+
_classPrivateFieldInitSpec(this, _$input, {
|
|
19
|
+
writable: true,
|
|
20
|
+
value: void 0
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
_classPrivateFieldInitSpec(this, _$label, {
|
|
24
|
+
writable: true,
|
|
25
|
+
value: void 0
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
_classPrivateFieldInitSpec(this, _$optionalText, {
|
|
29
|
+
writable: true,
|
|
30
|
+
value: void 0
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
_classPrivateFieldInitSpec(this, _$additionalText, {
|
|
34
|
+
writable: true,
|
|
35
|
+
value: void 0
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
_classPrivateFieldInitSpec(this, _$invalidText, {
|
|
39
|
+
writable: true,
|
|
40
|
+
value: void 0
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
_classPrivateFieldInitSpec(this, _onInput, {
|
|
44
|
+
writable: true,
|
|
45
|
+
value: e => {
|
|
46
|
+
e.stopPropagation();
|
|
47
|
+
const value = e.target.value;
|
|
48
|
+
_classPrivateFieldGet(this, _$input).value = this.value;
|
|
49
|
+
this.dispatchEvent(new CustomEvent('change', {
|
|
50
|
+
detail: value,
|
|
51
|
+
bubbles: true
|
|
52
|
+
}));
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const shadowRoot = this.attachShadow({
|
|
57
|
+
mode: 'production' === 'development' ? 'open' : 'closed',
|
|
58
|
+
delegatesFocus: true
|
|
59
|
+
});
|
|
60
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
61
|
+
|
|
62
|
+
_classPrivateFieldSet(this, _$input, shadowRoot.querySelector('#input'));
|
|
63
|
+
|
|
64
|
+
_classPrivateFieldSet(this, _$label, shadowRoot.querySelector('#label'));
|
|
65
|
+
|
|
66
|
+
_classPrivateFieldSet(this, _$optionalText, shadowRoot.querySelector('#optional'));
|
|
67
|
+
|
|
68
|
+
_classPrivateFieldSet(this, _$additionalText, shadowRoot.querySelector('#additional'));
|
|
69
|
+
|
|
70
|
+
_classPrivateFieldSet(this, _$invalidText, shadowRoot.querySelector('#invalid'));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
connectedCallback() {
|
|
74
|
+
_classPrivateFieldGet(this, _$input).addEventListener('input', _classPrivateFieldGet(this, _onInput));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
disconnectedCallback() {
|
|
78
|
+
_classPrivateFieldGet(this, _$input).removeEventListener('input', _classPrivateFieldGet(this, _onInput));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
static get observedAttributes() {
|
|
82
|
+
return ['value', 'placeholder', 'label', 'optionaltext', 'additionaltext', 'invalidtext', 'disabled'];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
get type() {
|
|
86
|
+
return 'text';
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
get nodeName() {
|
|
90
|
+
return 'input';
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
set value(value) {
|
|
94
|
+
updateAttribute(this, 'value', value);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
get value() {
|
|
98
|
+
return getAttribute(this, 'value', '');
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
set placeholder(value) {
|
|
102
|
+
updateAttribute(this, 'placeholder', value);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
get placeholder() {
|
|
106
|
+
return getAttribute(this, 'placeholder', null);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
set label(value) {
|
|
110
|
+
updateAttribute(this, 'label', value);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
get label() {
|
|
114
|
+
return getAttribute(this, 'label', '');
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
set optionalText(value) {
|
|
118
|
+
updateAttribute(this, 'optionaltext', value);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
get optionalText() {
|
|
122
|
+
return getAttribute(this, 'optionaltext', null);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
set additionalText(value) {
|
|
126
|
+
updateAttribute(this, 'additionaltext', value);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
get additionalText() {
|
|
130
|
+
return getAttribute(this, 'additionaltext', null);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
set invalidText(value) {
|
|
134
|
+
updateAttribute(this, 'invalidtext', value);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
get invalidText() {
|
|
138
|
+
return getAttribute(this, 'invalidtext', null);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
set disabled(isDisabled) {
|
|
142
|
+
updateBooleanAttribute(this, 'disabled', isDisabled);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
get disabled() {
|
|
146
|
+
return getBooleanAttribute(this, 'disabled');
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
attributeChangedCallback(name, _, newVal) {
|
|
150
|
+
switch (name) {
|
|
151
|
+
case 'value':
|
|
152
|
+
{
|
|
153
|
+
_classPrivateFieldGet(this, _$input).value = newVal ?? '';
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
case 'label':
|
|
158
|
+
{
|
|
159
|
+
_classPrivateFieldGet(this, _$label).textContent = newVal;
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
case 'placeholder':
|
|
164
|
+
{
|
|
165
|
+
_classPrivateFieldGet(this, _$input).placeholder = newVal ?? '';
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
case 'optionaltext':
|
|
170
|
+
{
|
|
171
|
+
_classPrivateFieldGet(this, _$optionalText).textContent = newVal;
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
case 'additionaltext':
|
|
176
|
+
{
|
|
177
|
+
_classPrivateFieldGet(this, _$additionalText).textContent = newVal;
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
case 'invalidtext':
|
|
182
|
+
{
|
|
183
|
+
_classPrivateFieldGet(this, _$invalidText).textContent = newVal;
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
case 'disabled':
|
|
188
|
+
{
|
|
189
|
+
_classPrivateFieldGet(this, _$input).disabled = isAttrTrue(newVal);
|
|
190
|
+
break;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
focus() {
|
|
196
|
+
_classPrivateFieldGet(this, _$input).focus();
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
blur() {
|
|
200
|
+
_classPrivateFieldGet(this, _$input).blur();
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
}));
|
package/link/index.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import '../icon/cancel';
|
|
2
|
+
import type { TSinchElementReact } from '../types';
|
|
3
|
+
import type { FocusEvent, MouseEvent } from 'react';
|
|
4
|
+
export declare type TSinchLinkElement = HTMLElement & {
|
|
5
|
+
text: string;
|
|
6
|
+
href: string;
|
|
7
|
+
disabled: boolean;
|
|
8
|
+
external: boolean;
|
|
9
|
+
focus(): void;
|
|
10
|
+
blur(): void;
|
|
11
|
+
};
|
|
12
|
+
export declare type TSinchLinkReact = TSinchElementReact<TSinchLinkElement> & {
|
|
13
|
+
text: string;
|
|
14
|
+
href: string;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
external?: boolean;
|
|
17
|
+
onClick?: (e: MouseEvent<TSinchLinkElement>) => void;
|
|
18
|
+
onFocus?: (e: FocusEvent<TSinchLinkElement>) => void;
|
|
19
|
+
onBlur?: (e: FocusEvent<TSinchLinkElement>) => void;
|
|
20
|
+
};
|
|
21
|
+
declare global {
|
|
22
|
+
namespace JSX {
|
|
23
|
+
interface IntrinsicElements {
|
|
24
|
+
'sinch-link': TSinchLinkReact;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
interface HTMLElementTagNameMap {
|
|
28
|
+
'sinch-link': TSinchLinkElement;
|
|
29
|
+
}
|
|
30
|
+
}
|
package/link/index.js
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
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{font:var(--sinch-font-body);font-size:inherit;line-height:inherit;color:var(--sinch-color-text-link);fill:var(--sinch-color-text-link)}svg{display:none;transform:translateY(.15em);margin-left:.4em;width:.8em;pointer-events:none}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-200);pointer-events:none;cursor:initial;fill:var(--sinch-color-tropical-200)}:host([external]:not([external=false])) svg{display:inline-block}</style><a><span></span><svg viewBox="0 0 16 16"><path d="M14.222 14.222H1.778V1.778H8V0H1.778C.79 0 0 .8 0 1.778v12.444C0 15.2.791 16 1.778 16h12.444C15.2 16 16 15.2 16 14.222V8h-1.778v6.222ZM9.778 0v1.778h3.19l-8.737 8.738 1.253 1.253 8.738-8.738v3.191H16V0H9.778Z"/></svg></a>';
|
|
13
|
+
const template = document.createElement('template');
|
|
14
|
+
template.innerHTML = templateHTML;
|
|
15
|
+
defineCustomElement('sinch-link', (_$anchor = new WeakMap(), _$text = new WeakMap(), _onClick = new WeakMap(), class extends HTMLElement {
|
|
16
|
+
constructor() {
|
|
17
|
+
super();
|
|
18
|
+
|
|
19
|
+
_classPrivateFieldInitSpec(this, _$anchor, {
|
|
20
|
+
writable: true,
|
|
21
|
+
value: void 0
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
_classPrivateFieldInitSpec(this, _$text, {
|
|
25
|
+
writable: true,
|
|
26
|
+
value: void 0
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
_classPrivateFieldInitSpec(this, _onClick, {
|
|
30
|
+
writable: true,
|
|
31
|
+
value: e => {
|
|
32
|
+
if (this.disabled) {
|
|
33
|
+
e.preventDefault();
|
|
34
|
+
e.stopPropagation();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const shadowRoot = this.attachShadow({
|
|
40
|
+
mode: 'production' === 'development' ? 'open' : 'closed',
|
|
41
|
+
delegatesFocus: true
|
|
42
|
+
});
|
|
43
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
44
|
+
|
|
45
|
+
_classPrivateFieldSet(this, _$anchor, shadowRoot.querySelector('a'));
|
|
46
|
+
|
|
47
|
+
_classPrivateFieldSet(this, _$text, shadowRoot.querySelector('span'));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
connectedCallback() {
|
|
51
|
+
_classPrivateFieldGet(this, _$anchor).addEventListener('click', _classPrivateFieldGet(this, _onClick));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
disconnectedCallback() {
|
|
55
|
+
_classPrivateFieldGet(this, _$anchor).removeEventListener('click', _classPrivateFieldGet(this, _onClick));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
get text() {
|
|
59
|
+
return getAttribute(this, 'text', '');
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
set text(value) {
|
|
63
|
+
updateAttribute(this, 'text', value);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
get href() {
|
|
67
|
+
return getAttribute(this, 'href', '');
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
set href(value) {
|
|
71
|
+
updateAttribute(this, 'href', value);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
set disabled(isDisabled) {
|
|
75
|
+
updateBooleanAttribute(this, 'disabled', isDisabled);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
get disabled() {
|
|
79
|
+
return getBooleanAttribute(this, 'disabled');
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
set external(isExternal) {
|
|
83
|
+
updateBooleanAttribute(this, 'external', isExternal);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
get external() {
|
|
87
|
+
return getBooleanAttribute(this, 'external');
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
static get observedAttributes() {
|
|
91
|
+
return ['text', 'href'];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
attributeChangedCallback(name, _, newVal) {
|
|
95
|
+
switch (name) {
|
|
96
|
+
case 'text':
|
|
97
|
+
{
|
|
98
|
+
_classPrivateFieldGet(this, _$text).textContent = newVal;
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
case 'href':
|
|
103
|
+
{
|
|
104
|
+
updateAttribute(_classPrivateFieldGet(this, _$anchor), 'href', newVal);
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
focus() {
|
|
111
|
+
_classPrivateFieldGet(this, _$anchor).focus();
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
blur() {
|
|
115
|
+
_classPrivateFieldGet(this, _$anchor).blur();
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
}));
|