@operato/input 1.0.0-alpha.8 → 1.0.0-beta.1

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 (119) hide show
  1. package/CHANGELOG.md +412 -0
  2. package/README.md +9 -6
  3. package/assets/images/icon-editor-gradient-direction.png +0 -0
  4. package/assets/images/icon-properties-label.png +0 -0
  5. package/assets/images/icon-properties-line-type.png +0 -0
  6. package/assets/images/icon-properties-table.png +0 -0
  7. package/demo/index-color-gradient.html +35 -0
  8. package/demo/index-color-stops.html +62 -0
  9. package/demo/index-color.html +35 -0
  10. package/demo/index-crontab.html +37 -0
  11. package/demo/index-multiple-colors.html +37 -0
  12. package/demo/index-partition-keys.html +71 -0
  13. package/demo/index-select.html +21 -14
  14. package/demo/index-table.html +39 -0
  15. package/demo/index-value-map.html +80 -0
  16. package/demo/index-value-ranges.html +80 -0
  17. package/demo/index-work-shift.html +59 -0
  18. package/demo/index.html +14 -0
  19. package/dist/src/index.d.ts +21 -11
  20. package/dist/src/index.js +21 -11
  21. package/dist/src/index.js.map +1 -1
  22. package/dist/src/ox-checkbox.d.ts +1 -1
  23. package/dist/src/ox-checkbox.js +1 -1
  24. package/dist/src/ox-checkbox.js.map +1 -1
  25. package/dist/src/ox-form-field.d.ts +2 -2
  26. package/dist/src/ox-form-field.js.map +1 -1
  27. package/dist/src/ox-input-barcode.d.ts +1 -1
  28. package/dist/src/ox-input-barcode.js +1 -1
  29. package/dist/src/ox-input-barcode.js.map +1 -1
  30. package/dist/src/ox-input-code.d.ts +4 -4
  31. package/dist/src/ox-input-code.js +8 -8
  32. package/dist/src/ox-input-code.js.map +1 -1
  33. package/dist/src/ox-input-color-gradient.d.ts +26 -0
  34. package/dist/src/ox-input-color-gradient.js +318 -0
  35. package/dist/src/ox-input-color-gradient.js.map +1 -0
  36. package/dist/src/ox-input-color-stops.d.ts +71 -0
  37. package/dist/src/ox-input-color-stops.js +445 -0
  38. package/dist/src/ox-input-color-stops.js.map +1 -0
  39. package/dist/src/ox-input-color.d.ts +176 -0
  40. package/dist/src/ox-input-color.js +298 -0
  41. package/dist/src/ox-input-color.js.map +1 -0
  42. package/dist/src/ox-input-crontab.d.ts +23 -0
  43. package/dist/src/ox-input-crontab.js +560 -0
  44. package/dist/src/ox-input-crontab.js.map +1 -0
  45. package/dist/src/ox-input-data.d.ts +1 -1
  46. package/dist/src/ox-input-data.js +1 -1
  47. package/dist/src/ox-input-data.js.map +1 -1
  48. package/dist/src/ox-input-layout/ox-input-card-layout.d.ts +4 -0
  49. package/dist/src/ox-input-layout/ox-input-card-layout.js +57 -0
  50. package/dist/src/ox-input-layout/ox-input-card-layout.js.map +1 -0
  51. package/dist/src/ox-input-layout/ox-input-grid-layout.d.ts +4 -0
  52. package/dist/src/ox-input-layout/ox-input-grid-layout.js +63 -0
  53. package/dist/src/ox-input-layout/ox-input-grid-layout.js.map +1 -0
  54. package/dist/src/ox-input-layout/ox-input-layout.d.ts +5 -0
  55. package/dist/src/ox-input-layout/ox-input-layout.js +73 -0
  56. package/dist/src/ox-input-layout/ox-input-layout.js.map +1 -0
  57. package/dist/src/ox-input-multiple-colors.d.ts +28 -0
  58. package/dist/src/ox-input-multiple-colors.js +113 -0
  59. package/dist/src/ox-input-multiple-colors.js.map +1 -0
  60. package/dist/src/ox-input-options.js.map +1 -1
  61. package/dist/src/ox-input-partition-keys.d.ts +36 -0
  62. package/dist/src/ox-input-partition-keys.js +204 -0
  63. package/dist/src/ox-input-partition-keys.js.map +1 -0
  64. package/dist/src/{ox-input-id.d.ts → ox-input-scene-component-id.d.ts} +0 -0
  65. package/dist/src/{ox-input-id.js → ox-input-scene-component-id.js} +2 -2
  66. package/dist/src/ox-input-scene-component-id.js.map +1 -0
  67. package/dist/src/ox-input-search.d.ts +1 -0
  68. package/dist/src/ox-input-search.js +7 -1
  69. package/dist/src/ox-input-search.js.map +1 -1
  70. package/dist/src/ox-input-stack.d.ts +1 -1
  71. package/dist/src/ox-input-stack.js +1 -1
  72. package/dist/src/ox-input-stack.js.map +1 -1
  73. package/dist/src/ox-input-table.d.ts +8 -0
  74. package/dist/src/ox-input-table.js +379 -0
  75. package/dist/src/ox-input-table.js.map +1 -0
  76. package/dist/src/ox-input-value-map.d.ts +41 -0
  77. package/dist/src/ox-input-value-map.js +279 -0
  78. package/dist/src/ox-input-value-map.js.map +1 -0
  79. package/dist/src/ox-input-value-ranges.d.ts +41 -0
  80. package/dist/src/ox-input-value-ranges.js +298 -0
  81. package/dist/src/ox-input-value-ranges.js.map +1 -0
  82. package/dist/src/ox-input-work-shift.d.ts +33 -0
  83. package/dist/src/ox-input-work-shift.js +229 -0
  84. package/dist/src/ox-input-work-shift.js.map +1 -0
  85. package/dist/src/ox-select.d.ts +3 -0
  86. package/dist/src/ox-select.js +28 -3
  87. package/dist/src/ox-select.js.map +1 -1
  88. package/dist/tsconfig.tsbuildinfo +1 -1
  89. package/package.json +24 -7
  90. package/src/index.ts +21 -11
  91. package/src/ox-checkbox.ts +2 -2
  92. package/src/ox-form-field.ts +2 -2
  93. package/src/ox-input-barcode.ts +2 -3
  94. package/src/ox-input-code.ts +9 -10
  95. package/src/ox-input-color-gradient.ts +343 -0
  96. package/src/ox-input-color-stops.ts +499 -0
  97. package/src/ox-input-color.ts +323 -0
  98. package/src/ox-input-crontab.ts +561 -0
  99. package/src/ox-input-data.ts +2 -2
  100. package/src/ox-input-layout/ox-input-card-layout.ts +58 -0
  101. package/src/ox-input-layout/ox-input-grid-layout.ts +64 -0
  102. package/src/ox-input-layout/ox-input-layout.ts +77 -0
  103. package/src/ox-input-multiple-colors.ts +113 -0
  104. package/src/ox-input-options.ts +1 -1
  105. package/src/ox-input-partition-keys.ts +243 -0
  106. package/src/{ox-input-id.ts → ox-input-scene-component-id.ts} +1 -1
  107. package/src/ox-input-search.ts +9 -1
  108. package/src/ox-input-stack.ts +1 -1
  109. package/src/ox-input-table.ts +404 -0
  110. package/src/{ox-input-keyvalues.ts.ing → ox-input-value-map.ts} +125 -94
  111. package/src/ox-input-value-ranges.ts +325 -0
  112. package/src/ox-input-work-shift.ts +251 -0
  113. package/src/ox-select.ts +31 -5
  114. package/translations/en.json +1 -0
  115. package/translations/ko.json +1 -0
  116. package/translations/ms.json +1 -0
  117. package/translations/zh.json +1 -0
  118. package/dist/src/ox-input-id.js.map +0 -1
  119. package/src/ox-input-ranges.ts.ing +0 -292
@@ -0,0 +1,343 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+
5
+ import '@operato/i18n/ox-i18n.js'
6
+ import '@polymer/paper-dropdown-menu/paper-dropdown-menu'
7
+ import '@polymer/paper-listbox/paper-listbox'
8
+ import '@polymer/paper-item/paper-item'
9
+ import '@operato/input/ox-input-angle.js'
10
+ import '@operato/input/ox-input-color-stops.js'
11
+
12
+ import { css, html } from 'lit'
13
+ import { customElement, property } from 'lit/decorators.js'
14
+
15
+ import { ColorStop } from './ox-input-color-stops.js'
16
+ import { OxFormField } from './ox-form-field.js'
17
+
18
+ export type GradientOption = {
19
+ type: 'linear' | 'radial'
20
+ rotation: number
21
+ direction?:
22
+ | 'left-to-right'
23
+ | 'lefttop-to-rightbottom'
24
+ | 'top-to-bottom'
25
+ | 'righttop-to-leftbottom'
26
+ | 'right-to-left'
27
+ | 'rightbottom-to-lefttop'
28
+ | 'bottom-to-top'
29
+ | 'leftbottom-to-righttop'
30
+ | 'left-to-right'
31
+ | 'center-to-corner'
32
+ center?: 'center' | 'left-top' | 'right-top' | 'right-bottom' | 'left-bottom'
33
+ colorStops?: ColorStop[]
34
+ }
35
+
36
+ @customElement('ox-input-color-gradient')
37
+ export class OxInputColorGradient extends OxFormField {
38
+ static styles = css`
39
+ :host {
40
+ display: grid;
41
+
42
+ grid-template-columns: repeat(10, 1fr);
43
+ grid-gap: 5px;
44
+ grid-auto-rows: minmax(24px, auto);
45
+
46
+ align-items: center;
47
+ }
48
+
49
+ :host > * {
50
+ align-self: stretch;
51
+ }
52
+
53
+ :host > label {
54
+ grid-column: span 2;
55
+ text-align: right;
56
+ text-transform: capitalize;
57
+ align-self: center;
58
+ }
59
+
60
+ :host > .icon-only-label {
61
+ grid-column: span 1;
62
+ }
63
+
64
+ :host > input,
65
+ :host > [editors] {
66
+ grid-column: span 8;
67
+ }
68
+
69
+ :host > select {
70
+ grid-column: span 4;
71
+ height: 100%;
72
+ border: 1px solid rgba(0, 0, 0, 0.2);
73
+ }
74
+
75
+ :host > ox-input-angle {
76
+ grid-column: span 3;
77
+ }
78
+
79
+ ox-input-color-stops {
80
+ grid-column: span 10;
81
+ }
82
+
83
+ .host > input[type='checkbox'] {
84
+ grid-column: 3 / 4;
85
+ }
86
+
87
+ .host > input[type='checkbox'] ~ label {
88
+ grid-column: span 7;
89
+ text-align: left;
90
+ }
91
+
92
+ [editors] > :not([active-selector]) {
93
+ display: none;
94
+ }
95
+
96
+ [gradient-direction] {
97
+ overflow: hidden;
98
+ max-width: 210px;
99
+ }
100
+
101
+ [gradient-direction] paper-item {
102
+ background: url(/assets/images/icon-editor-gradient-direction.png) 50% 0 no-repeat;
103
+ min-height: 32px;
104
+ padding: 3px 5px;
105
+ width: 30px;
106
+ float: left;
107
+ }
108
+
109
+ [gradient-direction] [name='lefttop-to-rightbottom'] {
110
+ background-position: 50% 4px;
111
+ }
112
+
113
+ [gradient-direction] [name='left-top'] {
114
+ background-position: 50% 4px;
115
+ }
116
+
117
+ [gradient-direction] [name='top-to-bottom'] {
118
+ background-position: 50% -46px;
119
+ }
120
+
121
+ [gradient-direction] [name='righttop-to-leftbottom'] {
122
+ background-position: 50% -96px;
123
+ }
124
+
125
+ [gradient-direction] [name='right-top'] {
126
+ background-position: 50% -96px;
127
+ }
128
+
129
+ [gradient-direction] [name='right-to-left'] {
130
+ background-position: 50% -146px;
131
+ }
132
+
133
+ [gradient-direction] [name='rightbottom-to-lefttop'] {
134
+ background-position: 50% -196px;
135
+ }
136
+
137
+ [gradient-direction] [name='right-bottom'] {
138
+ background-position: 50% -196px;
139
+ }
140
+
141
+ [gradient-direction] [name='bottom-to-top'] {
142
+ background-position: 50% -246px;
143
+ }
144
+
145
+ [gradient-direction] [name='leftbottom-to-righttop'] {
146
+ background-position: 50% -296px;
147
+ }
148
+
149
+ [gradient-direction] [name='left-bottom'] {
150
+ background-position: 50% -296px;
151
+ }
152
+
153
+ [gradient-direction] [name='left-to-right'] {
154
+ background-position: 50% -346px;
155
+ }
156
+
157
+ [gradient-direction] [name='center-to-corner'] {
158
+ background-position: 50% -396px;
159
+ }
160
+
161
+ [gradient-direction] [name='center'] {
162
+ background-position: 50% -396px;
163
+ }
164
+
165
+ [gradient-direction] paper-item[focused] {
166
+ background-color: rgba(255, 246, 143, 0.5);
167
+ }
168
+
169
+ .icon-only-label {
170
+ top: 0 !important;
171
+ width: 30px !important;
172
+ height: 24px;
173
+ background: url(/assets/images/icon-properties-label.png) no-repeat;
174
+ }
175
+
176
+ .icon-only-label.color {
177
+ background-position: 70% -198px;
178
+ }
179
+ `
180
+
181
+ @property({ type: Object }) value: GradientOption = {
182
+ type: 'linear',
183
+ direction: 'left-to-right',
184
+ rotation: 0
185
+ }
186
+
187
+ firstUpdated() {
188
+ this.renderRoot.addEventListener('change', this._onChange.bind(this))
189
+ }
190
+
191
+ _onChange(e: Event) {
192
+ var element = e.target as HTMLElement & { type: string }
193
+ var key = element.getAttribute('value-key')
194
+
195
+ if (!key) {
196
+ return
197
+ }
198
+
199
+ var value
200
+
201
+ switch (element.tagName) {
202
+ case 'INPUT':
203
+ switch (element.type) {
204
+ case 'checkbox':
205
+ value = (element as HTMLInputElement).checked
206
+ break
207
+ case 'number':
208
+ value = Number((element as HTMLInputElement).value) || 0
209
+ break
210
+ case 'text':
211
+ value = String((element as HTMLInputElement).value)
212
+ }
213
+ break
214
+
215
+ case 'PAPER-BUTTON':
216
+ value = (element as any).active
217
+ break
218
+
219
+ case 'PAPER-LISTBOX':
220
+ value = (element as any).selected
221
+ break
222
+
223
+ default:
224
+ value = (element as HTMLInputElement).value
225
+ break
226
+ }
227
+
228
+ if (key === 'rotation') {
229
+ this.value = {
230
+ ...this.value,
231
+ rotation: value,
232
+ direction: undefined
233
+ }
234
+ } else if (key === 'direction') {
235
+ if (value) {
236
+ this.value = {
237
+ ...this.value,
238
+ direction: value,
239
+ rotation: this._convertDirectionToRotation(value)
240
+ }
241
+ }
242
+ } else {
243
+ this.value = {
244
+ ...this.value,
245
+ [key]: value
246
+ }
247
+ }
248
+
249
+ this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))
250
+ }
251
+
252
+ render() {
253
+ var selector = (this.value && this.value.type) || 'linear'
254
+ var value = this.value || {}
255
+
256
+ return html`
257
+ <label> <ox-i18n msgid="label.type">type</ox-i18n> </label>
258
+ <select value-key="type" .value=${value.type || 'linear'}>
259
+ <option>linear</option>
260
+ <option>radial</option>
261
+ </select>
262
+
263
+ <label class="icon-only-label color"></label>
264
+ <ox-input-angle value-key="rotation" .value=${value.rotation || 0}> </ox-input-angle>
265
+
266
+ <label> <ox-i18n msgid="label.direction">direction</ox-i18n> </label>
267
+ <div editors>
268
+ <paper-dropdown-menu no-label-float="true" ?active-selector=${selector == 'linear'} .value=${value.direction}>
269
+ <paper-listbox
270
+ @selected-changed=${(e: Event) => this._onChange(e)}
271
+ value-key="direction"
272
+ slot="dropdown-content"
273
+ gradient-direction
274
+ .selected=${value.direction}
275
+ attr-for-selected="name"
276
+ >
277
+ <paper-item name="lefttop-to-rightbottom"></paper-item>
278
+ <paper-item name="top-to-bottom"></paper-item>
279
+ <paper-item name="righttop-to-leftbottom"></paper-item>
280
+ <paper-item name="right-to-left"></paper-item>
281
+ <paper-item name="rightbottom-to-lefttop"></paper-item>
282
+ <paper-item name="bottom-to-top"></paper-item>
283
+ <paper-item name="leftbottom-to-righttop"></paper-item>
284
+ <paper-item name="left-to-right"></paper-item>
285
+ <paper-item name="center-to-corner"></paper-item>
286
+ </paper-listbox>
287
+ </paper-dropdown-menu>
288
+
289
+ <paper-dropdown-menu no-label-float="true" ?active-selector=${selector == 'radial'} .value=${value.center}>
290
+ <paper-listbox
291
+ @selected-changed=${(e: Event) => this._onChange(e)}
292
+ value-key="center"
293
+ slot="dropdown-content"
294
+ gradient-direction
295
+ .selected=${value.center || 'center'}
296
+ attr-for-selected="name"
297
+ >
298
+ <paper-item name="center"></paper-item>
299
+ <paper-item name="left-top"></paper-item>
300
+ <paper-item name="right-top"></paper-item>
301
+ <paper-item name="right-bottom"></paper-item>
302
+ <paper-item name="left-bottom"></paper-item>
303
+ </paper-listbox>
304
+ </paper-dropdown-menu>
305
+ </div>
306
+
307
+ <ox-input-color-stops value-key="colorStops" type="gradient" .value=${value.colorStops}> </ox-input-color-stops>
308
+ `
309
+ }
310
+
311
+ _convertDirectionToRotation(direction: string): number {
312
+ var rotation
313
+ switch (direction) {
314
+ case 'lefttop-to-rightbottom':
315
+ rotation = 45
316
+ break
317
+ case 'top-to-bottom':
318
+ rotation = 90
319
+ break
320
+ case 'righttop-to-leftbottom':
321
+ rotation = 135
322
+ break
323
+ case 'right-to-left':
324
+ rotation = 180
325
+ break
326
+ case 'rightbottom-to-lefttop':
327
+ rotation = 215
328
+ break
329
+ case 'bottom-to-top':
330
+ rotation = 270
331
+ break
332
+ case 'leftbottom-to-righttop':
333
+ rotation = 315
334
+ break
335
+ case 'left-to-right':
336
+ default:
337
+ rotation = 0
338
+ break
339
+ }
340
+
341
+ return (rotation / 360) * Math.PI * 2
342
+ }
343
+ }