@operato/input 10.29.62 → 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 +19 -0
- package/dist/src/ox-input-data.d.ts +0 -1
- package/dist/src/ox-input-data.js +3 -5
- package/dist/src/ox-input-data.js.map +1 -1
- 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-data.test.d.ts +1 -0
- package/dist/test/ox-input-data.test.js +42 -0
- package/dist/test/ox-input-data.test.js.map +1 -0
- 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 +3 -3
- package/test/ox-input-data.test.ts +58 -0
- 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",
|
|
@@ -257,9 +257,9 @@
|
|
|
257
257
|
"@types/codemirror": "^5.60.5",
|
|
258
258
|
"@undecaf/zbar-wasm": "^0.11.0",
|
|
259
259
|
"codemirror": "^6.0.1",
|
|
260
|
+
"json5": "^2.2.3",
|
|
260
261
|
"lit": "^3.1.2",
|
|
261
262
|
"lodash-es": "^4.17.21",
|
|
262
|
-
"ses": "^1.5.0",
|
|
263
263
|
"tinycolor2": "^1.6.0"
|
|
264
264
|
},
|
|
265
265
|
"devDependencies": {
|
|
@@ -295,5 +295,5 @@
|
|
|
295
295
|
"prettier --write"
|
|
296
296
|
]
|
|
297
297
|
},
|
|
298
|
-
"gitHead": "
|
|
298
|
+
"gitHead": "cd6c3fd780bbfd658cdf48086fa4bfcf7f745883"
|
|
299
299
|
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { html } from 'lit'
|
|
2
|
+
import { fixture, expect } from '@open-wc/testing'
|
|
3
|
+
|
|
4
|
+
import '../src/ox-input-data.js'
|
|
5
|
+
import { OxInputData } from '../src/ox-input-data.js'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* ox-input-data 의 object 해석 계약.
|
|
9
|
+
*
|
|
10
|
+
* object 로 고른 글은 JSON5 데이터로 읽는다 — 코드로 실행하지 않는다.
|
|
11
|
+
* 따옴표 없는 키·작은따옴표·끝 쉼표·주석은 받고, 식은 계산하지 않아 글 그대로 남는다.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
async function makeInput() {
|
|
15
|
+
return (await fixture(html`<ox-input-data></ox-input-data>`)) as OxInputData
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
describe('ox-input-data — object 는 데이터로 읽는다', () => {
|
|
19
|
+
it('JSON5 표기를 객체로 읽는다', async () => {
|
|
20
|
+
const el = await makeInput()
|
|
21
|
+
|
|
22
|
+
el._setDataTypeAndValue('object', `{ a: 1, 'b': [1, 2,], /* note */ c: { d: "x" }, }`)
|
|
23
|
+
|
|
24
|
+
expect(el.value).to.deep.equal({ a: 1, b: [1, 2], c: { d: 'x' } })
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
it('JSON 으로 저장된 값은 그대로 읽는다', async () => {
|
|
28
|
+
const el = await makeInput()
|
|
29
|
+
const saved = JSON.stringify({ a: 1, b: [true, null], c: 'x' }, null, 1)
|
|
30
|
+
|
|
31
|
+
el._setDataTypeAndValue('object', saved)
|
|
32
|
+
|
|
33
|
+
expect(el.value).to.deep.equal({ a: 1, b: [true, null], c: 'x' })
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
it('식은 실행하지 않는다 — 글이 그대로 남는다', async () => {
|
|
37
|
+
const el = await makeInput()
|
|
38
|
+
const text = `{ a: (globalThis.__oxInputDataRan = 1) }`
|
|
39
|
+
|
|
40
|
+
el._setDataTypeAndValue('object', text)
|
|
41
|
+
|
|
42
|
+
expect((globalThis as any).__oxInputDataRan).to.equal(undefined)
|
|
43
|
+
expect(el.value).to.equal(text)
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
it('string 값을 object 로 바꾸면 그 글을 읽는다', async () => {
|
|
47
|
+
const el = await makeInput()
|
|
48
|
+
el.value = `{ n: 2 }`
|
|
49
|
+
|
|
50
|
+
el._setDataType('object')
|
|
51
|
+
|
|
52
|
+
expect(el.value).to.deep.equal({ n: 2 })
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
it('불러도 전역에 Compartment 를 심지 않는다', () => {
|
|
56
|
+
expect((globalThis as any).Compartment).to.equal(undefined)
|
|
57
|
+
})
|
|
58
|
+
})
|
|
@@ -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
|
})
|