@nectary/components 0.39.0 → 0.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/accordion/index.js +47 -84
- package/accordion-item/index.js +26 -53
- package/action-menu/index.d.ts +0 -1
- package/action-menu/index.js +179 -223
- package/action-menu/types.d.ts +8 -18
- package/action-menu-option/index.d.ts +1 -0
- package/action-menu-option/index.js +51 -62
- package/action-menu-option/types.d.ts +9 -0
- package/action-menu-option/utils.d.ts +2 -0
- package/action-menu-option/utils.js +3 -0
- package/alert/index.js +6 -20
- package/avatar/index.js +12 -31
- package/avatar-badge/index.js +8 -22
- package/avatar-status/index.js +1 -1
- package/button/index.js +42 -92
- package/card/index.js +21 -59
- package/chat-avatar/index.js +8 -22
- package/chat-block/index.js +29 -69
- package/chat-bubble/index.js +6 -20
- package/checkbox/index.js +55 -107
- package/chip/index.d.ts +13 -0
- package/chip/index.js +137 -0
- package/chip/types.d.ts +38 -0
- package/color-menu/index.d.ts +13 -0
- package/color-menu/index.js +464 -0
- package/color-menu/types.d.ts +37 -0
- package/color-swatch/index.d.ts +13 -0
- package/color-swatch/index.js +59 -0
- package/color-swatch/types.d.ts +12 -0
- package/colors.json +57 -49
- package/date-picker/index.js +161 -292
- package/dialog/index.js +70 -142
- package/dropdown-checkbox-option/index.js +6 -20
- package/dropdown-radio-option/index.js +6 -20
- package/field/index.js +25 -63
- package/file-drop/index.js +123 -200
- package/file-picker/index.d.ts +0 -1
- package/file-picker/index.js +55 -108
- package/file-status/index.js +15 -39
- package/help-tooltip/index.js +1 -1
- package/horizontal-stepper/index.js +33 -59
- package/horizontal-stepper-item/index.js +13 -37
- package/icon-button/index.js +39 -84
- package/icons-channel/notify/index.d.ts +11 -0
- package/icons-channel/notify/index.js +4 -0
- package/illustrations/create-illustration-class.js +1 -1
- package/inline-alert/index.js +29 -81
- package/input/index.js +113 -222
- package/link/index.js +46 -96
- package/list-item/index.js +1 -1
- package/package.json +12 -14
- package/pagination/index.js +109 -163
- package/popover/index.js +224 -294
- package/progress/index.js +9 -28
- package/radio/index.js +103 -169
- package/radio-option/index.js +24 -48
- package/segment/index.js +49 -130
- package/segment-collapse/index.js +24 -49
- package/segmented-control/index.js +36 -73
- package/segmented-control-option/index.js +41 -87
- package/segmented-icon-control/index.js +47 -84
- package/segmented-icon-control-option/index.js +38 -79
- package/select-button/index.d.ts +13 -0
- package/select-button/index.js +153 -0
- package/select-button/types.d.ts +43 -0
- package/select-menu/index.d.ts +11 -0
- package/select-menu/index.js +346 -0
- package/select-menu/types.d.ts +29 -0
- package/select-menu/types.js +1 -0
- package/{dropdown-text-option → select-menu-option}/index.d.ts +5 -7
- package/select-menu-option/index.js +76 -0
- package/{select-option → select-menu-option}/types.d.ts +8 -9
- package/stop-events/index.js +7 -20
- package/table-head-cell/index.js +7 -21
- package/tabs/index.js +103 -165
- package/tabs-option/index.js +20 -44
- package/tag/index.d.ts +0 -1
- package/tag/index.js +37 -38
- package/tag/types.d.ts +13 -7
- package/textarea/index.js +92 -167
- package/theme.css +80 -49
- package/tile-control/index.js +55 -96
- package/tile-control-option/index.js +40 -86
- package/time-picker/index.js +216 -368
- package/title/index.js +6 -20
- package/toast/index.js +32 -70
- package/toast-manager/index.js +141 -217
- package/toggle/index.js +54 -106
- package/types.d.ts +7 -0
- package/utils/colors.d.ts +10 -0
- package/utils/colors.js +121 -0
- package/{utils.d.ts → utils/index.d.ts} +17 -9
- package/{utils.js → utils/index.js} +96 -39
- package/vertical-stepper/index.js +29 -50
- package/vertical-stepper-item/index.js +13 -37
- package/dropdown/index.d.ts +0 -12
- package/dropdown/index.js +0 -415
- package/dropdown/types.d.ts +0 -32
- package/dropdown-text-option/index.js +0 -104
- package/dropdown-text-option/types.d.ts +0 -16
- package/select/index.d.ts +0 -13
- package/select/index.js +0 -316
- package/select/types.d.ts +0 -53
- package/select-option/index.d.ts +0 -11
- package/select-option/index.js +0 -8
- package/tag/utils.d.ts +0 -5
- package/tag/utils.js +0 -6
- package/tag-close/index.d.ts +0 -12
- package/tag-close/index.js +0 -42
- package/tag-close/types.d.ts +0 -5
- /package/{dropdown-text-option → chip}/types.js +0 -0
- /package/{dropdown → color-menu}/types.js +0 -0
- /package/{select-option → color-swatch}/types.js +0 -0
- /package/{select → select-button}/types.js +0 -0
- /package/{tag-close → select-menu-option}/types.js +0 -0
|
@@ -1,68 +1,27 @@
|
|
|
1
|
-
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
|
-
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
|
-
|
|
4
|
-
var _$itemsSlot, _updateItems;
|
|
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
1
|
import '../icons/check';
|
|
11
2
|
import '../icons/error-outline';
|
|
12
3
|
import { clampNumber, defineCustomElement, getAttribute, getIntegerAttribute, NectaryElement, updateAttribute } from '../utils';
|
|
13
4
|
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{position:relative;display:flex;flex-direction:column;width:100%}#progress{position:absolute;height:1px;background-color:var(--sinch-color-snow-700);left:72px;right:72px;top:16px;transform:translateY(-50%)}#bar{position:absolute;height:1px;background-color:var(--sinch-color-stormy-400);left:0;top:0}</style><div id="wrapper"><slot></slot></div>';
|
|
14
5
|
const template = document.createElement('template');
|
|
15
6
|
template.innerHTML = templateHTML;
|
|
16
|
-
defineCustomElement('sinch-vertical-stepper',
|
|
7
|
+
defineCustomElement('sinch-vertical-stepper', class extends NectaryElement {
|
|
8
|
+
#$itemsSlot;
|
|
9
|
+
|
|
17
10
|
constructor() {
|
|
18
11
|
super();
|
|
19
|
-
|
|
20
|
-
_classPrivateFieldInitSpec(this, _$itemsSlot, {
|
|
21
|
-
writable: true,
|
|
22
|
-
value: void 0
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
_classPrivateFieldInitSpec(this, _updateItems, {
|
|
26
|
-
writable: true,
|
|
27
|
-
value: () => {
|
|
28
|
-
const $items = _classPrivateFieldGet(this, _$itemsSlot).assignedElements();
|
|
29
|
-
|
|
30
|
-
const activeIndex = clampNumber(getIntegerAttribute(this, 'index', 0), 0, $items.length + 1);
|
|
31
|
-
|
|
32
|
-
for (let i = 0; i < $items.length; i++) {
|
|
33
|
-
const $el = $items[i];
|
|
34
|
-
const itemIndex = i + 1;
|
|
35
|
-
$el.setAttribute('data-index', String(itemIndex));
|
|
36
|
-
|
|
37
|
-
if (itemIndex === activeIndex) {
|
|
38
|
-
$el.setAttribute('data-progress', 'active');
|
|
39
|
-
} else if (itemIndex < activeIndex) {
|
|
40
|
-
$el.setAttribute('data-progress', 'done');
|
|
41
|
-
} else {
|
|
42
|
-
$el.removeAttribute('data-progress');
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
this.setAttribute('aria-valuemax', String($items.length));
|
|
47
|
-
this.setAttribute('aria-valuenow', String(clampNumber(activeIndex, 0, $items.length)));
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
|
|
51
12
|
const shadowRoot = this.attachShadow();
|
|
52
13
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
53
|
-
|
|
54
|
-
_classPrivateFieldSet(this, _$itemsSlot, shadowRoot.querySelector('slot'));
|
|
14
|
+
this.#$itemsSlot = shadowRoot.querySelector('slot');
|
|
55
15
|
}
|
|
56
16
|
|
|
57
17
|
connectedCallback() {
|
|
58
18
|
this.setAttribute('role', 'progressbar');
|
|
59
19
|
this.setAttribute('aria-valuemin', '0');
|
|
60
|
-
|
|
61
|
-
_classPrivateFieldGet(this, _$itemsSlot).addEventListener('slotchange', _classPrivateFieldGet(this, _updateItems));
|
|
20
|
+
this.#$itemsSlot.addEventListener('slotchange', this.#updateItems);
|
|
62
21
|
}
|
|
63
22
|
|
|
64
23
|
disconnectedCallback() {
|
|
65
|
-
|
|
24
|
+
this.#$itemsSlot.removeEventListener('slotchange', this.#updateItems);
|
|
66
25
|
}
|
|
67
26
|
|
|
68
27
|
static get observedAttributes() {
|
|
@@ -77,8 +36,7 @@ defineCustomElement('sinch-vertical-stepper', (_$itemsSlot = new WeakMap(), _upd
|
|
|
77
36
|
switch (name) {
|
|
78
37
|
case 'index':
|
|
79
38
|
{
|
|
80
|
-
|
|
81
|
-
|
|
39
|
+
this.#updateItems();
|
|
82
40
|
break;
|
|
83
41
|
}
|
|
84
42
|
}
|
|
@@ -92,4 +50,25 @@ defineCustomElement('sinch-vertical-stepper', (_$itemsSlot = new WeakMap(), _upd
|
|
|
92
50
|
return getAttribute(this, 'index', '1');
|
|
93
51
|
}
|
|
94
52
|
|
|
95
|
-
|
|
53
|
+
#updateItems = () => {
|
|
54
|
+
const $items = this.#$itemsSlot.assignedElements();
|
|
55
|
+
const activeIndex = clampNumber(getIntegerAttribute(this, 'index', 0), 0, $items.length + 1);
|
|
56
|
+
|
|
57
|
+
for (let i = 0; i < $items.length; i++) {
|
|
58
|
+
const $el = $items[i];
|
|
59
|
+
const itemIndex = i + 1;
|
|
60
|
+
$el.setAttribute('data-index', String(itemIndex));
|
|
61
|
+
|
|
62
|
+
if (itemIndex === activeIndex) {
|
|
63
|
+
$el.setAttribute('data-progress', 'active');
|
|
64
|
+
} else if (itemIndex < activeIndex) {
|
|
65
|
+
$el.setAttribute('data-progress', 'done');
|
|
66
|
+
} else {
|
|
67
|
+
$el.removeAttribute('data-progress');
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
this.setAttribute('aria-valuemax', String($items.length));
|
|
72
|
+
this.setAttribute('aria-valuenow', String(clampNumber(activeIndex, 0, $items.length)));
|
|
73
|
+
};
|
|
74
|
+
});
|
|
@@ -1,46 +1,22 @@
|
|
|
1
|
-
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
|
-
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
|
-
|
|
4
|
-
var _$label, _$description, _$circleText;
|
|
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
1
|
import '../icons/check';
|
|
11
2
|
import '../icons/exclamation';
|
|
12
3
|
import { defineCustomElement, getAttribute, getLiteralAttribute, NectaryElement, updateAttribute, updateLiteralAttribute } from '../utils';
|
|
13
|
-
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{display:flex;flex-direction:column;position:relative;width:100%;min-height:68px}#circle-wrapper{display:flex;flex-direction:row;align-items:flex-start;gap:8px;min-width:0}#circle{display:flex;align-items:center;justify-content:center;width:32px;height:32px;background-color:var(--sinch-color-snow-700);font:var(--sinch-font-title-s);line-height:32px;text-align:center;color:var(--sinch-color-stormy-500);border:1px solid transparent;border-radius:50%;box-sizing:border-box;--sinch-icon
|
|
4
|
+
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{display:flex;flex-direction:column;position:relative;width:100%;min-height:68px}#circle-wrapper{display:flex;flex-direction:row;align-items:flex-start;gap:8px;min-width:0}#circle{display:flex;align-items:center;justify-content:center;width:32px;height:32px;background-color:var(--sinch-color-snow-700);font:var(--sinch-font-title-s);line-height:32px;text-align:center;color:var(--sinch-color-stormy-500);border:1px solid transparent;border-radius:50%;box-sizing:border-box;--sinch-size-icon:20px}#label-wrapper{margin-top:4px;min-width:0;flex:1}#label{font:var(--sinch-font-title-s);color:var(--sinch-color-stormy-500);overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#description{font:var(--sinch-font-text-xs);color:var(--sinch-color-stormy-300);overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#icon-error,#icon-success{display:none}#content{display:none;padding:16px 0 16px 40px}#progress{position:absolute;width:1px;left:16px;top:32px;bottom:0;background-color:var(--sinch-color-snow-700);transform:translateX(-50%)}#bar{position:absolute;width:1px;height:0;background-color:var(--sinch-color-stormy-400);left:0;top:0}:host(:last-of-type) #progress{display:none}:host([data-progress=active]) #content{display:block}:host([data-progress=active]) #circle{color:var(--sinch-color-snow-100);background-color:var(--sinch-color-stormy-400)}:host([data-progress=done]) #circle{border-color:var(--sinch-color-stormy-400)}:host([data-progress=done]:not([status])) #icon-success{display:block}:host([data-progress=done][status=error]) #circle{background-color:var(--sinch-color-error-200);border-color:var(--sinch-color-stormy-400)}:host([data-progress=done][status=error]) #icon-error{display:block}:host([data-progress=done]:not([status=skip])) #circle-text{display:none}:host([data-progress=done]) #bar{height:100%}</style><div id="wrapper"><div id="progress"><div id="bar"></div></div><div id="circle-wrapper"><div id="circle" aria-hidden="true"><sinch-icon-check id="icon-success"></sinch-icon-check><sinch-icon-exclamation id="icon-error"></sinch-icon-exclamation><span id="circle-text"></span></div><div id="label-wrapper"><div id="label"></div><div id="description"></div></div></div><div id="content"><slot></slot></div></div>';
|
|
14
5
|
import { statusValues } from './utils';
|
|
15
6
|
const template = document.createElement('template');
|
|
16
7
|
template.innerHTML = templateHTML;
|
|
17
|
-
defineCustomElement('sinch-vertical-stepper-item',
|
|
8
|
+
defineCustomElement('sinch-vertical-stepper-item', class extends NectaryElement {
|
|
9
|
+
#$label;
|
|
10
|
+
#$description;
|
|
11
|
+
#$circleText;
|
|
12
|
+
|
|
18
13
|
constructor() {
|
|
19
14
|
super();
|
|
20
|
-
|
|
21
|
-
_classPrivateFieldInitSpec(this, _$label, {
|
|
22
|
-
writable: true,
|
|
23
|
-
value: void 0
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
_classPrivateFieldInitSpec(this, _$description, {
|
|
27
|
-
writable: true,
|
|
28
|
-
value: void 0
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
_classPrivateFieldInitSpec(this, _$circleText, {
|
|
32
|
-
writable: true,
|
|
33
|
-
value: void 0
|
|
34
|
-
});
|
|
35
|
-
|
|
36
15
|
const shadowRoot = this.attachShadow();
|
|
37
16
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
_classPrivateFieldSet(this, _$description, shadowRoot.querySelector('#description'));
|
|
42
|
-
|
|
43
|
-
_classPrivateFieldSet(this, _$circleText, shadowRoot.querySelector('#circle-text'));
|
|
17
|
+
this.#$label = shadowRoot.querySelector('#label');
|
|
18
|
+
this.#$description = shadowRoot.querySelector('#description');
|
|
19
|
+
this.#$circleText = shadowRoot.querySelector('#circle-text');
|
|
44
20
|
}
|
|
45
21
|
|
|
46
22
|
connectedCallback() {}
|
|
@@ -55,19 +31,19 @@ defineCustomElement('sinch-vertical-stepper-item', (_$label = new WeakMap(), _$d
|
|
|
55
31
|
switch (name) {
|
|
56
32
|
case 'label':
|
|
57
33
|
{
|
|
58
|
-
|
|
34
|
+
this.#$label.textContent = newVal;
|
|
59
35
|
break;
|
|
60
36
|
}
|
|
61
37
|
|
|
62
38
|
case 'description':
|
|
63
39
|
{
|
|
64
|
-
|
|
40
|
+
this.#$description.textContent = newVal;
|
|
65
41
|
break;
|
|
66
42
|
}
|
|
67
43
|
|
|
68
44
|
case 'data-index':
|
|
69
45
|
{
|
|
70
|
-
|
|
46
|
+
this.#$circleText.textContent = newVal;
|
|
71
47
|
break;
|
|
72
48
|
}
|
|
73
49
|
}
|
|
@@ -97,4 +73,4 @@ defineCustomElement('sinch-vertical-stepper-item', (_$label = new WeakMap(), _$d
|
|
|
97
73
|
updateLiteralAttribute(this, statusValues, 'status', value);
|
|
98
74
|
}
|
|
99
75
|
|
|
100
|
-
})
|
|
76
|
+
});
|
package/dropdown/index.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import '../popover';
|
|
2
|
-
import type { TSinchDropdownElement, TSinchDropdownReact } from './types';
|
|
3
|
-
declare global {
|
|
4
|
-
namespace JSX {
|
|
5
|
-
interface IntrinsicElements {
|
|
6
|
-
'sinch-dropdown': TSinchDropdownReact;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
interface HTMLElementTagNameMap {
|
|
10
|
-
'sinch-dropdown': TSinchDropdownElement;
|
|
11
|
-
}
|
|
12
|
-
}
|
package/dropdown/index.js
DELETED
|
@@ -1,415 +0,0 @@
|
|
|
1
|
-
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
|
-
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
|
-
|
|
4
|
-
var _$optionSlot, _$listbox, _$popover, _onListboxClick, _onListboxKeyDown, _onOptionSlotChange, _onValueChange, _getFirstOption, _getLastOption, _getNextOption, _getPrevOption, _selectOption, _getOptionWithValue, _getOptionElements, _findSelectedOption, _getEnabledOptionElements, _dispatchChangeEvent, _onClose, _onCloseReactHandler, _onChangeReactHandler;
|
|
5
|
-
|
|
6
|
-
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
|
7
|
-
|
|
8
|
-
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
9
|
-
|
|
10
|
-
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
11
|
-
|
|
12
|
-
function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
|
|
13
|
-
|
|
14
|
-
import { orientationValues } from '../popover/utils';
|
|
15
|
-
import '../popover';
|
|
16
|
-
import { attrValueToPixels, defineCustomElement, getAttribute, getBooleanAttribute, getCsvSet, getFirstCsvValue, getIntegerAttribute, getLiteralAttribute, getReactEventHandler, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateCsv, updateIntegerAttribute, updateLiteralAttribute } from '../utils';
|
|
17
|
-
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0}#wrapper{width:100%;--sinch-popover-shape-radius:var(--sinch-shape-radius-s)}#listbox{overflow-y:auto}</style><sinch-popover id="wrapper" modal><slot name="target" slot="target"></slot><div id="listbox" slot="content"><slot name="option"></slot></div></sinch-popover>';
|
|
18
|
-
const ITEM_HEIGHT = 40;
|
|
19
|
-
const template = document.createElement('template');
|
|
20
|
-
template.innerHTML = templateHTML;
|
|
21
|
-
defineCustomElement('sinch-dropdown', (_$optionSlot = new WeakMap(), _$listbox = new WeakMap(), _$popover = new WeakMap(), _onListboxClick = new WeakMap(), _onListboxKeyDown = new WeakMap(), _onOptionSlotChange = new WeakMap(), _onValueChange = new WeakSet(), _getFirstOption = new WeakSet(), _getLastOption = new WeakSet(), _getNextOption = new WeakSet(), _getPrevOption = new WeakSet(), _selectOption = new WeakSet(), _getOptionWithValue = new WeakSet(), _getOptionElements = new WeakSet(), _findSelectedOption = new WeakSet(), _getEnabledOptionElements = new WeakSet(), _dispatchChangeEvent = new WeakSet(), _onClose = new WeakMap(), _onCloseReactHandler = new WeakMap(), _onChangeReactHandler = new WeakMap(), class extends NectaryElement {
|
|
22
|
-
constructor() {
|
|
23
|
-
super();
|
|
24
|
-
|
|
25
|
-
_classPrivateMethodInitSpec(this, _dispatchChangeEvent);
|
|
26
|
-
|
|
27
|
-
_classPrivateMethodInitSpec(this, _getEnabledOptionElements);
|
|
28
|
-
|
|
29
|
-
_classPrivateMethodInitSpec(this, _findSelectedOption);
|
|
30
|
-
|
|
31
|
-
_classPrivateMethodInitSpec(this, _getOptionElements);
|
|
32
|
-
|
|
33
|
-
_classPrivateMethodInitSpec(this, _getOptionWithValue);
|
|
34
|
-
|
|
35
|
-
_classPrivateMethodInitSpec(this, _selectOption);
|
|
36
|
-
|
|
37
|
-
_classPrivateMethodInitSpec(this, _getPrevOption);
|
|
38
|
-
|
|
39
|
-
_classPrivateMethodInitSpec(this, _getNextOption);
|
|
40
|
-
|
|
41
|
-
_classPrivateMethodInitSpec(this, _getLastOption);
|
|
42
|
-
|
|
43
|
-
_classPrivateMethodInitSpec(this, _getFirstOption);
|
|
44
|
-
|
|
45
|
-
_classPrivateMethodInitSpec(this, _onValueChange);
|
|
46
|
-
|
|
47
|
-
_classPrivateFieldInitSpec(this, _$optionSlot, {
|
|
48
|
-
writable: true,
|
|
49
|
-
value: void 0
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
_classPrivateFieldInitSpec(this, _$listbox, {
|
|
53
|
-
writable: true,
|
|
54
|
-
value: void 0
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
_classPrivateFieldInitSpec(this, _$popover, {
|
|
58
|
-
writable: true,
|
|
59
|
-
value: void 0
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
_classPrivateFieldInitSpec(this, _onListboxClick, {
|
|
63
|
-
writable: true,
|
|
64
|
-
value: e => {
|
|
65
|
-
const $elem = e.target;
|
|
66
|
-
|
|
67
|
-
if (getBooleanAttribute($elem, 'disabled')) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
e.stopPropagation();
|
|
72
|
-
|
|
73
|
-
_classPrivateMethodGet(this, _dispatchChangeEvent, _dispatchChangeEvent2).call(this, $elem);
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
_classPrivateFieldInitSpec(this, _onListboxKeyDown, {
|
|
78
|
-
writable: true,
|
|
79
|
-
value: e => {
|
|
80
|
-
switch (e.code) {
|
|
81
|
-
case 'Space':
|
|
82
|
-
case 'Enter':
|
|
83
|
-
{
|
|
84
|
-
const $option = _classPrivateMethodGet(this, _findSelectedOption, _findSelectedOption2).call(this, _classPrivateMethodGet(this, _getEnabledOptionElements, _getEnabledOptionElements2).call(this));
|
|
85
|
-
|
|
86
|
-
if ($option !== null) {
|
|
87
|
-
e.preventDefault();
|
|
88
|
-
|
|
89
|
-
_classPrivateMethodGet(this, _dispatchChangeEvent, _dispatchChangeEvent2).call(this, $option);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
break;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
case 'ArrowUp':
|
|
96
|
-
case 'ArrowLeft':
|
|
97
|
-
{
|
|
98
|
-
e.preventDefault();
|
|
99
|
-
|
|
100
|
-
_classPrivateMethodGet(this, _selectOption, _selectOption2).call(this, _classPrivateMethodGet(this, _getPrevOption, _getPrevOption2).call(this));
|
|
101
|
-
|
|
102
|
-
break;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
case 'ArrowDown':
|
|
106
|
-
case 'ArrowRight':
|
|
107
|
-
{
|
|
108
|
-
e.preventDefault();
|
|
109
|
-
|
|
110
|
-
_classPrivateMethodGet(this, _selectOption, _selectOption2).call(this, _classPrivateMethodGet(this, _getNextOption, _getNextOption2).call(this));
|
|
111
|
-
|
|
112
|
-
break;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
_classPrivateFieldInitSpec(this, _onOptionSlotChange, {
|
|
119
|
-
writable: true,
|
|
120
|
-
value: () => {
|
|
121
|
-
_classPrivateMethodGet(this, _onValueChange, _onValueChange2).call(this, this.value);
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
_classPrivateFieldInitSpec(this, _onClose, {
|
|
126
|
-
writable: true,
|
|
127
|
-
value: () => {
|
|
128
|
-
this.dispatchEvent(new CustomEvent('-close'));
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
_classPrivateFieldInitSpec(this, _onCloseReactHandler, {
|
|
133
|
-
writable: true,
|
|
134
|
-
value: e => {
|
|
135
|
-
getReactEventHandler(this, 'onClose')?.();
|
|
136
|
-
getReactEventHandler(this, 'on-close')?.(e);
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
_classPrivateFieldInitSpec(this, _onChangeReactHandler, {
|
|
141
|
-
writable: true,
|
|
142
|
-
value: e => {
|
|
143
|
-
getReactEventHandler(this, 'on-change')?.(e);
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
const shadowRoot = this.attachShadow();
|
|
148
|
-
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
149
|
-
|
|
150
|
-
_classPrivateFieldSet(this, _$optionSlot, shadowRoot.querySelector('slot[name="option"]'));
|
|
151
|
-
|
|
152
|
-
_classPrivateFieldSet(this, _$listbox, shadowRoot.querySelector('#listbox'));
|
|
153
|
-
|
|
154
|
-
_classPrivateFieldSet(this, _$popover, shadowRoot.querySelector('sinch-popover'));
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
connectedCallback() {
|
|
158
|
-
this.setAttribute('role', 'listbox');
|
|
159
|
-
|
|
160
|
-
_classPrivateFieldGet(this, _$optionSlot).addEventListener('slotchange', _classPrivateFieldGet(this, _onOptionSlotChange));
|
|
161
|
-
|
|
162
|
-
this.addEventListener('-close', _classPrivateFieldGet(this, _onCloseReactHandler));
|
|
163
|
-
this.addEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
disconnectedCallback() {
|
|
167
|
-
_classPrivateFieldGet(this, _$optionSlot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onOptionSlotChange));
|
|
168
|
-
|
|
169
|
-
this.removeEventListener('-close', _classPrivateFieldGet(this, _onCloseReactHandler));
|
|
170
|
-
this.removeEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
static get observedAttributes() {
|
|
174
|
-
return ['open', 'value', 'orientation', 'maxvisibleitems', 'multiple'];
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
get nodeName() {
|
|
178
|
-
return 'select';
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
set value(value) {
|
|
182
|
-
updateAttribute(this, 'value', value);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
get value() {
|
|
186
|
-
return getAttribute(this, 'value', '');
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
set maxVisibleItems(value) {
|
|
190
|
-
updateIntegerAttribute(this, 'maxvisibleitems', value);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
get maxVisibleItems() {
|
|
194
|
-
return getIntegerAttribute(this, 'maxvisibleitems', null);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
get orientation() {
|
|
198
|
-
return getLiteralAttribute(this, orientationValues, 'orientation', 'bottom-right');
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
set orientation(value) {
|
|
202
|
-
updateLiteralAttribute(this, orientationValues, 'orientation', value);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
set open(isOpen) {
|
|
206
|
-
updateBooleanAttribute(this, 'open', isOpen);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
get open() {
|
|
210
|
-
return getBooleanAttribute(this, 'open');
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
set multiple(isMultiple) {
|
|
214
|
-
updateBooleanAttribute(this, 'multiple', isMultiple);
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
get multiple() {
|
|
218
|
-
return getBooleanAttribute(this, 'multiple');
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
get dropdownRect() {
|
|
222
|
-
return _classPrivateFieldGet(this, _$popover).popoverRect;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
attributeChangedCallback(name, oldVal, newVal) {
|
|
226
|
-
if (oldVal === newVal) {
|
|
227
|
-
return;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
switch (name) {
|
|
231
|
-
case 'open':
|
|
232
|
-
{
|
|
233
|
-
updateAttribute(_classPrivateFieldGet(this, _$popover), 'open', newVal);
|
|
234
|
-
|
|
235
|
-
if (isAttrTrue(newVal)) {
|
|
236
|
-
_classPrivateMethodGet(this, _selectOption, _selectOption2).call(this, _classPrivateMethodGet(this, _getOptionWithValue, _getOptionWithValue2).call(this, getFirstCsvValue(this.value)) ?? _classPrivateMethodGet(this, _getFirstOption, _getFirstOption2).call(this));
|
|
237
|
-
|
|
238
|
-
_classPrivateFieldGet(this, _$popover).addEventListener('keydown', _classPrivateFieldGet(this, _onListboxKeyDown));
|
|
239
|
-
|
|
240
|
-
_classPrivateFieldGet(this, _$listbox).addEventListener('click', _classPrivateFieldGet(this, _onListboxClick));
|
|
241
|
-
|
|
242
|
-
_classPrivateFieldGet(this, _$popover).addEventListener('-close', _classPrivateFieldGet(this, _onClose));
|
|
243
|
-
} else {
|
|
244
|
-
_classPrivateFieldGet(this, _$popover).removeEventListener('keydown', _classPrivateFieldGet(this, _onListboxKeyDown));
|
|
245
|
-
|
|
246
|
-
_classPrivateFieldGet(this, _$listbox).removeEventListener('click', _classPrivateFieldGet(this, _onListboxClick));
|
|
247
|
-
|
|
248
|
-
_classPrivateFieldGet(this, _$popover).removeEventListener('-close', _classPrivateFieldGet(this, _onClose));
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
break;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
case 'multiple':
|
|
255
|
-
{
|
|
256
|
-
_classPrivateMethodGet(this, _onValueChange, _onValueChange2).call(this, this.value);
|
|
257
|
-
|
|
258
|
-
break;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
case 'orientation':
|
|
262
|
-
{
|
|
263
|
-
updateAttribute(_classPrivateFieldGet(this, _$popover), 'orientation', newVal);
|
|
264
|
-
break;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
case 'value':
|
|
268
|
-
{
|
|
269
|
-
_classPrivateMethodGet(this, _onValueChange, _onValueChange2).call(this, newVal ?? '');
|
|
270
|
-
|
|
271
|
-
break;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
case 'maxvisibleitems':
|
|
275
|
-
{
|
|
276
|
-
const $list = _classPrivateFieldGet(this, _$listbox);
|
|
277
|
-
|
|
278
|
-
if (newVal === '0') {
|
|
279
|
-
$list.style.maxHeight = 'unset';
|
|
280
|
-
} else {
|
|
281
|
-
$list.style.maxHeight = attrValueToPixels(newVal, {
|
|
282
|
-
min: 2,
|
|
283
|
-
multiplier: ITEM_HEIGHT
|
|
284
|
-
});
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
break;
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
}));
|
|
293
|
-
|
|
294
|
-
function _onValueChange2(csv) {
|
|
295
|
-
if (this.multiple) {
|
|
296
|
-
const values = getCsvSet(csv);
|
|
297
|
-
|
|
298
|
-
for (const $option of _classPrivateMethodGet(this, _getOptionElements, _getOptionElements2).call(this)) {
|
|
299
|
-
const isChecked = !getBooleanAttribute($option, 'disabled') && values.has(getAttribute($option, 'value', ''));
|
|
300
|
-
updateBooleanAttribute($option, 'data-checked', isChecked);
|
|
301
|
-
}
|
|
302
|
-
} else {
|
|
303
|
-
const value = getFirstCsvValue(csv);
|
|
304
|
-
|
|
305
|
-
for (const $option of _classPrivateMethodGet(this, _getOptionElements, _getOptionElements2).call(this)) {
|
|
306
|
-
const isChecked = !getBooleanAttribute($option, 'disabled') && value === getAttribute($option, 'value', '');
|
|
307
|
-
updateBooleanAttribute($option, 'data-checked', isChecked);
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
function _getFirstOption2() {
|
|
313
|
-
return _classPrivateMethodGet(this, _getEnabledOptionElements, _getEnabledOptionElements2).call(this)[0] ?? null;
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
function _getLastOption2() {
|
|
317
|
-
return _classPrivateMethodGet(this, _getEnabledOptionElements, _getEnabledOptionElements2).call(this).reverse()[0] ?? null;
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
function _getNextOption2() {
|
|
321
|
-
const $options = _classPrivateMethodGet(this, _getEnabledOptionElements, _getEnabledOptionElements2).call(this);
|
|
322
|
-
|
|
323
|
-
const $selectedOption = _classPrivateMethodGet(this, _findSelectedOption, _findSelectedOption2).call(this, $options);
|
|
324
|
-
|
|
325
|
-
const currentIndex = $selectedOption !== null ? $options.indexOf($selectedOption) : -1;
|
|
326
|
-
|
|
327
|
-
if (currentIndex < 0) {
|
|
328
|
-
return _classPrivateMethodGet(this, _getFirstOption, _getFirstOption2).call(this);
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
return $options[(currentIndex + 1) % $options.length];
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
function _getPrevOption2() {
|
|
335
|
-
const $options = _classPrivateMethodGet(this, _getEnabledOptionElements, _getEnabledOptionElements2).call(this);
|
|
336
|
-
|
|
337
|
-
const $selectedOption = _classPrivateMethodGet(this, _findSelectedOption, _findSelectedOption2).call(this, $options);
|
|
338
|
-
|
|
339
|
-
const currentIndex = $selectedOption !== null ? $options.indexOf($selectedOption) : -1;
|
|
340
|
-
|
|
341
|
-
if (currentIndex < 0) {
|
|
342
|
-
return _classPrivateMethodGet(this, _getLastOption, _getLastOption2).call(this);
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
return $options[(currentIndex - 1 + $options.length) % $options.length];
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
function _selectOption2($option) {
|
|
349
|
-
const hasMaxVisibleItems = this.hasAttribute('maxvisibleitems');
|
|
350
|
-
|
|
351
|
-
for (const $op of _classPrivateMethodGet(this, _getOptionElements, _getOptionElements2).call(this)) {
|
|
352
|
-
const isSelected = $op === $option;
|
|
353
|
-
updateBooleanAttribute($op, 'data-selected', isSelected);
|
|
354
|
-
|
|
355
|
-
if (isSelected && hasMaxVisibleItems) {
|
|
356
|
-
$op.scrollIntoView?.({
|
|
357
|
-
block: 'nearest'
|
|
358
|
-
});
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
function _getOptionWithValue2(value) {
|
|
364
|
-
if (value === null) {
|
|
365
|
-
return null;
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
for (const $option of _classPrivateMethodGet(this, _getOptionElements, _getOptionElements2).call(this)) {
|
|
369
|
-
if ($option.disabled !== true && $option.value === value) {
|
|
370
|
-
return $option;
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
return null;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
function _getOptionElements2() {
|
|
378
|
-
let $elements = _classPrivateFieldGet(this, _$optionSlot).assignedElements();
|
|
379
|
-
|
|
380
|
-
if ($elements.length === 1 && $elements[0].tagName === 'SLOT') {
|
|
381
|
-
$elements = $elements[0].assignedElements();
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
return $elements;
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
function _findSelectedOption2(elements) {
|
|
388
|
-
for (const el of elements) {
|
|
389
|
-
if (getBooleanAttribute(el, 'data-selected')) {
|
|
390
|
-
return el;
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
return null;
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
function _getEnabledOptionElements2() {
|
|
398
|
-
return _classPrivateMethodGet(this, _getOptionElements, _getOptionElements2).call(this).filter(opt => opt.disabled !== true);
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
function _dispatchChangeEvent2($opt) {
|
|
402
|
-
if ($opt === null) {
|
|
403
|
-
return;
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
const value = $opt.value;
|
|
407
|
-
const result = this.multiple ? updateCsv(this.value, value, !getBooleanAttribute($opt, 'data-checked')) : value;
|
|
408
|
-
this.dispatchEvent(new CustomEvent('change', {
|
|
409
|
-
detail: result,
|
|
410
|
-
bubbles: true
|
|
411
|
-
}));
|
|
412
|
-
this.dispatchEvent(new CustomEvent('-change', {
|
|
413
|
-
detail: result
|
|
414
|
-
}));
|
|
415
|
-
}
|
package/dropdown/types.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { TSinchPopoverOrientation } from '../popover/types';
|
|
2
|
-
import type { TRect, TSinchElementReact } from '../types';
|
|
3
|
-
import type { SyntheticEvent } from 'react';
|
|
4
|
-
export declare type TSinchDropdownElement = HTMLElement & {
|
|
5
|
-
open: boolean;
|
|
6
|
-
multiple: boolean;
|
|
7
|
-
orientation: TSinchPopoverOrientation;
|
|
8
|
-
value: string;
|
|
9
|
-
maxVisibleItems: number | null;
|
|
10
|
-
readonly dropdownRect: TRect;
|
|
11
|
-
addEventListener(type: '-change', listener: (e: CustomEvent<string>) => void): void;
|
|
12
|
-
addEventListener(type: '-close', listener: (e: CustomEvent<void>) => void): void;
|
|
13
|
-
setAttribute(name: 'open', value: ''): void;
|
|
14
|
-
setAttribute(name: 'multiple', value: ''): void;
|
|
15
|
-
setAttribute(name: 'orientation', value: TSinchPopoverOrientation): void;
|
|
16
|
-
setAttribute(name: 'value', value: string): void;
|
|
17
|
-
setAttribute(name: 'maxvisibleitems', value: string): void;
|
|
18
|
-
};
|
|
19
|
-
export declare type TSinchDropdownReact = TSinchElementReact<TSinchDropdownElement> & {
|
|
20
|
-
open: boolean;
|
|
21
|
-
multiple?: boolean;
|
|
22
|
-
orientation?: TSinchPopoverOrientation;
|
|
23
|
-
value: string;
|
|
24
|
-
maxVisibleItems?: number;
|
|
25
|
-
'aria-label': string;
|
|
26
|
-
/** @deprecated */
|
|
27
|
-
onClose?: () => void;
|
|
28
|
-
'on-close'?: (e: CustomEvent<void>) => void;
|
|
29
|
-
/** @deprecated */
|
|
30
|
-
onChange?: (e: SyntheticEvent<TSinchDropdownElement, CustomEvent<string>>) => void;
|
|
31
|
-
'on-change'?: (e: CustomEvent<string>) => void;
|
|
32
|
-
};
|