@24i/bigscreen-sdk 0.9.9-alpha.2154 → 0.9.9-alpha.2158
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 +2 -1
- package/packages/developer-tools/src/EnvironmentSelection/EnvironmentList.tsx +3 -1
- package/packages/developer-tools/src/EnvironmentSelection/EnvironmentListItem.tsx +23 -3
- package/packages/developer-tools/src/EnvironmentSelection/EnvironmentSelection.tsx +2 -0
- package/packages/developer-tools/src/EnvironmentSelection/styles/EnvironmentSelection.scss +10 -0
- package/packages/input/src/Input.tsx +2 -2
- package/packages/utils/src/textUtils.ts +25 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@24i/bigscreen-sdk",
|
|
3
|
-
"version": "0.9.9-alpha.
|
|
3
|
+
"version": "0.9.9-alpha.2158",
|
|
4
4
|
"description": "SmartApps BIGscreen SDK monorepo",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -259,6 +259,7 @@
|
|
|
259
259
|
"./utils/removeClass": "./packages/utils/src/removeClass.ts",
|
|
260
260
|
"./utils/scaledImage": "./packages/utils/src/scaledImage.ts",
|
|
261
261
|
"./utils/stopEvent": "./packages/utils/src/stopEvent.ts",
|
|
262
|
+
"./utils/textUtils": "./packages/utils/src/textUtils.ts",
|
|
262
263
|
"./utils/timeConstants": "./packages/utils/src/timeConstants.ts",
|
|
263
264
|
"./utils/timers": "./packages/utils/src/timers/index.ts",
|
|
264
265
|
"./utils/wait": "./packages/utils/src/wait.ts",
|
|
@@ -12,6 +12,7 @@ import * as sizes from './sizes';
|
|
|
12
12
|
type Props = {
|
|
13
13
|
data: ItemData[],
|
|
14
14
|
onClose: () => void,
|
|
15
|
+
leadingEllipses?: boolean;
|
|
15
16
|
};
|
|
16
17
|
|
|
17
18
|
export class EnvironmentList extends Component<Props> {
|
|
@@ -55,7 +56,7 @@ export class EnvironmentList extends Component<Props> {
|
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
render() {
|
|
58
|
-
const { data } = this.props;
|
|
59
|
+
const { data, leadingEllipses } = this.props;
|
|
59
60
|
const { visibleItems, firstScrollStep, scrollStep } = sizes;
|
|
60
61
|
return (
|
|
61
62
|
<div
|
|
@@ -80,6 +81,7 @@ export class EnvironmentList extends Component<Props> {
|
|
|
80
81
|
label={label}
|
|
81
82
|
value={value}
|
|
82
83
|
onPress={this.onPressItem}
|
|
84
|
+
leadingEllipses={leadingEllipses}
|
|
83
85
|
/>
|
|
84
86
|
);
|
|
85
87
|
}}
|
|
@@ -2,10 +2,12 @@ import { Component, createRef, setText } from '@24i/bigscreen-sdk/jsx';
|
|
|
2
2
|
import { getDisplayToggler } from '@24i/bigscreen-sdk/utils/displayToggler';
|
|
3
3
|
import { Item } from '@24i/bigscreen-sdk/list/interface';
|
|
4
4
|
import { Interactable } from '@24i/bigscreen-sdk/interactable';
|
|
5
|
+
import { trimWithLeadingEllipsis } from '@24i/bigscreen-sdk/utils/textUtils';
|
|
5
6
|
import { ItemData } from './types';
|
|
6
7
|
|
|
7
8
|
type Props = {
|
|
8
9
|
onPress: (environment: string) => void,
|
|
10
|
+
leadingEllipses?: boolean;
|
|
9
11
|
} & ItemData;
|
|
10
12
|
|
|
11
13
|
export class EnvironmentListItem extends Component<Props> implements Item<ItemData> {
|
|
@@ -23,6 +25,10 @@ export class EnvironmentListItem extends Component<Props> implements Item<ItemDa
|
|
|
23
25
|
this.value = value;
|
|
24
26
|
}
|
|
25
27
|
|
|
28
|
+
componentDidMount(): void {
|
|
29
|
+
this.trimRows();
|
|
30
|
+
}
|
|
31
|
+
|
|
26
32
|
onPress = () => {
|
|
27
33
|
const { onPress } = this.props;
|
|
28
34
|
onPress(this.value);
|
|
@@ -40,10 +46,18 @@ export class EnvironmentListItem extends Component<Props> implements Item<ItemDa
|
|
|
40
46
|
this.display.hide();
|
|
41
47
|
}
|
|
42
48
|
|
|
49
|
+
trimRows() {
|
|
50
|
+
const { leadingEllipses } = this.props;
|
|
51
|
+
if (leadingEllipses) {
|
|
52
|
+
trimWithLeadingEllipsis(this.labelRef.current!);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
43
56
|
updateData({ label, value }: ItemData) {
|
|
44
57
|
if (value !== this.value) {
|
|
45
58
|
this.value = value;
|
|
46
59
|
setText(this.labelRef, label);
|
|
60
|
+
this.trimRows();
|
|
47
61
|
}
|
|
48
62
|
}
|
|
49
63
|
|
|
@@ -52,14 +66,20 @@ export class EnvironmentListItem extends Component<Props> implements Item<ItemDa
|
|
|
52
66
|
}
|
|
53
67
|
|
|
54
68
|
render() {
|
|
55
|
-
const { active, label } = this.props;
|
|
69
|
+
const { active, label, leadingEllipses: ellipses } = this.props;
|
|
56
70
|
return (
|
|
57
71
|
<Interactable
|
|
58
72
|
ref={this.itemRef}
|
|
59
|
-
className=
|
|
73
|
+
className={`environment-list-item ${ellipses ? 'leading-ellipses-list-item' : ''}`}
|
|
60
74
|
onPress={this.onPress}
|
|
61
75
|
>
|
|
62
|
-
{active
|
|
76
|
+
{ active
|
|
77
|
+
&& (
|
|
78
|
+
<span
|
|
79
|
+
className={`checkmark ${ellipses ? 'leading-ellipses-checkmark' : ''}`}
|
|
80
|
+
/>
|
|
81
|
+
)}
|
|
82
|
+
|
|
63
83
|
<span
|
|
64
84
|
className={`label ${active ? 'active' : ''}`}
|
|
65
85
|
ref={this.labelRef}
|
|
@@ -9,6 +9,7 @@ import { getEnvironmentConfigNamesList, getActiveEnvironmentConfigName } from '.
|
|
|
9
9
|
|
|
10
10
|
export type Props = {
|
|
11
11
|
onClose?: () => void;
|
|
12
|
+
leadingEllipses?: boolean;
|
|
12
13
|
};
|
|
13
14
|
|
|
14
15
|
export class EnvironmentSelection extends Component<Props> implements IDeveloperTool<Props> {
|
|
@@ -75,6 +76,7 @@ export class EnvironmentSelection extends Component<Props> implements IDeveloper
|
|
|
75
76
|
ref={this.environmentListRef}
|
|
76
77
|
data={this.getEnvironments()}
|
|
77
78
|
onClose={this.closeEnvironmentSelectionList}
|
|
79
|
+
leadingEllipses
|
|
78
80
|
/>,
|
|
79
81
|
this.div,
|
|
80
82
|
);
|
|
@@ -85,6 +85,12 @@
|
|
|
85
85
|
width: $checkmark-size;
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
+
.leading-ellipses-checkmark {
|
|
89
|
+
position: absolute;
|
|
90
|
+
height: 100%;
|
|
91
|
+
top: 0;
|
|
92
|
+
}
|
|
93
|
+
|
|
88
94
|
.label {
|
|
89
95
|
font-size: $label-font-size;
|
|
90
96
|
font-weight: 400;
|
|
@@ -103,5 +109,9 @@
|
|
|
103
109
|
}
|
|
104
110
|
}
|
|
105
111
|
}
|
|
112
|
+
|
|
113
|
+
.leading-ellipses-list-item {
|
|
114
|
+
height: fit-content;
|
|
115
|
+
}
|
|
106
116
|
}
|
|
107
117
|
}
|
|
@@ -78,7 +78,7 @@ export class Input extends Component<Props> implements IFocusable {
|
|
|
78
78
|
return this.nativeInput.current!.value;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
onPress = (event: KeyboardEvent | MouseEvent) => {
|
|
82
82
|
if (!this.isInputting && isClickOrEnter(event)) {
|
|
83
83
|
stopEvent(event);
|
|
84
84
|
this.processInput();
|
|
@@ -186,7 +186,7 @@ export class Input extends Component<Props> implements IFocusable {
|
|
|
186
186
|
<Interactable
|
|
187
187
|
className="input"
|
|
188
188
|
ref={this.wrap}
|
|
189
|
-
onPress={this.
|
|
189
|
+
onPress={this.onPress}
|
|
190
190
|
onFocus={onFocus}
|
|
191
191
|
onBlur={onBlur}
|
|
192
192
|
>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const ELLIPSIS = '...';
|
|
2
|
+
|
|
3
|
+
export const trimWithLeadingEllipsis = (row: HTMLSpanElement) => {
|
|
4
|
+
if (row && row.textContent != null) {
|
|
5
|
+
row.style.visibility = 'hidden';
|
|
6
|
+
const lineHeightString = window.getComputedStyle(row, null).getPropertyValue('line-height');
|
|
7
|
+
const lineHeight = parseInt(lineHeightString, 10);
|
|
8
|
+
let numberOfLines = row.offsetHeight / lineHeight;
|
|
9
|
+
if (numberOfLines > 2) {
|
|
10
|
+
const originalTextContent = row.textContent;
|
|
11
|
+
row.textContent = ELLIPSIS;
|
|
12
|
+
let stringBuffer = '';
|
|
13
|
+
let currentPosition = originalTextContent.length - 1;
|
|
14
|
+
do {
|
|
15
|
+
const charToAdd = originalTextContent.at(currentPosition);
|
|
16
|
+
stringBuffer = `${charToAdd}${stringBuffer}`;
|
|
17
|
+
row.textContent = `${ELLIPSIS}${stringBuffer}`;
|
|
18
|
+
currentPosition -= 1;
|
|
19
|
+
numberOfLines = Math.floor(row.offsetHeight / lineHeight);
|
|
20
|
+
} while (numberOfLines <= 2 && currentPosition >= 0);
|
|
21
|
+
row.textContent = `${ELLIPSIS}${stringBuffer.substring(1)}`;
|
|
22
|
+
}
|
|
23
|
+
row.style.visibility = 'visible';
|
|
24
|
+
}
|
|
25
|
+
};
|