@nectary/components 0.41.1 → 0.42.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/accordion/index.js +0 -16
- package/accordion/types.d.ts +9 -1
- package/accordion-item/index.js +0 -24
- package/accordion-item/types.d.ts +18 -3
- package/action-menu/index.js +1 -45
- package/action-menu-option/index.js +0 -18
- package/alert/index.js +0 -10
- package/alert/types.d.ts +6 -0
- package/avatar/index.js +57 -20
- package/avatar/types.d.ts +25 -7
- package/avatar/utils.d.ts +10 -2
- package/avatar/utils.js +23 -2
- package/badge/index.d.ts +11 -0
- package/badge/index.js +140 -0
- package/badge/types.d.ts +38 -0
- package/badge/utils.d.ts +11 -0
- package/badge/utils.js +23 -0
- package/button/index.js +0 -18
- package/card/index.js +0 -16
- package/card/types.d.ts +15 -3
- package/card-container/index.js +0 -1
- package/chat/index.js +0 -1
- package/chat-block/index.js +0 -19
- package/chat-block/types.d.ts +16 -4
- package/chat-bubble/index.js +0 -9
- package/chat-bubble/types.d.ts +6 -0
- package/checkbox/index.js +0 -23
- package/chip/index.js +16 -25
- package/chip/utils.d.ts +3 -0
- package/chip/utils.js +11 -0
- package/color-menu/index.js +8 -86
- package/color-menu/utils.js +0 -4
- package/color-swatch/index.js +17 -17
- package/color-swatch/types.d.ts +2 -2
- package/color-swatch/utils.d.ts +3 -0
- package/color-swatch/utils.js +11 -0
- package/date-picker/index.js +1 -50
- package/date-picker/utils.js +0 -7
- package/dialog/index.js +1 -17
- package/field/index.js +0 -19
- package/file-drop/index.js +0 -40
- package/file-drop/utils.js +0 -6
- package/file-picker/index.js +0 -17
- package/file-picker/utils.js +0 -1
- package/file-status/index.js +0 -12
- package/grid/index.js +0 -1
- package/grid-item/index.js +0 -9
- package/help-tooltip/index.js +0 -14
- package/horizontal-stepper/index.js +0 -12
- package/horizontal-stepper-item/index.js +0 -14
- package/icon-button/index.js +0 -15
- package/icons/create-icon-class.js +0 -2
- package/icons-branded/create-icon-class.js +0 -8
- package/icons-channel/create-icon-class.js +0 -6
- package/illustrations/create-illustration-class.js +0 -11
- package/inline-alert/index.js +0 -14
- package/input/index.js +0 -37
- package/link/index.js +0 -25
- package/list/index.js +0 -2
- package/list-item/index.js +0 -2
- package/logo/create-logo-class.js +0 -9
- package/package.json +3 -1
- package/pagination/index.js +0 -31
- package/pop/index.js +26 -68
- package/pop/utils.js +0 -1
- package/popover/index.js +0 -33
- package/popover/utils.js +0 -2
- package/progress/index.js +0 -10
- package/radio/index.js +0 -30
- package/radio-option/index.js +0 -20
- package/segment/index.js +0 -15
- package/segment-collapse/index.js +0 -13
- package/segmented-control/index.js +0 -12
- package/segmented-control-option/index.js +0 -18
- package/segmented-icon-control/index.js +0 -16
- package/segmented-icon-control-option/index.js +0 -14
- package/select-button/index.js +0 -23
- package/select-menu/index.js +1 -63
- package/select-menu-option/index.js +0 -14
- package/spinner/index.js +0 -4
- package/stop-events/index.js +0 -5
- package/table/index.js +0 -2
- package/table-body/index.js +0 -2
- package/table-cell/index.js +0 -4
- package/table-head/index.js +0 -2
- package/table-head-cell/index.js +0 -11
- package/table-row/index.js +0 -6
- package/tabs/index.js +0 -30
- package/tabs-option/index.js +0 -19
- package/tag/index.js +18 -21
- package/tag/utils.d.ts +3 -0
- package/tag/utils.js +11 -0
- package/text/index.js +1 -12
- package/textarea/index.js +0 -40
- package/theme/avatar.css +25 -0
- package/theme/badge.css +15 -0
- package/theme/chip.css +53 -0
- package/theme/color-swatch.css +65 -0
- package/{utils → theme}/colors.d.ts +0 -1
- package/{utils → theme}/colors.js +0 -1
- package/theme/elevation.css +7 -0
- package/theme/fonts.css +76 -0
- package/theme/fonts.json +79 -0
- package/theme/palette.css +90 -0
- package/theme/shapes.css +7 -0
- package/theme/tag.css +53 -0
- package/theme/typography.css +16 -0
- package/theme.css +13 -209
- package/tile-control/index.js +0 -24
- package/tile-control-option/index.js +0 -18
- package/time-picker/index.js +2 -51
- package/time-picker/utils.js +0 -18
- package/title/index.js +1 -12
- package/title/utils.js +0 -5
- package/toast/index.js +0 -19
- package/toast-manager/index.js +0 -27
- package/toggle/index.js +0 -23
- package/tooltip/index.js +0 -27
- package/tooltip/utils.js +0 -4
- package/utils/animation.js +0 -20
- package/utils/context.js +0 -6
- package/utils/index.d.ts +1 -0
- package/utils/index.js +11 -52
- package/vertical-stepper/index.js +0 -12
- package/vertical-stepper-item/index.js +0 -14
- package/avatar-badge/index.d.ts +0 -11
- package/avatar-badge/index.js +0 -38
- package/avatar-badge/types.d.ts +0 -8
- package/avatar-status/index.d.ts +0 -11
- package/avatar-status/index.js +0 -37
- package/avatar-status/types.d.ts +0 -9
- package/avatar-status/types.js +0 -1
- package/avatar-status/utils.d.ts +0 -5
- package/avatar-status/utils.js +0 -6
- package/chat-avatar/index.d.ts +0 -12
- package/chat-avatar/index.js +0 -52
- package/chat-avatar/types.d.ts +0 -12
- package/chat-avatar/types.js +0 -1
- /package/{avatar-badge → badge}/types.js +0 -0
package/utils/index.js
CHANGED
|
@@ -6,25 +6,20 @@ export const defineCustomElement = (name, constructor) => {
|
|
|
6
6
|
if (nectaryRegistry.get(name) == null) {
|
|
7
7
|
nectaryRegistry.define(name, constructor);
|
|
8
8
|
}
|
|
9
|
-
|
|
10
9
|
return;
|
|
11
10
|
}
|
|
12
|
-
|
|
13
11
|
nectaryDefinitions.set(name, constructor);
|
|
14
12
|
};
|
|
15
13
|
export const setNectaryRegistry = registry => {
|
|
16
14
|
if (nectaryRegistry !== null) {
|
|
17
15
|
throw new Error('Nectary elements already registered');
|
|
18
16
|
}
|
|
19
|
-
|
|
20
17
|
nectaryRegistry = registry;
|
|
21
|
-
|
|
22
18
|
for (const [name, ctor] of nectaryDefinitions.entries()) {
|
|
23
19
|
if (nectaryRegistry.get(name) == null) {
|
|
24
20
|
nectaryRegistry.define(name, ctor);
|
|
25
21
|
}
|
|
26
22
|
}
|
|
27
|
-
|
|
28
23
|
nectaryDefinitions.clear();
|
|
29
24
|
};
|
|
30
25
|
export class NectaryElement extends HTMLElement {
|
|
@@ -36,13 +31,10 @@ export class NectaryElement extends HTMLElement {
|
|
|
36
31
|
...options
|
|
37
32
|
});
|
|
38
33
|
}
|
|
39
|
-
|
|
40
34
|
version = pkg.version;
|
|
41
|
-
|
|
42
35
|
get focusable() {
|
|
43
36
|
return false;
|
|
44
37
|
}
|
|
45
|
-
|
|
46
38
|
}
|
|
47
39
|
export const getReactEventHandler = ($element, handlerName) => {
|
|
48
40
|
for (const key in $element) {
|
|
@@ -50,7 +42,6 @@ export const getReactEventHandler = ($element, handlerName) => {
|
|
|
50
42
|
return $element[key][handlerName];
|
|
51
43
|
}
|
|
52
44
|
}
|
|
53
|
-
|
|
54
45
|
return null;
|
|
55
46
|
};
|
|
56
47
|
export const updateExplicitBooleanAttribute = ($element, attrName, attrValue) => {
|
|
@@ -64,7 +55,6 @@ export const getBooleanAttribute = ($element, attrName) => {
|
|
|
64
55
|
};
|
|
65
56
|
export const updateBooleanAttribute = ($element, attrName, attrValue) => {
|
|
66
57
|
const currentAttrValue = $element.getAttribute(attrName);
|
|
67
|
-
|
|
68
58
|
if (attrValue === true) {
|
|
69
59
|
if (!isAttrTrue(currentAttrValue)) {
|
|
70
60
|
$element.setAttribute(attrName, '');
|
|
@@ -96,15 +86,12 @@ export const updateLiteralAttribute = ($element, literals, attrName, attrValue)
|
|
|
96
86
|
};
|
|
97
87
|
export function getLiteralAttribute($element, literals, attrName, defaultValue) {
|
|
98
88
|
const attrValue = $element.getAttribute(attrName);
|
|
99
|
-
|
|
100
89
|
if (isLiteralValue(literals, attrValue)) {
|
|
101
90
|
return attrValue;
|
|
102
91
|
}
|
|
103
|
-
|
|
104
92
|
if (typeof defaultValue === 'undefined') {
|
|
105
93
|
throw new Error(`Invalid attribute value: ${attrName} = ${attrValue}`);
|
|
106
94
|
}
|
|
107
|
-
|
|
108
95
|
return defaultValue;
|
|
109
96
|
}
|
|
110
97
|
export const clampNumber = (value, min, max) => {
|
|
@@ -115,25 +102,20 @@ const DEFAULT_INTEGER_OPTIONS = {
|
|
|
115
102
|
itemSpaceBetween: 0,
|
|
116
103
|
defaultValue: null
|
|
117
104
|
};
|
|
118
|
-
|
|
119
105
|
const applyRange = (value, _ref) => {
|
|
120
106
|
let {
|
|
121
107
|
min,
|
|
122
108
|
max
|
|
123
109
|
} = _ref;
|
|
124
110
|
let result = value;
|
|
125
|
-
|
|
126
111
|
if (min != null) {
|
|
127
112
|
result = Math.max(min, result);
|
|
128
113
|
}
|
|
129
|
-
|
|
130
114
|
if (max != null) {
|
|
131
115
|
result = Math.min(max, result);
|
|
132
116
|
}
|
|
133
|
-
|
|
134
117
|
return result;
|
|
135
118
|
};
|
|
136
|
-
|
|
137
119
|
export const attrValueToInteger = function (value) {
|
|
138
120
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_INTEGER_OPTIONS;
|
|
139
121
|
const {
|
|
@@ -142,19 +124,15 @@ export const attrValueToInteger = function (value) {
|
|
|
142
124
|
itemSpaceBetween = 0
|
|
143
125
|
} = options;
|
|
144
126
|
let intValue = defaultValue;
|
|
145
|
-
|
|
146
127
|
if (value !== null) {
|
|
147
128
|
const int = parseInt(value);
|
|
148
|
-
|
|
149
129
|
if (Number.isInteger(int)) {
|
|
150
130
|
intValue = applyRange(int, options);
|
|
151
131
|
}
|
|
152
132
|
}
|
|
153
|
-
|
|
154
133
|
if (intValue !== null) {
|
|
155
134
|
return intValue * itemSizeMultiplier + Math.max(intValue - 1, 0) * itemSpaceBetween;
|
|
156
135
|
}
|
|
157
|
-
|
|
158
136
|
return null;
|
|
159
137
|
};
|
|
160
138
|
export const attrValueToPixels = function (value) {
|
|
@@ -169,7 +147,6 @@ export const updateIntegerAttribute = function ($element, attrName, attrValue) {
|
|
|
169
147
|
itemSizeMultiplier: multiplier = 1
|
|
170
148
|
} = options;
|
|
171
149
|
let intValue = null;
|
|
172
|
-
|
|
173
150
|
if (typeof attrValue === 'string') {
|
|
174
151
|
intValue = attrValueToInteger(attrValue, options);
|
|
175
152
|
} else if (typeof attrValue === 'number') {
|
|
@@ -177,7 +154,6 @@ export const updateIntegerAttribute = function ($element, attrName, attrValue) {
|
|
|
177
154
|
} else {
|
|
178
155
|
intValue = defaultValue;
|
|
179
156
|
}
|
|
180
|
-
|
|
181
157
|
if (intValue === null) {
|
|
182
158
|
$element.removeAttribute(attrName);
|
|
183
159
|
} else {
|
|
@@ -187,27 +163,22 @@ export const updateIntegerAttribute = function ($element, attrName, attrValue) {
|
|
|
187
163
|
export function getIntegerAttribute($element, attrName, defaultValue) {
|
|
188
164
|
return attrValueToInteger($element.getAttribute(attrName)) ?? defaultValue;
|
|
189
165
|
}
|
|
190
|
-
|
|
191
166
|
const unpackCsv = csv => {
|
|
192
167
|
return csv === '' ? [] : csv.split(',');
|
|
193
168
|
};
|
|
194
|
-
|
|
195
169
|
const packCsv = values => {
|
|
196
170
|
return Array.from(values).join(',');
|
|
197
171
|
};
|
|
198
|
-
|
|
199
172
|
export const getCsvSet = acc => {
|
|
200
173
|
return new Set(unpackCsv(acc));
|
|
201
174
|
};
|
|
202
175
|
export const updateCsv = (acc, value, setActive) => {
|
|
203
176
|
const values = getCsvSet(acc);
|
|
204
|
-
|
|
205
177
|
if (setActive) {
|
|
206
178
|
values.add(value);
|
|
207
179
|
} else {
|
|
208
180
|
values.delete(value);
|
|
209
181
|
}
|
|
210
|
-
|
|
211
182
|
return packCsv(values);
|
|
212
183
|
};
|
|
213
184
|
export const getFirstCsvValue = acc => {
|
|
@@ -234,24 +205,19 @@ export const getCssVar = (element, variableName) => {
|
|
|
234
205
|
const result = getComputedStyle(element).getPropertyValue(variableName);
|
|
235
206
|
return result === '' ? null : result;
|
|
236
207
|
};
|
|
237
|
-
|
|
238
208
|
const throttle = (delayFn, cancelFn) => cb => {
|
|
239
209
|
let id = null;
|
|
240
210
|
let fnArgs;
|
|
241
|
-
|
|
242
211
|
const delayCallback = () => {
|
|
243
212
|
id = null;
|
|
244
213
|
cb(fnArgs);
|
|
245
214
|
};
|
|
246
|
-
|
|
247
215
|
return {
|
|
248
216
|
fn: function () {
|
|
249
217
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
250
218
|
args[_key] = arguments[_key];
|
|
251
219
|
}
|
|
252
|
-
|
|
253
220
|
fnArgs = args;
|
|
254
|
-
|
|
255
221
|
if (id === null) {
|
|
256
222
|
id = delayFn(delayCallback);
|
|
257
223
|
}
|
|
@@ -263,75 +229,57 @@ const throttle = (delayFn, cancelFn) => cb => {
|
|
|
263
229
|
}
|
|
264
230
|
};
|
|
265
231
|
};
|
|
266
|
-
|
|
267
232
|
export const throttleAnimationFrame = throttle(global.requestAnimationFrame, global.cancelAnimationFrame);
|
|
268
|
-
|
|
269
233
|
const isSlotElement = el => {
|
|
270
234
|
return el.tagName === 'SLOT';
|
|
271
235
|
};
|
|
272
|
-
|
|
273
236
|
export const getFirstSlotElement = function (root) {
|
|
274
237
|
let isDeep = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
275
238
|
const el = root.assignedElements()[0];
|
|
276
|
-
|
|
277
239
|
if (el == null) {
|
|
278
240
|
return null;
|
|
279
241
|
}
|
|
280
|
-
|
|
281
242
|
if (isDeep && isSlotElement(el)) {
|
|
282
243
|
return getFirstSlotElement(el, isDeep);
|
|
283
244
|
}
|
|
284
|
-
|
|
285
245
|
return el;
|
|
286
246
|
};
|
|
287
|
-
|
|
288
247
|
const getChildren = root => {
|
|
289
248
|
if (isSlotElement(root)) {
|
|
290
249
|
return root.assignedElements();
|
|
291
250
|
}
|
|
292
|
-
|
|
293
251
|
return Array.from(root.children);
|
|
294
252
|
};
|
|
295
|
-
|
|
296
253
|
const isFocusable = el => {
|
|
297
254
|
return el.focusable === true;
|
|
298
255
|
};
|
|
299
|
-
|
|
300
256
|
export const getFirstFocusableElement = root => {
|
|
301
257
|
for (const child of getChildren(root)) {
|
|
302
258
|
if (isFocusable(child)) {
|
|
303
259
|
return child;
|
|
304
260
|
}
|
|
305
|
-
|
|
306
261
|
const resultEl = getFirstFocusableElement(child);
|
|
307
|
-
|
|
308
262
|
if (resultEl !== null) {
|
|
309
263
|
return resultEl;
|
|
310
264
|
}
|
|
311
265
|
}
|
|
312
|
-
|
|
313
266
|
return null;
|
|
314
267
|
};
|
|
315
268
|
export const cloneNode = (el, deep) => {
|
|
316
269
|
const root = el.getRootNode();
|
|
317
|
-
|
|
318
270
|
if (root !== document && Reflect.has(root, 'createElement')) {
|
|
319
271
|
const cloned = root.createElement(el.tagName.toLowerCase());
|
|
320
|
-
|
|
321
272
|
for (const attr of el.getAttributeNames()) {
|
|
322
273
|
cloned.setAttribute(attr, el.getAttribute(attr));
|
|
323
274
|
}
|
|
324
|
-
|
|
325
275
|
if (deep) {
|
|
326
276
|
for (let i = 0; i < el.children.length; i++) {
|
|
327
277
|
const clonedChild = cloneNode(el.children[i], deep);
|
|
328
278
|
cloned.appendChild(clonedChild);
|
|
329
279
|
}
|
|
330
280
|
}
|
|
331
|
-
|
|
332
281
|
return cloned;
|
|
333
282
|
}
|
|
334
|
-
|
|
335
283
|
return el.cloneNode(deep);
|
|
336
284
|
};
|
|
337
285
|
export const isElementFocused = $el => {
|
|
@@ -339,4 +287,15 @@ export const isElementFocused = $el => {
|
|
|
339
287
|
};
|
|
340
288
|
export const rectOverlap = (targetRect, contentRect) => {
|
|
341
289
|
return targetRect.x < contentRect.x + contentRect.width && targetRect.x + targetRect.width > contentRect.x && targetRect.y < contentRect.y + contentRect.height && targetRect.y + targetRect.height > contentRect.y;
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
export const getTargetRect = slot => {
|
|
293
|
+
const item = getFirstSlotElement(slot, true);
|
|
294
|
+
if (item === null) {
|
|
295
|
+
return null;
|
|
296
|
+
}
|
|
297
|
+
if (Reflect.has(item, 'footprintRect')) {
|
|
298
|
+
return item.footprintRect;
|
|
299
|
+
}
|
|
300
|
+
return getRect(item);
|
|
342
301
|
};
|
|
@@ -6,33 +6,27 @@ const template = document.createElement('template');
|
|
|
6
6
|
template.innerHTML = templateHTML;
|
|
7
7
|
defineCustomElement('sinch-vertical-stepper', class extends NectaryElement {
|
|
8
8
|
#$itemsSlot;
|
|
9
|
-
|
|
10
9
|
constructor() {
|
|
11
10
|
super();
|
|
12
11
|
const shadowRoot = this.attachShadow();
|
|
13
12
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
14
13
|
this.#$itemsSlot = shadowRoot.querySelector('slot');
|
|
15
14
|
}
|
|
16
|
-
|
|
17
15
|
connectedCallback() {
|
|
18
16
|
this.setAttribute('role', 'progressbar');
|
|
19
17
|
this.setAttribute('aria-valuemin', '0');
|
|
20
18
|
this.#$itemsSlot.addEventListener('slotchange', this.#updateItems);
|
|
21
19
|
}
|
|
22
|
-
|
|
23
20
|
disconnectedCallback() {
|
|
24
21
|
this.#$itemsSlot.removeEventListener('slotchange', this.#updateItems);
|
|
25
22
|
}
|
|
26
|
-
|
|
27
23
|
static get observedAttributes() {
|
|
28
24
|
return ['index'];
|
|
29
25
|
}
|
|
30
|
-
|
|
31
26
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
32
27
|
if (oldVal === newVal) {
|
|
33
28
|
return;
|
|
34
29
|
}
|
|
35
|
-
|
|
36
30
|
switch (name) {
|
|
37
31
|
case 'index':
|
|
38
32
|
{
|
|
@@ -41,24 +35,19 @@ defineCustomElement('sinch-vertical-stepper', class extends NectaryElement {
|
|
|
41
35
|
}
|
|
42
36
|
}
|
|
43
37
|
}
|
|
44
|
-
|
|
45
38
|
set index(value) {
|
|
46
39
|
updateAttribute(this, 'index', value);
|
|
47
40
|
}
|
|
48
|
-
|
|
49
41
|
get index() {
|
|
50
42
|
return getAttribute(this, 'index', '1');
|
|
51
43
|
}
|
|
52
|
-
|
|
53
44
|
#updateItems = () => {
|
|
54
45
|
const $items = this.#$itemsSlot.assignedElements();
|
|
55
46
|
const activeIndex = clampNumber(getIntegerAttribute(this, 'index', 0), 0, $items.length + 1);
|
|
56
|
-
|
|
57
47
|
for (let i = 0; i < $items.length; i++) {
|
|
58
48
|
const $el = $items[i];
|
|
59
49
|
const itemIndex = i + 1;
|
|
60
50
|
$el.setAttribute('data-index', String(itemIndex));
|
|
61
|
-
|
|
62
51
|
if (itemIndex === activeIndex) {
|
|
63
52
|
$el.setAttribute('data-progress', 'active');
|
|
64
53
|
} else if (itemIndex < activeIndex) {
|
|
@@ -67,7 +56,6 @@ defineCustomElement('sinch-vertical-stepper', class extends NectaryElement {
|
|
|
67
56
|
$el.removeAttribute('data-progress');
|
|
68
57
|
}
|
|
69
58
|
}
|
|
70
|
-
|
|
71
59
|
this.setAttribute('aria-valuemax', String($items.length));
|
|
72
60
|
this.setAttribute('aria-valuenow', String(clampNumber(activeIndex, 0, $items.length)));
|
|
73
61
|
};
|
|
@@ -9,7 +9,6 @@ defineCustomElement('sinch-vertical-stepper-item', class extends NectaryElement
|
|
|
9
9
|
#$label;
|
|
10
10
|
#$description;
|
|
11
11
|
#$circleText;
|
|
12
|
-
|
|
13
12
|
constructor() {
|
|
14
13
|
super();
|
|
15
14
|
const shadowRoot = this.attachShadow();
|
|
@@ -18,15 +17,11 @@ defineCustomElement('sinch-vertical-stepper-item', class extends NectaryElement
|
|
|
18
17
|
this.#$description = shadowRoot.querySelector('#description');
|
|
19
18
|
this.#$circleText = shadowRoot.querySelector('#circle-text');
|
|
20
19
|
}
|
|
21
|
-
|
|
22
20
|
connectedCallback() {}
|
|
23
|
-
|
|
24
21
|
disconnectedCallback() {}
|
|
25
|
-
|
|
26
22
|
static get observedAttributes() {
|
|
27
23
|
return ['label', 'description', 'data-index'];
|
|
28
24
|
}
|
|
29
|
-
|
|
30
25
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
31
26
|
switch (name) {
|
|
32
27
|
case 'label':
|
|
@@ -34,13 +29,11 @@ defineCustomElement('sinch-vertical-stepper-item', class extends NectaryElement
|
|
|
34
29
|
this.#$label.textContent = newVal;
|
|
35
30
|
break;
|
|
36
31
|
}
|
|
37
|
-
|
|
38
32
|
case 'description':
|
|
39
33
|
{
|
|
40
34
|
this.#$description.textContent = newVal;
|
|
41
35
|
break;
|
|
42
36
|
}
|
|
43
|
-
|
|
44
37
|
case 'data-index':
|
|
45
38
|
{
|
|
46
39
|
this.#$circleText.textContent = newVal;
|
|
@@ -48,29 +41,22 @@ defineCustomElement('sinch-vertical-stepper-item', class extends NectaryElement
|
|
|
48
41
|
}
|
|
49
42
|
}
|
|
50
43
|
}
|
|
51
|
-
|
|
52
44
|
set label(value) {
|
|
53
45
|
updateAttribute(this, 'label', value);
|
|
54
46
|
}
|
|
55
|
-
|
|
56
47
|
get label() {
|
|
57
48
|
return getAttribute(this, 'label', '');
|
|
58
49
|
}
|
|
59
|
-
|
|
60
50
|
set description(value) {
|
|
61
51
|
updateAttribute(this, 'description', value);
|
|
62
52
|
}
|
|
63
|
-
|
|
64
53
|
get description() {
|
|
65
54
|
return getAttribute(this, 'description', '');
|
|
66
55
|
}
|
|
67
|
-
|
|
68
56
|
get status() {
|
|
69
57
|
return getLiteralAttribute(this, statusValues, 'status', null);
|
|
70
58
|
}
|
|
71
|
-
|
|
72
59
|
set status(value) {
|
|
73
60
|
updateLiteralAttribute(this, statusValues, 'status', value);
|
|
74
61
|
}
|
|
75
|
-
|
|
76
62
|
});
|
package/avatar-badge/index.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { TSinchAvatarBadgeElement, TSinchAvatarBadgeReact } from './types';
|
|
2
|
-
declare global {
|
|
3
|
-
namespace JSX {
|
|
4
|
-
interface IntrinsicElements {
|
|
5
|
-
'sinch-avatar-badge': TSinchAvatarBadgeReact;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
interface HTMLElementTagNameMap {
|
|
9
|
-
'sinch-avatar-badge': TSinchAvatarBadgeElement;
|
|
10
|
-
}
|
|
11
|
-
}
|
package/avatar-badge/index.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { defineCustomElement, getAttribute, NectaryElement, setClass, updateAttribute } from '../utils';
|
|
2
|
-
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle}#wrapper{width:fit-content;background-color:var(--sinch-color-snow-100);border-radius:calc(var(--sinch-avatar-badge-size)/ 2);padding:1px;box-sizing:border-box}#text{width:calc(var(--sinch-avatar-badge-size) - 2px);height:calc(var(--sinch-avatar-badge-size) - 2px);font:var(--sinch-avatar-badge-font);color:var(--sinch-color-snow-100);text-align:center;background-color:var(--sinch-color-raspberry-500);border-radius:calc(var(--sinch-avatar-badge-size)/ 2 - 1px)}#text.long{width:fit-content;padding:0 calc(var(--sinch-avatar-badge-size)/ 4)}</style><div id="wrapper"><div id="text"></div></div>';
|
|
3
|
-
const template = document.createElement('template');
|
|
4
|
-
template.innerHTML = templateHTML;
|
|
5
|
-
defineCustomElement('sinch-avatar-badge', class extends NectaryElement {
|
|
6
|
-
#$text;
|
|
7
|
-
|
|
8
|
-
constructor() {
|
|
9
|
-
super();
|
|
10
|
-
const shadowRoot = this.attachShadow();
|
|
11
|
-
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
12
|
-
this.#$text = shadowRoot.querySelector('#text');
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
get text() {
|
|
16
|
-
return getAttribute(this, 'text', '');
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
set text(value) {
|
|
20
|
-
updateAttribute(this, 'text', value);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
static get observedAttributes() {
|
|
24
|
-
return ['text'];
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
attributeChangedCallback(name, _, newVal) {
|
|
28
|
-
switch (name) {
|
|
29
|
-
case 'text':
|
|
30
|
-
{
|
|
31
|
-
this.#$text.textContent = newVal;
|
|
32
|
-
setClass(this.#$text, 'long', newVal !== null && newVal.length > 1);
|
|
33
|
-
break;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
});
|
package/avatar-badge/types.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { TSinchElementReact } from '../types';
|
|
2
|
-
export declare type TSinchAvatarBadgeElement = HTMLElement & {
|
|
3
|
-
text: string;
|
|
4
|
-
setAttribute(name: 'text', value: string): void;
|
|
5
|
-
};
|
|
6
|
-
export declare type TSinchAvatarBadgeReact = TSinchElementReact<TSinchAvatarBadgeElement> & {
|
|
7
|
-
text: string;
|
|
8
|
-
};
|
package/avatar-status/index.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { TSinchAvatarStatusElement, TSinchAvatarStatusReact } from './types';
|
|
2
|
-
declare global {
|
|
3
|
-
namespace JSX {
|
|
4
|
-
interface IntrinsicElements {
|
|
5
|
-
'sinch-avatar-status': TSinchAvatarStatusReact;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
interface HTMLElementTagNameMap {
|
|
9
|
-
'sinch-avatar-status': TSinchAvatarStatusElement;
|
|
10
|
-
}
|
|
11
|
-
}
|
package/avatar-status/index.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { defineCustomElement, getLiteralAttribute, NectaryElement, updateLiteralAttribute } from '../utils';
|
|
2
|
-
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle}#wrapper{width:10px;height:10px;padding:1px;box-sizing:border-box;border-radius:50%;background-color:var(--sinch-color-snow-100)}#circle{width:8px;height:8px;border-radius:50%}:host([color=grey]) #circle{background-color:var(--sinch-color-snow-600)}:host([color=yellow]) #circle{background-color:var(--sinch-color-honey-500)}:host([color=red]) #circle{background-color:var(--sinch-color-raspberry-500)}:host([color=green]) #circle{background-color:var(--sinch-color-grass-400)}</style><div id="wrapper"><div id="circle"></div></div>';
|
|
3
|
-
import { assertColor, colorValues } from './utils';
|
|
4
|
-
const template = document.createElement('template');
|
|
5
|
-
template.innerHTML = templateHTML;
|
|
6
|
-
defineCustomElement('sinch-avatar-status', class extends NectaryElement {
|
|
7
|
-
constructor() {
|
|
8
|
-
super();
|
|
9
|
-
const shadowRoot = this.attachShadow();
|
|
10
|
-
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
connectedCallback() {}
|
|
14
|
-
|
|
15
|
-
static get observedAttributes() {
|
|
16
|
-
return ['color'];
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
attributeChangedCallback(name, _, newVal) {
|
|
20
|
-
switch (name) {
|
|
21
|
-
case 'color':
|
|
22
|
-
{
|
|
23
|
-
assertColor(newVal);
|
|
24
|
-
break;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
get color() {
|
|
30
|
-
return getLiteralAttribute(this, colorValues, 'color');
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
set color(value) {
|
|
34
|
-
updateLiteralAttribute(this, colorValues, 'color', value);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
});
|
package/avatar-status/types.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { TSinchElementReact } from '../types';
|
|
2
|
-
export declare type TSinchAvatarStatusColor = 'red' | 'yellow' | 'green' | 'grey';
|
|
3
|
-
export declare type TSinchAvatarStatusElement = HTMLElement & {
|
|
4
|
-
color: TSinchAvatarStatusColor;
|
|
5
|
-
setAttribute(name: 'color', value: TSinchAvatarStatusColor): void;
|
|
6
|
-
};
|
|
7
|
-
export declare type TSinchAvatarStatusReact = TSinchElementReact<TSinchAvatarStatusElement> & {
|
|
8
|
-
color: TSinchAvatarStatusColor;
|
|
9
|
-
};
|
package/avatar-status/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/avatar-status/utils.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { TSinchAvatarStatusColor } from './types';
|
|
2
|
-
export declare const colorValues: readonly TSinchAvatarStatusColor[];
|
|
3
|
-
declare type TAssertColor = (value: string | null) => asserts value is TSinchAvatarStatusColor;
|
|
4
|
-
export declare const assertColor: TAssertColor;
|
|
5
|
-
export {};
|
package/avatar-status/utils.js
DELETED
package/chat-avatar/index.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import '../avatar';
|
|
2
|
-
import type { TSinchChatAvatarElement, TSinchChatAvatarReact } from './types';
|
|
3
|
-
declare global {
|
|
4
|
-
namespace JSX {
|
|
5
|
-
interface IntrinsicElements {
|
|
6
|
-
'sinch-chat-avatar': TSinchChatAvatarReact;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
interface HTMLElementTagNameMap {
|
|
10
|
-
'sinch-chat-avatar': TSinchChatAvatarElement;
|
|
11
|
-
}
|
|
12
|
-
}
|
package/chat-avatar/index.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import '../avatar';
|
|
2
|
-
import { defineCustomElement, getAttribute, NectaryElement, updateAttribute } from '../utils';
|
|
3
|
-
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle}sinch-avatar{display:block}</style><sinch-avatar background="blue" size="l"></sinch-avatar>';
|
|
4
|
-
const template = document.createElement('template');
|
|
5
|
-
template.innerHTML = templateHTML;
|
|
6
|
-
defineCustomElement('sinch-chat-avatar', class extends NectaryElement {
|
|
7
|
-
#$avatar;
|
|
8
|
-
|
|
9
|
-
constructor() {
|
|
10
|
-
super();
|
|
11
|
-
const shadowRoot = this.attachShadow();
|
|
12
|
-
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
13
|
-
this.#$avatar = shadowRoot.querySelector('sinch-avatar');
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
static get observedAttributes() {
|
|
17
|
-
return ['src', 'alt'];
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
attributeChangedCallback(name, _, newVal) {
|
|
21
|
-
switch (name) {
|
|
22
|
-
case 'src':
|
|
23
|
-
{
|
|
24
|
-
updateAttribute(this.#$avatar, 'src', newVal);
|
|
25
|
-
break;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
case 'alt':
|
|
29
|
-
{
|
|
30
|
-
updateAttribute(this.#$avatar, 'alt', newVal);
|
|
31
|
-
break;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
get src() {
|
|
37
|
-
return getAttribute(this, 'src');
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
set src(value) {
|
|
41
|
-
updateAttribute(this, 'src', value);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
get alt() {
|
|
45
|
-
return getAttribute(this, 'alt', '');
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
set alt(value) {
|
|
49
|
-
updateAttribute(this, 'alt', value);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
});
|
package/chat-avatar/types.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { TSinchAvatarElement, TSinchAvatarReact } from '../avatar/types';
|
|
2
|
-
import type { TSinchElementReact } from '../types';
|
|
3
|
-
export declare type TSinchChatAvatarElement = HTMLElement & {
|
|
4
|
-
alt: TSinchAvatarElement['alt'];
|
|
5
|
-
src: TSinchAvatarElement['src'];
|
|
6
|
-
setAttribute(name: 'alt', value: string): void;
|
|
7
|
-
setAttribute(name: 'src', value: string): void;
|
|
8
|
-
};
|
|
9
|
-
export declare type TSinchChatAvatarReact = TSinchElementReact<TSinchChatAvatarElement> & {
|
|
10
|
-
alt: TSinchAvatarReact['alt'];
|
|
11
|
-
src?: TSinchAvatarReact['src'];
|
|
12
|
-
};
|
package/chat-avatar/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
File without changes
|