@operato/input 10.29.63 → 10.29.67
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/ox-input-select-buttons.d.ts +5 -0
- package/dist/src/ox-input-select-buttons.js +22 -4
- package/dist/src/ox-input-select-buttons.js.map +1 -1
- package/dist/test/ox-input-select-buttons.test.js +60 -0
- package/dist/test/ox-input-select-buttons.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/test/ox-input-select-buttons.test.ts +65 -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": "10.29.
|
|
5
|
+
"version": "10.29.67",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "dist/src/index.js",
|
|
8
8
|
"module": "dist/src/index.js",
|
|
@@ -295,5 +295,5 @@
|
|
|
295
295
|
"prettier --write"
|
|
296
296
|
]
|
|
297
297
|
},
|
|
298
|
-
"gitHead": "
|
|
298
|
+
"gitHead": "cd6c3fd780bbfd658cdf48086fa4bfcf7f745883"
|
|
299
299
|
}
|
|
@@ -48,4 +48,69 @@ describe('ox-input-select-buttons', () => {
|
|
|
48
48
|
|
|
49
49
|
chips(el).forEach(chip => expect(getComputedStyle(chip).textTransform).to.equal('none'))
|
|
50
50
|
})
|
|
51
|
+
|
|
52
|
+
/*
|
|
53
|
+
* A chip may carry how many rows it stands for — the stages of a list with the number in each. The number shows
|
|
54
|
+
* after the name whether the chip is pressed or not, and a chip without one shows its name alone as before.
|
|
55
|
+
*/
|
|
56
|
+
it('shows each chip\'s count after its name, pressed or not', async () => {
|
|
57
|
+
const el = await fixture(html`
|
|
58
|
+
<ox-input-select-buttons
|
|
59
|
+
multiple
|
|
60
|
+
.value=${['lead']}
|
|
61
|
+
.options=${[
|
|
62
|
+
{ display: 'Lead', value: 'lead', count: 3 },
|
|
63
|
+
{ display: 'Won', value: 'won', count: 0 },
|
|
64
|
+
{ display: 'Plain', value: 'plain' }
|
|
65
|
+
]}
|
|
66
|
+
></ox-input-select-buttons>
|
|
67
|
+
`)
|
|
68
|
+
const [lead, won, plain] = chips(el) as any[]
|
|
69
|
+
|
|
70
|
+
expect(lead.selected).to.equal(true)
|
|
71
|
+
expect(won.selected).to.equal(false)
|
|
72
|
+
expect(lead.querySelector('.count')?.textContent).to.equal('3')
|
|
73
|
+
expect(won.querySelector('.count')?.textContent).to.equal('0')
|
|
74
|
+
expect(lead.textContent.trim()).to.equal('Lead3')
|
|
75
|
+
expect(plain.querySelector('.count')).to.equal(null)
|
|
76
|
+
expect(plain.label).to.equal('Plain')
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
it('toggles a counted chip like any other, keeping the rest pressed', async () => {
|
|
80
|
+
const el = (await fixture(html`
|
|
81
|
+
<ox-input-select-buttons
|
|
82
|
+
multiple
|
|
83
|
+
.value=${['lead', 'won']}
|
|
84
|
+
.options=${[
|
|
85
|
+
{ display: 'Lead', value: 'lead', count: 3 },
|
|
86
|
+
{ display: 'Won', value: 'won', count: 1 }
|
|
87
|
+
]}
|
|
88
|
+
></ox-input-select-buttons>
|
|
89
|
+
`)) as any
|
|
90
|
+
chips(el)[1].click()
|
|
91
|
+
expect(el.value).to.deep.equal(['lead'])
|
|
92
|
+
chips(el)[1].click()
|
|
93
|
+
expect(el.value).to.deep.equal(['lead', 'won'])
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
/* A pressed chip is told by its fill, not a checkmark: it keeps its width, so the row does not shift as chips toggle. */
|
|
97
|
+
it('marks a pressed chip without a checkmark, at the same width as when not pressed', async () => {
|
|
98
|
+
const el = await fixture(html`
|
|
99
|
+
<ox-input-select-buttons
|
|
100
|
+
multiple
|
|
101
|
+
.value=${['a']}
|
|
102
|
+
.options=${[
|
|
103
|
+
{ display: 'Same', value: 'a', count: 12 },
|
|
104
|
+
{ display: 'Same', value: 'b', count: 12 }
|
|
105
|
+
]}
|
|
106
|
+
></ox-input-select-buttons>
|
|
107
|
+
`)
|
|
108
|
+
const [pressed, released] = chips(el) as any[]
|
|
109
|
+
await pressed.updateComplete
|
|
110
|
+
|
|
111
|
+
expect(pressed.selected).to.equal(true)
|
|
112
|
+
const check = pressed.shadowRoot.querySelector('svg.checkmark')
|
|
113
|
+
expect(!check || check.getBoundingClientRect().width === 0).to.equal(true)
|
|
114
|
+
expect(pressed.getBoundingClientRect().width).to.equal(released.getBoundingClientRect().width)
|
|
115
|
+
})
|
|
51
116
|
})
|