@nectary/components 0.9.0 → 0.10.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 +5 -1
- package/accordion-item/index.js +7 -7
- package/alert/index.js +2 -2
- package/alert-button/index.js +1 -1
- package/alert-close/index.js +2 -2
- package/button/index.d.ts +2 -1
- package/button/index.js +7 -3
- package/checkbox/index.d.ts +3 -0
- package/checkbox/index.js +27 -18
- package/dropdown/index.d.ts +34 -0
- package/dropdown/index.js +451 -0
- package/dropdown-option/index.d.ts +44 -0
- package/dropdown-option/index.js +116 -0
- package/help-tooltip/index.js +5 -1
- package/icon/cancel/index.js +1 -1
- package/icon/close/index.js +1 -1
- package/icon/create-icon-class.js +1 -1
- package/icon/east/index.js +1 -1
- package/icon/help-outline/index.js +1 -1
- package/icon/more-horiz/index.js +1 -1
- package/icon/more-vert/index.js +1 -1
- package/icon/north/index.js +1 -1
- package/icon/north-east/index.js +1 -1
- package/icon/north-west/index.js +1 -1
- package/icon/open-in-new/index.js +1 -1
- package/icon/south/index.js +1 -1
- package/icon/south-east/index.js +1 -1
- package/icon/south-west/index.js +1 -1
- package/icon/west/index.js +1 -1
- package/icon-branded/barchart-down/index.js +1 -1
- package/icon-branded/barchart-up/index.js +1 -1
- package/icon-branded/campaigns/index.js +1 -1
- package/icon-branded/chatbot/index.js +1 -1
- package/icon-branded/contact/index.js +1 -1
- package/icon-branded/create-icon-class.js +1 -1
- package/icon-branded/home/index.js +1 -1
- package/icon-branded/multiple-channels/index.js +1 -1
- package/icon-branded/rocket/index.js +1 -1
- package/icon-branded/settings/index.js +1 -1
- package/icon-branded/user/index.js +1 -1
- package/icon-branded/users/index.js +1 -1
- package/index.d.ts +2 -0
- package/index.js +2 -0
- package/input/index.d.ts +3 -1
- package/input/index.js +59 -11
- package/link/index.js +2 -2
- package/logo/create-logo-class.js +1 -1
- package/logo/sinch-icon/index.js +1 -1
- package/logo/sinch-icon-wordmark/index.js +1 -1
- package/package.json +1 -1
- package/pagination/index.js +1 -6
- package/radio/index.d.ts +1 -0
- package/radio/index.js +97 -71
- package/radio-option/index.d.ts +1 -0
- package/radio-option/index.js +4 -1
- package/select/index.d.ts +4 -1
- package/select/index.js +72 -265
- package/select-option/index.d.ts +3 -17
- package/select-option/index.js +4 -103
- package/spinner/index.js +1 -1
- package/table/index.js +1 -1
- package/table-body/index.js +1 -1
- package/table-cell/index.js +1 -1
- package/table-head/index.js +1 -1
- package/table-head-cell/index.js +3 -2
- package/table-head-sort/index.d.ts +1 -0
- package/table-head-sort/index.js +3 -1
- package/table-row/index.js +1 -1
- package/tabs/index.d.ts +1 -0
- package/tabs/index.js +96 -66
- package/tabs-option/index.d.ts +1 -0
- package/tabs-option/index.js +4 -2
- package/tag/index.js +1 -1
- package/tag-close/index.js +2 -2
- package/textarea/index.d.ts +3 -1
- package/textarea/index.js +58 -11
- package/theme.css +3 -0
- package/toggle/index.d.ts +1 -0
- package/toggle/index.js +4 -5
- package/tooltip/index.d.ts +2 -1
- package/tooltip/index.js +7 -3
- package/types.d.ts +7 -0
- package/utils.d.ts +3 -0
- package/utils.js +17 -0
package/radio/index.js
CHANGED
|
@@ -1,73 +1,43 @@
|
|
|
1
1
|
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
2
2
|
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
3
3
|
|
|
4
|
-
var _$slot, _onOptionKeyDown, _onSlotChange, _onOptionChange;
|
|
4
|
+
var _$slot, _onOptionKeyDown, _onSlotChange, _onOptionChange, _onValueChange, _dispatchChangeEvent, _getFirstOption, _getLastOption, _getNextOption, _getPrevOption, _getEnabledRadioElements;
|
|
5
|
+
|
|
6
|
+
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
|
5
7
|
|
|
6
8
|
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
7
9
|
|
|
8
10
|
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
9
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
|
+
|
|
10
14
|
import { isRadioOptionElement } from '../radio-option';
|
|
11
15
|
import { defineCustomElement, getAttribute, updateAttribute } from '../utils';
|
|
12
16
|
const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-direction:column;gap:8px;box-sizing:border-box;width:100%}</style><div id="wrapper"><slot></slot></div>';
|
|
13
17
|
|
|
14
|
-
const getEnabledRadioElements = $slot => {
|
|
15
|
-
return $slot.assignedElements().filter(opt => isRadioOptionElement(opt) && opt.disabled !== true);
|
|
16
|
-
};
|
|
17
|
-
|
|
18
18
|
const findSelectedOption = elements => {
|
|
19
19
|
return elements.find(el => el.checked) ?? null;
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return null;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const getLastOption = $slot => {
|
|
33
|
-
for (const $option of $slot.assignedElements().reverse()) {
|
|
34
|
-
if (isRadioOptionElement($option) && $option.disabled !== true) {
|
|
35
|
-
return $option;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return null;
|
|
40
|
-
};
|
|
22
|
+
const template = document.createElement('template');
|
|
23
|
+
template.innerHTML = templateHTML;
|
|
24
|
+
defineCustomElement('sinch-radio', (_$slot = new WeakMap(), _onOptionKeyDown = new WeakMap(), _onSlotChange = new WeakMap(), _onOptionChange = new WeakMap(), _onValueChange = new WeakSet(), _dispatchChangeEvent = new WeakSet(), _getFirstOption = new WeakSet(), _getLastOption = new WeakSet(), _getNextOption = new WeakSet(), _getPrevOption = new WeakSet(), _getEnabledRadioElements = new WeakSet(), class extends HTMLElement {
|
|
25
|
+
constructor() {
|
|
26
|
+
super();
|
|
41
27
|
|
|
42
|
-
|
|
43
|
-
const $options = getEnabledRadioElements($slot);
|
|
44
|
-
const $selectedOption = findSelectedOption($options);
|
|
45
|
-
const currentIndex = $selectedOption !== null ? $options.indexOf($selectedOption) : -1;
|
|
28
|
+
_classPrivateMethodInitSpec(this, _getEnabledRadioElements);
|
|
46
29
|
|
|
47
|
-
|
|
48
|
-
return getFirstOption($slot);
|
|
49
|
-
}
|
|
30
|
+
_classPrivateMethodInitSpec(this, _getPrevOption);
|
|
50
31
|
|
|
51
|
-
|
|
52
|
-
};
|
|
32
|
+
_classPrivateMethodInitSpec(this, _getNextOption);
|
|
53
33
|
|
|
54
|
-
|
|
55
|
-
const $options = getEnabledRadioElements($slot);
|
|
56
|
-
const $selectedOption = findSelectedOption($options);
|
|
57
|
-
const currentIndex = $selectedOption !== null ? $options.indexOf($selectedOption) : -1;
|
|
34
|
+
_classPrivateMethodInitSpec(this, _getLastOption);
|
|
58
35
|
|
|
59
|
-
|
|
60
|
-
return getLastOption($slot);
|
|
61
|
-
}
|
|
36
|
+
_classPrivateMethodInitSpec(this, _getFirstOption);
|
|
62
37
|
|
|
63
|
-
|
|
64
|
-
};
|
|
38
|
+
_classPrivateMethodInitSpec(this, _dispatchChangeEvent);
|
|
65
39
|
|
|
66
|
-
|
|
67
|
-
template.innerHTML = templateHTML;
|
|
68
|
-
defineCustomElement('sinch-radio', (_$slot = new WeakMap(), _onOptionKeyDown = new WeakMap(), _onSlotChange = new WeakMap(), _onOptionChange = new WeakMap(), class extends HTMLElement {
|
|
69
|
-
constructor() {
|
|
70
|
-
super();
|
|
40
|
+
_classPrivateMethodInitSpec(this, _onValueChange);
|
|
71
41
|
|
|
72
42
|
_classPrivateFieldInitSpec(this, _$slot, {
|
|
73
43
|
writable: true,
|
|
@@ -82,11 +52,13 @@ defineCustomElement('sinch-radio', (_$slot = new WeakMap(), _onOptionKeyDown = n
|
|
|
82
52
|
case 'ArrowLeft':
|
|
83
53
|
{
|
|
84
54
|
e.preventDefault();
|
|
85
|
-
|
|
55
|
+
|
|
56
|
+
const $option = _classPrivateMethodGet(this, _getPrevOption, _getPrevOption2).call(this);
|
|
86
57
|
|
|
87
58
|
if ($option !== null) {
|
|
88
59
|
$option.focus();
|
|
89
|
-
|
|
60
|
+
|
|
61
|
+
_classPrivateMethodGet(this, _dispatchChangeEvent, _dispatchChangeEvent2).call(this, $option.value);
|
|
90
62
|
}
|
|
91
63
|
|
|
92
64
|
break;
|
|
@@ -96,11 +68,13 @@ defineCustomElement('sinch-radio', (_$slot = new WeakMap(), _onOptionKeyDown = n
|
|
|
96
68
|
case 'ArrowRight':
|
|
97
69
|
{
|
|
98
70
|
e.preventDefault();
|
|
99
|
-
|
|
71
|
+
|
|
72
|
+
const $option = _classPrivateMethodGet(this, _getNextOption, _getNextOption2).call(this);
|
|
100
73
|
|
|
101
74
|
if ($option !== null) {
|
|
102
75
|
$option.focus();
|
|
103
|
-
|
|
76
|
+
|
|
77
|
+
_classPrivateMethodGet(this, _dispatchChangeEvent, _dispatchChangeEvent2).call(this, $option.value);
|
|
104
78
|
}
|
|
105
79
|
|
|
106
80
|
break;
|
|
@@ -112,7 +86,7 @@ defineCustomElement('sinch-radio', (_$slot = new WeakMap(), _onOptionKeyDown = n
|
|
|
112
86
|
_classPrivateFieldInitSpec(this, _onSlotChange, {
|
|
113
87
|
writable: true,
|
|
114
88
|
value: () => {
|
|
115
|
-
this.
|
|
89
|
+
_classPrivateMethodGet(this, _onValueChange, _onValueChange2).call(this, this.value);
|
|
116
90
|
}
|
|
117
91
|
});
|
|
118
92
|
|
|
@@ -120,12 +94,13 @@ defineCustomElement('sinch-radio', (_$slot = new WeakMap(), _onOptionKeyDown = n
|
|
|
120
94
|
writable: true,
|
|
121
95
|
value: e => {
|
|
122
96
|
e.stopPropagation();
|
|
123
|
-
|
|
97
|
+
|
|
98
|
+
_classPrivateMethodGet(this, _dispatchChangeEvent, _dispatchChangeEvent2).call(this, e.detail);
|
|
124
99
|
}
|
|
125
100
|
});
|
|
126
101
|
|
|
127
102
|
const shadowRoot = this.attachShadow({
|
|
128
|
-
mode: '
|
|
103
|
+
mode: 'closed',
|
|
129
104
|
delegatesFocus: true
|
|
130
105
|
});
|
|
131
106
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
@@ -137,16 +112,16 @@ defineCustomElement('sinch-radio', (_$slot = new WeakMap(), _onOptionKeyDown = n
|
|
|
137
112
|
_classPrivateFieldGet(this, _$slot).addEventListener('slotchange', _classPrivateFieldGet(this, _onSlotChange));
|
|
138
113
|
}
|
|
139
114
|
|
|
140
|
-
|
|
141
|
-
|
|
115
|
+
connectedCallback() {
|
|
116
|
+
this.setAttribute('role', 'radiogroup');
|
|
142
117
|
}
|
|
143
118
|
|
|
144
|
-
get
|
|
145
|
-
return '
|
|
119
|
+
static get observedAttributes() {
|
|
120
|
+
return ['value'];
|
|
146
121
|
}
|
|
147
122
|
|
|
148
123
|
get nodeName() {
|
|
149
|
-
return '
|
|
124
|
+
return 'select';
|
|
150
125
|
}
|
|
151
126
|
|
|
152
127
|
set value(value) {
|
|
@@ -161,25 +136,76 @@ defineCustomElement('sinch-radio', (_$slot = new WeakMap(), _onOptionKeyDown = n
|
|
|
161
136
|
switch (name) {
|
|
162
137
|
case 'value':
|
|
163
138
|
{
|
|
164
|
-
this.
|
|
139
|
+
_classPrivateMethodGet(this, _onValueChange, _onValueChange2).call(this, newVal ?? '');
|
|
140
|
+
|
|
165
141
|
break;
|
|
166
142
|
}
|
|
167
143
|
}
|
|
168
144
|
}
|
|
169
145
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
146
|
+
}));
|
|
147
|
+
|
|
148
|
+
function _onValueChange2(value) {
|
|
149
|
+
for (const $option of _classPrivateFieldGet(this, _$slot).assignedElements()) {
|
|
150
|
+
if (isRadioOptionElement($option)) {
|
|
151
|
+
$option.checked = $option.disabled !== true && $option.value === value;
|
|
175
152
|
}
|
|
176
153
|
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function _dispatchChangeEvent2(value) {
|
|
157
|
+
this.dispatchEvent(new CustomEvent('change', {
|
|
158
|
+
detail: value,
|
|
159
|
+
bubbles: true
|
|
160
|
+
}));
|
|
161
|
+
}
|
|
177
162
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
}
|
|
163
|
+
function _getFirstOption2() {
|
|
164
|
+
for (const $option of _classPrivateFieldGet(this, _$slot).assignedElements()) {
|
|
165
|
+
if (isRadioOptionElement($option) && $option.disabled !== true) {
|
|
166
|
+
return $option;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function _getLastOption2() {
|
|
174
|
+
for (const $option of _classPrivateFieldGet(this, _$slot).assignedElements().reverse()) {
|
|
175
|
+
if (isRadioOptionElement($option) && $option.disabled !== true) {
|
|
176
|
+
return $option;
|
|
177
|
+
}
|
|
183
178
|
}
|
|
184
179
|
|
|
185
|
-
|
|
180
|
+
return null;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function _getNextOption2() {
|
|
184
|
+
const $options = _classPrivateMethodGet(this, _getEnabledRadioElements, _getEnabledRadioElements2).call(this);
|
|
185
|
+
|
|
186
|
+
const $selectedOption = findSelectedOption($options);
|
|
187
|
+
const currentIndex = $selectedOption !== null ? $options.indexOf($selectedOption) : -1;
|
|
188
|
+
|
|
189
|
+
if (currentIndex < 0) {
|
|
190
|
+
return _classPrivateMethodGet(this, _getFirstOption, _getFirstOption2).call(this);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
return $options[(currentIndex + 1) % $options.length];
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function _getPrevOption2() {
|
|
197
|
+
const $options = _classPrivateMethodGet(this, _getEnabledRadioElements, _getEnabledRadioElements2).call(this);
|
|
198
|
+
|
|
199
|
+
const $selectedOption = findSelectedOption($options);
|
|
200
|
+
const currentIndex = $selectedOption !== null ? $options.indexOf($selectedOption) : -1;
|
|
201
|
+
|
|
202
|
+
if (currentIndex < 0) {
|
|
203
|
+
return _classPrivateMethodGet(this, _getLastOption, _getLastOption2).call(this);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
return $options[(currentIndex - 1 + $options.length) % $options.length];
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function _getEnabledRadioElements2() {
|
|
210
|
+
return _classPrivateFieldGet(this, _$slot).assignedElements().filter(opt => isRadioOptionElement(opt) && opt.disabled !== true);
|
|
211
|
+
}
|
package/radio-option/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export declare type TSinchRadioOptionReact = TSinchElementReact<TSinchRadioOptio
|
|
|
13
13
|
value: string;
|
|
14
14
|
disabled?: boolean;
|
|
15
15
|
text: string;
|
|
16
|
+
'aria-label': string;
|
|
16
17
|
onFocus?: (e: FocusEvent<TSinchRadioOptionElement>) => void;
|
|
17
18
|
onBlur?: (e: FocusEvent<TSinchRadioOptionElement>) => void;
|
|
18
19
|
};
|
package/radio-option/index.js
CHANGED
|
@@ -41,7 +41,7 @@ defineCustomElement('sinch-radio-option', (_$input = new WeakMap(), _$label = ne
|
|
|
41
41
|
});
|
|
42
42
|
|
|
43
43
|
const shadowRoot = this.attachShadow({
|
|
44
|
-
mode: '
|
|
44
|
+
mode: 'closed',
|
|
45
45
|
delegatesFocus: true
|
|
46
46
|
});
|
|
47
47
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
@@ -52,6 +52,8 @@ defineCustomElement('sinch-radio-option', (_$input = new WeakMap(), _$label = ne
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
connectedCallback() {
|
|
55
|
+
this.setAttribute('role', 'radio');
|
|
56
|
+
|
|
55
57
|
_classPrivateFieldGet(this, _$input).addEventListener('input', _classPrivateFieldGet(this, _onInput));
|
|
56
58
|
}
|
|
57
59
|
|
|
@@ -106,6 +108,7 @@ defineCustomElement('sinch-radio-option', (_$input = new WeakMap(), _$label = ne
|
|
|
106
108
|
case 'checked':
|
|
107
109
|
{
|
|
108
110
|
_classPrivateFieldGet(this, _$input).checked = isAttrTrue(newVal);
|
|
111
|
+
updateAttribute(this, 'aria-checked', isAttrTrue(newVal));
|
|
109
112
|
break;
|
|
110
113
|
}
|
|
111
114
|
|
package/select/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import '../select-option';
|
|
2
|
+
import type { TRect, TSinchElementReact } from '../types';
|
|
2
3
|
import type { FocusEvent, SyntheticEvent } from 'react';
|
|
3
4
|
export declare type TSinchSelectElement = HTMLElement & {
|
|
4
5
|
value: string;
|
|
@@ -9,6 +10,7 @@ export declare type TSinchSelectElement = HTMLElement & {
|
|
|
9
10
|
additionalText: string | null;
|
|
10
11
|
disabled: boolean;
|
|
11
12
|
maxVisibleItems: number | null;
|
|
13
|
+
readonly dropdownRect: TRect;
|
|
12
14
|
focus(): void;
|
|
13
15
|
blur(): void;
|
|
14
16
|
};
|
|
@@ -21,6 +23,7 @@ export declare type TSinchSelectReact = TSinchElementReact<TSinchSelectElement>
|
|
|
21
23
|
additionalText?: string;
|
|
22
24
|
disabled?: boolean;
|
|
23
25
|
maxVisibleItems?: number;
|
|
26
|
+
'aria-label': string;
|
|
24
27
|
onChange: (e: SyntheticEvent<TSinchSelectElement, CustomEvent<string>>) => void;
|
|
25
28
|
onFocus?: (e: FocusEvent<TSinchSelectElement>) => void;
|
|
26
29
|
onBlur?: (e: FocusEvent<TSinchSelectElement>) => void;
|