@24i/bigscreen-sdk 1.0.46-alpha.2746 → 1.0.47
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@24i/bigscreen-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.47",
|
|
4
4
|
"description": "SmartApps BIGscreen SDK monorepo",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@24i/appstage-shared-events-manager": "1.0.11",
|
|
43
43
|
"@24i/appstage-shared-perf-utils": "1.0.11",
|
|
44
44
|
"@24i/bigscreen-players-engine-base": "4.0.10",
|
|
45
|
-
"@24i/smartapps-datalayer": "3.0.
|
|
45
|
+
"@24i/smartapps-datalayer": "3.0.18",
|
|
46
46
|
"@sentry/browser": "7.35.0",
|
|
47
47
|
"@sentry/types": "7.35.0",
|
|
48
48
|
"csstype": "^3.1.3",
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
input.selectionStart = position;
|
|
3
|
-
input.selectionEnd = position;
|
|
4
|
-
};
|
|
1
|
+
import { setInputSelectionRange } from './setInputSelectionRange';
|
|
5
2
|
|
|
6
3
|
export const caretLeft = (input: HTMLInputElement | null): false | number => {
|
|
7
4
|
if (!input) return false;
|
|
8
5
|
const selectionStart = input.selectionStart!;
|
|
9
6
|
if (selectionStart > 0) {
|
|
10
7
|
const newPosition = selectionStart - 1;
|
|
11
|
-
|
|
8
|
+
setInputSelectionRange(input, newPosition);
|
|
12
9
|
return newPosition;
|
|
13
10
|
}
|
|
14
11
|
return false;
|
|
@@ -20,7 +17,7 @@ export const caretRight = (input: HTMLInputElement | null): false | number => {
|
|
|
20
17
|
const selectionStart = input.selectionStart!;
|
|
21
18
|
if (selectionStart < value.length) {
|
|
22
19
|
const newPosition = selectionStart + 1;
|
|
23
|
-
|
|
20
|
+
setInputSelectionRange(input, newPosition);
|
|
24
21
|
return newPosition;
|
|
25
22
|
}
|
|
26
23
|
return false;
|
|
@@ -30,7 +27,7 @@ export const caretHome = (input: HTMLInputElement | null): false | number => {
|
|
|
30
27
|
if (!input) return false;
|
|
31
28
|
const selectionStart = input.selectionStart!;
|
|
32
29
|
if (selectionStart > 0) {
|
|
33
|
-
|
|
30
|
+
setInputSelectionRange(input, 0);
|
|
34
31
|
return 0;
|
|
35
32
|
}
|
|
36
33
|
return false;
|
|
@@ -41,7 +38,7 @@ export const caretEnd = (input: HTMLInputElement | null): false | number => {
|
|
|
41
38
|
const { value: { length } } = input;
|
|
42
39
|
const selectionStart = input.selectionStart!;
|
|
43
40
|
if (selectionStart < length) {
|
|
44
|
-
|
|
41
|
+
setInputSelectionRange(input, length);
|
|
45
42
|
return length;
|
|
46
43
|
}
|
|
47
44
|
return false;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { setInputSelectionRange } from './setInputSelectionRange';
|
|
2
|
+
|
|
1
3
|
export const insertCharAtCaret = (input: HTMLInputElement | null, char: string): false | string => {
|
|
2
4
|
if (!input) return false;
|
|
3
5
|
const { value } = input;
|
|
@@ -6,8 +8,7 @@ export const insertCharAtCaret = (input: HTMLInputElement | null, char: string):
|
|
|
6
8
|
const postCaret = value.substring(selectionStart);
|
|
7
9
|
input.value = `${preCaret}${char}${postCaret}`;
|
|
8
10
|
const newCaretPosition = selectionStart + char.length;
|
|
9
|
-
input
|
|
10
|
-
input.selectionEnd = newCaretPosition;
|
|
11
|
+
setInputSelectionRange(input, newCaretPosition);
|
|
11
12
|
return input.value;
|
|
12
13
|
};
|
|
13
14
|
|
|
@@ -20,8 +21,7 @@ export const backspace = (input: HTMLInputElement): false | string => {
|
|
|
20
21
|
const postCaret = value.substring(selectionStart);
|
|
21
22
|
input.value = `${preCaret}${postCaret}`;
|
|
22
23
|
const newCaretPosition = selectionStart - 1;
|
|
23
|
-
input
|
|
24
|
-
input.selectionEnd = newCaretPosition;
|
|
24
|
+
setInputSelectionRange(input, newCaretPosition);
|
|
25
25
|
return input.value;
|
|
26
26
|
};
|
|
27
27
|
|
|
@@ -34,7 +34,6 @@ export const del = (input: HTMLInputElement): false | string => {
|
|
|
34
34
|
const postCaret = value.substring(selectionStart + 1);
|
|
35
35
|
input.value = `${preCaret}${postCaret}`;
|
|
36
36
|
const newCaretPosition = selectionStart;
|
|
37
|
-
input
|
|
38
|
-
input.selectionEnd = newCaretPosition;
|
|
37
|
+
setInputSelectionRange(input, newCaretPosition);
|
|
39
38
|
return input.value;
|
|
40
39
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// On some platforms, selectionStart/selectionEnd may change focus.
|
|
2
|
+
// This function ensures that the focus state remains the same.
|
|
3
|
+
export const setInputSelectionRange = (input: HTMLInputElement, position: number) => {
|
|
4
|
+
const { activeElement } = document;
|
|
5
|
+
const wasFocused = activeElement === input;
|
|
6
|
+
if (!wasFocused) input.focus();
|
|
7
|
+
input.selectionStart = position;
|
|
8
|
+
input.selectionEnd = position;
|
|
9
|
+
if (!wasFocused) (activeElement as HTMLElement).focus();
|
|
10
|
+
};
|