@nectary/components 0.19.0 → 0.21.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-item/index.js +1 -1
- package/alert/index.js +1 -1
- package/avatar/index.js +1 -1
- package/avatar-badge/index.d.ts +18 -0
- package/avatar-badge/index.js +55 -0
- package/avatar-status/index.d.ts +21 -0
- package/avatar-status/index.js +49 -0
- package/button/index.js +1 -1
- package/card/index.js +1 -1
- package/card-container/index.d.ts +13 -0
- package/card-container/index.js +15 -0
- package/chat-avatar/index.js +1 -1
- package/chat-block/index.js +1 -1
- package/dialog/index.js +9 -20
- package/dropdown/index.d.ts +3 -2
- package/dropdown/index.js +118 -66
- package/index.d.ts +5 -0
- package/index.js +6 -1
- package/input/index.js +1 -1
- package/package.json +1 -1
- package/popover/index.d.ts +26 -0
- package/popover/index.js +230 -0
- package/search/index.d.ts +3 -0
- package/search/index.js +49 -4
- package/segment/index.js +1 -1
- package/select/index.js +26 -3
- package/table-head-cell/index.js +1 -1
- package/tabs-option/index.js +1 -1
- package/textarea/index.js +1 -1
- package/theme.css +5 -5
- package/title/index.d.ts +26 -0
- package/title/index.js +96 -0
- package/utils.d.ts +2 -1
- package/utils.js +19 -1
package/search/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
2
|
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
3
|
|
|
4
|
-
var _$label, _$input, _selectionStart, _selectionEnd, _$optionSlot, _$listbox, _$clear, _onInput, _onValueChange, _onClearMouseDown, _onClear, _onInputFocus, _onInputBlur, _onListboxClick, _onListboxKeyPress, _onListboxKeyDown, _onOptionSlotChange, _onExpand, _onCollapse, _getFirstOption, _getLastOption, _getNextOption, _getPrevOption, _selectOption, _getOptionElements;
|
|
4
|
+
var _$label, _$input, _selectionStart, _selectionEnd, _$optionSlot, _$listbox, _$clear, _isPendingDk, _onCompositionStart, _onInput, _onValueChange, _onClearMouseDown, _onClear, _onInputFocus, _onInputBlur, _onListboxClick, _onListboxKeyPress, _onListboxKeyDown, _onOptionSlotChange, _onExpand, _onCollapse, _getFirstOption, _getLastOption, _getNextOption, _getPrevOption, _selectOption, _getOptionElements;
|
|
5
5
|
|
|
6
6
|
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
|
7
7
|
|
|
@@ -13,7 +13,7 @@ function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(
|
|
|
13
13
|
|
|
14
14
|
import { isSearchOptionElement } from '../search-option';
|
|
15
15
|
import { attrValueToPixels, defineCustomElement, getAttribute, getIntegerAttribute, getRect, updateAttribute, updateIntegerAttribute } from '../utils';
|
|
16
|
-
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{position:relative;width:100%;box-sizing:border-box;--sinch-size-icon:24px}#label{display:none;font:var(--sinch-font-title-
|
|
16
|
+
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{position:relative;width:100%;box-sizing:border-box;--sinch-size-icon:24px}#label{display:none;font:var(--sinch-font-title-s);color:var(--sinch-color-text-default);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:100%;height:24px;margin-bottom:2px}#input{all:initial;display:block;border:1px solid var(--sinch-color-stormy-200);box-sizing:border-box;border-radius:4px;width:100%;height:48px;padding:0 44px;padding-right:12px;font:var(--sinch-font-body);color:var(--sinch-color-text-default);caret-color:var(--sinch-caret-color,auto)}#input::placeholder{font:var(--sinch-font-body);color:var(--sinch-color-text-muted)}#input:focus{border-color:var(--sinch-color-stormy-600)}#icon-search{position:absolute;left:12px;top:12px;pointer-events:none;--sinch-color-icon:var(--sinch-color-stormy-500)}#clear{position:absolute;right:8px;top:8px;display:none;--sinch-color-icon:red}#clear:focus{--sinch-color-icon:var(--sinch-color-stormy-500)}:host([value]:not([value=""])) #clear{display:flex}:host([value]:not([value=""])) #input{padding-right:44px}#listbox{display:none;position:absolute;z-index:1;left:0;top:calc(100% + 8px);width:100%;box-sizing:border-box;font:var(--sinch-font-body);color:var(--sinch-color-text-default);background-color:var(--sinch-color-snow-100);box-shadow:1px 2px 4px rgba(0,0,0,.15);overflow-y:auto;contain:content}:host([aria-expanded=true]) #listbox{display:block}:host([label]:not([label=""])) #label{display:block}</style><label id="label" for="input"></label><div id="wrapper"><input id="input" type="text"/><sinch-icon-search id="icon-search"></sinch-icon-search><sinch-icon-button id="clear" small><sinch-icon-close id="icon-close" slot="icon"></sinch-icon-close></sinch-icon-button><div id="listbox"><slot name="option"></slot></div></div>';
|
|
17
17
|
import '../icon/search';
|
|
18
18
|
import '../icon/close';
|
|
19
19
|
import '../icon-button';
|
|
@@ -31,7 +31,7 @@ const findSelectedOption = elements => {
|
|
|
31
31
|
|
|
32
32
|
const template = document.createElement('template');
|
|
33
33
|
template.innerHTML = templateHTML;
|
|
34
|
-
defineCustomElement('sinch-search', (_$label = new WeakMap(), _$input = new WeakMap(), _selectionStart = new WeakMap(), _selectionEnd = new WeakMap(), _$optionSlot = new WeakMap(), _$listbox = new WeakMap(), _$clear = new WeakMap(), _onInput = new WeakMap(), _onValueChange = new WeakSet(), _onClearMouseDown = new WeakMap(), _onClear = new WeakMap(), _onInputFocus = new WeakMap(), _onInputBlur = new WeakMap(), _onListboxClick = new WeakMap(), _onListboxKeyPress = new WeakMap(), _onListboxKeyDown = new WeakMap(), _onOptionSlotChange = new WeakMap(), _onExpand = new WeakSet(), _onCollapse = new WeakSet(), _getFirstOption = new WeakSet(), _getLastOption = new WeakSet(), _getNextOption = new WeakSet(), _getPrevOption = new WeakSet(), _selectOption = new WeakSet(), _getOptionElements = new WeakSet(), class extends HTMLElement {
|
|
34
|
+
defineCustomElement('sinch-search', (_$label = new WeakMap(), _$input = new WeakMap(), _selectionStart = new WeakMap(), _selectionEnd = new WeakMap(), _$optionSlot = new WeakMap(), _$listbox = new WeakMap(), _$clear = new WeakMap(), _isPendingDk = new WeakMap(), _onCompositionStart = new WeakMap(), _onInput = new WeakMap(), _onValueChange = new WeakSet(), _onClearMouseDown = new WeakMap(), _onClear = new WeakMap(), _onInputFocus = new WeakMap(), _onInputBlur = new WeakMap(), _onListboxClick = new WeakMap(), _onListboxKeyPress = new WeakMap(), _onListboxKeyDown = new WeakMap(), _onOptionSlotChange = new WeakMap(), _onExpand = new WeakSet(), _onCollapse = new WeakSet(), _getFirstOption = new WeakSet(), _getLastOption = new WeakSet(), _getNextOption = new WeakSet(), _getPrevOption = new WeakSet(), _selectOption = new WeakSet(), _getOptionElements = new WeakSet(), class extends HTMLElement {
|
|
35
35
|
constructor() {
|
|
36
36
|
super();
|
|
37
37
|
|
|
@@ -88,6 +88,18 @@ defineCustomElement('sinch-search', (_$label = new WeakMap(), _$input = new Weak
|
|
|
88
88
|
value: void 0
|
|
89
89
|
});
|
|
90
90
|
|
|
91
|
+
_classPrivateFieldInitSpec(this, _isPendingDk, {
|
|
92
|
+
writable: true,
|
|
93
|
+
value: false
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
_classPrivateFieldInitSpec(this, _onCompositionStart, {
|
|
97
|
+
writable: true,
|
|
98
|
+
value: () => {
|
|
99
|
+
_classPrivateFieldSet(this, _isPendingDk, true);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
|
|
91
103
|
_classPrivateFieldInitSpec(this, _onInput, {
|
|
92
104
|
writable: true,
|
|
93
105
|
value: e => {
|
|
@@ -229,6 +241,8 @@ defineCustomElement('sinch-search', (_$label = new WeakMap(), _$input = new Weak
|
|
|
229
241
|
|
|
230
242
|
_classPrivateFieldGet(this, _$input).addEventListener('input', _classPrivateFieldGet(this, _onInput));
|
|
231
243
|
|
|
244
|
+
_classPrivateFieldGet(this, _$input).addEventListener('compositionstart', _classPrivateFieldGet(this, _onCompositionStart));
|
|
245
|
+
|
|
232
246
|
_classPrivateFieldGet(this, _$input).addEventListener('focus', _classPrivateFieldGet(this, _onInputFocus));
|
|
233
247
|
|
|
234
248
|
_classPrivateFieldGet(this, _$input).addEventListener('blur', _classPrivateFieldGet(this, _onInputBlur));
|
|
@@ -249,6 +263,8 @@ defineCustomElement('sinch-search', (_$label = new WeakMap(), _$input = new Weak
|
|
|
249
263
|
disconnectedCallback() {
|
|
250
264
|
_classPrivateFieldGet(this, _$input).removeEventListener('input', _classPrivateFieldGet(this, _onInput));
|
|
251
265
|
|
|
266
|
+
_classPrivateFieldGet(this, _$input).removeEventListener('compositionstart', _classPrivateFieldGet(this, _onCompositionStart));
|
|
267
|
+
|
|
252
268
|
_classPrivateFieldGet(this, _$input).removeEventListener('focus', _classPrivateFieldGet(this, _onInputFocus));
|
|
253
269
|
|
|
254
270
|
_classPrivateFieldGet(this, _$input).removeEventListener('blur', _classPrivateFieldGet(this, _onInputBlur));
|
|
@@ -314,6 +330,30 @@ defineCustomElement('sinch-search', (_$label = new WeakMap(), _$input = new Weak
|
|
|
314
330
|
return getRect(_classPrivateFieldGet(this, _$listbox));
|
|
315
331
|
}
|
|
316
332
|
|
|
333
|
+
get selectionStart() {
|
|
334
|
+
return _classPrivateFieldGet(this, _$input).selectionStart;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
set selectionStart(value) {
|
|
338
|
+
_classPrivateFieldGet(this, _$input).selectionStart = value;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
get selectionEnd() {
|
|
342
|
+
return _classPrivateFieldGet(this, _$input).selectionEnd;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
set selectionEnd(value) {
|
|
346
|
+
_classPrivateFieldGet(this, _$input).selectionEnd = value;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
get selectionDirection() {
|
|
350
|
+
return _classPrivateFieldGet(this, _$input).selectionDirection;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
set selectionDirection(value) {
|
|
354
|
+
_classPrivateFieldGet(this, _$input).selectionDirection = value;
|
|
355
|
+
}
|
|
356
|
+
|
|
317
357
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
318
358
|
switch (name) {
|
|
319
359
|
case 'value':
|
|
@@ -384,7 +424,12 @@ function _onValueChange2(nextValue) {
|
|
|
384
424
|
const prevSelectionEnd = _classPrivateFieldGet(this, _selectionEnd);
|
|
385
425
|
|
|
386
426
|
const isPrevCursorEnd = prevSelectionStart === prevSelectionEnd && prevSelectionStart === prevValue.length;
|
|
387
|
-
|
|
427
|
+
|
|
428
|
+
if (!_classPrivateFieldGet(this, _isPendingDk)) {
|
|
429
|
+
_classPrivateFieldGet(this, _$input).value = prevValue;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
_classPrivateFieldSet(this, _isPendingDk, false);
|
|
388
433
|
|
|
389
434
|
if (!isPrevCursorEnd) {
|
|
390
435
|
_classPrivateFieldGet(this, _$input).setSelectionRange(prevSelectionStart, prevSelectionEnd);
|
package/segment/index.js
CHANGED
|
@@ -8,7 +8,7 @@ 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 { defineCustomElement, getAttribute, getBooleanAttribute, updateAttribute, updateBooleanAttribute } from '../utils';
|
|
11
|
-
const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:column;width:100%;border-radius:4px;box-sizing:border-box;background-color:var(--sinch-color-snow-100);color:var(--sinch-color-text-default);font:var(--sinch-font-body);border:none;box-shadow:1px 2px 8px
|
|
11
|
+
const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:column;width:100%;height:100%;border-radius:4px;box-sizing:border-box;background-color:var(--sinch-color-snow-100);color:var(--sinch-color-text-default);font:var(--sinch-font-body);border:none;box-shadow:1px 2px 8px rgba(0,0,0,.1)}#header{position:relative;display:flex;flex-direction:row;align-items:center;gap:16px;height:32px;padding:24px 32px 16px;--sinch-size-icon:32px}#caption{font:var(--sinch-font-title-l);color:var(--sinch-color-text-default);flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#content-wrapper{padding:0 32px;flex:1;min-height:0;overflow:auto}#action{display:flex;flex-direction:row;justify-content:flex-end;gap:16px;padding:16px 32px 24px}#info{position:relative;display:flex;flex-direction:row;align-items:center;gap:16px;z-index:1}:host([collapsed]:not([collapsed=false])) :is(#content-wrapper,#action){display:none}:host([collapsed]:not([collapsed=false])) #header{padding-bottom:24px}</style><div id="wrapper"><div id="header"><slot name="icon"></slot><span id="caption"></span><div id="info"><slot name="info"></slot></div><slot name="collapse"></slot></div><div id="content-wrapper"><slot name="content"></slot></div><div id="action"><slot name="action"></slot></div></div>';
|
|
12
12
|
const template = document.createElement('template');
|
|
13
13
|
template.innerHTML = templateHTML;
|
|
14
14
|
defineCustomElement('sinch-segment', (_$caption = new WeakMap(), class extends HTMLElement {
|
package/select/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
2
|
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
3
|
|
|
4
|
-
var _$button, _$buttonContent, _$label, _$optionalText, _$additionalText, _$invalidText, _$dropdown, _$optionSlot, _updateButtonContent, _onValueChange, _getOptionWithValue, _onLabelClick;
|
|
4
|
+
var _$button, _$buttonContent, _$label, _$optionalText, _$additionalText, _$invalidText, _$dropdown, _$optionSlot, _updateButtonContent, _onValueChange, _getOptionWithValue, _onLabelClick, _onDropdownClick, _onDropdownClose;
|
|
5
5
|
|
|
6
6
|
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
|
7
7
|
|
|
@@ -15,10 +15,10 @@ import { isDropdownOptionElement } from '../dropdown-option';
|
|
|
15
15
|
import '../select-option';
|
|
16
16
|
import '../dropdown';
|
|
17
17
|
import { defineCustomElement, getAttribute, getBooleanAttribute, getIntegerAttribute, isAttrTrue, updateAttribute, updateBooleanAttribute, updateIntegerAttribute } from '../utils';
|
|
18
|
-
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0;--sinch-color-icon:var(--sinch-color-stormy-500)}#wrapper{position:relative}sinch-dropdown{display:block}#button{all:initial;display:flex;align-items:center;gap:8px;border:1px solid var(--sinch-color-stormy-200);border-radius:4px;box-sizing:border-box;width:100%;height:48px;margin:2px 0;padding:8px 12px;font:var(--sinch-font-body);color:var(--sinch-color-text-default);background-color:var(--sinch-color-snow-100);cursor:pointer}#button:focus{border-color:var(--sinch-color-stormy-600)}#dropdown-icon{fill:var(--sinch-color-stormy-500)}#button>*{pointer-events:none}#button[data-unselected]{color:var(--sinch-color-text-muted)}#button:disabled{border-color:var(--sinch-color-snow-500);color:var(--sinch-color-stormy-100);cursor:initial}#button:disabled #dropdown-icon{fill:var(--sinch-color-stormy-100)}:host([invalidtext]:not([invalidtext=""])) #button:not(:disabled){border-color:var(--sinch-color-text-invalid)}#content{flex:1;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}#bottom,#top{display:flex;align-items:baseline}#top{height:24px}#bottom{height:20px}#additional,#invalid,#label,#optional{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#label{font:var(--sinch-font-title-
|
|
18
|
+
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0;--sinch-color-icon:var(--sinch-color-stormy-500)}#wrapper{position:relative}sinch-dropdown{display:block}#button{all:initial;display:flex;align-items:center;gap:8px;border:1px solid var(--sinch-color-stormy-200);border-radius:4px;box-sizing:border-box;width:100%;height:48px;margin:2px 0;padding:8px 12px;font:var(--sinch-font-body);color:var(--sinch-color-text-default);background-color:var(--sinch-color-snow-100);cursor:pointer}#button:focus{border-color:var(--sinch-color-stormy-600)}#dropdown-icon{fill:var(--sinch-color-stormy-500)}#button>*{pointer-events:none}#button[data-unselected]{color:var(--sinch-color-text-muted)}#button:disabled{border-color:var(--sinch-color-snow-500);color:var(--sinch-color-stormy-100);cursor:initial}#button:disabled #dropdown-icon{fill:var(--sinch-color-stormy-100)}:host([invalidtext]:not([invalidtext=""])) #button:not(:disabled){border-color:var(--sinch-color-text-invalid)}#content{flex:1;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}#bottom,#top{display:flex;align-items:baseline}#top{height:24px}#bottom{height:20px}#additional,#invalid,#label,#optional{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#label{font:var(--sinch-font-title-s);color:var(--sinch-color-text-default)}#optional{flex:1;text-align:right;font:var(--sinch-font-small-text);color:var(--sinch-color-text-muted)}#additional{flex:1;text-align:right;font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-muted)}#invalid{font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-invalid)}::slotted(sinch-help-tooltip){align-self:center;margin:0 8px}:host([disabled]:not([disabled=false])) :is(#label,#additional,#optional,#invalid){color:var(--sinch-color-stormy-100)}:host([disabled]:not([disabled=false])){--sinch-color-icon:var(--sinch-color-stormy-100)}#listbox{position:absolute;left:0;top:0;padding-top:74px;width:100%;display:none;list-style:none;outline:0;z-index:1}#listbox-body{font:var(--sinch-font-body);color:var(--sinch-color-text-default);background-color:var(--sinch-color-snow-100);border:1px solid var(--sinch-color-stormy-500);border-top-width:0;border-bottom-left-radius:2px;border-bottom-right-radius:2px;width:100%;box-sizing:border-box;box-shadow:1px 2px 4px rgba(0,0,0,.15);overflow-y:auto}#button[aria-expanded=true]~#listbox{display:block}</style><div id="wrapper"><div id="top"><label id="label" for="dropdown"></label><slot name="tooltip"></slot><span id="optional"></span></div><sinch-dropdown id="dropdown"><button slot="target" id="button"><span id="content"></span> <svg id="dropdown-icon" width="12" height="8" aria-hidden="true"><path d="M1.41.59 6 5.17 10.59.59 12 2 6 8 0 2 1.41.59Z"/></svg></button><slot name="option" slot="option"></slot></sinch-dropdown><div id="bottom"><span id="invalid"></span> <span id="additional"></span></div></div>';
|
|
19
19
|
const template = document.createElement('template');
|
|
20
20
|
template.innerHTML = templateHTML;
|
|
21
|
-
defineCustomElement('sinch-select', (_$button = new WeakMap(), _$buttonContent = new WeakMap(), _$label = new WeakMap(), _$optionalText = new WeakMap(), _$additionalText = new WeakMap(), _$invalidText = new WeakMap(), _$dropdown = new WeakMap(), _$optionSlot = new WeakMap(), _updateButtonContent = new WeakSet(), _onValueChange = new WeakMap(), _getOptionWithValue = new WeakSet(), _onLabelClick = new WeakMap(), class extends HTMLElement {
|
|
21
|
+
defineCustomElement('sinch-select', (_$button = new WeakMap(), _$buttonContent = new WeakMap(), _$label = new WeakMap(), _$optionalText = new WeakMap(), _$additionalText = new WeakMap(), _$invalidText = new WeakMap(), _$dropdown = new WeakMap(), _$optionSlot = new WeakMap(), _updateButtonContent = new WeakSet(), _onValueChange = new WeakMap(), _getOptionWithValue = new WeakSet(), _onLabelClick = new WeakMap(), _onDropdownClick = new WeakMap(), _onDropdownClose = new WeakMap(), class extends HTMLElement {
|
|
22
22
|
constructor() {
|
|
23
23
|
super();
|
|
24
24
|
|
|
@@ -69,6 +69,7 @@ defineCustomElement('sinch-select', (_$button = new WeakMap(), _$buttonContent =
|
|
|
69
69
|
_classPrivateFieldInitSpec(this, _onValueChange, {
|
|
70
70
|
writable: true,
|
|
71
71
|
value: e => {
|
|
72
|
+
_classPrivateFieldGet(this, _$dropdown).open = false;
|
|
72
73
|
this.dispatchEvent(new CustomEvent('change', {
|
|
73
74
|
detail: e.detail,
|
|
74
75
|
bubbles: true
|
|
@@ -83,6 +84,20 @@ defineCustomElement('sinch-select', (_$button = new WeakMap(), _$buttonContent =
|
|
|
83
84
|
}
|
|
84
85
|
});
|
|
85
86
|
|
|
87
|
+
_classPrivateFieldInitSpec(this, _onDropdownClick, {
|
|
88
|
+
writable: true,
|
|
89
|
+
value: () => {
|
|
90
|
+
_classPrivateFieldGet(this, _$dropdown).open = true;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
_classPrivateFieldInitSpec(this, _onDropdownClose, {
|
|
95
|
+
writable: true,
|
|
96
|
+
value: () => {
|
|
97
|
+
_classPrivateFieldGet(this, _$dropdown).open = false;
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
|
|
86
101
|
const shadowRoot = this.attachShadow({
|
|
87
102
|
mode: 'closed',
|
|
88
103
|
delegatesFocus: true
|
|
@@ -111,12 +126,20 @@ defineCustomElement('sinch-select', (_$button = new WeakMap(), _$buttonContent =
|
|
|
111
126
|
|
|
112
127
|
_classPrivateFieldGet(this, _$dropdown).addEventListener('change', _classPrivateFieldGet(this, _onValueChange));
|
|
113
128
|
|
|
129
|
+
_classPrivateFieldGet(this, _$dropdown).addEventListener('close', _classPrivateFieldGet(this, _onDropdownClose));
|
|
130
|
+
|
|
131
|
+
_classPrivateFieldGet(this, _$button).addEventListener('click', _classPrivateFieldGet(this, _onDropdownClick));
|
|
132
|
+
|
|
114
133
|
_classPrivateFieldGet(this, _$label).addEventListener('click', _classPrivateFieldGet(this, _onLabelClick));
|
|
115
134
|
}
|
|
116
135
|
|
|
117
136
|
disconnectedCallback() {
|
|
118
137
|
_classPrivateFieldGet(this, _$dropdown).removeEventListener('change', _classPrivateFieldGet(this, _onValueChange));
|
|
119
138
|
|
|
139
|
+
_classPrivateFieldGet(this, _$dropdown).removeEventListener('close', _classPrivateFieldGet(this, _onDropdownClose));
|
|
140
|
+
|
|
141
|
+
_classPrivateFieldGet(this, _$button).removeEventListener('click', _classPrivateFieldGet(this, _onDropdownClick));
|
|
142
|
+
|
|
120
143
|
_classPrivateFieldGet(this, _$label).removeEventListener('click', _classPrivateFieldGet(this, _onLabelClick));
|
|
121
144
|
}
|
|
122
145
|
|
package/table-head-cell/index.js
CHANGED
|
@@ -8,7 +8,7 @@ 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 { defineCustomElement, getAttribute, getBooleanAttribute, getLiteralAttribute, updateAttribute, updateBooleanAttribute, updateLiteralAttribute } from '../utils';
|
|
11
|
-
const templateHTML = '<style>:host{display:table-cell;border-bottom:1px solid var(--sinch-color-stormy-200);height:48px;vertical-align:middle;padding:0 6px;--sinch-color-icon:var(--sinch-color-stormy-200)}:host(:first-child){padding-left:8px}:host(:last-child){padding-right:8px}#wrapper{position:relative;width:100%;height:100%;box-sizing:border-box;font:var(--sinch-font-title-
|
|
11
|
+
const templateHTML = '<style>:host{display:table-cell;border-bottom:1px solid var(--sinch-color-stormy-200);height:48px;vertical-align:middle;padding:0 6px;--sinch-color-icon:var(--sinch-color-stormy-200)}:host(:first-child){padding-left:8px}:host(:last-child){padding-right:8px}#wrapper{position:relative;width:100%;height:100%;box-sizing:border-box;font:var(--sinch-font-title-s);color:var(--sinch-color-stormy-300);display:flex;align-items:center;gap:4px}#text{flex-shrink:1;min-width:0;font:var(--sinch-font-title-s);color:var(--sinch-color-stormy-200);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}:host([align=center])>#wrapper{justify-content:center}:host([align=end]) #text{margin-left:auto}:host(:is([text=""],:not([text])))>#wrapper{display:none}:host([fit]:not([fit=false])){width:1px}::slotted(sinch-help-tooltip){position:relative;z-index:1}</style><slot name="checkbox"></slot><div id="wrapper"><span id="text"></span><slot name="tooltip"></slot><slot name="sort"></slot></div>';
|
|
12
12
|
const template = document.createElement('template');
|
|
13
13
|
template.innerHTML = templateHTML;
|
|
14
14
|
const alignValues = ['start', 'center', 'end'];
|
package/tabs-option/index.js
CHANGED
|
@@ -7,7 +7,7 @@ function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedec
|
|
|
7
7
|
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
8
8
|
|
|
9
9
|
import { defineCustomElement, getAttribute, getBooleanAttribute, isAttrTrue, updateAttribute, updateBooleanAttribute } from '../utils';
|
|
10
|
-
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}*{pointer-events:none}#wrapper{display:flex;flex-direction:row;align-items:center;gap:12px;position:relative;width:100%;height:42px;padding:8px 20px;box-sizing:border-box;box-shadow:0 1px 0 0 var(--sinch-color-stormy-100);color:var(--sinch-color-stormy-500);--sinch-color-icon:var(--sinch-color-stormy-500);--sinch-size-icon:16px}#content{font:var(--sinch-font-title-
|
|
10
|
+
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}*{pointer-events:none}#wrapper{display:flex;flex-direction:row;align-items:center;gap:12px;position:relative;width:100%;height:42px;padding:8px 20px;box-sizing:border-box;box-shadow:0 1px 0 0 var(--sinch-color-stormy-100);color:var(--sinch-color-stormy-500);--sinch-color-icon:var(--sinch-color-stormy-500);--sinch-size-icon:16px}#content{font:var(--sinch-font-title-s);flex-shrink:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}:host([checked]) #wrapper{box-shadow:0 2px 0 0 var(--sinch-color-stormy-500)}input{all:initial;position:absolute;left:0;top:0;box-sizing:border-box;width:100%;height:100%;cursor:pointer}:host([disabled]:not([disabled=false])) #wrapper{color:var(--sinch-color-stormy-100);--sinch-color-icon:var(--sinch-color-stormy-100)}input:disabled{cursor:unset}</style><div id="wrapper"><slot name="icon"></slot><label for="input" id="content" aria-hidden="true"></label> <input id="input" type="radio" aria-hidden="true"/></div>';
|
|
11
11
|
export const isTabsOptionElement = element => {
|
|
12
12
|
return element instanceof Element && element.tagName === 'SINCH-TABS-OPTION';
|
|
13
13
|
};
|
package/textarea/index.js
CHANGED
|
@@ -8,7 +8,7 @@ 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 { defineCustomElement, getAttribute, getBooleanAttribute, getIntegerAttribute, isAttrTrue, updateAttribute, updateBooleanAttribute } from '../utils';
|
|
11
|
-
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0;--sinch-color-icon:var(--sinch-color-stormy-500)}#wrapper{width:100%;box-sizing:border-box}#input{all:initial;border:1px solid var(--sinch-color-stormy-200);box-sizing:border-box;border-radius:4px;width:100%;margin:2px 0;padding:8px 12px;font:var(--sinch-font-body);color:var(--sinch-color-text-default);caret-color:var(--sinch-caret-color,auto);resize:none}#input::placeholder{font:var(--sinch-font-body);color:var(--sinch-color-text-muted)}#input:disabled{border-color:var(--sinch-color-snow-500);color:var(--sinch-color-stormy-100)}#input:disabled::placeholder{color:var(--sinch-color-snow-500)}#input:focus{border-color:var(--sinch-color-stormy-600)}:host([resizable]:not([resizable=false])) #input{resize:vertical}:host([invalidtext]:not([invalidtext=""])) #input:not(:disabled){border-color:var(--sinch-color-text-invalid)}#bottom,#top{display:flex;align-items:baseline}#top{height:24px}#bottom{height:20px}#additional,#invalid,#label,#optional{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#label{font:var(--sinch-font-title-
|
|
11
|
+
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0;--sinch-color-icon:var(--sinch-color-stormy-500)}#wrapper{width:100%;box-sizing:border-box}#input{all:initial;border:1px solid var(--sinch-color-stormy-200);box-sizing:border-box;border-radius:4px;width:100%;margin:2px 0;padding:8px 12px;font:var(--sinch-font-body);color:var(--sinch-color-text-default);caret-color:var(--sinch-caret-color,auto);resize:none}#input::placeholder{font:var(--sinch-font-body);color:var(--sinch-color-text-muted)}#input:disabled{border-color:var(--sinch-color-snow-500);color:var(--sinch-color-stormy-100)}#input:disabled::placeholder{color:var(--sinch-color-snow-500)}#input:focus{border-color:var(--sinch-color-stormy-600)}:host([resizable]:not([resizable=false])) #input{resize:vertical}:host([invalidtext]:not([invalidtext=""])) #input:not(:disabled){border-color:var(--sinch-color-text-invalid)}#bottom,#top{display:flex;align-items:baseline}#top{height:24px}#bottom{height:20px}#additional,#invalid,#label,#optional{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#label{font:var(--sinch-font-title-s);color:var(--sinch-color-text-default)}#optional{flex:1;text-align:right;font:var(--sinch-font-small-text);color:var(--sinch-color-text-muted)}#additional{flex:1;text-align:right;font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-muted)}#invalid{font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-invalid)}::slotted(sinch-help-tooltip){align-self:center;margin:0 8px}:host([disabled]:not([disabled=false])) :is(#label,#additional,#optional,#invalid){color:var(--sinch-color-stormy-100)}:host([disabled]:not([disabled=false])){--sinch-color-icon:var(--sinch-color-stormy-100)}</style><div id="wrapper"><div id="top"><label id="label" for="input"></label><slot name="tooltip"></slot><span id="optional"></span></div><textarea id="input"></textarea><div id="bottom"><span id="invalid"></span> <span id="additional"></span></div></div>';
|
|
12
12
|
const template = document.createElement('template');
|
|
13
13
|
template.innerHTML = templateHTML;
|
|
14
14
|
defineCustomElement('sinch-textarea', (_$input = new WeakMap(), _$label = new WeakMap(), _$optionalText = new WeakMap(), _$additionalText = new WeakMap(), _$invalidText = new WeakMap(), _selectionStart = new WeakMap(), _selectionEnd = new WeakMap(), _isPendingDk = new WeakMap(), _onCompositionStart = new WeakMap(), _onInput = new WeakMap(), class extends HTMLElement {
|
package/theme.css
CHANGED
|
@@ -70,11 +70,11 @@
|
|
|
70
70
|
--sinch-color-bolt-200: #FFE6B3;
|
|
71
71
|
--sinch-color-transparent: transparent;
|
|
72
72
|
--sinch-font-hero: 700 56px/72px "Gilroy", "Arial", "sans-serif";
|
|
73
|
-
--sinch-font-title-
|
|
74
|
-
--sinch-font-title-
|
|
75
|
-
--sinch-font-title-
|
|
76
|
-
--sinch-font-title-
|
|
77
|
-
--sinch-font-title-
|
|
73
|
+
--sinch-font-title-xl: 600 40px/48px "Gilroy", "Arial", "sans-serif";
|
|
74
|
+
--sinch-font-title-l: 600 24px/32px "Gilroy", "Arial", "sans-serif";
|
|
75
|
+
--sinch-font-title-m: 600 20px/24px "Gilroy", "Arial", "sans-serif";
|
|
76
|
+
--sinch-font-title-s: 600 16px/24px "Gilroy", "Arial", "sans-serif";
|
|
77
|
+
--sinch-font-title-xs: 600 14px/22px "Gilroy", "Arial", "sans-serif";
|
|
78
78
|
--sinch-font-body: 400 16px/24px "Gilroy", "Arial", "sans-serif";
|
|
79
79
|
--sinch-font-emphasized-body: 600 16px/24px "Gilroy", "Arial", "sans-serif";
|
|
80
80
|
--sinch-font-small-text: 400 14px/22px "Gilroy", "Arial", "sans-serif";
|
package/title/index.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import '../icon/cancel';
|
|
2
|
+
import type { TSinchElementReact } from '../types';
|
|
3
|
+
declare const typeValues: readonly ["xl", "l", "m", "s", "xs"];
|
|
4
|
+
declare const levelValues: readonly ["1", "2", "3", "4", "5", "6"];
|
|
5
|
+
export declare type TSinchTitleType = typeof typeValues[number];
|
|
6
|
+
export declare type TSinchTitleLevel = typeof levelValues[number];
|
|
7
|
+
export declare type TSinchTitleElement = HTMLElement & {
|
|
8
|
+
text: string;
|
|
9
|
+
type: TSinchTitleType;
|
|
10
|
+
};
|
|
11
|
+
export declare type TSinchTitleReact = TSinchElementReact<TSinchTitleElement> & {
|
|
12
|
+
text: string;
|
|
13
|
+
type: TSinchTitleType;
|
|
14
|
+
'aria-level': TSinchTitleLevel;
|
|
15
|
+
};
|
|
16
|
+
declare global {
|
|
17
|
+
namespace JSX {
|
|
18
|
+
interface IntrinsicElements {
|
|
19
|
+
'sinch-title': TSinchTitleReact;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
interface HTMLElementTagNameMap {
|
|
23
|
+
'sinch-title': TSinchTitleElement;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export {};
|
package/title/index.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
|
+
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
|
+
|
|
4
|
+
var _$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 '../icon/cancel';
|
|
11
|
+
import { defineCustomElement, getAttribute, updateAttribute, updateLiteralAttribute, getLiteralAttribute } from '../utils';
|
|
12
|
+
const templateHTML = '<style>:host{display:block}:host([type=xl])>*{font:var(--sinch-font-title-xl)}:host([type="l"])>*{font:var(--sinch-font-title-l)}:host([type="m"])>*{font:var(--sinch-font-title-m)}:host([type="s"])>*{font:var(--sinch-font-title-s)}:host([type=xs])>*{font:var(--sinch-font-title-xs)}</style><span id="text"></span>';
|
|
13
|
+
const typeValues = ['xl', 'l', 'm', 's', 'xs'];
|
|
14
|
+
const levelValues = ['1', '2', '3', '4', '5', '6'];
|
|
15
|
+
|
|
16
|
+
const assertLevel = value => {
|
|
17
|
+
if (value === null || !levelValues.includes(value)) {
|
|
18
|
+
throw new Error(`sinch-title: invalid aria-level attribute: ${value}`);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const assertType = value => {
|
|
23
|
+
if (value === null || !typeValues.includes(value)) {
|
|
24
|
+
throw new Error(`sinch-title: invalid type attribute: ${value}`);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const template = document.createElement('template');
|
|
29
|
+
template.innerHTML = templateHTML;
|
|
30
|
+
defineCustomElement('sinch-title', (_$text = new WeakMap(), class extends HTMLElement {
|
|
31
|
+
constructor() {
|
|
32
|
+
super();
|
|
33
|
+
|
|
34
|
+
_classPrivateFieldInitSpec(this, _$text, {
|
|
35
|
+
writable: true,
|
|
36
|
+
value: void 0
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const shadowRoot = this.attachShadow({
|
|
40
|
+
mode: 'closed',
|
|
41
|
+
delegatesFocus: true
|
|
42
|
+
});
|
|
43
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
44
|
+
|
|
45
|
+
_classPrivateFieldSet(this, _$text, shadowRoot.querySelector('#text'));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
connectedCallback() {
|
|
49
|
+
this.setAttribute('role', 'heading');
|
|
50
|
+
assertLevel(this.getAttribute('aria-level'));
|
|
51
|
+
assertType(this.getAttribute('type'));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
get text() {
|
|
55
|
+
return getAttribute(this, 'text', '');
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
set text(value) {
|
|
59
|
+
updateAttribute(this, 'text', value);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
set type(value) {
|
|
63
|
+
updateLiteralAttribute(this, typeValues, 'type', value);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
get type() {
|
|
67
|
+
return getLiteralAttribute(this, typeValues, 'type');
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
static get observedAttributes() {
|
|
71
|
+
return ['text', 'type', 'aria-level'];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
attributeChangedCallback(name, _, newVal) {
|
|
75
|
+
switch (name) {
|
|
76
|
+
case 'text':
|
|
77
|
+
{
|
|
78
|
+
_classPrivateFieldGet(this, _$text).textContent = newVal;
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
case 'aria-level':
|
|
83
|
+
{
|
|
84
|
+
assertLevel(newVal);
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
case 'type':
|
|
89
|
+
{
|
|
90
|
+
assertType(newVal);
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
}));
|
package/utils.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { TRect } from './types';
|
|
2
|
+
export declare const getReactEventHandler: ($element: HTMLElement, handlerName: string) => ((arg?: any) => void) | null;
|
|
2
3
|
export declare const defineCustomElement: (name: string, constructor: CustomElementConstructor) => void;
|
|
3
4
|
export declare const defineNectaryElements: (registry: CustomElementRegistry) => void;
|
|
4
5
|
export declare type TEventHandler = (arg?: any) => void;
|
|
@@ -12,7 +13,7 @@ export declare function getAttribute($element: Element, attrName: string, defaul
|
|
|
12
13
|
export declare function getAttribute($element: Element, attrName: string, defaultValue: string): string;
|
|
13
14
|
export declare const isLiteralValue: <T extends readonly string[]>(literals: T, value: string | null | undefined) => value is T[number];
|
|
14
15
|
export declare const updateLiteralAttribute: <T extends readonly string[]>($element: Element, literals: T, attrName: string, attrValue: string | null | undefined) => void;
|
|
15
|
-
export declare function getLiteralAttribute<T extends readonly string[]>($element: Element, literals: T, attrName: string): T[number]
|
|
16
|
+
export declare function getLiteralAttribute<T extends readonly string[]>($element: Element, literals: T, attrName: string): T[number];
|
|
16
17
|
export declare function getLiteralAttribute<T extends readonly string[]>($element: Element, literals: T, attrName: string, defaultValue: null): T[number] | null;
|
|
17
18
|
export declare function getLiteralAttribute<T extends readonly string[]>($element: Element, literals: T, attrName: string, defaultValue: T[number]): T[number];
|
|
18
19
|
declare type TRange = {
|
package/utils.js
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
const nectaryDefinitions = new Map();
|
|
2
2
|
let nectaryRegistry = null;
|
|
3
|
+
export const getReactEventHandler = ($element, handlerName) => {
|
|
4
|
+
for (const key in $element) {
|
|
5
|
+
if (key.startsWith('__reactProps$')) {
|
|
6
|
+
return $element[key][handlerName];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return null;
|
|
11
|
+
};
|
|
3
12
|
export const defineCustomElement = (name, constructor) => {
|
|
4
13
|
if (nectaryRegistry !== null) {
|
|
5
14
|
if (nectaryRegistry.get(name) == null) {
|
|
@@ -66,7 +75,16 @@ export const updateLiteralAttribute = ($element, literals, attrName, attrValue)
|
|
|
66
75
|
};
|
|
67
76
|
export function getLiteralAttribute($element, literals, attrName, defaultValue) {
|
|
68
77
|
const attrValue = $element.getAttribute(attrName);
|
|
69
|
-
|
|
78
|
+
|
|
79
|
+
if (isLiteralValue(literals, attrValue)) {
|
|
80
|
+
return attrValue;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (typeof defaultValue === 'undefined') {
|
|
84
|
+
throw new Error(`Invalid attribute value: ${attrName} = ${attrValue}`);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return defaultValue;
|
|
70
88
|
}
|
|
71
89
|
|
|
72
90
|
const applyRange = (value, range) => {
|