@telixon/web-sdk 1.0.0 → 1.0.1
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/README.md +1 -0
- package/dist/index.js +23 -5
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -5,6 +5,7 @@ The DOM adapter for [`@telixon/core`](https://www.npmjs.com/package/@telixon/cor
|
|
|
5
5
|
[](https://proof.telixon.dev/parity.html)
|
|
6
6
|
[](https://proof.telixon.dev/benchmark.html)
|
|
7
7
|
[](https://www.npmjs.com/package/@telixon/web-sdk)
|
|
8
|
+
[](https://www.npmjs.com/package/@telixon/web-sdk)
|
|
8
9
|
|
|
9
10
|
**[Documentation](https://telixon.dev/web-sdk/)** · **[Live demo](https://telixon.dev/web-sdk/guides/complete-field/)**
|
|
10
11
|
|
package/dist/index.js
CHANGED
|
@@ -78,7 +78,8 @@ function createInternationalController(options) {
|
|
|
78
78
|
return createInternationalInputController(config);
|
|
79
79
|
}
|
|
80
80
|
function buildController(options) {
|
|
81
|
-
|
|
81
|
+
const seeded = options.initialValue === void 0 && options.input.value !== "" ? { ...options, initialValue: options.input.value } : options;
|
|
82
|
+
return seeded.mode === "national" ? createNationalController(seeded) : createInternationalController(seeded);
|
|
82
83
|
}
|
|
83
84
|
|
|
84
85
|
// src/modules/phone-input/utils/derive-state.ts
|
|
@@ -202,12 +203,27 @@ function createPhoneInput(options) {
|
|
|
202
203
|
change();
|
|
203
204
|
notify(buildState());
|
|
204
205
|
}
|
|
206
|
+
function reconcile() {
|
|
207
|
+
const domValue = input.value;
|
|
208
|
+
if (domValue === inputController.currentState.value) return;
|
|
209
|
+
commit(() => inputController.setValue(domValue));
|
|
210
|
+
}
|
|
205
211
|
function handleCompositionEnd(event) {
|
|
206
212
|
if (event.target !== input) return;
|
|
207
|
-
|
|
208
|
-
const
|
|
209
|
-
const
|
|
210
|
-
|
|
213
|
+
const data = event.data ?? "";
|
|
214
|
+
const value = input.value;
|
|
215
|
+
const caret = input.selectionStart ?? value.length;
|
|
216
|
+
const start = caret - data.length;
|
|
217
|
+
if (data !== "" && start >= 0 && value.slice(start, caret) === data) {
|
|
218
|
+
commit(() => inputController.insert(value.slice(0, start) + value.slice(caret), data, start, start));
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
reconcile();
|
|
222
|
+
}
|
|
223
|
+
function handleInput(event) {
|
|
224
|
+
if (event.target !== input) return;
|
|
225
|
+
if (event instanceof InputEvent && event.isComposing) return;
|
|
226
|
+
reconcile();
|
|
211
227
|
}
|
|
212
228
|
function handleBeforeInput(event) {
|
|
213
229
|
if (event.target !== input) return;
|
|
@@ -296,6 +312,7 @@ function createPhoneInput(options) {
|
|
|
296
312
|
}
|
|
297
313
|
input.addEventListener("compositionend", handleCompositionEnd);
|
|
298
314
|
input.addEventListener("beforeinput", handleBeforeInput);
|
|
315
|
+
input.addEventListener("input", handleInput);
|
|
299
316
|
input.addEventListener("keydown", handleKeyDown);
|
|
300
317
|
notify(buildState());
|
|
301
318
|
return {
|
|
@@ -346,6 +363,7 @@ function createPhoneInput(options) {
|
|
|
346
363
|
ATTACHED_INPUTS.delete(input);
|
|
347
364
|
input.removeEventListener("compositionend", handleCompositionEnd);
|
|
348
365
|
input.removeEventListener("beforeinput", handleBeforeInput);
|
|
366
|
+
input.removeEventListener("input", handleInput);
|
|
349
367
|
input.removeEventListener("keydown", handleKeyDown);
|
|
350
368
|
listeners.clear();
|
|
351
369
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telixon/web-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "DOM adapter for @telixon/core: two headless widgets, PhoneInput driving a plain <input> and RegionList feeding region pickers.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"phone-input",
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
"LICENSE"
|
|
38
38
|
],
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"@telixon/core": "^1.
|
|
40
|
+
"@telixon/core": "^1.1.1"
|
|
41
41
|
},
|
|
42
42
|
"engines": {
|
|
43
43
|
"node": ">=18"
|
|
44
44
|
},
|
|
45
|
-
"bundleSize": "3.
|
|
45
|
+
"bundleSize": "3.92 kB brotli"
|
|
46
46
|
}
|