@nectary/components 0.39.0 → 0.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/accordion/index.js +47 -84
- package/accordion-item/index.js +26 -53
- package/action-menu/index.d.ts +0 -1
- package/action-menu/index.js +179 -223
- package/action-menu/types.d.ts +8 -18
- package/action-menu-option/index.d.ts +1 -0
- package/action-menu-option/index.js +51 -62
- package/action-menu-option/types.d.ts +9 -0
- package/action-menu-option/utils.d.ts +2 -0
- package/action-menu-option/utils.js +3 -0
- package/alert/index.js +6 -20
- package/avatar/index.js +12 -31
- package/avatar-badge/index.js +8 -22
- package/avatar-status/index.js +1 -1
- package/button/index.js +42 -92
- package/card/index.js +21 -59
- package/chat-avatar/index.js +8 -22
- package/chat-block/index.js +29 -69
- package/chat-bubble/index.js +6 -20
- package/checkbox/index.js +55 -107
- package/chip/index.d.ts +13 -0
- package/chip/index.js +137 -0
- package/chip/types.d.ts +38 -0
- package/color-menu/index.d.ts +13 -0
- package/color-menu/index.js +464 -0
- package/color-menu/types.d.ts +37 -0
- package/color-swatch/index.d.ts +13 -0
- package/color-swatch/index.js +59 -0
- package/color-swatch/types.d.ts +12 -0
- package/colors.json +57 -49
- package/date-picker/index.js +161 -292
- package/dialog/index.js +70 -142
- package/dropdown-checkbox-option/index.js +6 -20
- package/dropdown-radio-option/index.js +6 -20
- package/field/index.js +25 -63
- package/file-drop/index.js +123 -200
- package/file-picker/index.d.ts +0 -1
- package/file-picker/index.js +55 -108
- package/file-status/index.js +15 -39
- package/help-tooltip/index.js +1 -1
- package/horizontal-stepper/index.js +33 -59
- package/horizontal-stepper-item/index.js +13 -37
- package/icon-button/index.js +39 -84
- package/icons-channel/notify/index.d.ts +11 -0
- package/icons-channel/notify/index.js +4 -0
- package/illustrations/create-illustration-class.js +1 -1
- package/inline-alert/index.js +29 -81
- package/input/index.js +113 -222
- package/link/index.js +46 -96
- package/list-item/index.js +1 -1
- package/package.json +12 -14
- package/pagination/index.js +109 -163
- package/popover/index.js +224 -294
- package/progress/index.js +9 -28
- package/radio/index.js +103 -169
- package/radio-option/index.js +24 -48
- package/segment/index.js +49 -130
- package/segment-collapse/index.js +24 -49
- package/segmented-control/index.js +36 -73
- package/segmented-control-option/index.js +41 -87
- package/segmented-icon-control/index.js +47 -84
- package/segmented-icon-control-option/index.js +38 -79
- package/select-button/index.d.ts +13 -0
- package/select-button/index.js +153 -0
- package/select-button/types.d.ts +43 -0
- package/select-menu/index.d.ts +11 -0
- package/select-menu/index.js +346 -0
- package/select-menu/types.d.ts +29 -0
- package/select-menu/types.js +1 -0
- package/{dropdown-text-option → select-menu-option}/index.d.ts +5 -7
- package/select-menu-option/index.js +76 -0
- package/{select-option → select-menu-option}/types.d.ts +8 -9
- package/stop-events/index.js +7 -20
- package/table-head-cell/index.js +7 -21
- package/tabs/index.js +103 -165
- package/tabs-option/index.js +20 -44
- package/tag/index.d.ts +0 -1
- package/tag/index.js +37 -38
- package/tag/types.d.ts +13 -7
- package/textarea/index.js +92 -167
- package/theme.css +80 -49
- package/tile-control/index.js +55 -96
- package/tile-control-option/index.js +40 -86
- package/time-picker/index.js +216 -368
- package/title/index.js +6 -20
- package/toast/index.js +32 -70
- package/toast-manager/index.js +141 -217
- package/toggle/index.js +54 -106
- package/types.d.ts +7 -0
- package/utils/colors.d.ts +10 -0
- package/utils/colors.js +121 -0
- package/{utils.d.ts → utils/index.d.ts} +17 -9
- package/{utils.js → utils/index.js} +96 -39
- package/vertical-stepper/index.js +29 -50
- package/vertical-stepper-item/index.js +13 -37
- package/dropdown/index.d.ts +0 -12
- package/dropdown/index.js +0 -415
- package/dropdown/types.d.ts +0 -32
- package/dropdown-text-option/index.js +0 -104
- package/dropdown-text-option/types.d.ts +0 -16
- package/select/index.d.ts +0 -13
- package/select/index.js +0 -316
- package/select/types.d.ts +0 -53
- package/select-option/index.d.ts +0 -11
- package/select-option/index.js +0 -8
- package/tag/utils.d.ts +0 -5
- package/tag/utils.js +0 -6
- package/tag-close/index.d.ts +0 -12
- package/tag-close/index.js +0 -42
- package/tag-close/types.d.ts +0 -5
- /package/{dropdown-text-option → chip}/types.js +0 -0
- /package/{dropdown → color-menu}/types.js +0 -0
- /package/{select-option → color-swatch}/types.js +0 -0
- /package/{select → select-button}/types.js +0 -0
- /package/{tag-close → select-menu-option}/types.js +0 -0
package/segment/index.js
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
|
-
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
|
-
|
|
4
|
-
var _$caption, _$previewSlot, _$previewWrapper, _$infoSlot, _$infoWrapper, _$collapseSlot, _$collapseWrapper, _$actionSlot, _$actionWrapper, _onPreviewSlotChange, _onInfoSlotChange, _onCollapseSlotChange, _onActionSlotChange;
|
|
5
|
-
|
|
6
|
-
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
7
|
-
|
|
8
|
-
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
9
|
-
|
|
10
1
|
import '../title';
|
|
11
2
|
import { getTitleLevelFromType } from '../title/utils';
|
|
12
3
|
import { defineCustomElement, getAttribute, getBooleanAttribute, getLiteralAttribute, getRect, isAttrTrue, NectaryElement, setClass, updateAttribute, updateBooleanAttribute, updateLiteralAttribute } from '../utils';
|
|
@@ -14,131 +5,48 @@ const templateHTML = '<style>:host{display:block}#wrapper{display:flex;flex-dire
|
|
|
14
5
|
import { assertSize, sizeValues } from './utils';
|
|
15
6
|
const template = document.createElement('template');
|
|
16
7
|
template.innerHTML = templateHTML;
|
|
17
|
-
defineCustomElement('sinch-segment',
|
|
8
|
+
defineCustomElement('sinch-segment', class extends NectaryElement {
|
|
9
|
+
#$caption;
|
|
10
|
+
#$previewSlot;
|
|
11
|
+
#$previewWrapper;
|
|
12
|
+
#$infoSlot;
|
|
13
|
+
#$infoWrapper;
|
|
14
|
+
#$collapseSlot;
|
|
15
|
+
#$collapseWrapper;
|
|
16
|
+
#$actionSlot;
|
|
17
|
+
#$actionWrapper;
|
|
18
|
+
|
|
18
19
|
constructor() {
|
|
19
20
|
super();
|
|
20
|
-
|
|
21
|
-
_classPrivateFieldInitSpec(this, _$caption, {
|
|
22
|
-
writable: true,
|
|
23
|
-
value: void 0
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
_classPrivateFieldInitSpec(this, _$previewSlot, {
|
|
27
|
-
writable: true,
|
|
28
|
-
value: void 0
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
_classPrivateFieldInitSpec(this, _$previewWrapper, {
|
|
32
|
-
writable: true,
|
|
33
|
-
value: void 0
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
_classPrivateFieldInitSpec(this, _$infoSlot, {
|
|
37
|
-
writable: true,
|
|
38
|
-
value: void 0
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
_classPrivateFieldInitSpec(this, _$infoWrapper, {
|
|
42
|
-
writable: true,
|
|
43
|
-
value: void 0
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
_classPrivateFieldInitSpec(this, _$collapseSlot, {
|
|
47
|
-
writable: true,
|
|
48
|
-
value: void 0
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
_classPrivateFieldInitSpec(this, _$collapseWrapper, {
|
|
52
|
-
writable: true,
|
|
53
|
-
value: void 0
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
_classPrivateFieldInitSpec(this, _$actionSlot, {
|
|
57
|
-
writable: true,
|
|
58
|
-
value: void 0
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
_classPrivateFieldInitSpec(this, _$actionWrapper, {
|
|
62
|
-
writable: true,
|
|
63
|
-
value: void 0
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
_classPrivateFieldInitSpec(this, _onPreviewSlotChange, {
|
|
67
|
-
writable: true,
|
|
68
|
-
value: () => {
|
|
69
|
-
setClass(_classPrivateFieldGet(this, _$previewWrapper), 'empty', _classPrivateFieldGet(this, _$previewSlot).assignedElements().length === 0);
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
_classPrivateFieldInitSpec(this, _onInfoSlotChange, {
|
|
74
|
-
writable: true,
|
|
75
|
-
value: () => {
|
|
76
|
-
setClass(_classPrivateFieldGet(this, _$infoWrapper), 'empty', _classPrivateFieldGet(this, _$infoSlot).assignedElements().length === 0);
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
_classPrivateFieldInitSpec(this, _onCollapseSlotChange, {
|
|
81
|
-
writable: true,
|
|
82
|
-
value: () => {
|
|
83
|
-
setClass(_classPrivateFieldGet(this, _$collapseWrapper), 'empty', _classPrivateFieldGet(this, _$collapseSlot).assignedElements().length === 0);
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
_classPrivateFieldInitSpec(this, _onActionSlotChange, {
|
|
88
|
-
writable: true,
|
|
89
|
-
value: () => {
|
|
90
|
-
setClass(_classPrivateFieldGet(this, _$actionWrapper), 'empty', _classPrivateFieldGet(this, _$actionSlot).assignedElements().length === 0);
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
|
|
94
21
|
const shadowRoot = this.attachShadow();
|
|
95
22
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
_classPrivateFieldSet(this, _$actionSlot, shadowRoot.querySelector('slot[name="action"]'));
|
|
106
|
-
|
|
107
|
-
_classPrivateFieldSet(this, _$previewWrapper, shadowRoot.querySelector('#preview'));
|
|
108
|
-
|
|
109
|
-
_classPrivateFieldSet(this, _$infoWrapper, shadowRoot.querySelector('#info'));
|
|
110
|
-
|
|
111
|
-
_classPrivateFieldSet(this, _$collapseWrapper, shadowRoot.querySelector('#collapse'));
|
|
112
|
-
|
|
113
|
-
_classPrivateFieldSet(this, _$actionWrapper, shadowRoot.querySelector('#action'));
|
|
23
|
+
this.#$caption = shadowRoot.querySelector('#caption');
|
|
24
|
+
this.#$previewSlot = shadowRoot.querySelector('slot[name="preview"]');
|
|
25
|
+
this.#$infoSlot = shadowRoot.querySelector('slot[name="info"]');
|
|
26
|
+
this.#$collapseSlot = shadowRoot.querySelector('slot[name="collapse"]');
|
|
27
|
+
this.#$actionSlot = shadowRoot.querySelector('slot[name="action"]');
|
|
28
|
+
this.#$previewWrapper = shadowRoot.querySelector('#preview');
|
|
29
|
+
this.#$infoWrapper = shadowRoot.querySelector('#info');
|
|
30
|
+
this.#$collapseWrapper = shadowRoot.querySelector('#collapse');
|
|
31
|
+
this.#$actionWrapper = shadowRoot.querySelector('#action');
|
|
114
32
|
}
|
|
115
33
|
|
|
116
34
|
connectedCallback() {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
_classPrivateFieldGet(this, _onPreviewSlotChange).call(this);
|
|
126
|
-
|
|
127
|
-
_classPrivateFieldGet(this, _onInfoSlotChange).call(this);
|
|
128
|
-
|
|
129
|
-
_classPrivateFieldGet(this, _onCollapseSlotChange).call(this);
|
|
130
|
-
|
|
131
|
-
_classPrivateFieldGet(this, _onActionSlotChange).call(this);
|
|
35
|
+
this.#$previewSlot.addEventListener('slotchange', this.#onPreviewSlotChange);
|
|
36
|
+
this.#$infoSlot.addEventListener('slotchange', this.#onInfoSlotChange);
|
|
37
|
+
this.#$collapseSlot.addEventListener('slotchange', this.#onCollapseSlotChange);
|
|
38
|
+
this.#$actionSlot.addEventListener('slotchange', this.#onActionSlotChange);
|
|
39
|
+
this.#onPreviewSlotChange();
|
|
40
|
+
this.#onInfoSlotChange();
|
|
41
|
+
this.#onCollapseSlotChange();
|
|
42
|
+
this.#onActionSlotChange();
|
|
132
43
|
}
|
|
133
44
|
|
|
134
45
|
disconnectedCallback() {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
_classPrivateFieldGet(this, _$collapseSlot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onCollapseSlotChange));
|
|
140
|
-
|
|
141
|
-
_classPrivateFieldGet(this, _$actionSlot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onActionSlotChange));
|
|
46
|
+
this.#$previewSlot.removeEventListener('slotchange', this.#onPreviewSlotChange);
|
|
47
|
+
this.#$infoSlot.removeEventListener('slotchange', this.#onInfoSlotChange);
|
|
48
|
+
this.#$collapseSlot.removeEventListener('slotchange', this.#onCollapseSlotChange);
|
|
49
|
+
this.#$actionSlot.removeEventListener('slotchange', this.#onActionSlotChange);
|
|
142
50
|
}
|
|
143
51
|
|
|
144
52
|
static get observedAttributes() {
|
|
@@ -149,7 +57,7 @@ defineCustomElement('sinch-segment', (_$caption = new WeakMap(), _$previewSlot =
|
|
|
149
57
|
switch (name) {
|
|
150
58
|
case 'caption':
|
|
151
59
|
{
|
|
152
|
-
updateAttribute(
|
|
60
|
+
updateAttribute(this.#$caption, 'text', newVal);
|
|
153
61
|
break;
|
|
154
62
|
}
|
|
155
63
|
|
|
@@ -162,8 +70,8 @@ defineCustomElement('sinch-segment', (_$caption = new WeakMap(), _$previewSlot =
|
|
|
162
70
|
case 'size':
|
|
163
71
|
{
|
|
164
72
|
assertSize(newVal);
|
|
165
|
-
updateAttribute(
|
|
166
|
-
updateAttribute(
|
|
73
|
+
updateAttribute(this.#$caption, 'type', newVal);
|
|
74
|
+
updateAttribute(this.#$caption, 'level', getTitleLevelFromType(newVal));
|
|
167
75
|
break;
|
|
168
76
|
}
|
|
169
77
|
}
|
|
@@ -194,9 +102,20 @@ defineCustomElement('sinch-segment', (_$caption = new WeakMap(), _$previewSlot =
|
|
|
194
102
|
}
|
|
195
103
|
|
|
196
104
|
get collapseButtonRect() {
|
|
197
|
-
const $collapseButton =
|
|
198
|
-
|
|
105
|
+
const $collapseButton = this.#$collapseSlot.assignedElements()[0];
|
|
199
106
|
return $collapseButton != null ? getRect($collapseButton) : null;
|
|
200
107
|
}
|
|
201
108
|
|
|
202
|
-
|
|
109
|
+
#onPreviewSlotChange = () => {
|
|
110
|
+
setClass(this.#$previewWrapper, 'empty', this.#$previewSlot.assignedElements().length === 0);
|
|
111
|
+
};
|
|
112
|
+
#onInfoSlotChange = () => {
|
|
113
|
+
setClass(this.#$infoWrapper, 'empty', this.#$infoSlot.assignedElements().length === 0);
|
|
114
|
+
};
|
|
115
|
+
#onCollapseSlotChange = () => {
|
|
116
|
+
setClass(this.#$collapseWrapper, 'empty', this.#$collapseSlot.assignedElements().length === 0);
|
|
117
|
+
};
|
|
118
|
+
#onActionSlotChange = () => {
|
|
119
|
+
setClass(this.#$actionWrapper, 'empty', this.#$actionSlot.assignedElements().length === 0);
|
|
120
|
+
};
|
|
121
|
+
});
|
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
|
-
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
|
-
|
|
4
|
-
var _$button, _onClick, _onChangeReactHandler;
|
|
5
|
-
|
|
6
|
-
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
7
|
-
|
|
8
|
-
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
9
|
-
|
|
10
1
|
import '../icons/expand-less';
|
|
11
2
|
import '../icons/expand-more';
|
|
12
3
|
import '../icon-button';
|
|
@@ -14,54 +5,25 @@ import { defineCustomElement, getBooleanAttribute, getReactEventHandler, isAttrT
|
|
|
14
5
|
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>';
|
|
15
6
|
const template = document.createElement('template');
|
|
16
7
|
template.innerHTML = templateHTML;
|
|
17
|
-
defineCustomElement('sinch-segment-collapse',
|
|
8
|
+
defineCustomElement('sinch-segment-collapse', class extends NectaryElement {
|
|
9
|
+
#$button;
|
|
10
|
+
|
|
18
11
|
constructor() {
|
|
19
12
|
super();
|
|
20
|
-
|
|
21
|
-
_classPrivateFieldInitSpec(this, _$button, {
|
|
22
|
-
writable: true,
|
|
23
|
-
value: void 0
|
|
24
|
-
});
|
|
25
|
-
|
|
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
|
-
}
|
|
45
|
-
});
|
|
46
|
-
|
|
47
13
|
const shadowRoot = this.attachShadow();
|
|
48
14
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
49
|
-
|
|
50
|
-
_classPrivateFieldSet(this, _$button, shadowRoot.querySelector('#button'));
|
|
15
|
+
this.#$button = shadowRoot.querySelector('#button');
|
|
51
16
|
}
|
|
52
17
|
|
|
53
18
|
connectedCallback() {
|
|
54
19
|
this.setAttribute('role', 'checkbox');
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
this.addEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
|
|
20
|
+
this.#$button.addEventListener('click', this.#onClick);
|
|
21
|
+
this.addEventListener('-change', this.#onChangeReactHandler);
|
|
59
22
|
}
|
|
60
23
|
|
|
61
24
|
disconnectedCallback() {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
this.removeEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
|
|
25
|
+
this.#$button.removeEventListener('click', this.#onClick);
|
|
26
|
+
this.removeEventListener('-change', this.#onChangeReactHandler);
|
|
65
27
|
}
|
|
66
28
|
|
|
67
29
|
static get observedAttributes() {
|
|
@@ -95,11 +57,24 @@ defineCustomElement('sinch-segment-collapse', (_$button = new WeakMap(), _onClic
|
|
|
95
57
|
}
|
|
96
58
|
|
|
97
59
|
focus() {
|
|
98
|
-
|
|
60
|
+
this.#$button.focus();
|
|
99
61
|
}
|
|
100
62
|
|
|
101
63
|
blur() {
|
|
102
|
-
|
|
64
|
+
this.#$button.blur();
|
|
103
65
|
}
|
|
104
66
|
|
|
105
|
-
|
|
67
|
+
#onClick = () => {
|
|
68
|
+
const detail = !this.value;
|
|
69
|
+
this.dispatchEvent(new CustomEvent('change', {
|
|
70
|
+
detail,
|
|
71
|
+
bubbles: true
|
|
72
|
+
}));
|
|
73
|
+
this.dispatchEvent(new CustomEvent('-change', {
|
|
74
|
+
detail
|
|
75
|
+
}));
|
|
76
|
+
};
|
|
77
|
+
#onChangeReactHandler = e => {
|
|
78
|
+
getReactEventHandler(this, 'on-change')?.(e);
|
|
79
|
+
};
|
|
80
|
+
});
|
|
@@ -1,82 +1,28 @@
|
|
|
1
|
-
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
|
-
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
|
-
|
|
4
|
-
var _$slot, _onSlotChange, _onOptionChange, _onValueChange, _onChangeReactHandler;
|
|
5
|
-
|
|
6
|
-
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
|
7
|
-
|
|
8
|
-
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
9
|
-
|
|
10
|
-
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
11
|
-
|
|
12
|
-
function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
|
|
13
|
-
|
|
14
1
|
import { defineCustomElement, getAttribute, getBooleanAttribute, getReactEventHandler, NectaryElement, updateAttribute, updateBooleanAttribute } from '../utils';
|
|
15
2
|
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
3
|
const template = document.createElement('template');
|
|
17
4
|
template.innerHTML = templateHTML;
|
|
18
|
-
defineCustomElement('sinch-segmented-control',
|
|
5
|
+
defineCustomElement('sinch-segmented-control', class extends NectaryElement {
|
|
6
|
+
#$slot;
|
|
7
|
+
|
|
19
8
|
constructor() {
|
|
20
9
|
super();
|
|
21
|
-
|
|
22
|
-
_classPrivateMethodInitSpec(this, _onValueChange);
|
|
23
|
-
|
|
24
|
-
_classPrivateFieldInitSpec(this, _$slot, {
|
|
25
|
-
writable: true,
|
|
26
|
-
value: void 0
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
_classPrivateFieldInitSpec(this, _onSlotChange, {
|
|
30
|
-
writable: true,
|
|
31
|
-
value: () => {
|
|
32
|
-
_classPrivateMethodGet(this, _onValueChange, _onValueChange2).call(this, this.value);
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
_classPrivateFieldInitSpec(this, _onOptionChange, {
|
|
37
|
-
writable: true,
|
|
38
|
-
value: e => {
|
|
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
|
-
});
|
|
50
|
-
|
|
51
|
-
_classPrivateFieldInitSpec(this, _onChangeReactHandler, {
|
|
52
|
-
writable: true,
|
|
53
|
-
value: e => {
|
|
54
|
-
getReactEventHandler(this, 'on-change')?.(e);
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
|
|
58
10
|
const shadowRoot = this.attachShadow();
|
|
59
11
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
60
|
-
|
|
61
|
-
_classPrivateFieldSet(this, _$slot, shadowRoot.querySelector('slot'));
|
|
12
|
+
this.#$slot = shadowRoot.querySelector('slot');
|
|
62
13
|
}
|
|
63
14
|
|
|
64
15
|
connectedCallback() {
|
|
65
16
|
this.setAttribute('role', 'tablist');
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
_classPrivateFieldGet(this, _$slot).addEventListener('slotchange', _classPrivateFieldGet(this, _onSlotChange));
|
|
70
|
-
|
|
71
|
-
this.addEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
|
|
17
|
+
this.#$slot.addEventListener('option-change', this.#onOptionChange);
|
|
18
|
+
this.#$slot.addEventListener('slotchange', this.#onSlotChange);
|
|
19
|
+
this.addEventListener('-change', this.#onChangeReactHandler);
|
|
72
20
|
}
|
|
73
21
|
|
|
74
22
|
disconnectedCallback() {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
this.removeEventListener('-change', _classPrivateFieldGet(this, _onChangeReactHandler));
|
|
23
|
+
this.#$slot.removeEventListener('option-change', this.#onOptionChange);
|
|
24
|
+
this.#$slot.removeEventListener('slotchange', this.#onSlotChange);
|
|
25
|
+
this.removeEventListener('-change', this.#onChangeReactHandler);
|
|
80
26
|
}
|
|
81
27
|
|
|
82
28
|
static get observedAttributes() {
|
|
@@ -103,18 +49,35 @@ defineCustomElement('sinch-segmented-control', (_$slot = new WeakMap(), _onSlotC
|
|
|
103
49
|
switch (name) {
|
|
104
50
|
case 'value':
|
|
105
51
|
{
|
|
106
|
-
|
|
107
|
-
|
|
52
|
+
this.#onValueChange(newVal);
|
|
108
53
|
break;
|
|
109
54
|
}
|
|
110
55
|
}
|
|
111
56
|
}
|
|
112
57
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
58
|
+
#onSlotChange = () => {
|
|
59
|
+
this.#onValueChange(this.value);
|
|
60
|
+
};
|
|
61
|
+
#onOptionChange = e => {
|
|
62
|
+
e.stopPropagation();
|
|
63
|
+
const detail = e.detail;
|
|
64
|
+
this.dispatchEvent(new CustomEvent('change', {
|
|
65
|
+
detail,
|
|
66
|
+
bubbles: true
|
|
67
|
+
}));
|
|
68
|
+
this.dispatchEvent(new CustomEvent('-change', {
|
|
69
|
+
detail
|
|
70
|
+
}));
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
#onValueChange(value) {
|
|
74
|
+
for (const $option of this.#$slot.assignedElements()) {
|
|
75
|
+
const isChecked = !getBooleanAttribute($option, 'disabled') && value === getAttribute($option, 'value', '');
|
|
76
|
+
updateBooleanAttribute($option, 'data-checked', isChecked);
|
|
77
|
+
}
|
|
119
78
|
}
|
|
120
|
-
|
|
79
|
+
|
|
80
|
+
#onChangeReactHandler = e => {
|
|
81
|
+
getReactEventHandler(this, 'on-change')?.(e);
|
|
82
|
+
};
|
|
83
|
+
});
|
|
@@ -1,99 +1,34 @@
|
|
|
1
|
-
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
|
-
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
|
-
|
|
4
|
-
var _$button, _$label, _onButtonClick, _onButtonFocus, _onButtonBlur, _onFocusReactHandler, _onBlurReactHandler;
|
|
5
|
-
|
|
6
|
-
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
7
|
-
|
|
8
|
-
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
9
|
-
|
|
10
1
|
import { 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-
|
|
2
|
+
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-400)}: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
3
|
const template = document.createElement('template');
|
|
13
4
|
template.innerHTML = templateHTML;
|
|
14
|
-
defineCustomElement('sinch-segmented-control-option',
|
|
5
|
+
defineCustomElement('sinch-segmented-control-option', class extends NectaryElement {
|
|
6
|
+
#$button;
|
|
7
|
+
#$label;
|
|
8
|
+
|
|
15
9
|
constructor() {
|
|
16
10
|
super();
|
|
17
|
-
|
|
18
|
-
_classPrivateFieldInitSpec(this, _$button, {
|
|
19
|
-
writable: true,
|
|
20
|
-
value: void 0
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
_classPrivateFieldInitSpec(this, _$label, {
|
|
24
|
-
writable: true,
|
|
25
|
-
value: void 0
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
_classPrivateFieldInitSpec(this, _onButtonClick, {
|
|
29
|
-
writable: true,
|
|
30
|
-
value: e => {
|
|
31
|
-
e.stopPropagation();
|
|
32
|
-
this.dispatchEvent(new CustomEvent('option-change', {
|
|
33
|
-
detail: this.value,
|
|
34
|
-
bubbles: true
|
|
35
|
-
}));
|
|
36
|
-
}
|
|
37
|
-
});
|
|
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
|
-
|
|
67
11
|
const shadowRoot = this.attachShadow();
|
|
68
12
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
_classPrivateFieldSet(this, _$label, shadowRoot.querySelector('#content'));
|
|
13
|
+
this.#$button = shadowRoot.querySelector('#button');
|
|
14
|
+
this.#$label = shadowRoot.querySelector('#content');
|
|
73
15
|
}
|
|
74
16
|
|
|
75
17
|
connectedCallback() {
|
|
76
18
|
this.setAttribute('role', 'tab');
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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));
|
|
19
|
+
this.#$button.addEventListener('click', this.#onButtonClick);
|
|
20
|
+
this.#$button.addEventListener('focus', this.#onButtonFocus);
|
|
21
|
+
this.#$button.addEventListener('blur', this.#onButtonBlur);
|
|
22
|
+
this.addEventListener('-focus', this.#onFocusReactHandler);
|
|
23
|
+
this.addEventListener('-blur', this.#onBlurReactHandler);
|
|
86
24
|
}
|
|
87
25
|
|
|
88
26
|
disconnectedCallback() {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
this.removeEventListener('-focus', _classPrivateFieldGet(this, _onFocusReactHandler));
|
|
96
|
-
this.removeEventListener('-blur', _classPrivateFieldGet(this, _onBlurReactHandler));
|
|
27
|
+
this.#$button.removeEventListener('click', this.#onButtonClick);
|
|
28
|
+
this.#$button.removeEventListener('focus', this.#onButtonFocus);
|
|
29
|
+
this.#$button.removeEventListener('blur', this.#onButtonBlur);
|
|
30
|
+
this.removeEventListener('-focus', this.#onFocusReactHandler);
|
|
31
|
+
this.removeEventListener('-blur', this.#onBlurReactHandler);
|
|
97
32
|
}
|
|
98
33
|
|
|
99
34
|
static get observedAttributes() {
|
|
@@ -132,7 +67,7 @@ defineCustomElement('sinch-segmented-control-option', (_$button = new WeakMap(),
|
|
|
132
67
|
switch (name) {
|
|
133
68
|
case 'text':
|
|
134
69
|
{
|
|
135
|
-
|
|
70
|
+
this.#$label.textContent = newVal;
|
|
136
71
|
break;
|
|
137
72
|
}
|
|
138
73
|
|
|
@@ -144,18 +79,37 @@ defineCustomElement('sinch-segmented-control-option', (_$button = new WeakMap(),
|
|
|
144
79
|
|
|
145
80
|
case 'disabled':
|
|
146
81
|
{
|
|
147
|
-
|
|
82
|
+
this.#$button.disabled = isAttrTrue(newVal);
|
|
148
83
|
break;
|
|
149
84
|
}
|
|
150
85
|
}
|
|
151
86
|
}
|
|
152
87
|
|
|
153
88
|
focus() {
|
|
154
|
-
|
|
89
|
+
this.#$button.focus();
|
|
155
90
|
}
|
|
156
91
|
|
|
157
92
|
blur() {
|
|
158
|
-
|
|
93
|
+
this.#$button.blur();
|
|
159
94
|
}
|
|
160
95
|
|
|
161
|
-
|
|
96
|
+
#onButtonClick = e => {
|
|
97
|
+
e.stopPropagation();
|
|
98
|
+
this.dispatchEvent(new CustomEvent('option-change', {
|
|
99
|
+
detail: this.value,
|
|
100
|
+
bubbles: true
|
|
101
|
+
}));
|
|
102
|
+
};
|
|
103
|
+
#onButtonFocus = () => {
|
|
104
|
+
this.dispatchEvent(new CustomEvent('-focus'));
|
|
105
|
+
};
|
|
106
|
+
#onButtonBlur = () => {
|
|
107
|
+
this.dispatchEvent(new CustomEvent('-blur'));
|
|
108
|
+
};
|
|
109
|
+
#onFocusReactHandler = () => {
|
|
110
|
+
getReactEventHandler(this, 'on-focus')?.();
|
|
111
|
+
};
|
|
112
|
+
#onBlurReactHandler = () => {
|
|
113
|
+
getReactEventHandler(this, 'on-blur')?.();
|
|
114
|
+
};
|
|
115
|
+
});
|