@operato/input 1.0.0-beta.3 → 1.0.0-beta.32

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 (172) hide show
  1. package/.storybook/main.js +2 -2
  2. package/.storybook/server.mjs +4 -4
  3. package/CHANGELOG.md +495 -0
  4. package/demo/index-multiple-colors.html +4 -1
  5. package/demo/index-partition-keys.html +2 -5
  6. package/demo/index-select.html +1 -1
  7. package/demo/index.html +4 -0
  8. package/dist/src/index.d.ts +3 -2
  9. package/dist/src/index.js +3 -2
  10. package/dist/src/index.js.map +1 -1
  11. package/dist/src/locales/en.d.ts +8 -0
  12. package/dist/src/locales/en.js +8 -0
  13. package/dist/src/locales/en.js.map +1 -1
  14. package/dist/src/locales/ko.d.ts +8 -0
  15. package/dist/src/locales/ko.js +8 -0
  16. package/dist/src/locales/ko.js.map +1 -1
  17. package/dist/src/locales/ms.d.ts +8 -0
  18. package/dist/src/locales/ms.js +8 -0
  19. package/dist/src/locales/ms.js.map +1 -1
  20. package/dist/src/locales/zh.d.ts +8 -0
  21. package/dist/src/locales/zh.js +8 -0
  22. package/dist/src/locales/zh.js.map +1 -1
  23. package/dist/src/ox-input-3dish.js +24 -8
  24. package/dist/src/ox-input-3dish.js.map +1 -1
  25. package/dist/src/ox-input-barcode.d.ts +5 -2
  26. package/dist/src/ox-input-barcode.js +55 -19
  27. package/dist/src/ox-input-barcode.js.map +1 -1
  28. package/dist/src/ox-input-color.js +16 -11
  29. package/dist/src/ox-input-color.js.map +1 -1
  30. package/dist/src/ox-input-crontab.js +28 -10
  31. package/dist/src/ox-input-crontab.js.map +1 -1
  32. package/dist/src/ox-input-duration.d.ts +13 -0
  33. package/dist/src/ox-input-duration.js +138 -0
  34. package/dist/src/ox-input-duration.js.map +1 -0
  35. package/dist/src/ox-input-file.js +5 -3
  36. package/dist/src/ox-input-file.js.map +1 -1
  37. package/dist/src/ox-input-key-values.d.ts +41 -0
  38. package/dist/src/ox-input-key-values.js +233 -0
  39. package/dist/src/ox-input-key-values.js.map +1 -0
  40. package/dist/src/ox-input-multiple-colors.d.ts +1 -0
  41. package/dist/src/ox-input-multiple-colors.js +29 -21
  42. package/dist/src/ox-input-multiple-colors.js.map +1 -1
  43. package/dist/src/ox-input-options.d.ts +1 -0
  44. package/dist/src/ox-input-options.js +54 -14
  45. package/dist/src/ox-input-options.js.map +1 -1
  46. package/dist/src/ox-input-partition-keys.d.ts +1 -0
  47. package/dist/src/ox-input-partition-keys.js +51 -23
  48. package/dist/src/ox-input-partition-keys.js.map +1 -1
  49. package/dist/src/ox-input-range.js +35 -38
  50. package/dist/src/ox-input-range.js.map +1 -1
  51. package/dist/src/ox-input-search.d.ts +0 -1
  52. package/dist/src/ox-input-search.js +14 -7
  53. package/dist/src/ox-input-search.js.map +1 -1
  54. package/dist/src/ox-input-unit.d.ts +17 -0
  55. package/dist/src/ox-input-unit.js +122 -0
  56. package/dist/src/ox-input-unit.js.map +1 -0
  57. package/dist/src/ox-input-value-map.d.ts +2 -2
  58. package/dist/src/ox-input-value-map.js +51 -15
  59. package/dist/src/ox-input-value-map.js.map +1 -1
  60. package/dist/src/ox-input-value-ranges.d.ts +2 -2
  61. package/dist/src/ox-input-value-ranges.js +50 -23
  62. package/dist/src/ox-input-value-ranges.js.map +1 -1
  63. package/dist/src/ox-input-work-shift.js +77 -43
  64. package/dist/src/ox-input-work-shift.js.map +1 -1
  65. package/dist/src/ox-select.js +9 -1
  66. package/dist/src/ox-select.js.map +1 -1
  67. package/dist/stories/ox-checkbox.stories.d.ts +39 -0
  68. package/dist/stories/ox-checkbox.stories.js +44 -0
  69. package/dist/stories/ox-checkbox.stories.js.map +1 -0
  70. package/dist/stories/ox-input-3dish.stories.d.ts +26 -0
  71. package/dist/stories/ox-input-3dish.stories.js +59 -0
  72. package/dist/stories/ox-input-3dish.stories.js.map +1 -0
  73. package/dist/stories/ox-input-barcode.stories.d.ts +43 -0
  74. package/dist/stories/ox-input-barcode.stories.js +50 -0
  75. package/dist/stories/ox-input-barcode.stories.js.map +1 -0
  76. package/dist/stories/ox-input-crontab.stories.d.ts +26 -0
  77. package/dist/stories/ox-input-crontab.stories.js +37 -0
  78. package/dist/stories/ox-input-crontab.stories.js.map +1 -0
  79. package/dist/stories/ox-input-duration.stories.d.ts +26 -0
  80. package/dist/stories/ox-input-duration.stories.js +37 -0
  81. package/dist/stories/ox-input-duration.stories.js.map +1 -0
  82. package/dist/stories/ox-input-file.stories.d.ts +49 -0
  83. package/dist/stories/ox-input-file.stories.js +48 -0
  84. package/dist/stories/ox-input-file.stories.js.map +1 -0
  85. package/dist/stories/{index.stories.d.ts → ox-input-key-values.stories.d.ts} +7 -11
  86. package/dist/stories/ox-input-key-values.stories.js +49 -0
  87. package/dist/stories/ox-input-key-values.stories.js.map +1 -0
  88. package/dist/stories/ox-input-multiple-colors.stories.d.ts +20 -0
  89. package/dist/stories/ox-input-multiple-colors.stories.js +167 -0
  90. package/dist/stories/ox-input-multiple-colors.stories.js.map +1 -0
  91. package/dist/stories/ox-input-options.stories.d.ts +25 -0
  92. package/dist/stories/ox-input-options.stories.js +33 -0
  93. package/dist/stories/ox-input-options.stories.js.map +1 -0
  94. package/dist/stories/ox-input-partition-keys.stories.d.ts +25 -0
  95. package/dist/stories/ox-input-partition-keys.stories.js +37 -0
  96. package/dist/stories/ox-input-partition-keys.stories.js.map +1 -0
  97. package/dist/stories/ox-input-range.stories.d.ts +37 -0
  98. package/dist/stories/ox-input-range.stories.js +28 -0
  99. package/dist/stories/ox-input-range.stories.js.map +1 -0
  100. package/dist/stories/ox-input-search.stories.d.ts +29 -0
  101. package/dist/stories/ox-input-search.stories.js +32 -0
  102. package/dist/stories/ox-input-search.stories.js.map +1 -0
  103. package/dist/stories/ox-input-unit.stories.d.ts +40 -0
  104. package/dist/stories/ox-input-unit.stories.js +42 -0
  105. package/dist/stories/ox-input-unit.stories.js.map +1 -0
  106. package/dist/stories/ox-input-value-map.stories.d.ts +35 -0
  107. package/dist/stories/ox-input-value-map.stories.js +37 -0
  108. package/dist/stories/ox-input-value-map.stories.js.map +1 -0
  109. package/dist/stories/ox-input-value-ranges.stories.d.ts +35 -0
  110. package/dist/stories/ox-input-value-ranges.stories.js +37 -0
  111. package/dist/stories/ox-input-value-ranges.stories.js.map +1 -0
  112. package/dist/stories/ox-input-work-shift.stories.d.ts +26 -0
  113. package/dist/stories/ox-input-work-shift.stories.js +59 -0
  114. package/dist/stories/ox-input-work-shift.stories.js.map +1 -0
  115. package/dist/stories/ox-select.stories.d.ts +30 -0
  116. package/dist/stories/ox-select.stories.js +83 -0
  117. package/dist/stories/ox-select.stories.js.map +1 -0
  118. package/dist/themes/common-grist-styles.d.ts +1 -0
  119. package/dist/themes/common-grist-styles.js +110 -0
  120. package/dist/themes/common-grist-styles.js.map +1 -0
  121. package/dist/tsconfig.tsbuildinfo +1 -1
  122. package/package.json +13 -11
  123. package/src/index.ts +3 -2
  124. package/src/locales/en.ts +8 -0
  125. package/src/locales/ko.ts +8 -0
  126. package/src/locales/ms.ts +8 -0
  127. package/src/locales/zh.ts +8 -0
  128. package/src/ox-input-3dish.ts +24 -8
  129. package/src/ox-input-barcode.ts +61 -20
  130. package/src/ox-input-color.ts +17 -11
  131. package/src/ox-input-crontab.ts +30 -10
  132. package/src/ox-input-duration.ts +143 -0
  133. package/src/ox-input-file.ts +7 -6
  134. package/src/ox-input-key-values.ts +270 -0
  135. package/src/ox-input-multiple-colors.ts +29 -21
  136. package/src/ox-input-options.ts +53 -13
  137. package/src/ox-input-partition-keys.ts +51 -22
  138. package/src/ox-input-range.ts +35 -38
  139. package/src/ox-input-search.ts +14 -8
  140. package/src/ox-input-unit.ts +123 -0
  141. package/src/ox-input-value-map.ts +52 -16
  142. package/src/ox-input-value-ranges.ts +52 -25
  143. package/src/ox-input-work-shift.ts +78 -43
  144. package/src/ox-select.ts +12 -3
  145. package/stories/ox-checkbox.stories.ts +69 -0
  146. package/stories/ox-input-3dish.stories.ts +73 -0
  147. package/stories/ox-input-barcode.stories.ts +76 -0
  148. package/stories/ox-input-code.stories.ts_ +51 -0
  149. package/stories/ox-input-crontab.stories.ts +51 -0
  150. package/stories/ox-input-duration.stories.ts +51 -0
  151. package/stories/ox-input-file.stories.ts +77 -0
  152. package/stories/ox-input-key-values.stories.ts +64 -0
  153. package/stories/ox-input-multiple-colors.stories.ts +178 -0
  154. package/stories/ox-input-options.stories.ts +47 -0
  155. package/stories/ox-input-partition-keys.stories.ts +51 -0
  156. package/stories/ox-input-range.stories.ts +45 -0
  157. package/stories/ox-input-search.stories.ts +47 -0
  158. package/stories/ox-input-unit.stories.ts +66 -0
  159. package/stories/ox-input-value-map.stories.ts +58 -0
  160. package/stories/ox-input-value-ranges.stories.ts +58 -0
  161. package/stories/ox-input-work-shift.stories.ts +73 -0
  162. package/stories/ox-select.stories.ts +101 -0
  163. package/themes/app-theme.css +142 -0
  164. package/themes/common-grist-styles.ts +110 -0
  165. package/themes/input-theme.css +19 -0
  166. package/xliff/en.xlf +24 -0
  167. package/xliff/ko.xlf +32 -0
  168. package/xliff/ms.xlf +24 -0
  169. package/xliff/zh.xlf +24 -0
  170. package/dist/stories/index.stories.js +0 -33
  171. package/dist/stories/index.stories.js.map +0 -1
  172. package/stories/index.stories.ts +0 -52
@@ -16,21 +16,37 @@ export class OxInput3Dish extends OxFormField {
16
16
  css`
17
17
  :host {
18
18
  display: grid;
19
- grid-template-columns: repeat(4, minmax(50px, 1fr));
20
- grid-gap: 5px;
21
- grid-auto-rows: minmax(24px, auto);
22
- }
23
-
24
- :host > * {
25
- grid-column: span 1;
19
+ grid-template-columns: repeat(7, minmax(50px, 1fr));
20
+ grid-gap: var(--margin-default);
26
21
  }
27
22
 
28
23
  label {
29
24
  text-align: right;
25
+ align-self: center;
26
+ font: var(--label-font);
27
+ color: var(--label-color);
28
+ text-transform: var(--label-text-transform);
29
+ grid-column: span 1;
30
30
  }
31
31
 
32
32
  span {
33
+ grid-column: span 2;
33
34
  text-align: center;
35
+ font: var(--label-font);
36
+ color: var(--legend-color);
37
+ }
38
+
39
+ input {
40
+ grid-column: span 2;
41
+ border: 0;
42
+ border-bottom: var(--border-dark-color);
43
+ padding: var(--input-padding);
44
+ font: var(--input-font);
45
+ color: var(--primary-text-color);
46
+ }
47
+ input:focus {
48
+ outline: none;
49
+ border-bottom: 1px solid var(--primary-color);
34
50
  }
35
51
  `
36
52
  ]
@@ -154,7 +170,7 @@ export class OxInput3Dish extends OxFormField {
154
170
 
155
171
  render() {
156
172
  return html`
157
- <span></span> <span>${msg('x-axes')}</span>
173
+ <label></label> <span>${msg('x-axes')}</span>
158
174
  <span>${msg('y-axes')}</span>
159
175
  <span>${msg('z-axes')}</span>
160
176
 
@@ -3,9 +3,10 @@ import '@operato/popup/ox-popup.js'
3
3
  import { css, html } from 'lit'
4
4
  import { customElement, property, query, state } from 'lit/decorators.js'
5
5
 
6
+ import { OxPopup } from '@operato/popup'
6
7
  import { BrowserMultiFormatReader } from '@zxing/library'
8
+
7
9
  import { OxFormField } from './ox-form-field.js'
8
- import { OxPopup } from '@operato/popup'
9
10
 
10
11
  const barcodeIcon = `data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAYBAMAAAAfR1CMAAADKGlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS42LWMxNDUgNzkuMTYzNDk5LCAyMDE4LzA4LzEzLTE2OjQwOjIyICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOnhtcE1NPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvbW0vIiB4bWxuczpzdFJlZj0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL3NUeXBlL1Jlc291cmNlUmVmIyIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgQ0MgMjAxOSAoTWFjaW50b3NoKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDpFNjM4RURDQkQ1OUExMUU5QkExMkQ4NUY3NkMxNzBFOSIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDpFNjM4RURDQ0Q1OUExMUU5QkExMkQ4NUY3NkMxNzBFOSI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkU2MzhFREM5RDU5QTExRTlCQTEyRDg1Rjc2QzE3MEU5IiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkU2MzhFRENBRDU5QTExRTlCQTEyRDg1Rjc2QzE3MEU5Ii8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+55pr/QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAAkUExURQAAAEdwTAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEus/7UCWQwAAAALdFJOU9YAg3wKBFBDSz9PnvQNDgAAAE9JREFUGNNjEEQFDKLJSnCOklkgg9QUJFn3RgZhRyS+iCGDEIp2RSBfQICRkRGIgTSQL4jCF6ScvxsZYOFT2T50/6D7Fz080MMLPTzRwhsAHVspfelur08AAAAASUVORK5CYII=`
11
12
 
@@ -18,9 +19,6 @@ export class OxInputBarcode extends OxFormField {
18
19
  align-items: center;
19
20
  border: none;
20
21
  overflow: hidden;
21
- background-color: #fff;
22
-
23
- padding: var(--custom-input-barcode-field-padding) !important;
24
22
  }
25
23
 
26
24
  * {
@@ -32,23 +30,26 @@ export class OxInputBarcode extends OxFormField {
32
30
  }
33
31
 
34
32
  input {
35
- flex: 1 !important;
36
- border: none;
37
- font: var(--custom-input-barcode-field-font);
38
- width: 10px;
39
- flex-grow: 1;
33
+ flex: 1;
34
+ border: 0;
35
+ border-bottom: var(--border-dark-color);
36
+ padding: var(--input-padding);
37
+ padding-right: 35px;
38
+ font: var(--input-font);
39
+ color: var(--primary-text-color);
40
+ }
41
+ input:focus {
42
+ outline: none;
43
+ border-bottom: 1px solid var(--primary-color);
40
44
  }
41
45
 
42
46
  #scan-button {
43
47
  display: block;
48
+ position: relative;
49
+ margin-left: -30px;
44
50
  width: 30px;
45
- height: 100%;
46
- min-height: 24px;
47
51
  border: none;
48
- background-color: transparent;
49
- background-repeat: no-repeat;
50
- background-position: center;
51
- background-image: var(--barcodescan-input-button-icon);
52
+ background: var(--barcodescan-input-button-icon) no-repeat center center;
52
53
  }
53
54
 
54
55
  #scan-button[hidden] {
@@ -84,6 +85,8 @@ export class OxInputBarcode extends OxFormField {
84
85
  @property({ type: Boolean }) scannable?: boolean
85
86
  @property({ attribute: 'without-enter', type: Boolean }) withoutEnter?: boolean
86
87
  @property({ type: String }) declare value?: string
88
+ @property({ attribute: 'english-only', type: Boolean }) englishOnly?: boolean
89
+ @property({ attribute: 'select-over-change', type: Boolean }) selectOverChange?: boolean
87
90
 
88
91
  @state() stream?: MediaStream
89
92
  @state() reader?: BrowserMultiFormatReader
@@ -123,9 +126,8 @@ export class OxInputBarcode extends OxFormField {
123
126
  <input
124
127
  type="text"
125
128
  .value=${this.value || ''}
126
- maxlength="50"
127
- @change=${(e: Event) => this.onChange(e)}
128
- @keypress=${(e: Event) => this.onChange(e)}
129
+ @change=${(e: Event) => this.onInputChange(e)}
130
+ @keydown=${(e: KeyboardEvent) => this.onInputKeyDown(e)}
129
131
  />
130
132
  <button
131
133
  ?hidden=${!this.scannable}
@@ -145,13 +147,52 @@ export class OxInputBarcode extends OxFormField {
145
147
  `
146
148
  }
147
149
 
148
- onChange(e: Event) {
150
+ onInputChange(e: Event) {
149
151
  e.stopPropagation()
150
- this.value = (e.target as HTMLInputElement)?.value
152
+
153
+ if (this.englishOnly) {
154
+ /* englishOnly 인 경우에는 멀티바이트 문자들을 모두 제거한다. */
155
+ this.value = this.input.value = this.input.value?.replace(/[^\x00-\x7F]/g, '')
156
+ } else {
157
+ this.value = this.input.value
158
+ }
159
+
160
+ if (this.selectOverChange) {
161
+ this.input.select()
162
+ }
163
+
151
164
  //@ts-ignore
152
165
  this.dispatchEvent(new e.constructor(e.type, e))
153
166
  }
154
167
 
168
+ onInputKeyDown(e: KeyboardEvent) {
169
+ if (this.englishOnly && !e.metaKey && !e.ctrlKey && !e.altKey && /^(Digit|Key)/.test(e.code)) {
170
+ e.stopPropagation()
171
+ e.preventDefault()
172
+
173
+ /* englishOnly 인 경우에 문자와 숫자들은 여기에서 처리한다. 멀티바이트 문자들이 대부분 알파벳과 숫자 키보드의 자모음을 조합하므로, ... */
174
+ switch (true) {
175
+ case /^Key/.test(e.code):
176
+ var key = e.shiftKey ? e.code.charAt(3) : e.code.charAt(3).toLowerCase()
177
+ break
178
+ case /^Digit/.test(e.code):
179
+ var key = e.code.charAt(5)
180
+ break
181
+ default:
182
+ var key = ''
183
+ }
184
+
185
+ const value = this.input.value
186
+
187
+ const start = this.input.selectionStart || 0
188
+ const end = this.input.selectionEnd || 0
189
+
190
+ this.input.value = [value.substring(0, start), key, value.substring(end)].join('')
191
+
192
+ this.input.selectionEnd = this.input.selectionStart = start + 1
193
+ }
194
+ }
195
+
155
196
  async scan(e: MouseEvent) {
156
197
  try {
157
198
  this.popup.open({})
@@ -7,9 +7,10 @@ import '@operato/color-picker/paper-color-picker.js'
7
7
  import { css, html } from 'lit'
8
8
  import { customElement, property } from 'lit/decorators.js'
9
9
 
10
- import { OxFormField } from './ox-form-field'
11
10
  import { tinycolor } from '@thebespokepixel/es-tinycolor'
12
11
 
12
+ import { OxFormField } from './ox-form-field'
13
+
13
14
  /**
14
15
  색상을 입력하는데 사용되는 입력 컴포넌트이다.
15
16
  화면상에는 두개의 입력 필드가 보이며, 하나는 색상값을 키보드로 직접 입력하는 입력 픽드이며,
@@ -180,18 +181,24 @@ export class OxInputColor extends OxFormField {
180
181
  }
181
182
 
182
183
  input[type='text'] {
183
- padding-right: 24px;
184
184
  width: 100%;
185
- height: 100%;
186
- box-sizing: border-box;
187
- border: 1px solid rgba(0, 0, 0, 0.2);
185
+ border: 0;
186
+ border-bottom: var(--border-dark-color);
187
+ padding: var(--input-padding);
188
+ font: var(--input-font);
189
+ color: var(--primary-text-color);
190
+ padding-right: 35px;
191
+ }
192
+ input:focus {
193
+ outline: none;
194
+ border-bottom: 1px solid var(--primary-color);
188
195
  }
189
196
 
190
197
  a {
191
198
  -webkit-appearance: none;
192
199
  display: flex;
193
200
  position: absolute;
194
- width: 24px;
201
+ width: 35px;
195
202
  height: 100%;
196
203
  box-sizing: border-box;
197
204
  align-items: center;
@@ -199,11 +206,10 @@ export class OxInputColor extends OxFormField {
199
206
  }
200
207
 
201
208
  span {
202
- width: 18px;
203
- height: 100%;
204
- max-height: 18px;
205
- border-radius: 10%;
206
- border: 1px solid #eee;
209
+ width: 80%;
210
+ height: 60%;
211
+ border: var(--border-dark-color);
212
+ border-radius: var(--border-radius);
207
213
  }
208
214
 
209
215
  span.transparent {
@@ -84,7 +84,6 @@ export class OxInputCrontab extends OxFormField {
84
84
  width: 100%;
85
85
  height: 100%;
86
86
  border: 0;
87
- background-color: var(--main-section-background-color);
88
87
  }
89
88
 
90
89
  :host * {
@@ -118,32 +117,36 @@ export class OxInputCrontab extends OxFormField {
118
117
  grid-column: 4 / span 3;
119
118
  width: 100%;
120
119
  height: 100%;
121
- font: normal 0.9em var(--theme-font);
120
+ padding: var(--input-padding);
121
+ border: 0;
122
+ border-bottom: var(--border-dark-color);
122
123
  text-transform: capitalize;
123
- border-radius: var(--border-radius);
124
- border: var(--border-dark-color);
124
+ font: var(--label-font);
125
+ color: var(--label-color);
125
126
  }
126
127
 
127
128
  input {
128
129
  width: 100%;
129
130
  margin-top: var(--margin-default);
130
131
  padding: 5px;
131
- border-radius: var(--border-radius);
132
- border: var(--border-dark-color);
133
- font: normal 1em var(--theme-font);
132
+ border: 0;
133
+ border-bottom: var(--border-dark-color);
134
+ padding: var(--input-padding);
135
+ font: var(--input-font);
136
+ color: var(--primary-text-color);
134
137
  }
135
138
  input:focus {
136
- border: 1px solid var(--primary-color);
139
+ outline: none;
140
+ border-bottom: 1px solid var(--primary-color);
137
141
  }
138
142
 
139
143
  input:invalid {
140
- border: 1px solid var(--status-danger-color);
144
+ border-bottom: 1px solid var(--status-danger-color);
141
145
  color: var(--status-danger-color);
142
146
  }
143
147
 
144
148
  label {
145
149
  width: 100%;
146
- height: 100%;
147
150
  font: normal 0.8em var(--theme-font);
148
151
  color: var(--primary-color);
149
152
  }
@@ -370,6 +373,23 @@ export class OxInputCrontab extends OxFormField {
370
373
  `
371
374
  )}
372
375
  </div>
376
+ <button
377
+ id="clear"
378
+ @click=${(e: Event) => {
379
+ e.preventDefault()
380
+ e.stopPropagation()
381
+ this.value = ''
382
+ this.dispatchEvent(
383
+ new CustomEvent('change', {
384
+ bubbles: true,
385
+ composed: true,
386
+ detail: this.value
387
+ })
388
+ )
389
+ }}
390
+ >
391
+ Clear
392
+ </button>
373
393
  </form>
374
394
  `
375
395
  }
@@ -0,0 +1,143 @@
1
+ import '@material/mwc-button'
2
+
3
+ import { css, html } from 'lit'
4
+ import { customElement, property, query } from 'lit/decorators.js'
5
+
6
+ import { i18next } from '@operato/i18n'
7
+
8
+ import { OxFormField } from './ox-form-field'
9
+
10
+ @customElement('ox-input-duration')
11
+ export class OxInputDuration extends OxFormField {
12
+ static styles = css`
13
+ :host {
14
+ display: block;
15
+ width: 100%;
16
+ height: 100%;
17
+ }
18
+
19
+ :host * {
20
+ box-sizing: border-box;
21
+ }
22
+
23
+ :host *:focus {
24
+ outline: none;
25
+ }
26
+
27
+ form {
28
+ width: 100%;
29
+ height: 100%;
30
+ justify-content: center;
31
+ }
32
+
33
+ input {
34
+ margin-top: var(--margin-default);
35
+ padding: 5px;
36
+ border: 0;
37
+ border-bottom: var(--border-dark-color);
38
+ padding: var(--input-padding);
39
+ font: var(--input-font);
40
+ color: var(--primary-text-color);
41
+ }
42
+
43
+ input:focus {
44
+ outline: none;
45
+ border-bottom: 1px solid var(--primary-color);
46
+ }
47
+
48
+ input:invalid {
49
+ border-bottom: 1px solid var(--status-danger-color);
50
+ color: var(--status-danger-color);
51
+ }
52
+
53
+ label {
54
+ width: 100%;
55
+ font: normal 0.8em var(--theme-font);
56
+ color: var(--primary-color);
57
+ }
58
+ `
59
+
60
+ @property({ type: Number }) declare value?: number
61
+
62
+ render() {
63
+ var d = Number(this.value || 0)
64
+
65
+ const days = Math.floor(d / (3600 * 24))
66
+ d -= days * 24 * 3600
67
+ const hours = Math.floor(d / 3600)
68
+ d -= hours * 3600
69
+ const minutes = Math.floor(d / 60)
70
+ const seconds = d - minutes * 60
71
+
72
+ return html`
73
+ <form @change=${this.onChange.bind(this)}>
74
+ <input id="days" type="number" .value=${days} pattern="\\d*" />
75
+ <label for="days">${i18next.t('label.days')}</label>
76
+
77
+ <input id="hours" type="number" .value=${hours} pattern="[01]?\\d|2[0-3]" />
78
+ <label for="hour">${i18next.t('label.hours')}</label>
79
+
80
+ <input id="minutes" type="number" .value=${minutes} pattern="[0-5]?\\d" />
81
+ <label for="minute">${i18next.t('label.minutes')}</label>
82
+
83
+ <input id="seconds" type="number" .value=${seconds} pattern="[0-5]?\\d" />
84
+ <label for="second">${i18next.t('label.seconds')}</label>
85
+
86
+ <button
87
+ type="button"
88
+ @click=${(e: Event) => {
89
+ e.preventDefault()
90
+ e.stopPropagation()
91
+
92
+ this.value = 0
93
+
94
+ this.dispatchEvent(
95
+ new CustomEvent('change', {
96
+ bubbles: true,
97
+ composed: true,
98
+ detail: this.value
99
+ })
100
+ )
101
+ }}
102
+ >
103
+ Clear
104
+ </button>
105
+ </form>
106
+ `
107
+ }
108
+
109
+ firstUpdated() {
110
+ ;(this.renderRoot.querySelector('input') as HTMLInputElement).focus()
111
+ }
112
+
113
+ @query('#days') days!: HTMLInputElement
114
+ @query('#hours') hours!: HTMLInputElement
115
+ @query('#minutes') minutes!: HTMLInputElement
116
+ @query('#seconds') seconds!: HTMLInputElement
117
+
118
+ onChange(e: Event) {
119
+ e.stopPropagation()
120
+
121
+ var form = this.renderRoot.querySelector('form') as HTMLFormElement
122
+ var valid = form.checkValidity()
123
+ if (!valid) {
124
+ form.reportValidity()
125
+ return
126
+ }
127
+
128
+ const days = Number(this.days.value)
129
+ const hours = Number(this.hours.value)
130
+ const minutes = Number(this.minutes.value)
131
+ const seconds = Number(this.seconds.value)
132
+
133
+ this.value = (days || 0) * 24 * 60 * 60 + (hours || 0) * 60 * 60 + (minutes || 0) * 60 + (seconds || 0)
134
+
135
+ this.dispatchEvent(
136
+ new CustomEvent('change', {
137
+ bubbles: true,
138
+ composed: true,
139
+ detail: this.value
140
+ })
141
+ )
142
+ }
143
+ }
@@ -1,11 +1,12 @@
1
1
  import '@material/mwc-icon'
2
2
 
3
- import { PropertyValues, css, html } from 'lit'
3
+ import { css, html, PropertyValues } from 'lit'
4
4
  import { customElement, property, query } from 'lit/decorators.js'
5
5
 
6
+ import { ScrollbarStyles } from '@operato/styles'
6
7
  import { FileDropHelper } from '@operato/utils'
8
+
7
9
  import { OxFormField } from './ox-form-field.js'
8
- import { ScrollbarStyles } from '@operato/styles'
9
10
 
10
11
  @customElement('ox-input-file')
11
12
  export class OxInputFile extends OxFormField {
@@ -85,9 +86,9 @@ export class OxInputFile extends OxFormField {
85
86
 
86
87
  @property({ type: Boolean }) multiple?: boolean
87
88
  @property({ type: String }) accept?: string
88
- @property({ type: String }) icon?: string
89
+ @property({ type: String }) icon?: string = 'upload'
89
90
  @property({ type: String }) label?: string
90
- @property({ type: String }) description?: string
91
+ @property({ type: String }) description?: string = 'drop files here!'
91
92
  @property({ type: Boolean, reflect: true, attribute: 'hide-filelist' })
92
93
  hideFileList: boolean = false
93
94
  @property({ type: Boolean, reflect: true, attribute: 'attach-filelist' })
@@ -99,9 +100,9 @@ export class OxInputFile extends OxFormField {
99
100
  var files: File[] = this.value || []
100
101
 
101
102
  return html`
102
- <mwc-icon>upload</mwc-icon>
103
+ <mwc-icon>${this.icon || 'upload'}</mwc-icon>
103
104
 
104
- <span>drop files here!</span>
105
+ <span>${this.description || 'drop files here!'}</span>
105
106
 
106
107
  <input
107
108
  id="input-file"