@nectary/components 0.34.0 → 0.35.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 +35 -10
- package/accordion/types.d.ts +3 -2
- package/accordion-item/index.js +8 -4
- package/action-menu/index.js +7 -8
- package/action-menu/types.d.ts +3 -3
- package/action-menu-option/index.js +23 -3
- package/action-menu-option/types.d.ts +2 -0
- package/alert/index.js +1 -1
- package/avatar/index.js +1 -1
- package/button/index.js +68 -4
- package/button/types.d.ts +6 -0
- package/checkbox/index.js +64 -6
- package/checkbox/types.d.ts +8 -2
- package/date-picker/index.js +37 -12
- package/date-picker/types.d.ts +4 -2
- package/dialog/index.js +5 -6
- package/dialog/types.d.ts +3 -3
- package/dropdown/index.js +44 -28
- package/dropdown/types.d.ts +6 -4
- package/dropdown-checkbox-option/index.js +1 -1
- package/dropdown-checkbox-option/types.d.ts +0 -2
- package/dropdown-radio-option/index.js +1 -1
- package/dropdown-radio-option/types.d.ts +0 -2
- package/dropdown-text-option/index.js +1 -1
- package/dropdown-text-option/types.d.ts +0 -2
- package/horizontal-stepper-item/index.js +1 -1
- package/icon-button/index.js +67 -3
- package/icon-button/types.d.ts +6 -0
- package/icons/create-icon-class.js +1 -1
- package/icons-branded/create-icon-class.js +3 -7
- package/icons-branded/types.d.ts +3 -0
- package/icons-channel/create-icon-class.js +3 -7
- package/icons-channel/types.d.ts +3 -0
- package/input/index.d.ts +0 -1
- package/input/index.js +58 -5
- package/input/types.d.ts +8 -2
- package/link/index.js +81 -3
- package/link/types.d.ts +9 -0
- package/package.json +1 -1
- package/pagination/index.js +24 -8
- package/pagination/types.d.ts +3 -1
- package/popover/index.js +5 -6
- package/popover/types.d.ts +4 -3
- package/radio/index.js +36 -8
- package/radio/types.d.ts +3 -1
- package/radio-option/index.js +1 -1
- package/search/types.d.ts +0 -1
- package/segment-collapse/index.js +28 -12
- package/segment-collapse/types.d.ts +3 -1
- package/segmented-control/index.js +28 -23
- package/segmented-control/types.d.ts +3 -2
- package/segmented-control-option/index.js +59 -13
- package/segmented-control-option/types.d.ts +4 -0
- package/segmented-icon-control/index.js +27 -16
- package/segmented-icon-control/types.d.ts +5 -2
- package/segmented-icon-control-option/index.js +54 -12
- package/segmented-icon-control-option/types.d.ts +4 -0
- package/select/index.js +68 -9
- package/select/types.d.ts +8 -2
- package/tabs/index.js +32 -8
- package/tabs/types.d.ts +3 -2
- package/tabs-option/index.js +2 -2
- package/textarea/index.js +58 -4
- package/textarea/types.d.ts +7 -2
- package/tile-control/index.d.ts +11 -0
- package/tile-control/index.js +181 -0
- package/tile-control/types.d.ts +38 -0
- package/tile-control/types.js +1 -0
- package/tile-control-option/index.d.ts +11 -0
- package/tile-control-option/index.js +161 -0
- package/tile-control-option/types.d.ts +37 -0
- package/tile-control-option/types.js +1 -0
- package/time-picker/index.js +17 -3
- package/time-picker/types.d.ts +4 -2
- package/toggle/index.js +63 -5
- package/toggle/types.d.ts +3 -1
|
@@ -3,6 +3,8 @@ export declare type TSinchSegmentedControlOptionElement = HTMLElement & {
|
|
|
3
3
|
value: string;
|
|
4
4
|
disabled: boolean;
|
|
5
5
|
text: string;
|
|
6
|
+
addEventListener(type: '-focus', listener: (e: CustomEvent<void>) => void): void;
|
|
7
|
+
addEventListener(type: '-blur', listener: (e: CustomEvent<void>) => void): void;
|
|
6
8
|
setAttribute(name: 'value', value: string): void;
|
|
7
9
|
setAttribute(name: 'text', value: string): void;
|
|
8
10
|
setAttribute(name: 'disabled', value: ''): void;
|
|
@@ -12,4 +14,6 @@ export declare type TSinchSegmentedControlOptionReact = TSinchElementReact<TSinc
|
|
|
12
14
|
text: string;
|
|
13
15
|
disabled?: boolean;
|
|
14
16
|
'aria-label': string;
|
|
17
|
+
'on-focus'?: (e: CustomEvent<void>) => void;
|
|
18
|
+
'on-blur'?: (e: CustomEvent<void>) => void;
|
|
15
19
|
};
|
|
@@ -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 _$slot,
|
|
4
|
+
var _$slot, _onSlotChange, _onOptionChange, _onValueChange, _onChangeReactHandler;
|
|
5
5
|
|
|
6
6
|
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
|
7
7
|
|
|
@@ -11,11 +11,11 @@ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollect
|
|
|
11
11
|
|
|
12
12
|
function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
|
|
13
13
|
|
|
14
|
-
import { defineCustomElement, getAttribute, getBooleanAttribute, getCsvSet, getFirstCsvValue, NectaryElement, updateAttribute, updateBooleanAttribute, updateCsv } from '../utils';
|
|
14
|
+
import { defineCustomElement, getAttribute, getBooleanAttribute, getCsvSet, getFirstCsvValue, getReactEventHandler, NectaryElement, updateAttribute, updateBooleanAttribute, updateCsv } from '../utils';
|
|
15
15
|
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{display:flex;flex-direction:row}</style><div id="wrapper"><slot></slot></div>';
|
|
16
16
|
const template = document.createElement('template');
|
|
17
17
|
template.innerHTML = templateHTML;
|
|
18
|
-
defineCustomElement('sinch-segmented-icon-control', (_$slot = new WeakMap(),
|
|
18
|
+
defineCustomElement('sinch-segmented-icon-control', (_$slot = new WeakMap(), _onSlotChange = new WeakMap(), _onOptionChange = new WeakMap(), _onValueChange = new WeakSet(), _onChangeReactHandler = new WeakMap(), class extends NectaryElement {
|
|
19
19
|
constructor() {
|
|
20
20
|
super();
|
|
21
21
|
|
|
@@ -26,11 +26,6 @@ defineCustomElement('sinch-segmented-icon-control', (_$slot = new WeakMap(), _$s
|
|
|
26
26
|
value: void 0
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
-
_classPrivateFieldInitSpec(this, _$sh, {
|
|
30
|
-
writable: true,
|
|
31
|
-
value: void 0
|
|
32
|
-
});
|
|
33
|
-
|
|
34
29
|
_classPrivateFieldInitSpec(this, _onSlotChange, {
|
|
35
30
|
writable: true,
|
|
36
31
|
value: () => {
|
|
@@ -44,19 +39,27 @@ defineCustomElement('sinch-segmented-icon-control', (_$slot = new WeakMap(), _$s
|
|
|
44
39
|
e.stopPropagation();
|
|
45
40
|
const $elem = e.target;
|
|
46
41
|
const value = e.detail;
|
|
47
|
-
const
|
|
42
|
+
const detail = this.multiple ? updateCsv(this.value, value, !getBooleanAttribute($elem, 'data-checked')) : value;
|
|
48
43
|
this.dispatchEvent(new CustomEvent('change', {
|
|
49
|
-
detail
|
|
44
|
+
detail,
|
|
50
45
|
bubbles: true
|
|
51
46
|
}));
|
|
47
|
+
this.dispatchEvent(new CustomEvent('-change', {
|
|
48
|
+
detail
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
_classPrivateFieldInitSpec(this, _onChangeReactHandler, {
|
|
54
|
+
writable: true,
|
|
55
|
+
value: e => {
|
|
56
|
+
getReactEventHandler(this, 'on-change')?.(e);
|
|
52
57
|
}
|
|
53
58
|
});
|
|
54
59
|
|
|
55
60
|
const shadowRoot = this.attachShadow();
|
|
56
61
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
57
62
|
|
|
58
|
-
_classPrivateFieldSet(this, _$sh, shadowRoot);
|
|
59
|
-
|
|
60
63
|
_classPrivateFieldSet(this, _$slot, shadowRoot.querySelector('slot'));
|
|
61
64
|
}
|
|
62
65
|
|
|
@@ -65,13 +68,17 @@ defineCustomElement('sinch-segmented-icon-control', (_$slot = new WeakMap(), _$s
|
|
|
65
68
|
|
|
66
69
|
_classPrivateFieldGet(this, _$slot).addEventListener('slotchange', _classPrivateFieldGet(this, _onSlotChange));
|
|
67
70
|
|
|
68
|
-
_classPrivateFieldGet(this, _$
|
|
71
|
+
_classPrivateFieldGet(this, _$slot).addEventListener('option-change', _classPrivateFieldGet(this, _onOptionChange));
|
|
72
|
+
|
|
73
|
+
this.addEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
|
|
69
74
|
}
|
|
70
75
|
|
|
71
76
|
disconnectedCallback() {
|
|
72
77
|
_classPrivateFieldGet(this, _$slot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onSlotChange));
|
|
73
78
|
|
|
74
|
-
_classPrivateFieldGet(this, _$
|
|
79
|
+
_classPrivateFieldGet(this, _$slot).removeEventListener('option-change', _classPrivateFieldGet(this, _onOptionChange));
|
|
80
|
+
|
|
81
|
+
this.removeEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
|
|
75
82
|
}
|
|
76
83
|
|
|
77
84
|
static get observedAttributes() {
|
|
@@ -99,6 +106,10 @@ defineCustomElement('sinch-segmented-icon-control', (_$slot = new WeakMap(), _$s
|
|
|
99
106
|
}
|
|
100
107
|
|
|
101
108
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
109
|
+
if (oldVal === newVal) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
|
|
102
113
|
switch (name) {
|
|
103
114
|
case 'value':
|
|
104
115
|
{
|
|
@@ -117,14 +128,14 @@ function _onValueChange2(csv) {
|
|
|
117
128
|
|
|
118
129
|
for (const $option of _classPrivateFieldGet(this, _$slot).assignedElements()) {
|
|
119
130
|
const isChecked = !getBooleanAttribute($option, 'disabled') && values.has(getAttribute($option, 'value', ''));
|
|
120
|
-
updateBooleanAttribute($option, 'checked', isChecked);
|
|
131
|
+
updateBooleanAttribute($option, 'data-checked', isChecked);
|
|
121
132
|
}
|
|
122
133
|
} else {
|
|
123
134
|
const value = getFirstCsvValue(csv);
|
|
124
135
|
|
|
125
136
|
for (const $option of _classPrivateFieldGet(this, _$slot).assignedElements()) {
|
|
126
137
|
const isChecked = !getBooleanAttribute($option, 'disabled') && value === getAttribute($option, 'value', '');
|
|
127
|
-
updateBooleanAttribute($option, 'checked', isChecked);
|
|
138
|
+
updateBooleanAttribute($option, 'data-checked', isChecked);
|
|
128
139
|
}
|
|
129
140
|
}
|
|
130
141
|
}
|
|
@@ -3,11 +3,14 @@ import type { SyntheticEvent } from 'react';
|
|
|
3
3
|
export declare type TSinchSegmentedIconControlElement = HTMLElement & {
|
|
4
4
|
value: string;
|
|
5
5
|
multiple: boolean;
|
|
6
|
-
addEventListener(type: 'change', listener: (e: CustomEvent<string>) => void): void;
|
|
6
|
+
addEventListener(type: '-change', listener: (e: CustomEvent<string>) => void): void;
|
|
7
|
+
setAttribute(name: 'value', value: string): void;
|
|
8
|
+
setAttribute(name: 'multiple', value: ''): void;
|
|
7
9
|
};
|
|
8
10
|
export declare type TSinchSegmentedIconControlReact = TSinchElementReact<TSinchSegmentedIconControlElement> & {
|
|
9
11
|
value: string;
|
|
10
12
|
multiple?: boolean;
|
|
11
13
|
'aria-label': string;
|
|
12
|
-
onChange
|
|
14
|
+
onChange?: (event: SyntheticEvent<TSinchSegmentedIconControlElement, CustomEvent<string>>) => void;
|
|
15
|
+
'on-change'?: (e: CustomEvent<string>) => void;
|
|
13
16
|
};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
2
|
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
3
|
|
|
4
|
-
var _$button,
|
|
4
|
+
var _$button, _onButtonClick, _onButtonFocus, _onButtonBlur, _onFocusReactHandler, _onBlurReactHandler;
|
|
5
5
|
|
|
6
6
|
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
7
7
|
|
|
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
|
-
import { defineCustomElement, getAttribute, getBooleanAttribute, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
|
|
11
|
-
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{position:relative;width:56px;height:32px;padding:3px 16px;box-sizing:border-box;border:1px solid var(--sinch-color-snow-600);border-left-width:0;border-right-width:0;color:var(--sinch-color-stormy-500);background-color:var(--sinch-color-snow-100);--sinch-color-icon:var(--sinch-color-stormy-500);--sinch-size-icon:24px}#wrapper:hover{background-color:var(--sinch-color-snow-500)}:host(:first-child) #wrapper{border-left-width:1px;border-top-left-radius:4px;border-bottom-left-radius:4px}:host(:last-child) #wrapper{border-right-width:1px;border-top-right-radius:4px;border-bottom-right-radius:4px}:host([checked]
|
|
10
|
+
import { defineCustomElement, getAttribute, getBooleanAttribute, getReactEventHandler, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
|
|
11
|
+
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{position:relative;width:56px;height:32px;padding:3px 16px;box-sizing:border-box;border:1px solid var(--sinch-color-snow-600);border-left-width:0;border-right-width:0;color:var(--sinch-color-stormy-500);background-color:var(--sinch-color-snow-100);--sinch-color-icon:var(--sinch-color-stormy-500);--sinch-size-icon:24px}#wrapper:hover{background-color:var(--sinch-color-snow-500)}:host(:first-child) #wrapper{border-left-width:1px;border-top-left-radius:4px;border-bottom-left-radius:4px}:host(:last-child) #wrapper{border-right-width:1px;border-top-right-radius:4px;border-bottom-right-radius:4px}:host([data-checked]) #wrapper{border-color:var(--sinch-color-stormy-500)}:host([data-checked]:not(:first-child)) #wrapper::before{content:"";width:1px;background-color:var(--sinch-color-stormy-500);position:absolute;left:-1px;top:-1px;bottom:-1px}:host([data-checked]:not(:last-child)) #wrapper::after{content:"";width:1px;background-color:var(--sinch-color-stormy-500);position:absolute;right:0;top:-1px;bottom:-1px}#button{all:initial;position:absolute;left:0;top:0;box-sizing:border-box;width:100%;height:100%;cursor:pointer;z-index:1}#button:disabled{cursor:unset}#button:focus::before{content:"";position:absolute;left:-4px;right:-3px;top:-4px;bottom:-4px;border-style:solid;border-color:var(--sinch-color-aqua-400);border-width:0}#button:focus-visible::before{border-width:2px}:host(:first-child) #button:focus::before{left:-4px;border-top-left-radius:6px;border-bottom-left-radius:6px}:host(:last-child) #button:focus::before{right:-4px;border-top-right-radius:6px;border-bottom-right-radius:6px}@supports not selector(:focus-visible){#button:focus::before{border-width:2px}}:host([disabled]:not([disabled=false])) #wrapper{background-color:var(--sinch-color-snow-100);color:var(--sinch-color-stormy-100);--sinch-color-icon:var(--sinch-color-stormy-100)}::slotted(*){display:block}</style><div id="wrapper"><slot name="icon"></slot><button id="button"></button></div>';
|
|
12
12
|
const template = document.createElement('template');
|
|
13
13
|
template.innerHTML = templateHTML;
|
|
14
|
-
defineCustomElement('sinch-segmented-icon-control-option', (_$button = new WeakMap(),
|
|
14
|
+
defineCustomElement('sinch-segmented-icon-control-option', (_$button = new WeakMap(), _onButtonClick = new WeakMap(), _onButtonFocus = new WeakMap(), _onButtonBlur = new WeakMap(), _onFocusReactHandler = new WeakMap(), _onBlurReactHandler = new WeakMap(), class extends NectaryElement {
|
|
15
15
|
constructor() {
|
|
16
16
|
super();
|
|
17
17
|
|
|
@@ -20,17 +20,45 @@ defineCustomElement('sinch-segmented-icon-control-option', (_$button = new WeakM
|
|
|
20
20
|
value: void 0
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
-
_classPrivateFieldInitSpec(this,
|
|
23
|
+
_classPrivateFieldInitSpec(this, _onButtonClick, {
|
|
24
24
|
writable: true,
|
|
25
25
|
value: e => {
|
|
26
26
|
e.stopPropagation();
|
|
27
|
-
this.dispatchEvent(new CustomEvent('change', {
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
this.dispatchEvent(new CustomEvent('option-change', {
|
|
28
|
+
detail: this.value,
|
|
29
|
+
bubbles: true
|
|
30
30
|
}));
|
|
31
31
|
}
|
|
32
32
|
});
|
|
33
33
|
|
|
34
|
+
_classPrivateFieldInitSpec(this, _onButtonFocus, {
|
|
35
|
+
writable: true,
|
|
36
|
+
value: () => {
|
|
37
|
+
this.dispatchEvent(new CustomEvent('-focus'));
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
_classPrivateFieldInitSpec(this, _onButtonBlur, {
|
|
42
|
+
writable: true,
|
|
43
|
+
value: () => {
|
|
44
|
+
this.dispatchEvent(new CustomEvent('-blur'));
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
_classPrivateFieldInitSpec(this, _onFocusReactHandler, {
|
|
49
|
+
writable: true,
|
|
50
|
+
value: () => {
|
|
51
|
+
getReactEventHandler(this, 'on-focus')?.();
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
_classPrivateFieldInitSpec(this, _onBlurReactHandler, {
|
|
56
|
+
writable: true,
|
|
57
|
+
value: () => {
|
|
58
|
+
getReactEventHandler(this, 'on-blur')?.();
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
34
62
|
const shadowRoot = this.attachShadow();
|
|
35
63
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
36
64
|
|
|
@@ -40,15 +68,29 @@ defineCustomElement('sinch-segmented-icon-control-option', (_$button = new WeakM
|
|
|
40
68
|
connectedCallback() {
|
|
41
69
|
this.setAttribute('role', 'tab');
|
|
42
70
|
|
|
43
|
-
_classPrivateFieldGet(this, _$button).addEventListener('click', _classPrivateFieldGet(this,
|
|
71
|
+
_classPrivateFieldGet(this, _$button).addEventListener('click', _classPrivateFieldGet(this, _onButtonClick));
|
|
72
|
+
|
|
73
|
+
_classPrivateFieldGet(this, _$button).addEventListener('focus', _classPrivateFieldGet(this, _onButtonFocus));
|
|
74
|
+
|
|
75
|
+
_classPrivateFieldGet(this, _$button).addEventListener('blur', _classPrivateFieldGet(this, _onButtonBlur));
|
|
76
|
+
|
|
77
|
+
this.addEventListener('-focus', _classPrivateFieldGet(this, _onFocusReactHandler));
|
|
78
|
+
this.addEventListener('-blur', _classPrivateFieldGet(this, _onBlurReactHandler));
|
|
44
79
|
}
|
|
45
80
|
|
|
46
81
|
disconnectedCallback() {
|
|
47
|
-
_classPrivateFieldGet(this, _$button).removeEventListener('click', _classPrivateFieldGet(this,
|
|
82
|
+
_classPrivateFieldGet(this, _$button).removeEventListener('click', _classPrivateFieldGet(this, _onButtonClick));
|
|
83
|
+
|
|
84
|
+
_classPrivateFieldGet(this, _$button).removeEventListener('focus', _classPrivateFieldGet(this, _onButtonFocus));
|
|
85
|
+
|
|
86
|
+
_classPrivateFieldGet(this, _$button).removeEventListener('blur', _classPrivateFieldGet(this, _onButtonBlur));
|
|
87
|
+
|
|
88
|
+
this.removeEventListener('-focus', _classPrivateFieldGet(this, _onFocusReactHandler));
|
|
89
|
+
this.removeEventListener('-blur', _classPrivateFieldGet(this, _onBlurReactHandler));
|
|
48
90
|
}
|
|
49
91
|
|
|
50
92
|
static get observedAttributes() {
|
|
51
|
-
return ['checked', 'disabled'
|
|
93
|
+
return ['data-checked', 'disabled'];
|
|
52
94
|
}
|
|
53
95
|
|
|
54
96
|
set value(value) {
|
|
@@ -69,7 +111,7 @@ defineCustomElement('sinch-segmented-icon-control-option', (_$button = new WeakM
|
|
|
69
111
|
|
|
70
112
|
attributeChangedCallback(name, _, newVal) {
|
|
71
113
|
switch (name) {
|
|
72
|
-
case 'checked':
|
|
114
|
+
case 'data-checked':
|
|
73
115
|
{
|
|
74
116
|
updateExplicitBooleanAttribute(this, 'aria-selected', isAttrTrue(newVal));
|
|
75
117
|
break;
|
|
@@ -2,6 +2,8 @@ import type { TSinchElementReact } from '../types';
|
|
|
2
2
|
export declare type TSinchSegmentedIconControlOptionElement = HTMLElement & {
|
|
3
3
|
value: string;
|
|
4
4
|
disabled: boolean;
|
|
5
|
+
addEventListener(type: '-focus', listener: (e: CustomEvent<void>) => void): void;
|
|
6
|
+
addEventListener(type: '-blur', listener: (e: CustomEvent<void>) => void): void;
|
|
5
7
|
setAttribute(name: 'value', value: string): void;
|
|
6
8
|
setAttribute(name: 'disabled', value: ''): void;
|
|
7
9
|
};
|
|
@@ -9,4 +11,6 @@ export declare type TSinchSegmentedIconControlOptionReact = TSinchElementReact<T
|
|
|
9
11
|
value: string;
|
|
10
12
|
disabled?: boolean;
|
|
11
13
|
'aria-label': string;
|
|
14
|
+
'on-focus'?: (e: CustomEvent<void>) => void;
|
|
15
|
+
'on-blur'?: (e: CustomEvent<void>) => void;
|
|
12
16
|
};
|
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, _$sh, _createElement, _updateButtonContent, _onValueChange, _getOptionWithValue, _onLabelClick, _onDropdownClick, _onDropdownClose;
|
|
4
|
+
var _$button, _$buttonContent, _$label, _$optionalText, _$additionalText, _$invalidText, _$dropdown, _$optionSlot, _$sh, _createElement, _updateButtonContent, _onValueChange, _getOptionWithValue, _onLabelClick, _onDropdownClick, _onDropdownClose, _onButtonFocus, _onButtonBlur, _onChangeReactHandler, _onFocusReactHandler, _onBlurReactHandler;
|
|
5
5
|
|
|
6
6
|
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
|
7
7
|
|
|
@@ -12,11 +12,11 @@ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollect
|
|
|
12
12
|
function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
|
|
13
13
|
|
|
14
14
|
import '../dropdown';
|
|
15
|
-
import { defineCustomElement, getAttribute, getBooleanAttribute, getIntegerAttribute, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute, updateIntegerAttribute } from '../utils';
|
|
16
|
-
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:var(--sinch-shape-radius-s);box-sizing:border-box;width:100%;height:48px;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;margin-bottom:2px}#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);line-height:20px;margin-top:2px}#additional:empty{display:none}#invalid{font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-invalid);line-height:20px;margin-top:2px}#invalid:empty{display:none}::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="button"></label><slot name="tooltip"></slot><span id="optional"></span></div><sinch-dropdown id="dropdown" modal orientation="bottom"><button slot="target" id="button"><span id="content"></span
|
|
15
|
+
import { defineCustomElement, getAttribute, getBooleanAttribute, getIntegerAttribute, getReactEventHandler, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute, updateIntegerAttribute } from '../utils';
|
|
16
|
+
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:var(--sinch-shape-radius-s);box-sizing:border-box;width:100%;height:48px;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;margin-bottom:2px}#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);line-height:20px;margin-top:2px}#additional:empty{display:none}#invalid{font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-invalid);line-height:20px;margin-top:2px}#invalid:empty{display:none}::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="button"></label><slot name="tooltip"></slot><span id="optional"></span></div><sinch-dropdown id="dropdown" modal orientation="bottom"><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>';
|
|
17
17
|
const template = document.createElement('template');
|
|
18
18
|
template.innerHTML = templateHTML;
|
|
19
|
-
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(), _$sh = new WeakMap(), _createElement = new WeakSet(), _updateButtonContent = new WeakSet(), _onValueChange = new WeakMap(), _getOptionWithValue = new WeakSet(), _onLabelClick = new WeakMap(), _onDropdownClick = new WeakMap(), _onDropdownClose = new WeakMap(), class extends NectaryElement {
|
|
19
|
+
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(), _$sh = new WeakMap(), _createElement = new WeakSet(), _updateButtonContent = new WeakSet(), _onValueChange = new WeakMap(), _getOptionWithValue = new WeakSet(), _onLabelClick = new WeakMap(), _onDropdownClick = new WeakMap(), _onDropdownClose = new WeakMap(), _onButtonFocus = new WeakMap(), _onButtonBlur = new WeakMap(), _onChangeReactHandler = new WeakMap(), _onFocusReactHandler = new WeakMap(), _onBlurReactHandler = new WeakMap(), class extends NectaryElement {
|
|
20
20
|
constructor() {
|
|
21
21
|
super();
|
|
22
22
|
|
|
@@ -74,11 +74,15 @@ defineCustomElement('sinch-select', (_$button = new WeakMap(), _$buttonContent =
|
|
|
74
74
|
_classPrivateFieldInitSpec(this, _onValueChange, {
|
|
75
75
|
writable: true,
|
|
76
76
|
value: e => {
|
|
77
|
+
const detail = e.detail;
|
|
77
78
|
_classPrivateFieldGet(this, _$dropdown).open = false;
|
|
78
79
|
this.dispatchEvent(new CustomEvent('change', {
|
|
79
|
-
detail
|
|
80
|
+
detail,
|
|
80
81
|
bubbles: true
|
|
81
82
|
}));
|
|
83
|
+
this.dispatchEvent(new CustomEvent('-change', {
|
|
84
|
+
detail
|
|
85
|
+
}));
|
|
82
86
|
}
|
|
83
87
|
});
|
|
84
88
|
|
|
@@ -103,6 +107,41 @@ defineCustomElement('sinch-select', (_$button = new WeakMap(), _$buttonContent =
|
|
|
103
107
|
}
|
|
104
108
|
});
|
|
105
109
|
|
|
110
|
+
_classPrivateFieldInitSpec(this, _onButtonFocus, {
|
|
111
|
+
writable: true,
|
|
112
|
+
value: () => {
|
|
113
|
+
this.dispatchEvent(new CustomEvent('-focus'));
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
_classPrivateFieldInitSpec(this, _onButtonBlur, {
|
|
118
|
+
writable: true,
|
|
119
|
+
value: () => {
|
|
120
|
+
this.dispatchEvent(new CustomEvent('-blur'));
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
_classPrivateFieldInitSpec(this, _onChangeReactHandler, {
|
|
125
|
+
writable: true,
|
|
126
|
+
value: e => {
|
|
127
|
+
getReactEventHandler(this, 'on-change')?.(e);
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
_classPrivateFieldInitSpec(this, _onFocusReactHandler, {
|
|
132
|
+
writable: true,
|
|
133
|
+
value: () => {
|
|
134
|
+
getReactEventHandler(this, 'on-focus')?.();
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
_classPrivateFieldInitSpec(this, _onBlurReactHandler, {
|
|
139
|
+
writable: true,
|
|
140
|
+
value: () => {
|
|
141
|
+
getReactEventHandler(this, 'on-blur')?.();
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
|
|
106
145
|
const shadowRoot = this.attachShadow();
|
|
107
146
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
108
147
|
|
|
@@ -129,23 +168,39 @@ defineCustomElement('sinch-select', (_$button = new WeakMap(), _$buttonContent =
|
|
|
129
168
|
this.setAttribute('role', 'listbox');
|
|
130
169
|
this.setAttribute('aria-haspopup', 'listbox');
|
|
131
170
|
|
|
132
|
-
_classPrivateFieldGet(this, _$dropdown).addEventListener('change', _classPrivateFieldGet(this, _onValueChange));
|
|
171
|
+
_classPrivateFieldGet(this, _$dropdown).addEventListener('-change', _classPrivateFieldGet(this, _onValueChange));
|
|
133
172
|
|
|
134
|
-
_classPrivateFieldGet(this, _$dropdown).addEventListener('close', _classPrivateFieldGet(this, _onDropdownClose));
|
|
173
|
+
_classPrivateFieldGet(this, _$dropdown).addEventListener('-close', _classPrivateFieldGet(this, _onDropdownClose));
|
|
135
174
|
|
|
136
175
|
_classPrivateFieldGet(this, _$button).addEventListener('click', _classPrivateFieldGet(this, _onDropdownClick));
|
|
137
176
|
|
|
177
|
+
_classPrivateFieldGet(this, _$button).addEventListener('focus', _classPrivateFieldGet(this, _onButtonFocus));
|
|
178
|
+
|
|
179
|
+
_classPrivateFieldGet(this, _$button).addEventListener('blur', _classPrivateFieldGet(this, _onButtonBlur));
|
|
180
|
+
|
|
138
181
|
_classPrivateFieldGet(this, _$label).addEventListener('click', _classPrivateFieldGet(this, _onLabelClick));
|
|
182
|
+
|
|
183
|
+
this.addEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
|
|
184
|
+
this.addEventListener('-focus', _classPrivateFieldGet(this, _onFocusReactHandler));
|
|
185
|
+
this.addEventListener('-blur', _classPrivateFieldGet(this, _onBlurReactHandler));
|
|
139
186
|
}
|
|
140
187
|
|
|
141
188
|
disconnectedCallback() {
|
|
142
|
-
_classPrivateFieldGet(this, _$dropdown).removeEventListener('change', _classPrivateFieldGet(this, _onValueChange));
|
|
189
|
+
_classPrivateFieldGet(this, _$dropdown).removeEventListener('-change', _classPrivateFieldGet(this, _onValueChange));
|
|
143
190
|
|
|
144
|
-
_classPrivateFieldGet(this, _$dropdown).removeEventListener('close', _classPrivateFieldGet(this, _onDropdownClose));
|
|
191
|
+
_classPrivateFieldGet(this, _$dropdown).removeEventListener('-close', _classPrivateFieldGet(this, _onDropdownClose));
|
|
145
192
|
|
|
146
193
|
_classPrivateFieldGet(this, _$button).removeEventListener('click', _classPrivateFieldGet(this, _onDropdownClick));
|
|
147
194
|
|
|
195
|
+
_classPrivateFieldGet(this, _$button).removeEventListener('focus', _classPrivateFieldGet(this, _onButtonFocus));
|
|
196
|
+
|
|
197
|
+
_classPrivateFieldGet(this, _$button).removeEventListener('blur', _classPrivateFieldGet(this, _onButtonBlur));
|
|
198
|
+
|
|
148
199
|
_classPrivateFieldGet(this, _$label).removeEventListener('click', _classPrivateFieldGet(this, _onLabelClick));
|
|
200
|
+
|
|
201
|
+
this.removeEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
|
|
202
|
+
this.removeEventListener('-focus', _classPrivateFieldGet(this, _onFocusReactHandler));
|
|
203
|
+
this.removeEventListener('-blur', _classPrivateFieldGet(this, _onBlurReactHandler));
|
|
149
204
|
}
|
|
150
205
|
|
|
151
206
|
static get observedAttributes() {
|
|
@@ -225,6 +280,10 @@ defineCustomElement('sinch-select', (_$button = new WeakMap(), _$buttonContent =
|
|
|
225
280
|
}
|
|
226
281
|
|
|
227
282
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
283
|
+
if (newVal === oldVal) {
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
|
|
228
287
|
switch (name) {
|
|
229
288
|
case 'value':
|
|
230
289
|
{
|
package/select/types.d.ts
CHANGED
|
@@ -19,7 +19,9 @@ export declare type TSinchSelectElement = HTMLElement & {
|
|
|
19
19
|
maxVisibleItems: number | null;
|
|
20
20
|
readonly dropdownRect: TRect;
|
|
21
21
|
/** Change value event */
|
|
22
|
-
addEventListener(type: 'change', listener: (e: CustomEvent<string>) => void): void;
|
|
22
|
+
addEventListener(type: '-change', listener: (e: CustomEvent<string>) => void): void;
|
|
23
|
+
addEventListener(type: '-focus', listener: (e: CustomEvent<void>) => void): void;
|
|
24
|
+
addEventListener(type: '-blur', listener: (e: CustomEvent<void>) => void): void;
|
|
23
25
|
/** Value that matches one of the options `value` */
|
|
24
26
|
setAttribute(name: 'value', value: string): void;
|
|
25
27
|
/** Label */
|
|
@@ -57,5 +59,9 @@ export declare type TSinchSelectReact = TSinchElementReact<TSinchSelectElement>
|
|
|
57
59
|
/** Number of visible at the same time options in the list */
|
|
58
60
|
maxVisibleItems?: number;
|
|
59
61
|
/** Change value handler */
|
|
60
|
-
onChange
|
|
62
|
+
onChange?: (e: SyntheticEvent<TSinchSelectElement, CustomEvent<string>>) => void;
|
|
63
|
+
/** Change value handler */
|
|
64
|
+
'on-change'?: (e: CustomEvent<string>) => void;
|
|
65
|
+
'on-focus'?: (e: CustomEvent<void>) => void;
|
|
66
|
+
'on-blur'?: (e: CustomEvent<void>) => void;
|
|
61
67
|
};
|
package/tabs/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
2
1
|
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
|
+
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
3
|
|
|
4
|
-
var _$slot, _onOptionKeyDown, _onSlotChange, _onOptionChange, _onValueChange, _dispatchChangeEvent, _getFirstOption, _getLastOption, _getNextOption, _getPrevOption, _getEnabledRadioElements;
|
|
4
|
+
var _$slot, _onOptionKeyDown, _onSlotChange, _onOptionChange, _onValueChange, _dispatchChangeEvent, _getFirstOption, _getLastOption, _getNextOption, _getPrevOption, _getEnabledRadioElements, _onChangeReactHandler;
|
|
5
5
|
|
|
6
6
|
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
|
7
7
|
|
|
@@ -11,7 +11,7 @@ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollect
|
|
|
11
11
|
|
|
12
12
|
function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
|
|
13
13
|
|
|
14
|
-
import { defineCustomElement, getAttribute, getBooleanAttribute, NectaryElement, updateAttribute, updateBooleanAttribute } from '../utils';
|
|
14
|
+
import { defineCustomElement, getAttribute, getBooleanAttribute, getReactEventHandler, NectaryElement, updateAttribute, updateBooleanAttribute } from '../utils';
|
|
15
15
|
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{display:flex;flex-direction:row;height:44px;width:100%;box-sizing:border-box}</style><div id="wrapper"><slot></slot></div>';
|
|
16
16
|
|
|
17
17
|
const findSelectedOption = elements => {
|
|
@@ -20,7 +20,7 @@ const findSelectedOption = elements => {
|
|
|
20
20
|
|
|
21
21
|
const template = document.createElement('template');
|
|
22
22
|
template.innerHTML = templateHTML;
|
|
23
|
-
defineCustomElement('sinch-tabs', (_$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 NectaryElement {
|
|
23
|
+
defineCustomElement('sinch-tabs', (_$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(), _onChangeReactHandler = new WeakMap(), class extends NectaryElement {
|
|
24
24
|
constructor() {
|
|
25
25
|
super();
|
|
26
26
|
|
|
@@ -98,18 +98,39 @@ defineCustomElement('sinch-tabs', (_$slot = new WeakMap(), _onOptionKeyDown = ne
|
|
|
98
98
|
}
|
|
99
99
|
});
|
|
100
100
|
|
|
101
|
+
_classPrivateFieldInitSpec(this, _onChangeReactHandler, {
|
|
102
|
+
writable: true,
|
|
103
|
+
value: e => {
|
|
104
|
+
getReactEventHandler(this, 'on-change')?.(e);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
|
|
101
108
|
const shadowRoot = this.attachShadow();
|
|
102
109
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
103
|
-
shadowRoot.addEventListener('keydown', _classPrivateFieldGet(this, _onOptionKeyDown));
|
|
104
|
-
shadowRoot.addEventListener('change', _classPrivateFieldGet(this, _onOptionChange));
|
|
105
110
|
|
|
106
111
|
_classPrivateFieldSet(this, _$slot, shadowRoot.querySelector('slot'));
|
|
107
|
-
|
|
108
|
-
_classPrivateFieldGet(this, _$slot).addEventListener('slotchange', _classPrivateFieldGet(this, _onSlotChange));
|
|
109
112
|
}
|
|
110
113
|
|
|
111
114
|
connectedCallback() {
|
|
112
115
|
this.setAttribute('role', 'tablist');
|
|
116
|
+
|
|
117
|
+
_classPrivateFieldGet(this, _$slot).addEventListener('keydown', _classPrivateFieldGet(this, _onOptionKeyDown));
|
|
118
|
+
|
|
119
|
+
_classPrivateFieldGet(this, _$slot).addEventListener('option-change', _classPrivateFieldGet(this, _onOptionChange));
|
|
120
|
+
|
|
121
|
+
_classPrivateFieldGet(this, _$slot).addEventListener('slotchange', _classPrivateFieldGet(this, _onSlotChange));
|
|
122
|
+
|
|
123
|
+
this.addEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
disconnectedCallback() {
|
|
127
|
+
_classPrivateFieldGet(this, _$slot).removeEventListener('keydown', _classPrivateFieldGet(this, _onOptionKeyDown));
|
|
128
|
+
|
|
129
|
+
_classPrivateFieldGet(this, _$slot).removeEventListener('option-change', _classPrivateFieldGet(this, _onOptionChange));
|
|
130
|
+
|
|
131
|
+
_classPrivateFieldGet(this, _$slot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onSlotChange));
|
|
132
|
+
|
|
133
|
+
this.removeEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
|
|
113
134
|
}
|
|
114
135
|
|
|
115
136
|
static get observedAttributes() {
|
|
@@ -153,6 +174,9 @@ function _dispatchChangeEvent2(value) {
|
|
|
153
174
|
detail: value,
|
|
154
175
|
bubbles: true
|
|
155
176
|
}));
|
|
177
|
+
this.dispatchEvent(new CustomEvent('-change', {
|
|
178
|
+
detail: value
|
|
179
|
+
}));
|
|
156
180
|
}
|
|
157
181
|
|
|
158
182
|
function _getFirstOption2() {
|
package/tabs/types.d.ts
CHANGED
|
@@ -2,11 +2,12 @@ import type { TSinchElementReact } from '../types';
|
|
|
2
2
|
import type { SyntheticEvent } from 'react';
|
|
3
3
|
export declare type TSinchTabsElement = HTMLElement & {
|
|
4
4
|
value: string;
|
|
5
|
-
addEventListener(type: 'change', listener: (e: CustomEvent<string>) => void): void;
|
|
5
|
+
addEventListener(type: '-change', listener: (e: CustomEvent<string>) => void): void;
|
|
6
6
|
setAttribute(name: 'value', value: string): void;
|
|
7
7
|
};
|
|
8
8
|
export declare type TSinchTabsReact = TSinchElementReact<TSinchTabsElement> & {
|
|
9
9
|
value: string;
|
|
10
10
|
'aria-label': string;
|
|
11
|
-
onChange
|
|
11
|
+
onChange?: (event: SyntheticEvent<TSinchTabsElement, CustomEvent<string>>) => void;
|
|
12
|
+
'on-change'?: (e: CustomEvent<string>) => void;
|
|
12
13
|
};
|
package/tabs-option/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, isAttrTrue, NectaryElement, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
|
|
11
|
-
const templateHTML = '<style>:host{display:block;outline:0}:host()>*{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);background-color:var(--sinch-color-snow-100);--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]:not([checked=false])) #wrapper{box-shadow:0 2px 0 0 var(--sinch-color-stormy-500)}#button{all:initial;position:absolute;left:0;top:0;box-sizing:border-box;width:100%;height:100%;cursor:pointer}#button:disabled{cursor:unset}:host([disabled]:not([disabled=false])) #wrapper{color:var(--sinch-color-stormy-100);--sinch-color-icon:var(--sinch-color-stormy-100)}</style><div id="wrapper"><slot name="icon"></slot><label for="input" id="content"></label
|
|
11
|
+
const templateHTML = '<style>:host{display:block;outline:0}:host()>*{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);background-color:var(--sinch-color-snow-100);--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]:not([checked=false])) #wrapper{box-shadow:0 2px 0 0 var(--sinch-color-stormy-500)}#button{all:initial;position:absolute;left:0;top:0;box-sizing:border-box;width:100%;height:100%;cursor:pointer}#button:disabled{cursor:unset}:host([disabled]:not([disabled=false])) #wrapper{color:var(--sinch-color-stormy-100);--sinch-color-icon:var(--sinch-color-stormy-100)}</style><div id="wrapper"><slot name="icon"></slot><label for="input" id="content"></label><button id="button" type="radio"/></div>';
|
|
12
12
|
const template = document.createElement('template');
|
|
13
13
|
template.innerHTML = templateHTML;
|
|
14
14
|
defineCustomElement('sinch-tabs-option', (_$button = new WeakMap(), _$label = new WeakMap(), _onClick = new WeakMap(), class extends NectaryElement {
|
|
@@ -29,7 +29,7 @@ defineCustomElement('sinch-tabs-option', (_$button = new WeakMap(), _$label = ne
|
|
|
29
29
|
writable: true,
|
|
30
30
|
value: e => {
|
|
31
31
|
e.stopPropagation();
|
|
32
|
-
this.dispatchEvent(new CustomEvent('change', {
|
|
32
|
+
this.dispatchEvent(new CustomEvent('option-change', {
|
|
33
33
|
bubbles: true,
|
|
34
34
|
detail: this.value
|
|
35
35
|
}));
|