@operato/board 1.4.78 → 1.4.80
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/CHANGELOG.md +17 -0
- package/dist/src/ox-board-player.js +1 -1
- package/dist/src/ox-board-player.js.map +1 -1
- package/dist/src/player/ox-board-wrapper.js +76 -29
- package/dist/src/player/ox-board-wrapper.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/ox-board-player.ts +1 -1
- package/src/player/ox-board-wrapper.ts +81 -29
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@operato/board",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.80",
|
|
4
4
|
"description": "Webcomponent for board following open-wc recommendations",
|
|
5
5
|
"author": "heartyoh",
|
|
6
6
|
"main": "dist/src/index.js",
|
|
@@ -88,9 +88,9 @@
|
|
|
88
88
|
},
|
|
89
89
|
"dependencies": {
|
|
90
90
|
"@open-wc/scoped-elements": "^2.0.0-next.6",
|
|
91
|
-
"@operato/app": "^1.4.
|
|
91
|
+
"@operato/app": "^1.4.79",
|
|
92
92
|
"@operato/data-grist": "^1.4.77",
|
|
93
|
-
"@operato/font": "^1.4.
|
|
93
|
+
"@operato/font": "^1.4.79",
|
|
94
94
|
"@operato/graphql": "^1.4.76",
|
|
95
95
|
"@operato/i18n": "^1.4.64",
|
|
96
96
|
"@operato/input": "^1.4.64",
|
|
@@ -148,5 +148,5 @@
|
|
|
148
148
|
"prettier --write"
|
|
149
149
|
]
|
|
150
150
|
},
|
|
151
|
-
"gitHead": "
|
|
151
|
+
"gitHead": "2f8ba7760be08a680a4b531a55b0ba783a2bdb04"
|
|
152
152
|
}
|
package/src/ox-board-player.ts
CHANGED
|
@@ -45,7 +45,7 @@ export class BoardPlayer extends LitElement {
|
|
|
45
45
|
${this.boards.map(
|
|
46
46
|
item =>
|
|
47
47
|
html`
|
|
48
|
-
<ox-board-wrapper page .
|
|
48
|
+
<ox-board-wrapper page .board=${item} .data=${this.data} .provider=${this.provider}>
|
|
49
49
|
</ox-board-wrapper>
|
|
50
50
|
`
|
|
51
51
|
)}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { css, html, LitElement, PropertyValues } from 'lit'
|
|
2
2
|
import { customElement, property, query, state } from 'lit/decorators.js'
|
|
3
3
|
|
|
4
|
+
import { BoardDataStorage } from '../data-storage/data-storage.js'
|
|
5
|
+
import { DataSubscriptionProviderImpl } from '../graphql/data-subscription.js'
|
|
6
|
+
|
|
7
|
+
import { create, SCENE_MODE } from '@hatiolab/things-scene'
|
|
8
|
+
|
|
4
9
|
/**
|
|
5
10
|
* @class BoardWrapper
|
|
6
11
|
*
|
|
@@ -11,11 +16,13 @@ class BoardWrapper extends LitElement {
|
|
|
11
16
|
static styles = [
|
|
12
17
|
css`
|
|
13
18
|
:host {
|
|
14
|
-
|
|
19
|
+
display: flex;
|
|
20
|
+
flex-direction: column;
|
|
15
21
|
}
|
|
16
22
|
|
|
17
23
|
#target {
|
|
18
|
-
|
|
24
|
+
flex: 1;
|
|
25
|
+
|
|
19
26
|
width: 100%;
|
|
20
27
|
height: 100%;
|
|
21
28
|
outline: 0;
|
|
@@ -23,11 +30,13 @@ class BoardWrapper extends LitElement {
|
|
|
23
30
|
`
|
|
24
31
|
]
|
|
25
32
|
|
|
26
|
-
@property({ type: String }) sceneId!: string
|
|
27
33
|
@property({ type: Object }) provider!: any
|
|
28
34
|
@property({ type: Object }) data: any
|
|
35
|
+
@property({ type: Object }) board?: any
|
|
36
|
+
@property({ type: String }) baseUrl?: string
|
|
29
37
|
|
|
30
|
-
|
|
38
|
+
private _scene: any
|
|
39
|
+
private connected: boolean = false
|
|
31
40
|
|
|
32
41
|
@query('#target') _targetEl!: HTMLElement
|
|
33
42
|
|
|
@@ -38,6 +47,8 @@ class BoardWrapper extends LitElement {
|
|
|
38
47
|
connectedCallback() {
|
|
39
48
|
super.connectedCallback()
|
|
40
49
|
|
|
50
|
+
this.connected = true
|
|
51
|
+
|
|
41
52
|
window.addEventListener('resize', () => {
|
|
42
53
|
requestAnimationFrame(() => {
|
|
43
54
|
if (this._scene) {
|
|
@@ -53,45 +64,86 @@ class BoardWrapper extends LitElement {
|
|
|
53
64
|
|
|
54
65
|
disconnectedCallback() {
|
|
55
66
|
super.disconnectedCallback()
|
|
67
|
+
this.connected = false
|
|
56
68
|
|
|
57
|
-
|
|
69
|
+
/* ox-board-player-carousel에 의해서 mutation 되면서, 잠깐 disconnected되므로,
|
|
70
|
+
최종적으로 disconnected 여부를 확인하여야 한다. */
|
|
71
|
+
requestAnimationFrame(() => {
|
|
72
|
+
if (!this.connected) {
|
|
73
|
+
this.closeScene()
|
|
74
|
+
}
|
|
75
|
+
})
|
|
58
76
|
}
|
|
59
77
|
|
|
60
78
|
updated(changes: PropertyValues<this>) {
|
|
61
|
-
changes.has('
|
|
79
|
+
changes.has('board') && this._onBoardChanged()
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
_onBoardChanged() {
|
|
83
|
+
this.initScene()
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
initScene() {
|
|
87
|
+
if (!this.board || !this.board.id) {
|
|
88
|
+
return
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
var { model } = this.board
|
|
92
|
+
|
|
93
|
+
try {
|
|
94
|
+
if (typeof model == 'string') {
|
|
95
|
+
model = JSON.parse(model)
|
|
96
|
+
} else {
|
|
97
|
+
model = JSON.parse(JSON.stringify(model))
|
|
98
|
+
}
|
|
99
|
+
} catch (err) {
|
|
100
|
+
console.error(err)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
this._scene = create({
|
|
104
|
+
model,
|
|
105
|
+
mode: SCENE_MODE.VIEW,
|
|
106
|
+
refProvider: this.provider!,
|
|
107
|
+
dataStorage: new BoardDataStorage(this.board.id),
|
|
108
|
+
dataSubscriptionProvider: new DataSubscriptionProviderImpl()
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
if (this.baseUrl) {
|
|
112
|
+
this._scene.baseUrl = this.baseUrl
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
this.setupScene({ id: this.board.id, scene: this._scene })
|
|
62
116
|
}
|
|
63
117
|
|
|
64
|
-
|
|
118
|
+
closeScene() {
|
|
65
119
|
if (this._scene) {
|
|
66
120
|
this._scene.target = null
|
|
67
121
|
this._scene.release && this._scene.release()
|
|
68
|
-
|
|
122
|
+
|
|
123
|
+
this._scene = null
|
|
69
124
|
}
|
|
70
125
|
}
|
|
71
126
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
this._releaseRef()
|
|
127
|
+
setupScene({ id, scene }: { id: string; scene: any }) {
|
|
128
|
+
this._scene = scene
|
|
75
129
|
|
|
76
|
-
|
|
130
|
+
const backgroundColor = this._scene?.root.state.fillStyle
|
|
131
|
+
if (typeof backgroundColor === 'string') {
|
|
132
|
+
this.style.backgroundColor = backgroundColor
|
|
133
|
+
} else {
|
|
134
|
+
this.style.backgroundColor = 'initial'
|
|
135
|
+
}
|
|
77
136
|
|
|
78
|
-
this.
|
|
79
|
-
(scene: any) => {
|
|
80
|
-
this._scene = scene
|
|
81
|
-
this._scene.target = this._targetEl
|
|
82
|
-
if (this.data) {
|
|
83
|
-
this._scene.data = this.data
|
|
84
|
-
}
|
|
137
|
+
this._scene.target = this._targetEl
|
|
85
138
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
)
|
|
139
|
+
requestAnimationFrame(() => {
|
|
140
|
+
if (this._scene.target.offsetWidth) {
|
|
141
|
+
this._scene.fit()
|
|
142
|
+
}
|
|
143
|
+
})
|
|
144
|
+
|
|
145
|
+
if (this.data) {
|
|
146
|
+
this._scene.data = this.data
|
|
147
|
+
}
|
|
96
148
|
}
|
|
97
149
|
}
|