@operato/input 1.0.0-beta.2 → 1.0.0-beta.22
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.
- package/.storybook/main.js +2 -2
- package/.storybook/server.mjs +4 -4
- package/CHANGELOG.md +417 -0
- package/demo/index-multiple-colors.html +4 -1
- package/demo/index-partition-keys.html +2 -5
- package/demo/index-select.html +1 -1
- package/demo/index.html +4 -0
- package/dist/src/locales/en.d.ts +8 -0
- package/dist/src/locales/en.js +8 -0
- package/dist/src/locales/en.js.map +1 -1
- package/dist/src/locales/ko.d.ts +8 -0
- package/dist/src/locales/ko.js +8 -0
- package/dist/src/locales/ko.js.map +1 -1
- package/dist/src/locales/ms.d.ts +8 -0
- package/dist/src/locales/ms.js +8 -0
- package/dist/src/locales/ms.js.map +1 -1
- package/dist/src/locales/zh.d.ts +8 -0
- package/dist/src/locales/zh.js +8 -0
- package/dist/src/locales/zh.js.map +1 -1
- package/dist/src/ox-input-3dish.js +24 -8
- package/dist/src/ox-input-3dish.js.map +1 -1
- package/dist/src/ox-input-color.js +16 -11
- package/dist/src/ox-input-color.js.map +1 -1
- package/dist/src/ox-input-crontab.js +28 -10
- package/dist/src/ox-input-crontab.js.map +1 -1
- package/dist/src/ox-input-file.js +5 -3
- package/dist/src/ox-input-file.js.map +1 -1
- package/dist/src/ox-input-key-values.d.ts +41 -0
- package/dist/src/ox-input-key-values.js +233 -0
- package/dist/src/ox-input-key-values.js.map +1 -0
- package/dist/src/ox-input-multiple-colors.d.ts +1 -0
- package/dist/src/ox-input-multiple-colors.js +29 -21
- package/dist/src/ox-input-multiple-colors.js.map +1 -1
- package/dist/src/ox-input-options.d.ts +1 -0
- package/dist/src/ox-input-options.js +54 -14
- package/dist/src/ox-input-options.js.map +1 -1
- package/dist/src/ox-input-partition-keys.d.ts +1 -0
- package/dist/src/ox-input-partition-keys.js +51 -23
- package/dist/src/ox-input-partition-keys.js.map +1 -1
- package/dist/src/ox-input-range.js +35 -38
- package/dist/src/ox-input-range.js.map +1 -1
- package/dist/src/ox-input-search.d.ts +0 -1
- package/dist/src/ox-input-search.js +14 -7
- package/dist/src/ox-input-search.js.map +1 -1
- package/dist/src/ox-input-unit.d.ts +17 -0
- package/dist/src/ox-input-unit.js +122 -0
- package/dist/src/ox-input-unit.js.map +1 -0
- package/dist/src/ox-input-value-map.d.ts +2 -2
- package/dist/src/ox-input-value-map.js +1 -1
- package/dist/src/ox-input-value-map.js.map +1 -1
- package/dist/src/ox-input-value-ranges.d.ts +2 -2
- package/dist/src/ox-input-value-ranges.js.map +1 -1
- package/dist/src/ox-input-work-shift.js +77 -43
- package/dist/src/ox-input-work-shift.js.map +1 -1
- package/dist/src/ox-select.js +12 -1
- package/dist/src/ox-select.js.map +1 -1
- package/dist/stories/ox-checkbox.stories.d.ts +39 -0
- package/dist/stories/ox-checkbox.stories.js +44 -0
- package/dist/stories/ox-checkbox.stories.js.map +1 -0
- package/dist/stories/ox-input-3dish.stories.d.ts +26 -0
- package/dist/stories/ox-input-3dish.stories.js +59 -0
- package/dist/stories/ox-input-3dish.stories.js.map +1 -0
- package/dist/stories/{index.stories.d.ts → ox-input-barcode.stories.d.ts} +11 -11
- package/dist/stories/ox-input-barcode.stories.js +22 -0
- package/dist/stories/ox-input-barcode.stories.js.map +1 -0
- package/dist/stories/ox-input-conntab.stories.d.ts +26 -0
- package/dist/stories/ox-input-conntab.stories.js +37 -0
- package/dist/stories/ox-input-conntab.stories.js.map +1 -0
- package/dist/stories/ox-input-crontab.stories.d.ts +26 -0
- package/dist/stories/ox-input-crontab.stories.js +37 -0
- package/dist/stories/ox-input-crontab.stories.js.map +1 -0
- package/dist/stories/ox-input-file.stories.d.ts +49 -0
- package/dist/stories/ox-input-file.stories.js +48 -0
- package/dist/stories/ox-input-file.stories.js.map +1 -0
- package/dist/stories/ox-input-key-values.stories.d.ts +29 -0
- package/dist/stories/ox-input-key-values.stories.js +49 -0
- package/dist/stories/ox-input-key-values.stories.js.map +1 -0
- package/dist/stories/ox-input-multiple-colors.stories.d.ts +20 -0
- package/dist/stories/ox-input-multiple-colors.stories.js +167 -0
- package/dist/stories/ox-input-multiple-colors.stories.js.map +1 -0
- package/dist/stories/ox-input-options.stories.d.ts +25 -0
- package/dist/stories/ox-input-options.stories.js +33 -0
- package/dist/stories/ox-input-options.stories.js.map +1 -0
- package/dist/stories/ox-input-partition-keys.stories.d.ts +25 -0
- package/dist/stories/ox-input-partition-keys.stories.js +37 -0
- package/dist/stories/ox-input-partition-keys.stories.js.map +1 -0
- package/dist/stories/ox-input-range.stories.d.ts +37 -0
- package/dist/stories/ox-input-range.stories.js +28 -0
- package/dist/stories/ox-input-range.stories.js.map +1 -0
- package/dist/stories/ox-input-search.stories.d.ts +29 -0
- package/dist/stories/ox-input-search.stories.js +32 -0
- package/dist/stories/ox-input-search.stories.js.map +1 -0
- package/dist/stories/ox-input-unit.stories.d.ts +40 -0
- package/dist/stories/ox-input-unit.stories.js +42 -0
- package/dist/stories/ox-input-unit.stories.js.map +1 -0
- package/dist/stories/ox-input-value-map.stories copy.d.ts +35 -0
- package/dist/stories/ox-input-value-map.stories copy.js +37 -0
- package/dist/stories/ox-input-value-map.stories copy.js.map +1 -0
- package/dist/stories/ox-input-value-map.stories.d.ts +35 -0
- package/dist/stories/ox-input-value-map.stories.js +37 -0
- package/dist/stories/ox-input-value-map.stories.js.map +1 -0
- package/dist/stories/ox-input-value-range.stories.d.ts +35 -0
- package/dist/stories/ox-input-value-range.stories.js +37 -0
- package/dist/stories/ox-input-value-range.stories.js.map +1 -0
- package/dist/stories/ox-input-value-ranges.stories.d.ts +35 -0
- package/dist/stories/ox-input-value-ranges.stories.js +37 -0
- package/dist/stories/ox-input-value-ranges.stories.js.map +1 -0
- package/dist/stories/ox-input-work-shift.stories.d.ts +26 -0
- package/dist/stories/ox-input-work-shift.stories.js +59 -0
- package/dist/stories/ox-input-work-shift.stories.js.map +1 -0
- package/dist/stories/ox-select.stories.d.ts +30 -0
- package/dist/stories/ox-select.stories.js +83 -0
- package/dist/stories/ox-select.stories.js.map +1 -0
- package/dist/themes/common-grist-styles.d.ts +1 -0
- package/dist/themes/common-grist-styles.js +110 -0
- package/dist/themes/common-grist-styles.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +12 -11
- package/src/locales/en.ts +8 -0
- package/src/locales/ko.ts +8 -0
- package/src/locales/ms.ts +8 -0
- package/src/locales/zh.ts +8 -0
- package/src/ox-input-3dish.ts +24 -8
- package/src/ox-input-color.ts +17 -11
- package/src/ox-input-crontab.ts +30 -10
- package/src/ox-input-file.ts +7 -6
- package/src/ox-input-key-values.ts +270 -0
- package/src/ox-input-multiple-colors.ts +29 -21
- package/src/ox-input-options.ts +53 -13
- package/src/ox-input-partition-keys.ts +51 -22
- package/src/ox-input-range.ts +35 -38
- package/src/ox-input-search.ts +14 -8
- package/src/ox-input-unit.ts +123 -0
- package/src/ox-input-value-map.ts +2 -2
- package/src/ox-input-value-ranges.ts +2 -2
- package/src/ox-input-work-shift.ts +78 -43
- package/src/ox-select.ts +15 -3
- package/stories/ox-checkbox.stories.ts +69 -0
- package/stories/ox-input-3dish.stories.ts +73 -0
- package/stories/ox-input-barcode.stories.ts +38 -0
- package/stories/ox-input-code.stories.ts_ +51 -0
- package/stories/ox-input-crontab.stories.ts +51 -0
- package/stories/ox-input-file.stories.ts +77 -0
- package/stories/ox-input-key-values.stories.ts +64 -0
- package/stories/ox-input-multiple-colors.stories.ts +178 -0
- package/stories/ox-input-options.stories.ts +47 -0
- package/stories/ox-input-partition-keys.stories.ts +51 -0
- package/stories/ox-input-range.stories.ts +45 -0
- package/stories/ox-input-search.stories.ts +47 -0
- package/stories/ox-input-unit.stories.ts +66 -0
- package/stories/ox-input-value-map.stories.ts +58 -0
- package/stories/ox-input-value-ranges.stories.ts +58 -0
- package/stories/ox-input-work-shift.stories.ts +73 -0
- package/stories/ox-select.stories.ts +101 -0
- package/themes/app-theme.css +142 -0
- package/themes/common-grist-styles.ts +110 -0
- package/themes/input-theme.css +19 -0
- package/xliff/en.xlf +24 -0
- package/xliff/ko.xlf +32 -0
- package/xliff/ms.xlf +24 -0
- package/xliff/zh.xlf +24 -0
- package/dist/stories/index.stories.js +0 -33
- package/dist/stories/index.stories.js.map +0 -1
- package/stories/index.stories.ts +0 -52
@@ -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
|
-
|
31
|
+
margin-bottom: var(--margin-wide);
|
33
32
|
}
|
34
33
|
|
35
34
|
div {
|
36
35
|
display: flex;
|
37
36
|
flex-flow: row nowrap;
|
38
|
-
|
39
|
-
|
40
|
-
border-bottom: 1px solid #c0c0c0;
|
37
|
+
gap: var(--margin-default);
|
38
|
+
margin-bottom: var(--margin-narrow);
|
41
39
|
}
|
42
40
|
|
43
|
-
|
44
|
-
border
|
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
|
-
|
48
|
-
min-width: 0px;
|
49
|
-
margin: 2px;
|
50
|
-
padding: 0;
|
50
|
+
button + button {
|
51
|
+
margin-left: -5px;
|
51
52
|
}
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
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"
|
81
|
-
|
82
|
-
|
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"
|
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">
|
package/src/ox-input-range.ts
CHANGED
@@ -11,10 +11,9 @@ import { OxFormField } from './ox-form-field.js'
|
|
11
11
|
class OxInputRange extends OxFormField {
|
12
12
|
static styles = css`
|
13
13
|
:host {
|
14
|
-
font-size: 16px;
|
15
14
|
display: flex;
|
15
|
+
gap: var(--margin-default);
|
16
16
|
align-items: center;
|
17
|
-
padding: 1px 0;
|
18
17
|
|
19
18
|
width: 100%;
|
20
19
|
user-select: text;
|
@@ -22,15 +21,15 @@ class OxInputRange extends OxFormField {
|
|
22
21
|
|
23
22
|
input[type='number'] {
|
24
23
|
width: 48px;
|
25
|
-
|
24
|
+
border: 0;
|
25
|
+
border-bottom: var(--border-dark-color);
|
26
|
+
padding: var(--input-padding);
|
27
|
+
font: var(--input-font);
|
28
|
+
color: var(--primary-text-color);
|
26
29
|
}
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
border: none;
|
31
|
-
font-weight: 300;
|
32
|
-
background: white;
|
33
|
-
padding: 1px 2px;
|
30
|
+
input[type='number']:focus {
|
31
|
+
outline: none;
|
32
|
+
border-bottom: 1px solid var(--primary-color);
|
34
33
|
}
|
35
34
|
|
36
35
|
input[type='range'] {
|
@@ -44,40 +43,40 @@ class OxInputRange extends OxFormField {
|
|
44
43
|
}
|
45
44
|
input[type='range']::-webkit-slider-runnable-track {
|
46
45
|
width: 100%;
|
47
|
-
height:
|
48
|
-
background:
|
49
|
-
border:
|
46
|
+
height: 7px;
|
47
|
+
background-color: rgba(0, 0, 0, 0.02);
|
48
|
+
border: 1px solid rgba(0, 0, 0, 0.05);
|
50
49
|
border-radius: 5px;
|
51
50
|
}
|
52
51
|
input[type='range']::-webkit-slider-thumb {
|
53
52
|
-webkit-appearance: none;
|
54
53
|
border: none;
|
55
|
-
height:
|
56
|
-
width:
|
54
|
+
height: 16px;
|
55
|
+
width: 16px;
|
57
56
|
border-radius: 50%;
|
58
|
-
background:
|
59
|
-
margin-top: -
|
57
|
+
background: var(--primary-color);
|
58
|
+
margin-top: -6px;
|
59
|
+
box-shadow: 0px 0px 2px 1px rgba(0, 0, 0, 0.15);
|
60
60
|
}
|
61
61
|
input[type='range']:focus {
|
62
62
|
outline: none;
|
63
63
|
}
|
64
|
-
input[type='range']:focus::-webkit-slider-runnable-track {
|
65
|
-
background: black;
|
66
|
-
}
|
67
64
|
|
68
65
|
input[type='range']::-moz-range-track {
|
69
66
|
width: 100%;
|
70
|
-
height:
|
71
|
-
background:
|
72
|
-
border:
|
67
|
+
height: 7px;
|
68
|
+
background-color: rgba(0, 0, 0, 0.02);
|
69
|
+
border: 1px solid rgba(0, 0, 0, 0.05);
|
73
70
|
border-radius: 5px;
|
74
71
|
}
|
75
72
|
input[type='range']::-moz-range-thumb {
|
76
73
|
border: none;
|
77
|
-
height:
|
78
|
-
width:
|
74
|
+
height: 16px;
|
75
|
+
width: 16px;
|
79
76
|
border-radius: 50%;
|
80
|
-
background:
|
77
|
+
background: var(--primary-color);
|
78
|
+
margin-top: -6px;
|
79
|
+
box-shadow: 0px 0px 2px 1px rgba(0, 0, 0, 0.15);
|
81
80
|
}
|
82
81
|
|
83
82
|
input[type='range']:-moz-focusring {
|
@@ -87,21 +86,19 @@ class OxInputRange extends OxFormField {
|
|
87
86
|
|
88
87
|
input[type='range']::-ms-track {
|
89
88
|
width: 100%;
|
90
|
-
height:
|
91
|
-
background:
|
92
|
-
border
|
93
|
-
|
94
|
-
border: none;
|
95
|
-
outline: none;
|
89
|
+
height: 7px;
|
90
|
+
background-color: rgba(0, 0, 0, 0.02);
|
91
|
+
border: 1px solid rgba(0, 0, 0, 0.05);
|
92
|
+
border-radius: 5px;
|
96
93
|
}
|
97
94
|
input[type='range']::-ms-thumb {
|
98
|
-
height: 10px;
|
99
|
-
width: 10px;
|
100
|
-
border-radius: 50%;
|
101
|
-
background: black;
|
102
95
|
border: none;
|
103
|
-
|
104
|
-
|
96
|
+
height: 16px;
|
97
|
+
width: 16px;
|
98
|
+
border-radius: 50%;
|
99
|
+
background: var(--primary-color);
|
100
|
+
margin-top: -6px;
|
101
|
+
box-shadow: 0px 0px 2px 1px rgba(0, 0, 0, 0.15);
|
105
102
|
}
|
106
103
|
|
107
104
|
input:focus {
|
package/src/ox-input-search.ts
CHANGED
@@ -14,8 +14,6 @@ export class OxInputSearch extends OxFormField {
|
|
14
14
|
static styles = [
|
15
15
|
css`
|
16
16
|
:host {
|
17
|
-
flex: 1;
|
18
|
-
|
19
17
|
display: flex;
|
20
18
|
position: relative;
|
21
19
|
align-items: center;
|
@@ -28,9 +26,14 @@ export class OxInputSearch extends OxFormField {
|
|
28
26
|
background-color: transparent;
|
29
27
|
border: 0;
|
30
28
|
border-bottom: var(--border-dark-color);
|
31
|
-
padding: var(--
|
32
|
-
|
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 {
|
33
35
|
outline: none;
|
36
|
+
border-bottom: 1px solid var(--primary-color);
|
34
37
|
}
|
35
38
|
|
36
39
|
mwc-icon {
|
@@ -52,14 +55,17 @@ export class OxInputSearch extends OxFormField {
|
|
52
55
|
.value=${this.value || ''}
|
53
56
|
.placeholder=${this.placeholder || ''}
|
54
57
|
@change=${(e: Event) => this._onChangeValue(e)}
|
58
|
+
@keydown=${(e: KeyboardEvent) => {
|
59
|
+
if (e.key === 'Enter') {
|
60
|
+
/* Even if the value has not changed, the enter key triggers a change event. */
|
61
|
+
e.preventDefault() /* Prevent change event from occurring twice. */
|
62
|
+
this._onChangeValue(e)
|
63
|
+
}
|
64
|
+
}}
|
55
65
|
/>
|
56
66
|
`
|
57
67
|
}
|
58
68
|
|
59
|
-
firstUpdated() {
|
60
|
-
this.renderRoot.addEventListener('change', this._onChangeValue.bind(this))
|
61
|
-
}
|
62
|
-
|
63
69
|
_onChangeValue(e: Event) {
|
64
70
|
e.stopPropagation()
|
65
71
|
this.value = this.input.value
|
@@ -0,0 +1,123 @@
|
|
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 { OxPopupList } from '@operato/popup'
|
9
|
+
|
10
|
+
import { OxFormField } from './ox-form-field'
|
11
|
+
|
12
|
+
const UNIT_SYSTEMS: { [unit: string]: { [unit: string]: number } } = {
|
13
|
+
kg: {
|
14
|
+
mg: 1000000,
|
15
|
+
g: 1000,
|
16
|
+
ton: 0.001
|
17
|
+
},
|
18
|
+
rad: {
|
19
|
+
degree: 180 / Math.PI
|
20
|
+
}
|
21
|
+
}
|
22
|
+
|
23
|
+
@customElement('ox-input-unit')
|
24
|
+
export class OxInputUnit extends OxFormField {
|
25
|
+
static styles = [
|
26
|
+
css`
|
27
|
+
input {
|
28
|
+
border: 0;
|
29
|
+
border-bottom: var(--border-dark-color);
|
30
|
+
padding: var(--input-padding);
|
31
|
+
font: var(--input-font);
|
32
|
+
color: var(--primary-text-color);
|
33
|
+
}
|
34
|
+
input:focus {
|
35
|
+
outline: none;
|
36
|
+
border-bottom: 1px solid var(--primary-color);
|
37
|
+
}
|
38
|
+
|
39
|
+
input::-webkit-outer-spin-button,
|
40
|
+
input::-webkit-inner-spin-button {
|
41
|
+
-webkit-appearance: none;
|
42
|
+
margin: 0;
|
43
|
+
}
|
44
|
+
|
45
|
+
input[type='number'] {
|
46
|
+
-moz-appearance: textfield;
|
47
|
+
}
|
48
|
+
|
49
|
+
div {
|
50
|
+
display: inline;
|
51
|
+
position: relative;
|
52
|
+
margin-left: var(--margin-narrow);
|
53
|
+
font: var(--label-font);
|
54
|
+
color: var(--label-color);
|
55
|
+
opacity: 0.7;
|
56
|
+
}
|
57
|
+
`
|
58
|
+
]
|
59
|
+
|
60
|
+
@property({ type: String }) placeholder?: string
|
61
|
+
@property({ type: String, attribute: 'std-unit' }) stdUnit!: string
|
62
|
+
@property({ type: String, attribute: 'user-unit' }) userUnit?: string
|
63
|
+
|
64
|
+
@query('input') input!: HTMLInputElement
|
65
|
+
@query('ox-popup-list') popup!: OxPopupList
|
66
|
+
|
67
|
+
render() {
|
68
|
+
const userUnit = this.userUnit || this.stdUnit
|
69
|
+
const units = Object.keys(UNIT_SYSTEMS[this.stdUnit])
|
70
|
+
const rate = !this.userUnit || this.userUnit === this.stdUnit ? 1 : UNIT_SYSTEMS[this.stdUnit][this.userUnit] || 1
|
71
|
+
|
72
|
+
return html`
|
73
|
+
<input
|
74
|
+
type="number"
|
75
|
+
.value=${this._toUserUnit(this.value)}
|
76
|
+
placeholder=${this.placeholder}
|
77
|
+
@change=${(e: Event) => this._onChangeValue(e)}
|
78
|
+
/>
|
79
|
+
<div
|
80
|
+
@click=${(e: Event) => {
|
81
|
+
const target = e.currentTarget as HTMLElement
|
82
|
+
this.popup.open({
|
83
|
+
right: 0,
|
84
|
+
top: target.offsetTop + target.offsetHeight
|
85
|
+
})
|
86
|
+
}}
|
87
|
+
>
|
88
|
+
${userUnit}
|
89
|
+
<ox-popup-list
|
90
|
+
.value=${userUnit}
|
91
|
+
@select=${(e: CustomEvent) => {
|
92
|
+
this.userUnit = e.detail
|
93
|
+
}}
|
94
|
+
>
|
95
|
+
<div option value=${this.stdUnit}>${this.stdUnit}</div>
|
96
|
+
${units.map(unit => html`<div option value=${unit}>${unit}</div>`)}
|
97
|
+
</ox-popup-list>
|
98
|
+
</div>
|
99
|
+
`
|
100
|
+
}
|
101
|
+
|
102
|
+
_onChangeValue(e: Event) {
|
103
|
+
this.value = this._toStdUnit(this.input.value)
|
104
|
+
|
105
|
+
this.dispatchEvent(
|
106
|
+
new CustomEvent('change', {
|
107
|
+
bubbles: true,
|
108
|
+
composed: true,
|
109
|
+
detail: this.value
|
110
|
+
})
|
111
|
+
)
|
112
|
+
}
|
113
|
+
|
114
|
+
_toUserUnit(stdValue: string | number | undefined) {
|
115
|
+
const rate = !this.userUnit || this.userUnit === this.stdUnit ? 1 : UNIT_SYSTEMS[this.stdUnit][this.userUnit] || 1
|
116
|
+
return Number(stdValue) * rate
|
117
|
+
}
|
118
|
+
|
119
|
+
_toStdUnit(userValue: string | number | undefined) {
|
120
|
+
const rate = !this.userUnit || this.userUnit === this.stdUnit ? 1 : UNIT_SYSTEMS[this.stdUnit][this.userUnit] || 1
|
121
|
+
return isNaN(Number(userValue)) ? undefined : Number(userValue) / rate
|
122
|
+
}
|
123
|
+
}
|
@@ -80,8 +80,8 @@ export class OxInputValueMap extends OxFormField {
|
|
80
80
|
`
|
81
81
|
|
82
82
|
@property({ type: Object }) value: ValueMap = {}
|
83
|
-
@property({ type: String }) valuetype: 'string' | 'boolean' | 'color' | string = 'string'
|
84
|
-
@property({ type: String }) keytype: 'string' | '
|
83
|
+
@property({ type: String }) valuetype: 'string' | 'boolean' | 'color' | 'number' | 'date' | string = 'string'
|
84
|
+
@property({ type: String }) keytype: 'string' | 'number' = 'number'
|
85
85
|
|
86
86
|
private _changingNow: boolean = false
|
87
87
|
|
@@ -92,8 +92,8 @@ export class OxInputValueRange extends OxFormField {
|
|
92
92
|
`
|
93
93
|
|
94
94
|
@property({ type: Object }) value: ValueRange = {}
|
95
|
-
@property({ type: String }) valuetype: 'string' | 'boolean' | 'color' | string = 'string'
|
96
|
-
@property({ type: String }) rangetype: 'string' | '
|
95
|
+
@property({ type: String }) valuetype: 'string' | 'boolean' | 'color' | 'number' | 'date' | string = 'string'
|
96
|
+
@property({ type: String }) rangetype: 'string' | 'number' = 'number'
|
97
97
|
|
98
98
|
private _changingNow: boolean = false
|
99
99
|
|
@@ -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,40 +23,26 @@ 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`
|
27
30
|
:host {
|
28
31
|
display: flex;
|
29
32
|
flex-direction: column;
|
30
|
-
align-content: center;
|
31
33
|
|
32
34
|
width: 100%;
|
33
35
|
overflow: hidden;
|
34
|
-
border: 1px solid #ccc;
|
35
36
|
}
|
36
37
|
|
37
38
|
div {
|
38
39
|
display: flex;
|
39
40
|
flex-flow: row nowrap;
|
40
|
-
|
41
|
-
|
42
|
-
border-bottom: 1px solid #c0c0c0;
|
43
|
-
}
|
44
|
-
|
45
|
-
div:last-child {
|
46
|
-
border-bottom: none;
|
47
|
-
}
|
48
|
-
|
49
|
-
div > * {
|
50
|
-
min-width: 0px;
|
51
|
-
margin: 2px;
|
52
|
-
padding: 0;
|
41
|
+
gap: var(--margin-default);
|
53
42
|
}
|
54
43
|
|
55
|
-
button,
|
56
44
|
empty-element {
|
57
|
-
width:
|
45
|
+
width: 34px;
|
58
46
|
text-align: center;
|
59
47
|
}
|
60
48
|
|
@@ -63,21 +51,64 @@ export class OxInputWorkShift extends OxFormField {
|
|
63
51
|
span {
|
64
52
|
flex: 1;
|
65
53
|
}
|
54
|
+
[data-header] {
|
55
|
+
background-color: rgba(var(--primary-color-rgb), 0.05);
|
56
|
+
padding: var(--padding-narrow);
|
57
|
+
}
|
58
|
+
[data-header] span {
|
59
|
+
font: var(--label-font);
|
60
|
+
color: var(--label-color);
|
61
|
+
text-transform: var(--label-text-transform);
|
62
|
+
text-align: center;
|
63
|
+
}
|
64
|
+
[data-record] {
|
65
|
+
margin-bottom: var(--margin-narrow);
|
66
|
+
}
|
67
|
+
input,
|
68
|
+
select {
|
69
|
+
border: 0;
|
70
|
+
border-bottom: var(--border-dark-color);
|
71
|
+
padding: var(--input-padding);
|
72
|
+
font: var(--input-font);
|
73
|
+
color: var(--primary-text-color);
|
74
|
+
|
75
|
+
max-height: 35px;
|
76
|
+
}
|
77
|
+
input:focus,
|
78
|
+
select:focus {
|
79
|
+
outline: none;
|
80
|
+
border-bottom: 1px solid var(--primary-color);
|
81
|
+
}
|
66
82
|
|
67
83
|
input:required:invalid {
|
68
84
|
border: 1px dashed red;
|
69
85
|
}
|
70
|
-
|
71
|
-
|
72
|
-
flex: 2;
|
86
|
+
input[type='time'] {
|
87
|
+
padding: 2px var(--padding-default);
|
73
88
|
}
|
74
89
|
|
75
|
-
|
76
|
-
border
|
90
|
+
button {
|
91
|
+
border: var(--button-border);
|
92
|
+
border-radius: var(--border-radius);
|
93
|
+
background-color: var(--button-background-color);
|
94
|
+
padding: var(--padding-narrow) var(--padding-default);
|
95
|
+
line-height: 0.8;
|
96
|
+
color: var(--button-color);
|
97
|
+
cursor: pointer;
|
98
|
+
}
|
99
|
+
button mwc-icon {
|
100
|
+
font-size: var(--fontsize-default);
|
101
|
+
}
|
102
|
+
button:focus,
|
103
|
+
button:hover,
|
104
|
+
button:active {
|
105
|
+
border: var(--button-activ-border);
|
106
|
+
background-color: var(--button-background-focus-color);
|
107
|
+
color: var(--theme-white-color);
|
77
108
|
}
|
78
109
|
|
79
|
-
|
80
|
-
|
110
|
+
[placeholder='value'] {
|
111
|
+
flex: 2;
|
81
112
|
}
|
82
113
|
`
|
83
114
|
|
@@ -92,11 +123,11 @@ export class OxInputWorkShift extends OxFormField {
|
|
92
123
|
render() {
|
93
124
|
return html`
|
94
125
|
<div data-header>
|
95
|
-
<span
|
96
|
-
<span
|
97
|
-
<span
|
98
|
-
<span
|
99
|
-
<span
|
126
|
+
<span>${msg('name')}</span>
|
127
|
+
<span>${msg('from date')}</span>
|
128
|
+
<span>${msg('from time')}</span>
|
129
|
+
<span>${msg('to date')}</span>
|
130
|
+
<span>${msg('to time')}</span>
|
100
131
|
<empty-element></empty-element>
|
101
132
|
</div>
|
102
133
|
|
@@ -106,20 +137,22 @@ export class OxInputWorkShift extends OxFormField {
|
|
106
137
|
<input type="text" data-name .value=${item.name} required />
|
107
138
|
|
108
139
|
<select data-from-date .value=${item.fromDate || 0}>
|
109
|
-
<option value="-1"
|
110
|
-
<option value="0"
|
111
|
-
<option value="1"
|
140
|
+
<option value="-1">${msg('The day before')}</option>
|
141
|
+
<option value="0">${msg('The day')}</option>
|
142
|
+
<option value="1">${msg('The day after')}</option>
|
112
143
|
</select>
|
113
144
|
<input type="time" data-from-time .value=${item.fromTime} step="1800" required />
|
114
145
|
|
115
146
|
<select data-to-date .value=${item.toDate || 0}>
|
116
|
-
<option value="-1"
|
117
|
-
<option value="0"
|
118
|
-
<option value="1"
|
147
|
+
<option value="-1">${msg('The day before')}</option>
|
148
|
+
<option value="0">${msg('The day')}</option>
|
149
|
+
<option value="1">${msg('The day after')}</option>
|
119
150
|
</select>
|
120
151
|
<input type="time" data-to-time .value=${item.toTime} step="1800" required />
|
121
152
|
|
122
|
-
<button class="record-action" @click=${(e: Event) => this._delete(e)} tabindex="-1"
|
153
|
+
<button class="record-action" @click=${(e: Event) => this._delete(e)} tabindex="-1">
|
154
|
+
<mwc-icon>remove</mwc-icon>
|
155
|
+
</button>
|
123
156
|
</div>
|
124
157
|
`
|
125
158
|
)}
|
@@ -128,20 +161,22 @@ export class OxInputWorkShift extends OxFormField {
|
|
128
161
|
<input type="text" data-name />
|
129
162
|
|
130
163
|
<select data-from-date>
|
131
|
-
<option value="-1"
|
132
|
-
<option value="0" selected
|
133
|
-
<option value="+1"
|
164
|
+
<option value="-1">${msg('The day before')}</option>
|
165
|
+
<option value="0" selected>${msg('The day')}</option>
|
166
|
+
<option value="+1">${msg('The day after')}</option>
|
134
167
|
</select>
|
135
168
|
<input type="time" data-from-time step="1800" />
|
136
169
|
|
137
170
|
<select data-to-date>
|
138
|
-
<option value="-1"
|
139
|
-
<option value="0" selected
|
140
|
-
<option value="+1"
|
171
|
+
<option value="-1">${msg('The day before')}</option>
|
172
|
+
<option value="0" selected>${msg('The day')}</option>
|
173
|
+
<option value="+1">${msg('The day after')}</option>
|
141
174
|
</select>
|
142
175
|
<input type="time" data-to-time step="1800" />
|
143
176
|
|
144
|
-
<button class="record-action" @click=${(e: Event) => this._add()} tabindex="-1"
|
177
|
+
<button class="record-action" @click=${(e: Event) => this._add()} tabindex="-1">
|
178
|
+
<mwc-icon>add</mwc-icon>
|
179
|
+
</button>
|
145
180
|
</div>
|
146
181
|
`
|
147
182
|
}
|
package/src/ox-select.ts
CHANGED
@@ -5,14 +5,15 @@
|
|
5
5
|
import '@material/mwc-icon'
|
6
6
|
import '@operato/popup/ox-popup-list.js'
|
7
7
|
|
8
|
-
import {
|
9
|
-
import { customElement, property,
|
8
|
+
import { css, html, PropertyValues } from 'lit'
|
9
|
+
import { customElement, property, state } from 'lit/decorators.js'
|
10
10
|
|
11
|
-
import { OxFormField } from './ox-form-field.js'
|
12
11
|
import { OxPopupList } from '@operato/popup'
|
13
12
|
import { TooltipStyles } from '@operato/styles'
|
14
13
|
import { detectOverflow } from '@operato/utils'
|
15
14
|
|
15
|
+
import { OxFormField } from './ox-form-field.js'
|
16
|
+
|
16
17
|
function onmouseover(e: Event) {
|
17
18
|
const element = e.target as HTMLSpanElement
|
18
19
|
if (detectOverflow(element)) {
|
@@ -41,6 +42,11 @@ export class Select extends OxFormField {
|
|
41
42
|
align-items: center;
|
42
43
|
justify-content: center;
|
43
44
|
cursor: pointer;
|
45
|
+
|
46
|
+
border-bottom: var(--border-dark-color);
|
47
|
+
padding: var(--input-padding);
|
48
|
+
font: var(--input-font);
|
49
|
+
color: var(--primary-text-color);
|
44
50
|
}
|
45
51
|
|
46
52
|
span {
|
@@ -49,6 +55,9 @@ export class Select extends OxFormField {
|
|
49
55
|
text-overflow: ellipsis;
|
50
56
|
white-space: nowrap;
|
51
57
|
}
|
58
|
+
div:hover {
|
59
|
+
border-bottom: 1px solid var(--primary-color);
|
60
|
+
}
|
52
61
|
|
53
62
|
mwc-icon {
|
54
63
|
display: block;
|
@@ -58,6 +67,9 @@ export class Select extends OxFormField {
|
|
58
67
|
color: var(--theme-primary-text-color, #3c3938);
|
59
68
|
opacity: 0.7;
|
60
69
|
}
|
70
|
+
div:hover mwc-icon {
|
71
|
+
color: var(--primary-color);
|
72
|
+
}
|
61
73
|
|
62
74
|
::slotted(ox-popup-list) {
|
63
75
|
width: 100%;
|