@nectary/components 0.41.0 → 0.42.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 +0 -16
- package/accordion/types.d.ts +9 -1
- package/accordion-item/index.js +0 -24
- package/accordion-item/types.d.ts +18 -3
- package/action-menu/index.js +1 -45
- package/action-menu-option/index.js +0 -18
- package/alert/index.js +0 -10
- package/alert/types.d.ts +6 -0
- package/avatar/index.js +57 -20
- package/avatar/types.d.ts +25 -7
- package/avatar/utils.d.ts +10 -2
- package/avatar/utils.js +23 -2
- package/badge/index.d.ts +11 -0
- package/badge/index.js +140 -0
- package/badge/types.d.ts +38 -0
- package/badge/utils.d.ts +11 -0
- package/badge/utils.js +23 -0
- package/button/index.js +0 -18
- package/card/index.js +0 -16
- package/card/types.d.ts +15 -3
- package/card-container/index.js +0 -1
- package/chat/index.js +0 -1
- package/chat-block/index.js +0 -19
- package/chat-block/types.d.ts +16 -4
- package/chat-bubble/index.js +0 -9
- package/chat-bubble/types.d.ts +6 -0
- package/checkbox/index.js +0 -23
- package/chip/index.js +16 -25
- package/chip/utils.d.ts +3 -0
- package/chip/utils.js +11 -0
- package/color-menu/index.js +8 -86
- package/color-menu/utils.js +0 -4
- package/color-swatch/index.js +17 -17
- package/color-swatch/types.d.ts +2 -2
- package/color-swatch/utils.d.ts +3 -0
- package/color-swatch/utils.js +11 -0
- package/date-picker/index.js +1 -50
- package/date-picker/utils.js +0 -7
- package/dialog/index.js +1 -17
- package/field/index.js +0 -19
- package/file-drop/index.js +0 -40
- package/file-drop/utils.js +0 -6
- package/file-picker/index.js +0 -17
- package/file-picker/utils.js +0 -1
- package/file-status/index.js +0 -12
- package/grid/index.js +0 -1
- package/grid-item/index.js +0 -9
- package/help-tooltip/index.js +0 -14
- package/horizontal-stepper/index.js +0 -12
- package/horizontal-stepper-item/index.js +0 -14
- package/icon-button/index.js +0 -15
- package/icons/create-icon-class.js +0 -2
- package/icons-branded/create-icon-class.js +0 -8
- package/icons-channel/create-icon-class.js +0 -6
- package/illustrations/create-illustration-class.js +0 -11
- package/inline-alert/index.js +0 -14
- package/input/index.js +0 -37
- package/link/index.js +0 -25
- package/list/index.js +0 -2
- package/list-item/index.js +0 -2
- package/logo/create-logo-class.js +0 -9
- package/package.json +1 -1
- package/pagination/index.js +0 -31
- package/pop/index.js +64 -68
- package/pop/utils.js +0 -1
- package/popover/index.js +0 -33
- package/popover/utils.js +0 -2
- package/progress/index.js +0 -10
- package/radio/index.js +0 -30
- package/radio-option/index.js +0 -20
- package/segment/index.js +0 -15
- package/segment-collapse/index.js +0 -13
- package/segmented-control/index.js +0 -12
- package/segmented-control-option/index.js +0 -18
- package/segmented-icon-control/index.js +0 -16
- package/segmented-icon-control-option/index.js +0 -14
- package/select-button/index.js +0 -23
- package/select-menu/index.js +1 -63
- package/select-menu-option/index.js +0 -14
- package/spinner/index.js +0 -4
- package/stop-events/index.js +0 -5
- package/table/index.js +0 -2
- package/table-body/index.js +0 -2
- package/table-cell/index.js +0 -4
- package/table-head/index.js +0 -2
- package/table-head-cell/index.js +0 -11
- package/table-row/index.js +0 -6
- package/tabs/index.js +0 -30
- package/tabs-option/index.js +0 -19
- package/tag/index.js +18 -21
- package/tag/utils.d.ts +3 -0
- package/tag/utils.js +11 -0
- package/text/index.js +1 -12
- package/textarea/index.js +0 -40
- package/{utils → theme}/colors.d.ts +0 -1
- package/{utils → theme}/colors.js +0 -1
- package/theme.css +13 -209
- package/tile-control/index.js +0 -24
- package/tile-control-option/index.js +0 -18
- package/time-picker/index.js +2 -51
- package/time-picker/utils.js +0 -18
- package/title/index.js +1 -12
- package/title/utils.js +0 -5
- package/toast/index.js +0 -19
- package/toast-manager/index.js +0 -27
- package/toggle/index.js +0 -23
- package/tooltip/index.js +0 -27
- package/tooltip/utils.js +0 -4
- package/utils/animation.js +0 -20
- package/utils/context.js +0 -6
- package/utils/index.d.ts +1 -0
- package/utils/index.js +11 -52
- package/vertical-stepper/index.js +0 -12
- package/vertical-stepper-item/index.js +0 -14
- package/avatar-badge/index.d.ts +0 -11
- package/avatar-badge/index.js +0 -38
- package/avatar-badge/types.d.ts +0 -8
- package/avatar-status/index.d.ts +0 -11
- package/avatar-status/index.js +0 -37
- package/avatar-status/types.d.ts +0 -9
- package/avatar-status/types.js +0 -1
- package/avatar-status/utils.d.ts +0 -5
- package/avatar-status/utils.js +0 -6
- package/chat-avatar/index.d.ts +0 -12
- package/chat-avatar/index.js +0 -52
- package/chat-avatar/types.d.ts +0 -12
- package/chat-avatar/types.js +0 -1
- /package/{avatar-badge → badge}/types.js +0 -0
package/toggle/index.js
CHANGED
|
@@ -5,7 +5,6 @@ template.innerHTML = templateHTML;
|
|
|
5
5
|
defineCustomElement('sinch-toggle', class extends NectaryElement {
|
|
6
6
|
#$input;
|
|
7
7
|
#$label;
|
|
8
|
-
|
|
9
8
|
constructor() {
|
|
10
9
|
super();
|
|
11
10
|
const shadowRoot = this.attachShadow();
|
|
@@ -13,7 +12,6 @@ defineCustomElement('sinch-toggle', class extends NectaryElement {
|
|
|
13
12
|
this.#$input = shadowRoot.querySelector('#input');
|
|
14
13
|
this.#$label = shadowRoot.querySelector('#label');
|
|
15
14
|
}
|
|
16
|
-
|
|
17
15
|
connectedCallback() {
|
|
18
16
|
this.setAttribute('role', 'checkbox');
|
|
19
17
|
this.#$input.addEventListener('input', this.#onInput);
|
|
@@ -23,7 +21,6 @@ defineCustomElement('sinch-toggle', class extends NectaryElement {
|
|
|
23
21
|
this.addEventListener('-focus', this.#onFocusReactHandler);
|
|
24
22
|
this.addEventListener('-blur', this.#onBlurReactHandler);
|
|
25
23
|
}
|
|
26
|
-
|
|
27
24
|
disconnectedCallback() {
|
|
28
25
|
this.#$input.removeEventListener('input', this.#onInput);
|
|
29
26
|
this.#$input.removeEventListener('focus', this.#onCheckboxFocus);
|
|
@@ -32,59 +29,45 @@ defineCustomElement('sinch-toggle', class extends NectaryElement {
|
|
|
32
29
|
this.removeEventListener('-focus', this.#onFocusReactHandler);
|
|
33
30
|
this.removeEventListener('-blur', this.#onBlurReactHandler);
|
|
34
31
|
}
|
|
35
|
-
|
|
36
32
|
static get observedAttributes() {
|
|
37
33
|
return ['checked', 'disabled', 'text'];
|
|
38
34
|
}
|
|
39
|
-
|
|
40
35
|
get type() {
|
|
41
36
|
return 'text';
|
|
42
37
|
}
|
|
43
|
-
|
|
44
38
|
get nodeName() {
|
|
45
39
|
return 'input';
|
|
46
40
|
}
|
|
47
|
-
|
|
48
41
|
set checked(isChecked) {
|
|
49
42
|
updateBooleanAttribute(this, 'checked', isChecked);
|
|
50
43
|
}
|
|
51
|
-
|
|
52
44
|
get checked() {
|
|
53
45
|
return getBooleanAttribute(this, 'checked');
|
|
54
46
|
}
|
|
55
|
-
|
|
56
47
|
set small(isSmall) {
|
|
57
48
|
updateBooleanAttribute(this, 'small', isSmall);
|
|
58
49
|
}
|
|
59
|
-
|
|
60
50
|
get small() {
|
|
61
51
|
return getBooleanAttribute(this, 'small');
|
|
62
52
|
}
|
|
63
|
-
|
|
64
53
|
set labeled(isLabeled) {
|
|
65
54
|
updateBooleanAttribute(this, 'labeled', isLabeled);
|
|
66
55
|
}
|
|
67
|
-
|
|
68
56
|
get labeled() {
|
|
69
57
|
return getBooleanAttribute(this, 'labeled');
|
|
70
58
|
}
|
|
71
|
-
|
|
72
59
|
set disabled(isDisabled) {
|
|
73
60
|
updateBooleanAttribute(this, 'disabled', isDisabled);
|
|
74
61
|
}
|
|
75
|
-
|
|
76
62
|
get disabled() {
|
|
77
63
|
return getBooleanAttribute(this, 'disabled');
|
|
78
64
|
}
|
|
79
|
-
|
|
80
65
|
set text(value) {
|
|
81
66
|
updateAttribute(this, 'text', value);
|
|
82
67
|
}
|
|
83
|
-
|
|
84
68
|
get text() {
|
|
85
69
|
return getAttribute(this, 'text');
|
|
86
70
|
}
|
|
87
|
-
|
|
88
71
|
attributeChangedCallback(name, _, newVal) {
|
|
89
72
|
switch (name) {
|
|
90
73
|
case 'text':
|
|
@@ -92,7 +75,6 @@ defineCustomElement('sinch-toggle', class extends NectaryElement {
|
|
|
92
75
|
this.#$label.textContent = newVal;
|
|
93
76
|
break;
|
|
94
77
|
}
|
|
95
|
-
|
|
96
78
|
case 'checked':
|
|
97
79
|
{
|
|
98
80
|
const isChecked = isAttrTrue(newVal);
|
|
@@ -100,7 +82,6 @@ defineCustomElement('sinch-toggle', class extends NectaryElement {
|
|
|
100
82
|
updateExplicitBooleanAttribute(this, 'aria-checked', isChecked);
|
|
101
83
|
break;
|
|
102
84
|
}
|
|
103
|
-
|
|
104
85
|
case 'disabled':
|
|
105
86
|
{
|
|
106
87
|
const isDisabled = isAttrTrue(newVal);
|
|
@@ -110,19 +91,15 @@ defineCustomElement('sinch-toggle', class extends NectaryElement {
|
|
|
110
91
|
}
|
|
111
92
|
}
|
|
112
93
|
}
|
|
113
|
-
|
|
114
94
|
get focusable() {
|
|
115
95
|
return true;
|
|
116
96
|
}
|
|
117
|
-
|
|
118
97
|
focus() {
|
|
119
98
|
this.#$input.focus();
|
|
120
99
|
}
|
|
121
|
-
|
|
122
100
|
blur() {
|
|
123
101
|
this.#$input.blur();
|
|
124
102
|
}
|
|
125
|
-
|
|
126
103
|
#onInput = e => {
|
|
127
104
|
e.stopPropagation();
|
|
128
105
|
const isChecked = this.#$input.checked;
|
package/tooltip/index.js
CHANGED
|
@@ -21,7 +21,6 @@ defineCustomElement('sinch-tooltip', class extends NectaryElement {
|
|
|
21
21
|
#tooltipState;
|
|
22
22
|
#animation = null;
|
|
23
23
|
#shouldReduceMotion = false;
|
|
24
|
-
|
|
25
24
|
constructor() {
|
|
26
25
|
super();
|
|
27
26
|
const shadowRoot = this.attachShadow();
|
|
@@ -42,7 +41,6 @@ defineCustomElement('sinch-tooltip', class extends NectaryElement {
|
|
|
42
41
|
onHideEnd: this.#onHideEnd
|
|
43
42
|
});
|
|
44
43
|
}
|
|
45
|
-
|
|
46
44
|
connectedCallback() {
|
|
47
45
|
this.#controller = new AbortController();
|
|
48
46
|
const {
|
|
@@ -68,48 +66,37 @@ defineCustomElement('sinch-tooltip', class extends NectaryElement {
|
|
|
68
66
|
});
|
|
69
67
|
updateAttribute(this.#$pop, 'orientation', getPopOrientation(this.orientation));
|
|
70
68
|
}
|
|
71
|
-
|
|
72
69
|
disconnectedCallback() {
|
|
73
70
|
this.#controller.abort();
|
|
74
71
|
this.#tooltipState.destroy();
|
|
75
72
|
}
|
|
76
|
-
|
|
77
73
|
static get observedAttributes() {
|
|
78
74
|
return ['text', 'orientation'];
|
|
79
75
|
}
|
|
80
|
-
|
|
81
76
|
get text() {
|
|
82
77
|
return getAttribute(this, 'text', '');
|
|
83
78
|
}
|
|
84
|
-
|
|
85
79
|
set text(value) {
|
|
86
80
|
updateAttribute(this, 'text', value);
|
|
87
81
|
}
|
|
88
|
-
|
|
89
82
|
get inverted() {
|
|
90
83
|
return getBooleanAttribute(this, 'inverted');
|
|
91
84
|
}
|
|
92
|
-
|
|
93
85
|
set inverted(isInverted) {
|
|
94
86
|
updateBooleanAttribute(this, 'inverted', isInverted);
|
|
95
87
|
}
|
|
96
|
-
|
|
97
88
|
get orientation() {
|
|
98
89
|
return getLiteralAttribute(this, orientationValues, 'orientation', 'top');
|
|
99
90
|
}
|
|
100
|
-
|
|
101
91
|
set orientation(value) {
|
|
102
92
|
updateLiteralAttribute(this, orientationValues, 'orientation', value);
|
|
103
93
|
}
|
|
104
|
-
|
|
105
94
|
get footprintRect() {
|
|
106
95
|
return this.#$pop.footprintRect;
|
|
107
96
|
}
|
|
108
|
-
|
|
109
97
|
get tooltipRect() {
|
|
110
98
|
return this.#$pop.popoverRect;
|
|
111
99
|
}
|
|
112
|
-
|
|
113
100
|
attributeChangedCallback(name, _, newVal) {
|
|
114
101
|
switch (name) {
|
|
115
102
|
case 'text':
|
|
@@ -117,22 +104,18 @@ defineCustomElement('sinch-tooltip', class extends NectaryElement {
|
|
|
117
104
|
this.#$tooltipText.textContent = newVal;
|
|
118
105
|
break;
|
|
119
106
|
}
|
|
120
|
-
|
|
121
107
|
case 'orientation':
|
|
122
108
|
{
|
|
123
109
|
assertOrientation(newVal);
|
|
124
110
|
updateAttribute(this.#$pop, 'orientation', getPopOrientation(newVal));
|
|
125
|
-
|
|
126
111
|
if (this.#isOpen()) {
|
|
127
112
|
this.#resetTipOrientation();
|
|
128
113
|
this.#updateTipOrientation();
|
|
129
114
|
}
|
|
130
|
-
|
|
131
115
|
break;
|
|
132
116
|
}
|
|
133
117
|
}
|
|
134
118
|
}
|
|
135
|
-
|
|
136
119
|
#onMouseDown = () => {
|
|
137
120
|
this.#tooltipState.interrupt();
|
|
138
121
|
};
|
|
@@ -150,7 +133,6 @@ defineCustomElement('sinch-tooltip', class extends NectaryElement {
|
|
|
150
133
|
#onShow = () => {
|
|
151
134
|
updateBooleanAttribute(this.#$pop, 'open', true);
|
|
152
135
|
requestAnimationFrame(this.#updateTipOrientation);
|
|
153
|
-
|
|
154
136
|
if (this.#animation !== null) {
|
|
155
137
|
this.#animation.updatePlaybackRate(1);
|
|
156
138
|
this.#animation.play();
|
|
@@ -173,41 +155,32 @@ defineCustomElement('sinch-tooltip', class extends NectaryElement {
|
|
|
173
155
|
this.#resetTipOrientation();
|
|
174
156
|
updateBooleanAttribute(this.#$pop, 'open', false);
|
|
175
157
|
};
|
|
176
|
-
|
|
177
158
|
#resetTipOrientation() {
|
|
178
159
|
this.#$tip.style.top = '';
|
|
179
160
|
this.#$tip.style.left = '';
|
|
180
161
|
}
|
|
181
|
-
|
|
182
162
|
#updateTipOrientation = () => {
|
|
183
163
|
const orient = this.orientation;
|
|
184
164
|
const targetRect = this.#$pop.footprintRect;
|
|
185
165
|
const contentRect = this.#$content.getBoundingClientRect();
|
|
186
166
|
const diffX = targetRect.x - contentRect.x;
|
|
187
167
|
const diffY = targetRect.y - contentRect.y;
|
|
188
|
-
|
|
189
168
|
if (orient === 'left' || orient === 'right') {
|
|
190
169
|
const yPos = Math.max(TIP_SIZE, Math.min(diffY + targetRect.height / 2, contentRect.height - TIP_SIZE));
|
|
191
170
|
this.#$tip.style.top = `${yPos}px`;
|
|
192
171
|
} else {
|
|
193
172
|
let xPos = Math.max(TIP_SIZE, Math.min(diffX + targetRect.width / 2, contentRect.width - TIP_SIZE));
|
|
194
|
-
|
|
195
173
|
if (orient === 'bottom-left' || orient === 'top-left') {
|
|
196
174
|
xPos = Math.max(xPos, contentRect.width * 0.75);
|
|
197
175
|
}
|
|
198
|
-
|
|
199
176
|
if (orient === 'bottom-right' || orient === 'top-right') {
|
|
200
177
|
xPos = Math.min(xPos, contentRect.width * 0.25);
|
|
201
178
|
}
|
|
202
|
-
|
|
203
179
|
this.#$tip.style.left = `${xPos}px`;
|
|
204
180
|
}
|
|
205
|
-
|
|
206
181
|
setClass(this.#$tip, 'hidden', rectOverlap(targetRect, contentRect));
|
|
207
182
|
};
|
|
208
|
-
|
|
209
183
|
#isOpen() {
|
|
210
184
|
return this.#$pop.hasAttribute('open');
|
|
211
185
|
}
|
|
212
|
-
|
|
213
186
|
});
|
package/tooltip/utils.js
CHANGED
|
@@ -3,19 +3,15 @@ export const getPopOrientation = orientation => {
|
|
|
3
3
|
if (orientation === 'top') {
|
|
4
4
|
return 'top-center';
|
|
5
5
|
}
|
|
6
|
-
|
|
7
6
|
if (orientation === 'bottom') {
|
|
8
7
|
return 'bottom-center';
|
|
9
8
|
}
|
|
10
|
-
|
|
11
9
|
if (orientation === 'left') {
|
|
12
10
|
return 'center-left';
|
|
13
11
|
}
|
|
14
|
-
|
|
15
12
|
if (orientation === 'right') {
|
|
16
13
|
return 'center-right';
|
|
17
14
|
}
|
|
18
|
-
|
|
19
15
|
return orientation;
|
|
20
16
|
};
|
|
21
17
|
export const assertOrientation = value => {
|
package/utils/animation.js
CHANGED
|
@@ -2,11 +2,9 @@ export class TooltipState {
|
|
|
2
2
|
#timerId = null;
|
|
3
3
|
#state = 'initial';
|
|
4
4
|
#options;
|
|
5
|
-
|
|
6
5
|
constructor(options) {
|
|
7
6
|
this.#options = options;
|
|
8
7
|
}
|
|
9
|
-
|
|
10
8
|
show() {
|
|
11
9
|
switch (this.#state) {
|
|
12
10
|
case 'initial':
|
|
@@ -14,13 +12,11 @@ export class TooltipState {
|
|
|
14
12
|
this.#delayShow();
|
|
15
13
|
break;
|
|
16
14
|
}
|
|
17
|
-
|
|
18
15
|
case 'hide-delay':
|
|
19
16
|
{
|
|
20
17
|
this.#cancelStateChange('show');
|
|
21
18
|
break;
|
|
22
19
|
}
|
|
23
|
-
|
|
24
20
|
case 'hide':
|
|
25
21
|
{
|
|
26
22
|
this.#cancelStateChange();
|
|
@@ -29,7 +25,6 @@ export class TooltipState {
|
|
|
29
25
|
}
|
|
30
26
|
}
|
|
31
27
|
}
|
|
32
|
-
|
|
33
28
|
hide() {
|
|
34
29
|
switch (this.#state) {
|
|
35
30
|
case 'show-delay':
|
|
@@ -37,7 +32,6 @@ export class TooltipState {
|
|
|
37
32
|
this.#cancelStateChange('initial');
|
|
38
33
|
break;
|
|
39
34
|
}
|
|
40
|
-
|
|
41
35
|
case 'show':
|
|
42
36
|
{
|
|
43
37
|
this.#delayHide();
|
|
@@ -45,7 +39,6 @@ export class TooltipState {
|
|
|
45
39
|
}
|
|
46
40
|
}
|
|
47
41
|
}
|
|
48
|
-
|
|
49
42
|
interrupt() {
|
|
50
43
|
switch (this.#state) {
|
|
51
44
|
case 'show-delay':
|
|
@@ -53,13 +46,11 @@ export class TooltipState {
|
|
|
53
46
|
this.#cancelStateChange('initial');
|
|
54
47
|
break;
|
|
55
48
|
}
|
|
56
|
-
|
|
57
49
|
case 'show':
|
|
58
50
|
{
|
|
59
51
|
this.#onHideStart();
|
|
60
52
|
break;
|
|
61
53
|
}
|
|
62
|
-
|
|
63
54
|
case 'hide-delay':
|
|
64
55
|
{
|
|
65
56
|
this.#cancelStateChange();
|
|
@@ -68,7 +59,6 @@ export class TooltipState {
|
|
|
68
59
|
}
|
|
69
60
|
}
|
|
70
61
|
}
|
|
71
|
-
|
|
72
62
|
destroy() {
|
|
73
63
|
switch (this.#state) {
|
|
74
64
|
case 'show-delay':
|
|
@@ -76,20 +66,17 @@ export class TooltipState {
|
|
|
76
66
|
this.#cancelStateChange('initial');
|
|
77
67
|
break;
|
|
78
68
|
}
|
|
79
|
-
|
|
80
69
|
case 'show':
|
|
81
70
|
{
|
|
82
71
|
this.#onHideStart(true);
|
|
83
72
|
break;
|
|
84
73
|
}
|
|
85
|
-
|
|
86
74
|
case 'hide-delay':
|
|
87
75
|
{
|
|
88
76
|
this.#cancelStateChange();
|
|
89
77
|
this.#onHideStart(true);
|
|
90
78
|
break;
|
|
91
79
|
}
|
|
92
|
-
|
|
93
80
|
case 'hide':
|
|
94
81
|
{
|
|
95
82
|
this.#cancelStateChange();
|
|
@@ -98,17 +85,14 @@ export class TooltipState {
|
|
|
98
85
|
}
|
|
99
86
|
}
|
|
100
87
|
}
|
|
101
|
-
|
|
102
88
|
#delayShow() {
|
|
103
89
|
this.#state = 'show-delay';
|
|
104
90
|
this.#timerId = window.setTimeout(this.#onShow, this.#options.showDelay);
|
|
105
91
|
}
|
|
106
|
-
|
|
107
92
|
#delayHide() {
|
|
108
93
|
this.#state = 'hide-delay';
|
|
109
94
|
this.#timerId = window.setTimeout(this.#onHideStart, this.#options.hideDelay);
|
|
110
95
|
}
|
|
111
|
-
|
|
112
96
|
#onShow = () => {
|
|
113
97
|
this.#state = 'show';
|
|
114
98
|
this.#options.onShow();
|
|
@@ -116,7 +100,6 @@ export class TooltipState {
|
|
|
116
100
|
#onHideStart = isImmediate => {
|
|
117
101
|
this.#state = 'hide';
|
|
118
102
|
this.#options.onHideStart();
|
|
119
|
-
|
|
120
103
|
if (isImmediate === true || this.#options.hideAnimationDuration === 0) {
|
|
121
104
|
this.#onHideEnd();
|
|
122
105
|
} else {
|
|
@@ -127,16 +110,13 @@ export class TooltipState {
|
|
|
127
110
|
this.#state = 'initial';
|
|
128
111
|
this.#options.onHideEnd();
|
|
129
112
|
};
|
|
130
|
-
|
|
131
113
|
#cancelStateChange(nextState) {
|
|
132
114
|
if (nextState != null) {
|
|
133
115
|
this.#state = nextState;
|
|
134
116
|
}
|
|
135
|
-
|
|
136
117
|
if (this.#timerId !== null) {
|
|
137
118
|
clearTimeout(this.#timerId);
|
|
138
119
|
this.#timerId = null;
|
|
139
120
|
}
|
|
140
121
|
}
|
|
141
|
-
|
|
142
122
|
}
|
package/utils/context.js
CHANGED
|
@@ -3,33 +3,27 @@ export class Context {
|
|
|
3
3
|
#listeners = new Set();
|
|
4
4
|
#name;
|
|
5
5
|
#isSubscribed = false;
|
|
6
|
-
|
|
7
6
|
constructor($element, name) {
|
|
8
7
|
this.#$root = $element;
|
|
9
8
|
this.#name = name;
|
|
10
9
|
}
|
|
11
|
-
|
|
12
10
|
get elements() {
|
|
13
11
|
return this.#listeners;
|
|
14
12
|
}
|
|
15
|
-
|
|
16
13
|
subscribe() {
|
|
17
14
|
if (this.#isSubscribed) {
|
|
18
15
|
return;
|
|
19
16
|
}
|
|
20
|
-
|
|
21
17
|
this.#$root.addEventListener(`-context-connect-${this.#name}`, this.#onConnect);
|
|
22
18
|
this.#$root.addEventListener(`-context-disconnect-${this.#name}`, this.#onDisconnect);
|
|
23
19
|
this.#isSubscribed = true;
|
|
24
20
|
}
|
|
25
|
-
|
|
26
21
|
unsubscribe() {
|
|
27
22
|
this.#listeners.clear();
|
|
28
23
|
this.#$root.removeEventListener(`-context-connect-${this.#name}`, this.#onConnect);
|
|
29
24
|
this.#$root.removeEventListener(`-context-disconnect-${this.#name}`, this.#onDisconnect);
|
|
30
25
|
this.#isSubscribed = false;
|
|
31
26
|
}
|
|
32
|
-
|
|
33
27
|
#onConnect = e => {
|
|
34
28
|
e.stopPropagation();
|
|
35
29
|
this.#listeners.add(e.detail);
|
package/utils/index.d.ts
CHANGED
|
@@ -53,4 +53,5 @@ export declare const getFirstFocusableElement: (root: Element) => NectaryElement
|
|
|
53
53
|
export declare const cloneNode: (el: Element, deep: boolean) => Element;
|
|
54
54
|
export declare const isElementFocused: ($el: Element | null) => boolean;
|
|
55
55
|
export declare const rectOverlap: (targetRect: TRect, contentRect: TRect) => boolean;
|
|
56
|
+
export declare const getTargetRect: (slot: HTMLSlotElement) => TRect | null;
|
|
56
57
|
export {};
|