@operato/scene-legend 8.0.0-beta.1 → 9.0.0-beta.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. package/package.json +4 -4
  2. package/CHANGELOG.md +0 -896
  3. package/attachments/3c2f6007-c06b-47ca-9508-9bcda9428fd0.svg +0 -425
  4. package/attachments/dcf0e8fe-6c3e-4b36-b3e9-a8e70b4ed590.svg +0 -425
  5. package/logs/.08636eb59927f12972f6774f5947c8507b3564c2-audit.json +0 -15
  6. package/logs/.5e5d741d8b7784a2fbad65eedc0fd46946aaf6f2-audit.json +0 -15
  7. package/logs/application-2023-07-13-20.log +0 -10
  8. package/logs/connections-2023-07-13-20.log +0 -80
  9. package/logs/system/.144ddb221a51f7e2afac3fe1fc3dcf306a8de9ef-audit.json +0 -15
  10. package/logs/system/.437ed478d36eef33cb9dfb565b13329b4464783e-audit.json +0 -20
  11. package/logs/system/.a16ac19e6e222b854c699e1f94ae757f5c8db307-audit.json +0 -15
  12. package/logs/system/scenario-/353/260/234/354/240/204/353/237/211 /354/230/210/354/270/241 /353/215/260/354/235/264/355/204/260-2023-05-09-11.log" +0 -16914
  13. package/logs/system/scenario-/353/260/234/354/240/204/353/237/211 /354/230/210/354/270/241 /353/215/260/354/235/264/355/204/260-2023-05-09-12.log" +0 -1382
  14. package/logs/system/scenario-/354/227/220/353/204/210/354/247/200 /353/240/210/354/235/264/354/226/264 /354/203/211/354/203/201-2023-07-13-20.log" +0 -510
  15. package/logs/system/scenario-/354/235/274/354/202/254/353/237/211 /354/230/210/354/270/241 /354/247/200/353/217/204-2023-05-09-12.log" +0 -30
  16. package/src/editors/editor-legend-status.ts +0 -337
  17. package/src/editors/index.ts +0 -17
  18. package/src/editors/property-editor-legend-status.ts +0 -13
  19. package/src/editors/property-editor-svg-info.ts +0 -77
  20. package/src/index.ts +0 -8
  21. package/src/legend-item.ts +0 -52
  22. package/src/legend.ts +0 -232
  23. package/src/svg.ts +0 -201
  24. package/src/templates/index.ts +0 -4
  25. package/src/templates/legend.ts +0 -19
  26. package/src/templates/svg.ts +0 -19
  27. package/test/basic-test.html +0 -67
  28. package/test/index.html +0 -24
  29. package/test/unit/test-legend.js +0 -33
  30. package/test/unit/util.js +0 -22
  31. package/tsconfig.json +0 -23
  32. package/tsconfig.tsbuildinfo +0 -1
@@ -1,337 +0,0 @@
1
- import '@operato/i18n/ox-i18n.js'
2
-
3
- import { LitElement, PropertyValues, css, html } from 'lit'
4
- import { customElement, property, state } from 'lit/decorators.js'
5
-
6
- @customElement('editor-legend-status')
7
- class EditorLegendStatus extends LitElement {
8
- static styles = [
9
- css`
10
- :host {
11
- font-size: 0.8em;
12
- display: grid;
13
- grid-template-columns: repeat(10, 1fr);
14
- grid-gap: 5px;
15
- }
16
-
17
- :host > * {
18
- order: 2;
19
- grid-column: 4 / -1;
20
- }
21
-
22
- :host > legend {
23
- order: 1;
24
- grid-column: 1 / -1;
25
- font-size: 11px;
26
- color: rgb(228, 108, 46);
27
- font-weight: bold;
28
- text-transform: capitalize;
29
- padding: 5px 0px 0px 5px;
30
- }
31
-
32
- :host > label {
33
- grid-column: 1 / 4;
34
- text-align: right;
35
- color: var(--primary-text-color);
36
- }
37
-
38
- div[data-record] input {
39
- width: 20%;
40
- }
41
- :host > table {
42
- grid-column: 1 / -1;
43
- }
44
- table input {
45
- width: 25px;
46
- margin: 3px 0 2px 0;
47
- padding: 3px;
48
- font-size: 12px;
49
- }
50
- table td span {
51
- padding: 5px 0 0 0;
52
- }
53
- table td ox-input-color {
54
- width: 81px;
55
- height: 25px;
56
- }
57
- table td button {
58
- margin-left: 0;
59
- }
60
- table th {
61
- background-color: rgba(0, 0, 0, 0.1);
62
- padding: 2px 0;
63
- text-align: center;
64
- }
65
-
66
- table tr > th:first-child {
67
- width: 40px;
68
- }
69
-
70
- table tr > th:nth-child(2) {
71
- width: 85px;
72
- }
73
-
74
- table tr > th:nth-child(4) {
75
- width: 30px;
76
- }
77
-
78
- table *.editor-legend-status {
79
- float: none !important;
80
- }
81
- table td {
82
- text-align: center;
83
- border-bottom: 1px solid rgba(0, 0, 0, 0.1);
84
- }
85
- table tr.stock-new {
86
- background-color: rgba(179, 145, 117, 0.3);
87
- }
88
- table td input[data-description] {
89
- width: 100%;
90
- box-sizing: border-box;
91
- }
92
- `
93
- ]
94
-
95
- @property({ type: Object }) value: any
96
-
97
- @state() private _statusField?: string
98
- @state() private _defaultColor?: string
99
- @state() private _ranges: any[] = []
100
-
101
- private boundOnChange?: any
102
- private _changingNow: boolean = false
103
-
104
- render() {
105
- return html`
106
- <legend>
107
- <ox-i18n msgid="label.status">Status</ox-i18n>
108
- </legend>
109
-
110
- <label class="stock-field">
111
- <ox-i18n msgid="label.field">Field</ox-i18n>
112
- </label>
113
- <input
114
- type="text"
115
- .value=${this._statusField || ''}
116
- @change=${(e: Event) => {
117
- this._statusField = (e.target as HTMLInputElement).value
118
- }}
119
- />
120
- <label class="default-color">
121
- <ox-i18n msgid="label.default-color">Default Color</ox-i18n>
122
- </label>
123
- <ox-input-color
124
- name="default-color"
125
- .value=${this._defaultColor || ''}
126
- placeholder="default color"
127
- @change=${(e: Event) => {
128
- this._defaultColor = (e.target as HTMLInputElement).value
129
- }}
130
- ></ox-input-color>
131
-
132
- <table>
133
- <tr>
134
- <th>
135
- Min &le; <br />Field<br />
136
- &lt; Max
137
- </th>
138
- <th>color</th>
139
- <th>disp. text</th>
140
- <th></th>
141
- </tr>
142
- ${this._ranges.map(
143
- item => html`
144
- <tr data-record>
145
- <td>
146
- <input type="text" data-min placeholder="min" .value="${item.min}" />
147
- <span>~</span>
148
- <input type="text" data-max placeholder="max" .value="${item.max}" />
149
- </td>
150
- <td>
151
- <ox-input-color data-color .value="${item.color}" placeholder="color"></ox-input-color>
152
- </td>
153
- <td>
154
- <input type="text" data-description .value="${item.description || ''}" placeholder="display text" />
155
- </td>
156
- <td>
157
- <button class="record-action" @tap=${(e: TouchEvent) => this._delete(e)} tabindex="-1">-</button>
158
- </td>
159
- </tr>
160
- `
161
- )}
162
-
163
- <tr data-record-new class="stock-new">
164
- <td>
165
- <input type="text" data-min placeholder="min" value="" />
166
- <span>~</span>
167
- <input type="text" data-max placeholder="max" value="" />
168
- </td>
169
- <td>
170
- <ox-input-color data-color value="" placeholder="color"></ox-input-color>
171
- </td>
172
- <td>
173
- <input type="text" data-description value="" placeholder="display text" />
174
- </td>
175
- <td>
176
- <button class="record-action" @tap=${() => this._add()} tabindex="-1">+</button>
177
- </td>
178
- </tr>
179
- </table>
180
- `
181
- }
182
-
183
- connectedCallback() {
184
- super.connectedCallback()
185
- if (!this.boundOnChange) this.boundOnChange = this._onChange.bind(this)
186
-
187
- this.renderRoot.addEventListener('change', this.boundOnChange)
188
- }
189
-
190
- disconnectedCallback() {
191
- super.disconnectedCallback()
192
- this.renderRoot.removeEventListener('change', this.boundOnChange)
193
- }
194
-
195
- _valueChanged(value: any) {
196
- var val = value || this._getDefaultValue()
197
- this._statusField = val.field
198
- this._defaultColor = val.defaultColor
199
- this._ranges = [...val.ranges]
200
-
201
- this.requestUpdate()
202
- }
203
-
204
- _onChange(e: Event) {
205
- e.stopPropagation()
206
- this._changingNow = true
207
-
208
- var input = e.target as HTMLInputElement
209
- var value = input.value
210
-
211
- var tr = input.closest('tr')
212
-
213
- if (tr) {
214
- if (tr.hasAttribute('data-record')) this._build(true)
215
- else if (tr.hasAttribute('data-record-new') && input.hasAttribute('data-color')) this._add()
216
- }
217
-
218
- this.value = {
219
- field: this._statusField,
220
- defaultColor: this._defaultColor,
221
- ranges: this._ranges
222
- }
223
-
224
- this.dispatchEvent(
225
- new CustomEvent('change', {
226
- bubbles: true,
227
- composed: true
228
- })
229
- )
230
- this.requestUpdate()
231
- }
232
-
233
- _build(includeNewRecord: boolean) {
234
- if (includeNewRecord) var records = this.renderRoot.querySelectorAll('[data-record],[data-record-new]')
235
- else var records = this.renderRoot.querySelectorAll('[data-record]')
236
-
237
- var newRanges = []
238
-
239
- for (var i = 0; i < records.length; i++) {
240
- var record = records[i]
241
-
242
- var min = (record.querySelector('[data-min]') as HTMLInputElement).value
243
- var max = (record.querySelector('[data-max]') as HTMLInputElement).value
244
- var description = (record.querySelector('[data-description]') as HTMLInputElement).value
245
- var inputs = record.querySelectorAll('[data-color]:not([style*="display: none"])') as NodeListOf<HTMLInputElement>
246
- if (!inputs || inputs.length == 0) continue
247
-
248
- var input = inputs[inputs.length - 1]
249
- var color = input.value
250
-
251
- if (min != undefined && max != undefined && color)
252
- newRanges.push({
253
- min: min.trim(),
254
- max: max.trim(),
255
- color: color.trim(),
256
- description: description.trim()
257
- })
258
- }
259
-
260
- newRanges.sort(function (range1, range2) {
261
- var min1 = Number(range1.min)
262
- var min2 = Number(range2.min)
263
-
264
- var result = min1 - min2
265
-
266
- if (Number.isNaN(result)) {
267
- var strMin1 = String(min1)
268
- var strMin2 = String(min2)
269
-
270
- if (strMin1 > strMin2) result = 1
271
- else if (strMin1 == strMin2) result = 0
272
- else result = -1
273
- }
274
-
275
- return result
276
- })
277
-
278
- this._ranges = newRanges
279
- this.requestUpdate()
280
- }
281
-
282
- _add() {
283
- this._build(true)
284
-
285
- var inputs = this.renderRoot.querySelectorAll(
286
- '[data-record-new] input:not([style*="display: none"]), [data-record-new] [data-color]:not([style*="display: none"])'
287
- ) as NodeListOf<HTMLInputElement>
288
-
289
- for (var i = 0; i < inputs.length; i++) {
290
- let input = inputs[i]
291
- input.value = ''
292
- }
293
- }
294
-
295
- _delete(e: Event) {
296
- var record = (e.target as Element).closest('tr[data-record]')
297
-
298
- ;(record!.querySelector('[data-min]') as HTMLInputElement).value = ''
299
- ;(record!.querySelector('[data-max]') as HTMLInputElement).value = ''
300
- ;(record!.querySelector('[data-color]') as HTMLInputElement).value = ''
301
-
302
- this._build(false)
303
-
304
- this.value = {
305
- field: this._statusField,
306
- defaultColor: this._defaultColor,
307
- ranges: this._ranges
308
- }
309
-
310
- this.dispatchEvent(
311
- new CustomEvent('change', {
312
- bubbles: true,
313
- composed: true
314
- })
315
- )
316
- }
317
-
318
- _getDefaultValue() {
319
- return {
320
- field: '',
321
- defaultColor: '',
322
- ranges: []
323
- }
324
- }
325
-
326
- _onRepeaterChanged() {
327
- var inputs = this.renderRoot.querySelectorAll(
328
- '[data-record] input:not([style*="display: none"])[value=""], [data-record-new] input:not([style*="display: none"])[value=""]'
329
- ) as NodeListOf<HTMLInputElement>
330
-
331
- inputs[0].focus()
332
- }
333
-
334
- updated(changes: PropertyValues<this>) {
335
- if (changes.has('value')) this._valueChanged(this.value)
336
- }
337
- }
@@ -1,17 +0,0 @@
1
- /*
2
- * Copyright © HatioLab Inc. All rights reserved.
3
- */
4
-
5
- import './property-editor-legend-status'
6
- import './property-editor-svg-info'
7
-
8
- export default [
9
- {
10
- type: 'legend-status',
11
- element: 'property-editor-legend-status'
12
- },
13
- {
14
- type: 'svg-info',
15
- element: 'property-editor-svg-info'
16
- }
17
- ]
@@ -1,13 +0,0 @@
1
- import './editor-legend-status'
2
-
3
- import { html } from 'lit'
4
- import { customElement } from 'lit/decorators.js'
5
-
6
- import { OxPropertyEditor, PropertySpec } from '@operato/property-editor'
7
-
8
- @customElement('property-editor-legend-status')
9
- export class PropertyEditorLegendStatus extends OxPropertyEditor {
10
- editorTemplate(value: any, spec: PropertySpec) {
11
- return html` <editor-legend-status .value=${value} fullwidth></editor-legend-status> `
12
- }
13
- }
@@ -1,77 +0,0 @@
1
- import '@operato/i18n/ox-i18n.js'
2
-
3
- import { css, html, PropertyValues, TemplateResult } from 'lit'
4
- import { customElement, property, state } from 'lit/decorators.js'
5
-
6
- import { OxPropertyEditor, PropertySpec } from '@operato/property-editor'
7
- import { Component, HTMLOverlayContainer } from '@hatiolab/things-scene'
8
-
9
- @customElement('property-editor-svg-info')
10
- export default class SVGInfoEditor extends OxPropertyEditor {
11
- static styles = [
12
- ...OxPropertyEditor.styles,
13
- css`
14
- ul[info] {
15
- margin: 0;
16
- font-size: 1em;
17
- }
18
- `
19
- ]
20
-
21
- @property({ type: String }) src?: string
22
-
23
- @state() ids: SVGPathElement[] = []
24
-
25
- private fillStyleSaved: any[] = []
26
-
27
- editorTemplate(value: any, spec: PropertySpec): TemplateResult {
28
- return html`
29
- <fieldset fullwidth>
30
- <ul info>
31
- ${this.ids.map(
32
- path =>
33
- html`<li @mouseenter=${() => this.onEnterEvent(path)} @mouseout=${() => this.onOutEvent(path)}>
34
- <div style="fillStyle:${path.style.fill}">${path.id}</div>
35
- </li>`
36
- )}
37
- </ul>
38
- </fieldset>
39
- `
40
- }
41
-
42
- onEnterEvent(path: SVGPathElement) {
43
- this.fillStyleSaved.push(path.style.fill)
44
- path.style.fill = 'red'
45
- }
46
-
47
- onOutEvent(path: SVGPathElement) {
48
- path.style.fill = this.fillStyleSaved.pop()
49
- }
50
-
51
- updated(changes: PropertyValues<this>) {
52
- if (changes.has('src')) {
53
- this.dispatchEvent(
54
- new CustomEvent('i-need-selected', {
55
- bubbles: true,
56
- composed: true,
57
- detail: {
58
- callback: (selected: any[]) => {
59
- this.fetchSourceInfo(selected[0], this.src!)
60
- }
61
- }
62
- })
63
- )
64
- }
65
- }
66
-
67
- async fetchSourceInfo(component: Component, src: string) {
68
- if (!src || !src.trim()) {
69
- return
70
- }
71
-
72
- const element = (component as HTMLOverlayContainer).element as HTMLDivElement
73
-
74
- const elements = element.querySelectorAll('path[id]')
75
- this.ids = Array.from(elements).map(path => path) as any
76
- }
77
- }
package/src/index.ts DELETED
@@ -1,8 +0,0 @@
1
- /*
2
- * Copyright © HatioLab Inc. All rights reserved.
3
- */
4
-
5
- export { default as Legend } from './legend'
6
- export { default as LegendItem } from './legend-item'
7
-
8
- export { default as Svg } from './svg'
@@ -1,52 +0,0 @@
1
- /*
2
- * Copyright © HatioLab Inc. All rights reserved.
3
- */
4
- import { Component, ComponentNature, Properties, RectPath, Shape } from '@hatiolab/things-scene'
5
-
6
- const NATURE: ComponentNature = {
7
- mutable: false,
8
- resizable: false,
9
- rotatable: false,
10
- properties: []
11
- }
12
-
13
- export default class LegendItem extends RectPath(Shape) {
14
- render(context: CanvasRenderingContext2D) {
15
- var { left, top, height, color } = this.state
16
-
17
- context.beginPath()
18
-
19
- var c = height / 2
20
- var r = c / 2
21
-
22
- context.save()
23
-
24
- context.fillStyle = color
25
- context.ellipse(left + c, top + c, r, r, 0, 0, Math.PI * 2, true)
26
- context.shadowColor = 'rgba(0,0,0,0.15)'
27
- context.shadowBlur = 2
28
- context.shadowOffsetX = 1
29
- context.shadowOffsetY = 2
30
- context.fill()
31
-
32
- context.restore()
33
- }
34
-
35
- onchange(after: Properties) {
36
- if (after.hasOwnProperty('height')) this.set('paddingLeft', after.height)
37
- }
38
-
39
- get stuck() {
40
- return true
41
- }
42
-
43
- get capturable() {
44
- return false
45
- }
46
-
47
- get nature() {
48
- return NATURE
49
- }
50
- }
51
-
52
- Component.register('legend-item', LegendItem)