@operato/input 2.0.0-beta.0 → 2.0.0-beta.12
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/CHANGELOG.md +79 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/ox-input-direction.d.ts +11 -0
- package/dist/src/ox-input-direction.js +60 -0
- package/dist/src/ox-input-direction.js.map +1 -0
- package/dist/src/ox-input-mass-fraction.js +1 -0
- package/dist/src/ox-input-mass-fraction.js.map +1 -1
- package/dist/src/ox-input-select-buttons.d.ts +1 -1
- package/dist/src/ox-input-select-buttons.js +2 -2
- package/dist/src/ox-input-select-buttons.js.map +1 -1
- package/dist/src/ox-input-unit-number.d.ts +0 -2
- package/dist/src/ox-input-unit-number.js +4 -6
- package/dist/src/ox-input-unit-number.js.map +1 -1
- package/dist/src/ox-input-work-shift.js +1 -1
- package/dist/src/ox-input-work-shift.js.map +1 -1
- package/dist/stories/ox-input-direction.stories.d.ts +34 -0
- package/dist/stories/ox-input-direction.stories.js +70 -0
- package/dist/stories/ox-input-direction.stories.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -6
- package/src/index.ts +1 -0
- package/src/ox-input-direction.ts +65 -0
- package/src/ox-input-mass-fraction.ts +1 -0
- package/src/ox-input-select-buttons.ts +2 -2
- package/src/ox-input-unit-number.ts +6 -7
- package/src/ox-input-work-shift.ts +1 -1
- package/stories/ox-input-direction.stories.ts +86 -0
- package/themes/grist-theme.css +4 -0
package/package.json
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
"name": "@operato/input",
|
3
3
|
"description": "Webcomponents for input following open-wc recommendations",
|
4
4
|
"author": "heartyoh@hatiolab.com",
|
5
|
-
"version": "2.0.0-beta.
|
5
|
+
"version": "2.0.0-beta.12",
|
6
6
|
"main": "dist/src/index.js",
|
7
7
|
"module": "dist/src/index.js",
|
8
8
|
"license": "MIT",
|
@@ -53,7 +53,8 @@
|
|
53
53
|
"./ox-input-work-shift.js": "./dist/src/ox-input-work-shift.js",
|
54
54
|
"./ox-input-hashtags.js": "./dist/src/ox-input-hashtags.js",
|
55
55
|
"./ox-input-mass-fraction.js": "./dist/src/ox-input-mass-fraction.js",
|
56
|
-
"./ox-input-textarea.js": "./dist/src/ox-input-textarea.js"
|
56
|
+
"./ox-input-textarea.js": "./dist/src/ox-input-textarea.js",
|
57
|
+
"./ox-input-direction.js": "./dist/src/ox-input-direction.js"
|
57
58
|
},
|
58
59
|
"typesVersions": {
|
59
60
|
"*": {
|
@@ -167,6 +168,9 @@
|
|
167
168
|
],
|
168
169
|
"./ox-input-textarea.js": [
|
169
170
|
"./dist/src/ox-input-textarea.d.ts"
|
171
|
+
],
|
172
|
+
"./ox-input-direction.js": [
|
173
|
+
"./dist/src/ox-input-direction.d.ts"
|
170
174
|
]
|
171
175
|
}
|
172
176
|
},
|
@@ -196,9 +200,9 @@
|
|
196
200
|
"@lit/localize": "^0.12.1",
|
197
201
|
"@material/web": "^1.4.0",
|
198
202
|
"@operato/color-picker": "^2.0.0-beta.0",
|
199
|
-
"@operato/i18n": "^2.0.0-beta.
|
200
|
-
"@operato/popup": "^2.0.0-beta.
|
201
|
-
"@operato/styles": "^2.0.0-beta.
|
203
|
+
"@operato/i18n": "^2.0.0-beta.3",
|
204
|
+
"@operato/popup": "^2.0.0-beta.12",
|
205
|
+
"@operato/styles": "^2.0.0-beta.5",
|
202
206
|
"@operato/utils": "^2.0.0-beta.0",
|
203
207
|
"@polymer/paper-dropdown-menu": "^3.2.0",
|
204
208
|
"@polymer/paper-item": "^3.0.1",
|
@@ -243,5 +247,5 @@
|
|
243
247
|
"prettier --write"
|
244
248
|
]
|
245
249
|
},
|
246
|
-
"gitHead": "
|
250
|
+
"gitHead": "08cd1f9bacfca1f0559ee61089a26087cc1876ba"
|
247
251
|
}
|
package/src/index.ts
CHANGED
@@ -0,0 +1,65 @@
|
|
1
|
+
/**
|
2
|
+
* @license Copyright © HatioLab Inc. All rights reserved.
|
3
|
+
*/
|
4
|
+
|
5
|
+
import '@material/web/icon/icon.js'
|
6
|
+
|
7
|
+
import { css, html } from 'lit'
|
8
|
+
import { customElement, property } from 'lit/decorators.js'
|
9
|
+
|
10
|
+
import { OxFormField } from './ox-form-field'
|
11
|
+
|
12
|
+
@customElement('ox-input-direction')
|
13
|
+
export class OxInputDirection extends OxFormField {
|
14
|
+
static styles = css`
|
15
|
+
:host {
|
16
|
+
--md-icon-size: 1.4em;
|
17
|
+
}
|
18
|
+
|
19
|
+
div {
|
20
|
+
display: flex;
|
21
|
+
justify-content: space-between;
|
22
|
+
max-width: 140px;
|
23
|
+
}
|
24
|
+
|
25
|
+
md-icon {
|
26
|
+
color: var(--md-sys-color-on-background);
|
27
|
+
background-color: var(--md-sys-color-background);
|
28
|
+
}
|
29
|
+
|
30
|
+
md-icon[selected] {
|
31
|
+
color: var(--md-sys-color-on-primary);
|
32
|
+
background-color: var(--md-sys-color-primary);
|
33
|
+
}
|
34
|
+
`
|
35
|
+
|
36
|
+
@property({ type: String }) value?: string
|
37
|
+
|
38
|
+
render() {
|
39
|
+
const value = this.value
|
40
|
+
|
41
|
+
return html`
|
42
|
+
<div @click=${this.onClick.bind(this)}>
|
43
|
+
<md-icon ?selected=${value == 'W'} data-value="W">arrow_back</md-icon>
|
44
|
+
<md-icon ?selected=${value == 'N'} data-value="N">arrow_upward</md-icon>
|
45
|
+
<md-icon ?selected=${value == 'S'} data-value="S">arrow_downward</md-icon>
|
46
|
+
<md-icon ?selected=${value == 'E'} data-value="E">arrow_forward</md-icon>
|
47
|
+
</div>
|
48
|
+
`
|
49
|
+
}
|
50
|
+
|
51
|
+
onClick(e: MouseEvent) {
|
52
|
+
e.stopPropagation()
|
53
|
+
|
54
|
+
if (this.disabled) {
|
55
|
+
return
|
56
|
+
}
|
57
|
+
|
58
|
+
const target = e.target as Element
|
59
|
+
const value = target.getAttribute('data-value') as string
|
60
|
+
|
61
|
+
this.value = this.value === value ? undefined : value
|
62
|
+
|
63
|
+
this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: this.value }))
|
64
|
+
}
|
65
|
+
}
|
@@ -40,7 +40,7 @@ export class OxInputSelectButtons extends OxFormField {
|
|
40
40
|
data-value=${value}
|
41
41
|
label=${display}
|
42
42
|
?selected=${values.includes(value)}
|
43
|
-
@
|
43
|
+
@tap=${(e: MouseEvent | TouchEvent) => !this.disabled && this.onTap(e)}
|
44
44
|
></md-filter-chip>
|
45
45
|
`
|
46
46
|
)}
|
@@ -48,7 +48,7 @@ export class OxInputSelectButtons extends OxFormField {
|
|
48
48
|
`
|
49
49
|
}
|
50
50
|
|
51
|
-
|
51
|
+
onTap(e: MouseEvent | TouchEvent) {
|
52
52
|
e.stopPropagation()
|
53
53
|
|
54
54
|
const target = e.target as MdFilterChip
|
@@ -215,7 +215,7 @@ export class OxInputUnitNumber extends OxFormField {
|
|
215
215
|
position: relative;
|
216
216
|
margin-left: var(--margin-narrow);
|
217
217
|
font: var(--label-font);
|
218
|
-
color: var(--label-color);
|
218
|
+
color: var(--label-color, var(--md-sys-color-on-surface));
|
219
219
|
min-width: 24px;
|
220
220
|
}
|
221
221
|
|
@@ -268,6 +268,11 @@ export class OxInputUnitNumber extends OxFormField {
|
|
268
268
|
.value=${userUnit}
|
269
269
|
@select=${(e: CustomEvent) => {
|
270
270
|
this.userUnit = e.detail
|
271
|
+
this.dispatchEvent(
|
272
|
+
new CustomEvent('user-unit-change', {
|
273
|
+
detail: this.userUnit
|
274
|
+
})
|
275
|
+
)
|
271
276
|
}}
|
272
277
|
>
|
273
278
|
<div option value=${this.stdUnit}>${this.stdUnit}</div>
|
@@ -278,12 +283,6 @@ export class OxInputUnitNumber extends OxFormField {
|
|
278
283
|
`
|
279
284
|
}
|
280
285
|
|
281
|
-
updated(changes: PropertyValues<this>) {
|
282
|
-
// if (changes.has('stdUnit')) {
|
283
|
-
// this.userUnit = this.userUnit || this.stdUnit
|
284
|
-
// }
|
285
|
-
}
|
286
|
-
|
287
286
|
_onChangeValue(e: Event) {
|
288
287
|
this.value = this._toStdUnit(this.input.value)
|
289
288
|
|
@@ -57,7 +57,7 @@ export class OxInputWorkShift extends OxFormField {
|
|
57
57
|
}
|
58
58
|
[data-header] span {
|
59
59
|
font: var(--label-font);
|
60
|
-
color: var(--label-color);
|
60
|
+
color: var(--label-color, var(--md-sys-color-on-surface));
|
61
61
|
text-transform: var(--label-text-transform);
|
62
62
|
text-align: center;
|
63
63
|
}
|
@@ -0,0 +1,86 @@
|
|
1
|
+
import '../src/ox-input-direction.js'
|
2
|
+
|
3
|
+
import { html, TemplateResult } from 'lit'
|
4
|
+
import { styles as MDTypeScaleStyles } from '@material/web/typography/md-typescale-styles'
|
5
|
+
|
6
|
+
export default {
|
7
|
+
title: 'ox-input-direction',
|
8
|
+
component: 'ox-input-direction',
|
9
|
+
argTypes: {
|
10
|
+
value: { control: 'object' },
|
11
|
+
name: { control: 'text' },
|
12
|
+
disabled: { control: 'boolean' },
|
13
|
+
theme: { control: 'select', options: ['light', 'dark'] }
|
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
|
+
name?: string
|
25
|
+
value?: object | string
|
26
|
+
disabled?: boolean
|
27
|
+
theme?: string
|
28
|
+
}
|
29
|
+
|
30
|
+
const Template: Story<ArgTypes> = ({ name = 'options', value, disabled, theme = 'light' }: ArgTypes) => html`
|
31
|
+
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap" rel="stylesheet" />
|
32
|
+
|
33
|
+
<link href="/themes/light.css" rel="stylesheet" />
|
34
|
+
<link href="/themes/dark.css" rel="stylesheet" />
|
35
|
+
<link href="/themes/spacing.css" rel="stylesheet" />
|
36
|
+
|
37
|
+
<link
|
38
|
+
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL@20..48,100..700,0..1"
|
39
|
+
rel="stylesheet"
|
40
|
+
/>
|
41
|
+
<link
|
42
|
+
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL@20..48,100..700,0..1"
|
43
|
+
rel="stylesheet"
|
44
|
+
/>
|
45
|
+
<link
|
46
|
+
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Sharp:opsz,wght,FILL@20..48,100..700,0..1"
|
47
|
+
rel="stylesheet"
|
48
|
+
/>
|
49
|
+
|
50
|
+
<style>
|
51
|
+
${MDTypeScaleStyles.cssText}
|
52
|
+
</style>
|
53
|
+
|
54
|
+
<style>
|
55
|
+
.container {
|
56
|
+
height: 500px;
|
57
|
+
text-align: center;
|
58
|
+
padding: 20px;
|
59
|
+
|
60
|
+
background-color: var(--md-sys-color-primary-container);
|
61
|
+
color: var(--md-sys-color-on-primary-container);
|
62
|
+
}
|
63
|
+
</style>
|
64
|
+
|
65
|
+
<script>
|
66
|
+
document.body.classList.add('${theme}')
|
67
|
+
</script>
|
68
|
+
|
69
|
+
<div class="container">
|
70
|
+
<ox-input-direction
|
71
|
+
@change=${(e: Event) => {
|
72
|
+
console.log((e.target as HTMLInputElement).value)
|
73
|
+
}}
|
74
|
+
name=${name}
|
75
|
+
.value=${value}
|
76
|
+
?disabled=${disabled}
|
77
|
+
>
|
78
|
+
</ox-input-direction>
|
79
|
+
</div>
|
80
|
+
`
|
81
|
+
|
82
|
+
export const Regular = Template.bind({})
|
83
|
+
Regular.args = {
|
84
|
+
name: 'options',
|
85
|
+
value: ''
|
86
|
+
}
|