@operato/scene-tab 0.0.22
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/@types/global/index.d.ts +1 -0
- package/CHANGELOG.md +11 -0
- package/LICENSE +21 -0
- package/README.md +33 -0
- package/assets/tab.png +0 -0
- package/demo/index.html +252 -0
- package/demo/things-scene-tab.html +5 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/tab-button.d.ts +18 -0
- package/dist/tab-button.js +78 -0
- package/dist/tab-button.js.map +1 -0
- package/dist/tab.d.ts +48 -0
- package/dist/tab.js +256 -0
- package/dist/tab.js.map +1 -0
- package/dist/templates/index.d.ts +20 -0
- package/dist/templates/index.js +3 -0
- package/dist/templates/index.js.map +1 -0
- package/dist/templates/tab.d.ts +20 -0
- package/dist/templates/tab.js +21 -0
- package/dist/templates/tab.js.map +1 -0
- package/helps/scene/component/tab.ko.md +14 -0
- package/helps/scene/component/tab.md +13 -0
- package/helps/scene/component/tab.zh.md +13 -0
- package/helps/scene/images/container-04.png +0 -0
- package/images/icon-button.png +0 -0
- package/package.json +61 -0
- package/src/index.ts +4 -0
- package/src/tab-button.ts +100 -0
- package/src/tab.ts +328 -0
- package/src/templates/index.ts +3 -0
- package/src/templates/tab.ts +21 -0
- package/test/basic-test.html +67 -0
- package/test/index.html +22 -0
- package/things-scene.config.js +5 -0
- package/tsconfig.json +22 -0
- package/tsconfig.tsbuildinfo +1 -0
package/dist/tab.js
ADDED
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import { Component, Container, LinearHorizontalLayout, LinearVerticalLayout, Model } from '@hatiolab/things-scene';
|
|
5
|
+
const HANDLE_WIDTH = 25;
|
|
6
|
+
const HANDLE_HEIGHT = 25;
|
|
7
|
+
function rgba(r, g, b, a) {
|
|
8
|
+
return `rgba(${r}, ${g}, ${b}, ${a})`;
|
|
9
|
+
}
|
|
10
|
+
const NATURE = {
|
|
11
|
+
mutable: false,
|
|
12
|
+
resizable: true,
|
|
13
|
+
rotatable: true,
|
|
14
|
+
properties: [
|
|
15
|
+
{
|
|
16
|
+
type: 'id-input',
|
|
17
|
+
label: 'tab-reference',
|
|
18
|
+
name: 'reference',
|
|
19
|
+
property: {
|
|
20
|
+
component: 'indoor-map'
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
type: 'number',
|
|
25
|
+
label: 'tab-active-index',
|
|
26
|
+
name: 'activeIndex',
|
|
27
|
+
property: {
|
|
28
|
+
min: 0,
|
|
29
|
+
step: 1
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
type: 'color',
|
|
34
|
+
label: 'active-fill-style',
|
|
35
|
+
name: 'activeFillStyle',
|
|
36
|
+
property: 'activeFillStyle'
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
type: 'color',
|
|
40
|
+
label: 'active-font-color',
|
|
41
|
+
name: 'activeFontColor',
|
|
42
|
+
property: 'activeFontColor'
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
type: 'color',
|
|
46
|
+
label: 'active-line-color',
|
|
47
|
+
name: 'activeLineColor',
|
|
48
|
+
property: 'activeLineColor'
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
type: 'number',
|
|
52
|
+
label: 'active-line-width',
|
|
53
|
+
name: 'activeLineWidth',
|
|
54
|
+
property: 'activeLineWidth'
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
};
|
|
58
|
+
export default class Tab extends Container {
|
|
59
|
+
get layout() {
|
|
60
|
+
let { width, height } = this.model;
|
|
61
|
+
if (width >= height) {
|
|
62
|
+
return LinearHorizontalLayout;
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
return LinearVerticalLayout;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
get nature() {
|
|
69
|
+
return NATURE;
|
|
70
|
+
}
|
|
71
|
+
// 컴포넌트를 임의로 추가 및 삭제할 수 있는 지를 지정하는 속성임.
|
|
72
|
+
get focusible() {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
get reference() {
|
|
76
|
+
var { reference } = this.model;
|
|
77
|
+
if (!reference)
|
|
78
|
+
return null;
|
|
79
|
+
if (!this._reference) {
|
|
80
|
+
this._reference = this.root.findById(reference);
|
|
81
|
+
if (this._reference)
|
|
82
|
+
this._reference.on('change', this.onRefChanged, this);
|
|
83
|
+
}
|
|
84
|
+
return this._reference;
|
|
85
|
+
}
|
|
86
|
+
get labelHeight() {
|
|
87
|
+
var components = this.reference.components.length;
|
|
88
|
+
var height = this.model.height;
|
|
89
|
+
return (components > 0 && height / components) || height;
|
|
90
|
+
}
|
|
91
|
+
get activeIndex() {
|
|
92
|
+
return this.get('activeIndex');
|
|
93
|
+
}
|
|
94
|
+
set reference(reference) {
|
|
95
|
+
if (this.reference)
|
|
96
|
+
this.reference.off('change', this.onRefChanged, this);
|
|
97
|
+
this._reference = null;
|
|
98
|
+
this.model.reference = reference;
|
|
99
|
+
}
|
|
100
|
+
set activeIndex(index) {
|
|
101
|
+
this.set('activeIndex', index);
|
|
102
|
+
if (this.reference) {
|
|
103
|
+
this.reference.activeIndex = index;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
render(context) {
|
|
107
|
+
super.render(context);
|
|
108
|
+
if (this.reference) {
|
|
109
|
+
if (this.size() !== this.reference.size())
|
|
110
|
+
this.rebuildTabButtons();
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
// TODO reference 가 잘못되거나 안되어있다는 경고 의미로 뭔가 그려라..
|
|
114
|
+
var componentsLength = this.components.length;
|
|
115
|
+
for (var i = componentsLength - 1; i >= 0; i--) {
|
|
116
|
+
var tabBtn = this.components[i];
|
|
117
|
+
this.removeComponent(tabBtn);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
postrender(context) {
|
|
122
|
+
super.postrender(context);
|
|
123
|
+
if (!this.app.isEditMode)
|
|
124
|
+
return;
|
|
125
|
+
var { left, top, width, fillStyle } = this.model;
|
|
126
|
+
// 이동 핸들 그리기
|
|
127
|
+
context.beginPath();
|
|
128
|
+
context.rect(left + width, top, HANDLE_WIDTH, HANDLE_HEIGHT);
|
|
129
|
+
let color = 255 - (20 % 255);
|
|
130
|
+
context.fillStyle = rgba(color, color, color, 1);
|
|
131
|
+
context.fill();
|
|
132
|
+
context.closePath();
|
|
133
|
+
}
|
|
134
|
+
contains(x, y) {
|
|
135
|
+
if (!this.app.isEditMode)
|
|
136
|
+
return super.contains(x, y);
|
|
137
|
+
if (super.contains(x, y))
|
|
138
|
+
return true;
|
|
139
|
+
var { left, top, width } = this.bounds;
|
|
140
|
+
var right = left + width;
|
|
141
|
+
var h = HANDLE_HEIGHT;
|
|
142
|
+
return (x < Math.max(right + HANDLE_WIDTH, right) &&
|
|
143
|
+
x > Math.min(right + HANDLE_WIDTH, right) &&
|
|
144
|
+
y < Math.max(top + h, top) &&
|
|
145
|
+
y > Math.min(top + h, top));
|
|
146
|
+
}
|
|
147
|
+
dispose() {
|
|
148
|
+
if (this.reference)
|
|
149
|
+
this.reference.off('change', this.onRefChanged, this);
|
|
150
|
+
super.dispose();
|
|
151
|
+
}
|
|
152
|
+
rebuildTabButtons() {
|
|
153
|
+
var { tabIndex = 0, left, top, width, height, fillStyle, activeFillStyle, activeLineColor, activeLineWidth, strokeStyle, fontColor, activeFontColor, fontFamily, fontSize, lineHeight, italic, bold, lineWidth = 0 } = this.model;
|
|
154
|
+
var reference = this.reference;
|
|
155
|
+
let children = [];
|
|
156
|
+
let components = reference.components;
|
|
157
|
+
let label_height = this.labelHeight;
|
|
158
|
+
let componentsLength = this.components.length;
|
|
159
|
+
for (var i = componentsLength - 1; i >= 0; i--) {
|
|
160
|
+
this.removeComponent(this.components[i]);
|
|
161
|
+
}
|
|
162
|
+
for (let i = 0; i < components.length; i++) {
|
|
163
|
+
if (components[i].model.type != 'floor')
|
|
164
|
+
continue;
|
|
165
|
+
let floorText = components[i].text || '';
|
|
166
|
+
children.push(Model.compile({
|
|
167
|
+
type: 'tab-button',
|
|
168
|
+
index: i,
|
|
169
|
+
text: floorText || String(i + 1),
|
|
170
|
+
fillStyle: fillStyle || 'transparent',
|
|
171
|
+
activeFillStyle: activeFillStyle,
|
|
172
|
+
activeLineColor: activeLineColor,
|
|
173
|
+
activeLineWidth: activeLineWidth,
|
|
174
|
+
fontColor: fontColor,
|
|
175
|
+
activeFontColor: activeFontColor || fontColor,
|
|
176
|
+
fontFamily: fontFamily,
|
|
177
|
+
fontSize: fontSize,
|
|
178
|
+
lineHeight: lineHeight,
|
|
179
|
+
italic: italic,
|
|
180
|
+
bold: bold,
|
|
181
|
+
strokeStyle: strokeStyle,
|
|
182
|
+
lineWidth: lineWidth,
|
|
183
|
+
left: 0,
|
|
184
|
+
top: 0,
|
|
185
|
+
width: width,
|
|
186
|
+
height: height
|
|
187
|
+
}));
|
|
188
|
+
}
|
|
189
|
+
this.add(children);
|
|
190
|
+
this.reflow();
|
|
191
|
+
this.activeIndex = this.model.activeIndex || 0;
|
|
192
|
+
}
|
|
193
|
+
setTabButtonsStyle(style) {
|
|
194
|
+
// var {
|
|
195
|
+
// fillStyle,
|
|
196
|
+
// activeFillStyle,
|
|
197
|
+
// fontColor,
|
|
198
|
+
// activeFontColor,
|
|
199
|
+
// strokeStyle,
|
|
200
|
+
// lineWidth = 0,
|
|
201
|
+
// fontFamily,
|
|
202
|
+
// fontSize,
|
|
203
|
+
// lineHeight,
|
|
204
|
+
// italic,
|
|
205
|
+
// bold
|
|
206
|
+
// } = style
|
|
207
|
+
var children = this.components;
|
|
208
|
+
for (var i in children) {
|
|
209
|
+
var tabBtn = children[i];
|
|
210
|
+
tabBtn.set(style);
|
|
211
|
+
// tabBtn.set({
|
|
212
|
+
// fillStyle: fillStyle,
|
|
213
|
+
// activeFillStyle: activeFillStyle,
|
|
214
|
+
// fontColor: fontColor,
|
|
215
|
+
// activeFontColor: activeFontColor,
|
|
216
|
+
// strokeStyle: strokeStyle,
|
|
217
|
+
// lineWidth: lineWidth,
|
|
218
|
+
// fontFamily: fontFamily,
|
|
219
|
+
// fontSize: fontSize,
|
|
220
|
+
// lineHeight: lineHeight,
|
|
221
|
+
// italic: italic,
|
|
222
|
+
// bold: bold
|
|
223
|
+
// })
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
// reference가 변했을 때 (tab에 변화를 주기위해)
|
|
227
|
+
onRefChanged(after, before, hint) {
|
|
228
|
+
// let sourceIndex = hint.deliverer.indexOf(hint.origin)
|
|
229
|
+
// if(this.components[sourceIndex]) {
|
|
230
|
+
// this.components[sourceIndex].set(after)
|
|
231
|
+
// this.invalidate()
|
|
232
|
+
// }
|
|
233
|
+
}
|
|
234
|
+
onchange(after, before) {
|
|
235
|
+
if (after.hasOwnProperty('reference')) {
|
|
236
|
+
this.reference = after.reference;
|
|
237
|
+
this.invalidate();
|
|
238
|
+
}
|
|
239
|
+
// if(after.hasOwnProperty("activeFillStyle")
|
|
240
|
+
// || after.hasOwnProperty("activeFontColor")
|
|
241
|
+
// || after.hasOwnProperty("fillStyle")
|
|
242
|
+
// || after.hasOwnProperty("fontColor")
|
|
243
|
+
// || after.hasOwnProperty("strokeStyle")
|
|
244
|
+
// || after.hasOwnProperty("lineWidth")
|
|
245
|
+
// || after.hasOwnProperty("fontFamily")
|
|
246
|
+
// || after.hasOwnProperty("fontSize")
|
|
247
|
+
// || after.hasOwnProperty("lineHeight")
|
|
248
|
+
// || after.hasOwnProperty("italic")
|
|
249
|
+
// || after.hasOwnProperty("bold")) {
|
|
250
|
+
//
|
|
251
|
+
// }
|
|
252
|
+
this.setTabButtonsStyle(after);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
Component.register('tab', Tab);
|
|
256
|
+
//# sourceMappingURL=tab.js.map
|
package/d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B;YAC5B,oBAAoB;YACpB,eAAe;YACf,KAAK;SACN;IACH,CAAC;IAED,mCAAmC;IACnC,YAAY,CAAC,KAAU,EAAE,MAAW,EAAE,IAAS;QAC7C,wDAAwD;QACxD,qCAAqC;QACrC,4CAA4C;QAC5C,sBAAsB;QACtB,IAAI;IACN,CAAC;IAED,QAAQ,CAAC,KAAY,EAAE,MAAa;QAClC,IAAI,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE;YACrC,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,CAAA;YAChC,IAAI,CAAC,UAAU,EAAE,CAAA;SAClB;QAED,6CAA6C;QAC7C,+CAA+C;QAC/C,yCAAyC;QACzC,yCAAyC;QACzC,2CAA2C;QAC3C,yCAAyC;QACzC,0CAA0C;QAC1C,wCAAwC;QACxC,0CAA0C;QAC1C,sCAAsC;QACtC,uCAAuC;QACvC,EAAE;QACF,IAAI;QACJ,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAA;IAChC,CAAC;CACF;AAED,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA","sourcesContent":["/*\n * Copyright © HatioLab Inc. All rights reserved.\n */\nimport {\n Component,\n Container,\n LinearHorizontalLayout,\n LinearVerticalLayout,\n Model,\n State,\n Style\n} from '@hatiolab/things-scene'\n\nconst HANDLE_WIDTH = 25\nconst HANDLE_HEIGHT = 25\n\nfunction rgba(r: number, g: number, b: number, a: number) {\n return `rgba(${r}, ${g}, ${b}, ${a})`\n}\n\nconst NATURE = {\n mutable: false,\n resizable: true,\n rotatable: true,\n properties: [\n {\n type: 'id-input',\n label: 'tab-reference',\n name: 'reference',\n property: {\n component: 'indoor-map'\n }\n },\n {\n type: 'number',\n label: 'tab-active-index',\n name: 'activeIndex',\n property: {\n min: 0,\n step: 1\n }\n },\n {\n type: 'color',\n label: 'active-fill-style',\n name: 'activeFillStyle',\n property: 'activeFillStyle'\n },\n {\n type: 'color',\n label: 'active-font-color',\n name: 'activeFontColor',\n property: 'activeFontColor'\n },\n {\n type: 'color',\n label: 'active-line-color',\n name: 'activeLineColor',\n property: 'activeLineColor'\n },\n {\n type: 'number',\n label: 'active-line-width',\n name: 'activeLineWidth',\n property: 'activeLineWidth'\n }\n ]\n}\n\nexport default class Tab extends Container {\n get layout() {\n let { width, height } = this.model\n\n if (width >= height) {\n return LinearHorizontalLayout\n } else {\n return LinearVerticalLayout\n }\n }\n\n get nature() {\n return NATURE\n }\n\n // 컴포넌트를 임의로 추가 및 삭제할 수 있는 지를 지정하는 속성임.\n get focusible() {\n return false\n }\n\n get reference() {\n var { reference } = this.model\n if (!reference) return null\n\n if (!this._reference) {\n this._reference = this.root.findById(reference)\n if (this._reference) this._reference.on('change', this.onRefChanged, this)\n }\n\n return this._reference\n }\n\n get labelHeight() {\n var components = this.reference.components.length\n var height = this.model.height\n\n return (components > 0 && height / components) || height\n }\n\n get activeIndex() {\n return this.get('activeIndex')\n }\n\n private _reference: any\n\n set reference(reference) {\n if (this.reference) this.reference.off('change', this.onRefChanged, this)\n\n this._reference = null\n this.model.reference = reference\n }\n\n set activeIndex(index) {\n this.set('activeIndex', index)\n if (this.reference) {\n this.reference.activeIndex = index\n }\n }\n\n render(context: CanvasRenderingContext2D) {\n super.render(context)\n\n if (this.reference) {\n if (this.size() !== this.reference.size()) this.rebuildTabButtons()\n } else {\n // TODO reference 가 잘못되거나 안되어있다는 경고 의미로 뭔가 그려라..\n var componentsLength = this.components.length\n for (var i = componentsLength - 1; i >= 0; i--) {\n var tabBtn = this.components[i]\n this.removeComponent(tabBtn)\n }\n }\n }\n\n postrender(context: CanvasRenderingContext2D) {\n super.postrender(context)\n\n if (!this.app.isEditMode) return\n\n var { left, top, width, fillStyle } = this.model\n\n // 이동 핸들 그리기\n context.beginPath()\n\n context.rect(left + width, top, HANDLE_WIDTH, HANDLE_HEIGHT)\n\n let color = 255 - (20 % 255)\n context.fillStyle = rgba(color, color, color, 1)\n context.fill()\n\n context.closePath()\n }\n\n contains(x: number, y: number) {\n if (!this.app.isEditMode) return super.contains(x, y)\n\n if (super.contains(x, y)) return true\n\n var { left, top, width } = this.bounds\n\n var right = left + width\n\n var h = HANDLE_HEIGHT\n\n return (\n x < Math.max(right + HANDLE_WIDTH, right) &&\n x > Math.min(right + HANDLE_WIDTH, right) &&\n y < Math.max(top + h, top) &&\n y > Math.min(top + h, top)\n )\n }\n\n dispose() {\n if (this.reference) this.reference.off('change', this.onRefChanged, this)\n\n super.dispose()\n }\n\n rebuildTabButtons() {\n var {\n tabIndex = 0,\n left,\n top,\n width,\n height,\n fillStyle,\n activeFillStyle,\n activeLineColor,\n activeLineWidth,\n strokeStyle,\n fontColor,\n activeFontColor,\n fontFamily,\n fontSize,\n lineHeight,\n italic,\n bold,\n lineWidth = 0\n } = this.model\n\n var reference = this.reference\n let children = []\n\n let components = reference.components\n let label_height = this.labelHeight\n\n let componentsLength = this.components.length\n\n for (var i = componentsLength - 1; i >= 0; i--) {\n this.removeComponent(this.components[i])\n }\n\n for (let i = 0; i < components.length; i++) {\n if (components[i].model.type != 'floor') continue\n\n let floorText = components[i].text || ''\n\n children.push(\n Model.compile({\n type: 'tab-button',\n index: i,\n text: floorText || String(i + 1),\n fillStyle: fillStyle || 'transparent',\n activeFillStyle: activeFillStyle,\n activeLineColor: activeLineColor,\n activeLineWidth: activeLineWidth,\n fontColor: fontColor,\n activeFontColor: activeFontColor || fontColor,\n fontFamily: fontFamily,\n fontSize: fontSize,\n lineHeight: lineHeight,\n italic: italic,\n bold: bold,\n strokeStyle: strokeStyle,\n lineWidth: lineWidth,\n left: 0,\n top: 0,\n width: width,\n height: height\n })\n )\n }\n\n this.add(children)\n\n this.reflow()\n\n this.activeIndex = this.model.activeIndex || 0\n }\n\n setTabButtonsStyle(style: Style) {\n // var {\n // fillStyle,\n // activeFillStyle,\n // fontColor,\n // activeFontColor,\n // strokeStyle,\n // lineWidth = 0,\n // fontFamily,\n // fontSize,\n // lineHeight,\n // italic,\n // bold\n // } = style\n\n var children = this.components\n\n for (var i in children) {\n var tabBtn = children[i]\n tabBtn.set(style)\n // tabBtn.set({\n // fillStyle: fillStyle,\n // activeFillStyle: activeFillStyle,\n // fontColor: fontColor,\n // activeFontColor: activeFontColor,\n // strokeStyle: strokeStyle,\n // lineWidth: lineWidth,\n // fontFamily: fontFamily,\n // fontSize: fontSize,\n // lineHeight: lineHeight,\n // italic: italic,\n // bold: bold\n // })\n }\n }\n\n // reference가 변했을 때 (tab에 변화를 주기위해)\n onRefChanged(after: any, before: any, hint: any) {\n // let sourceIndex = hint.deliverer.indexOf(hint.origin)\n // if(this.components[sourceIndex]) {\n // this.components[sourceIndex].set(after)\n // this.invalidate()\n // }\n }\n\n onchange(after: State, before: State) {\n if (after.hasOwnProperty('reference')) {\n this.reference = after.reference\n this.invalidate()\n }\n\n // if(after.hasOwnProperty(\"activeFillStyle\")\n // || after.hasOwnProperty(\"activeFontColor\")\n // || after.hasOwnProperty(\"fillStyle\")\n // || after.hasOwnProperty(\"fontColor\")\n // || after.hasOwnProperty(\"strokeStyle\")\n // || after.hasOwnProperty(\"lineWidth\")\n // || after.hasOwnProperty(\"fontFamily\")\n // || after.hasOwnProperty(\"fontSize\")\n // || after.hasOwnProperty(\"lineHeight\")\n // || after.hasOwnProperty(\"italic\")\n // || after.hasOwnProperty(\"bold\")) {\n //\n // }\n this.setTabButtonsStyle(after)\n }\n}\n\nComponent.register('tab', Tab)\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
type: string;
|
|
3
|
+
description: string;
|
|
4
|
+
group: string;
|
|
5
|
+
icon: any;
|
|
6
|
+
model: {
|
|
7
|
+
type: string;
|
|
8
|
+
left: number;
|
|
9
|
+
top: number;
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
lineWidth: number;
|
|
13
|
+
fillStyle: string;
|
|
14
|
+
activeFillStyle: string;
|
|
15
|
+
strokeStyle: string;
|
|
16
|
+
fontColor: string;
|
|
17
|
+
};
|
|
18
|
+
about: string;
|
|
19
|
+
}[];
|
|
20
|
+
export default _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/templates/index.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,OAAO,CAAA;AAEvB,eAAe,CAAC,GAAG,CAAC,CAAA","sourcesContent":["import tab from './tab'\n\nexport default [tab]\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
type: string;
|
|
3
|
+
description: string;
|
|
4
|
+
group: string;
|
|
5
|
+
icon: any;
|
|
6
|
+
model: {
|
|
7
|
+
type: string;
|
|
8
|
+
left: number;
|
|
9
|
+
top: number;
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
lineWidth: number;
|
|
13
|
+
fillStyle: string;
|
|
14
|
+
activeFillStyle: string;
|
|
15
|
+
strokeStyle: string;
|
|
16
|
+
fontColor: string;
|
|
17
|
+
};
|
|
18
|
+
about: string;
|
|
19
|
+
};
|
|
20
|
+
export default _default;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import icon from '../../assets/tab.png';
|
|
2
|
+
export default {
|
|
3
|
+
type: 'tab',
|
|
4
|
+
description: 'container tab',
|
|
5
|
+
group: 'container' /* line|shape|textAndMedia|chartAndGauge|table|container|dataSource|IoT|3D|warehouse|form|etc */,
|
|
6
|
+
icon,
|
|
7
|
+
model: {
|
|
8
|
+
type: 'tab',
|
|
9
|
+
left: 100,
|
|
10
|
+
top: 100,
|
|
11
|
+
width: 100,
|
|
12
|
+
height: 400,
|
|
13
|
+
lineWidth: 5,
|
|
14
|
+
fillStyle: 'navy',
|
|
15
|
+
activeFillStyle: 'red',
|
|
16
|
+
strokeStyle: 'white',
|
|
17
|
+
fontColor: 'white'
|
|
18
|
+
},
|
|
19
|
+
about: '/helps/scene/component/tab.md'
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=tab.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tab.js","sourceRoot":"","sources":["../../src/templates/tab.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,sBAAsB,CAAA;AAEvC,eAAe;IACb,IAAI,EAAE,KAAK;IACX,WAAW,EAAE,eAAe;IAC5B,KAAK,EAAE,WAAW,CAAC,gGAAgG;IACnH,IAAI;IACJ,KAAK,EAAE;QACL,IAAI,EAAE,KAAK;QACX,IAAI,EAAE,GAAG;QACT,GAAG,EAAE,GAAG;QACR,KAAK,EAAE,GAAG;QACV,MAAM,EAAE,GAAG;QACX,SAAS,EAAE,CAAC;QACZ,SAAS,EAAE,MAAM;QACjB,eAAe,EAAE,KAAK;QACtB,WAAW,EAAE,OAAO;QACpB,SAAS,EAAE,OAAO;KACnB;IACD,KAAK,EAAE,+BAA+B;CACvC,CAAA","sourcesContent":["import icon from '../../assets/tab.png'\n\nexport default {\n type: 'tab',\n description: 'container tab',\n group: 'container' /* line|shape|textAndMedia|chartAndGauge|table|container|dataSource|IoT|3D|warehouse|form|etc */,\n icon,\n model: {\n type: 'tab',\n left: 100,\n top: 100,\n width: 100,\n height: 400,\n lineWidth: 5,\n fillStyle: 'navy',\n activeFillStyle: 'red',\n strokeStyle: 'white',\n fontColor: 'white'\n },\n about: '/helps/scene/component/tab.md'\n}\n"]}
|
|
Binary file
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@operato/scene-tab",
|
|
3
|
+
"description": "Tab style container for Things Scene",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"author": "heartyoh",
|
|
6
|
+
"version": "0.0.22",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"module": "dist/index.js",
|
|
9
|
+
"things-scene": true,
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "public",
|
|
12
|
+
"@oprato:registry": "https://registry.npmjs.org"
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/things-scene/operato-scene.git",
|
|
17
|
+
"directory": "packages/tab"
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"serve": "tsc && things-factory-dev",
|
|
21
|
+
"start": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wds\"",
|
|
22
|
+
"build": "tsc",
|
|
23
|
+
"prepublish": "tsc",
|
|
24
|
+
"lint": "eslint --ext .ts,.html . --ignore-path .gitignore && prettier \"**/*.ts\" --check --ignore-path .gitignore",
|
|
25
|
+
"format": "eslint --ext .ts,.html . --fix --ignore-path .gitignore && prettier \"**/*.ts\" --write --ignore-path .gitignore",
|
|
26
|
+
"migration": "things-factory-migration"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@hatiolab/things-scene": "^2.7.28"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@hatiolab/prettier-config": "^1.0.0",
|
|
33
|
+
"@operato/board": "^0.2.49",
|
|
34
|
+
"@things-factory/builder": "^4.0.17",
|
|
35
|
+
"@things-factory/operato-board": "^4.0.17",
|
|
36
|
+
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
|
37
|
+
"@typescript-eslint/parser": "^4.33.0",
|
|
38
|
+
"@web/dev-server": "^0.1.28",
|
|
39
|
+
"concurrently": "^5.3.0",
|
|
40
|
+
"eslint": "^7.32.0",
|
|
41
|
+
"eslint-config-prettier": "^8.3.0",
|
|
42
|
+
"husky": "^4.3.8",
|
|
43
|
+
"lint-staged": "^10.5.4",
|
|
44
|
+
"prettier": "^2.4.1",
|
|
45
|
+
"tslib": "^2.3.1",
|
|
46
|
+
"typescript": "^4.5.2"
|
|
47
|
+
},
|
|
48
|
+
"prettier": "@hatiolab/prettier-config",
|
|
49
|
+
"husky": {
|
|
50
|
+
"hooks": {
|
|
51
|
+
"pre-commit": "lint-staged"
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"lint-staged": {
|
|
55
|
+
"*.ts": [
|
|
56
|
+
"eslint --fix",
|
|
57
|
+
"prettier --write"
|
|
58
|
+
]
|
|
59
|
+
},
|
|
60
|
+
"gitHead": "7e822f1e624ce53025a7e960578ad43b100b3f01"
|
|
61
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
import { Component, RectPath, State } from '@hatiolab/things-scene'
|
|
5
|
+
|
|
6
|
+
import Tab from './tab'
|
|
7
|
+
|
|
8
|
+
export default class TabButton extends RectPath(Component) {
|
|
9
|
+
get index() {
|
|
10
|
+
return this.model.index
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
get activated() {
|
|
14
|
+
return (this.parent as Tab).activeIndex === this.index
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
removed(parent: Tab) {
|
|
18
|
+
this.dispose()
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
private _fillStyle?: string
|
|
22
|
+
private _fontColor?: string
|
|
23
|
+
private _strokeStyle?: string
|
|
24
|
+
private _lineWidth?: string
|
|
25
|
+
|
|
26
|
+
prerender(context: CanvasRenderingContext2D) {
|
|
27
|
+
super.prerender(context)
|
|
28
|
+
let { fillStyle, activeFillStyle, activeLineColor, activeLineWidth, fontColor, activeFontColor } = this.model
|
|
29
|
+
|
|
30
|
+
// backup style
|
|
31
|
+
if (!this.hasOwnProperty('_fillStyle')) {
|
|
32
|
+
this._fillStyle = fillStyle
|
|
33
|
+
}
|
|
34
|
+
if (!this.hasOwnProperty('_fontColor')) {
|
|
35
|
+
this._fontColor = fontColor
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (this.activated) {
|
|
39
|
+
this.model.fillStyle = activeFillStyle
|
|
40
|
+
this.model.fontColor = activeFontColor
|
|
41
|
+
this.model.strokeStyle = activeLineColor
|
|
42
|
+
this.model.lineWidth = activeLineWidth
|
|
43
|
+
} else {
|
|
44
|
+
this.model.fillStyle = this._fillStyle
|
|
45
|
+
this.model.fontColor = this._fontColor
|
|
46
|
+
this.model.strokeStyle = this._strokeStyle
|
|
47
|
+
this.model.lineWidth = this._lineWidth
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
render(context: CanvasRenderingContext2D) {
|
|
52
|
+
var { left = 0, top = 0, width, height } = this.bounds
|
|
53
|
+
|
|
54
|
+
// 컨테이너의 바운드를 표현한다.(컨테이너의 기본 그리기 기능)
|
|
55
|
+
context.beginPath()
|
|
56
|
+
|
|
57
|
+
context.rect(left, top, width, height)
|
|
58
|
+
|
|
59
|
+
this.drawFill(context)
|
|
60
|
+
this.drawStroke(context)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
postrender(context: CanvasRenderingContext2D) {
|
|
64
|
+
super.postrender(context)
|
|
65
|
+
|
|
66
|
+
// restore style
|
|
67
|
+
this.model.fillStyle = this._fillStyle
|
|
68
|
+
this.model.fontColor = this._fontColor
|
|
69
|
+
this.model.strokeStyle = this._strokeStyle
|
|
70
|
+
this.model.lineWidth = this._lineWidth
|
|
71
|
+
|
|
72
|
+
delete this._fillStyle
|
|
73
|
+
delete this._fontColor
|
|
74
|
+
delete this._strokeStyle
|
|
75
|
+
delete this._lineWidth
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
onclick(e: MouseEvent) {
|
|
79
|
+
(this.parent as Tab).activeIndex = this.index
|
|
80
|
+
this.parent.invalidate()
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
onchange(after: State) {
|
|
84
|
+
if (after.hasOwnProperty('fillStyle')) this._fillStyle = after.fillStyle
|
|
85
|
+
|
|
86
|
+
if (after.hasOwnProperty('fontColor')) this._fontColor = after.fontColor
|
|
87
|
+
|
|
88
|
+
if (after.hasOwnProperty('strokeStyle')) this._fontColor = after.fontColor
|
|
89
|
+
|
|
90
|
+
if (after.hasOwnProperty('lineWidth')) this._fontColor = after.fontColor
|
|
91
|
+
|
|
92
|
+
if (after.hasOwnProperty('text')) {
|
|
93
|
+
(this.parent as Tab).reference.getAt(this.index).set('text', after.text)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
this.invalidate()
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
Component.register('tab-button', TabButton)
|