@nectary/components 0.34.0 → 0.36.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.d.ts +4 -0
- package/alert/index.js +17 -32
- package/alert/types.d.ts +1 -7
- package/alert/utils.d.ts +3 -0
- package/alert/utils.js +6 -1
- package/avatar/index.js +1 -1
- package/button/index.js +69 -5
- 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/types.d.ts +4 -0
- package/horizontal-stepper-item/index.js +1 -1
- package/horizontal-stepper-item/types.d.ts +9 -0
- package/icon-button/index.js +75 -5
- 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/inline-alert/index.d.ts +17 -0
- package/inline-alert/index.js +154 -0
- package/inline-alert/types.d.ts +15 -0
- package/inline-alert/utils.d.ts +5 -0
- package/inline-alert/utils.js +6 -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/text/index.js +1 -1
- 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/time-picker/index.js +18 -4
- package/time-picker/types.d.ts +4 -2
- package/toggle/index.js +63 -5
- package/toggle/types.d.ts +3 -1
- package/vertical-stepper/index.d.ts +13 -0
- package/vertical-stepper/index.js +95 -0
- package/vertical-stepper/types.d.ts +13 -0
- package/vertical-stepper/types.js +1 -0
- package/vertical-stepper-item/index.d.ts +13 -0
- package/vertical-stepper-item/index.js +100 -0
- package/vertical-stepper-item/types.d.ts +24 -0
- package/vertical-stepper-item/types.js +1 -0
- package/vertical-stepper-item/utils.d.ts +2 -0
- package/vertical-stepper-item/utils.js +1 -0
- package/alert-button/index.d.ts +0 -11
- package/alert-button/index.js +0 -59
- package/alert-button/types.d.ts +0 -8
- package/alert-close/index.d.ts +0 -12
- package/alert-close/index.js +0 -38
- package/alert-close/types.d.ts +0 -3
- /package/{alert-button → inline-alert}/types.js +0 -0
- /package/{alert-close → tile-control-option}/types.js +0 -0
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
1
|
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
3
2
|
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
4
3
|
|
|
5
|
-
var _$button;
|
|
4
|
+
var _$button, _onClick, _onChangeReactHandler;
|
|
6
5
|
|
|
7
6
|
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
8
7
|
|
|
@@ -11,11 +10,11 @@ function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollect
|
|
|
11
10
|
import '../icons/expand-less';
|
|
12
11
|
import '../icons/expand-more';
|
|
13
12
|
import '../icon-button';
|
|
14
|
-
import { defineCustomElement, getBooleanAttribute, isAttrTrue, NectaryElement, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
|
|
13
|
+
import { defineCustomElement, getBooleanAttribute, getReactEventHandler, isAttrTrue, NectaryElement, updateBooleanAttribute, updateExplicitBooleanAttribute } from '../utils';
|
|
15
14
|
const templateHTML = '<style>:host{display:block;--sinch-size-icon:32px}#up{display:block}#down{display:none}:host([value]:not([value=false])) #up{display:none}:host([value]:not([value=false])) #down{display:block}</style><sinch-icon-button id="button" small><sinch-icon-expand-less id="up" slot="icon"></sinch-icon-expand-less><sinch-icon-expand-more id="down" slot="icon"></sinch-icon-expand-more></sinch-icon-button>';
|
|
16
15
|
const template = document.createElement('template');
|
|
17
16
|
template.innerHTML = templateHTML;
|
|
18
|
-
defineCustomElement('sinch-segment-collapse', (_$button = new WeakMap(), class extends NectaryElement {
|
|
17
|
+
defineCustomElement('sinch-segment-collapse', (_$button = new WeakMap(), _onClick = new WeakMap(), _onChangeReactHandler = new WeakMap(), class extends NectaryElement {
|
|
19
18
|
constructor() {
|
|
20
19
|
super();
|
|
21
20
|
|
|
@@ -24,12 +23,25 @@ defineCustomElement('sinch-segment-collapse', (_$button = new WeakMap(), class e
|
|
|
24
23
|
value: void 0
|
|
25
24
|
});
|
|
26
25
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
detail
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
_classPrivateFieldInitSpec(this, _onClick, {
|
|
27
|
+
writable: true,
|
|
28
|
+
value: () => {
|
|
29
|
+
const detail = !this.value;
|
|
30
|
+
this.dispatchEvent(new CustomEvent('change', {
|
|
31
|
+
detail,
|
|
32
|
+
bubbles: true
|
|
33
|
+
}));
|
|
34
|
+
this.dispatchEvent(new CustomEvent('-change', {
|
|
35
|
+
detail
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
_classPrivateFieldInitSpec(this, _onChangeReactHandler, {
|
|
41
|
+
writable: true,
|
|
42
|
+
value: e => {
|
|
43
|
+
getReactEventHandler(this, 'on-change')?.(e);
|
|
44
|
+
}
|
|
33
45
|
});
|
|
34
46
|
|
|
35
47
|
const shadowRoot = this.attachShadow();
|
|
@@ -41,11 +53,15 @@ defineCustomElement('sinch-segment-collapse', (_$button = new WeakMap(), class e
|
|
|
41
53
|
connectedCallback() {
|
|
42
54
|
this.setAttribute('role', 'checkbox');
|
|
43
55
|
|
|
44
|
-
_classPrivateFieldGet(this, _$button).addEventListener('click', this
|
|
56
|
+
_classPrivateFieldGet(this, _$button).addEventListener('click', _classPrivateFieldGet(this, _onClick));
|
|
57
|
+
|
|
58
|
+
this.addEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
|
|
45
59
|
}
|
|
46
60
|
|
|
47
61
|
disconnectedCallback() {
|
|
48
|
-
_classPrivateFieldGet(this, _$button).removeEventListener('click', this
|
|
62
|
+
_classPrivateFieldGet(this, _$button).removeEventListener('click', _classPrivateFieldGet(this, _onClick));
|
|
63
|
+
|
|
64
|
+
this.removeEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
|
|
49
65
|
}
|
|
50
66
|
|
|
51
67
|
static get observedAttributes() {
|
|
@@ -3,10 +3,12 @@ import type { SyntheticEvent } from 'react';
|
|
|
3
3
|
export declare type TSinchSegmentExpandElement = HTMLElement & {
|
|
4
4
|
value: boolean;
|
|
5
5
|
addEventListener(type: 'change', listener: (e: CustomEvent<boolean>) => void): void;
|
|
6
|
+
addEventListener(type: '-change', listener: (e: CustomEvent<boolean>) => void): void;
|
|
6
7
|
setAttribute(name: 'value', value: string): void;
|
|
7
8
|
};
|
|
8
9
|
export declare type TSinchSegmentExpandReact = TSinchElementReact<TSinchSegmentExpandElement> & {
|
|
9
10
|
value: boolean;
|
|
10
11
|
'aria-label': string;
|
|
11
|
-
onChange
|
|
12
|
+
onChange?: (e: SyntheticEvent<TSinchSegmentExpandElement, CustomEvent<boolean>>) => void;
|
|
13
|
+
'on-change'?: (e: CustomEvent<boolean>) => void;
|
|
12
14
|
};
|
|
@@ -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,16 +11,14 @@ 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;width:100%;box-sizing:border-box}</style><div id="wrapper"><slot></slot></div>';
|
|
16
16
|
const template = document.createElement('template');
|
|
17
17
|
template.innerHTML = templateHTML;
|
|
18
|
-
defineCustomElement('sinch-segmented-control', (_$slot = new WeakMap(),
|
|
18
|
+
defineCustomElement('sinch-segmented-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
|
|
|
22
|
-
_classPrivateMethodInitSpec(this, _dispatchChangeEvent);
|
|
23
|
-
|
|
24
22
|
_classPrivateMethodInitSpec(this, _onValueChange);
|
|
25
23
|
|
|
26
24
|
_classPrivateFieldInitSpec(this, _$slot, {
|
|
@@ -28,11 +26,6 @@ defineCustomElement('sinch-segmented-control', (_$slot = new WeakMap(), _$sh = n
|
|
|
28
26
|
value: void 0
|
|
29
27
|
});
|
|
30
28
|
|
|
31
|
-
_classPrivateFieldInitSpec(this, _$sh, {
|
|
32
|
-
writable: true,
|
|
33
|
-
value: void 0
|
|
34
|
-
});
|
|
35
|
-
|
|
36
29
|
_classPrivateFieldInitSpec(this, _onSlotChange, {
|
|
37
30
|
writable: true,
|
|
38
31
|
value: () => {
|
|
@@ -44,31 +37,46 @@ defineCustomElement('sinch-segmented-control', (_$slot = new WeakMap(), _$sh = n
|
|
|
44
37
|
writable: true,
|
|
45
38
|
value: e => {
|
|
46
39
|
e.stopPropagation();
|
|
40
|
+
const detail = e.detail;
|
|
41
|
+
this.dispatchEvent(new CustomEvent('change', {
|
|
42
|
+
detail,
|
|
43
|
+
bubbles: true
|
|
44
|
+
}));
|
|
45
|
+
this.dispatchEvent(new CustomEvent('-change', {
|
|
46
|
+
detail
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
49
|
+
});
|
|
47
50
|
|
|
48
|
-
|
|
51
|
+
_classPrivateFieldInitSpec(this, _onChangeReactHandler, {
|
|
52
|
+
writable: true,
|
|
53
|
+
value: e => {
|
|
54
|
+
getReactEventHandler(this, 'on-change')?.(e);
|
|
49
55
|
}
|
|
50
56
|
});
|
|
51
57
|
|
|
52
58
|
const shadowRoot = this.attachShadow();
|
|
53
59
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
54
60
|
|
|
55
|
-
_classPrivateFieldSet(this, _$sh, shadowRoot);
|
|
56
|
-
|
|
57
61
|
_classPrivateFieldSet(this, _$slot, shadowRoot.querySelector('slot'));
|
|
58
62
|
}
|
|
59
63
|
|
|
60
64
|
connectedCallback() {
|
|
61
65
|
this.setAttribute('role', 'tablist');
|
|
62
66
|
|
|
63
|
-
_classPrivateFieldGet(this, _$
|
|
67
|
+
_classPrivateFieldGet(this, _$slot).addEventListener('option-change', _classPrivateFieldGet(this, _onOptionChange));
|
|
64
68
|
|
|
65
69
|
_classPrivateFieldGet(this, _$slot).addEventListener('slotchange', _classPrivateFieldGet(this, _onSlotChange));
|
|
70
|
+
|
|
71
|
+
this.addEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
|
|
66
72
|
}
|
|
67
73
|
|
|
68
74
|
disconnectedCallback() {
|
|
69
|
-
_classPrivateFieldGet(this, _$
|
|
75
|
+
_classPrivateFieldGet(this, _$slot).removeEventListener('option-change', _classPrivateFieldGet(this, _onOptionChange));
|
|
70
76
|
|
|
71
77
|
_classPrivateFieldGet(this, _$slot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onSlotChange));
|
|
78
|
+
|
|
79
|
+
this.removeEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
|
|
72
80
|
}
|
|
73
81
|
|
|
74
82
|
static get observedAttributes() {
|
|
@@ -88,6 +96,10 @@ defineCustomElement('sinch-segmented-control', (_$slot = new WeakMap(), _$sh = n
|
|
|
88
96
|
}
|
|
89
97
|
|
|
90
98
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
99
|
+
if (oldVal === newVal) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
91
103
|
switch (name) {
|
|
92
104
|
case 'value':
|
|
93
105
|
{
|
|
@@ -103,13 +115,6 @@ defineCustomElement('sinch-segmented-control', (_$slot = new WeakMap(), _$sh = n
|
|
|
103
115
|
function _onValueChange2(value) {
|
|
104
116
|
for (const $option of _classPrivateFieldGet(this, _$slot).assignedElements()) {
|
|
105
117
|
const isChecked = !getBooleanAttribute($option, 'disabled') && value === getAttribute($option, 'value', '');
|
|
106
|
-
updateBooleanAttribute($option, 'checked', isChecked);
|
|
118
|
+
updateBooleanAttribute($option, 'data-checked', isChecked);
|
|
107
119
|
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function _dispatchChangeEvent2(value) {
|
|
111
|
-
this.dispatchEvent(new CustomEvent('change', {
|
|
112
|
-
detail: value,
|
|
113
|
-
bubbles: true
|
|
114
|
-
}));
|
|
115
120
|
}
|
|
@@ -2,11 +2,12 @@ import type { TSinchElementReact } from '../types';
|
|
|
2
2
|
import type { SyntheticEvent } from 'react';
|
|
3
3
|
export declare type TSinchSegmentedControlElement = 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 TSinchSegmentedControlReact = TSinchElementReact<TSinchSegmentedControlElement> & {
|
|
9
9
|
value: string;
|
|
10
10
|
'aria-label': string;
|
|
11
|
-
onChange
|
|
11
|
+
onChange?: (event: SyntheticEvent<TSinchSegmentedControlElement, CustomEvent<string>>) => void;
|
|
12
|
+
'on-change'?: (e: CustomEvent<string>) => void;
|
|
12
13
|
};
|
|
@@ -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, _$label,
|
|
4
|
+
var _$button, _$label, _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{display:flex;position:relative;flex-direction:row;align-items:center;gap:12px;width:100%;height:32px;padding:0 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:16px}#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}#content{font:var(--sinch-font-title-s);flex-shrink:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}: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{display:flex;position:relative;flex-direction:row;align-items:center;gap:12px;width:100%;height:32px;padding:0 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:16px}#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}#content{font:var(--sinch-font-title-s);flex-shrink:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}: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:0;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:-3px;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)}</style><div id="wrapper"><slot name="icon"></slot><label for="button" id="content"></label><button id="button"></button></div>';
|
|
12
12
|
const template = document.createElement('template');
|
|
13
13
|
template.innerHTML = templateHTML;
|
|
14
|
-
defineCustomElement('sinch-segmented-control-option', (_$button = new WeakMap(), _$label = new WeakMap(),
|
|
14
|
+
defineCustomElement('sinch-segmented-control-option', (_$button = new WeakMap(), _$label = 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
|
|
|
@@ -25,17 +25,45 @@ defineCustomElement('sinch-segmented-control-option', (_$button = new WeakMap(),
|
|
|
25
25
|
value: void 0
|
|
26
26
|
});
|
|
27
27
|
|
|
28
|
-
_classPrivateFieldInitSpec(this,
|
|
28
|
+
_classPrivateFieldInitSpec(this, _onButtonClick, {
|
|
29
29
|
writable: true,
|
|
30
30
|
value: e => {
|
|
31
31
|
e.stopPropagation();
|
|
32
|
-
this.dispatchEvent(new CustomEvent('change', {
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
this.dispatchEvent(new CustomEvent('option-change', {
|
|
33
|
+
detail: this.value,
|
|
34
|
+
bubbles: true
|
|
35
35
|
}));
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
38
|
|
|
39
|
+
_classPrivateFieldInitSpec(this, _onButtonFocus, {
|
|
40
|
+
writable: true,
|
|
41
|
+
value: () => {
|
|
42
|
+
this.dispatchEvent(new CustomEvent('-focus'));
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
_classPrivateFieldInitSpec(this, _onButtonBlur, {
|
|
47
|
+
writable: true,
|
|
48
|
+
value: () => {
|
|
49
|
+
this.dispatchEvent(new CustomEvent('-blur'));
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
_classPrivateFieldInitSpec(this, _onFocusReactHandler, {
|
|
54
|
+
writable: true,
|
|
55
|
+
value: () => {
|
|
56
|
+
getReactEventHandler(this, 'on-focus')?.();
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
_classPrivateFieldInitSpec(this, _onBlurReactHandler, {
|
|
61
|
+
writable: true,
|
|
62
|
+
value: () => {
|
|
63
|
+
getReactEventHandler(this, 'on-blur')?.();
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
|
|
39
67
|
const shadowRoot = this.attachShadow();
|
|
40
68
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
41
69
|
|
|
@@ -47,15 +75,29 @@ defineCustomElement('sinch-segmented-control-option', (_$button = new WeakMap(),
|
|
|
47
75
|
connectedCallback() {
|
|
48
76
|
this.setAttribute('role', 'tab');
|
|
49
77
|
|
|
50
|
-
_classPrivateFieldGet(this, _$button).addEventListener('click', _classPrivateFieldGet(this,
|
|
78
|
+
_classPrivateFieldGet(this, _$button).addEventListener('click', _classPrivateFieldGet(this, _onButtonClick));
|
|
79
|
+
|
|
80
|
+
_classPrivateFieldGet(this, _$button).addEventListener('focus', _classPrivateFieldGet(this, _onButtonFocus));
|
|
81
|
+
|
|
82
|
+
_classPrivateFieldGet(this, _$button).addEventListener('blur', _classPrivateFieldGet(this, _onButtonBlur));
|
|
83
|
+
|
|
84
|
+
this.addEventListener('-focus', _classPrivateFieldGet(this, _onFocusReactHandler));
|
|
85
|
+
this.addEventListener('-blur', _classPrivateFieldGet(this, _onBlurReactHandler));
|
|
51
86
|
}
|
|
52
87
|
|
|
53
88
|
disconnectedCallback() {
|
|
54
|
-
_classPrivateFieldGet(this, _$button).removeEventListener('click', _classPrivateFieldGet(this,
|
|
89
|
+
_classPrivateFieldGet(this, _$button).removeEventListener('click', _classPrivateFieldGet(this, _onButtonClick));
|
|
90
|
+
|
|
91
|
+
_classPrivateFieldGet(this, _$button).removeEventListener('focus', _classPrivateFieldGet(this, _onButtonFocus));
|
|
92
|
+
|
|
93
|
+
_classPrivateFieldGet(this, _$button).removeEventListener('blur', _classPrivateFieldGet(this, _onButtonBlur));
|
|
94
|
+
|
|
95
|
+
this.removeEventListener('-focus', _classPrivateFieldGet(this, _onFocusReactHandler));
|
|
96
|
+
this.removeEventListener('-blur', _classPrivateFieldGet(this, _onBlurReactHandler));
|
|
55
97
|
}
|
|
56
98
|
|
|
57
99
|
static get observedAttributes() {
|
|
58
|
-
return ['checked', 'disabled', 'text'
|
|
100
|
+
return ['data-checked', 'disabled', 'text'];
|
|
59
101
|
}
|
|
60
102
|
|
|
61
103
|
set value(value) {
|
|
@@ -82,7 +124,11 @@ defineCustomElement('sinch-segmented-control-option', (_$button = new WeakMap(),
|
|
|
82
124
|
return getAttribute(this, 'text', '');
|
|
83
125
|
}
|
|
84
126
|
|
|
85
|
-
attributeChangedCallback(name,
|
|
127
|
+
attributeChangedCallback(name, oldVal, newVal) {
|
|
128
|
+
if (oldVal === newVal) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
|
|
86
132
|
switch (name) {
|
|
87
133
|
case 'text':
|
|
88
134
|
{
|
|
@@ -90,7 +136,7 @@ defineCustomElement('sinch-segmented-control-option', (_$button = new WeakMap(),
|
|
|
90
136
|
break;
|
|
91
137
|
}
|
|
92
138
|
|
|
93
|
-
case 'checked':
|
|
139
|
+
case 'data-checked':
|
|
94
140
|
{
|
|
95
141
|
updateExplicitBooleanAttribute(this, 'aria-selected', isAttrTrue(newVal));
|
|
96
142
|
break;
|
|
@@ -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
|
};
|