@operato/input 1.0.0-beta.10 → 1.0.0-beta.13

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 (117) hide show
  1. package/.storybook/main.js +2 -2
  2. package/.storybook/server.mjs +4 -4
  3. package/CHANGELOG.md +41 -0
  4. package/demo/index-multiple-colors.html +4 -1
  5. package/demo/index-partition-keys.html +2 -5
  6. package/demo/index.html +4 -0
  7. package/dist/src/locales/en.d.ts +8 -0
  8. package/dist/src/locales/en.js +8 -0
  9. package/dist/src/locales/en.js.map +1 -1
  10. package/dist/src/locales/ko.d.ts +8 -0
  11. package/dist/src/locales/ko.js +8 -0
  12. package/dist/src/locales/ko.js.map +1 -1
  13. package/dist/src/locales/ms.d.ts +8 -0
  14. package/dist/src/locales/ms.js +8 -0
  15. package/dist/src/locales/ms.js.map +1 -1
  16. package/dist/src/locales/zh.d.ts +8 -0
  17. package/dist/src/locales/zh.js +8 -0
  18. package/dist/src/locales/zh.js.map +1 -1
  19. package/dist/src/ox-input-3dish.js +24 -8
  20. package/dist/src/ox-input-3dish.js.map +1 -1
  21. package/dist/src/ox-input-color.js +16 -11
  22. package/dist/src/ox-input-color.js.map +1 -1
  23. package/dist/src/ox-input-crontab.js +13 -10
  24. package/dist/src/ox-input-crontab.js.map +1 -1
  25. package/dist/src/ox-input-multiple-colors.d.ts +1 -0
  26. package/dist/src/ox-input-multiple-colors.js +29 -21
  27. package/dist/src/ox-input-multiple-colors.js.map +1 -1
  28. package/dist/src/ox-input-options.d.ts +1 -0
  29. package/dist/src/ox-input-options.js +54 -14
  30. package/dist/src/ox-input-options.js.map +1 -1
  31. package/dist/src/ox-input-partition-keys.d.ts +1 -0
  32. package/dist/src/ox-input-partition-keys.js +51 -23
  33. package/dist/src/ox-input-partition-keys.js.map +1 -1
  34. package/dist/src/ox-input-search.js +7 -2
  35. package/dist/src/ox-input-search.js.map +1 -1
  36. package/dist/src/ox-input-unit.d.ts +17 -0
  37. package/dist/src/ox-input-unit.js +112 -0
  38. package/dist/src/ox-input-unit.js.map +1 -0
  39. package/dist/src/ox-input-work-shift.js +19 -17
  40. package/dist/src/ox-input-work-shift.js.map +1 -1
  41. package/dist/stories/ox-checkbox.stories.d.ts +39 -0
  42. package/dist/stories/ox-checkbox.stories.js +44 -0
  43. package/dist/stories/ox-checkbox.stories.js.map +1 -0
  44. package/dist/stories/ox-input-3dish.stories.d.ts +26 -0
  45. package/dist/stories/ox-input-3dish.stories.js +59 -0
  46. package/dist/stories/ox-input-3dish.stories.js.map +1 -0
  47. package/dist/stories/{index.stories.d.ts → ox-input-barcode.stories.d.ts} +11 -11
  48. package/dist/stories/ox-input-barcode.stories.js +22 -0
  49. package/dist/stories/ox-input-barcode.stories.js.map +1 -0
  50. package/dist/stories/ox-input-conntab.stories.d.ts +26 -0
  51. package/dist/stories/ox-input-conntab.stories.js +37 -0
  52. package/dist/stories/ox-input-conntab.stories.js.map +1 -0
  53. package/dist/stories/ox-input-multiple-colors.stories.d.ts +20 -0
  54. package/dist/stories/ox-input-multiple-colors.stories.js +167 -0
  55. package/dist/stories/ox-input-multiple-colors.stories.js.map +1 -0
  56. package/dist/stories/ox-input-options.stories.d.ts +25 -0
  57. package/dist/stories/ox-input-options.stories.js +33 -0
  58. package/dist/stories/ox-input-options.stories.js.map +1 -0
  59. package/dist/stories/ox-input-partition-keys.stories.d.ts +27 -0
  60. package/dist/stories/ox-input-partition-keys.stories.js +55 -0
  61. package/dist/stories/ox-input-partition-keys.stories.js.map +1 -0
  62. package/dist/stories/ox-input-range.stories.d.ts +37 -0
  63. package/dist/stories/ox-input-range.stories.js +25 -0
  64. package/dist/stories/ox-input-range.stories.js.map +1 -0
  65. package/dist/stories/ox-input-search.stories.d.ts +29 -0
  66. package/dist/stories/ox-input-search.stories.js +28 -0
  67. package/dist/stories/ox-input-search.stories.js.map +1 -0
  68. package/dist/stories/ox-input-unit.stories.d.ts +40 -0
  69. package/dist/stories/ox-input-unit.stories.js +41 -0
  70. package/dist/stories/ox-input-unit.stories.js.map +1 -0
  71. package/dist/stories/ox-input-work-shift.stories.d.ts +26 -0
  72. package/dist/stories/ox-input-work-shift.stories.js +59 -0
  73. package/dist/stories/ox-input-work-shift.stories.js.map +1 -0
  74. package/dist/stories/ox-select.stories.d.ts +30 -0
  75. package/dist/stories/ox-select.stories.js +82 -0
  76. package/dist/stories/ox-select.stories.js.map +1 -0
  77. package/dist/themes/common-grist-styles.d.ts +1 -0
  78. package/dist/themes/common-grist-styles.js +110 -0
  79. package/dist/themes/common-grist-styles.js.map +1 -0
  80. package/dist/tsconfig.tsbuildinfo +1 -1
  81. package/package.json +11 -11
  82. package/src/locales/en.ts +8 -0
  83. package/src/locales/ko.ts +8 -0
  84. package/src/locales/ms.ts +8 -0
  85. package/src/locales/zh.ts +8 -0
  86. package/src/ox-input-3dish.ts +24 -8
  87. package/src/ox-input-color.ts +17 -11
  88. package/src/ox-input-crontab.ts +13 -10
  89. package/src/ox-input-multiple-colors.ts +29 -21
  90. package/src/ox-input-options.ts +53 -13
  91. package/src/ox-input-partition-keys.ts +51 -22
  92. package/src/ox-input-search.ts +7 -2
  93. package/src/ox-input-unit.ts +112 -0
  94. package/src/ox-input-work-shift.ts +20 -17
  95. package/stories/ox-checkbox.stories.ts +69 -0
  96. package/stories/ox-input-3dish.stories.ts +73 -0
  97. package/stories/ox-input-barcode.stories.ts +38 -0
  98. package/stories/ox-input-code.stories.ts_ +71 -0
  99. package/stories/ox-input-conntab.stories.ts +51 -0
  100. package/stories/ox-input-multiple-colors.stories.ts +178 -0
  101. package/stories/ox-input-options.stories.ts +47 -0
  102. package/stories/ox-input-partition-keys.stories.ts +71 -0
  103. package/stories/ox-input-range.stories.ts +42 -0
  104. package/stories/ox-input-search.stories.ts +43 -0
  105. package/stories/ox-input-unit.stories.ts +65 -0
  106. package/stories/ox-input-work-shift.stories.ts +73 -0
  107. package/stories/ox-select.stories.ts +100 -0
  108. package/themes/app-theme.css +142 -0
  109. package/themes/common-grist-styles.ts +110 -0
  110. package/themes/input-theme.css +19 -0
  111. package/xliff/en.xlf +24 -0
  112. package/xliff/ko.xlf +32 -0
  113. package/xliff/ms.xlf +24 -0
  114. package/xliff/zh.xlf +24 -0
  115. package/dist/stories/index.stories.js +0 -33
  116. package/dist/stories/index.stories.js.map +0 -1
  117. 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
 
@@ -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
  }
@@ -3,6 +3,7 @@
3
3
  */
4
4
 
5
5
  import './ox-input-color.js'
6
+ import '@material/mwc-icon'
6
7
 
7
8
  import { css, html } from 'lit'
8
9
  import { customElement, property, query, queryAll } from 'lit/decorators.js'
@@ -28,29 +29,38 @@ export class OxInputMultipleColors extends OxFormField {
28
29
  :host {
29
30
  display: inline-block;
30
31
  }
31
-
32
32
  #colors-container > div {
33
33
  display: grid;
34
- grid-template-columns: 22px 1fr 22px;
35
- grid-gap: 5px;
34
+ grid-template-columns: 34px 1fr 34px;
35
+ grid-gap: var(--margin-default);
36
36
  align-items: center;
37
37
  justify-content: left;
38
+ margin-bottom: var(--margin-narrow);
38
39
  }
39
40
 
40
41
  ox-input-color {
41
- height: 25px;
42
42
  width: 100%;
43
43
  }
44
44
 
45
- input[type='button'] {
46
- width: 22px;
47
- height: 25px;
48
- border: 1px solid rgba(0, 0, 0, 0.15);
49
- padding-top: 0px;
50
- padding-bottom: 2px;
51
- background-color: #f1f2f4;
52
- color: #8f9192;
53
- font-size: 16px;
45
+ button {
46
+ height: 100%;
47
+ border: var(--button-border);
48
+ border-radius: var(--border-radius);
49
+ background-color: var(--button-background-color);
50
+ padding: var(--padding-narrow) var(--padding-default);
51
+ line-height: 0.8;
52
+ color: var(--button-color);
53
+ cursor: pointer;
54
+ }
55
+ button mwc-icon {
56
+ font-size: var(--fontsize-default);
57
+ }
58
+ button:focus,
59
+ button:hover,
60
+ button:active {
61
+ border: var(--button-activ-border);
62
+ background-color: var(--button-background-focus-color);
63
+ color: var(--theme-white-color);
54
64
  }
55
65
  `
56
66
 
@@ -69,18 +79,16 @@ export class OxInputMultipleColors extends OxFormField {
69
79
  ${(this.value || []).map(
70
80
  (item, index) => html`
71
81
  <div>
72
- <input type="button" value="+" @click=${() => this._appendEditorColor()} data-index=${index} />
73
-
82
+ <button @click=${() => this._appendEditorColor()} data-index=${index}>
83
+ <mwc-icon>add</mwc-icon>
84
+ </button>
74
85
  <ox-input-color .value=${item}> </ox-input-color>
75
86
 
76
87
  ${(this.value || []).length > 1
77
88
  ? html`
78
- <input
79
- type="button"
80
- value="-"
81
- @click=${(e: Event) => this._removeEditorColor(e)}
82
- data-index=${index}
83
- />
89
+ <button @click=${(e: Event) => this._removeEditorColor(e)} data-index=${index}>
90
+ <mwc-icon>remove</mwc-icon>
91
+ </button>
84
92
  `
85
93
  : html``}
86
94
  </div>
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * @license Copyright © HatioLab Inc. All rights reserved.
3
3
  */
4
+ import '@material/mwc-icon'
4
5
 
5
6
  import { css, html } from 'lit'
6
7
  import { customElement, property } from 'lit/decorators.js'
@@ -12,23 +13,58 @@ type Option = { text: string; value: string }
12
13
  @customElement('ox-input-options')
13
14
  export class OxInputOptions extends OxFormField {
14
15
  static styles = css`
15
- div {
16
- display: grid;
17
- grid-template-columns: repeat(10, 1fr);
18
- grid-gap: 5px;
19
- grid-auto-rows: minmax(24px, auto);
16
+ :host {
17
+ display: flex;
18
+ flex-direction: column;
19
+ overflow: hidden;
20
+ margin-bottom: var(--margin-wide);
20
21
  }
21
22
 
22
- input[data-text] {
23
- grid-column: span 5;
23
+ div {
24
+ display: flex;
25
+ flex-flow: row nowrap;
26
+ gap: var(--margin-default);
27
+ margin-bottom: var(--margin-narrow);
24
28
  }
25
29
 
26
- input[data-value] {
27
- grid-column: span 4;
30
+ button {
31
+ border: var(--button-border);
32
+ border-radius: var(--border-radius);
33
+ background-color: var(--button-background-color);
34
+ padding: var(--padding-narrow) var(--padding-default);
35
+ line-height: 0.8;
36
+ color: var(--button-color);
37
+ cursor: pointer;
38
+ }
39
+ button + button {
40
+ margin-left: -5px;
41
+ }
42
+ button mwc-icon {
43
+ font-size: var(--fontsize-default);
44
+ }
45
+ button:focus,
46
+ button:hover,
47
+ button:active {
48
+ border: var(--button-activ-border);
49
+ background-color: var(--button-background-focus-color);
50
+ color: var(--theme-white-color);
28
51
  }
29
52
 
30
- button {
31
- grid-column: span 1;
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
+ }
61
+ input:focus {
62
+ outline: none;
63
+ border-bottom: 1px solid var(--primary-color);
64
+ }
65
+ button.hidden {
66
+ opacity: 0;
67
+ cursor: default;
32
68
  }
33
69
  `
34
70
 
@@ -47,7 +83,9 @@ export class OxInputOptions extends OxFormField {
47
83
  <div data-record="">
48
84
  <input type="text" data-text="" placeholder="text" .value=${item.text} />
49
85
  <input type="text" data-value="" placeholder="value" .value=${item.value} />
50
- <button class="record-action" @click=${(e: MouseEvent) => this._delete(e)} tabindex="-1">-</button>
86
+ <button class="record-action" @click=${(e: MouseEvent) => this._delete(e)} tabindex="-1">
87
+ <mwc-icon>remove</mwc-icon>
88
+ </button>
51
89
  </div>
52
90
  `
53
91
  )}
@@ -55,7 +93,9 @@ export class OxInputOptions extends OxFormField {
55
93
  <div data-record-new="">
56
94
  <input type="text" data-text="" placeholder="text" value="" />
57
95
  <input type="text" data-value="" placeholder="value" value="" @change=${(e: Event) => this._add()} />
58
- <button class="record-action" @click=${(e: MouseEvent) => this._add()} tabindex="-1">+</button>
96
+ <button class="record-action" @click=${(e: MouseEvent) => this._add()} tabindex="-1">
97
+ <mwc-icon>add</mwc-icon>
98
+ </button>
59
99
  </div>
60
100
  `
61
101
  }
@@ -2,6 +2,8 @@
2
2
  * @license Copyright © HatioLab Inc. All rights reserved.
3
3
  */
4
4
 
5
+ import '@material/mwc-icon'
6
+
5
7
  import { css, html } from 'lit'
6
8
  import { customElement, property, queryAll } from 'lit/decorators.js'
7
9
 
@@ -25,38 +27,55 @@ export class OxInputPartitionKeys extends OxFormField {
25
27
  :host {
26
28
  display: flex;
27
29
  flex-direction: column;
28
- align-content: center;
29
-
30
- width: 100%;
31
30
  overflow: hidden;
32
- border: 1px solid #ccc;
31
+ margin-bottom: var(--margin-wide);
33
32
  }
34
33
 
35
34
  div {
36
35
  display: flex;
37
36
  flex-flow: row nowrap;
38
- align-items: center;
39
-
40
- border-bottom: 1px solid #c0c0c0;
37
+ gap: var(--margin-default);
38
+ margin-bottom: var(--margin-narrow);
41
39
  }
42
40
 
43
- div:last-child {
44
- border-bottom: none;
41
+ button {
42
+ border: var(--button-border);
43
+ border-radius: var(--border-radius);
44
+ background-color: var(--button-background-color);
45
+ padding: var(--padding-narrow) var(--padding-default);
46
+ line-height: 0.8;
47
+ color: var(--button-color);
48
+ cursor: pointer;
45
49
  }
46
-
47
- div > * {
48
- min-width: 0px;
49
- margin: 2px;
50
- padding: 0;
50
+ button + button {
51
+ margin-left: -5px;
51
52
  }
52
-
53
- button {
54
- width: 20px;
55
- text-align: center;
53
+ button mwc-icon {
54
+ font-size: var(--fontsize-default);
55
+ }
56
+ button:focus,
57
+ button:hover,
58
+ button:active {
59
+ border: var(--button-activ-border);
60
+ background-color: var(--button-background-focus-color);
61
+ color: var(--theme-white-color);
56
62
  }
57
63
 
58
64
  input {
59
65
  flex: 1;
66
+ border: 0;
67
+ border-bottom: var(--border-dark-color);
68
+ padding: var(--input-padding);
69
+ font: var(--input-font);
70
+ color: var(--primary-text-color);
71
+ }
72
+ input:focus {
73
+ outline: none;
74
+ border-bottom: 1px solid var(--primary-color);
75
+ }
76
+ button.hidden {
77
+ opacity: 0;
78
+ cursor: default;
60
79
  }
61
80
  `
62
81
 
@@ -77,9 +96,15 @@ export class OxInputPartitionKeys extends OxFormField {
77
96
  <div data-record>
78
97
  <input type="text" data-key placeholder="key" .value=${item.key} />
79
98
  <input type="text" data-value placeholder="value" .value=${item.value} list="value-template" />
80
- <button class="record-action" @click=${(e: MouseEvent) => this._delete(e)} tabindex="-1">-</button>
81
- <button class="record-action" @click=${(e: MouseEvent) => this._up(e)} tabindex="-1">↑</button>
82
- <button class="record-action" @click=${(e: MouseEvent) => this._down(e)} tabindex="-1">↓</button>
99
+ <button class="record-action" @click=${(e: MouseEvent) => this._delete(e)} tabindex="-1">
100
+ <mwc-icon>remove</mwc-icon>
101
+ </button>
102
+ <button class="record-action" @click=${(e: MouseEvent) => this._up(e)} tabindex="-1">
103
+ <mwc-icon>arrow_upward</mwc-icon>
104
+ </button>
105
+ <button class="record-action" @click=${(e: MouseEvent) => this._down(e)} tabindex="-1">
106
+ <mwc-icon>arrow_downward</mwc-icon>
107
+ </button>
83
108
  </div>
84
109
  `
85
110
  )}
@@ -87,7 +112,11 @@ export class OxInputPartitionKeys extends OxFormField {
87
112
  <div data-record-new>
88
113
  <input type="text" data-key placeholder="key" value="" />
89
114
  <input type="text" data-value placeholder="value" value="" list="value-template" />
90
- <button class="record-action" @click=${(e: MouseEvent) => this._add()} tabindex="-1">+</button>
115
+ <button class="record-action" @click=${(e: MouseEvent) => this._add()} tabindex="-1">
116
+ <mwc-icon>add</mwc-icon>
117
+ </button>
118
+ <button class="hidden"><mwc-icon>add</mwc-icon></button>
119
+ <button class="hidden"><mwc-icon>add</mwc-icon></button>
91
120
  </div>
92
121
 
93
122
  <datalist id="value-template">
@@ -26,9 +26,14 @@ export class OxInputSearch extends OxFormField {
26
26
  background-color: transparent;
27
27
  border: 0;
28
28
  border-bottom: var(--border-dark-color);
29
- padding: var(--padding-narrow) var(--padding-narrow) 7px 25px;
30
- font-size: var(--fontsize-large);
29
+ padding: var(--input-padding);
30
+ padding-left: 25px;
31
+ font: var(--input-font);
32
+ color: var(--primary-text-color);
33
+ }
34
+ [type='text']:focus {
31
35
  outline: none;
36
+ border-bottom: 1px solid var(--primary-color);
32
37
  }
33
38
 
34
39
  mwc-icon {
@@ -0,0 +1,112 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+
5
+ import { css, html } from 'lit'
6
+ import { customElement, property, query } from 'lit/decorators.js'
7
+
8
+ import { OxFormField } from './ox-form-field'
9
+ import { OxPopupList } from '@operato/popup'
10
+
11
+ const UNIT_SYSTEMS: { [unit: string]: { [unit: string]: number } } = {
12
+ kg: {
13
+ mg: 1000000,
14
+ g: 1000,
15
+ ton: 0.001
16
+ },
17
+ rad: {
18
+ degree: 180 / Math.PI
19
+ }
20
+ }
21
+
22
+ @customElement('ox-input-unit')
23
+ export class OxInputUnit extends OxFormField {
24
+ static styles = [
25
+ css`
26
+ input {
27
+ box-sizing: border-box;
28
+ border: 1px solid rgba(0, 0, 0, 0.2);
29
+ text-align: end;
30
+ }
31
+
32
+ input::-webkit-outer-spin-button,
33
+ input::-webkit-inner-spin-button {
34
+ -webkit-appearance: none;
35
+ margin: 0;
36
+ }
37
+
38
+ input[type='number'] {
39
+ -moz-appearance: textfield;
40
+ }
41
+
42
+ div {
43
+ display: inline;
44
+ position: relative;
45
+ }
46
+ `
47
+ ]
48
+
49
+ @property({ type: String }) placeholder?: string
50
+ @property({ type: String, attribute: 'std-unit' }) stdUnit!: string
51
+ @property({ type: String, attribute: 'user-unit' }) userUnit?: string
52
+
53
+ @query('input') input!: HTMLInputElement
54
+ @query('ox-popup-list') popup!: OxPopupList
55
+
56
+ render() {
57
+ const userUnit = this.userUnit || this.stdUnit
58
+ const units = Object.keys(UNIT_SYSTEMS[this.stdUnit])
59
+ const rate = !this.userUnit || this.userUnit === this.stdUnit ? 1 : UNIT_SYSTEMS[this.stdUnit][this.userUnit] || 1
60
+
61
+ return html`
62
+ <input
63
+ type="number"
64
+ .value=${this._toUserUnit(this.value)}
65
+ placeholder=${this.placeholder}
66
+ @change=${(e: Event) => this._onChangeValue(e)}
67
+ />
68
+ <div
69
+ @click=${(e: Event) => {
70
+ const target = e.currentTarget as HTMLElement
71
+ this.popup.open({
72
+ right: 0,
73
+ top: target.offsetTop + target.offsetHeight
74
+ })
75
+ }}
76
+ >
77
+ ${userUnit}
78
+ <ox-popup-list
79
+ .value=${userUnit}
80
+ @select=${(e: CustomEvent) => {
81
+ this.userUnit = e.detail
82
+ }}
83
+ >
84
+ <div option value=${this.stdUnit}>${this.stdUnit}</div>
85
+ ${units.map(unit => html`<div option value=${unit}>${unit}</div>`)}
86
+ </ox-popup-list>
87
+ </div>
88
+ `
89
+ }
90
+
91
+ _onChangeValue(e: Event) {
92
+ this.value = this._toStdUnit(this.input.value)
93
+
94
+ this.dispatchEvent(
95
+ new CustomEvent('change', {
96
+ bubbles: true,
97
+ composed: true,
98
+ detail: this.value
99
+ })
100
+ )
101
+ }
102
+
103
+ _toUserUnit(stdValue: string | number | undefined) {
104
+ const rate = !this.userUnit || this.userUnit === this.stdUnit ? 1 : UNIT_SYSTEMS[this.stdUnit][this.userUnit] || 1
105
+ return Number(stdValue) * rate
106
+ }
107
+
108
+ _toStdUnit(userValue: string | number | undefined) {
109
+ const rate = !this.userUnit || this.userUnit === this.stdUnit ? 1 : UNIT_SYSTEMS[this.stdUnit][this.userUnit] || 1
110
+ return isNaN(Number(userValue)) ? undefined : Number(userValue) / rate
111
+ }
112
+ }
@@ -7,6 +7,8 @@ import './ox-input-color'
7
7
  import { css, html } from 'lit'
8
8
  import { customElement, property } from 'lit/decorators.js'
9
9
 
10
+ import { localized, msg } from '@lit/localize'
11
+
10
12
  import { OxFormField } from './ox-form-field.js'
11
13
 
12
14
  type WorkShift = { name: string; fromDate: number; fromTime: string; toDate: number; toTime: string }
@@ -21,6 +23,7 @@ Example:
21
23
  </ox-input-work-shift>
22
24
  */
23
25
 
26
+ @localized()
24
27
  @customElement('ox-input-work-shift')
25
28
  export class OxInputWorkShift extends OxFormField {
26
29
  static styles = css`
@@ -92,11 +95,11 @@ export class OxInputWorkShift extends OxFormField {
92
95
  render() {
93
96
  return html`
94
97
  <div data-header>
95
- <span>name</span>
96
- <span>from date</span>
97
- <span>from time</span>
98
- <span>to date</span>
99
- <span>to time</span>
98
+ <span>${msg('name')}</span>
99
+ <span>${msg('from date')}</span>
100
+ <span>${msg('from time')}</span>
101
+ <span>${msg('to date')}</span>
102
+ <span>${msg('to time')}</span>
100
103
  <empty-element></empty-element>
101
104
  </div>
102
105
 
@@ -106,16 +109,16 @@ export class OxInputWorkShift extends OxFormField {
106
109
  <input type="text" data-name .value=${item.name} required />
107
110
 
108
111
  <select data-from-date .value=${item.fromDate || 0}>
109
- <option value="-1">The day before</option>
110
- <option value="0">The day</option>
111
- <option value="1">The day after</option>
112
+ <option value="-1">${msg('The day before')}</option>
113
+ <option value="0">${msg('The day')}</option>
114
+ <option value="1">${msg('The day after')}</option>
112
115
  </select>
113
116
  <input type="time" data-from-time .value=${item.fromTime} step="1800" required />
114
117
 
115
118
  <select data-to-date .value=${item.toDate || 0}>
116
- <option value="-1">The day before</option>
117
- <option value="0">The day</option>
118
- <option value="1">The day after</option>
119
+ <option value="-1">${msg('The day before')}</option>
120
+ <option value="0">${msg('The day')}</option>
121
+ <option value="1">${msg('The day after')}</option>
119
122
  </select>
120
123
  <input type="time" data-to-time .value=${item.toTime} step="1800" required />
121
124
 
@@ -128,16 +131,16 @@ export class OxInputWorkShift extends OxFormField {
128
131
  <input type="text" data-name />
129
132
 
130
133
  <select data-from-date>
131
- <option value="-1">The day before</option>
132
- <option value="0" selected>The day</option>
133
- <option value="+1">The day after</option>
134
+ <option value="-1">${msg('The day before')}</option>
135
+ <option value="0" selected>${msg('The day')}</option>
136
+ <option value="+1">${msg('The day after')}</option>
134
137
  </select>
135
138
  <input type="time" data-from-time step="1800" />
136
139
 
137
140
  <select data-to-date>
138
- <option value="-1">The day before</option>
139
- <option value="0" selected>The day</option>
140
- <option value="+1">The day after</option>
141
+ <option value="-1">${msg('The day before')}</option>
142
+ <option value="0" selected>${msg('The day')}</option>
143
+ <option value="+1">${msg('The day after')}</option>
141
144
  </select>
142
145
  <input type="time" data-to-time step="1800" />
143
146