@things-factory/modeller-ui 5.0.0-alpha.5 → 5.0.0-alpha.6

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.
Files changed (29) hide show
  1. package/client/bootstrap.js +22 -26
  2. package/client/editors/things-editor-layout/things-card-layout.js +1 -1
  3. package/client/editors/things-editor-property.js +1 -546
  4. package/package.json +15 -14
  5. package/client/editors/paper-color-picker/paper-color-circle.js +0 -466
  6. package/client/editors/paper-color-picker/paper-color-input.js +0 -266
  7. package/client/editors/paper-color-picker/paper-color-picker.js +0 -584
  8. package/client/editors/things-editor-3dish.js +0 -164
  9. package/client/editors/things-editor-angle-input.js +0 -69
  10. package/client/editors/things-editor-attachment-selector.js +0 -110
  11. package/client/editors/things-editor-buttons-radio.js +0 -93
  12. package/client/editors/things-editor-code.js +0 -152
  13. package/client/editors/things-editor-color-stops.js +0 -499
  14. package/client/editors/things-editor-color-style.js +0 -345
  15. package/client/editors/things-editor-color.js +0 -313
  16. package/client/editors/things-editor-data.js +0 -152
  17. package/client/editors/things-editor-gradient.js +0 -335
  18. package/client/editors/things-editor-graphql.js +0 -173
  19. package/client/editors/things-editor-id.js +0 -85
  20. package/client/editors/things-editor-multiple-color.js +0 -132
  21. package/client/editors/things-editor-options.js +0 -156
  22. package/client/editors/things-editor-pattern.js +0 -161
  23. package/client/editors/things-editor-property-styles.js +0 -71
  24. package/client/editors/things-editor-range-input.js +0 -166
  25. package/client/editors/things-editor-script.js +0 -213
  26. package/client/editors/things-editor-stack.js +0 -107
  27. package/client/editors/things-editor-table.js +0 -376
  28. package/client/editors/things-editor-value-map.js +0 -290
  29. package/client/editors/things-editor-value-range.js +0 -292
@@ -1,466 +0,0 @@
1
- import { html } from '@polymer/polymer/polymer-element'
2
-
3
- import { Polymer } from '@polymer/polymer/lib/legacy/polymer-fn'
4
- import '@polymer/paper-ripple/paper-ripple'
5
- import { IronResizableBehavior } from '@polymer/iron-resizable-behavior/iron-resizable-behavior'
6
-
7
- function hsv2rgb(h, s, v) {
8
- var c = v * s
9
- var h1 = h / 60
10
- var x = c * (1 - Math.abs((h1 % 2) - 1))
11
- var m = v - c
12
- var rgb
13
- if (typeof h == 'undefined') rgb = [0, 0, 0]
14
- else if (h1 < 1) rgb = [c, x, 0]
15
- else if (h1 < 2) rgb = [x, c, 0]
16
- else if (h1 < 3) rgb = [0, c, x]
17
- else if (h1 < 4) rgb = [0, x, c]
18
- else if (h1 < 5) rgb = [x, 0, c]
19
- else if (h1 <= 6) rgb = [c, 0, x]
20
- return [255 * (rgb[0] + m), 255 * (rgb[1] + m), 255 * (rgb[2] + m)]
21
- }
22
-
23
- function hsl2rgb(h, s, l) {
24
- var r, g, b
25
- h /= 360
26
- if (s == 0) {
27
- r = g = b = l // achromatic
28
- } else {
29
- function hue2rgb(p, q, t) {
30
- if (t < 0) t += 1
31
- if (t > 1) t -= 1
32
- if (t < 1 / 6) return p + (q - p) * 6 * t
33
- if (t < 1 / 2) return q
34
- if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6
35
- return p
36
- }
37
-
38
- var q = l < 0.5 ? l * (1 + s) : l + s - l * s
39
- var p = 2 * l - q
40
- r = hue2rgb(p, q, h + 1 / 3)
41
- g = hue2rgb(p, q, h)
42
- b = hue2rgb(p, q, h - 1 / 3)
43
- }
44
-
45
- return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)]
46
- }
47
- function rgb2hsl(r, g, b) {
48
- ;(r /= 255), (g /= 255), (b /= 255)
49
- var max = Math.max(r, g, b),
50
- min = Math.min(r, g, b)
51
- var h,
52
- s,
53
- l = (max + min) / 2
54
-
55
- if (max == min) {
56
- h = s = 0
57
- } else {
58
- var d = max - min
59
- s = l > 0.5 ? d / (2 - max - min) : d / (max + min)
60
- switch (max) {
61
- case r:
62
- h = (g - b) / d + (g < b ? 6 : 0)
63
- break
64
- case g:
65
- h = (b - r) / d + 2
66
- break
67
- case b:
68
- h = (r - g) / d + 4
69
- break
70
- }
71
- h /= 6
72
- }
73
-
74
- return [h, s, l]
75
- }
76
- var rgb2hsv = function(r, g, b) {
77
- var b, delta, g, h, max, min, r, s, v
78
- min = Math.min(r, g, b)
79
- max = Math.max(r, g, b)
80
- delta = max - min
81
- v = max / 255.0
82
- if (max === 0) {
83
- h = Number.NaN
84
- s = 0
85
- } else {
86
- s = delta / max
87
- if (r === max) {
88
- h = (g - b) / delta
89
- }
90
- if (g === max) {
91
- h = 2 + (b - r) / delta
92
- }
93
- if (b === max) {
94
- h = 4 + (r - g) / delta
95
- }
96
- h *= 60
97
- if (h < 0) {
98
- h += 360
99
- }
100
- }
101
- return [h / 360, s, v]
102
- }
103
-
104
- Polymer({
105
- _template: html`
106
- <style>
107
- :host {
108
- display: inline-block;
109
- position: relative;
110
- }
111
-
112
- canvas {
113
- min-width: 100px;
114
- min-height: 100px;
115
- cursor: crosshair;
116
- -webkit-touch-callout: none;
117
- -webkit-user-select: none;
118
- -khtml-user-select: none;
119
- -moz-user-select: none;
120
- -ms-user-select: none;
121
- user-select: none;
122
- }
123
-
124
- #rippleContainer {
125
- position: relative;
126
- margin: auto;
127
- }
128
- </style>
129
-
130
- <div id="rippleContainer">
131
- <canvas id="canvas" on-down="onDown" on-up="onUp" on-track="onMove"></canvas>
132
- <paper-ripple id="ripple" class$="{{shape}}" recenters noink></paper-ripple>
133
- </div>
134
- `,
135
-
136
- is: 'paper-color-circle',
137
-
138
- properties: {
139
- /**
140
- * A AA border can be drawn to prevent jagged edges on circles
141
- *
142
- * @attribute colouredAaBorder
143
- * @type boolean
144
- * @default false
145
- */
146
- noAaBorder: {
147
- type: Boolean,
148
- value: false
149
- },
150
- _ctx: {
151
- type: Object,
152
- value: function() {
153
- return {}
154
- }
155
- },
156
- _domReady: {
157
- type: Boolean,
158
- value: false
159
- },
160
- _down: {
161
- type: Boolean,
162
- value: false
163
- },
164
- _moveStart: {
165
- type: Boolean,
166
- value: false
167
- },
168
- _redrawTimer: {
169
- type: Number,
170
- value: 0
171
- },
172
- _setAaBorder: {
173
- value: function() {
174
- return undefined
175
- }
176
- },
177
- /**
178
- * Picked color
179
- *
180
- * @attribute color
181
- * @type Array
182
- * @default new Array(2)
183
- */
184
- color: {
185
- type: Object,
186
- notify: true,
187
- value: {
188
- red: undefined,
189
- green: undefined,
190
- blue: undefined
191
- }
192
- },
193
- /**
194
- * A coloured AA border can be drawn to prevent jagged edges on circles
195
- *
196
- * @attribute colouredAaBorder
197
- * @type Array
198
- * @default false
199
- */
200
- colouredAaBorder: {
201
- type: Boolean,
202
- value: false,
203
- notify: true
204
- },
205
- hsl2rgb: {
206
- value: function() {
207
- return hsl2rgb
208
- }
209
- },
210
- rgb2hsl: {
211
- value: function() {
212
- return rgb2hsl
213
- }
214
- },
215
- hsv2rgb: {
216
- value: function() {
217
- return hsv2rgb
218
- }
219
- },
220
- rgb2hsv: {
221
- value: function() {
222
- return rgb2hsv
223
- }
224
- },
225
- /**
226
- * In case of a huebox, the hue from 0 to 1
227
- *
228
- * @attribute value
229
- * @type number
230
- * @default 1
231
- */
232
- hue: {
233
- type: Number,
234
- value: 0,
235
- notify: true,
236
- observer: 'hueChanged'
237
- },
238
- /**
239
- * In case of hsl, the lightness
240
- *
241
- * @attribute lightness
242
- * @type number
243
- * @default .5
244
- */
245
- lightness: {
246
- type: Number,
247
- value: 0.5,
248
- notify: true,
249
- observer: 'lightnessChanged'
250
- },
251
- /**
252
- * square, circle or huebox
253
- *
254
- * @attribute shape
255
- * @type string
256
- * @default 'circle'
257
- */
258
- shape: {
259
- type: String,
260
- value: 'circle',
261
- notify: true
262
- },
263
- /**
264
- * hsv OR hsl
265
- *
266
- * @attribute type
267
- * @type string
268
- * @default 'hsv'
269
- */
270
- type: {
271
- type: String,
272
- value: 'hsv',
273
- notify: true
274
- },
275
- /**
276
- * In case of hsv, the value
277
- *
278
- * @attribute value
279
- * @type number
280
- * @default 1
281
- */
282
- value: {
283
- type: Number,
284
- value: 1,
285
- notify: true,
286
- observer: 'valueChanged'
287
- }
288
- },
289
- observers: ['colorChanged(color.*)'],
290
- behaviors: [IronResizableBehavior],
291
- listeners: {
292
- 'iron-resize': 'redraw'
293
- },
294
- pickColor: function(e) {
295
- var rect = this.getBoundingClientRect()
296
- var touchX = e.detail.x - rect.left
297
- var touchY = e.detail.y - rect.top
298
- var color = this._ctx.getImageData(touchX, touchY, 1, 1).data
299
- if (this.shape === 'circle') {
300
- var distance = Math.abs(
301
- Math.sqrt(Math.pow(touchX - this.size / 2, 2) + Math.pow(touchY - this.size / 2, 2)) - this.size / 2
302
- )
303
- if (distance < this.size / 100) {
304
- return
305
- }
306
- }
307
- if (color[3] > 0 && color[3] == 255) {
308
- this.set('color.red', color[0])
309
- this.set('color.green', color[1])
310
- this.set('color.blue', color[2])
311
- if (!this.noAaBorder && this.colouredAaBorder) this.redraw()
312
- }
313
- },
314
- onDown: function(e) {
315
- this.pickColor(e, true)
316
- this._trackingColorChanges = true
317
- },
318
- onMove: function(e) {
319
- this.pickColor(e)
320
- },
321
- onUp: function(e) {
322
- this._trackingColorChanges = false
323
- this.$.ripple.style.color = 'rgb(' + this.color['red'] + ',' + this.color['green'] + ',' + this.color['blue'] + ')'
324
- this.$.ripple.downAction(e)
325
- this.async(function() {
326
- this.$.ripple.upAction()
327
- })
328
- },
329
- redraw: function() {
330
- this.debounce('redraw', function() {
331
- var size = this.getBoundingClientRect()
332
- var width = size.width
333
- var height = size.height
334
- if (width == 0 || height == 0) {
335
- var computedStyle = window.getComputedStyle(this)
336
- width = parseInt(computedStyle.width)
337
- height = parseInt(computedStyle.height)
338
- }
339
- this.size = Math.floor(Math.min(width, height))
340
- this.$.canvas.width = this.size
341
- this.$.canvas.height = this.size
342
- this.$.rippleContainer.style.width = this.size + 'px'
343
- this.$.rippleContainer.style.height = this.size + 'px'
344
- var halfsize = this.size / 2
345
- if (!this.size) return
346
- var bitmap = this._ctx.getImageData(0, 0, this.size, this.size)
347
- var smoothBorder = 0
348
- for (var y = 0; y < this.size; y++) {
349
- for (var x = 0; x < this.size; x++) {
350
- // offset for the 4 RGBA values in the data array
351
- var offset = 4 * (y * this.size + x)
352
- if (this.shape === 'circle') {
353
- var distanceFromCenter = Math.sqrt(Math.pow(y - halfsize, 2) + Math.pow(x - halfsize, 2)) / halfsize
354
- if (distanceFromCenter < (halfsize + smoothBorder) / halfsize - 0.01) {
355
- var hue = Math.atan2(y - halfsize, x - halfsize) * (180 / Math.PI)
356
- if (hue < 0) hue += 360
357
- var saturation = Math.round(distanceFromCenter * 1000) / 1000
358
- saturation = Math.min(1, saturation)
359
- if (this.type === 'hsv') {
360
- var value = Math.round(this.value * 1000) / 1000
361
- var color = hsv2rgb(hue, saturation, value)
362
- } else if (this.type === 'hsl') {
363
- var lightness = Math.round(this.lightness * 1000) / 1000
364
- var color = hsl2rgb(hue, saturation, lightness)
365
- }
366
- // fill RGBA values
367
- bitmap.data[offset + 0] = color[0]
368
- bitmap.data[offset + 1] = color[1]
369
- bitmap.data[offset + 2] = color[2]
370
- if (distanceFromCenter - 1 >= 0) {
371
- var distance = Math.round((distanceFromCenter - 1) * halfsize)
372
- bitmap.data[offset + 3] = 255 * ((smoothBorder - distance) / smoothBorder) // transparency
373
- } else {
374
- bitmap.data[offset + 3] = 255 // no transparency
375
- }
376
- }
377
- } else if (this.shape === 'huebox') {
378
- var saturation = x / width
379
- var hue = (Math.round(this.hue * 1000) / 1000) * 360
380
- var third = 1 - y / this.size
381
- if (this.type === 'hsv') {
382
- var color = hsv2rgb(hue, saturation, third)
383
- } else if (this.type === 'hsl') {
384
- var color = hsl2rgb(hue, saturation, third)
385
- }
386
- bitmap.data[offset + 0] = color[0]
387
- bitmap.data[offset + 1] = color[1]
388
- bitmap.data[offset + 2] = color[2]
389
- bitmap.data[offset + 3] = 255 // no transparency
390
- } else if (this.shape === 'square') {
391
- var hue = (x / width) * 360
392
- var saturation = 1 - y / this.size
393
- if (this.type === 'hsv') {
394
- var value = Math.round(this.value * 1000) / 1000
395
- var color = hsv2rgb(hue, saturation, value)
396
- } else if (this.type === 'hsl') {
397
- var lightness = Math.round(this.lightness * 1000) / 1000
398
- var color = hsl2rgb(hue, saturation, lightness)
399
- }
400
- bitmap.data[offset + 0] = color[0]
401
- bitmap.data[offset + 1] = color[1]
402
- bitmap.data[offset + 2] = color[2]
403
- bitmap.data[offset + 3] = 255 // no transparency
404
- }
405
- }
406
- }
407
- this._ctx.putImageData(bitmap, 0, 0)
408
- if (!this.noAaBorder && this.shape === 'circle') {
409
- //Getting a nice anti aliased edge using canvas is hard, so instead a white circle is draw over the border
410
- this.drawAACircle()
411
- }
412
- })
413
- },
414
- drawAACircle: function() {
415
- if (this.colouredAaBorder) {
416
- if (this.color['green']) {
417
- this.set(
418
- '_ctx.strokeStyle',
419
- 'rgb(' + this.color['red'] + ',' + this.color['green'] + ',' + this.color['blue'] + ')'
420
- )
421
- } else {
422
- this.set(
423
- '_ctx.strokeStyle',
424
- 'rgb(' + this.colouredAaBorder[0] + ',' + this.colouredAaBorder[1] + ',' + this.colouredAaBorder[2] + ')'
425
- )
426
- }
427
- } else {
428
- this.set('_ctx.strokeStyle', 'rgba(255,255,255,.99)')
429
- }
430
- this.set('_ctx.lineWidth', this.size / 100)
431
- this._ctx.beginPath()
432
- var borderRadius = this.size / 2
433
- this._ctx.arc(this.size / 2, this.size / 2, borderRadius - 1, 0, 2 * Math.PI, false)
434
- this._ctx.closePath()
435
- this._ctx.stroke()
436
- },
437
- valueChanged: function() {
438
- if (this._domReady) this.redraw()
439
- },
440
- lightnessChanged: function() {
441
- if (this._domReady) this.redraw()
442
- },
443
- hueChanged: function() {
444
- if (this._domReady) this.redraw()
445
- },
446
- colorChanged: function() {
447
- if (!this._trackingColorChanges) {
448
- if (this.type == 'hsl') {
449
- var hsl = this.rgb2hsl(parseInt(this.color.red), parseInt(this.color.green), parseInt(this.color.blue))
450
- this.hue = hsl[0]
451
- this.lightness = hsl[2]
452
- } else if (this.type == 'hsv') {
453
- var hsv = this.rgb2hsv(parseInt(this.color.red), parseInt(this.color.green), parseInt(this.color.blue))
454
- if (!isNaN(Number(hsv[0]))) this.hue = Number(hsv[0])
455
- this.value = hsv[2]
456
- }
457
- }
458
- //if(this._domReady)
459
- // this.redraw();
460
- },
461
- attached: function() {
462
- this._domReady = true
463
- this._ctx = this.$.canvas.getContext('2d')
464
- this.redraw()
465
- }
466
- })