@operato/input 1.0.0-alpha.4 → 1.0.0-alpha.42

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 (116) hide show
  1. package/CHANGELOG.md +327 -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 +36 -0
  11. package/demo/index-file.html +41 -0
  12. package/demo/index-image.html +1 -1
  13. package/demo/index-multiple-colors.html +37 -0
  14. package/demo/index-options.html +43 -0
  15. package/demo/index-partition-keys.html +71 -0
  16. package/demo/index-range.html +40 -0
  17. package/demo/index-select.html +21 -14
  18. package/demo/index-table.html +39 -0
  19. package/demo/index-value-map.html +80 -0
  20. package/demo/index-value-ranges.html +80 -0
  21. package/demo/index.html +23 -54
  22. package/dist/src/index.d.ts +21 -11
  23. package/dist/src/index.js +21 -11
  24. package/dist/src/index.js.map +1 -1
  25. package/dist/src/ox-checkbox.d.ts +1 -1
  26. package/dist/src/ox-checkbox.js +2 -2
  27. package/dist/src/ox-checkbox.js.map +1 -1
  28. package/dist/src/ox-input-code.d.ts +4 -4
  29. package/dist/src/ox-input-code.js +8 -8
  30. package/dist/src/ox-input-code.js.map +1 -1
  31. package/dist/src/ox-input-color-gradient.d.ts +26 -0
  32. package/dist/src/ox-input-color-gradient.js +318 -0
  33. package/dist/src/ox-input-color-gradient.js.map +1 -0
  34. package/dist/src/ox-input-color-stops.d.ts +71 -0
  35. package/dist/src/ox-input-color-stops.js +445 -0
  36. package/dist/src/ox-input-color-stops.js.map +1 -0
  37. package/dist/src/ox-input-color.d.ts +176 -0
  38. package/dist/src/ox-input-color.js +298 -0
  39. package/dist/src/ox-input-color.js.map +1 -0
  40. package/dist/src/ox-input-crontab.d.ts +23 -0
  41. package/dist/src/ox-input-crontab.js +560 -0
  42. package/dist/src/ox-input-crontab.js.map +1 -0
  43. package/dist/src/ox-input-data.d.ts +2 -2
  44. package/dist/src/ox-input-data.js +2 -2
  45. package/dist/src/ox-input-data.js.map +1 -1
  46. package/dist/src/ox-input-file.d.ts +2 -0
  47. package/dist/src/ox-input-file.js +6 -1
  48. package/dist/src/ox-input-file.js.map +1 -1
  49. package/dist/src/ox-input-layout/ox-input-card-layout.d.ts +4 -0
  50. package/dist/src/ox-input-layout/ox-input-card-layout.js +57 -0
  51. package/dist/src/ox-input-layout/ox-input-card-layout.js.map +1 -0
  52. package/dist/src/ox-input-layout/ox-input-grid-layout.d.ts +4 -0
  53. package/dist/src/ox-input-layout/ox-input-grid-layout.js +63 -0
  54. package/dist/src/ox-input-layout/ox-input-grid-layout.js.map +1 -0
  55. package/dist/src/ox-input-layout/ox-input-layout.d.ts +5 -0
  56. package/dist/src/ox-input-layout/ox-input-layout.js +73 -0
  57. package/dist/src/ox-input-layout/ox-input-layout.js.map +1 -0
  58. package/dist/src/ox-input-multiple-colors.d.ts +28 -0
  59. package/dist/src/ox-input-multiple-colors.js +113 -0
  60. package/dist/src/ox-input-multiple-colors.js.map +1 -0
  61. package/dist/src/ox-input-options.d.ts +22 -0
  62. package/dist/src/ox-input-options.js +137 -0
  63. package/dist/src/ox-input-options.js.map +1 -0
  64. package/dist/src/ox-input-partition-keys.d.ts +36 -0
  65. package/dist/src/ox-input-partition-keys.js +204 -0
  66. package/dist/src/ox-input-partition-keys.js.map +1 -0
  67. package/dist/src/ox-input-range.d.ts +4 -0
  68. package/dist/src/ox-input-range.js +161 -0
  69. package/dist/src/ox-input-range.js.map +1 -0
  70. package/dist/src/ox-input-scene-component-id.d.ts +11 -0
  71. package/dist/src/ox-input-scene-component-id.js +68 -0
  72. package/dist/src/ox-input-scene-component-id.js.map +1 -0
  73. package/dist/src/ox-input-stack.d.ts +1 -1
  74. package/dist/src/ox-input-stack.js +1 -1
  75. package/dist/src/ox-input-stack.js.map +1 -1
  76. package/dist/src/ox-input-table.d.ts +8 -0
  77. package/dist/src/ox-input-table.js +379 -0
  78. package/dist/src/ox-input-table.js.map +1 -0
  79. package/dist/src/ox-input-value-map.d.ts +41 -0
  80. package/dist/src/ox-input-value-map.js +279 -0
  81. package/dist/src/ox-input-value-map.js.map +1 -0
  82. package/dist/src/ox-input-value-ranges.d.ts +41 -0
  83. package/dist/src/ox-input-value-ranges.js +298 -0
  84. package/dist/src/ox-input-value-ranges.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 +25 -7
  90. package/src/index.ts +21 -11
  91. package/src/ox-checkbox.ts +3 -3
  92. package/src/ox-input-code.ts +9 -10
  93. package/src/ox-input-color-gradient.ts +343 -0
  94. package/src/ox-input-color-stops.ts +499 -0
  95. package/src/ox-input-color.ts +323 -0
  96. package/src/ox-input-crontab.ts +560 -0
  97. package/src/ox-input-data.ts +5 -5
  98. package/src/ox-input-file.ts +8 -3
  99. package/src/ox-input-layout/ox-input-card-layout.ts +58 -0
  100. package/src/ox-input-layout/ox-input-grid-layout.ts +64 -0
  101. package/src/ox-input-layout/ox-input-layout.ts +77 -0
  102. package/src/ox-input-multiple-colors.ts +113 -0
  103. package/src/ox-input-options.ts +165 -0
  104. package/src/ox-input-partition-keys.ts +243 -0
  105. package/src/ox-input-range.ts +147 -0
  106. package/src/{ox-input-id.ts → ox-input-scene-component-id.ts} +1 -1
  107. package/src/ox-input-stack.ts +1 -1
  108. package/src/ox-input-table.ts +404 -0
  109. package/src/{ox-input-keyvalues.ts.ing → ox-input-value-map.ts} +125 -94
  110. package/src/ox-input-value-ranges.ts +325 -0
  111. package/src/ox-select.ts +31 -5
  112. package/translations/en.json +1 -0
  113. package/translations/ko.json +1 -0
  114. package/translations/ms.json +1 -0
  115. package/translations/zh.json +1 -0
  116. package/src/ox-input-ranges.ts.ing +0 -292
package/src/index.ts CHANGED
@@ -1,11 +1,21 @@
1
- export * from './ox-form-field'
2
- export * from './ox-input-angle'
3
- export * from './ox-input-3dish'
4
- export * from './ox-input-stack'
5
- export * from './ox-input-barcode'
6
- export * from './ox-buttons-radio'
7
- export * from './ox-checkbox'
8
- export * from './ox-select'
9
- export * from './ox-input-code'
10
- export * from './ox-input-file'
11
- export * from './ox-input-image'
1
+ export * from './ox-form-field.js'
2
+ export * from './ox-buttons-radio.js'
3
+ export * from './ox-checkbox.js'
4
+ export * from './ox-select.js'
5
+ export * from './ox-input-angle.js'
6
+ export * from './ox-input-3dish.js'
7
+ export * from './ox-input-stack.js'
8
+ export * from './ox-input-barcode.js'
9
+ export * from './ox-input-code.js'
10
+ export * from './ox-input-color.js'
11
+ export * from './ox-input-multiple-colors.js'
12
+ export * from './ox-input-color-stops.js'
13
+ export * from './ox-input-color-gradient.js'
14
+ export * from './ox-input-file.js'
15
+ export * from './ox-input-image.js'
16
+ export * from './ox-input-value-ranges.js'
17
+ export * from './ox-input-value-map.js'
18
+ export * from './ox-input-table.js'
19
+ export * from './ox-input-scene-component-id.js'
20
+ export * from './ox-input-crontab'
21
+ export * from './ox-input-partition-keys'
@@ -12,7 +12,7 @@ export class OxCheckbox extends OxFormField {
12
12
  static styles = [
13
13
  css`
14
14
  :host {
15
- display: block;
15
+ display: flex;
16
16
  }
17
17
 
18
18
  div {
@@ -71,7 +71,7 @@ export class OxCheckbox extends OxFormField {
71
71
  `
72
72
  ]
73
73
 
74
- @property({ type: Boolean, attribute: 'checked', reflect: true }) checked: boolean = false
74
+ @property({ type: Boolean, attribute: 'checked', reflect: true }) checked: boolean | undefined = false
75
75
  @property({ type: Boolean }) disabled: boolean = false
76
76
  @property({ type: Boolean, attribute: 'indeterminatable' }) indeterminatable: boolean = false
77
77
  @property({ type: Boolean, attribute: 'indeterminate', reflect: true }) indeterminate: boolean = false
@@ -117,7 +117,7 @@ export class OxCheckbox extends OxFormField {
117
117
  this.checked = false
118
118
  } else {
119
119
  this.indeterminate = true
120
- this.checked = false
120
+ this.checked = undefined
121
121
  }
122
122
  }
123
123
 
@@ -7,27 +7,26 @@ import 'codemirror/mode/python/python'
7
7
  import 'codemirror/addon/display/fullscreen'
8
8
  import 'codemirror/addon/display/autorefresh'
9
9
 
10
- import FullScreenStyle from '!!text-loader!codemirror/addon/display/fullscreen.css'
11
- import CodeMirrorStyle from '!!text-loader!codemirror/lib/codemirror.css'
12
- import NightThemeStyle from '!!text-loader!codemirror/theme/night.css'
13
- import CodeMirror from 'codemirror'
14
- import { css, html, PropertyValues, unsafeCSS } from 'lit'
10
+ import { PropertyValues, css, html, unsafeCSS } from 'lit'
15
11
  import { customElement, property } from 'lit/decorators.js'
16
12
 
17
- import { ScrollbarStyles } from '@operato/styles'
18
-
13
+ import CodeMirror from 'codemirror'
14
+ import CodeMirrorStyle from '!!text-loader!codemirror/lib/codemirror.css'
15
+ import FullScreenStyle from '!!text-loader!codemirror/addon/display/fullscreen.css'
16
+ import NightThemeStyle from '!!text-loader!codemirror/theme/night.css'
19
17
  import { OxFormField } from './ox-form-field'
18
+ import { ScrollbarStyles } from '@operato/styles'
20
19
 
21
20
  /**
22
21
  WEB Component for code-mirror code editor.
23
22
 
24
23
  Example:
25
24
 
26
- <things-editor-code .value=${text} mode=${mode} tab-size="4" tab-as-space="true">
27
- </things-editor-code>
25
+ <ox-input-code .value=${text} mode=${mode} tab-size="4" tab-as-space="true">
26
+ </ox-input-code>
28
27
  */
29
28
  @customElement('ox-input-code')
30
- export default class OxInputCode extends OxFormField {
29
+ export class OxInputCode extends OxFormField {
31
30
  static styles = [
32
31
  ScrollbarStyles,
33
32
  css`
@@ -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
+ }