@operato/input 1.0.0-beta.9 → 1.0.6

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 (182) hide show
  1. package/.storybook/main.js +2 -2
  2. package/.storybook/server.mjs +4 -4
  3. package/CHANGELOG.md +449 -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/index.d.ts +4 -2
  8. package/dist/src/index.js +4 -2
  9. package/dist/src/index.js.map +1 -1
  10. package/dist/src/locales/en.d.ts +8 -0
  11. package/dist/src/locales/en.js +8 -0
  12. package/dist/src/locales/en.js.map +1 -1
  13. package/dist/src/locales/ko.d.ts +8 -0
  14. package/dist/src/locales/ko.js +8 -0
  15. package/dist/src/locales/ko.js.map +1 -1
  16. package/dist/src/locales/ms.d.ts +8 -0
  17. package/dist/src/locales/ms.js +8 -0
  18. package/dist/src/locales/ms.js.map +1 -1
  19. package/dist/src/locales/zh.d.ts +8 -0
  20. package/dist/src/locales/zh.js +8 -0
  21. package/dist/src/locales/zh.js.map +1 -1
  22. package/dist/src/ox-input-3dish.js +24 -8
  23. package/dist/src/ox-input-3dish.js.map +1 -1
  24. package/dist/src/ox-input-barcode.d.ts +5 -2
  25. package/dist/src/ox-input-barcode.js +61 -31
  26. package/dist/src/ox-input-barcode.js.map +1 -1
  27. package/dist/src/ox-input-color.js +16 -11
  28. package/dist/src/ox-input-color.js.map +1 -1
  29. package/dist/src/ox-input-crontab.js +28 -10
  30. package/dist/src/ox-input-crontab.js.map +1 -1
  31. package/dist/src/ox-input-data.js +1 -1
  32. package/dist/src/ox-input-data.js.map +1 -1
  33. package/dist/src/ox-input-duration.d.ts +13 -0
  34. package/dist/src/ox-input-duration.js +163 -0
  35. package/dist/src/ox-input-duration.js.map +1 -0
  36. package/dist/src/ox-input-file.js +5 -3
  37. package/dist/src/ox-input-file.js.map +1 -1
  38. package/dist/src/ox-input-key-values.d.ts +41 -0
  39. package/dist/src/ox-input-key-values.js +233 -0
  40. package/dist/src/ox-input-key-values.js.map +1 -0
  41. package/dist/src/ox-input-multiple-colors.d.ts +1 -0
  42. package/dist/src/ox-input-multiple-colors.js +29 -21
  43. package/dist/src/ox-input-multiple-colors.js.map +1 -1
  44. package/dist/src/ox-input-options.d.ts +1 -0
  45. package/dist/src/ox-input-options.js +55 -14
  46. package/dist/src/ox-input-options.js.map +1 -1
  47. package/dist/src/ox-input-partition-keys.d.ts +1 -0
  48. package/dist/src/ox-input-partition-keys.js +51 -23
  49. package/dist/src/ox-input-partition-keys.js.map +1 -1
  50. package/dist/src/ox-input-quantifier.d.ts +11 -0
  51. package/dist/src/ox-input-quantifier.js +67 -0
  52. package/dist/src/ox-input-quantifier.js.map +1 -0
  53. package/dist/src/ox-input-range.js +35 -38
  54. package/dist/src/ox-input-range.js.map +1 -1
  55. package/dist/src/ox-input-search.d.ts +1 -0
  56. package/dist/src/ox-input-search.js +27 -3
  57. package/dist/src/ox-input-search.js.map +1 -1
  58. package/dist/src/ox-input-unit.d.ts +17 -0
  59. package/dist/src/ox-input-unit.js +122 -0
  60. package/dist/src/ox-input-unit.js.map +1 -0
  61. package/dist/src/ox-input-value-map.d.ts +2 -2
  62. package/dist/src/ox-input-value-map.js +51 -15
  63. package/dist/src/ox-input-value-map.js.map +1 -1
  64. package/dist/src/ox-input-value-ranges.d.ts +2 -2
  65. package/dist/src/ox-input-value-ranges.js +50 -23
  66. package/dist/src/ox-input-value-ranges.js.map +1 -1
  67. package/dist/src/ox-input-work-shift.js +79 -44
  68. package/dist/src/ox-input-work-shift.js.map +1 -1
  69. package/dist/src/ox-select.js +12 -3
  70. package/dist/src/ox-select.js.map +1 -1
  71. package/dist/stories/ox-checkbox.stories.d.ts +39 -0
  72. package/dist/stories/ox-checkbox.stories.js +44 -0
  73. package/dist/stories/ox-checkbox.stories.js.map +1 -0
  74. package/dist/stories/ox-input-3dish.stories.d.ts +26 -0
  75. package/dist/stories/ox-input-3dish.stories.js +59 -0
  76. package/dist/stories/ox-input-3dish.stories.js.map +1 -0
  77. package/dist/stories/ox-input-barcode.stories.d.ts +43 -0
  78. package/dist/stories/ox-input-barcode.stories.js +59 -0
  79. package/dist/stories/ox-input-barcode.stories.js.map +1 -0
  80. package/dist/stories/ox-input-crontab.stories.d.ts +25 -0
  81. package/dist/stories/ox-input-crontab.stories.js +35 -0
  82. package/dist/stories/ox-input-crontab.stories.js.map +1 -0
  83. package/dist/stories/ox-input-duration.stories.d.ts +26 -0
  84. package/dist/stories/ox-input-duration.stories.js +37 -0
  85. package/dist/stories/ox-input-duration.stories.js.map +1 -0
  86. package/dist/stories/ox-input-file.stories.d.ts +49 -0
  87. package/dist/stories/ox-input-file.stories.js +48 -0
  88. package/dist/stories/ox-input-file.stories.js.map +1 -0
  89. package/dist/stories/{index.stories.d.ts → ox-input-key-values.stories.d.ts} +7 -11
  90. package/dist/stories/ox-input-key-values.stories.js +49 -0
  91. package/dist/stories/ox-input-key-values.stories.js.map +1 -0
  92. package/dist/stories/ox-input-multiple-colors.stories.d.ts +20 -0
  93. package/dist/stories/ox-input-multiple-colors.stories.js +167 -0
  94. package/dist/stories/ox-input-multiple-colors.stories.js.map +1 -0
  95. package/dist/stories/ox-input-options.stories.d.ts +25 -0
  96. package/dist/stories/ox-input-options.stories.js +33 -0
  97. package/dist/stories/ox-input-options.stories.js.map +1 -0
  98. package/dist/stories/ox-input-partition-keys.stories.d.ts +25 -0
  99. package/dist/stories/ox-input-partition-keys.stories.js +37 -0
  100. package/dist/stories/ox-input-partition-keys.stories.js.map +1 -0
  101. package/dist/stories/ox-input-quantifier.stories.d.ts +25 -0
  102. package/dist/stories/ox-input-quantifier.stories.js +27 -0
  103. package/dist/stories/ox-input-quantifier.stories.js.map +1 -0
  104. package/dist/stories/ox-input-range.stories.d.ts +37 -0
  105. package/dist/stories/ox-input-range.stories.js +28 -0
  106. package/dist/stories/ox-input-range.stories.js.map +1 -0
  107. package/dist/stories/ox-input-search.stories.d.ts +33 -0
  108. package/dist/stories/ox-input-search.stories.js +35 -0
  109. package/dist/stories/ox-input-search.stories.js.map +1 -0
  110. package/dist/stories/ox-input-unit.stories.d.ts +40 -0
  111. package/dist/stories/ox-input-unit.stories.js +42 -0
  112. package/dist/stories/ox-input-unit.stories.js.map +1 -0
  113. package/dist/stories/ox-input-value-map.stories.d.ts +35 -0
  114. package/dist/stories/ox-input-value-map.stories.js +37 -0
  115. package/dist/stories/ox-input-value-map.stories.js.map +1 -0
  116. package/dist/stories/ox-input-value-ranges.stories.d.ts +35 -0
  117. package/dist/stories/ox-input-value-ranges.stories.js +37 -0
  118. package/dist/stories/ox-input-value-ranges.stories.js.map +1 -0
  119. package/dist/stories/ox-input-work-shift.stories.d.ts +26 -0
  120. package/dist/stories/ox-input-work-shift.stories.js +59 -0
  121. package/dist/stories/ox-input-work-shift.stories.js.map +1 -0
  122. package/dist/stories/ox-select.stories.d.ts +30 -0
  123. package/dist/stories/ox-select.stories.js +83 -0
  124. package/dist/stories/ox-select.stories.js.map +1 -0
  125. package/dist/tsconfig.tsbuildinfo +1 -1
  126. package/package.json +23 -19
  127. package/src/index.ts +4 -2
  128. package/src/locales/en.ts +8 -0
  129. package/src/locales/ko.ts +8 -0
  130. package/src/locales/ms.ts +8 -0
  131. package/src/locales/zh.ts +8 -0
  132. package/src/ox-input-3dish.ts +24 -8
  133. package/src/ox-input-barcode.ts +67 -34
  134. package/src/ox-input-color.ts +17 -11
  135. package/src/ox-input-crontab.ts +30 -10
  136. package/src/ox-input-data.ts +2 -2
  137. package/src/ox-input-duration.ts +168 -0
  138. package/src/ox-input-file.ts +7 -6
  139. package/src/ox-input-key-values.ts +270 -0
  140. package/src/ox-input-multiple-colors.ts +29 -21
  141. package/src/ox-input-options.ts +54 -13
  142. package/src/ox-input-partition-keys.ts +51 -22
  143. package/src/ox-input-quantifier.ts +62 -0
  144. package/src/ox-input-range.ts +35 -38
  145. package/src/ox-input-search.ts +29 -3
  146. package/src/ox-input-unit.ts +123 -0
  147. package/src/ox-input-value-map.ts +52 -16
  148. package/src/ox-input-value-ranges.ts +52 -25
  149. package/src/ox-input-work-shift.ts +81 -44
  150. package/src/ox-select.ts +19 -5
  151. package/stories/ox-checkbox.stories.ts +69 -0
  152. package/stories/ox-input-3dish.stories.ts +73 -0
  153. package/stories/ox-input-barcode.stories.ts +85 -0
  154. package/stories/ox-input-code.stories.ts_ +51 -0
  155. package/stories/ox-input-crontab.stories.ts +49 -0
  156. package/stories/ox-input-duration.stories.ts +51 -0
  157. package/stories/ox-input-file.stories.ts +77 -0
  158. package/stories/ox-input-key-values.stories.ts +64 -0
  159. package/stories/ox-input-multiple-colors.stories.ts +178 -0
  160. package/stories/ox-input-options.stories.ts +47 -0
  161. package/stories/ox-input-partition-keys.stories.ts +51 -0
  162. package/stories/ox-input-quantifier.stories.ts +43 -0
  163. package/stories/ox-input-range.stories.ts +45 -0
  164. package/stories/ox-input-search.stories.ts +56 -0
  165. package/stories/ox-input-unit.stories.ts +66 -0
  166. package/stories/ox-input-value-map.stories.ts +58 -0
  167. package/stories/ox-input-value-ranges.stories.ts +58 -0
  168. package/stories/ox-input-work-shift.stories.ts +73 -0
  169. package/stories/ox-select.stories.ts +101 -0
  170. package/themes/app-theme.css +142 -0
  171. package/themes/input-theme.css +19 -0
  172. package/translations/en.json +45 -1
  173. package/translations/ko.json +43 -1
  174. package/translations/ms.json +43 -1
  175. package/translations/zh.json +43 -1
  176. package/xliff/en.xlf +24 -0
  177. package/xliff/ko.xlf +32 -0
  178. package/xliff/ms.xlf +24 -0
  179. package/xliff/zh.xlf +24 -0
  180. package/dist/stories/index.stories.js +0 -33
  181. package/dist/stories/index.stories.js.map +0 -1
  182. package/stories/index.stories.ts +0 -52
@@ -29,23 +29,18 @@ export class OxInputValueRange extends OxFormField {
29
29
  :host {
30
30
  display: flex;
31
31
  flex-direction: column;
32
- align-content: center;
33
-
34
- width: 100%;
35
- overflow: hidden;
36
- border: 1px solid #ccc;
32
+ border: var(--border-dark-color);
33
+ padding: var(--padding-narrow) var(--padding-narrow) 0 var(--padding-narrow);
37
34
  }
38
35
 
39
36
  div {
40
37
  display: flex;
41
38
  flex-flow: row nowrap;
42
- align-items: center;
43
-
44
- border-bottom: 1px solid #c0c0c0;
39
+ gap: var(--padding-default);
45
40
  }
46
41
 
47
42
  div:last-child {
48
- border-bottom: none;
43
+ margin-bottom: var(--margin-narrow);
49
44
  }
50
45
 
51
46
  div > * {
@@ -55,14 +50,47 @@ export class OxInputValueRange extends OxFormField {
55
50
  }
56
51
 
57
52
  button {
58
- width: 20px;
59
- text-align: center;
53
+ border: var(--button-border);
54
+ border-radius: var(--border-radius);
55
+ background-color: var(--button-background-color);
56
+ padding: var(--padding-narrow) var(--padding-default);
57
+ line-height: 0.8;
58
+ color: var(--button-color);
59
+ cursor: pointer;
60
+ }
61
+ button + button {
62
+ margin-left: -5px;
63
+ }
64
+ button mwc-icon {
65
+ font-size: var(--fontsize-default);
66
+ }
67
+ button:focus,
68
+ button:hover,
69
+ button:active {
70
+ border: var(--button-activ-border);
71
+ background-color: var(--button-background-focus-color);
72
+ color: var(--theme-white-color);
60
73
  }
61
74
 
62
75
  input,
63
76
  ox-input-color {
64
77
  flex: 1;
65
78
  }
79
+ input {
80
+ border: 0;
81
+ border-bottom: var(--border-dark-color);
82
+ padding: var(--input-padding);
83
+ font: var(--input-font);
84
+ color: var(--primary-text-color);
85
+ }
86
+ input:focus {
87
+ outline: none;
88
+ border-bottom: 1px solid var(--primary-color);
89
+ }
90
+ button.hidden {
91
+ opacity: 0;
92
+ cursor: default;
93
+ }
66
94
 
67
95
  ox-input-color {
68
96
  --things-editor-color-input-color: {
@@ -74,26 +102,19 @@ export class OxInputValueRange extends OxFormField {
74
102
  }
75
103
  }
76
104
 
77
- [placeholder='value'] {
105
+ [placeholder='value'],
106
+ [value='default'] {
78
107
  flex: 2;
79
108
  }
80
109
 
81
- div {
82
- border-bottom: 1px solid #c0c0c0;
83
- }
84
-
85
- div:last-child {
86
- border-bottom: none;
87
- }
88
-
89
110
  input[type='checkbox'] {
90
111
  width: initial;
91
112
  }
92
113
  `
93
114
 
94
115
  @property({ type: Object }) value: ValueRange = {}
95
- @property({ type: String }) valuetype: 'string' | 'boolean' | 'color' | string = 'string'
96
- @property({ type: String }) rangetype: 'string' | 'boolean' | 'color' | string = 'number'
116
+ @property({ type: String }) valuetype: 'string' | 'boolean' | 'color' | 'number' | 'date' | string = 'string'
117
+ @property({ type: String }) rangetype: 'string' | 'number' = 'number'
97
118
 
98
119
  private _changingNow: boolean = false
99
120
 
@@ -121,7 +142,10 @@ export class OxInputValueRange extends OxFormField {
121
142
  .value=${item.value}
122
143
  data-value-type=${this.valuetype}
123
144
  />
124
- `} <button class="record-action" @click=${(e: Event) => this._delete(e)} tabindex="-1">-</button>
145
+ `}
146
+ <button class="record-action" @click=${(e: Event) => this._delete(e)} tabindex="-1">
147
+ <mwc-icon>remove</mwc-icon>
148
+ </button>
125
149
  </div>
126
150
  `
127
151
  )}
@@ -135,7 +159,9 @@ export class OxInputValueRange extends OxFormField {
135
159
  : this.valuetype == 'color'
136
160
  ? html` <ox-input-color data-value value="" placeholder="value"> </ox-input-color> `
137
161
  : html` <input type="text" data-value placeholder="value" value="" data-value-type=${this.valuetype} /> `}
138
- <button class="record-action" @click=${(e: Event) => this._add()} tabindex="-1">+</button>
162
+ <button class="record-action" @click=${(e: Event) => this._add()} tabindex="-1">
163
+ <mwc-icon>add</mwc-icon>
164
+ </button>
139
165
  </div>
140
166
 
141
167
  <div data-record>
@@ -165,7 +191,8 @@ export class OxInputValueRange extends OxFormField {
165
191
  class="default-value"
166
192
  data-value-type=${this.valuetype}
167
193
  />
168
- `} <button class="record-action" @click=${(e: Event) => this._sort()}>&gt;</button>
194
+ `}
195
+ <button class="record-action" @click=${(e: Event) => this._sort()}><mwc-icon>chevron_right</mwc-icon></button>
169
196
  </div>
170
197
  `
171
198
  }
@@ -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
- align-items: center;
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: 20px;
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
- [placeholder='value'] {
72
- flex: 2;
86
+ input[type='time'] {
87
+ padding: 2px var(--padding-default);
73
88
  }
74
89
 
75
- div {
76
- border-bottom: 1px solid #c0c0c0;
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
- div:last-child {
80
- border-bottom: none;
110
+ [placeholder='value'] {
111
+ flex: 2;
81
112
  }
82
113
  `
83
114
 
@@ -90,36 +121,40 @@ export class OxInputWorkShift extends OxFormField {
90
121
  }
91
122
 
92
123
  render() {
124
+ const workshifts = this.value || []
125
+
93
126
  return html`
94
127
  <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>
128
+ <span>${msg('name')}</span>
129
+ <span>${msg('from date')}</span>
130
+ <span>${msg('from time')}</span>
131
+ <span>${msg('to date')}</span>
132
+ <span>${msg('to time')}</span>
100
133
  <empty-element></empty-element>
101
134
  </div>
102
135
 
103
- ${this.value.map(
136
+ ${workshifts.map(
104
137
  item => html`
105
138
  <div data-record>
106
139
  <input type="text" data-name .value=${item.name} required />
107
140
 
108
141
  <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>
142
+ <option value="-1">${msg('The day before')}</option>
143
+ <option value="0">${msg('The day')}</option>
144
+ <option value="1">${msg('The day after')}</option>
112
145
  </select>
113
146
  <input type="time" data-from-time .value=${item.fromTime} step="1800" required />
114
147
 
115
148
  <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>
149
+ <option value="-1">${msg('The day before')}</option>
150
+ <option value="0">${msg('The day')}</option>
151
+ <option value="1">${msg('The day after')}</option>
119
152
  </select>
120
153
  <input type="time" data-to-time .value=${item.toTime} step="1800" required />
121
154
 
122
- <button class="record-action" @click=${(e: Event) => this._delete(e)} tabindex="-1">-</button>
155
+ <button class="record-action" @click=${(e: Event) => this._delete(e)} tabindex="-1">
156
+ <mwc-icon>remove</mwc-icon>
157
+ </button>
123
158
  </div>
124
159
  `
125
160
  )}
@@ -128,20 +163,22 @@ export class OxInputWorkShift extends OxFormField {
128
163
  <input type="text" data-name />
129
164
 
130
165
  <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>
166
+ <option value="-1">${msg('The day before')}</option>
167
+ <option value="0" selected>${msg('The day')}</option>
168
+ <option value="+1">${msg('The day after')}</option>
134
169
  </select>
135
170
  <input type="time" data-from-time step="1800" />
136
171
 
137
172
  <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>
173
+ <option value="-1">${msg('The day before')}</option>
174
+ <option value="0" selected>${msg('The day')}</option>
175
+ <option value="+1">${msg('The day after')}</option>
141
176
  </select>
142
177
  <input type="time" data-to-time step="1800" />
143
178
 
144
- <button class="record-action" @click=${(e: Event) => this._add()} tabindex="-1">+</button>
179
+ <button class="record-action" @click=${(e: Event) => this._add()} tabindex="-1">
180
+ <mwc-icon>add</mwc-icon>
181
+ </button>
145
182
  </div>
146
183
  `
147
184
  }
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 { PropertyValues, css, html } from 'lit'
9
- import { customElement, property, query, state } from 'lit/decorators.js'
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)) {
@@ -33,6 +34,7 @@ export class Select extends OxFormField {
33
34
  :host {
34
35
  display: block;
35
36
  position: relative;
37
+ border-bottom: var(--border-dark-color);
36
38
  }
37
39
 
38
40
  div {
@@ -41,6 +43,9 @@ export class Select extends OxFormField {
41
43
  align-items: center;
42
44
  justify-content: center;
43
45
  cursor: pointer;
46
+ padding: var(--input-padding);
47
+ font: var(--input-font);
48
+ color: var(--primary-text-color);
44
49
  }
45
50
 
46
51
  span {
@@ -58,6 +63,9 @@ export class Select extends OxFormField {
58
63
  color: var(--theme-primary-text-color, #3c3938);
59
64
  opacity: 0.7;
60
65
  }
66
+ div:hover mwc-icon {
67
+ color: var(--primary-color);
68
+ }
61
69
 
62
70
  ::slotted(ox-popup-list) {
63
71
  width: 100%;
@@ -71,7 +79,8 @@ export class Select extends OxFormField {
71
79
  @state() label: string | string[] = ''
72
80
 
73
81
  render() {
74
- const label = (this.label instanceof Array ? this.label.join(', ') : this.label?.trim()) || this.placeholder || ''
82
+ const label =
83
+ (this.label instanceof Array ? this.label.join(', ') : this.label?.trim()) || this.value || this.placeholder || ''
75
84
 
76
85
  return html`
77
86
  <div @click=${this.expand}>
@@ -103,20 +112,25 @@ export class Select extends OxFormField {
103
112
  this.addEventListener('keydown', (e: KeyboardEvent) => {
104
113
  e.preventDefault()
105
114
 
106
- if (e.key === ' ' || e.key == 'Spacebar' || e.key == 'ArrowDown') {
115
+ if (e.key === ' ' || e.key === 'Spacebar' || e.key === 'ArrowDown') {
107
116
  this.expand()
108
117
  }
109
118
  })
110
119
  }
111
120
 
112
121
  async updated(changes: PropertyValues<this>) {
122
+ const popupList = this.querySelector('ox-popup-list') as OxPopupList
123
+
113
124
  if (changes.has('value')) {
114
125
  const popupList = this.querySelector('ox-popup-list') as OxPopupList
115
126
  popupList.value = this.value
116
127
 
117
128
  await this.requestUpdate()
129
+
118
130
  this.label = popupList.getSelectedLabels()
119
131
  }
132
+
133
+ this.label = popupList.getSelectedLabels()
120
134
  }
121
135
 
122
136
  expand() {
@@ -0,0 +1,69 @@
1
+ import '../src/ox-checkbox.js'
2
+
3
+ import { TemplateResult, html } from 'lit'
4
+
5
+ export default {
6
+ title: 'ox-checkbox',
7
+ component: 'ox-checkbox',
8
+ argTypes: {
9
+ label: { control: 'text' },
10
+ name: { control: 'text' },
11
+ value: { control: 'boolean' },
12
+ indeterminatable: { control: 'boolean' },
13
+ indeterminate: { control: 'boolean' }
14
+ }
15
+ }
16
+
17
+ interface Story<T> {
18
+ (args: T): TemplateResult
19
+ args?: Partial<T>
20
+ argTypes?: Record<string, unknown>
21
+ }
22
+
23
+ interface ArgTypes {
24
+ label?: string
25
+ name?: string
26
+ value?: boolean
27
+ indeterminatable?: boolean
28
+ indeterminate?: boolean
29
+ }
30
+
31
+ const Template: Story<ArgTypes> = ({
32
+ label = 'Checkbox',
33
+ name = 'hello',
34
+ value = true,
35
+ indeterminatable = false,
36
+ indeterminate = false
37
+ }: ArgTypes) => html`
38
+ <ox-checkbox
39
+ @click=${(e: MouseEvent) => console.log('clicked')}
40
+ name=${name}
41
+ .checked=${value}
42
+ ?indeterminatable=${indeterminatable}
43
+ ?indeterminate=${indeterminate}
44
+ >
45
+ ${label}
46
+ </ox-checkbox>
47
+ `
48
+
49
+ export const Regular = Template.bind({})
50
+ Regular.args = {
51
+ label: 'label',
52
+ name: 'label',
53
+ value: false
54
+ }
55
+
56
+ export const CustomActivated = Template.bind({})
57
+ CustomActivated.args = {
58
+ label: 'Activated',
59
+ name: 'activated',
60
+ indeterminate: false,
61
+ value: true
62
+ }
63
+
64
+ export const CustomIndeterminated = Template.bind({})
65
+ CustomIndeterminated.args = {
66
+ label: 'Indeterminated',
67
+ indeterminate: true,
68
+ value: true
69
+ }
@@ -0,0 +1,73 @@
1
+ import '../src/ox-input-3dish.js'
2
+ import '../src/locale/locale-picker.js'
3
+
4
+ import { html, TemplateResult } from 'lit'
5
+
6
+ export default {
7
+ title: 'ox-input-3dish',
8
+ component: 'ox-input-3dish',
9
+ argTypes: {
10
+ value: { control: 'object' },
11
+ name: { control: 'text' }
12
+ }
13
+ }
14
+
15
+ interface Story<T> {
16
+ (args: T): TemplateResult
17
+ args?: Partial<T>
18
+ argTypes?: Record<string, unknown>
19
+ }
20
+
21
+ interface ArgTypes {
22
+ name?: string
23
+ value?: object
24
+ }
25
+
26
+ const Template: Story<ArgTypes> = ({ name = '3dish', value = [] }: ArgTypes) => html`
27
+ <link href="/themes/app-theme.css" rel="stylesheet" />
28
+ <link href="https://fonts.googleapis.com/css?family=Material+Icons&display=block" rel="stylesheet" />
29
+ <style>
30
+ body {
31
+ }
32
+ </style>
33
+
34
+ <locale-picker></locale-picker>
35
+ <br /><br />
36
+
37
+ <ox-input-3dish
38
+ @change=${(e: Event) => {
39
+ console.log((e.target as HTMLInputElement).value)
40
+ }}
41
+ name=${name}
42
+ .value=${value}
43
+ >
44
+ </ox-input-3dish>
45
+ `
46
+
47
+ export const Regular = Template.bind({})
48
+ Regular.args = {
49
+ name: '3dish',
50
+ value: [
51
+ {
52
+ name: 'DAY',
53
+ fromDate: -1,
54
+ fromTime: '22:00',
55
+ toDate: 0,
56
+ toTime: '06:00'
57
+ },
58
+ {
59
+ name: 'SWING',
60
+ fromDate: 0,
61
+ fromTime: '06:00',
62
+ toDate: 0,
63
+ toTime: '14:00'
64
+ },
65
+ {
66
+ name: 'NIGHT',
67
+ fromDate: 0,
68
+ fromTime: '14:00',
69
+ toDate: 0,
70
+ toTime: '22:00'
71
+ }
72
+ ]
73
+ }
@@ -0,0 +1,85 @@
1
+ import '../src/ox-input-barcode.js'
2
+
3
+ import { html, TemplateResult } from 'lit'
4
+
5
+ export default {
6
+ title: 'ox-input-barcode',
7
+ component: 'ox-input-barcode',
8
+ argTypes: {
9
+ name: { control: 'text' },
10
+ value: { control: 'text' },
11
+ scannable: { control: 'boolean' },
12
+ withoutEnter: { control: 'boolean' },
13
+ englishOnly: { control: 'boolean' },
14
+ selectAfterChange: { control: 'boolean' }
15
+ }
16
+ }
17
+
18
+ interface Story<T> {
19
+ (args: T): TemplateResult
20
+ args?: Partial<T>
21
+ argTypes?: Record<string, unknown>
22
+ }
23
+
24
+ interface ArgTypes {
25
+ name?: string
26
+ value?: string
27
+ scannable?: boolean
28
+ withoutEnter?: boolean
29
+ englishOnly?: boolean
30
+ selectAfterChange?: boolean
31
+ }
32
+
33
+ const Template: Story<ArgTypes> = ({
34
+ name = 'barcode',
35
+ scannable = true,
36
+ withoutEnter = true,
37
+ englishOnly = false,
38
+ selectAfterChange = false
39
+ }: ArgTypes) => html`
40
+ <link href="/themes/app-theme.css" rel="stylesheet" />
41
+ <link href="https://fonts.googleapis.com/css?family=Material+Icons&display=block" rel="stylesheet" />
42
+ <style>
43
+ ox-input-barcode {
44
+ font-size: 80px;
45
+ --input-font: initial;
46
+ }
47
+ </style>
48
+
49
+ <ox-input-barcode
50
+ name=${name}
51
+ ?without-enter=${withoutEnter}
52
+ ?scannable=${scannable}
53
+ ?english-only=${englishOnly}
54
+ ?select-after-change=${selectAfterChange}
55
+ @change=${(e: CustomEvent) => console.log((e.target as HTMLInputElement).value)}
56
+ >
57
+ </ox-input-barcode>
58
+ `
59
+
60
+ export const Regular = Template.bind({})
61
+ Regular.args = {
62
+ name: 'barcode',
63
+ scannable: true,
64
+ withoutEnter: true,
65
+ englishOnly: false,
66
+ selectAfterChange: false
67
+ }
68
+
69
+ export const EnglishOnly = Template.bind({})
70
+ EnglishOnly.args = {
71
+ name: 'barcode',
72
+ scannable: true,
73
+ withoutEnter: true,
74
+ englishOnly: true,
75
+ selectAfterChange: false
76
+ }
77
+
78
+ export const selectAfterChange = Template.bind({})
79
+ selectAfterChange.args = {
80
+ name: 'barcode',
81
+ scannable: true,
82
+ withoutEnter: true,
83
+ englishOnly: true,
84
+ selectAfterChange: true
85
+ }