@vnejs/plugins.view.coralina.history 0.0.1 → 0.1.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/modules/controller.js +12 -16
- package/modules/view.js +4 -4
- package/package.json +5 -6
- package/view/components/HistoryClose.jsx +24 -0
- package/view/components/HistoryLines.jsx +64 -0
- package/view/components/index.js +2 -0
- package/view/index.jsx +29 -50
- package/view/index.styl +0 -77
package/modules/controller.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ModuleController } from "@vnejs/module.components";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import { ZINDEX } from "../view";
|
|
4
|
+
|
|
5
|
+
export class HistoryController extends ModuleController {
|
|
4
6
|
name = "history.controller";
|
|
5
7
|
|
|
6
8
|
emitHide = () => this.emit(this.EVENTS.HISTORY_VIEW.HIDE);
|
|
@@ -14,7 +16,7 @@ export class HistoryController extends Module.Controller {
|
|
|
14
16
|
[this.CONST.CONTROLS.BUTTONS.ARROW_BOTTOM]: this.incCurrentItem,
|
|
15
17
|
[this.CONST.CONTROLS.BUTTONS.ACCEPT]: () => this.emit(this.EVENTS.HISTORY_VIEW.ACCEPT),
|
|
16
18
|
};
|
|
17
|
-
controlsIndex =
|
|
19
|
+
controlsIndex = ZINDEX;
|
|
18
20
|
|
|
19
21
|
subscribe = () => {
|
|
20
22
|
this.on(this.EVENTS.HISTORY_VIEW.SHOW, this.onShow);
|
|
@@ -25,22 +27,16 @@ export class HistoryController extends Module.Controller {
|
|
|
25
27
|
this.on(this.EVENTS.STATE.SET, this.onStateSet);
|
|
26
28
|
};
|
|
27
29
|
|
|
28
|
-
beforeShow = async () =>
|
|
29
|
-
this.
|
|
30
|
-
historyLocs: await Promise.all(this.globalState.history.history.map(this.getHistoryLoc)),
|
|
31
|
-
history: this.globalState.history.history,
|
|
32
|
-
});
|
|
30
|
+
beforeShow = async () => {
|
|
31
|
+
this.maxCurrentItem = this.globalState.history.history.length - 1;
|
|
33
32
|
|
|
34
|
-
|
|
35
|
-
if (this.currentItem !== null)
|
|
36
|
-
await this.emit(this.EVENTS.HISTORY_VIEW.CLICK, { uid: this.globalState.history.history[this.currentItem].uid });
|
|
33
|
+
this.updateState({ historyLocs: await Promise.all(this.globalState.history.history.map(this.getHistoryLoc)), history: this.globalState.history.history });
|
|
37
34
|
};
|
|
38
35
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
};
|
|
36
|
+
onAccept = () => this.currentItem !== null && this.emit(this.EVENTS.HISTORY_VIEW.CLICK, { uid: this.globalState.history.history[this.currentItem].uid });
|
|
37
|
+
onClick = ({ uid } = {}) => this.shared.history.storageKeys.includes(uid) && this.emit(this.EVENTS.HISTORY.LOAD, { uid });
|
|
42
38
|
|
|
43
|
-
onStateSet = () => this.emit(this.EVENTS.HISTORY_VIEW.HIDE, {
|
|
39
|
+
onStateSet = () => this.emit(this.EVENTS.HISTORY_VIEW.HIDE, { isForce: true });
|
|
44
40
|
|
|
45
|
-
getHistoryLoc = ({
|
|
41
|
+
getHistoryLoc = ({ label, text } = {}) => this.emitOne(this.EVENTS.LOCS.GET_TEXT, { label, key: text });
|
|
46
42
|
}
|
package/modules/view.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ModuleView } from "@vnejs/module.components";
|
|
2
2
|
|
|
3
|
-
import { render } from "../view";
|
|
3
|
+
import { render, TRANSITION } from "../view";
|
|
4
4
|
|
|
5
|
-
export class HistoryView extends
|
|
5
|
+
export class HistoryView extends ModuleView {
|
|
6
6
|
name = "history.view";
|
|
7
7
|
locLabel = "history";
|
|
8
|
-
animationTime =
|
|
8
|
+
animationTime = TRANSITION;
|
|
9
9
|
renderFunc = render;
|
|
10
10
|
updateEvent = this.EVENTS.HISTORY_VIEW.UPDATE;
|
|
11
11
|
updateHandler = this.onUpdateReactComponent;
|
package/package.json
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vnejs/plugins.view.coralina.history",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
7
|
+
"publish:major:plugin": "npm run publish:major",
|
|
8
|
+
"publish:minor:plugin": "npm run publish:minor",
|
|
9
|
+
"publish:patch:plugin": "npm run publish:patch",
|
|
7
10
|
"publish:major": "npm version major && npm publish --access public",
|
|
8
11
|
"publish:minor": "npm version minor && npm publish --access public",
|
|
9
12
|
"publish:patch": "npm version patch && npm publish --access public"
|
|
10
13
|
},
|
|
11
14
|
"author": "",
|
|
12
15
|
"license": "ISC",
|
|
13
|
-
"description": ""
|
|
14
|
-
"peerDependencies": {
|
|
15
|
-
"@vnejs/shared": "*",
|
|
16
|
-
"@vnejs/module": "*"
|
|
17
|
-
}
|
|
16
|
+
"description": ""
|
|
18
17
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import { PositionBox, Text } from "@vnejs/uis.base";
|
|
4
|
+
|
|
5
|
+
export class HistoryClose extends React.Component {
|
|
6
|
+
onCloseClick = () => this.props.emit(this.props.EVENTS.HISTORY_VIEW.HIDE);
|
|
7
|
+
|
|
8
|
+
render() {
|
|
9
|
+
const { locs = {} } = this.props;
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<PositionBox
|
|
13
|
+
bottom={120}
|
|
14
|
+
left={120}
|
|
15
|
+
>
|
|
16
|
+
<Text
|
|
17
|
+
size={60}
|
|
18
|
+
text={locs.back}
|
|
19
|
+
onClick={this.onCloseClick}
|
|
20
|
+
/>
|
|
21
|
+
</PositionBox>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import { PositionBox, Text, TextControls } from "@vnejs/uis.base";
|
|
4
|
+
|
|
5
|
+
export class HistoryLines extends React.Component {
|
|
6
|
+
scrollbarWrapRef = React.createRef(null);
|
|
7
|
+
|
|
8
|
+
componentDidUpdate(props, state) {
|
|
9
|
+
if (this.props.isShow && !props.isShow) setImmediate(this.scrollToBottom);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
scrollToBottom = () => {
|
|
13
|
+
this.scrollbarWrapRef.current.scrollTop = 9999999;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
onLineClick = (uid) => {
|
|
17
|
+
const { history: { storageKeys } = {} } = this.props.shared;
|
|
18
|
+
|
|
19
|
+
if (Boolean(storageKeys.find((key) => key === uid))) return this.props.emit(this.props.EVENTS.HISTORY_VIEW.CLICK, { uid });
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
mapTexts = ({ text, uid, speaker, meet }, i) => {
|
|
23
|
+
const { historyLocs = [], shared: { history: { storageKeys } = {}, lang = "ru" } = {} } = this.props;
|
|
24
|
+
|
|
25
|
+
const speakers = this.props.PARAMS.TEXT.SPEAKERS_INFO;
|
|
26
|
+
|
|
27
|
+
const { names = {}, speakerColor = "white" } = speakers[speaker] || speakers.default;
|
|
28
|
+
const langNames = names[lang] || names.default;
|
|
29
|
+
const speakerName = langNames[meet] || langNames[langNames.length - 1];
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
text: (historyLocs && historyLocs[i]) || text,
|
|
33
|
+
value: uid,
|
|
34
|
+
textPrefix: speakerName ? `${speakerName}: ` : undefined,
|
|
35
|
+
colorPrefix: speakerColor,
|
|
36
|
+
weightPrefix: Text.WEIGHT.BOLD,
|
|
37
|
+
isHoverable: Boolean(storageKeys.find((key) => key === uid)),
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
render() {
|
|
42
|
+
const { history = [], currentItem = null } = this.props;
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<PositionBox
|
|
46
|
+
top={120}
|
|
47
|
+
left={120}
|
|
48
|
+
right={120}
|
|
49
|
+
>
|
|
50
|
+
<TextControls
|
|
51
|
+
selectedIndex={currentItem}
|
|
52
|
+
scrollbarWrapRef={this.scrollbarWrapRef}
|
|
53
|
+
wrapHeight={1800}
|
|
54
|
+
withScrollbar={true}
|
|
55
|
+
flexGap={36}
|
|
56
|
+
textSize={60}
|
|
57
|
+
textMarginTop={36}
|
|
58
|
+
texts={history.map(this.mapTexts)}
|
|
59
|
+
onClick={this.onLineClick}
|
|
60
|
+
/>
|
|
61
|
+
</PositionBox>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
}
|
package/view/index.jsx
CHANGED
|
@@ -1,64 +1,43 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import ReactDOM from "react-dom";
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { Screen } from "@vnejs/uis.base";
|
|
5
5
|
|
|
6
|
-
import "./
|
|
6
|
+
import { HistoryClose, HistoryLines } from "./components";
|
|
7
7
|
|
|
8
|
-
const
|
|
8
|
+
export const ZINDEX = 2000;
|
|
9
|
+
export const TRANSITION = 300;
|
|
9
10
|
|
|
10
11
|
class History extends React.Component {
|
|
11
|
-
state = {
|
|
12
|
-
linesRef = React.createRef(null);
|
|
13
|
-
componentDidUpdate(props, state) {
|
|
14
|
-
if (this.state.isShow && !state.isShow) setImmediate(this.scrollLinesToBottom);
|
|
15
|
-
}
|
|
16
|
-
onCloseClick = () => this.props.emit(this.props.EVENTS.HISTORY_VIEW.HIDE);
|
|
17
|
-
onLineClick = (e) => {
|
|
18
|
-
const { uid } = e.currentTarget.dataset;
|
|
19
|
-
|
|
20
|
-
this.props.emit(this.props.EVENTS.HISTORY_VIEW.CLICK, { uid });
|
|
21
|
-
};
|
|
22
|
-
renderHistoryLine = ({ uid, text, speaker, meet } = {}, i) => {
|
|
23
|
-
const { historyLocs = [], currentItem } = this.state;
|
|
24
|
-
const { history: { storageKeys } = {}, speakers = {}, lang = "ru" } = this.props.shared;
|
|
25
|
-
const isActive = Boolean(storageKeys.find((key) => key === uid));
|
|
26
|
-
const { names = {}, speakerColor = "white" } = speakers[speaker] || speakers.default;
|
|
27
|
-
const langNames = names[lang] || names.default;
|
|
28
|
-
const speakerName = langNames[meet] || langNames[langNames.length - 1];
|
|
29
|
-
const realText = (historyLocs && historyLocs[i]) || text;
|
|
12
|
+
state = {};
|
|
30
13
|
|
|
31
|
-
return (
|
|
32
|
-
<div
|
|
33
|
-
className={b("line", { active: isActive, disabled: !isActive, isCurrent: currentItem === i }, ["textWrap_60"])}
|
|
34
|
-
key={uid}
|
|
35
|
-
data-uid={uid}
|
|
36
|
-
onClick={isActive ? this.onLineClick : undefined}
|
|
37
|
-
>
|
|
38
|
-
<span className={b("lineSpeaker", ["text"])} style={{ color: speakerColor }}>
|
|
39
|
-
{speakerName && <>{speakerName}: </>}
|
|
40
|
-
</span>
|
|
41
|
-
<span className={b("lineText", ["text"])}>{realText}</span>
|
|
42
|
-
</div>
|
|
43
|
-
);
|
|
44
|
-
};
|
|
45
|
-
scrollLinesToBottom = () => {
|
|
46
|
-
this.linesRef.current.scrollTop = 9999999;
|
|
47
|
-
};
|
|
48
14
|
render() {
|
|
49
|
-
const { isShow = false, isForce = false, history = [],
|
|
15
|
+
const { isShow = false, isForce = false, locs = {}, history = [], historyLocs = [], currentItem = null } = this.state;
|
|
50
16
|
|
|
51
17
|
return (
|
|
52
|
-
<
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
18
|
+
<Screen
|
|
19
|
+
isShow={isShow}
|
|
20
|
+
isForce={isForce}
|
|
21
|
+
zIndex={ZINDEX}
|
|
22
|
+
transition={TRANSITION}
|
|
23
|
+
isDisableAutoread={true}
|
|
24
|
+
isIgnoreOnScreenshot={true}
|
|
25
|
+
withBlur={true}
|
|
26
|
+
withDark={true}
|
|
27
|
+
>
|
|
28
|
+
<HistoryLines
|
|
29
|
+
{...this.props}
|
|
30
|
+
isShow={isShow}
|
|
31
|
+
history={history}
|
|
32
|
+
historyLocs={historyLocs}
|
|
33
|
+
currentItem={currentItem}
|
|
34
|
+
/>
|
|
35
|
+
|
|
36
|
+
<HistoryClose
|
|
37
|
+
{...this.props}
|
|
38
|
+
locs={locs}
|
|
39
|
+
/>
|
|
40
|
+
</Screen>
|
|
62
41
|
);
|
|
63
42
|
}
|
|
64
43
|
}
|
package/view/index.styl
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
.History
|
|
2
|
-
position: absolute
|
|
3
|
-
top: 0
|
|
4
|
-
right: 0
|
|
5
|
-
bottom: 0
|
|
6
|
-
left: 0
|
|
7
|
-
z-index: 4000
|
|
8
|
-
backdrop-filter: blur(5px) brightness(0.5)
|
|
9
|
-
background: rgba(0,0,0,0.4)
|
|
10
|
-
opacity: 0
|
|
11
|
-
pointer-events: none
|
|
12
|
-
display: flex
|
|
13
|
-
justify-content: center
|
|
14
|
-
align-items: center
|
|
15
|
-
font-family: Montserrat
|
|
16
|
-
|
|
17
|
-
&-wrap
|
|
18
|
-
position: absolute
|
|
19
|
-
top: 1.25%
|
|
20
|
-
right: 2.25%
|
|
21
|
-
bottom: 1.25%
|
|
22
|
-
left: 2.25%
|
|
23
|
-
z-index: 4001
|
|
24
|
-
box-sizing: border-box
|
|
25
|
-
display: flex
|
|
26
|
-
align-items: initial
|
|
27
|
-
justify-content: space-between
|
|
28
|
-
align-items: flex-start
|
|
29
|
-
flex-direction: column
|
|
30
|
-
|
|
31
|
-
&-linesWrap
|
|
32
|
-
position relative
|
|
33
|
-
|
|
34
|
-
&-lines
|
|
35
|
-
overflow: auto
|
|
36
|
-
display: flex
|
|
37
|
-
flex-direction: column
|
|
38
|
-
align-items: flex-start
|
|
39
|
-
height: calc(1900 / 2100 * 100%)
|
|
40
|
-
|
|
41
|
-
&-line
|
|
42
|
-
color: rgb(255, 255, 255, 1)
|
|
43
|
-
opacity: 0.6
|
|
44
|
-
border-radius: 8px
|
|
45
|
-
transition: opacity 300ms, outline 300ms
|
|
46
|
-
|
|
47
|
-
&_active
|
|
48
|
-
cursor: pointer
|
|
49
|
-
|
|
50
|
-
&:hover
|
|
51
|
-
opacity: 1
|
|
52
|
-
|
|
53
|
-
&_isCurrent
|
|
54
|
-
outline: 2px solid white
|
|
55
|
-
|
|
56
|
-
& ~ &
|
|
57
|
-
margin-top: 1%
|
|
58
|
-
|
|
59
|
-
&-lineSpeaker
|
|
60
|
-
font-weight: 700
|
|
61
|
-
|
|
62
|
-
&-back
|
|
63
|
-
color: white
|
|
64
|
-
cursor: pointer
|
|
65
|
-
transition: opacity 300ms
|
|
66
|
-
flex-shrink: 0
|
|
67
|
-
opacity 0.6
|
|
68
|
-
|
|
69
|
-
&:hover
|
|
70
|
-
opacity: 1
|
|
71
|
-
|
|
72
|
-
&_isShow
|
|
73
|
-
opacity: 1
|
|
74
|
-
pointer-events: all
|
|
75
|
-
|
|
76
|
-
&:not(&_isForce)
|
|
77
|
-
transition: opacity 300ms
|