@nectary/components 0.37.0 → 0.38.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/alert/index.js +1 -1
- package/file-drop/index.d.ts +13 -0
- package/file-drop/index.js +320 -0
- package/file-drop/types.d.ts +50 -0
- package/file-drop/types.js +1 -0
- package/file-drop/utils.d.ts +2 -0
- package/file-drop/utils.js +37 -0
- package/file-picker/index.d.ts +12 -0
- package/file-picker/index.js +170 -0
- package/file-picker/types.d.ts +32 -0
- package/file-picker/types.js +1 -0
- package/file-picker/utils.d.ts +1 -0
- package/file-picker/utils.js +9 -0
- package/file-status/index.d.ts +17 -0
- package/file-status/index.js +100 -0
- package/file-status/types.d.ts +18 -0
- package/file-status/types.js +1 -0
- package/file-status/utils.d.ts +5 -0
- package/file-status/utils.js +6 -0
- package/icons-branded/easytouse/index.d.ts +11 -0
- package/icons-branded/easytouse/index.js +4 -0
- package/inline-alert/index.js +1 -1
- package/inline-alert/types.d.ts +2 -2
- package/package.json +1 -1
- package/progress/index.d.ts +17 -0
- package/progress/index.js +87 -0
- package/progress/types.d.ts +12 -0
- package/progress/types.js +1 -0
- package/spinner/index.js +1 -1
- package/text/index.js +9 -1
- package/text/types.d.ts +3 -0
- package/title/index.js +10 -2
- package/title/types.d.ts +3 -0
- package/utils.d.ts +1 -0
- package/utils.js +18 -1
package/alert/index.js
CHANGED
|
@@ -12,7 +12,7 @@ import '../icons/report';
|
|
|
12
12
|
import '../icons/info';
|
|
13
13
|
import '../text';
|
|
14
14
|
import { defineCustomElement, getAttribute, getLiteralAttribute, updateAttribute, updateLiteralAttribute, NectaryElement } from '../utils';
|
|
15
|
-
const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:row;gap:8px;align-items:center;padding:
|
|
15
|
+
const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:row;gap:8px;align-items:center;padding:8px 16px;box-sizing:border-box;width:100%;min-height:48px}#text{color:var(--sinch-color-stormy-500);flex:1;min-width:0}#icon-error,#icon-info,#icon-warn{display:none}:host([type=warn]) #wrapper{background-color:var(--sinch-color-warning-200)}:host([type=error]) #wrapper{background-color:var(--sinch-color-error-200)}:host([type=info]) #wrapper{background-color:var(--sinch-color-informative-200)}:host([type=warn]) #icon-warn{display:block;--sinch-color-icon:var(--sinch-color-warning-500)}:host([type=error]) #icon-error{display:block;--sinch-color-icon:var(--sinch-color-error-500)}:host([type=info]) #icon-info{display:block;--sinch-color-icon:var(--sinch-color-informative-500)}</style><div id="wrapper"><sinch-icon-info id="icon-info"></sinch-icon-info><sinch-icon-report-problem id="icon-warn"></sinch-icon-report-problem><sinch-icon-report id="icon-error"></sinch-icon-report><sinch-text id="text" type="m"></sinch-text><slot name="action"></slot><slot name="close"></slot></div>';
|
|
16
16
|
import { assertType, typeValues } from './utils';
|
|
17
17
|
const template = document.createElement('template');
|
|
18
18
|
template.innerHTML = templateHTML;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import '../text';
|
|
2
|
+
import '../file-picker';
|
|
3
|
+
import type { TSinchFileDropElement, TSinchFileDropReact } from './types';
|
|
4
|
+
declare global {
|
|
5
|
+
namespace JSX {
|
|
6
|
+
interface IntrinsicElements {
|
|
7
|
+
'sinch-file-drop': TSinchFileDropReact;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
interface HTMLElementTagNameMap {
|
|
11
|
+
'sinch-file-drop': TSinchFileDropElement;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
|
+
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
|
+
|
|
4
|
+
var _$filePicker, _$dropArea, _$placeholder, _setDragEffect, _onDragEnter, _onDragLeave, _onDragOver, _onDrop, _onFilePickerChange, _onFilePickerInvalid, _onChangeReactHandler, _onInvalidReactHandler, _dispatchChangeEvent, _dispatchInvalidEvent;
|
|
5
|
+
|
|
6
|
+
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
|
7
|
+
|
|
8
|
+
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
9
|
+
|
|
10
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
11
|
+
|
|
12
|
+
function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
|
|
13
|
+
|
|
14
|
+
import '../text';
|
|
15
|
+
import '../file-picker';
|
|
16
|
+
import { defineCustomElement, getAttribute, getBooleanAttribute, getIntegerAttribute, getReactEventHandler, isAttrTrue, NectaryElement, setClass, updateAttribute, updateBooleanAttribute } from '../utils';
|
|
17
|
+
const templateHTML = '<style>:host{display:block}#wrapper{position:relative;display:flex;flex-direction:row;flex-wrap:wrap;justify-content:center;align-content:center;gap:8px;height:148px;min-width:148px;box-sizing:border-box;padding:16px;border-radius:var(--sinch-shape-radius-m);background-color:var(--sinch-color-background-grey)}#wrapper.drop.valid{background-color:var(--sinch-color-background-blue)}#wrapper::after{content:"";position:absolute;top:0;left:0;right:0;bottom:0;border:1px dashed var(--sinch-color-stormy-100);border-radius:var(--sinch-shape-radius-m);pointer-events:none}#placeholder{align-self:center;text-align:center}:host([invalid]) #wrapper::after{border-color:var(--sinch-color-text-invalid);border-width:1px}#wrapper.drop::after{pointer-events:all}#wrapper.drop.valid::after{border-color:var(--sinch-color-aqua-400);border-width:2px}#wrapper.drop #placeholder{color:var(--sinch-color-text-muted)}:host([disabled]) #wrapper #placeholder{color:var(--sinch-color-stormy-100)}:host([disabled]) #wrapper{background-color:var(--sinch-color-snow-100)}:host([disabled]) #wrapper::after{border-color:var(--sinch-color-stormy-100);border-width:1px}</style><div id="wrapper"><sinch-text id="placeholder" type="m" aria-hidden="true"></sinch-text><sinch-file-picker id="file-picker"><slot></slot></sinch-file-picker></div>';
|
|
18
|
+
import { areFilesAccepted, doFilesSatisfySize } from './utils';
|
|
19
|
+
const template = document.createElement('template');
|
|
20
|
+
template.innerHTML = templateHTML;
|
|
21
|
+
defineCustomElement('sinch-file-drop', (_$filePicker = new WeakMap(), _$dropArea = new WeakMap(), _$placeholder = new WeakMap(), _setDragEffect = new WeakSet(), _onDragEnter = new WeakMap(), _onDragLeave = new WeakMap(), _onDragOver = new WeakMap(), _onDrop = new WeakMap(), _onFilePickerChange = new WeakMap(), _onFilePickerInvalid = new WeakMap(), _onChangeReactHandler = new WeakMap(), _onInvalidReactHandler = new WeakMap(), _dispatchChangeEvent = new WeakSet(), _dispatchInvalidEvent = new WeakSet(), class extends NectaryElement {
|
|
22
|
+
constructor() {
|
|
23
|
+
super();
|
|
24
|
+
|
|
25
|
+
_classPrivateMethodInitSpec(this, _dispatchInvalidEvent);
|
|
26
|
+
|
|
27
|
+
_classPrivateMethodInitSpec(this, _dispatchChangeEvent);
|
|
28
|
+
|
|
29
|
+
_classPrivateMethodInitSpec(this, _setDragEffect);
|
|
30
|
+
|
|
31
|
+
_classPrivateFieldInitSpec(this, _$filePicker, {
|
|
32
|
+
writable: true,
|
|
33
|
+
value: void 0
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
_classPrivateFieldInitSpec(this, _$dropArea, {
|
|
37
|
+
writable: true,
|
|
38
|
+
value: void 0
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
_classPrivateFieldInitSpec(this, _$placeholder, {
|
|
42
|
+
writable: true,
|
|
43
|
+
value: void 0
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
_classPrivateFieldInitSpec(this, _onDragEnter, {
|
|
47
|
+
writable: true,
|
|
48
|
+
value: e => {
|
|
49
|
+
e.stopPropagation();
|
|
50
|
+
e.preventDefault();
|
|
51
|
+
const hasTypes = e.dataTransfer?.types?.includes('Files') === true;
|
|
52
|
+
const hasItems = e.dataTransfer?.items != null && e.dataTransfer.items.length > 0;
|
|
53
|
+
|
|
54
|
+
_classPrivateMethodGet(this, _setDragEffect, _setDragEffect2).call(this, true, hasTypes || hasItems);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
_classPrivateFieldInitSpec(this, _onDragLeave, {
|
|
59
|
+
writable: true,
|
|
60
|
+
value: e => {
|
|
61
|
+
e.stopPropagation();
|
|
62
|
+
e.preventDefault();
|
|
63
|
+
|
|
64
|
+
_classPrivateMethodGet(this, _setDragEffect, _setDragEffect2).call(this, false);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
_classPrivateFieldInitSpec(this, _onDragOver, {
|
|
69
|
+
writable: true,
|
|
70
|
+
value: e => {
|
|
71
|
+
e.stopPropagation();
|
|
72
|
+
e.preventDefault();
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
_classPrivateFieldInitSpec(this, _onDrop, {
|
|
77
|
+
writable: true,
|
|
78
|
+
value: e => {
|
|
79
|
+
e.stopPropagation();
|
|
80
|
+
e.preventDefault();
|
|
81
|
+
|
|
82
|
+
_classPrivateMethodGet(this, _setDragEffect, _setDragEffect2).call(this, false);
|
|
83
|
+
|
|
84
|
+
if (this.disabled) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const dt = e.dataTransfer;
|
|
89
|
+
|
|
90
|
+
if (dt === null) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (dt.files.length === 0) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (!this.multiple && dt.files.length > 1) {
|
|
99
|
+
_classPrivateMethodGet(this, _dispatchInvalidEvent, _dispatchInvalidEvent2).call(this, 'multiple');
|
|
100
|
+
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const files = Array.from(dt.files);
|
|
105
|
+
|
|
106
|
+
if (!areFilesAccepted(files, this.accept)) {
|
|
107
|
+
_classPrivateMethodGet(this, _dispatchInvalidEvent, _dispatchInvalidEvent2).call(this, 'accept');
|
|
108
|
+
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (!doFilesSatisfySize(files, this.size)) {
|
|
113
|
+
_classPrivateMethodGet(this, _dispatchInvalidEvent, _dispatchInvalidEvent2).call(this, 'size');
|
|
114
|
+
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
_classPrivateMethodGet(this, _dispatchChangeEvent, _dispatchChangeEvent2).call(this, files);
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
_classPrivateFieldInitSpec(this, _onFilePickerChange, {
|
|
123
|
+
writable: true,
|
|
124
|
+
value: e => {
|
|
125
|
+
_classPrivateMethodGet(this, _dispatchChangeEvent, _dispatchChangeEvent2).call(this, e.detail);
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
_classPrivateFieldInitSpec(this, _onFilePickerInvalid, {
|
|
130
|
+
writable: true,
|
|
131
|
+
value: e => {
|
|
132
|
+
_classPrivateMethodGet(this, _dispatchInvalidEvent, _dispatchInvalidEvent2).call(this, e.detail);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
_classPrivateFieldInitSpec(this, _onChangeReactHandler, {
|
|
137
|
+
writable: true,
|
|
138
|
+
value: e => {
|
|
139
|
+
getReactEventHandler(this, 'on-change')?.(e);
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
_classPrivateFieldInitSpec(this, _onInvalidReactHandler, {
|
|
144
|
+
writable: true,
|
|
145
|
+
value: e => {
|
|
146
|
+
getReactEventHandler(this, 'on-invalid')?.(e);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
const shadowRoot = this.attachShadow();
|
|
151
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
152
|
+
|
|
153
|
+
_classPrivateFieldSet(this, _$dropArea, shadowRoot.querySelector('#wrapper'));
|
|
154
|
+
|
|
155
|
+
_classPrivateFieldSet(this, _$placeholder, shadowRoot.querySelector('#placeholder'));
|
|
156
|
+
|
|
157
|
+
_classPrivateFieldSet(this, _$filePicker, shadowRoot.querySelector('#file-picker'));
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
connectedCallback() {
|
|
161
|
+
this.addEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
|
|
162
|
+
this.addEventListener('-invalid', _classPrivateFieldGet(this, _onInvalidReactHandler));
|
|
163
|
+
this.addEventListener('dragenter', _classPrivateFieldGet(this, _onDragEnter));
|
|
164
|
+
this.addEventListener('dragleave', _classPrivateFieldGet(this, _onDragLeave));
|
|
165
|
+
this.addEventListener('dragover', _classPrivateFieldGet(this, _onDragOver));
|
|
166
|
+
this.addEventListener('drop', _classPrivateFieldGet(this, _onDrop));
|
|
167
|
+
|
|
168
|
+
_classPrivateFieldGet(this, _$filePicker).addEventListener('-change', _classPrivateFieldGet(this, _onFilePickerChange));
|
|
169
|
+
|
|
170
|
+
_classPrivateFieldGet(this, _$filePicker).addEventListener('-invalid', _classPrivateFieldGet(this, _onFilePickerInvalid));
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
disconnectedCallback() {
|
|
174
|
+
this.removeEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
|
|
175
|
+
this.removeEventListener('-invalid', _classPrivateFieldGet(this, _onInvalidReactHandler));
|
|
176
|
+
this.removeEventListener('dragenter', _classPrivateFieldGet(this, _onDragEnter));
|
|
177
|
+
this.removeEventListener('dragleave', _classPrivateFieldGet(this, _onDragLeave));
|
|
178
|
+
this.removeEventListener('dragover', _classPrivateFieldGet(this, _onDragOver));
|
|
179
|
+
this.removeEventListener('drop', _classPrivateFieldGet(this, _onDrop));
|
|
180
|
+
|
|
181
|
+
_classPrivateFieldGet(this, _$filePicker).removeEventListener('-change', _classPrivateFieldGet(this, _onFilePickerChange));
|
|
182
|
+
|
|
183
|
+
_classPrivateFieldGet(this, _$filePicker).removeEventListener('-invalid', _classPrivateFieldGet(this, _onFilePickerInvalid));
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
static get observedAttributes() {
|
|
187
|
+
return ['accept', 'multiple', 'placeholder', 'disabled', 'invalid', 'size'];
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
attributeChangedCallback(name, oldVal, newVal) {
|
|
191
|
+
if (newVal === oldVal) {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
switch (name) {
|
|
196
|
+
case 'multiple':
|
|
197
|
+
{
|
|
198
|
+
updateAttribute(_classPrivateFieldGet(this, _$filePicker), 'multiple', newVal);
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
case 'accept':
|
|
203
|
+
{
|
|
204
|
+
updateAttribute(_classPrivateFieldGet(this, _$filePicker), 'accept', newVal);
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
case 'placeholder':
|
|
209
|
+
{
|
|
210
|
+
_classPrivateFieldGet(this, _$placeholder).textContent = newVal;
|
|
211
|
+
break;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
case 'disabled':
|
|
215
|
+
{
|
|
216
|
+
updateBooleanAttribute(this, 'disabled', isAttrTrue(newVal));
|
|
217
|
+
|
|
218
|
+
_classPrivateMethodGet(this, _setDragEffect, _setDragEffect2).call(this, false);
|
|
219
|
+
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
case 'invalid':
|
|
224
|
+
{
|
|
225
|
+
updateBooleanAttribute(this, 'invalid', isAttrTrue(newVal));
|
|
226
|
+
break;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
case 'size':
|
|
230
|
+
{
|
|
231
|
+
updateAttribute(_classPrivateFieldGet(this, _$filePicker), 'size', newVal);
|
|
232
|
+
break;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
set multiple(isMultiple) {
|
|
238
|
+
updateBooleanAttribute(this, 'multiple', isMultiple);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
get multiple() {
|
|
242
|
+
return getBooleanAttribute(this, 'multiple');
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
set accept(value) {
|
|
246
|
+
updateAttribute(this, 'accept', value);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
get accept() {
|
|
250
|
+
return getAttribute(this, 'accept', null);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
get size() {
|
|
254
|
+
return getIntegerAttribute(this, 'size', null);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
set size(value) {
|
|
258
|
+
updateAttribute(this, 'size', value);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
set text(value) {
|
|
262
|
+
updateAttribute(this, 'text', value);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
get text() {
|
|
266
|
+
return getAttribute(this, 'text', '');
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
set placeholder(value) {
|
|
270
|
+
updateAttribute(this, 'placeholder', value);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
get placeholder() {
|
|
274
|
+
return getAttribute(this, 'placeholder', '');
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
set disabled(isDisabled) {
|
|
278
|
+
updateBooleanAttribute(this, 'disabled', isDisabled);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
get disabled() {
|
|
282
|
+
return getBooleanAttribute(this, 'disabled');
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
set invalid(isInvalid) {
|
|
286
|
+
updateBooleanAttribute(this, 'invalid', isInvalid);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
get invalid() {
|
|
290
|
+
return getBooleanAttribute(this, 'invalid');
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
}));
|
|
294
|
+
|
|
295
|
+
function _setDragEffect2(shouldEnable) {
|
|
296
|
+
let isValid = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
297
|
+
const isElementEnabled = !this.disabled;
|
|
298
|
+
|
|
299
|
+
if (shouldEnable) {
|
|
300
|
+
if (isElementEnabled) {
|
|
301
|
+
setClass(_classPrivateFieldGet(this, _$dropArea), 'drop', true);
|
|
302
|
+
setClass(_classPrivateFieldGet(this, _$dropArea), 'valid', isValid);
|
|
303
|
+
}
|
|
304
|
+
} else {
|
|
305
|
+
setClass(_classPrivateFieldGet(this, _$dropArea), 'drop', false);
|
|
306
|
+
setClass(_classPrivateFieldGet(this, _$dropArea), 'valid', false);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
function _dispatchChangeEvent2(files) {
|
|
311
|
+
this.dispatchEvent(new CustomEvent('-change', {
|
|
312
|
+
detail: files
|
|
313
|
+
}));
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
function _dispatchInvalidEvent2(type) {
|
|
317
|
+
this.dispatchEvent(new CustomEvent('-invalid', {
|
|
318
|
+
detail: type
|
|
319
|
+
}));
|
|
320
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { TSinchElementReact } from '../types';
|
|
2
|
+
export declare type TSinchFileDropInvalidType = 'accept' | 'multiple' | 'size';
|
|
3
|
+
export declare type TSinchFileDropElement = HTMLElement & {
|
|
4
|
+
/** Allows to choose multiple files */
|
|
5
|
+
multiple: boolean;
|
|
6
|
+
/** [A unique file type specifier](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#unique_file_type_specifiers) */
|
|
7
|
+
accept: string | null;
|
|
8
|
+
/** Max file size in bytes */
|
|
9
|
+
size: number | null;
|
|
10
|
+
/** Disabled state */
|
|
11
|
+
disabled: boolean;
|
|
12
|
+
/** Invalid state */
|
|
13
|
+
invalid: boolean;
|
|
14
|
+
/** Placeholder */
|
|
15
|
+
placeholder: string;
|
|
16
|
+
/** Change value event */
|
|
17
|
+
addEventListener(type: '-change', listener: (e: CustomEvent<File[]>) => void): void;
|
|
18
|
+
/** Invalid event */
|
|
19
|
+
addEventListener(type: '-invalid', listener: (e: CustomEvent<TSinchFileDropInvalidType>) => void): void;
|
|
20
|
+
/** Allows to choose multiple files */
|
|
21
|
+
setAttribute(name: 'multiple', value: ''): void;
|
|
22
|
+
/** [A unique file type specifier](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#unique_file_type_specifiers) */
|
|
23
|
+
setAttribute(name: 'accept', value: string): void;
|
|
24
|
+
/** Max file size in bytes */
|
|
25
|
+
setAttribute(name: 'size', value: string): void;
|
|
26
|
+
/** Placeholder */
|
|
27
|
+
setAttribute(name: 'placeholder', value: string): void;
|
|
28
|
+
/** Invalid state */
|
|
29
|
+
setAttribute(name: 'invalid', value: ''): void;
|
|
30
|
+
/** Disabled state */
|
|
31
|
+
setAttribute(name: 'disabled', value: ''): void;
|
|
32
|
+
};
|
|
33
|
+
export declare type TSinchFileDropReact = TSinchElementReact<TSinchFileDropElement> & {
|
|
34
|
+
/** Allows to choose multiple files */
|
|
35
|
+
multiple?: boolean;
|
|
36
|
+
/** [A unique file type specifier](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#unique_file_type_specifiers) */
|
|
37
|
+
accept?: string;
|
|
38
|
+
/** Max file size in bytes */
|
|
39
|
+
size?: number;
|
|
40
|
+
/** Disabled state */
|
|
41
|
+
disabled?: boolean;
|
|
42
|
+
/** Invalid state */
|
|
43
|
+
invalid?: boolean;
|
|
44
|
+
/** Placeholder */
|
|
45
|
+
placeholder: string;
|
|
46
|
+
/** Change value handler */
|
|
47
|
+
'on-change'?: (e: CustomEvent<File[]>) => void;
|
|
48
|
+
/** Invalid handler */
|
|
49
|
+
'on-invalid'?: (e: CustomEvent<TSinchFileDropInvalidType>) => void;
|
|
50
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export const areFilesAccepted = (files, accept) => {
|
|
2
|
+
if (accept === null) {
|
|
3
|
+
return true;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
const acceptValues = accept.split(/\s*,\s*/);
|
|
7
|
+
return files.every(file => {
|
|
8
|
+
return acceptValues.some(acceptValue => {
|
|
9
|
+
if (acceptValue.startsWith('.')) {
|
|
10
|
+
return file.name.endsWith(acceptValue);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (acceptValue === 'image/*') {
|
|
14
|
+
return file.type.startsWith('image/');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (acceptValue === 'video/*') {
|
|
18
|
+
return file.type.startsWith('video/');
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (acceptValue === 'audio/*') {
|
|
22
|
+
return file.type.startsWith('audio/');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return acceptValue === file.type;
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
export const doFilesSatisfySize = (files, size) => {
|
|
30
|
+
if (size === null || size <= 0) {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return files.every(file => {
|
|
35
|
+
return file.size <= size;
|
|
36
|
+
});
|
|
37
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import '../dropdown';
|
|
2
|
+
import type { TSinchFilePickerElement, TSinchFilePickerReact } from './types';
|
|
3
|
+
declare global {
|
|
4
|
+
namespace JSX {
|
|
5
|
+
interface IntrinsicElements {
|
|
6
|
+
'sinch-file-picker': TSinchFilePickerReact;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
interface HTMLElementTagNameMap {
|
|
10
|
+
'sinch-file-picker': TSinchFilePickerElement;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
|
+
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
|
+
|
|
4
|
+
var _$input, _$targetSlot, _$target, _onTargetSlotChange, _onTargetClick, _onInputChange, _onChangeReactHandler, _onInvalidReactHandler;
|
|
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 '../dropdown';
|
|
11
|
+
import { defineCustomElement, getAttribute, getBooleanAttribute, getFirstSlotElement, getIntegerAttribute, getReactEventHandler, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute } from '../utils';
|
|
12
|
+
const templateHTML = '<style>:host{display:inline-block}::slotted(*){display:block}</style><slot></slot>';
|
|
13
|
+
import { doFilesSatisfySize } from './utils';
|
|
14
|
+
const template = document.createElement('template');
|
|
15
|
+
template.innerHTML = templateHTML;
|
|
16
|
+
defineCustomElement('sinch-file-picker', (_$input = new WeakMap(), _$targetSlot = new WeakMap(), _$target = new WeakMap(), _onTargetSlotChange = new WeakMap(), _onTargetClick = new WeakMap(), _onInputChange = new WeakMap(), _onChangeReactHandler = new WeakMap(), _onInvalidReactHandler = new WeakMap(), class extends NectaryElement {
|
|
17
|
+
constructor() {
|
|
18
|
+
super();
|
|
19
|
+
|
|
20
|
+
_classPrivateFieldInitSpec(this, _$input, {
|
|
21
|
+
writable: true,
|
|
22
|
+
value: void 0
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
_classPrivateFieldInitSpec(this, _$targetSlot, {
|
|
26
|
+
writable: true,
|
|
27
|
+
value: void 0
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
_classPrivateFieldInitSpec(this, _$target, {
|
|
31
|
+
writable: true,
|
|
32
|
+
value: null
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
_classPrivateFieldInitSpec(this, _onTargetSlotChange, {
|
|
36
|
+
writable: true,
|
|
37
|
+
value: () => {
|
|
38
|
+
_classPrivateFieldGet(this, _$target)?.removeEventListener('-click', _classPrivateFieldGet(this, _onTargetClick));
|
|
39
|
+
|
|
40
|
+
_classPrivateFieldSet(this, _$target, getFirstSlotElement(_classPrivateFieldGet(this, _$targetSlot)));
|
|
41
|
+
|
|
42
|
+
_classPrivateFieldGet(this, _$target)?.addEventListener('-click', _classPrivateFieldGet(this, _onTargetClick));
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
_classPrivateFieldInitSpec(this, _onTargetClick, {
|
|
47
|
+
writable: true,
|
|
48
|
+
value: () => {
|
|
49
|
+
_classPrivateFieldGet(this, _$input).click();
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
_classPrivateFieldInitSpec(this, _onInputChange, {
|
|
54
|
+
writable: true,
|
|
55
|
+
value: () => {
|
|
56
|
+
if (_classPrivateFieldGet(this, _$input).files === null) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const files = Array.from(_classPrivateFieldGet(this, _$input).files);
|
|
61
|
+
|
|
62
|
+
if (!doFilesSatisfySize(files, this.size)) {
|
|
63
|
+
this.dispatchEvent(new CustomEvent('-invalid', {
|
|
64
|
+
detail: 'size'
|
|
65
|
+
}));
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
this.dispatchEvent(new CustomEvent('-change', {
|
|
70
|
+
detail: files
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
_classPrivateFieldInitSpec(this, _onChangeReactHandler, {
|
|
76
|
+
writable: true,
|
|
77
|
+
value: e => {
|
|
78
|
+
getReactEventHandler(this, 'on-change')?.(e);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
_classPrivateFieldInitSpec(this, _onInvalidReactHandler, {
|
|
83
|
+
writable: true,
|
|
84
|
+
value: e => {
|
|
85
|
+
getReactEventHandler(this, 'on-invalid')?.(e);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
const shadowRoot = this.attachShadow();
|
|
90
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
91
|
+
|
|
92
|
+
_classPrivateFieldSet(this, _$input, document.createElement('input'));
|
|
93
|
+
|
|
94
|
+
_classPrivateFieldGet(this, _$input).type = 'file';
|
|
95
|
+
|
|
96
|
+
_classPrivateFieldSet(this, _$targetSlot, shadowRoot.querySelector('slot'));
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
connectedCallback() {
|
|
100
|
+
_classPrivateFieldGet(this, _$targetSlot).addEventListener('slotchange', _classPrivateFieldGet(this, _onTargetSlotChange));
|
|
101
|
+
|
|
102
|
+
_classPrivateFieldGet(this, _$input).addEventListener('change', _classPrivateFieldGet(this, _onInputChange));
|
|
103
|
+
|
|
104
|
+
this.addEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
|
|
105
|
+
this.addEventListener('-invalid', _classPrivateFieldGet(this, _onInvalidReactHandler));
|
|
106
|
+
|
|
107
|
+
_classPrivateFieldGet(this, _onTargetSlotChange).call(this);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
disconnectedCallback() {
|
|
111
|
+
_classPrivateFieldGet(this, _$targetSlot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onTargetSlotChange));
|
|
112
|
+
|
|
113
|
+
_classPrivateFieldGet(this, _$input).removeEventListener('change', _classPrivateFieldGet(this, _onInputChange));
|
|
114
|
+
|
|
115
|
+
this.removeEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
|
|
116
|
+
this.removeEventListener('-invalid', _classPrivateFieldGet(this, _onInvalidReactHandler));
|
|
117
|
+
_classPrivateFieldGet(this, _$target)?.removeEventListener('-click', _classPrivateFieldGet(this, _onTargetClick));
|
|
118
|
+
|
|
119
|
+
_classPrivateFieldSet(this, _$target, null);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
static get observedAttributes() {
|
|
123
|
+
return ['accept', 'multiple'];
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
set multiple(isMultiple) {
|
|
127
|
+
updateBooleanAttribute(this, 'multiple', isMultiple);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
get multiple() {
|
|
131
|
+
return getBooleanAttribute(this, 'multiple');
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
set accept(value) {
|
|
135
|
+
updateAttribute(this, 'accept', value);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
get accept() {
|
|
139
|
+
return getAttribute(this, 'accept', null);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
get size() {
|
|
143
|
+
return getIntegerAttribute(this, 'size', null);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
set size(value) {
|
|
147
|
+
updateAttribute(this, 'size', value);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
attributeChangedCallback(name, oldVal, newVal) {
|
|
151
|
+
if (newVal === oldVal) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
switch (name) {
|
|
156
|
+
case 'multiple':
|
|
157
|
+
{
|
|
158
|
+
updateBooleanAttribute(_classPrivateFieldGet(this, _$input), 'multiple', isAttrTrue(newVal));
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
case 'accept':
|
|
163
|
+
{
|
|
164
|
+
updateAttribute(_classPrivateFieldGet(this, _$input), 'accept', newVal);
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
}));
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { TSinchElementReact } from '../types';
|
|
2
|
+
export declare type TSinchFilePickerInvalidType = 'size';
|
|
3
|
+
export declare type TSinchFilePickerElement = HTMLElement & {
|
|
4
|
+
/** Allows to choose multiple files */
|
|
5
|
+
multiple: boolean;
|
|
6
|
+
/** [A unique file type specifier](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#unique_file_type_specifiers) */
|
|
7
|
+
accept: string | null;
|
|
8
|
+
/** Max file size in bytes */
|
|
9
|
+
size: number | null;
|
|
10
|
+
/** Change value event */
|
|
11
|
+
addEventListener(type: '-change', listener: (e: CustomEvent<File[]>) => void): void;
|
|
12
|
+
/** Invalid event */
|
|
13
|
+
addEventListener(type: '-invalid', listener: (e: CustomEvent<TSinchFilePickerInvalidType>) => void): void;
|
|
14
|
+
/** Allows to choose multiple files */
|
|
15
|
+
setAttribute(name: 'multiple', value: ''): void;
|
|
16
|
+
/** [A unique file type specifier](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#unique_file_type_specifiers) */
|
|
17
|
+
setAttribute(name: 'accept', value: string): void;
|
|
18
|
+
/** Max file size in bytes */
|
|
19
|
+
setAttribute(name: 'size', value: string): void;
|
|
20
|
+
};
|
|
21
|
+
export declare type TSinchFilePickerReact = TSinchElementReact<TSinchFilePickerElement> & {
|
|
22
|
+
/** Allows to choose multiple files */
|
|
23
|
+
multiple?: boolean;
|
|
24
|
+
/** [A unique file type specifier](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#unique_file_type_specifiers) */
|
|
25
|
+
accept?: string;
|
|
26
|
+
/** Max file size in bytes */
|
|
27
|
+
size?: number;
|
|
28
|
+
/** Change value handler */
|
|
29
|
+
'on-change': (e: CustomEvent<File[]>) => void;
|
|
30
|
+
/** Invalid handler */
|
|
31
|
+
'on-invalid'?: (e: CustomEvent<TSinchFilePickerInvalidType>) => void;
|
|
32
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const doFilesSatisfySize: (files: File[], size: number | null) => boolean;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import '../spinner';
|
|
2
|
+
import '../icons/check-circle';
|
|
3
|
+
import '../icons/report';
|
|
4
|
+
import '../icons/pending-actions';
|
|
5
|
+
import '../icons/text-snippet';
|
|
6
|
+
import '../text';
|
|
7
|
+
import type { TSinchFileStatusElement, TSinchFileStatusReact } from './types';
|
|
8
|
+
declare global {
|
|
9
|
+
namespace JSX {
|
|
10
|
+
interface IntrinsicElements {
|
|
11
|
+
'sinch-file-status': TSinchFileStatusReact;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
interface HTMLElementTagNameMap {
|
|
15
|
+
'sinch-file-status': TSinchFileStatusElement;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
|
+
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
|
+
|
|
4
|
+
var _$filename, _$contentSlot, _onContentSlotChange;
|
|
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 '../spinner';
|
|
11
|
+
import '../icons/check-circle';
|
|
12
|
+
import '../icons/report';
|
|
13
|
+
import '../icons/pending-actions';
|
|
14
|
+
import '../icons/text-snippet';
|
|
15
|
+
import '../text';
|
|
16
|
+
import { defineCustomElement, getAttribute, getLiteralAttribute, updateAttribute, updateLiteralAttribute, NectaryElement, updateBooleanAttribute } from '../utils';
|
|
17
|
+
const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:row;align-items:flex-start;padding:12px 16px;box-sizing:border-box;min-height:48px;min-width:148px;background-color:var(--sinch-color-background-grey);border-radius:var(--sinch-shape-radius-m)}:host([type=error]) #wrapper{background-color:var(--sinch-color-error-200)}#content-wrapper{display:flex;flex-direction:column;gap:8px;flex:1;min-width:0;margin-left:16px;color:var(--sinch-color-stormy-500)}#icon-error,#icon-loading,#icon-pending,#icon-progress,#icon-success{display:none}#action{height:24px}#action ::slotted(*){position:relative;top:50%;transform:translateY(-50%)}:host([type=error]) #icon-error,:host([type=loading]) #icon-loading,:host([type=pending]) #icon-pending,:host([type=progress]) #icon-progress,:host([type=success]) #icon-success{display:block;--sinch-color-icon:var(--sinch-color-stormy-500)}:host([type=success]) #icon-success{--sinch-color-icon:var(--sinch-color-success-500)}:host([type=error]) #icon-error{--sinch-color-icon:var(--sinch-color-error-500)}</style><div id="wrapper"><sinch-spinner id="icon-loading" type="medium"></sinch-spinner><sinch-icon-check-circle id="icon-success"></sinch-icon-check-circle><sinch-icon-report id="icon-error"></sinch-icon-report><sinch-icon-pending-actions id="icon-pending"></sinch-icon-pending-actions><sinch-icon-text-snippet id="icon-progress"></sinch-icon-text-snippet><div id="content-wrapper"><sinch-text id="filename" type="m" ellipsis></sinch-text><slot name="content"></slot></div><div id="action"><slot name="action"></slot></div></div>';
|
|
18
|
+
import { assertType, typeValues } from './utils';
|
|
19
|
+
const template = document.createElement('template');
|
|
20
|
+
template.innerHTML = templateHTML;
|
|
21
|
+
defineCustomElement('sinch-file-status', (_$filename = new WeakMap(), _$contentSlot = new WeakMap(), _onContentSlotChange = new WeakMap(), class extends NectaryElement {
|
|
22
|
+
constructor() {
|
|
23
|
+
super();
|
|
24
|
+
|
|
25
|
+
_classPrivateFieldInitSpec(this, _$filename, {
|
|
26
|
+
writable: true,
|
|
27
|
+
value: void 0
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
_classPrivateFieldInitSpec(this, _$contentSlot, {
|
|
31
|
+
writable: true,
|
|
32
|
+
value: void 0
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
_classPrivateFieldInitSpec(this, _onContentSlotChange, {
|
|
36
|
+
writable: true,
|
|
37
|
+
value: () => {
|
|
38
|
+
updateBooleanAttribute(_classPrivateFieldGet(this, _$filename), 'emphasized', _classPrivateFieldGet(this, _$contentSlot).assignedElements().length > 0);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const shadowRoot = this.attachShadow();
|
|
43
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
44
|
+
|
|
45
|
+
_classPrivateFieldSet(this, _$filename, shadowRoot.querySelector('#filename'));
|
|
46
|
+
|
|
47
|
+
_classPrivateFieldSet(this, _$contentSlot, shadowRoot.querySelector('slot[name="content"]'));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
connectedCallback() {
|
|
51
|
+
_classPrivateFieldGet(this, _$contentSlot).addEventListener('slotchange', _classPrivateFieldGet(this, _onContentSlotChange));
|
|
52
|
+
|
|
53
|
+
_classPrivateFieldGet(this, _onContentSlotChange).call(this);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
disconnectedCallback() {
|
|
57
|
+
_classPrivateFieldGet(this, _$contentSlot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onContentSlotChange));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
get type() {
|
|
61
|
+
return getLiteralAttribute(this, typeValues, 'type');
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
set type(value) {
|
|
65
|
+
updateLiteralAttribute(this, typeValues, 'type', value);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
get filename() {
|
|
69
|
+
return getAttribute(this, 'filename', '');
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
set filename(value) {
|
|
73
|
+
updateAttribute(this, 'filename', value);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
static get observedAttributes() {
|
|
77
|
+
return ['filename', 'type'];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
attributeChangedCallback(name, oldVal, newVal) {
|
|
81
|
+
if (oldVal === newVal) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
switch (name) {
|
|
86
|
+
case 'type':
|
|
87
|
+
{
|
|
88
|
+
assertType(newVal);
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
case 'filename':
|
|
93
|
+
{
|
|
94
|
+
_classPrivateFieldGet(this, _$filename).textContent = newVal;
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
}));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { TSinchElementReact } from '../types';
|
|
2
|
+
export declare type TSinchFileStatusType = 'pending' | 'loading' | 'progress' | 'success' | 'error';
|
|
3
|
+
export declare type TSinchFileStatusElement = HTMLElement & {
|
|
4
|
+
/** File status type */
|
|
5
|
+
type: TSinchFileStatusType;
|
|
6
|
+
/** File name */
|
|
7
|
+
filename: string;
|
|
8
|
+
/** File status type */
|
|
9
|
+
setAttribute(name: 'type', value: TSinchFileStatusType): void;
|
|
10
|
+
/** File name */
|
|
11
|
+
setAttribute(name: 'filename', value: string): void;
|
|
12
|
+
};
|
|
13
|
+
export declare type TSinchFileStatusReact = TSinchElementReact<TSinchFileStatusElement> & {
|
|
14
|
+
/** File status type */
|
|
15
|
+
type: TSinchFileStatusType;
|
|
16
|
+
/** File name */
|
|
17
|
+
filename: string;
|
|
18
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { TSinchFileStatusType } from './types';
|
|
2
|
+
export declare const typeValues: readonly TSinchFileStatusType[];
|
|
3
|
+
declare type TAssertType = (value: string | null) => asserts value is TSinchFileStatusType;
|
|
4
|
+
export declare const assertType: TAssertType;
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { TSinchIconBrandedElement, TSinchIconBrandedReact } from '../types';
|
|
2
|
+
declare global {
|
|
3
|
+
namespace JSX {
|
|
4
|
+
interface IntrinsicElements {
|
|
5
|
+
'sinch-icon-branded-easytouse': TSinchIconBrandedReact;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
interface HTMLElementTagNameMap {
|
|
9
|
+
'sinch-icon-branded-easytouse': TSinchIconBrandedElement;
|
|
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 48 48" aria-hidden="true"><path d="M25.99 18.104c.517-.276 1.178-.112 1.477.366l5.41 8.66c.299.479.122 1.09-.396 1.366-.517.276-1.18.113-1.478-.366l-5.41-8.66c-.299-.478-.121-1.09.396-1.366Zm0 7.396c-.3-.478-.961-.642-1.479-.366-.517.276-.695.888-.396 1.366l2.705 4.33c.299.478.96.642 1.478.366s.695-.888.396-1.366L25.99 25.5Zm4.176 7.383c-.299-.479-.96-.643-1.478-.366-.517.276-.695.887-.396 1.366l1.082 1.732c.299.478.96.642 1.478.366.517-.276.695-.888.396-1.366l-1.082-1.732ZM19.04 24.088c-.299-.478-.96-.642-1.478-.366-.518.277-.695.888-.396 1.366l3.246 5.197c.299.478.96.642 1.478.366.517-.276.695-.888.396-1.366l-3.246-5.197Zm13.83 13.125c.3.478.122 1.09-.395 1.366-.518.276-1.18.112-1.478-.366-.299-.479-.122-1.09.396-1.366.517-.276 1.18-.113 1.478.366Zm1.234-6.119c.517-.276.695-.887.396-1.366-.299-.478-.96-.642-1.478-.366s-.695.888-.396 1.366c.299.479.96.642 1.478.366Z"/><path class="accent" d="M15.405 9.527a1 1 0 0 0-1.413.914l.035 10.526a1 1 0 0 0 1.544.835l2.964-1.922 2.876 4.45L25.017 22l-2.88-4.455 2.97-1.925a1 1 0 0 0-.131-1.75l-9.571-4.343Z"/></svg>';
|
|
4
|
+
defineCustomElement('sinch-icon-branded-easytouse', createIconClass(templateHTML));
|
package/inline-alert/index.js
CHANGED
|
@@ -14,7 +14,7 @@ import '../icons/info';
|
|
|
14
14
|
import '../title';
|
|
15
15
|
import '../text';
|
|
16
16
|
import { defineCustomElement, getAttribute, getLiteralAttribute, updateAttribute, updateLiteralAttribute, NectaryElement, setClass } from '../utils';
|
|
17
|
-
const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:row;align-items:flex-start;padding:16px;border-radius:var(--sinch-shape-radius-l);background-color:var(--sinch-color-alert-info-background);box-sizing:border-box;width:100%}#body-wrapper{display:flex;flex-direction:column;align-items:flex-start;margin-left:8px;min-width:0;flex:1}#caption{color:var(--sinch-color-stormy-500)}#text{color:var(--sinch-color-stormy-500);margin-top:4px}#icon-error,#icon-info,#icon-success,#icon-warn{display:none}:host([type=success]) #wrapper{background-color:var(--sinch-color-success-200)}:host([type=warn]) #wrapper{background-color:var(--sinch-color-warning-200)}:host([type=error]) #wrapper{background-color:var(--sinch-color-error-200)}:host([type=info]) #wrapper{background-color:var(--sinch-color-informative-200)}:host([type=success]) #icon-success{display:block;--sinch-color-icon:var(--sinch-color-success-500)}:host([type=warn]) #icon-warn{display:block;--sinch-color-icon:var(--sinch-color-warning-500)}:host([type=error]) #icon-error{display:block;--sinch-color-icon:var(--sinch-color-error-500)}:host([type=info]) #icon-info{display:block;--sinch-color-icon:var(--sinch-color-informative-500)}#action{display:flex;margin-top:16px;min-width:0}#action.empty{display:none}#close{margin-left:16px}#close.empty{display:none}</style><div id="wrapper"><sinch-icon-info id="icon-info"></sinch-icon-info><sinch-icon-check-circle id="icon-success"></sinch-icon-check-circle><sinch-icon-report-problem id="icon-warn"></sinch-icon-report-problem><sinch-icon-report id="icon-error"></sinch-icon-report><div id="body-wrapper"><sinch-title id="caption" level="3" type="s"></sinch-title><sinch-text id="text" type="m"></sinch-text><div id="action"><slot name="action"></slot></div></div><div id="close"><slot name="close"></slot></div></div>';
|
|
17
|
+
const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:row;align-items:flex-start;padding:16px;border-radius:var(--sinch-shape-radius-l);background-color:var(--sinch-color-alert-info-background);box-sizing:border-box;width:100%}#body-wrapper{display:flex;flex-direction:column;align-items:flex-start;margin-left:8px;min-width:0;flex:1}#caption{color:var(--sinch-color-stormy-500);align-self:stretch}#text{color:var(--sinch-color-stormy-500);margin-top:4px;align-self:stretch}#text:empty{display:none}#icon-error,#icon-info,#icon-success,#icon-warn{display:none}:host([type=success]) #wrapper{background-color:var(--sinch-color-success-200)}:host([type=warn]) #wrapper{background-color:var(--sinch-color-warning-200)}:host([type=error]) #wrapper{background-color:var(--sinch-color-error-200)}:host([type=info]) #wrapper{background-color:var(--sinch-color-informative-200)}:host([type=success]) #icon-success{display:block;--sinch-color-icon:var(--sinch-color-success-500)}:host([type=warn]) #icon-warn{display:block;--sinch-color-icon:var(--sinch-color-warning-500)}:host([type=error]) #icon-error{display:block;--sinch-color-icon:var(--sinch-color-error-500)}:host([type=info]) #icon-info{display:block;--sinch-color-icon:var(--sinch-color-informative-500)}#action{display:flex;margin-top:16px;min-width:0}#action.empty{display:none}#close{margin-left:16px}#close.empty{display:none}</style><div id="wrapper"><sinch-icon-info id="icon-info"></sinch-icon-info><sinch-icon-check-circle id="icon-success"></sinch-icon-check-circle><sinch-icon-report-problem id="icon-warn"></sinch-icon-report-problem><sinch-icon-report id="icon-error"></sinch-icon-report><div id="body-wrapper"><sinch-title id="caption" level="3" type="s" ellipsis></sinch-title><sinch-text id="text" type="m"></sinch-text><div id="action"><slot name="action"></slot></div></div><div id="close"><slot name="close"></slot></div></div>';
|
|
18
18
|
import { assertType, typeValues } from './utils';
|
|
19
19
|
const template = document.createElement('template');
|
|
20
20
|
template.innerHTML = templateHTML;
|
package/inline-alert/types.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { TSinchElementReact } from '../types';
|
|
|
2
2
|
export declare type TSinchInlineAlertType = 'info' | 'success' | 'warn' | 'error';
|
|
3
3
|
export declare type TSinchInlineAlertElement = HTMLElement & {
|
|
4
4
|
type: TSinchInlineAlertType;
|
|
5
|
-
text: string;
|
|
5
|
+
text: string | null;
|
|
6
6
|
caption: string;
|
|
7
7
|
setAttribute(name: 'type', value: TSinchInlineAlertType): void;
|
|
8
8
|
setAttribute(name: 'text', value: string): void;
|
|
@@ -10,6 +10,6 @@ export declare type TSinchInlineAlertElement = HTMLElement & {
|
|
|
10
10
|
};
|
|
11
11
|
export declare type TSinchInlineAlertReact = TSinchElementReact<TSinchInlineAlertElement> & {
|
|
12
12
|
type: TSinchInlineAlertType;
|
|
13
|
-
text
|
|
13
|
+
text?: string;
|
|
14
14
|
caption: string;
|
|
15
15
|
};
|
package/package.json
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import '../spinner';
|
|
2
|
+
import '../icons/check-circle';
|
|
3
|
+
import '../icons/report';
|
|
4
|
+
import '../icons/pending-actions';
|
|
5
|
+
import '../icons/text-snippet';
|
|
6
|
+
import '../text';
|
|
7
|
+
import type { TSinchProgressElement, TSinchProgressReact } from './types';
|
|
8
|
+
declare global {
|
|
9
|
+
namespace JSX {
|
|
10
|
+
interface IntrinsicElements {
|
|
11
|
+
'sinch-progress': TSinchProgressReact;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
interface HTMLElementTagNameMap {
|
|
15
|
+
'sinch-progress': TSinchProgressElement;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
|
+
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
|
+
|
|
4
|
+
var _$bar, _$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 '../spinner';
|
|
11
|
+
import '../icons/check-circle';
|
|
12
|
+
import '../icons/report';
|
|
13
|
+
import '../icons/pending-actions';
|
|
14
|
+
import '../icons/text-snippet';
|
|
15
|
+
import '../text';
|
|
16
|
+
import { defineCustomElement, updateAttribute, NectaryElement, updateBooleanAttribute, getIntegerAttribute, getBooleanAttribute, attrValueToInteger } from '../utils';
|
|
17
|
+
const templateHTML = '<style>:host{display:block}#wrapper{display:flex;align-items:center;height:24px}#bar,#progress{height:8px;border-radius:4px}#progress{background-color:var(--sinch-color-tropical-100);flex:1;min-width:0}#bar{background-color:var(--sinch-color-tropical-500);width:0}#text{display:none;width:46px}:host([detailed]:not([detailed=false])) #text{display:block}</style><div id="wrapper"><sinch-text id="text" type="m"></sinch-text><div id="progress"><div id="bar"></div></div></div>';
|
|
18
|
+
const template = document.createElement('template');
|
|
19
|
+
template.innerHTML = templateHTML;
|
|
20
|
+
defineCustomElement('sinch-progress', (_$bar = new WeakMap(), _$text = new WeakMap(), class extends NectaryElement {
|
|
21
|
+
constructor() {
|
|
22
|
+
super();
|
|
23
|
+
|
|
24
|
+
_classPrivateFieldInitSpec(this, _$bar, {
|
|
25
|
+
writable: true,
|
|
26
|
+
value: void 0
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
_classPrivateFieldInitSpec(this, _$text, {
|
|
30
|
+
writable: true,
|
|
31
|
+
value: void 0
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const shadowRoot = this.attachShadow();
|
|
35
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
36
|
+
|
|
37
|
+
_classPrivateFieldSet(this, _$bar, shadowRoot.querySelector('#bar'));
|
|
38
|
+
|
|
39
|
+
_classPrivateFieldSet(this, _$text, shadowRoot.querySelector('#text'));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
connectedCallback() {
|
|
43
|
+
this.setAttribute('role', 'progressbar');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
get value() {
|
|
47
|
+
return getIntegerAttribute(this, 'value', 0);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
set value(value) {
|
|
51
|
+
updateAttribute(this, 'value', value);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
get detailed() {
|
|
55
|
+
return getBooleanAttribute(this, 'detailed');
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
set detailed(isDetailed) {
|
|
59
|
+
updateBooleanAttribute(this, 'detailed', isDetailed);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
static get observedAttributes() {
|
|
63
|
+
return ['value'];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
attributeChangedCallback(name, oldVal, newVal) {
|
|
67
|
+
if (oldVal === newVal) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
switch (name) {
|
|
72
|
+
case 'value':
|
|
73
|
+
{
|
|
74
|
+
const int = attrValueToInteger(newVal, {
|
|
75
|
+
min: 0,
|
|
76
|
+
max: 100
|
|
77
|
+
});
|
|
78
|
+
const intCss = int === null ? '0%' : `${int}%`;
|
|
79
|
+
_classPrivateFieldGet(this, _$bar).style.width = intCss;
|
|
80
|
+
_classPrivateFieldGet(this, _$text).textContent = intCss;
|
|
81
|
+
this.setAttribute('valuenow', int !== null ? String(int) : '0');
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
}));
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { TSinchElementReact } from '../types';
|
|
2
|
+
export declare type TSinchProgressElement = HTMLElement & {
|
|
3
|
+
value: number;
|
|
4
|
+
detailed: boolean;
|
|
5
|
+
setAttribute(name: 'value', value: string): void;
|
|
6
|
+
setAttribute(name: 'detailed', value: ''): void;
|
|
7
|
+
};
|
|
8
|
+
export declare type TSinchProgressReact = TSinchElementReact<TSinchProgressElement> & {
|
|
9
|
+
value: number;
|
|
10
|
+
detailed?: boolean;
|
|
11
|
+
'aria-label': string;
|
|
12
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/spinner/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineCustomElement, getLiteralAttribute, NectaryElement, updateLiteralAttribute } from '../utils';
|
|
2
|
-
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle}@keyframes spinner{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}div{animation:1.5s linear infinite spinner;animation-play-state:running;border:solid 3px var(--sinch-color-spinner-bg,#d4dadd);border-bottom-color:var(--sinch-color-spinner-fg,#0a273d);border-radius:50%;height:20px;width:20px;box-sizing:border-box;will-change:transform}:host([type=large]) div{height:
|
|
2
|
+
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle}@keyframes spinner{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}div{animation:1.5s linear infinite spinner;animation-play-state:running;border:solid 3px var(--sinch-color-spinner-bg,#d4dadd);border-bottom-color:var(--sinch-color-spinner-fg,#0a273d);border-radius:50%;height:20px;width:20px;box-sizing:border-box;will-change:transform;margin:2px}:host([type=large]) div{height:48px;width:48px;border-width:4px}:host([type=small]) div{height:14px;width:14px;border-width:2px;margin:1px}:host([static]:not([static=false])) div{animation-play-state:paused}</style><div></div>';
|
|
3
3
|
import { spinnerTypes } from './utils';
|
|
4
4
|
const template = document.createElement('template');
|
|
5
5
|
template.innerHTML = templateHTML;
|
package/text/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import '../icons/cancel';
|
|
2
2
|
import { defineCustomElement, getBooleanAttribute, updateBooleanAttribute, NectaryElement, getLiteralAttribute, updateLiteralAttribute, isAttrTrue } from '../utils';
|
|
3
|
-
const templateHTML = '<style>:host{display:block;font:var(--sinch-font-text-m)}:host([inline]:not([inline=false])){display:inline}:host([type="s"]){font:var(--sinch-font-text-s)}:host([type=xs]){font:var(--sinch-font-text-xs)}:host([type=xxs]){font:var(--sinch-font-text-xxs)}:host([emphasized]:not([emphasized=false])){font-weight:var(--sinch-font-weight-emphasized)}</style><slot></slot>';
|
|
3
|
+
const templateHTML = '<style>:host{display:block;font:var(--sinch-font-text-m)}:host([inline]:not([inline=false])){display:inline}:host([type="s"]){font:var(--sinch-font-text-s)}:host([type=xs]){font:var(--sinch-font-text-xs)}:host([type=xxs]){font:var(--sinch-font-text-xxs)}:host([emphasized]:not([emphasized=false])){font-weight:var(--sinch-font-weight-emphasized)}:host([ellipsis]:not([ellipsis=false])){overflow:hidden;text-overflow:ellipsis;white-space:nowrap}</style><slot></slot>';
|
|
4
4
|
import { assertType, typeValues } from './utils';
|
|
5
5
|
const template = document.createElement('template');
|
|
6
6
|
template.innerHTML = templateHTML;
|
|
@@ -31,6 +31,14 @@ defineCustomElement('sinch-text', class extends NectaryElement {
|
|
|
31
31
|
return getBooleanAttribute(this, 'inline');
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
set ellipsis(isEllipsis) {
|
|
35
|
+
updateBooleanAttribute(this, 'ellipsis', isEllipsis);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
get ellipsis() {
|
|
39
|
+
return getBooleanAttribute(this, 'ellipsis');
|
|
40
|
+
}
|
|
41
|
+
|
|
34
42
|
set emphasized(isEmphasized) {
|
|
35
43
|
updateBooleanAttribute(this, 'emphasized', isEmphasized);
|
|
36
44
|
}
|
package/text/types.d.ts
CHANGED
|
@@ -4,12 +4,15 @@ export declare type TSinchTextElement = HTMLElement & {
|
|
|
4
4
|
type: TSinchTextType;
|
|
5
5
|
inline: boolean;
|
|
6
6
|
emphasized: boolean;
|
|
7
|
+
ellipsis: boolean;
|
|
7
8
|
setAttribute(name: 'type', value: TSinchTextType): void;
|
|
8
9
|
setAttribute(name: 'inline', value: ''): void;
|
|
9
10
|
setAttribute(name: 'emphasized', value: ''): void;
|
|
11
|
+
setAttribute(name: 'ellipsis', value: ''): void;
|
|
10
12
|
};
|
|
11
13
|
export declare type TSinchTextReact = TSinchElementReact<TSinchTextElement> & {
|
|
12
14
|
type: TSinchTextType;
|
|
13
15
|
inline?: boolean;
|
|
14
16
|
emphasized?: boolean;
|
|
17
|
+
ellipsis?: boolean;
|
|
15
18
|
};
|
package/title/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 '../icons/cancel';
|
|
11
|
-
import { defineCustomElement, getAttribute, updateAttribute, updateLiteralAttribute, getLiteralAttribute, NectaryElement } from '../utils';
|
|
12
|
-
const templateHTML = '<style>:host{display:block}:host([type=xl])
|
|
11
|
+
import { defineCustomElement, getAttribute, updateAttribute, updateLiteralAttribute, getLiteralAttribute, NectaryElement, updateBooleanAttribute, getBooleanAttribute } from '../utils';
|
|
12
|
+
const templateHTML = '<style>:host{display:block}:host([type=xl]) #text{font:var(--sinch-font-title-xl)}:host([type="l"]) #text{font:var(--sinch-font-title-l)}:host([type="m"]) #text{font:var(--sinch-font-title-m)}:host([type="s"]) #text{font:var(--sinch-font-title-s)}:host([type=xs]) #text{font:var(--sinch-font-title-xs)}:host([ellipsis]:not([ellipsis=false])) #text{display:block;width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}</style><span id="text"></span>';
|
|
13
13
|
import { assertLevel, assertType, typeValues } from './utils';
|
|
14
14
|
const template = document.createElement('template');
|
|
15
15
|
template.innerHTML = templateHTML;
|
|
@@ -48,6 +48,14 @@ defineCustomElement('sinch-title', (_$text = new WeakMap(), class extends Nectar
|
|
|
48
48
|
return getLiteralAttribute(this, typeValues, 'type');
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
set ellipsis(isEllipsis) {
|
|
52
|
+
updateBooleanAttribute(this, 'ellipsis', isEllipsis);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
get ellipsis() {
|
|
56
|
+
return getBooleanAttribute(this, 'ellipsis');
|
|
57
|
+
}
|
|
58
|
+
|
|
51
59
|
static get observedAttributes() {
|
|
52
60
|
return ['text', 'type', 'level'];
|
|
53
61
|
}
|
package/title/types.d.ts
CHANGED
|
@@ -5,12 +5,15 @@ export declare type TSinchTitleElement = HTMLElement & {
|
|
|
5
5
|
text: string;
|
|
6
6
|
type: TSinchTitleType;
|
|
7
7
|
level: TSinchTitleLevel;
|
|
8
|
+
ellipsis: boolean;
|
|
8
9
|
setAttribute(name: 'text', value: string): void;
|
|
9
10
|
setAttribute(name: 'type', value: TSinchTitleType): void;
|
|
10
11
|
setAttribute(name: 'level', value: TSinchTitleLevel): void;
|
|
12
|
+
setAttribute(name: 'ellipsis', value: ''): void;
|
|
11
13
|
};
|
|
12
14
|
export declare type TSinchTitleReact = TSinchElementReact<TSinchTitleElement> & {
|
|
13
15
|
text: string;
|
|
14
16
|
type: TSinchTitleType;
|
|
15
17
|
level: TSinchTitleLevel;
|
|
18
|
+
ellipsis?: boolean;
|
|
16
19
|
};
|
package/utils.d.ts
CHANGED
package/utils.js
CHANGED
|
@@ -244,4 +244,21 @@ const throttle = (delayFn, cancelFn) => cb => {
|
|
|
244
244
|
};
|
|
245
245
|
};
|
|
246
246
|
|
|
247
|
-
export const throttleAnimationFrame = throttle(global.requestAnimationFrame, global.cancelAnimationFrame);
|
|
247
|
+
export const throttleAnimationFrame = throttle(global.requestAnimationFrame, global.cancelAnimationFrame);
|
|
248
|
+
export const getFirstSlotElement = root => {
|
|
249
|
+
let slot = root;
|
|
250
|
+
|
|
251
|
+
while (true) {
|
|
252
|
+
const el = slot.assignedElements()[0];
|
|
253
|
+
|
|
254
|
+
if (el == null) {
|
|
255
|
+
return null;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
if (el.tagName !== 'SLOT') {
|
|
259
|
+
return el;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
slot = el;
|
|
263
|
+
}
|
|
264
|
+
};
|