@nectary/components 0.32.0 → 0.34.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/action-menu/index.js +40 -18
- package/action-menu/types.d.ts +3 -0
- package/action-menu-option/index.js +22 -14
- package/dialog/index.d.ts +1 -0
- package/dialog/index.js +50 -46
- package/dialog/types.d.ts +2 -0
- package/dropdown/index.js +11 -13
- package/horizontal-stepper/index.d.ts +13 -0
- package/horizontal-stepper/index.js +104 -0
- package/horizontal-stepper/types.d.ts +9 -0
- package/horizontal-stepper/types.js +1 -0
- package/horizontal-stepper-item/index.d.ts +13 -0
- package/horizontal-stepper-item/index.js +100 -0
- package/horizontal-stepper-item/types.d.ts +15 -0
- package/horizontal-stepper-item/types.js +1 -0
- package/horizontal-stepper-item/utils.d.ts +2 -0
- package/horizontal-stepper-item/utils.js +1 -0
- package/icons/exclamation/index.d.ts +11 -0
- package/icons/exclamation/index.js +4 -0
- package/input/index.d.ts +1 -0
- package/input/index.js +89 -26
- package/package.json +1 -1
- package/popover/index.js +128 -36
- package/popover/types.d.ts +17 -2
- package/popover/utils.js +1 -1
- package/select/index.js +1 -1
- package/select/types.d.ts +33 -5
- package/stop-events/index.d.ts +1 -0
- package/stop-events/index.js +40 -0
- package/textarea/index.js +36 -28
- package/utils.d.ts +1 -0
- package/utils.js +3 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
|
+
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
|
+
|
|
4
|
+
var _$label, _$description, _$circleText;
|
|
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
|
+
import '../icons/check';
|
|
11
|
+
import '../icons/exclamation';
|
|
12
|
+
import { defineCustomElement, getAttribute, getLiteralAttribute, NectaryElement, updateAttribute, updateLiteralAttribute } from '../utils';
|
|
13
|
+
const templateHTML = '<style>:host{display:block;outline:0}#wrapper{width:144px;min-height:64px;display:flex;flex-direction:column}#circle{position:relative;display:flex;align-items:center;justify-content:center;align-self:center;width:32px;height:32px;background-color:var(--sinch-color-snow-700);font:var(--sinch-font-title-s);line-height:32px;text-align:center;color:var(--sinch-color-stormy-500);border:1px solid transparent;border-radius:50%;box-sizing:border-box;--sinch-icon-size:20px}#label{font:var(--sinch-font-title-s);color:var(--sinch-color-stormy-500);text-align:center;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;margin-top:8px}#description{font:var(--sinch-font-text-xs);color:var(--sinch-color-stormy-300);text-align:center;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#icon-error,#icon-success{display:none}:host([data-progress=active]) #circle{color:var(--sinch-color-snow-100);background-color:var(--sinch-color-stormy-400)}:host([data-progress=done]) #circle{border-color:var(--sinch-color-stormy-400)}:host([data-progress=done]:not([status])) #icon-success{display:block}:host([data-progress=done][status=error]) #circle{background-color:var(--sinch-color-error-200);border-color:var(--sinch-color-stormy-400)}:host([data-progress=done][status=error]) #icon-error{display:block}:host([data-progress=done]:not([status=skip])) #circle-text{display:none}</style><div id="wrapper"><div id="circle" aria-hidden="true"><sinch-icon-check id="icon-success"></sinch-icon-check><sinch-icon-exclamation id="icon-error"></sinch-icon-exclamation><span id="circle-text"></span></div><span id="label"></span> <span id="description"></span></div>';
|
|
14
|
+
import { statusValues } from './utils';
|
|
15
|
+
const template = document.createElement('template');
|
|
16
|
+
template.innerHTML = templateHTML;
|
|
17
|
+
defineCustomElement('sinch-horizontal-stepper-item', (_$label = new WeakMap(), _$description = new WeakMap(), _$circleText = new WeakMap(), class extends NectaryElement {
|
|
18
|
+
constructor() {
|
|
19
|
+
super();
|
|
20
|
+
|
|
21
|
+
_classPrivateFieldInitSpec(this, _$label, {
|
|
22
|
+
writable: true,
|
|
23
|
+
value: void 0
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
_classPrivateFieldInitSpec(this, _$description, {
|
|
27
|
+
writable: true,
|
|
28
|
+
value: void 0
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
_classPrivateFieldInitSpec(this, _$circleText, {
|
|
32
|
+
writable: true,
|
|
33
|
+
value: void 0
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const shadowRoot = this.attachShadow();
|
|
37
|
+
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
38
|
+
|
|
39
|
+
_classPrivateFieldSet(this, _$label, shadowRoot.querySelector('#label'));
|
|
40
|
+
|
|
41
|
+
_classPrivateFieldSet(this, _$description, shadowRoot.querySelector('#description'));
|
|
42
|
+
|
|
43
|
+
_classPrivateFieldSet(this, _$circleText, shadowRoot.querySelector('#circle-text'));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
connectedCallback() {}
|
|
47
|
+
|
|
48
|
+
disconnectedCallback() {}
|
|
49
|
+
|
|
50
|
+
static get observedAttributes() {
|
|
51
|
+
return ['label', 'description', 'data-index'];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
attributeChangedCallback(name, oldVal, newVal) {
|
|
55
|
+
switch (name) {
|
|
56
|
+
case 'label':
|
|
57
|
+
{
|
|
58
|
+
_classPrivateFieldGet(this, _$label).textContent = newVal;
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
case 'description':
|
|
63
|
+
{
|
|
64
|
+
_classPrivateFieldGet(this, _$description).textContent = newVal;
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
case 'data-index':
|
|
69
|
+
{
|
|
70
|
+
_classPrivateFieldGet(this, _$circleText).textContent = newVal;
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
set label(value) {
|
|
77
|
+
updateAttribute(this, 'label', value);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
get label() {
|
|
81
|
+
return getAttribute(this, 'label', '');
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
set description(value) {
|
|
85
|
+
updateAttribute(this, 'description', value);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
get description() {
|
|
89
|
+
return getAttribute(this, 'description', '');
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
get status() {
|
|
93
|
+
return getLiteralAttribute(this, statusValues, 'status', null);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
set status(value) {
|
|
97
|
+
updateLiteralAttribute(this, statusValues, 'status', value);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
}));
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { TSinchElementReact } from '../types';
|
|
2
|
+
export declare type TSinchHorizontalStepperStatusType = 'error' | 'skip';
|
|
3
|
+
export declare type TSinchHorizontalStepperItemElement = HTMLElement & {
|
|
4
|
+
label: string;
|
|
5
|
+
description: string | null;
|
|
6
|
+
status: TSinchHorizontalStepperStatusType | null;
|
|
7
|
+
setAttribute(name: 'label', value: string): void;
|
|
8
|
+
setAttribute(name: 'description', value: string): void;
|
|
9
|
+
setAttribute(name: 'status', value: TSinchHorizontalStepperStatusType): void;
|
|
10
|
+
};
|
|
11
|
+
export declare type TSinchHorizontalStepperItemReact = TSinchElementReact<TSinchHorizontalStepperItemElement> & {
|
|
12
|
+
label: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
status?: TSinchHorizontalStepperStatusType;
|
|
15
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const statusValues = ['skip', 'error'];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { TSinchIconElement, TSinchIconReact } from '../types';
|
|
2
|
+
declare global {
|
|
3
|
+
namespace JSX {
|
|
4
|
+
interface IntrinsicElements {
|
|
5
|
+
'sinch-icon-exclamation': TSinchIconReact;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
interface HTMLElementTagNameMap {
|
|
9
|
+
'sinch-icon-exclamation': TSinchIconElement;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { defineCustomElement } from '../../utils';
|
|
2
|
+
import { createIconClass } from '../create-icon-class';
|
|
3
|
+
const templateHTML = '<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M11 14V5h2v9Zm0 5v-2h2v2Z"/></svg>';
|
|
4
|
+
defineCustomElement('sinch-icon-exclamation', createIconClass(templateHTML));
|
package/input/index.d.ts
CHANGED
package/input/index.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import _classPrivateFieldGet from '@babel/runtime/helpers/classPrivateFieldGet';
|
|
2
2
|
import _classPrivateFieldSet from '@babel/runtime/helpers/classPrivateFieldSet';
|
|
3
3
|
|
|
4
|
-
var _$input, _$label, _$optionalText, _$additionalText, _$invalidText,
|
|
4
|
+
var _$input, _$label, _$optionalText, _$additionalText, _$invalidText, _$iconSlot, _$iconWrapper, _$rightSlot, _$rightWrapper, _cursorPos, _isPendingDk, _onCompositionStart, _onSelectionChange, _onInput, _onIconSlotChange, _onRightSlotChange;
|
|
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
|
|
11
|
-
|
|
10
|
+
import '../stop-events';
|
|
11
|
+
import { defineCustomElement, getAttribute, getBooleanAttribute, getLiteralAttribute, isAttrTrue, NectaryElement, setClass, updateAttribute, updateBooleanAttribute, updateExplicitBooleanAttribute, updateLiteralAttribute } from '../utils';
|
|
12
|
+
const templateHTML = '<style>:host{display:inline-block;vertical-align:middle;outline:0;--sinch-color-icon:var(--sinch-color-stormy-500)}#wrapper{width:100%;box-sizing:border-box}#input-wrapper{position:relative;display:flex;flex-direction:row;align-items:center;box-sizing:border-box;border-radius:var(--sinch-shape-radius-s);width:100%;height:48px;background-color:var(--sinch-color-snow-100)}#input{all:initial;flex:1;min-width:0;height:48px;padding:0 12px 0 44px;font:var(--sinch-font-body);color:var(--sinch-color-text-default);caret-color:var(--sinch-caret-color,auto)}#input::placeholder{font:var(--sinch-font-body);color:var(--sinch-color-text-muted)}#border{position:absolute;border:1px solid var(--sinch-color-stormy-200);border-radius:var(--sinch-shape-radius-s);left:0;right:0;top:0;bottom:0;pointer-events:none}:host([invalidtext]:not([invalidtext=""]):not([disabled])) #border{border-color:var(--sinch-color-text-invalid)}#input:disabled{color:var(--sinch-color-stormy-100)}#input:disabled::placeholder{color:var(--sinch-color-snow-500)}#input:disabled+#border{border-color:var(--sinch-color-snow-500)}#input:focus+#border{border-color:var(--sinch-color-stormy-600)}#input[type=password]{font-size:1.5em;letter-spacing:.1em}#bottom,#top{display:flex;align-items:baseline}#top{height:24px;margin-bottom:2px}#additional,#invalid,#label,#optional{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#label{font:var(--sinch-font-title-s);color:var(--sinch-color-text-default)}#optional{flex:1;text-align:right;font:var(--sinch-font-small-text);color:var(--sinch-color-text-muted)}#additional{flex:1;text-align:right;font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-muted);line-height:20px;margin-top:2px}#additional:empty{display:none}#invalid{font:var(--sinch-font-extra-small-text);color:var(--sinch-color-text-invalid);line-height:20px;margin-top:2px}#invalid:empty{display:none}#icon{position:absolute;left:12px;top:12px;pointer-events:none;--sinch-icon-size:24px}#icon.empty{display:none}#icon.empty~#input{padding-left:12px}#right{display:flex;flex-direction:row;align-self:stretch;align-items:center;gap:4px;padding-right:8px}#right.empty{display:none}::slotted(sinch-help-tooltip){align-self:center;margin:0 8px}:host([disabled]:not([disabled=false])) :is(#label,#additional,#optional,#invalid){color:var(--sinch-color-stormy-100)}:host([disabled]:not([disabled=false])){--sinch-color-icon:var(--sinch-color-stormy-100)}</style><div id="wrapper"><div id="top"><label id="label" for="input"></label><slot name="tooltip"></slot><span id="optional"></span></div><div id="input-wrapper"><div id="icon"><slot name="icon"></slot></div><input id="input" type="text"/><div id="border"></div><div id="right"><sinch-stop-events events="input,change,focusin,focusout"><slot name="right"></slot></sinch-stop-events></div></div><div id="bottom"><div id="invalid"></div><div id="additional"></div></div></div>';
|
|
12
13
|
import { inputTypes } from './utils';
|
|
13
14
|
const template = document.createElement('template');
|
|
14
15
|
template.innerHTML = templateHTML;
|
|
15
|
-
defineCustomElement('sinch-input', (_$input = new WeakMap(), _$label = new WeakMap(), _$optionalText = new WeakMap(), _$additionalText = new WeakMap(), _$invalidText = new WeakMap(),
|
|
16
|
+
defineCustomElement('sinch-input', (_$input = new WeakMap(), _$label = new WeakMap(), _$optionalText = new WeakMap(), _$additionalText = new WeakMap(), _$invalidText = new WeakMap(), _$iconSlot = new WeakMap(), _$iconWrapper = new WeakMap(), _$rightSlot = new WeakMap(), _$rightWrapper = new WeakMap(), _cursorPos = new WeakMap(), _isPendingDk = new WeakMap(), _onCompositionStart = new WeakMap(), _onSelectionChange = new WeakMap(), _onInput = new WeakMap(), _onIconSlotChange = new WeakMap(), _onRightSlotChange = new WeakMap(), class extends NectaryElement {
|
|
16
17
|
constructor() {
|
|
17
18
|
super();
|
|
18
19
|
|
|
@@ -41,12 +42,27 @@ defineCustomElement('sinch-input', (_$input = new WeakMap(), _$label = new WeakM
|
|
|
41
42
|
value: void 0
|
|
42
43
|
});
|
|
43
44
|
|
|
44
|
-
_classPrivateFieldInitSpec(this,
|
|
45
|
+
_classPrivateFieldInitSpec(this, _$iconSlot, {
|
|
45
46
|
writable: true,
|
|
46
|
-
value:
|
|
47
|
+
value: void 0
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
_classPrivateFieldInitSpec(this, _$iconWrapper, {
|
|
51
|
+
writable: true,
|
|
52
|
+
value: void 0
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
_classPrivateFieldInitSpec(this, _$rightSlot, {
|
|
56
|
+
writable: true,
|
|
57
|
+
value: void 0
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
_classPrivateFieldInitSpec(this, _$rightWrapper, {
|
|
61
|
+
writable: true,
|
|
62
|
+
value: void 0
|
|
47
63
|
});
|
|
48
64
|
|
|
49
|
-
_classPrivateFieldInitSpec(this,
|
|
65
|
+
_classPrivateFieldInitSpec(this, _cursorPos, {
|
|
50
66
|
writable: true,
|
|
51
67
|
value: null
|
|
52
68
|
});
|
|
@@ -63,6 +79,13 @@ defineCustomElement('sinch-input', (_$input = new WeakMap(), _$label = new WeakM
|
|
|
63
79
|
}
|
|
64
80
|
});
|
|
65
81
|
|
|
82
|
+
_classPrivateFieldInitSpec(this, _onSelectionChange, {
|
|
83
|
+
writable: true,
|
|
84
|
+
value: () => {
|
|
85
|
+
_classPrivateFieldSet(this, _cursorPos, _classPrivateFieldGet(this, _$input).selectionEnd);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
|
|
66
89
|
_classPrivateFieldInitSpec(this, _onInput, {
|
|
67
90
|
writable: true,
|
|
68
91
|
value: e => {
|
|
@@ -73,29 +96,23 @@ defineCustomElement('sinch-input', (_$input = new WeakMap(), _$label = new WeakM
|
|
|
73
96
|
const prevValue = this.value;
|
|
74
97
|
|
|
75
98
|
if (prevValue !== nextValue) {
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
const nextSelectionEnd = _classPrivateFieldGet(this, _$input).selectionEnd;
|
|
79
|
-
|
|
80
|
-
const prevSelectionStart = _classPrivateFieldGet(this, _selectionStart);
|
|
81
|
-
|
|
82
|
-
const prevSelectionEnd = _classPrivateFieldGet(this, _selectionEnd);
|
|
83
|
-
|
|
84
|
-
const isPrevCursorEnd = prevSelectionStart === prevSelectionEnd && prevSelectionStart === prevValue.length;
|
|
99
|
+
const nextCursorPos = _classPrivateFieldGet(this, _$input).selectionEnd;
|
|
85
100
|
|
|
86
101
|
if (!_classPrivateFieldGet(this, _isPendingDk)) {
|
|
87
102
|
_classPrivateFieldGet(this, _$input).value = prevValue;
|
|
88
|
-
}
|
|
89
103
|
|
|
90
|
-
|
|
104
|
+
const prevCursorPos = _classPrivateFieldGet(this, _cursorPos);
|
|
105
|
+
|
|
106
|
+
const isPrevCursorEnd = prevCursorPos === null || prevCursorPos === prevValue.length;
|
|
91
107
|
|
|
92
|
-
|
|
93
|
-
|
|
108
|
+
if (!isPrevCursorEnd) {
|
|
109
|
+
_classPrivateFieldGet(this, _$input).setSelectionRange(prevCursorPos, prevCursorPos);
|
|
110
|
+
}
|
|
94
111
|
}
|
|
95
112
|
|
|
96
|
-
_classPrivateFieldSet(this,
|
|
113
|
+
_classPrivateFieldSet(this, _isPendingDk, false);
|
|
97
114
|
|
|
98
|
-
_classPrivateFieldSet(this,
|
|
115
|
+
_classPrivateFieldSet(this, _cursorPos, nextCursorPos);
|
|
99
116
|
|
|
100
117
|
this.dispatchEvent(new CustomEvent('change', {
|
|
101
118
|
detail: nextValue,
|
|
@@ -105,6 +122,20 @@ defineCustomElement('sinch-input', (_$input = new WeakMap(), _$label = new WeakM
|
|
|
105
122
|
}
|
|
106
123
|
});
|
|
107
124
|
|
|
125
|
+
_classPrivateFieldInitSpec(this, _onIconSlotChange, {
|
|
126
|
+
writable: true,
|
|
127
|
+
value: () => {
|
|
128
|
+
setClass(_classPrivateFieldGet(this, _$iconWrapper), 'empty', _classPrivateFieldGet(this, _$iconSlot).assignedElements().length === 0);
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
_classPrivateFieldInitSpec(this, _onRightSlotChange, {
|
|
133
|
+
writable: true,
|
|
134
|
+
value: () => {
|
|
135
|
+
setClass(_classPrivateFieldGet(this, _$rightWrapper), 'empty', _classPrivateFieldGet(this, _$rightSlot).assignedElements().length === 0);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
|
|
108
139
|
const shadowRoot = this.attachShadow();
|
|
109
140
|
shadowRoot.appendChild(template.content.cloneNode(true));
|
|
110
141
|
|
|
@@ -117,6 +148,14 @@ defineCustomElement('sinch-input', (_$input = new WeakMap(), _$label = new WeakM
|
|
|
117
148
|
_classPrivateFieldSet(this, _$additionalText, shadowRoot.querySelector('#additional'));
|
|
118
149
|
|
|
119
150
|
_classPrivateFieldSet(this, _$invalidText, shadowRoot.querySelector('#invalid'));
|
|
151
|
+
|
|
152
|
+
_classPrivateFieldSet(this, _$iconSlot, shadowRoot.querySelector('slot[name="icon"]'));
|
|
153
|
+
|
|
154
|
+
_classPrivateFieldSet(this, _$iconWrapper, shadowRoot.querySelector('#icon'));
|
|
155
|
+
|
|
156
|
+
_classPrivateFieldSet(this, _$rightSlot, shadowRoot.querySelector('slot[name="right"]'));
|
|
157
|
+
|
|
158
|
+
_classPrivateFieldSet(this, _$rightWrapper, shadowRoot.querySelector('#right'));
|
|
120
159
|
}
|
|
121
160
|
|
|
122
161
|
connectedCallback() {
|
|
@@ -125,12 +164,32 @@ defineCustomElement('sinch-input', (_$input = new WeakMap(), _$label = new WeakM
|
|
|
125
164
|
_classPrivateFieldGet(this, _$input).addEventListener('input', _classPrivateFieldGet(this, _onInput));
|
|
126
165
|
|
|
127
166
|
_classPrivateFieldGet(this, _$input).addEventListener('compositionstart', _classPrivateFieldGet(this, _onCompositionStart));
|
|
167
|
+
|
|
168
|
+
_classPrivateFieldGet(this, _$input).addEventListener('mousedown', _classPrivateFieldGet(this, _onSelectionChange));
|
|
169
|
+
|
|
170
|
+
_classPrivateFieldGet(this, _$input).addEventListener('keydown', _classPrivateFieldGet(this, _onSelectionChange));
|
|
171
|
+
|
|
172
|
+
_classPrivateFieldGet(this, _$iconSlot).addEventListener('slotchange', _classPrivateFieldGet(this, _onIconSlotChange));
|
|
173
|
+
|
|
174
|
+
_classPrivateFieldGet(this, _$rightSlot).addEventListener('slotchange', _classPrivateFieldGet(this, _onRightSlotChange));
|
|
175
|
+
|
|
176
|
+
_classPrivateFieldGet(this, _onIconSlotChange).call(this);
|
|
177
|
+
|
|
178
|
+
_classPrivateFieldGet(this, _onRightSlotChange).call(this);
|
|
128
179
|
}
|
|
129
180
|
|
|
130
181
|
disconnectedCallback() {
|
|
131
182
|
_classPrivateFieldGet(this, _$input).removeEventListener('input', _classPrivateFieldGet(this, _onInput));
|
|
132
183
|
|
|
133
184
|
_classPrivateFieldGet(this, _$input).removeEventListener('compositionstart', _classPrivateFieldGet(this, _onCompositionStart));
|
|
185
|
+
|
|
186
|
+
_classPrivateFieldGet(this, _$input).removeEventListener('mousedown', _classPrivateFieldGet(this, _onSelectionChange));
|
|
187
|
+
|
|
188
|
+
_classPrivateFieldGet(this, _$input).removeEventListener('keydown', _classPrivateFieldGet(this, _onSelectionChange));
|
|
189
|
+
|
|
190
|
+
_classPrivateFieldGet(this, _$iconSlot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onIconSlotChange));
|
|
191
|
+
|
|
192
|
+
_classPrivateFieldGet(this, _$rightSlot).removeEventListener('slotchange', _classPrivateFieldGet(this, _onRightSlotChange));
|
|
134
193
|
}
|
|
135
194
|
|
|
136
195
|
static get observedAttributes() {
|
|
@@ -241,12 +300,16 @@ defineCustomElement('sinch-input', (_$input = new WeakMap(), _$label = new WeakM
|
|
|
241
300
|
{
|
|
242
301
|
const nextVal = newVal ?? '';
|
|
243
302
|
|
|
244
|
-
|
|
303
|
+
const prevVal = _classPrivateFieldGet(this, _$input).value;
|
|
304
|
+
|
|
305
|
+
if (nextVal !== prevVal) {
|
|
306
|
+
const prevCursorPos = _classPrivateFieldGet(this, _$input).selectionEnd;
|
|
307
|
+
|
|
308
|
+
const isPrevCursorEnd = prevCursorPos === prevVal.length;
|
|
245
309
|
_classPrivateFieldGet(this, _$input).value = nextVal;
|
|
246
|
-
const isNextCursorEnd = _classPrivateFieldGet(this, _selectionStart) === _classPrivateFieldGet(this, _selectionEnd) && (_classPrivateFieldGet(this, _selectionStart) === null || _classPrivateFieldGet(this, _selectionStart) === nextVal.length);
|
|
247
310
|
|
|
248
|
-
if (!
|
|
249
|
-
_classPrivateFieldGet(this, _$input).setSelectionRange(_classPrivateFieldGet(this,
|
|
311
|
+
if (!isPrevCursorEnd) {
|
|
312
|
+
_classPrivateFieldGet(this, _$input).setSelectionRange(_classPrivateFieldGet(this, _cursorPos), _classPrivateFieldGet(this, _cursorPos));
|
|
250
313
|
}
|
|
251
314
|
}
|
|
252
315
|
|