@nectary/components 0.37.0 → 0.39.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/types.d.ts +1 -0
- package/alert/index.js +1 -1
- package/card/index.d.ts +2 -0
- package/card/index.js +6 -31
- package/date-picker/index.js +42 -2
- package/date-picker/types.d.ts +25 -1
- package/dialog/index.d.ts +1 -0
- package/dialog/index.js +3 -2
- package/dropdown/types.d.ts +2 -0
- 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/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/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/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/pagination/types.d.ts +1 -0
- package/progress/index.d.ts +17 -0
- package/progress/index.js +87 -0
- package/progress/types.d.ts +12 -0
- package/radio/types.d.ts +1 -0
- package/segment/index.js +1 -1
- package/segment-collapse/types.d.ts +1 -0
- package/segmented-control/types.d.ts +1 -0
- package/segmented-icon-control/types.d.ts +1 -0
- package/select/types.d.ts +1 -1
- package/spinner/index.js +1 -1
- package/tabs/types.d.ts +1 -0
- package/tag/index.d.ts +1 -0
- package/tag/index.js +10 -3
- package/tag/utils.d.ts +3 -0
- package/tag/utils.js +6 -1
- package/tag-close/index.js +5 -1
- package/tag-close/types.d.ts +3 -1
- package/text/index.js +9 -1
- package/text/types.d.ts +3 -0
- package/time-picker/index.js +9 -1
- package/time-picker/types.d.ts +5 -1
- package/title/index.js +10 -2
- package/title/types.d.ts +3 -0
- package/toast/index.d.ts +17 -0
- package/toast/index.js +153 -0
- package/toast/types.d.ts +28 -0
- package/toast/types.js +1 -0
- package/toast/utils.d.ts +5 -0
- package/toast/utils.js +6 -0
- package/toast-manager/index.d.ts +17 -0
- package/toast-manager/index.js +271 -0
- package/toast-manager/types.d.ts +7 -0
- package/toast-manager/types.js +1 -0
- package/toggle/index.js +3 -4
- package/toggle/types.d.ts +1 -0
- package/utils.d.ts +2 -0
- package/utils.js +40 -1
- package/card-button/index.d.ts +0 -11
- package/card-button/index.js +0 -77
- package/card-button/types.d.ts +0 -12
- package/card-link/index.d.ts +0 -12
- package/card-link/index.js +0 -115
- package/card-link/types.d.ts +0 -14
- package/search/index.d.ts +0 -14
- package/search/index.js +0 -523
- package/search/types.d.ts +0 -25
- package/search-option/index.d.ts +0 -11
- package/search-option/index.js +0 -55
- package/search-option/types.d.ts +0 -9
- /package/{card-button → file-drop}/types.js +0 -0
- /package/{card-link → file-picker}/types.js +0 -0
- /package/{search-option → file-status}/types.js +0 -0
- /package/{search → progress}/types.js +0 -0
|
@@ -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,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 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,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);
|
|
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);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
package/pagination/types.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export declare type TSinchPaginationElement = HTMLElement & {
|
|
|
14
14
|
export declare type TSinchPaginationReact = TSinchElementReact<TSinchPaginationElement> & {
|
|
15
15
|
value: number;
|
|
16
16
|
max: number;
|
|
17
|
+
/** @deprecated */
|
|
17
18
|
onChange?: (event: SyntheticEvent<TSinchPaginationElement, CustomEvent<number>>) => void;
|
|
18
19
|
'on-change': (e: CustomEvent<number>) => void;
|
|
19
20
|
};
|
|
@@ -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
|
+
}));
|