@operato/data-grist 10.29.60 → 10.29.62
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 +18 -0
- package/dist/src/data-grid/data-grid-body.d.ts +4 -0
- package/dist/src/data-grid/data-grid-body.js +53 -0
- package/dist/src/data-grid/data-grid-body.js.map +1 -1
- package/dist/src/data-grid/data-grid-header.js +9 -1
- package/dist/src/data-grid/data-grid-header.js.map +1 -1
- package/dist/src/renderers/index.d.ts +1 -0
- package/dist/src/renderers/index.js +1 -0
- package/dist/src/renderers/index.js.map +1 -1
- package/dist/src/renderers/ox-grist-renderer-sparkline.d.ts +30 -0
- package/dist/src/renderers/ox-grist-renderer-sparkline.js +103 -0
- package/dist/src/renderers/ox-grist-renderer-sparkline.js.map +1 -0
- package/dist/src/renderers/registry.js +2 -0
- package/dist/src/renderers/registry.js.map +1 -1
- package/dist/src/types.d.ts +6 -0
- package/dist/src/types.js.map +1 -1
- package/dist/test/field-hint.test.d.ts +2 -0
- package/dist/test/field-hint.test.js +54 -0
- package/dist/test/field-hint.test.js.map +1 -0
- package/dist/test/sparkline-renderer.test.d.ts +1 -0
- package/dist/test/sparkline-renderer.test.js +36 -0
- package/dist/test/sparkline-renderer.test.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -8
- package/test/field-hint.test.ts +60 -0
- package/test/sparkline-renderer.test.ts +40 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@operato/data-grist",
|
|
3
|
-
"version": "10.29.
|
|
3
|
+
"version": "10.29.62",
|
|
4
4
|
"description": "User interface for grid (desktop) and list (mobile)",
|
|
5
5
|
"author": "heartyoh",
|
|
6
6
|
"type": "module",
|
|
@@ -78,14 +78,14 @@
|
|
|
78
78
|
"@material/web": "^2.0.0",
|
|
79
79
|
"@operato/headroom": "^10.29.1",
|
|
80
80
|
"@operato/i18n": "^10.29.27",
|
|
81
|
-
"@operato/input": "^10.29.
|
|
82
|
-
"@operato/list-state": "^10.29.
|
|
83
|
-
"@operato/p13n": "^10.29.
|
|
84
|
-
"@operato/popup": "^10.29.
|
|
81
|
+
"@operato/input": "^10.29.62",
|
|
82
|
+
"@operato/list-state": "^10.29.61",
|
|
83
|
+
"@operato/p13n": "^10.29.61",
|
|
84
|
+
"@operato/popup": "^10.29.61",
|
|
85
85
|
"@operato/pull-to-refresh": "^10.29.23",
|
|
86
|
-
"@operato/styles": "^10.29.
|
|
86
|
+
"@operato/styles": "^10.29.61",
|
|
87
87
|
"@operato/time-calculator": "^10.29.1",
|
|
88
|
-
"@operato/utils": "^10.29.
|
|
88
|
+
"@operato/utils": "^10.29.61",
|
|
89
89
|
"i18next": "^24.2.1",
|
|
90
90
|
"json5": "^2.2.0",
|
|
91
91
|
"lit": "^3.1.2",
|
|
@@ -124,5 +124,5 @@
|
|
|
124
124
|
"prettier --write"
|
|
125
125
|
]
|
|
126
126
|
},
|
|
127
|
-
"gitHead": "
|
|
127
|
+
"gitHead": "d60b1d27a42a15e5ab1828c5e63803e4db81e911"
|
|
128
128
|
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { expect, fixture } from '@open-wc/testing'
|
|
2
|
+
import { html } from 'lit'
|
|
3
|
+
|
|
4
|
+
import '../src/data-grid/data-grid-body.js'
|
|
5
|
+
import '../src/data-grid/data-grid-header.js'
|
|
6
|
+
import { buildColumn } from '../src/configure/column-builder.js'
|
|
7
|
+
import { ZERO_CONFIG, ZERO_DATA } from '../src/configure/zero-config.js'
|
|
8
|
+
|
|
9
|
+
/*
|
|
10
|
+
* A column says what it takes and the limit the server checks (record.hint). A grid has no room under a cell, so the
|
|
11
|
+
* sentence shows under the focused cell while it can be edited, as a spreadsheet's input message, and on the header
|
|
12
|
+
* when the pointer rests there. The focused cell's input names it for a screen reader.
|
|
13
|
+
*/
|
|
14
|
+
const columns = [
|
|
15
|
+
{ type: 'number', name: 'share', header: '배분율', record: { editable: true, hint: '0보다 크고 100 이하입니다.' } },
|
|
16
|
+
{ type: 'string', name: 'notes', header: '비고', record: { editable: true } },
|
|
17
|
+
{ type: 'number', name: 'total', header: '합계', record: { editable: false, hint: '읽기만 합니다.' } }
|
|
18
|
+
].map(buildColumn)
|
|
19
|
+
|
|
20
|
+
async function bodyFocusedAt(column: number) {
|
|
21
|
+
const body: any = await fixture(html`
|
|
22
|
+
<ox-grid-body
|
|
23
|
+
.config=${{ ...ZERO_CONFIG, columns }}
|
|
24
|
+
.columns=${columns}
|
|
25
|
+
.data=${{ ...ZERO_DATA, records: [{ share: 50, notes: '', total: 1 }] }}
|
|
26
|
+
.focused=${{ row: 0, column }}
|
|
27
|
+
></ox-grid-body>
|
|
28
|
+
`)
|
|
29
|
+
await body.updateComplete
|
|
30
|
+
return {
|
|
31
|
+
hint: body.renderRoot.querySelector('#field-hint') as HTMLElement,
|
|
32
|
+
buffer: body.renderRoot.querySelector('#ime-buffer') as HTMLInputElement
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
describe('record.hint', () => {
|
|
37
|
+
it('is the note of the focused editable cell, and its input is described by it', async () => {
|
|
38
|
+
const { hint, buffer } = await bodyFocusedAt(0)
|
|
39
|
+
expect(hint.hidden).to.equal(false)
|
|
40
|
+
expect(hint.textContent!.trim()).to.equal('0보다 크고 100 이하입니다.')
|
|
41
|
+
expect(buffer.getAttribute('aria-describedby')).to.equal('field-hint')
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
it('is absent on a column without one', async () => {
|
|
45
|
+
const { hint, buffer } = await bodyFocusedAt(1)
|
|
46
|
+
expect(hint.hidden).to.equal(true)
|
|
47
|
+
expect(buffer.getAttribute('aria-describedby')).to.equal(null)
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
it('is not shown on a cell that cannot be edited', async () => {
|
|
51
|
+
expect((await bodyFocusedAt(2)).hint.hidden).to.equal(true)
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
it('rides the header title as its tooltip', async () => {
|
|
55
|
+
const header: any = await fixture(html`<ox-grid-header .config=${{ ...ZERO_CONFIG, columns }} .columns=${columns} .data=${ZERO_DATA}></ox-grid-header>`)
|
|
56
|
+
await header.updateComplete
|
|
57
|
+
const titles = [...header.renderRoot.querySelectorAll('span[for-title]')] as HTMLElement[]
|
|
58
|
+
expect(titles.map(title => title.dataset.tooltip ?? null)).to.deep.equal(['0보다 크고 100 이하입니다.', null, '읽기만 합니다.'])
|
|
59
|
+
})
|
|
60
|
+
})
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { expect, fixture, html } from '@open-wc/testing'
|
|
2
|
+
|
|
3
|
+
import '../src/renderers/ox-grist-renderer-sparkline.js'
|
|
4
|
+
import { OxGristRendererSparkline, sparklineRuns } from '../src/renderers/ox-grist-renderer-sparkline.js'
|
|
5
|
+
|
|
6
|
+
/* A sparkline in a cell: a gap where a month has no value, the months to come dashed, the last value a dot. */
|
|
7
|
+
describe('sparkline renderer', () => {
|
|
8
|
+
it('★ splits at a missing month and puts the highest value at the top', () => {
|
|
9
|
+
const runs = sparklineRuns([1, 3, null, 2])
|
|
10
|
+
expect(runs.actual.length).to.equal(2)
|
|
11
|
+
expect(runs.actual[0].length).to.equal(2)
|
|
12
|
+
expect(runs.actual[0][1][1]).to.equal(2, 'the highest value is at the top')
|
|
13
|
+
expect(runs.actual[1].length).to.equal(1)
|
|
14
|
+
expect(runs.last![0]).to.equal(98, 'the last value is at the right end')
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
it('draws the months to come from the last value, apart', () => {
|
|
18
|
+
const runs = sparklineRuns({ values: [10, 20], expected: [20, 30] })
|
|
19
|
+
expect(runs.expected.length).to.equal(1)
|
|
20
|
+
expect(runs.expected[0].length).to.equal(3, 'joined to the last value')
|
|
21
|
+
expect(sparklineRuns({ values: [10, null], expected: [30] }).expected[0].length).to.equal(1, 'not joined across a gap')
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
it('a flat line is in the middle; nothing draws nothing', () => {
|
|
25
|
+
expect(sparklineRuns([5, 5, 5]).actual[0].every(([, y]) => y === 12)).to.be.true
|
|
26
|
+
expect(sparklineRuns([]).actual).to.deep.equal([])
|
|
27
|
+
expect(sparklineRuns(null).last).to.equal(null)
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
it('renders its lines and the tooltip the column gives', async () => {
|
|
31
|
+
const element = new OxGristRendererSparkline()
|
|
32
|
+
element.value = { values: [1, 2, null, 4], expected: [5] }
|
|
33
|
+
element.column = { type: 'sparkline', name: 'trend', record: { options: { title: () => '1, 2, -, 4 → 5' } } } as any
|
|
34
|
+
const shown = await fixture<OxGristRendererSparkline>(html`${element}`)
|
|
35
|
+
const svgElement = shown.shadowRoot!.querySelector('svg')!
|
|
36
|
+
expect(svgElement.querySelectorAll('path:not(.expected)').length).to.equal(1)
|
|
37
|
+
expect(svgElement.querySelectorAll('path.expected').length).to.equal(1)
|
|
38
|
+
expect(svgElement.querySelector('title')!.textContent).to.equal('1, 2, -, 4 → 5')
|
|
39
|
+
})
|
|
40
|
+
})
|