@operato/input 2.0.0-beta.0 → 2.0.0-beta.1
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 +10 -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/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 +7 -3
- package/src/index.ts +1 -0
- package/src/ox-input-direction.ts +65 -0
- package/src/ox-input-mass-fraction.ts +1 -0
- package/stories/ox-input-direction.stories.ts +86 -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.1",
|
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
|
},
|
@@ -243,5 +247,5 @@
|
|
243
247
|
"prettier --write"
|
244
248
|
]
|
245
249
|
},
|
246
|
-
"gitHead": "
|
250
|
+
"gitHead": "9ea81d43b1a5b47e2e40320baf6f8729552edc05"
|
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
|
+
}
|
@@ -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
|
+
}
|