@operato/input 2.0.0-alpha.0 → 2.0.0-alpha.102

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 (202) hide show
  1. package/CHANGELOG.md +339 -0
  2. package/demo/index-multiple-colors.html +14 -2
  3. package/demo/index-partition-keys.html +13 -2
  4. package/demo/index-select.html +20 -9
  5. package/demo/index-table.html +13 -2
  6. package/demo/index.html +13 -2
  7. package/dist/src/locale/locale-picker.d.ts +1 -1
  8. package/dist/src/ox-buttons-radio.d.ts +1 -1
  9. package/dist/src/ox-checkbox.d.ts +5 -4
  10. package/dist/src/ox-checkbox.js +12 -6
  11. package/dist/src/ox-checkbox.js.map +1 -1
  12. package/dist/src/ox-input-3axis.d.ts +1 -1
  13. package/dist/src/ox-input-3dish.d.ts +1 -1
  14. package/dist/src/ox-input-angle.d.ts +1 -1
  15. package/dist/src/ox-input-barcode.d.ts +49 -6
  16. package/dist/src/ox-input-barcode.js +97 -69
  17. package/dist/src/ox-input-barcode.js.map +1 -1
  18. package/dist/src/ox-input-code.d.ts +2 -3
  19. package/dist/src/ox-input-code.js +8 -15
  20. package/dist/src/ox-input-code.js.map +1 -1
  21. package/dist/src/ox-input-color-gradient.d.ts +1 -1
  22. package/dist/src/ox-input-color-stops.d.ts +1 -1
  23. package/dist/src/ox-input-color.d.ts +1 -1
  24. package/dist/src/ox-input-container.d.ts +2 -2
  25. package/dist/src/ox-input-container.js +2 -2
  26. package/dist/src/ox-input-container.js.map +1 -1
  27. package/dist/src/ox-input-crontab.d.ts +1 -2
  28. package/dist/src/ox-input-crontab.js +4 -7
  29. package/dist/src/ox-input-crontab.js.map +1 -1
  30. package/dist/src/ox-input-data.d.ts +4 -5
  31. package/dist/src/ox-input-data.js +88 -36
  32. package/dist/src/ox-input-data.js.map +1 -1
  33. package/dist/src/ox-input-duration.d.ts +1 -2
  34. package/dist/src/ox-input-duration.js +13 -9
  35. package/dist/src/ox-input-duration.js.map +1 -1
  36. package/dist/src/ox-input-file.d.ts +2 -2
  37. package/dist/src/ox-input-file.js +10 -9
  38. package/dist/src/ox-input-file.js.map +1 -1
  39. package/dist/src/ox-input-hashtags.d.ts +1 -1
  40. package/dist/src/ox-input-i18n-label.d.ts +33 -0
  41. package/dist/src/ox-input-i18n-label.js +130 -0
  42. package/dist/src/ox-input-i18n-label.js.map +1 -0
  43. package/dist/src/ox-input-image.d.ts +2 -2
  44. package/dist/src/ox-input-image.js +4 -4
  45. package/dist/src/ox-input-image.js.map +1 -1
  46. package/dist/src/ox-input-key-values.d.ts +2 -2
  47. package/dist/src/ox-input-key-values.js +9 -10
  48. package/dist/src/ox-input-key-values.js.map +1 -1
  49. package/dist/src/ox-input-mass-fraction.d.ts +3 -2
  50. package/dist/src/ox-input-mass-fraction.js +90 -56
  51. package/dist/src/ox-input-mass-fraction.js.map +1 -1
  52. package/dist/src/ox-input-multiple-colors.d.ts +2 -2
  53. package/dist/src/ox-input-multiple-colors.js +7 -7
  54. package/dist/src/ox-input-multiple-colors.js.map +1 -1
  55. package/dist/src/ox-input-options.d.ts +2 -2
  56. package/dist/src/ox-input-options.js +5 -7
  57. package/dist/src/ox-input-options.js.map +1 -1
  58. package/dist/src/ox-input-partition-keys.d.ts +2 -2
  59. package/dist/src/ox-input-partition-keys.js +10 -10
  60. package/dist/src/ox-input-partition-keys.js.map +1 -1
  61. package/dist/src/ox-input-privilege.d.ts +1 -2
  62. package/dist/src/ox-input-privilege.js +15 -31
  63. package/dist/src/ox-input-privilege.js.map +1 -1
  64. package/dist/src/ox-input-quantifier.d.ts +1 -1
  65. package/dist/src/ox-input-scene-component-id.d.ts +1 -1
  66. package/dist/src/ox-input-search.d.ts +2 -2
  67. package/dist/src/ox-input-search.js +5 -4
  68. package/dist/src/ox-input-search.js.map +1 -1
  69. package/dist/src/ox-input-select-buttons.d.ts +1 -1
  70. package/dist/src/ox-input-select-buttons.js +1 -1
  71. package/dist/src/ox-input-select-buttons.js.map +1 -1
  72. package/dist/src/ox-input-stack.d.ts +1 -1
  73. package/dist/src/ox-input-table.d.ts +1 -1
  74. package/dist/src/ox-input-table.js +12 -12
  75. package/dist/src/ox-input-table.js.map +1 -1
  76. package/dist/src/ox-input-textarea.d.ts +1 -1
  77. package/dist/src/ox-input-unit-number.d.ts +3 -2
  78. package/dist/src/ox-input-unit-number.js +25 -10
  79. package/dist/src/ox-input-unit-number.js.map +1 -1
  80. package/dist/src/ox-input-value-map.d.ts +2 -2
  81. package/dist/src/ox-input-value-map.js +17 -17
  82. package/dist/src/ox-input-value-map.js.map +1 -1
  83. package/dist/src/ox-input-value-ranges.d.ts +2 -2
  84. package/dist/src/ox-input-value-ranges.js +22 -17
  85. package/dist/src/ox-input-value-ranges.js.map +1 -1
  86. package/dist/src/ox-input-work-shift.d.ts +1 -1
  87. package/dist/src/ox-input-work-shift.js +4 -8
  88. package/dist/src/ox-input-work-shift.js.map +1 -1
  89. package/dist/src/ox-select.d.ts +2 -2
  90. package/dist/src/ox-select.js +16 -10
  91. package/dist/src/ox-select.js.map +1 -1
  92. package/dist/stories/ox-input-3axis.stories.js +14 -1
  93. package/dist/stories/ox-input-3axis.stories.js.map +1 -1
  94. package/dist/stories/ox-input-3dish.stories.js +14 -1
  95. package/dist/stories/ox-input-3dish.stories.js.map +1 -1
  96. package/dist/stories/ox-input-angle.stories.js +13 -1
  97. package/dist/stories/ox-input-angle.stories.js.map +1 -1
  98. package/dist/stories/ox-input-barcode.stories.js +17 -1
  99. package/dist/stories/ox-input-barcode.stories.js.map +1 -1
  100. package/dist/stories/ox-input-code.stories.d.ts +4 -0
  101. package/dist/stories/ox-input-code.stories.js +18 -3
  102. package/dist/stories/ox-input-code.stories.js.map +1 -1
  103. package/dist/stories/ox-input-crontab.stories.js +13 -1
  104. package/dist/stories/ox-input-crontab.stories.js.map +1 -1
  105. package/dist/stories/ox-input-data.stories.d.ts +29 -0
  106. package/dist/stories/ox-input-data.stories.js +50 -0
  107. package/dist/stories/ox-input-data.stories.js.map +1 -0
  108. package/dist/stories/ox-input-duration.stories.js +13 -1
  109. package/dist/stories/ox-input-duration.stories.js.map +1 -1
  110. package/dist/stories/ox-input-file.stories.js +13 -1
  111. package/dist/stories/ox-input-file.stories.js.map +1 -1
  112. package/dist/stories/ox-input-hashtags.stories.js +13 -1
  113. package/dist/stories/ox-input-hashtags.stories.js.map +1 -1
  114. package/dist/stories/ox-input-i18n-label.stories.d.ts +29 -0
  115. package/dist/stories/ox-input-i18n-label.stories.js +70 -0
  116. package/dist/stories/ox-input-i18n-label.stories.js.map +1 -0
  117. package/dist/stories/ox-input-key-values.stories.js +13 -1
  118. package/dist/stories/ox-input-key-values.stories.js.map +1 -1
  119. package/dist/stories/ox-input-mass-fraction.stories.d.ts +4 -0
  120. package/dist/stories/ox-input-mass-fraction.stories.js +22 -3
  121. package/dist/stories/ox-input-mass-fraction.stories.js.map +1 -1
  122. package/dist/stories/ox-input-multiple-colors.stories.js +21 -11
  123. package/dist/stories/ox-input-multiple-colors.stories.js.map +1 -1
  124. package/dist/stories/ox-input-options.stories.js +13 -1
  125. package/dist/stories/ox-input-options.stories.js.map +1 -1
  126. package/dist/stories/ox-input-partition-keys.stories.js +13 -1
  127. package/dist/stories/ox-input-partition-keys.stories.js.map +1 -1
  128. package/dist/stories/ox-input-privilege.stories.js +13 -1
  129. package/dist/stories/ox-input-privilege.stories.js.map +1 -1
  130. package/dist/stories/ox-input-quantifier.stories.js +13 -1
  131. package/dist/stories/ox-input-quantifier.stories.js.map +1 -1
  132. package/dist/stories/ox-input-range.stories.js +13 -1
  133. package/dist/stories/ox-input-range.stories.js.map +1 -1
  134. package/dist/stories/ox-input-search.stories.js +13 -1
  135. package/dist/stories/ox-input-search.stories.js.map +1 -1
  136. package/dist/stories/ox-input-select-buttons.stories.js +13 -1
  137. package/dist/stories/ox-input-select-buttons.stories.js.map +1 -1
  138. package/dist/stories/ox-input-unit.stories.js +14 -0
  139. package/dist/stories/ox-input-unit.stories.js.map +1 -1
  140. package/dist/stories/ox-input-value-map.stories.js +13 -1
  141. package/dist/stories/ox-input-value-map.stories.js.map +1 -1
  142. package/dist/stories/ox-input-value-ranges.stories.js +13 -1
  143. package/dist/stories/ox-input-value-ranges.stories.js.map +1 -1
  144. package/dist/stories/ox-input-work-shift.stories.js +13 -1
  145. package/dist/stories/ox-input-work-shift.stories.js.map +1 -1
  146. package/dist/stories/ox-select.stories.js +13 -1
  147. package/dist/stories/ox-select.stories.js.map +1 -1
  148. package/dist/tsconfig.tsbuildinfo +1 -1
  149. package/package.json +26 -22
  150. package/src/ox-checkbox.ts +9 -6
  151. package/src/ox-input-barcode.ts +128 -63
  152. package/src/ox-input-code.ts +6 -13
  153. package/src/ox-input-container.ts +2 -2
  154. package/src/ox-input-crontab.ts +4 -8
  155. package/src/ox-input-data.ts +97 -38
  156. package/src/ox-input-duration.ts +13 -10
  157. package/src/ox-input-file.ts +10 -9
  158. package/src/ox-input-i18n-label.ts +140 -0
  159. package/src/ox-input-image.ts +4 -4
  160. package/src/ox-input-key-values.ts +27 -22
  161. package/src/ox-input-mass-fraction.ts +88 -57
  162. package/src/ox-input-multiple-colors.ts +7 -7
  163. package/src/ox-input-options.ts +5 -7
  164. package/src/ox-input-partition-keys.ts +28 -22
  165. package/src/ox-input-privilege.ts +15 -32
  166. package/src/ox-input-search.ts +5 -4
  167. package/src/ox-input-select-buttons.ts +1 -1
  168. package/src/ox-input-table.ts +12 -12
  169. package/src/ox-input-unit-number.ts +18 -2
  170. package/src/ox-input-value-map.ts +19 -19
  171. package/src/ox-input-value-ranges.ts +24 -19
  172. package/src/ox-input-work-shift.ts +4 -8
  173. package/src/ox-select.ts +16 -10
  174. package/stories/ox-input-3axis.stories.ts +14 -1
  175. package/stories/ox-input-3dish.stories.ts +14 -1
  176. package/stories/ox-input-angle.stories.ts +13 -1
  177. package/stories/ox-input-barcode.stories.ts +17 -1
  178. package/stories/ox-input-code.stories.ts +25 -3
  179. package/stories/ox-input-crontab.stories.ts +13 -1
  180. package/stories/ox-input-data.stories.ts +65 -0
  181. package/stories/ox-input-duration.stories.ts +13 -1
  182. package/stories/ox-input-file.stories.ts +13 -1
  183. package/stories/ox-input-hashtags.stories.ts +13 -1
  184. package/stories/ox-input-i18n-label.stories.ts +85 -0
  185. package/stories/ox-input-key-values.stories.ts +13 -1
  186. package/stories/ox-input-mass-fraction.stories.ts +23 -2
  187. package/stories/ox-input-multiple-colors.stories.ts +21 -11
  188. package/stories/ox-input-options.stories.ts +13 -1
  189. package/stories/ox-input-partition-keys.stories.ts +13 -1
  190. package/stories/ox-input-privilege.stories.ts +13 -1
  191. package/stories/ox-input-quantifier.stories.ts +13 -1
  192. package/stories/ox-input-range.stories.ts +13 -1
  193. package/stories/ox-input-search.stories.ts +13 -1
  194. package/stories/ox-input-select-buttons.stories.ts +13 -1
  195. package/stories/ox-input-unit.stories.ts +14 -0
  196. package/stories/ox-input-value-map.stories.ts +13 -1
  197. package/stories/ox-input-value-ranges.stories.ts +13 -1
  198. package/stories/ox-input-work-shift.stories.ts +13 -1
  199. package/stories/ox-select.stories.ts +13 -1
  200. package/themes/app-theme.css +1 -1
  201. package/themes/input-theme.css +20 -7
  202. package/yarn-error.log +17084 -0
@@ -4,11 +4,13 @@
4
4
 
5
5
  import './ox-input-code'
6
6
 
7
- import { css, html, PropertyValues } from 'lit'
7
+ import { css, html } from 'lit'
8
8
  import { customElement } from 'lit/decorators.js'
9
+ import { live } from 'lit/directives/live.js'
9
10
 
10
11
  import { OxFormField } from './ox-form-field.js'
11
12
  import { OxInputCode } from './ox-input-code.js'
13
+ import { isEqual } from 'lodash-es'
12
14
 
13
15
  /**
14
16
  WEB Component for code-mirror based data editor.
@@ -36,7 +38,7 @@ export class OxInputData extends OxFormField {
36
38
  font-size: small;
37
39
  }
38
40
 
39
- div[datatype] mwc-icon {
41
+ div[datatype] md-icon {
40
42
  margin-left: auto;
41
43
  }
42
44
 
@@ -49,38 +51,56 @@ export class OxInputData extends OxFormField {
49
51
  ]
50
52
 
51
53
  render() {
54
+ const valueType = typeof this.value
55
+
52
56
  return html`
53
57
  <div datatype>
54
58
  <input
59
+ id="string"
55
60
  type="radio"
56
61
  name="data-type"
57
62
  data-value="string"
58
- .checked=${typeof this.value == 'string'}
63
+ .checked=${live(valueType == 'string')}
59
64
  @click=${() => this._setDataType('string')}
60
65
  ?disabled=${this.disabled}
61
- />string
66
+ />
67
+ <label for="string">string</label>
62
68
 
63
69
  <input
70
+ id="number"
64
71
  type="radio"
65
72
  name="data-type"
66
73
  data-value="number"
67
- .checked=${typeof this.value == 'number'}
74
+ .checked=${live(valueType == 'number')}
68
75
  @click=${() => this._setDataType('number')}
69
76
  ?disabled=${this.disabled}
70
- />number
77
+ />
78
+ <label for="number">number</label>
71
79
 
72
80
  <input
81
+ id="object"
73
82
  type="radio"
74
83
  name="data-type"
75
84
  data-value="object"
76
- .checked=${typeof this.value == 'object'}
85
+ .checked=${live(valueType == 'object')}
77
86
  @click=${() => this._setDataType('object')}
78
87
  ?disabled=${this.disabled}
79
- />object
80
- <mwc-icon @click=${() => this._clearData()} title="delete">delete_forever</mwc-icon>
88
+ />
89
+ <label for="object">object</label>
90
+
91
+ <md-icon @click=${() => this._clearData()} title="delete">delete_forever</md-icon>
81
92
  </div>
82
93
 
83
- <ox-input-code .value=${this._getData(this.value)} language="javascript" editor ?disabled=${this.disabled}>
94
+ <ox-input-code
95
+ .value=${this._getStringData(this.value)}
96
+ language="text"
97
+ editor
98
+ ?disabled=${this.disabled}
99
+ @change=${(e: CustomEvent) => {
100
+ e.stopPropagation()
101
+ this._setDataTypeAndValue(valueType, (e.target as any).value)
102
+ }}
103
+ >
84
104
  </ox-input-code>
85
105
  `
86
106
  }
@@ -88,45 +108,75 @@ export class OxInputData extends OxFormField {
88
108
  firstUpdated() {
89
109
  this.renderRoot.addEventListener('change', e => {
90
110
  e.stopPropagation()
111
+
91
112
  const target = e.target as OxInputCode
92
113
  if (target.hasAttribute('editor')) {
114
+ if (this.value === undefined && target.value == '') {
115
+ return
116
+ }
93
117
  this.value = target.value
94
118
  }
95
-
96
- const type = this.renderRoot.querySelector('input[name=data-type]:checked')?.getAttribute('data-value')
97
- this._setDataType(type)
98
119
  })
99
120
  }
100
121
 
101
- udpated(changes: PropertyValues<this>) {
102
- if (changes.has('value')) {
103
- this.value = this._getData(this.value)
122
+ _setDataTypeAndValue(type: string | undefined | null, value: any) {
123
+ /* value must be a string */
124
+ try {
125
+ switch (type) {
126
+ case 'number':
127
+ if (!isNaN(Number(value))) {
128
+ value = Number(value)
129
+ }
130
+ break
131
+ case 'object':
132
+ value = eval('(' + value + ')')
133
+ break
134
+ }
135
+ } catch (e) {}
136
+
137
+ if (isEqual(this.value, value)) {
138
+ return
104
139
  }
140
+
141
+ this.value = value
142
+
143
+ this.requestUpdate()
144
+ this._onAfterValueChange()
105
145
  }
106
146
 
107
147
  _setDataType(type: string | undefined | null) {
108
- if (typeof this.value !== type) {
109
- var value = this.value
110
-
111
- try {
112
- switch (type) {
113
- case 'string':
114
- this.value = String(value || '')
115
- break
116
- case 'number':
117
- if (!isNaN(value)) {
118
- this.value = Number(value)
119
- }
120
- break
121
- case 'object':
122
- this.value = eval('(' + value + ')')
123
- break
124
- }
125
- } catch (e) {
126
- console.log(e)
148
+ if (typeof this.value == type) {
149
+ return
150
+ }
151
+
152
+ var value = this.value
153
+
154
+ try {
155
+ switch (type) {
156
+ case 'string':
157
+ value = this._getStringData(value)
158
+ break
159
+ case 'number':
160
+ if (!isNaN(value)) {
161
+ value = Number(value)
162
+ }
163
+ break
164
+ case 'object':
165
+ value = eval('(' + value + ')')
166
+ break
127
167
  }
168
+ } catch (e) {
169
+ console.log(e)
128
170
  }
129
171
 
172
+ if (isEqual(this.value, value)) {
173
+ this.requestUpdate()
174
+ return
175
+ }
176
+
177
+ this.value = value
178
+
179
+ this.requestUpdate()
130
180
  this._onAfterValueChange()
131
181
  }
132
182
 
@@ -135,11 +185,20 @@ export class OxInputData extends OxFormField {
135
185
  this._onAfterValueChange()
136
186
  }
137
187
 
138
- _getData(data: any) {
139
- return typeof data !== 'object' ? data || '' : JSON.stringify(data, null, 1)
188
+ _getStringData(data: any) {
189
+ const type = typeof data
190
+
191
+ switch (type) {
192
+ case 'object':
193
+ return JSON.stringify(data, null, 1)
194
+ case 'undefined':
195
+ return ''
196
+ default:
197
+ return String(data) || ''
198
+ }
140
199
  }
141
200
 
142
- _onAfterValueChange() {
201
+ async _onAfterValueChange() {
143
202
  this.dispatchEvent(
144
203
  new CustomEvent('change', {
145
204
  bubbles: true,
@@ -2,8 +2,6 @@
2
2
  * @license Copyright © HatioLab Inc. All rights reserved.
3
3
  */
4
4
 
5
- import '@material/mwc-button'
6
-
7
5
  import { css, html } from 'lit'
8
6
  import { customElement, property, query } from 'lit/decorators.js'
9
7
 
@@ -28,9 +26,14 @@ export class OxInputDuration extends OxFormField {
28
26
  }
29
27
 
30
28
  form {
31
- width: 100%;
32
- height: 100%;
33
- justify-content: center;
29
+ display: flex;
30
+ flex-direction: row;
31
+
32
+ align-items: center;
33
+ }
34
+
35
+ [padding] {
36
+ min-width: 100px;
34
37
  }
35
38
 
36
39
  input {
@@ -65,18 +68,16 @@ export class OxInputDuration extends OxFormField {
65
68
  border: var(--button-border);
66
69
  border-radius: var(--border-radius);
67
70
  background-color: var(--button-background-color);
68
- padding: var(--padding-narrow) var(--padding-default);
69
71
  min-height: 35px;
70
72
  line-height: 0.8;
71
73
  color: var(--button-color);
72
74
  cursor: pointer;
73
75
  }
76
+
74
77
  button + button {
75
78
  margin-left: -5px;
76
79
  }
77
- button mwc-icon {
78
- font-size: var(--fontsize-default);
79
- }
80
+
80
81
  button:focus,
81
82
  button:hover,
82
83
  button:active {
@@ -100,6 +101,7 @@ export class OxInputDuration extends OxFormField {
100
101
 
101
102
  return html`
102
103
  <form @change=${this.onChange.bind(this)}>
104
+ <div padding></div>
103
105
  <input id="days" type="number" .value=${String(days || 0)} pattern="\\d*" ?disabled=${this.disabled} />
104
106
  <label for="days">${i18next.t('label.days')}</label>
105
107
 
@@ -148,8 +150,9 @@ export class OxInputDuration extends OxFormField {
148
150
  }}
149
151
  ?disabled=${this.disabled}
150
152
  >
151
- <mwc-icon>backspace</mwc-icon>
153
+ <md-icon>backspace</md-icon>
152
154
  </button>
155
+ <div padding></div>
153
156
  </form>
154
157
  `
155
158
  }
@@ -2,7 +2,7 @@
2
2
  * @license Copyright © HatioLab Inc. All rights reserved.
3
3
  */
4
4
 
5
- import '@material/mwc-icon'
5
+ import '@material/web/icon/icon.js'
6
6
 
7
7
  import { css, html, PropertyValues } from 'lit'
8
8
  import { customElement, property, query } from 'lit/decorators.js'
@@ -32,9 +32,10 @@ export class OxInputFile extends OxFormField {
32
32
  font: var(--file-uploader-font) !important;
33
33
  color: var(--file-uploader-color);
34
34
  }
35
- :host > mwc-icon {
35
+
36
+ :host > md-icon {
36
37
  color: var(--file-uploader-icon-color);
37
- --mdc-icon-size: var(--file-uploader-icon-size, 36px);
38
+ --md-icon-size: var(--file-uploader-icon-size, 36px);
38
39
  }
39
40
 
40
41
  :host(.candrop) {
@@ -75,14 +76,14 @@ export class OxInputFile extends OxFormField {
75
76
  border-bottom: var(--file-uploader-li-border-bottom);
76
77
  font: normal 14px var(--theme-font);
77
78
  }
78
- li mwc-icon {
79
+ li md-icon {
79
80
  float: right;
80
81
  cursor: pointer;
81
82
  margin: var(--file-uploader-li-icon-margin);
82
83
  font-size: 1em;
83
84
  }
84
- li mwc-icon:hover,
85
- li mwc-icon:active {
85
+ li md-icon:hover,
86
+ li md-icon:active {
86
87
  color: var(--file-uploader-li-icon-focus-color);
87
88
  }
88
89
  `
@@ -104,7 +105,7 @@ export class OxInputFile extends OxFormField {
104
105
  var files: File[] = this.value || []
105
106
 
106
107
  return html`
107
- <mwc-icon>${this.icon || 'upload'}</mwc-icon>
108
+ <md-icon>${this.icon || 'upload'}</md-icon>
108
109
 
109
110
  <span>${this.description || 'drop files here!'}</span>
110
111
 
@@ -127,7 +128,7 @@ export class OxInputFile extends OxFormField {
127
128
  file => html`
128
129
  <li>
129
130
  - ${file.name}
130
- <mwc-icon
131
+ <md-icon
131
132
  @click=${(e: Event) => {
132
133
  if (this.disabled) {
133
134
  return
@@ -136,7 +137,7 @@ export class OxInputFile extends OxFormField {
136
137
  this.value = [...files]
137
138
  this._notifyChange()
138
139
  }}
139
- >delete_outline</mwc-icon
140
+ >delete_outline</md-icon
140
141
  >
141
142
  </li>
142
143
  `
@@ -0,0 +1,140 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+
5
+ import '@material/web/icon/icon.js'
6
+
7
+ import { css, html } from 'lit'
8
+ import { customElement, property, queryAll } from 'lit/decorators.js'
9
+
10
+ import { OxFormField } from './ox-form-field'
11
+
12
+ type I18nLabel = { [code: string]: string }
13
+
14
+ const LANGUAGES = [
15
+ {
16
+ code: 'en',
17
+ display: 'English'
18
+ }
19
+ ]
20
+
21
+ /**
22
+ input component for i18n labels
23
+
24
+ Example:
25
+
26
+ <ox-input-i18n-label
27
+ value=${map}
28
+ languages=${languages}
29
+ </ox-input-i18n-label>
30
+ */
31
+ @customElement('ox-input-i18n-label')
32
+ export class OxInputI18nLabels extends OxFormField {
33
+ static styles = css`
34
+ :host {
35
+ display: flex;
36
+ flex-direction: column;
37
+ overflow: hidden;
38
+ gap: 10px;
39
+ }
40
+
41
+ [data-record] {
42
+ display: flex;
43
+ flex-direction: row;
44
+ align-items: center;
45
+ gap: 10px;
46
+ }
47
+
48
+ label {
49
+ width: 80px;
50
+ text-align: end;
51
+ }
52
+
53
+ input {
54
+ flex: 1;
55
+ border: 0;
56
+ border-bottom: var(--border-dark-color);
57
+ padding: var(--input-padding);
58
+ font: var(--input-font);
59
+ color: var(--primary-text-color);
60
+ min-width: 100px;
61
+ }
62
+
63
+ input:focus {
64
+ outline: none;
65
+ border-bottom: 1px solid var(--primary-color);
66
+ }
67
+
68
+ input[type='hidden'] {
69
+ flex: 0;
70
+ }
71
+ `
72
+
73
+ @property({ type: Object }) value: I18nLabel = {}
74
+ @property({ type: Array }) languages: { display: string; code: string }[] = LANGUAGES
75
+
76
+ @queryAll('[data-record]') records!: NodeListOf<HTMLElement>
77
+
78
+ private changing: boolean = false
79
+
80
+ firstUpdated() {
81
+ this.renderRoot.addEventListener('change', this.onChange.bind(this))
82
+ }
83
+
84
+ render() {
85
+ const value = !this.value || typeof this.value !== 'object' ? {} : this.value
86
+ const languages = (this.languages && this.languages.length > 0 && this.languages) || LANGUAGES
87
+
88
+ return html`
89
+ ${languages.map(
90
+ ({ display, code }) => html`
91
+ <div data-record>
92
+ <label>${display}</label>
93
+ <input type="hidden" data-code value=${code} />
94
+ <input
95
+ type="text"
96
+ data-label
97
+ placeholder="label"
98
+ .value=${value?.[code] || ''}
99
+ ?disabled=${this.disabled}
100
+ />
101
+ </div>
102
+ `
103
+ )}
104
+ `
105
+ }
106
+
107
+ private onChange(e: Event) {
108
+ e.stopPropagation()
109
+
110
+ if (this.changing) {
111
+ return
112
+ }
113
+
114
+ this.changing = true
115
+
116
+ this.build()
117
+
118
+ this.changing = false
119
+ }
120
+
121
+ private build() {
122
+ var records = this.renderRoot.querySelectorAll('[data-record]') as NodeListOf<HTMLElement>
123
+
124
+ var newmap: I18nLabel = {}
125
+
126
+ for (var i = 0; i < records.length; i++) {
127
+ var record = records[i]
128
+
129
+ const code = (record.querySelector('[data-code]') as HTMLInputElement).value
130
+ const label = (record.querySelector('[data-label]') as HTMLInputElement).value
131
+
132
+ if (code) {
133
+ newmap[code] = label || ''
134
+ }
135
+ }
136
+
137
+ this.value = { ...this.value, ...newmap }
138
+ this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: this.value }))
139
+ }
140
+ }
@@ -2,7 +2,7 @@
2
2
  * @license Copyright © HatioLab Inc. All rights reserved.
3
3
  */
4
4
 
5
- import '@material/mwc-icon'
5
+ import '@material/web/icon/icon.js'
6
6
 
7
7
  import { css, html } from 'lit'
8
8
  import { customElement, query } from 'lit/decorators.js'
@@ -76,11 +76,11 @@ export class OxInputImage extends OxFormField {
76
76
  place-content: center;
77
77
  }
78
78
 
79
- mwc-icon {
79
+ md-icon {
80
80
  align-self: center;
81
81
 
82
82
  color: var(--file-uploader-icon-color, black);
83
- --mdc-icon-size: var(--file-uploader-icon-size, 36px);
83
+ --md-icon-size: var(--file-uploader-icon-size, 36px);
84
84
  }
85
85
  `
86
86
  ]
@@ -118,7 +118,7 @@ export class OxInputImage extends OxFormField {
118
118
  @change=${(e: Event) => this._onChangeValue(e)}
119
119
  ?disabled=${this.disabled}
120
120
  />
121
- <mwc-icon>upload</mwc-icon>
121
+ <md-icon>upload</md-icon>
122
122
  </label>
123
123
  </div>
124
124
  `
@@ -2,7 +2,7 @@
2
2
  * @license Copyright © HatioLab Inc. All rights reserved.
3
3
  */
4
4
 
5
- import '@material/mwc-icon'
5
+ import '@material/web/icon/icon.js'
6
6
 
7
7
  import { css, html, nothing } from 'lit'
8
8
  import { customElement, property, queryAll } from 'lit/decorators.js'
@@ -29,6 +29,8 @@ export class OxInputKeyValues extends OxFormField {
29
29
  flex-direction: column;
30
30
  overflow: hidden;
31
31
  margin-bottom: var(--margin-wide);
32
+
33
+ --md-icon-size: 14px;
32
34
  }
33
35
 
34
36
  div {
@@ -50,9 +52,6 @@ export class OxInputKeyValues extends OxFormField {
50
52
  button + button {
51
53
  margin-left: -5px;
52
54
  }
53
- button mwc-icon {
54
- font-size: var(--fontsize-default);
55
- }
56
55
  button:focus,
57
56
  button:hover,
58
57
  button:active {
@@ -112,7 +111,7 @@ export class OxInputKeyValues extends OxFormField {
112
111
  tabindex="-1"
113
112
  ?disabled=${this.disabled}
114
113
  >
115
- <mwc-icon>remove</mwc-icon>
114
+ <md-icon>remove</md-icon>
116
115
  </button>
117
116
  <button
118
117
  class="record-action"
@@ -120,7 +119,7 @@ export class OxInputKeyValues extends OxFormField {
120
119
  tabindex="-1"
121
120
  ?disabled=${this.disabled}
122
121
  >
123
- <mwc-icon>arrow_upward</mwc-icon>
122
+ <md-icon>arrow_upward</md-icon>
124
123
  </button>
125
124
  <button
126
125
  class="record-action"
@@ -128,7 +127,7 @@ export class OxInputKeyValues extends OxFormField {
128
127
  tabindex="-1"
129
128
  ?disabled=${this.disabled}
130
129
  >
131
- <mwc-icon>arrow_downward</mwc-icon>
130
+ <md-icon>arrow_downward</md-icon>
132
131
  </button>
133
132
  </div>
134
133
  `
@@ -140,10 +139,10 @@ export class OxInputKeyValues extends OxFormField {
140
139
  <input type="text" data-key placeholder="key" value="" />
141
140
  <input type="text" data-value placeholder="value" value="" list="value-template" />
142
141
  <button class="record-action" @click=${(e: MouseEvent) => this._add()} tabindex="-1">
143
- <mwc-icon>add</mwc-icon>
142
+ <md-icon>add</md-icon>
144
143
  </button>
145
- <button class="hidden"><mwc-icon>add</mwc-icon></button>
146
- <button class="hidden"><mwc-icon>add</mwc-icon></button>
144
+ <button class="hidden"><md-icon>add</md-icon></button>
145
+ <button class="hidden"><md-icon>add</md-icon></button>
147
146
  </div>
148
147
  `}
149
148
 
@@ -260,13 +259,16 @@ export class OxInputKeyValues extends OxFormField {
260
259
  const deleted = array.splice(index, 1)
261
260
  array.splice(index + 1, 0, ...deleted)
262
261
 
263
- this.value = array.reduce((sum, record) => {
264
- const key = (record.querySelector('[data-key]') as HTMLInputElement).value
265
- const value = (record.querySelector('[data-value]') as HTMLInputElement).value
262
+ this.value = array.reduce(
263
+ (sum, record) => {
264
+ const key = (record.querySelector('[data-key]') as HTMLInputElement).value
265
+ const value = (record.querySelector('[data-value]') as HTMLInputElement).value
266
266
 
267
- sum[key] = value
268
- return sum
269
- }, {} as { [key: string]: string })
267
+ sum[key] = value
268
+ return sum
269
+ },
270
+ {} as { [key: string]: string }
271
+ )
270
272
 
271
273
  this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: this.value }))
272
274
  }
@@ -283,13 +285,16 @@ export class OxInputKeyValues extends OxFormField {
283
285
  array.splice(index, 1)
284
286
  array.splice(index + 1, 0, record)
285
287
 
286
- this.value = array.reduce((sum, record) => {
287
- const key = (record.querySelector('[data-key]') as HTMLInputElement).value
288
- const value = (record.querySelector('[data-value]') as HTMLInputElement).value
288
+ this.value = array.reduce(
289
+ (sum, record) => {
290
+ const key = (record.querySelector('[data-key]') as HTMLInputElement).value
291
+ const value = (record.querySelector('[data-value]') as HTMLInputElement).value
289
292
 
290
- sum[key] = value
291
- return sum
292
- }, {} as { [key: string]: string })
293
+ sum[key] = value
294
+ return sum
295
+ },
296
+ {} as { [key: string]: string }
297
+ )
293
298
 
294
299
  this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: this.value }))
295
300
  }