@operato/scene-legend 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- package/@types/global/index.d.ts +1 -0
- package/CHANGELOG.md +12 -0
- package/LICENSE +21 -0
- package/README.md +31 -0
- package/assets/legend.png +0 -0
- package/dist/editors/editor-legend-status.d.ts +4 -0
- package/dist/editors/editor-legend-status.js +313 -0
- package/dist/editors/editor-legend-status.js.map +1 -0
- package/dist/editors/index.d.ts +5 -0
- package/dist/editors/index.js +11 -0
- package/dist/editors/index.js.map +1 -0
- package/dist/editors/property-editor-legend-status.d.ts +7 -0
- package/dist/editors/property-editor-legend-status.js +13 -0
- package/dist/editors/property-editor-legend-status.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/legend-item.d.ts +15 -0
- package/dist/legend-item.js +42 -0
- package/dist/legend-item.js.map +1 -0
- package/dist/legend.d.ts +40 -0
- package/dist/legend.js +177 -0
- package/dist/legend.js.map +1 -0
- package/dist/templates/index.d.ts +18 -0
- package/dist/templates/index.js +3 -0
- package/dist/templates/index.js.map +1 -0
- package/dist/templates/legend.d.ts +18 -0
- package/dist/templates/legend.js +19 -0
- package/dist/templates/legend.js.map +1 -0
- package/helps/scene/component/legend.ko.md +18 -0
- package/helps/scene/component/legend.md +18 -0
- package/helps/scene/component/legend.zh.md +20 -0
- package/helps/scene/images/legend-01.png +0 -0
- package/helps/scene/images/legend-02.png +0 -0
- package/package.json +63 -0
- package/src/editors/editor-legend-status.ts +339 -0
- package/src/editors/index.ts +11 -0
- package/src/editors/property-editor-legend-status.ts +17 -0
- package/src/index.ts +6 -0
- package/src/legend-item.ts +52 -0
- package/src/legend.ts +232 -0
- package/src/templates/index.ts +3 -0
- package/src/templates/legend.ts +19 -0
- package/test/basic-test.html +67 -0
- package/test/index.html +24 -0
- package/test/unit/test-legend.js +33 -0
- package/test/unit/util.js +22 -0
- package/things-scene.config.js +7 -0
- package/tsconfig.json +23 -0
- package/tsconfig.tsbuildinfo +1 -0
@@ -0,0 +1 @@
|
|
1
|
+
declare module '*.png'
|
package/CHANGELOG.md
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# Change Log
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
5
|
+
|
6
|
+
### [0.0.11](https://github.com/things-scene/operato-scene/compare/v0.0.10...v0.0.11) (2021-12-06)
|
7
|
+
|
8
|
+
|
9
|
+
### :rocket: New Features
|
10
|
+
|
11
|
+
* add wheel-sorter, legend, timer and compass ([dc90f73](https://github.com/things-scene/operato-scene/commit/dc90f73054424c0867a1c4a28d51da6e7fab8b85))
|
12
|
+
* add wheel-sorter, legend, timer and compass ([518950c](https://github.com/things-scene/operato-scene/commit/518950cb5476048504a415a1dd0a1fd2d4359a77))
|
package/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2021 Hearty, Oh
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
범례 제공자의 범례 정보를 표현해주는 컴포넌트
|
2
|
+
|
3
|
+
범례 제공자
|
4
|
+
|
5
|
+
- 범례 리스트
|
6
|
+
- 범례 : 컬러 또는 이미지, 레이블
|
7
|
+
|
8
|
+
properties :
|
9
|
+
|
10
|
+
- legend <= stockStatus
|
11
|
+
|
12
|
+
범례 컴포넌트 특성
|
13
|
+
|
14
|
+
- 행 또는 열
|
15
|
+
- 행열수
|
16
|
+
|
17
|
+
범례 컴포넌트는 범례 제공자의 범례 정보 변화이벤트에 리스너를 등록한다.
|
18
|
+
|
19
|
+
## build
|
20
|
+
|
21
|
+
`$ yarn build`
|
22
|
+
|
23
|
+
| type | filename | for | tested |
|
24
|
+
| ---- | ------------------------- | -------------- | ------ |
|
25
|
+
| UMD | things-scene-legend.js | modern browser | O |
|
26
|
+
| UMD | things-scene-legend-ie.js | ie 11 | O |
|
27
|
+
| ESM | things-scene-legend.mjs | modern browser | O |
|
28
|
+
|
29
|
+
## publish
|
30
|
+
|
31
|
+
`$ yarn publish`
|
Binary file
|
@@ -0,0 +1,313 @@
|
|
1
|
+
/**
|
2
|
+
* @license Copyright © HatioLab Inc. All rights reserved.
|
3
|
+
*/
|
4
|
+
import { __decorate } from "tslib";
|
5
|
+
import { LitElement, css, html } from 'lit';
|
6
|
+
import { customElement, property, state } from 'lit/decorators.js';
|
7
|
+
let EditorLegendStatus = class EditorLegendStatus extends LitElement {
|
8
|
+
constructor() {
|
9
|
+
super(...arguments);
|
10
|
+
this._ranges = [];
|
11
|
+
this._changingNow = false;
|
12
|
+
}
|
13
|
+
render() {
|
14
|
+
return html `
|
15
|
+
<legend>
|
16
|
+
<i18n-msg msgid="label.status">Status</i18n-msg>
|
17
|
+
</legend>
|
18
|
+
|
19
|
+
<label class="stock-field">
|
20
|
+
<i18n-msg msgid="label.field">Field</i18n-msg>
|
21
|
+
</label>
|
22
|
+
<input
|
23
|
+
type="text"
|
24
|
+
.value=${this._statusField || ''}
|
25
|
+
@change=${(e) => {
|
26
|
+
this._statusField = e.target.value;
|
27
|
+
}}
|
28
|
+
/>
|
29
|
+
<label class="default-color">
|
30
|
+
<i18n-msg msgid="label.default-color">Default Color</i18n-msg>
|
31
|
+
</label>
|
32
|
+
<things-editor-color
|
33
|
+
name="default-color"
|
34
|
+
.value=${this._defaultColor || ''}
|
35
|
+
placeholder="default color"
|
36
|
+
@change=${(e) => {
|
37
|
+
this._defaultColor = e.target.value;
|
38
|
+
}}
|
39
|
+
></things-editor-color>
|
40
|
+
|
41
|
+
<table>
|
42
|
+
<tr>
|
43
|
+
<th>
|
44
|
+
Min ≤ <br />Field<br />
|
45
|
+
< Max
|
46
|
+
</th>
|
47
|
+
<th>color</th>
|
48
|
+
<th>disp. text</th>
|
49
|
+
<th></th>
|
50
|
+
</tr>
|
51
|
+
${this._ranges.map(item => html `
|
52
|
+
<tr data-record>
|
53
|
+
<td>
|
54
|
+
<input type="text" data-min placeholder="min" .value="${item.min}" />
|
55
|
+
<span>~</span>
|
56
|
+
<input type="text" data-max placeholder="max" .value="${item.max}" />
|
57
|
+
</td>
|
58
|
+
<td>
|
59
|
+
<things-editor-color data-color .value="${item.color}" placeholder="color"></things-editor-color>
|
60
|
+
</td>
|
61
|
+
<td>
|
62
|
+
<input type="text" data-description .value="${item.description || ''}" placeholder="display text" />
|
63
|
+
</td>
|
64
|
+
<td>
|
65
|
+
<button class="record-action" @tap=${(e) => this._delete(e)} tabindex="-1">-</button>
|
66
|
+
</td>
|
67
|
+
</tr>
|
68
|
+
`)}
|
69
|
+
|
70
|
+
<tr data-record-new class="stock-new">
|
71
|
+
<td>
|
72
|
+
<input type="text" data-min placeholder="min" value="" />
|
73
|
+
<span>~</span>
|
74
|
+
<input type="text" data-max placeholder="max" value="" />
|
75
|
+
</td>
|
76
|
+
<td>
|
77
|
+
<things-editor-color data-color value="" placeholder="color"></things-editor-color>
|
78
|
+
</td>
|
79
|
+
<td>
|
80
|
+
<input type="text" data-description value="" placeholder="display text" />
|
81
|
+
</td>
|
82
|
+
<td>
|
83
|
+
<button class="record-action" @tap=${() => this._add()} tabindex="-1">+</button>
|
84
|
+
</td>
|
85
|
+
</tr>
|
86
|
+
</table>
|
87
|
+
`;
|
88
|
+
}
|
89
|
+
connectedCallback() {
|
90
|
+
super.connectedCallback();
|
91
|
+
if (!this.boundOnChange)
|
92
|
+
this.boundOnChange = this._onChange.bind(this);
|
93
|
+
this.renderRoot.addEventListener('change', this.boundOnChange);
|
94
|
+
}
|
95
|
+
disconnectedCallback() {
|
96
|
+
super.disconnectedCallback();
|
97
|
+
this.renderRoot.removeEventListener('change', this.boundOnChange);
|
98
|
+
}
|
99
|
+
_valueChanged(value) {
|
100
|
+
var val = value || this._getDefaultValue();
|
101
|
+
this._statusField = val.field;
|
102
|
+
this._defaultColor = val.defaultColor;
|
103
|
+
this._ranges = [...val.ranges];
|
104
|
+
this.requestUpdate();
|
105
|
+
}
|
106
|
+
_onChange(e) {
|
107
|
+
e.stopPropagation();
|
108
|
+
this._changingNow = true;
|
109
|
+
var input = e.target;
|
110
|
+
var value = input.value;
|
111
|
+
var tr = input.closest('tr');
|
112
|
+
if (tr) {
|
113
|
+
if (tr.hasAttribute('data-record'))
|
114
|
+
this._build(true);
|
115
|
+
else if (tr.hasAttribute('data-record-new') && input.hasAttribute('data-color'))
|
116
|
+
this._add();
|
117
|
+
}
|
118
|
+
this.value = {
|
119
|
+
field: this._statusField,
|
120
|
+
defaultColor: this._defaultColor,
|
121
|
+
ranges: this._ranges
|
122
|
+
};
|
123
|
+
this.dispatchEvent(new CustomEvent('change', {
|
124
|
+
bubbles: true,
|
125
|
+
composed: true
|
126
|
+
}));
|
127
|
+
this.requestUpdate();
|
128
|
+
}
|
129
|
+
_build(includeNewRecord) {
|
130
|
+
if (includeNewRecord)
|
131
|
+
var records = this.renderRoot.querySelectorAll('[data-record],[data-record-new]');
|
132
|
+
else
|
133
|
+
var records = this.renderRoot.querySelectorAll('[data-record]');
|
134
|
+
var newRanges = [];
|
135
|
+
for (var i = 0; i < records.length; i++) {
|
136
|
+
var record = records[i];
|
137
|
+
var min = record.querySelector('[data-min]').value;
|
138
|
+
var max = record.querySelector('[data-max]').value;
|
139
|
+
var description = record.querySelector('[data-description]').value;
|
140
|
+
var inputs = record.querySelectorAll('[data-color]:not([style*="display: none"])');
|
141
|
+
if (!inputs || inputs.length == 0)
|
142
|
+
continue;
|
143
|
+
var input = inputs[inputs.length - 1];
|
144
|
+
var color = input.value;
|
145
|
+
if (min != undefined && max != undefined && color)
|
146
|
+
newRanges.push({
|
147
|
+
min: min.trim(),
|
148
|
+
max: max.trim(),
|
149
|
+
color: color.trim(),
|
150
|
+
description: description.trim()
|
151
|
+
});
|
152
|
+
}
|
153
|
+
newRanges.sort(function (range1, range2) {
|
154
|
+
var min1 = Number(range1.min);
|
155
|
+
var min2 = Number(range2.min);
|
156
|
+
var result = min1 - min2;
|
157
|
+
if (Number.isNaN(result)) {
|
158
|
+
var strMin1 = String(min1);
|
159
|
+
var strMin2 = String(min2);
|
160
|
+
if (strMin1 > strMin2)
|
161
|
+
result = 1;
|
162
|
+
else if (strMin1 == strMin2)
|
163
|
+
result = 0;
|
164
|
+
else
|
165
|
+
result = -1;
|
166
|
+
}
|
167
|
+
return result;
|
168
|
+
});
|
169
|
+
this._ranges = newRanges;
|
170
|
+
this.requestUpdate();
|
171
|
+
}
|
172
|
+
_add() {
|
173
|
+
this._build(true);
|
174
|
+
var inputs = this.renderRoot.querySelectorAll('[data-record-new] input:not([style*="display: none"]), [data-record-new] [data-color]:not([style*="display: none"])');
|
175
|
+
for (var i = 0; i < inputs.length; i++) {
|
176
|
+
let input = inputs[i];
|
177
|
+
input.value = '';
|
178
|
+
}
|
179
|
+
}
|
180
|
+
_delete(e) {
|
181
|
+
var record = e.target.closest('tr[data-record]');
|
182
|
+
record.querySelector('[data-min]').value = '';
|
183
|
+
record.querySelector('[data-max]').value = '';
|
184
|
+
record.querySelector('[data-color]').value = '';
|
185
|
+
this._build(false);
|
186
|
+
this.value = {
|
187
|
+
field: this._statusField,
|
188
|
+
defaultColor: this._defaultColor,
|
189
|
+
ranges: this._ranges
|
190
|
+
};
|
191
|
+
this.dispatchEvent(new CustomEvent('change', {
|
192
|
+
bubbles: true,
|
193
|
+
composed: true
|
194
|
+
}));
|
195
|
+
}
|
196
|
+
_getDefaultValue() {
|
197
|
+
return {
|
198
|
+
field: '',
|
199
|
+
defaultColor: '',
|
200
|
+
ranges: []
|
201
|
+
};
|
202
|
+
}
|
203
|
+
_onRepeaterChanged() {
|
204
|
+
var inputs = this.renderRoot.querySelectorAll('[data-record] input:not([style*="display: none"])[value=""], [data-record-new] input:not([style*="display: none"])[value=""]');
|
205
|
+
inputs[0].focus();
|
206
|
+
}
|
207
|
+
updated(changes) {
|
208
|
+
if (changes.has('value'))
|
209
|
+
this._valueChanged(this.value);
|
210
|
+
}
|
211
|
+
};
|
212
|
+
EditorLegendStatus.styles = [
|
213
|
+
css `
|
214
|
+
:host {
|
215
|
+
font-size: 0.8em;
|
216
|
+
display: grid;
|
217
|
+
grid-template-columns: repeat(10, 1fr);
|
218
|
+
grid-gap: 5px;
|
219
|
+
}
|
220
|
+
|
221
|
+
:host > * {
|
222
|
+
order: 2;
|
223
|
+
grid-column: 4 / -1;
|
224
|
+
}
|
225
|
+
|
226
|
+
:host > legend {
|
227
|
+
order: 1;
|
228
|
+
grid-column: 1 / -1;
|
229
|
+
font-size: 11px;
|
230
|
+
color: rgb(228, 108, 46);
|
231
|
+
font-weight: bold;
|
232
|
+
text-transform: capitalize;
|
233
|
+
padding: 5px 0px 0px 5px;
|
234
|
+
}
|
235
|
+
|
236
|
+
:host > label {
|
237
|
+
grid-column: 1 / 4;
|
238
|
+
text-align: right;
|
239
|
+
color: var(--primary-text-color);
|
240
|
+
}
|
241
|
+
|
242
|
+
div[data-record] input {
|
243
|
+
width: 20%;
|
244
|
+
}
|
245
|
+
:host > table {
|
246
|
+
grid-column: 1 / -1;
|
247
|
+
}
|
248
|
+
table input {
|
249
|
+
width: 25px;
|
250
|
+
margin: 3px 0 2px 0;
|
251
|
+
padding: 3px;
|
252
|
+
font-size: 12px;
|
253
|
+
}
|
254
|
+
table td span {
|
255
|
+
padding: 5px 0 0 0;
|
256
|
+
}
|
257
|
+
table td things-editor-color {
|
258
|
+
width: 81px;
|
259
|
+
height: 25px;
|
260
|
+
}
|
261
|
+
table td button {
|
262
|
+
margin-left: 0;
|
263
|
+
}
|
264
|
+
table th {
|
265
|
+
background-color: rgba(0, 0, 0, 0.1);
|
266
|
+
padding: 2px 0;
|
267
|
+
text-align: center;
|
268
|
+
}
|
269
|
+
|
270
|
+
table tr > th:first-child {
|
271
|
+
width: 40px;
|
272
|
+
}
|
273
|
+
|
274
|
+
table tr > th:nth-child(2) {
|
275
|
+
width: 85px;
|
276
|
+
}
|
277
|
+
|
278
|
+
table tr > th:nth-child(4) {
|
279
|
+
width: 30px;
|
280
|
+
}
|
281
|
+
|
282
|
+
table *.things-editor-legend-status {
|
283
|
+
float: none !important;
|
284
|
+
}
|
285
|
+
table td {
|
286
|
+
text-align: center;
|
287
|
+
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
|
288
|
+
}
|
289
|
+
table tr.stock-new {
|
290
|
+
background-color: rgba(179, 145, 117, 0.3);
|
291
|
+
}
|
292
|
+
table td input[data-description] {
|
293
|
+
width: 100%;
|
294
|
+
box-sizing: border-box;
|
295
|
+
}
|
296
|
+
`
|
297
|
+
];
|
298
|
+
__decorate([
|
299
|
+
property({ type: Object })
|
300
|
+
], EditorLegendStatus.prototype, "value", void 0);
|
301
|
+
__decorate([
|
302
|
+
state()
|
303
|
+
], EditorLegendStatus.prototype, "_statusField", void 0);
|
304
|
+
__decorate([
|
305
|
+
state()
|
306
|
+
], EditorLegendStatus.prototype, "_defaultColor", void 0);
|
307
|
+
__decorate([
|
308
|
+
state()
|
309
|
+
], EditorLegendStatus.prototype, "_ranges", void 0);
|
310
|
+
EditorLegendStatus = __decorate([
|
311
|
+
customElement('editor-legend-status')
|
312
|
+
], EditorLegendStatus);
|
313
|
+
//# sourceMappingURL=editor-legend-status.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"editor-legend-status.js","sourceRoot":"","sources":["../../src/editors/editor-legend-status.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,OAAO,EAAE,UAAU,EAAkB,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC3D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAGlE,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,UAAU;IAA3C;;QA4FmB,YAAO,GAAU,EAAE,CAAA;QAG5B,iBAAY,GAAY,KAAK,CAAA;IA2OvC,CAAC;IAzOC,MAAM;QACJ,OAAO,IAAI,CAAA;;;;;;;;;;iBAUE,IAAI,CAAC,YAAY,IAAI,EAAE;kBACtB,CAAC,CAAQ,EAAE,EAAE;YACrB,IAAI,CAAC,YAAY,GAAI,CAAC,CAAC,MAA2B,CAAC,KAAK,CAAA;QAC1D,CAAC;;;;;;;iBAOQ,IAAI,CAAC,aAAa,IAAI,EAAE;;kBAEvB,CAAC,CAAQ,EAAE,EAAE;YACrB,IAAI,CAAC,aAAa,GAAI,CAAC,CAAC,MAA2B,CAAC,KAAK,CAAA;QAC3D,CAAC;;;;;;;;;;;;;UAaC,IAAI,CAAC,OAAO,CAAC,GAAG,CAChB,IAAI,CAAC,EAAE,CAAC,IAAI,CAAA;;;wEAGkD,IAAI,CAAC,GAAG;;wEAER,IAAI,CAAC,GAAG;;;0DAGtB,IAAI,CAAC,KAAK;;;8DAGN,IAAI,CAAC,WAAW,IAAI,EAAE;;;qDAG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A;QAEjC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAA;IACnB,CAAC;IAED,OAAO,CAAC,OAA6B;QACnC,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC;YAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAC1D,CAAC;CACF,CAAA;AAzUQ,yBAAM,GAAG;IACd,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAmFF;CACF,CAAA;AAE2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iDAAW;AAE7B;IAAR,KAAK,EAAE;wDAA8B;AAC7B;IAAR,KAAK,EAAE;yDAA+B;AAC9B;IAAR,KAAK,EAAE;mDAA4B;AA5FhC,kBAAkB;IADvB,aAAa,CAAC,sBAAsB,CAAC;GAChC,kBAAkB,CA0UvB","sourcesContent":["/**\n * @license Copyright © HatioLab Inc. All rights reserved.\n */\n\nimport { LitElement, PropertyValues, css, html } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\n\n@customElement('editor-legend-status')\nclass EditorLegendStatus extends LitElement {\n static styles = [\n css`\n :host {\n font-size: 0.8em;\n display: grid;\n grid-template-columns: repeat(10, 1fr);\n grid-gap: 5px;\n }\n\n :host > * {\n order: 2;\n grid-column: 4 / -1;\n }\n\n :host > legend {\n order: 1;\n grid-column: 1 / -1;\n font-size: 11px;\n color: rgb(228, 108, 46);\n font-weight: bold;\n text-transform: capitalize;\n padding: 5px 0px 0px 5px;\n }\n\n :host > label {\n grid-column: 1 / 4;\n text-align: right;\n color: var(--primary-text-color);\n }\n\n div[data-record] input {\n width: 20%;\n }\n :host > table {\n grid-column: 1 / -1;\n }\n table input {\n width: 25px;\n margin: 3px 0 2px 0;\n padding: 3px;\n font-size: 12px;\n }\n table td span {\n padding: 5px 0 0 0;\n }\n table td things-editor-color {\n width: 81px;\n height: 25px;\n }\n table td button {\n margin-left: 0;\n }\n table th {\n background-color: rgba(0, 0, 0, 0.1);\n padding: 2px 0;\n text-align: center;\n }\n\n table tr > th:first-child {\n width: 40px;\n }\n\n table tr > th:nth-child(2) {\n width: 85px;\n }\n\n table tr > th:nth-child(4) {\n width: 30px;\n }\n\n table *.things-editor-legend-status {\n float: none !important;\n }\n table td {\n text-align: center;\n border-bottom: 1px solid rgba(0, 0, 0, 0.1);\n }\n table tr.stock-new {\n background-color: rgba(179, 145, 117, 0.3);\n }\n table td input[data-description] {\n width: 100%;\n box-sizing: border-box;\n }\n `\n ]\n\n @property({ type: Object }) value: any\n\n @state() private _statusField?: string\n @state() private _defaultColor?: string\n @state() private _ranges: any[] = []\n\n private boundOnChange?: any\n private _changingNow: boolean = false\n\n render() {\n return html`\n <legend>\n <i18n-msg msgid=\"label.status\">Status</i18n-msg>\n </legend>\n\n <label class=\"stock-field\">\n <i18n-msg msgid=\"label.field\">Field</i18n-msg>\n </label>\n <input\n type=\"text\"\n .value=${this._statusField || ''}\n @change=${(e: Event) => {\n this._statusField = (e.target as HTMLInputElement).value\n }}\n />\n <label class=\"default-color\">\n <i18n-msg msgid=\"label.default-color\">Default Color</i18n-msg>\n </label>\n <things-editor-color\n name=\"default-color\"\n .value=${this._defaultColor || ''}\n placeholder=\"default color\"\n @change=${(e: Event) => {\n this._defaultColor = (e.target as HTMLInputElement).value\n }}\n ></things-editor-color>\n\n <table>\n <tr>\n <th>\n Min ≤ <br />Field<br />\n < Max\n </th>\n <th>color</th>\n <th>disp. text</th>\n <th></th>\n </tr>\n ${this._ranges.map(\n item => html`\n <tr data-record>\n <td>\n <input type=\"text\" data-min placeholder=\"min\" .value=\"${item.min}\" />\n <span>~</span>\n <input type=\"text\" data-max placeholder=\"max\" .value=\"${item.max}\" />\n </td>\n <td>\n <things-editor-color data-color .value=\"${item.color}\" placeholder=\"color\"></things-editor-color>\n </td>\n <td>\n <input type=\"text\" data-description .value=\"${item.description || ''}\" placeholder=\"display text\" />\n </td>\n <td>\n <button class=\"record-action\" @tap=${(e: TouchEvent) => this._delete(e)} tabindex=\"-1\">-</button>\n </td>\n </tr>\n `\n )}\n\n <tr data-record-new class=\"stock-new\">\n <td>\n <input type=\"text\" data-min placeholder=\"min\" value=\"\" />\n <span>~</span>\n <input type=\"text\" data-max placeholder=\"max\" value=\"\" />\n </td>\n <td>\n <things-editor-color data-color value=\"\" placeholder=\"color\"></things-editor-color>\n </td>\n <td>\n <input type=\"text\" data-description value=\"\" placeholder=\"display text\" />\n </td>\n <td>\n <button class=\"record-action\" @tap=${() => this._add()} tabindex=\"-1\">+</button>\n </td>\n </tr>\n </table>\n `\n }\n\n connectedCallback() {\n super.connectedCallback()\n if (!this.boundOnChange) this.boundOnChange = this._onChange.bind(this)\n\n this.renderRoot.addEventListener('change', this.boundOnChange)\n }\n\n disconnectedCallback() {\n super.disconnectedCallback()\n this.renderRoot.removeEventListener('change', this.boundOnChange)\n }\n\n _valueChanged(value: any) {\n var val = value || this._getDefaultValue()\n this._statusField = val.field\n this._defaultColor = val.defaultColor\n this._ranges = [...val.ranges]\n\n this.requestUpdate()\n }\n\n _onChange(e: Event) {\n e.stopPropagation()\n this._changingNow = true\n\n var input = e.target as HTMLInputElement\n var value = input.value\n\n var tr = input.closest('tr')\n\n if (tr) {\n if (tr.hasAttribute('data-record')) this._build(true)\n else if (tr.hasAttribute('data-record-new') && input.hasAttribute('data-color')) this._add()\n }\n\n this.value = {\n field: this._statusField,\n defaultColor: this._defaultColor,\n ranges: this._ranges\n }\n\n this.dispatchEvent(\n new CustomEvent('change', {\n bubbles: true,\n composed: true\n })\n )\n this.requestUpdate()\n }\n\n _build(includeNewRecord: boolean) {\n if (includeNewRecord) var records = this.renderRoot.querySelectorAll('[data-record],[data-record-new]')\n else var records = this.renderRoot.querySelectorAll('[data-record]')\n\n var newRanges = []\n\n for (var i = 0; i < records.length; i++) {\n var record = records[i]\n\n var min = (record.querySelector('[data-min]') as HTMLInputElement).value\n var max = (record.querySelector('[data-max]') as HTMLInputElement).value\n var description = (record.querySelector('[data-description]') as HTMLInputElement).value\n var inputs = record.querySelectorAll('[data-color]:not([style*=\"display: none\"])') as NodeListOf<HTMLInputElement>\n if (!inputs || inputs.length == 0) continue\n\n var input = inputs[inputs.length - 1]\n var color = input.value\n\n if (min != undefined && max != undefined && color)\n newRanges.push({\n min: min.trim(),\n max: max.trim(),\n color: color.trim(),\n description: description.trim()\n })\n }\n\n newRanges.sort(function (range1, range2) {\n var min1 = Number(range1.min)\n var min2 = Number(range2.min)\n\n var result = min1 - min2\n\n if (Number.isNaN(result)) {\n var strMin1 = String(min1)\n var strMin2 = String(min2)\n\n if (strMin1 > strMin2) result = 1\n else if (strMin1 == strMin2) result = 0\n else result = -1\n }\n\n return result\n })\n\n this._ranges = newRanges\n this.requestUpdate()\n }\n\n _add() {\n this._build(true)\n\n var inputs = this.renderRoot.querySelectorAll(\n '[data-record-new] input:not([style*=\"display: none\"]), [data-record-new] [data-color]:not([style*=\"display: none\"])'\n ) as NodeListOf<HTMLInputElement>\n\n for (var i = 0; i < inputs.length; i++) {\n let input = inputs[i]\n input.value = ''\n }\n }\n\n _delete(e: Event) {\n var record = (e.target as Element).closest('tr[data-record]')\n\n ;(record!.querySelector('[data-min]') as HTMLInputElement).value = ''\n ;(record!.querySelector('[data-max]') as HTMLInputElement).value = ''\n ;(record!.querySelector('[data-color]') as HTMLInputElement).value = ''\n\n this._build(false)\n\n this.value = {\n field: this._statusField,\n defaultColor: this._defaultColor,\n ranges: this._ranges\n }\n\n this.dispatchEvent(\n new CustomEvent('change', {\n bubbles: true,\n composed: true\n })\n )\n }\n\n _getDefaultValue() {\n return {\n field: '',\n defaultColor: '',\n ranges: []\n }\n }\n\n _onRepeaterChanged() {\n var inputs = this.renderRoot.querySelectorAll(\n '[data-record] input:not([style*=\"display: none\"])[value=\"\"], [data-record-new] input:not([style*=\"display: none\"])[value=\"\"]'\n ) as NodeListOf<HTMLInputElement>\n\n inputs[0].focus()\n }\n\n updated(changes: PropertyValues<this>) {\n if (changes.has('value')) this._valueChanged(this.value)\n }\n}\n"]}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright © HatioLab Inc. All rights reserved.
|
3
|
+
*/
|
4
|
+
import { PropertyEditorLegendStatus } from './property-editor-legend-status';
|
5
|
+
export default [
|
6
|
+
{
|
7
|
+
type: 'legend-status',
|
8
|
+
element: PropertyEditorLegendStatus.is
|
9
|
+
}
|
10
|
+
];
|
11
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/editors/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAA;AAE5E,eAAe;IACb;QACE,IAAI,EAAE,eAAe;QACrB,OAAO,EAAE,0BAA0B,CAAC,EAAE;KACvC;CACF,CAAA","sourcesContent":["/*\n * Copyright © HatioLab Inc. All rights reserved.\n */\nimport { PropertyEditorLegendStatus } from './property-editor-legend-status'\n\nexport default [\n {\n type: 'legend-status',\n element: PropertyEditorLegendStatus.is\n }\n]\n"]}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import './editor-legend-status';
|
2
|
+
import { OxPropertyEditor } from '@operato/property-editor';
|
3
|
+
import { Properties } from '@hatiolab/things-scene';
|
4
|
+
export declare class PropertyEditorLegendStatus extends OxPropertyEditor {
|
5
|
+
static get is(): string;
|
6
|
+
editorTemplate(props: Properties): import("lit-html").TemplateResult<1>;
|
7
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import './editor-legend-status';
|
2
|
+
import { OxPropertyEditor } from '@operato/property-editor';
|
3
|
+
import { html } from 'lit-element';
|
4
|
+
export class PropertyEditorLegendStatus extends OxPropertyEditor {
|
5
|
+
static get is() {
|
6
|
+
return 'property-editor-legend-status';
|
7
|
+
}
|
8
|
+
editorTemplate(props) {
|
9
|
+
return html ` <editor-legend-status .value=${props.value} fullwidth></editor-legend-status> `;
|
10
|
+
}
|
11
|
+
}
|
12
|
+
customElements.define(PropertyEditorLegendStatus.is, PropertyEditorLegendStatus);
|
13
|
+
//# sourceMappingURL=property-editor-legend-status.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"property-editor-legend-status.js","sourceRoot":"","sources":["../../src/editors/property-editor-legend-status.ts"],"names":[],"mappings":"AAAA,OAAO,wBAAwB,CAAA;AAE/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAE3D,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAElC,MAAM,OAAO,0BAA2B,SAAQ,gBAAgB;IAC9D,MAAM,KAAK,EAAE;QACX,OAAO,+BAA+B,CAAA;IACxC,CAAC;IAED,cAAc,CAAC,KAAiB;QAC9B,OAAO,IAAI,CAAA,iCAAiC,KAAK,CAAC,KAAK,qCAAqC,CAAA;IAC9F,CAAC;CACF;AAED,cAAc,CAAC,MAAM,CAAC,0BAA0B,CAAC,EAAE,EAAE,0BAA0B,CAAC,CAAA","sourcesContent":["import './editor-legend-status'\n\nimport { OxPropertyEditor } from '@operato/property-editor'\nimport { Properties } from '@hatiolab/things-scene'\nimport { html } from 'lit-element'\n\nexport class PropertyEditorLegendStatus extends OxPropertyEditor {\n static get is() {\n return 'property-editor-legend-status'\n }\n\n editorTemplate(props: Properties) {\n return html` <editor-legend-status .value=${props.value} fullwidth></editor-legend-status> `\n }\n}\n\ncustomElements.define(PropertyEditorLegendStatus.is, PropertyEditorLegendStatus)\n"]}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAA;AAC5C,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,eAAe,CAAA","sourcesContent":["/*\n * Copyright © HatioLab Inc. All rights reserved.\n */\n\nexport { default as Legend } from './legend'\nexport { default as LegendItem } from './legend-item'\n"]}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import { Properties, Shape } from '@hatiolab/things-scene';
|
2
|
+
declare const LegendItem_base: typeof Shape;
|
3
|
+
export default class LegendItem extends LegendItem_base {
|
4
|
+
render(context: CanvasRenderingContext2D): void;
|
5
|
+
onchange(after: Properties): void;
|
6
|
+
get stuck(): boolean;
|
7
|
+
get capturable(): boolean;
|
8
|
+
get nature(): {
|
9
|
+
mutable: boolean;
|
10
|
+
resizable: boolean;
|
11
|
+
rotatable: boolean;
|
12
|
+
properties: never[];
|
13
|
+
};
|
14
|
+
}
|
15
|
+
export {};
|
@@ -0,0 +1,42 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright © HatioLab Inc. All rights reserved.
|
3
|
+
*/
|
4
|
+
import { Component, RectPath, Shape } from '@hatiolab/things-scene';
|
5
|
+
const NATURE = {
|
6
|
+
mutable: false,
|
7
|
+
resizable: false,
|
8
|
+
rotatable: false,
|
9
|
+
properties: []
|
10
|
+
};
|
11
|
+
export default class LegendItem extends RectPath(Shape) {
|
12
|
+
render(context) {
|
13
|
+
var { left, top, height, color } = this.model;
|
14
|
+
context.beginPath();
|
15
|
+
var c = height / 2;
|
16
|
+
var r = c / 2;
|
17
|
+
context.save();
|
18
|
+
context.fillStyle = color;
|
19
|
+
context.ellipse(left + c, top + c, r, r, 0, 0, Math.PI * 2, true);
|
20
|
+
context.shadowColor = 'rgba(0,0,0,0.15)';
|
21
|
+
context.shadowBlur = 2;
|
22
|
+
context.shadowOffsetX = 1;
|
23
|
+
context.shadowOffsetY = 2;
|
24
|
+
context.fill();
|
25
|
+
context.restore();
|
26
|
+
}
|
27
|
+
onchange(after) {
|
28
|
+
if (after.hasOwnProperty('height'))
|
29
|
+
this.set('paddingLeft', after.height);
|
30
|
+
}
|
31
|
+
get stuck() {
|
32
|
+
return true;
|
33
|
+
}
|
34
|
+
get capturable() {
|
35
|
+
return false;
|
36
|
+
}
|
37
|
+
get nature() {
|
38
|
+
return NATURE;
|
39
|
+
}
|
40
|
+
}
|
41
|
+
Component.register('legend-item', LegendItem);
|
42
|
+
//# sourceMappingURL=legend-item.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"legend-item.js","sourceRoot":"","sources":["../src/legend-item.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,SAAS,EAAqB,QAAQ,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAEtF,MAAM,MAAM,GAAG;IACb,OAAO,EAAE,KAAK;IACd,SAAS,EAAE,KAAK;IAChB,SAAS,EAAE,KAAK;IAChB,UAAU,EAAE,EAAE;CACf,CAAA;AAED,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,QAAQ,CAAC,KAAK,CAAC;IACrD,MAAM,CAAC,OAAiC;QACtC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,CAAA;QAE7C,OAAO,CAAC,SAAS,EAAE,CAAA;QAEnB,IAAI,CAAC,GAAG,MAAM,GAAG,CAAC,CAAA;QAClB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QAEb,OAAO,CAAC,IAAI,EAAE,CAAA;QAEd,OAAO,CAAC,SAAS,GAAG,KAAK,CAAA;QACzB,OAAO,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,EAAE,GAAG,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,GAAG,CAAC,EAAE,IAAI,CAAC,CAAA;QACjE,OAAO,CAAC,WAAW,GAAG,kBAAkB,CAAA;QACxC,OAAO,CAAC,UAAU,GAAG,CAAC,CAAA;QACtB,OAAO,CAAC,aAAa,GAAG,CAAC,CAAA;QACzB,OAAO,CAAC,aAAa,GAAG,CAAC,CAAA;QACzB,OAAO,CAAC,IAAI,EAAE,CAAA;QAEd,OAAO,CAAC,OAAO,EAAE,CAAA;IACnB,CAAC;IAED,QAAQ,CAAC,KAAiB;QACxB,IAAI,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC;YAAE,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IAC3E,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAA;IACb,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,KAAK,CAAA;IACd,CAAC;IAED,IAAI,MAAM;QACR,OAAO,MAAM,CAAA;IACf,CAAC;CACF;AAED,SAAS,CAAC,QAAQ,CAAC,aAAa,EAAE,UAAU,CAAC,CAAA","sourcesContent":["/*\n * Copyright © HatioLab Inc. All rights reserved.\n */\nimport { Component, Model, Properties, RectPath, Shape } from '@hatiolab/things-scene'\n\nconst NATURE = {\n mutable: false,\n resizable: false,\n rotatable: false,\n properties: []\n}\n\nexport default class LegendItem extends RectPath(Shape) {\n render(context: CanvasRenderingContext2D) {\n var { left, top, height, color } = this.model\n\n context.beginPath()\n\n var c = height / 2\n var r = c / 2\n\n context.save()\n\n context.fillStyle = color\n context.ellipse(left + c, top + c, r, r, 0, 0, Math.PI * 2, true)\n context.shadowColor = 'rgba(0,0,0,0.15)'\n context.shadowBlur = 2\n context.shadowOffsetX = 1\n context.shadowOffsetY = 2\n context.fill()\n\n context.restore()\n }\n\n onchange(after: Properties) {\n if (after.hasOwnProperty('height')) this.set('paddingLeft', after.height)\n }\n\n get stuck() {\n return true\n }\n\n get capturable() {\n return false\n }\n\n get nature() {\n return NATURE\n }\n}\n\nComponent.register('legend-item', LegendItem)\n"]}
|
package/dist/legend.d.ts
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
import { Component, Container, Properties } from '@hatiolab/things-scene';
|
2
|
+
export default class Legend extends Container {
|
3
|
+
ready(): void;
|
4
|
+
get showMoveHandle(): boolean;
|
5
|
+
render(context: CanvasRenderingContext2D): void;
|
6
|
+
get controls(): {
|
7
|
+
x: any;
|
8
|
+
y: any;
|
9
|
+
handler: {
|
10
|
+
ondragmove: (point: import("@hatiolab/things-scene").DIMENSION, index: number, component: Component) => void;
|
11
|
+
};
|
12
|
+
}[];
|
13
|
+
get layout(): import("@hatiolab/things-scene").LAYOUT;
|
14
|
+
get nature(): {
|
15
|
+
mutable: boolean;
|
16
|
+
resizable: boolean;
|
17
|
+
rotatable: boolean;
|
18
|
+
properties: ({
|
19
|
+
type: string;
|
20
|
+
label: string;
|
21
|
+
name: string;
|
22
|
+
property?: undefined;
|
23
|
+
} | {
|
24
|
+
type: string;
|
25
|
+
label: string;
|
26
|
+
name: string;
|
27
|
+
property: {
|
28
|
+
options: {
|
29
|
+
display: string;
|
30
|
+
value: string;
|
31
|
+
}[];
|
32
|
+
};
|
33
|
+
})[];
|
34
|
+
help: string;
|
35
|
+
};
|
36
|
+
rebuildLegendItems(): void;
|
37
|
+
get hasTextProperty(): boolean;
|
38
|
+
get textHidden(): boolean;
|
39
|
+
onchange(after: Properties, before: Properties): void;
|
40
|
+
}
|