@operato/input 0.2.35 → 0.2.36
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 +25 -0
- package/demo/index-3dish.html +15 -2
- package/demo/index-angle.html +9 -4
- package/demo/index-button-radio.html +18 -6
- package/demo/index-checkbox.html +16 -5
- package/demo/index-stack.html +15 -3
- package/demo/index.html +79 -69
- package/dist/src/ox-buttons-radio.d.ts +7 -5
- package/dist/src/ox-buttons-radio.js +13 -9
- package/dist/src/ox-buttons-radio.js.map +1 -1
- package/dist/src/ox-checkbox.d.ts +5 -6
- package/dist/src/ox-checkbox.js +28 -25
- package/dist/src/ox-checkbox.js.map +1 -1
- package/dist/src/ox-formfield.d.ts +10 -0
- package/dist/src/ox-formfield.js +38 -0
- package/dist/src/ox-formfield.js.map +1 -0
- package/dist/src/ox-input-3dish.d.ts +15 -14
- package/dist/src/ox-input-3dish.js +51 -23
- package/dist/src/ox-input-3dish.js.map +1 -1
- package/dist/src/ox-input-angle.d.ts +4 -5
- package/dist/src/ox-input-angle.js +10 -12
- package/dist/src/ox-input-angle.js.map +1 -1
- package/dist/src/ox-input-stack.d.ts +5 -3
- package/dist/src/ox-input-stack.js +40 -35
- package/dist/src/ox-input-stack.js.map +1 -1
- package/dist/src/ox-select.d.ts +5 -4
- package/dist/src/ox-select.js +34 -12
- package/dist/src/ox-select.js.map +1 -1
- package/dist/test/property-angle.test.js +3 -3
- package/dist/test/property-angle.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/ox-buttons-radio.ts +15 -9
- package/src/ox-checkbox.ts +32 -25
- package/src/ox-formfield.ts +36 -0
- package/src/ox-input-3dish.ts +65 -29
- package/src/ox-input-angle.ts +11 -12
- package/src/ox-input-stack.ts +43 -24
- package/src/ox-select.ts +44 -15
- package/test/property-angle.test.ts +3 -4
package/src/ox-select.ts
CHANGED
@@ -5,18 +5,19 @@
|
|
5
5
|
import '@material/mwc-icon'
|
6
6
|
import '@operato/popup'
|
7
7
|
|
8
|
-
import {
|
8
|
+
import { css, html } from 'lit'
|
9
9
|
import { customElement, property, query } from 'lit/decorators.js'
|
10
10
|
|
11
|
-
import {
|
12
|
-
import {
|
11
|
+
import { OxFormField } from './ox-formfield'
|
12
|
+
import { OxPopupList } from '@operato/popup'
|
13
13
|
|
14
14
|
@customElement('ox-select')
|
15
|
-
export class Select extends
|
15
|
+
export class Select extends OxFormField {
|
16
16
|
static styles = [
|
17
17
|
css`
|
18
18
|
:host {
|
19
19
|
display: block;
|
20
|
+
position: relative;
|
20
21
|
}
|
21
22
|
|
22
23
|
div {
|
@@ -29,6 +30,9 @@ export class Select extends LitElement {
|
|
29
30
|
|
30
31
|
span {
|
31
32
|
flex: 1;
|
33
|
+
overflow: hidden;
|
34
|
+
text-overflow: ellipsis;
|
35
|
+
white-space: nowrap;
|
32
36
|
}
|
33
37
|
|
34
38
|
mwc-icon {
|
@@ -47,36 +51,61 @@ export class Select extends LitElement {
|
|
47
51
|
]
|
48
52
|
|
49
53
|
@property({ type: String }) name: string = ''
|
50
|
-
@property({ type: String })
|
54
|
+
@property({ type: String }) placeholder: string = ''
|
51
55
|
|
52
56
|
render() {
|
57
|
+
const label = (this.value instanceof Array ? this.value.join(', ') : this.value) || this.placeholder || ''
|
58
|
+
|
53
59
|
return html`
|
54
60
|
<div @click=${this.expand}>
|
55
|
-
<span>${
|
61
|
+
<span>${label}</span>
|
56
62
|
<mwc-icon>expand_more</mwc-icon>
|
57
63
|
</div>
|
64
|
+
|
58
65
|
<slot></slot>
|
59
66
|
`
|
60
67
|
}
|
61
68
|
|
69
|
+
connectedCallback() {
|
70
|
+
super.connectedCallback()
|
71
|
+
|
72
|
+
this.setAttribute('tabindex', '0')
|
73
|
+
|
74
|
+
this.addEventListener('select', (e: Event) => {
|
75
|
+
this.value = (e as CustomEvent).detail
|
76
|
+
|
77
|
+
this.dispatchEvent(
|
78
|
+
new CustomEvent('change', {
|
79
|
+
bubbles: true,
|
80
|
+
composed: true,
|
81
|
+
detail: this.value
|
82
|
+
})
|
83
|
+
)
|
84
|
+
})
|
85
|
+
|
86
|
+
this.addEventListener('keydown', (e: KeyboardEvent) => {
|
87
|
+
e.preventDefault()
|
88
|
+
|
89
|
+
if (e.key === ' ' || e.key == 'Spacebar' || e.key == 'ArrowDown') {
|
90
|
+
this.expand()
|
91
|
+
}
|
92
|
+
})
|
93
|
+
}
|
94
|
+
|
62
95
|
expand() {
|
63
|
-
const popupList = this.querySelector('ox-popup-list') as
|
96
|
+
const popupList = this.querySelector('ox-popup-list') as OxPopupList
|
64
97
|
|
65
98
|
if (popupList) {
|
66
99
|
popupList.style.width = `${this.offsetWidth}px`
|
67
100
|
|
68
101
|
popupList.open({
|
69
|
-
top: this.
|
70
|
-
left:
|
102
|
+
top: this.offsetHeight,
|
103
|
+
left: 0
|
71
104
|
})
|
72
105
|
}
|
73
106
|
}
|
74
107
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
if (e.keyCode == 32 || e.code == 'Space') {
|
79
|
-
this.expand()
|
80
|
-
}
|
108
|
+
protected appendFormData({ formData }: FormDataEvent): void {
|
109
|
+
this.name && formData.append(this.name, JSON.stringify(this.value))
|
81
110
|
}
|
82
111
|
}
|
@@ -1,22 +1,21 @@
|
|
1
|
-
import { html } from 'lit'
|
2
|
-
|
3
1
|
import { expect, fixture } from '@open-wc/testing'
|
4
2
|
|
5
3
|
import { OxInputAngle } from '../src/ox-input-angle'
|
4
|
+
import { html } from 'lit'
|
6
5
|
|
7
6
|
describe('OxInputAngle', () => {
|
8
7
|
it('has a default title "Hey there" and angle 5', async () => {
|
9
8
|
const el = await fixture<OxInputAngle>(html`<ox-input-angle></ox-input-angle>`)
|
10
9
|
|
11
10
|
expect(el.title).to.equal('Hey there')
|
12
|
-
expect(el.
|
11
|
+
expect(el.value).to.equal(5)
|
13
12
|
})
|
14
13
|
|
15
14
|
it('increases the angle on button click', async () => {
|
16
15
|
const el = await fixture<OxInputAngle>(html`<ox-input-angle></ox-input-angle>`)
|
17
16
|
el.shadowRoot!.querySelector('button')!.click()
|
18
17
|
|
19
|
-
expect(el.
|
18
|
+
expect(el.value).to.equal(6)
|
20
19
|
})
|
21
20
|
|
22
21
|
it('can override the title via attribute', async () => {
|