@operato/data-grist 10.8.1 → 10.10.0
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 +44 -0
- package/dist/src/configure/column-builder.js +17 -2
- package/dist/src/configure/column-builder.js.map +1 -1
- package/dist/src/configure/config-builder.js +1 -1
- package/dist/src/configure/config-builder.js.map +1 -1
- package/dist/src/data-card/data-card.d.ts +6 -0
- package/dist/src/data-card/data-card.js +12 -3
- package/dist/src/data-card/data-card.js.map +1 -1
- package/dist/src/data-grid/data-grid-body-style.js +12 -1
- package/dist/src/data-grid/data-grid-body-style.js.map +1 -1
- package/dist/src/data-grid/data-grid-body.d.ts +31 -0
- package/dist/src/data-grid/data-grid-body.js +141 -39
- package/dist/src/data-grid/data-grid-body.js.map +1 -1
- package/dist/src/data-grid/data-grid-field.d.ts +21 -0
- package/dist/src/data-grid/data-grid-field.js +326 -19
- package/dist/src/data-grid/data-grid-field.js.map +1 -1
- package/dist/src/data-grid/data-grid-footer.js +1 -1
- package/dist/src/data-grid/data-grid-footer.js.map +1 -1
- package/dist/src/data-grid/data-grid-header.d.ts +12 -1
- package/dist/src/data-grid/data-grid-header.js +97 -36
- package/dist/src/data-grid/data-grid-header.js.map +1 -1
- package/dist/src/data-grid/data-grid.d.ts +15 -1
- package/dist/src/data-grid/data-grid.js +83 -40
- package/dist/src/data-grid/data-grid.js.map +1 -1
- package/dist/src/data-grist.d.ts +32 -0
- package/dist/src/data-grist.js +86 -10
- package/dist/src/data-grist.js.map +1 -1
- package/dist/src/data-list/data-list.d.ts +6 -0
- package/dist/src/data-list/data-list.js +12 -3
- package/dist/src/data-list/data-list.js.map +1 -1
- package/dist/src/editors/ox-grist-editor-json5.d.ts +1 -0
- package/dist/src/editors/ox-grist-editor-json5.js +2 -0
- package/dist/src/editors/ox-grist-editor-json5.js.map +1 -1
- package/dist/src/editors/ox-grist-editor.d.ts +27 -0
- package/dist/src/editors/ox-grist-editor.js +61 -1
- package/dist/src/editors/ox-grist-editor.js.map +1 -1
- package/dist/src/editors/registry.d.ts +10 -0
- package/dist/src/editors/registry.js +16 -0
- package/dist/src/editors/registry.js.map +1 -1
- package/dist/src/filters/filter-input.js +15 -0
- package/dist/src/filters/filter-input.js.map +1 -1
- package/dist/src/filters/filter-range-date.js +9 -0
- package/dist/src/filters/filter-range-date.js.map +1 -1
- package/dist/src/filters/filter-range-number.js +9 -0
- package/dist/src/filters/filter-range-number.js.map +1 -1
- package/dist/src/gutters/gutter-row-selector.js +16 -0
- package/dist/src/gutters/gutter-row-selector.js.map +1 -1
- 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/renderers/ox-grist-renderer-boolean.js +8 -0
- package/dist/src/renderers/ox-grist-renderer-boolean.js.map +1 -1
- package/dist/src/types.d.ts +11 -1
- package/dist/src/types.js.map +1 -1
- package/dist/src/utils/column-text.d.ts +18 -0
- package/dist/src/utils/column-text.js +37 -0
- package/dist/src/utils/column-text.js.map +1 -0
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/src/utils/index.js +1 -0
- package/dist/src/utils/index.js.map +1 -1
- package/dist/test/accessible-name.test.d.ts +2 -0
- package/dist/test/accessible-name.test.js +324 -0
- package/dist/test/accessible-name.test.js.map +1 -0
- package/dist/test/row-hover-visible.test.js +28 -16
- package/dist/test/row-hover-visible.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -6
- package/test/accessible-name.test.ts +408 -0
- package/test/row-hover-visible.test.ts +32 -16
- package/translations/en.json +20 -10
- package/translations/ja.json +19 -9
- package/translations/ko.json +19 -10
- package/translations/ms.json +19 -9
- package/translations/zh.json +19 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@operato/data-grist",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.10.0",
|
|
4
4
|
"description": "User interface for grid (desktop) and list (mobile)",
|
|
5
5
|
"author": "heartyoh",
|
|
6
6
|
"type": "module",
|
|
@@ -69,11 +69,12 @@
|
|
|
69
69
|
"dependencies": {
|
|
70
70
|
"@material/web": "^2.0.0",
|
|
71
71
|
"@operato/headroom": "^10.0.0",
|
|
72
|
-
"@operato/
|
|
73
|
-
"@operato/
|
|
74
|
-
"@operato/
|
|
72
|
+
"@operato/i18n": "^10.0.0",
|
|
73
|
+
"@operato/input": "^10.10.0",
|
|
74
|
+
"@operato/p13n": "^10.10.0",
|
|
75
|
+
"@operato/popup": "^10.10.0",
|
|
75
76
|
"@operato/pull-to-refresh": "^10.0.0",
|
|
76
|
-
"@operato/styles": "^10.
|
|
77
|
+
"@operato/styles": "^10.10.0",
|
|
77
78
|
"@operato/time-calculator": "^10.0.0",
|
|
78
79
|
"@operato/utils": "^10.7.0",
|
|
79
80
|
"i18next": "^24.2.1",
|
|
@@ -114,5 +115,5 @@
|
|
|
114
115
|
"prettier --write"
|
|
115
116
|
]
|
|
116
117
|
},
|
|
117
|
-
"gitHead": "
|
|
118
|
+
"gitHead": "15f722c8131e5a04b5b4186ac71ada9f94ef9a4f"
|
|
118
119
|
}
|
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
import { expect, fixture } from '@open-wc/testing'
|
|
2
|
+
import { html } from 'lit'
|
|
3
|
+
|
|
4
|
+
import '../src/data-grid/data-grid.js'
|
|
5
|
+
import '../src/data-grid/data-grid-body.js'
|
|
6
|
+
import { buildColumn } from '../src/configure/column-builder.js'
|
|
7
|
+
import { columnText } from '../src/utils/column-text.js'
|
|
8
|
+
import { ZERO_CONFIG, ZERO_DATA } from '../src/configure/zero-config.js'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 입력칸의 이름.
|
|
12
|
+
*
|
|
13
|
+
* ## 왜 시험이 필요한가
|
|
14
|
+
*
|
|
15
|
+
* 이 grid 안에는 이름 없는 입력칸이 여럿 있었다 — 줄을 고르는 체크박스, 머리줄의 filter 상자,
|
|
16
|
+
* 그리고 포커스를 담고 있는 IME buffer. 눈으로 보는 사람에게는 **자리**가 뜻을 말해 준다(맨 왼쪽
|
|
17
|
+
* 좁은 칸이면 줄 선택, 머리줄 이름 바로 아래면 그 column 의 filter). 그런데 자리는 그림일 뿐이고
|
|
18
|
+
* 관계가 아니라서, 화면을 못 보는 사람에게는 이름 없는 상자들만 남는다.
|
|
19
|
+
*
|
|
20
|
+
* ## 무엇을 지키려는가
|
|
21
|
+
*
|
|
22
|
+
* 이름의 출처가 하나여야 한다. `header` 를 고쳤을 때 읽히는 이름도 함께 바뀌어야 하고, 그러려면
|
|
23
|
+
* 부르는 쪽이 이름을 다시 적어 두면 안 된다. `columnText()` 가 그 유일한 출처다.
|
|
24
|
+
*
|
|
25
|
+
* `buildColumn` 이 문자열 header 를 `() => header` 함수로 바꿔 버리는 자리가 있었는데, 그 함수가
|
|
26
|
+
* 돌려주는 것은 lit template 이라 이름을 되꺼낼 수 없다 — 여기서 이름이 사라지고 있었다.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
describe('column 이름의 출처는 하나다', () => {
|
|
30
|
+
it('문자열로 준 header 는 함수로 바뀌어도 글자가 남는다', () => {
|
|
31
|
+
const column = buildColumn({ type: 'string', name: 'palletId', header: '파렛트 번호' })
|
|
32
|
+
|
|
33
|
+
expect(columnText(column)).to.equal('파렛트 번호')
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
it('header.renderer 에 문자열을 준 경우도 같다', () => {
|
|
37
|
+
const column = buildColumn({ type: 'string', name: 'palletId', header: { renderer: '파렛트 번호' } })
|
|
38
|
+
|
|
39
|
+
expect(columnText(column)).to.equal('파렛트 번호')
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
it('label: true 는 header 의 이름을 물려받는다', () => {
|
|
43
|
+
const column = buildColumn({ type: 'string', name: 'palletId', header: '파렛트 번호', label: true })
|
|
44
|
+
|
|
45
|
+
expect(columnText(column)).to.equal('파렛트 번호')
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
it('header 를 함수로 그리면 이름을 되꺼낼 수 없다 — 그때는 column 이름으로 물러난다', () => {
|
|
49
|
+
const column = buildColumn({ type: 'string', name: 'palletId', header: { renderer: () => html`<i>x</i>` } })
|
|
50
|
+
|
|
51
|
+
expect(columnText(column)).to.equal('palletId')
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
it('column 이 없으면 이름을 지어내지 않는다', () => {
|
|
55
|
+
expect(columnText(undefined)).to.equal('')
|
|
56
|
+
expect(columnText(null)).to.equal('')
|
|
57
|
+
})
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
describe('줄을 고르는 칸에는 이름이 있다', () => {
|
|
61
|
+
const columns = [
|
|
62
|
+
{ type: 'gutter', gutterName: 'row-selector', name: '__selected__', multiple: true },
|
|
63
|
+
{ type: 'string', name: 'palletId', header: '파렛트 번호' }
|
|
64
|
+
].map(buildColumn)
|
|
65
|
+
|
|
66
|
+
it('행마다 놓인 체크박스가 몇 번째 줄인지 말한다', async () => {
|
|
67
|
+
const body: any = await fixture(html`
|
|
68
|
+
<ox-grid-body
|
|
69
|
+
.config=${{ ...ZERO_CONFIG, columns }}
|
|
70
|
+
.columns=${columns}
|
|
71
|
+
.data=${{ ...ZERO_DATA, records: [{ palletId: 'P-0001' }, { palletId: 'P-0002' }] }}
|
|
72
|
+
></ox-grid-body>
|
|
73
|
+
`)
|
|
74
|
+
|
|
75
|
+
await body.updateComplete
|
|
76
|
+
|
|
77
|
+
/* 체크박스는 각 칸(ox-grid-field)의 shadow root 안에 그려진다 — 한 겹 더 들어가야 보인다. */
|
|
78
|
+
const fields = Array.from(body.renderRoot.querySelectorAll('ox-grid-field')) as any[]
|
|
79
|
+
|
|
80
|
+
await Promise.all(fields.map(field => field.updateComplete))
|
|
81
|
+
|
|
82
|
+
const boxes = fields.flatMap(field =>
|
|
83
|
+
Array.from(field.renderRoot?.querySelectorAll('input[type=checkbox], input[type=radio]') || [])
|
|
84
|
+
) as HTMLInputElement[]
|
|
85
|
+
|
|
86
|
+
expect(boxes.length, '줄을 고르는 칸을 찾지 못했다').to.be.greaterThan(0)
|
|
87
|
+
boxes.forEach(box =>
|
|
88
|
+
expect(box.getAttribute('aria-label'), '이름 없는 체크박스가 남아 있다').to.be.a('string').and.not.equal('')
|
|
89
|
+
)
|
|
90
|
+
})
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
describe('포커스를 담고 있는 IME buffer 가 지금 선 칸을 말한다', () => {
|
|
94
|
+
const columns = [
|
|
95
|
+
{ type: 'string', name: 'palletId', header: '파렛트 번호' },
|
|
96
|
+
{ type: 'string', name: 'location', header: '보관 위치' }
|
|
97
|
+
].map(buildColumn)
|
|
98
|
+
|
|
99
|
+
async function bodyFocusedAt(column: number) {
|
|
100
|
+
const body: any = await fixture(html`
|
|
101
|
+
<ox-grid-body
|
|
102
|
+
.config=${{ ...ZERO_CONFIG, columns }}
|
|
103
|
+
.columns=${columns}
|
|
104
|
+
.data=${{ ...ZERO_DATA, records: [{ palletId: 'P-0001', location: 'A-01' }] }}
|
|
105
|
+
.focused=${{ row: 0, column }}
|
|
106
|
+
></ox-grid-body>
|
|
107
|
+
`)
|
|
108
|
+
|
|
109
|
+
await body.updateComplete
|
|
110
|
+
|
|
111
|
+
return body.renderRoot.querySelector('#ime-buffer') as HTMLInputElement
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
it('첫 칸에 서 있으면 첫 칸의 이름을 읽는다', async () => {
|
|
115
|
+
expect((await bodyFocusedAt(0)).getAttribute('aria-label')).to.contain('파렛트 번호')
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
it('옆 칸으로 옮기면 읽히는 이름도 바뀐다 — 안 바뀌면 어디에 선 것인지 알 수 없다', async () => {
|
|
119
|
+
expect((await bodyFocusedAt(1)).getAttribute('aria-label')).to.contain('보관 위치')
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
it('보조기술에서 지우지 않는다 — 포커스를 받는 자리다', async () => {
|
|
123
|
+
expect((await bodyFocusedAt(0)).getAttribute('aria-hidden')).to.be.null
|
|
124
|
+
})
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* 표를 표라고 선언했나.
|
|
129
|
+
*
|
|
130
|
+
* ## 왜 시험이 필요한가
|
|
131
|
+
*
|
|
132
|
+
* 이 표는 CSS grid 로 그린다 — 칸이 평평하게 놓여 있고 **줄이라는 요소가 없다.** 보기에는 줄이
|
|
133
|
+
* 있지만 그것은 같은 높이에 놓였다는 그림일 뿐이다. 그래서 스크린 리더에게 이 화면은 「여기가
|
|
134
|
+
* 표다」도, 「지금 3행 3열이다」도, 「전체는 40행이다」도 아닌 **입력칸 더미**였다.
|
|
135
|
+
*
|
|
136
|
+
* 줄 감싸개를 넣으면서 두 가지가 동시에 깨질 수 있다.
|
|
137
|
+
*
|
|
138
|
+
* ```
|
|
139
|
+
* 뜻이 서나 role=grid / row / columnheader / gridcell 이 제대로 겹쳐 있나
|
|
140
|
+
* 모양이 사나 display: contents 가 정말로 상자를 안 만드나 — 만들면 표가 한 줄로 무너진다
|
|
141
|
+
* ```
|
|
142
|
+
*
|
|
143
|
+
* 두 번째가 특히 중요하다. `display: contents` 를 잘못 걸면 칸들이 grid 항목이 아니게 되어
|
|
144
|
+
* 열이 사라진다. 그래서 **자리를 실제로 확인한다** — 한 줄 안의 칸은 왼쪽으로 갈수록 x 가 커지고,
|
|
145
|
+
* 줄과 줄은 y 가 달라야 한다.
|
|
146
|
+
*/
|
|
147
|
+
describe('표를 표라고 선언한다', () => {
|
|
148
|
+
/* ox-grid 는 이미 다듬어진 column 을 받는다 — 다듬는 것은 ox-grist 의 일이다. */
|
|
149
|
+
const columns = [
|
|
150
|
+
{ type: 'gutter', gutterName: 'row-selector', name: '__selected__', multiple: true },
|
|
151
|
+
{ type: 'string', name: 'palletId', header: '파렛트 번호', sortable: true },
|
|
152
|
+
{ type: 'string', name: 'location', header: '보관 위치', sortable: true }
|
|
153
|
+
].map(buildColumn)
|
|
154
|
+
|
|
155
|
+
async function grid(overrides: any = {}) {
|
|
156
|
+
const el: any = await fixture(html`
|
|
157
|
+
<ox-grid
|
|
158
|
+
aria-label="입고 대기 목록"
|
|
159
|
+
.config=${{ ...ZERO_CONFIG, columns, rows: { ...ZERO_CONFIG.rows } }}
|
|
160
|
+
.data=${{
|
|
161
|
+
page: 1,
|
|
162
|
+
limit: 20,
|
|
163
|
+
total: 40,
|
|
164
|
+
records: [
|
|
165
|
+
{ palletId: 'P-0001', location: 'A-01' },
|
|
166
|
+
{ palletId: 'P-0002', location: 'A-02' }
|
|
167
|
+
],
|
|
168
|
+
...overrides
|
|
169
|
+
}}
|
|
170
|
+
></ox-grid>
|
|
171
|
+
`)
|
|
172
|
+
|
|
173
|
+
await el.updateComplete
|
|
174
|
+
|
|
175
|
+
const header = el.renderRoot.querySelector('ox-grid-header')
|
|
176
|
+
const body = el.renderRoot.querySelector('ox-grid-body')
|
|
177
|
+
|
|
178
|
+
await header?.updateComplete
|
|
179
|
+
await body?.updateComplete
|
|
180
|
+
|
|
181
|
+
return { el, header, body }
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
it('표 · 줄 · 칸이 겹쳐 있다', async () => {
|
|
185
|
+
const { el, header, body } = await grid()
|
|
186
|
+
|
|
187
|
+
const grid_ = el.renderRoot.querySelector('[role=grid]')
|
|
188
|
+
|
|
189
|
+
expect(grid_, 'role=grid 가 없다').to.exist
|
|
190
|
+
expect(header.getAttribute('role')).to.equal('rowgroup')
|
|
191
|
+
expect(body.getAttribute('role')).to.equal('rowgroup')
|
|
192
|
+
|
|
193
|
+
expect(header.renderRoot.querySelectorAll('[role=row]').length).to.equal(1)
|
|
194
|
+
expect(body.renderRoot.querySelectorAll('[role=row]').length).to.equal(2)
|
|
195
|
+
expect(header.renderRoot.querySelectorAll('[role=columnheader]').length).to.equal(3)
|
|
196
|
+
})
|
|
197
|
+
|
|
198
|
+
it('전체가 몇 줄 몇 열인지 말한다 — 지금 페이지가 아니라', async () => {
|
|
199
|
+
const { el } = await grid()
|
|
200
|
+
|
|
201
|
+
const grid_ = el.renderRoot.querySelector('[role=grid]')
|
|
202
|
+
|
|
203
|
+
/* 머리 한 줄 + 전체 40건. 화면에 두 줄만 그려도 40건짜리 표다. */
|
|
204
|
+
expect(grid_.getAttribute('aria-rowcount')).to.equal('41')
|
|
205
|
+
expect(grid_.getAttribute('aria-colcount')).to.equal('3')
|
|
206
|
+
expect(grid_.getAttribute('aria-label')).to.equal('입고 대기 목록')
|
|
207
|
+
})
|
|
208
|
+
|
|
209
|
+
it('2페이지의 첫 줄은 21번째 줄이다 — 페이지마다 1번으로 돌아가지 않는다', async () => {
|
|
210
|
+
const { body } = await grid({ page: 2 })
|
|
211
|
+
|
|
212
|
+
const rows = Array.from(body.renderRoot.querySelectorAll('[role=row]')) as HTMLElement[]
|
|
213
|
+
|
|
214
|
+
/* 머리 한 줄(1) + 앞 페이지 20건 = 22번째부터 */
|
|
215
|
+
expect(rows[0].getAttribute('aria-rowindex')).to.equal('22')
|
|
216
|
+
expect(rows[1].getAttribute('aria-rowindex')).to.equal('23')
|
|
217
|
+
})
|
|
218
|
+
|
|
219
|
+
it('칸이 몇 번째 열인지 말한다 — 남는 폭을 메우는 칸은 세지 않는다', async () => {
|
|
220
|
+
const { body } = await grid()
|
|
221
|
+
|
|
222
|
+
const row = body.renderRoot.querySelector('[role=row]') as HTMLElement
|
|
223
|
+
const cells = Array.from(row.querySelectorAll('[role=gridcell]')) as HTMLElement[]
|
|
224
|
+
|
|
225
|
+
expect(cells.map(cell => cell.getAttribute('aria-colindex'))).to.deep.equal(['1', '2', '3'])
|
|
226
|
+
expect(row.querySelectorAll('[role=presentation]').length, '메우는 칸이 표의 칸으로 세어졌다').to.equal(1)
|
|
227
|
+
})
|
|
228
|
+
|
|
229
|
+
it('정렬 상태를 글자로도 말한다 — 화살표는 눈으로만 읽힌다', async () => {
|
|
230
|
+
const el: any = await fixture(html`
|
|
231
|
+
<ox-grid
|
|
232
|
+
.config=${{ ...ZERO_CONFIG, columns, rows: { ...ZERO_CONFIG.rows } }}
|
|
233
|
+
.sorters=${[{ name: 'palletId', desc: true }]}
|
|
234
|
+
.data=${{ records: [{ palletId: 'P-0001', location: 'A-01' }] }}
|
|
235
|
+
></ox-grid>
|
|
236
|
+
`)
|
|
237
|
+
|
|
238
|
+
await el.updateComplete
|
|
239
|
+
|
|
240
|
+
const header = el.renderRoot.querySelector('ox-grid-header')
|
|
241
|
+
await header.updateComplete
|
|
242
|
+
|
|
243
|
+
const headers = Array.from(header.renderRoot.querySelectorAll('[role=columnheader]')) as HTMLElement[]
|
|
244
|
+
const sorts = headers.map(cell => cell.getAttribute('aria-sort'))
|
|
245
|
+
|
|
246
|
+
/* 거터는 정렬할 수 없다 — 있지도 않은 기능을 있다고 말하지 않는다. */
|
|
247
|
+
expect(sorts[0]).to.be.null
|
|
248
|
+
expect(sorts[1], '내림차순으로 정렬된 열').to.equal('descending')
|
|
249
|
+
expect(sorts[2], '정렬할 수 있으나 지금은 아닌 열').to.equal('none')
|
|
250
|
+
})
|
|
251
|
+
|
|
252
|
+
it('줄 감싸개가 배치를 건드리지 않는다 — 상자를 만들면 표가 무너진다', async () => {
|
|
253
|
+
const { body } = await grid()
|
|
254
|
+
|
|
255
|
+
const rows = Array.from(body.renderRoot.querySelectorAll('[role=row]')) as HTMLElement[]
|
|
256
|
+
const first = Array.from(rows[0].children) as HTMLElement[]
|
|
257
|
+
|
|
258
|
+
/* 감싸개 자신은 상자가 없다 */
|
|
259
|
+
expect(getComputedStyle(rows[0]).display).to.equal('contents')
|
|
260
|
+
|
|
261
|
+
/* 한 줄 안의 칸은 오른쪽으로 나아간다 — 한 자리에 겹쳐 있으면 열이 사라진 것이다 */
|
|
262
|
+
const lefts = first.map(cell => cell.offsetLeft)
|
|
263
|
+
expect(new Set(lefts).size, '칸들이 같은 x 에 겹쳐 있다').to.be.greaterThan(1)
|
|
264
|
+
lefts.slice(1).forEach((left, index) => expect(left).to.be.greaterThan(lefts[index]))
|
|
265
|
+
|
|
266
|
+
/* 줄과 줄은 아래로 내려간다 */
|
|
267
|
+
const firstTop = (rows[0].children[0] as HTMLElement).offsetTop
|
|
268
|
+
const secondTop = (rows[1].children[0] as HTMLElement).offsetTop
|
|
269
|
+
expect(secondTop, '두 줄이 같은 y 에 있다').to.be.greaterThan(firstTop)
|
|
270
|
+
})
|
|
271
|
+
})
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* 묶음 머리가 있는 표.
|
|
275
|
+
*
|
|
276
|
+
* 머리가 두 줄이 되고, 묶이지 않은 열은 두 줄에 걸친다(`.span-both`). 배치가 CSS grid 의
|
|
277
|
+
* `grid-row` / `grid-column` 으로 이루어지므로 **줄 감싸개가 가장 위험한 자리**다.
|
|
278
|
+
*/
|
|
279
|
+
describe('묶음 머리 — 머리가 두 줄이다', () => {
|
|
280
|
+
const columns = [
|
|
281
|
+
{ type: 'string', name: 'palletId', header: '파렛트 번호' },
|
|
282
|
+
{ type: 'string', name: 'width', header: { renderer: '폭', group: '치수' } },
|
|
283
|
+
{ type: 'string', name: 'height', header: { renderer: '높이', group: '치수' } }
|
|
284
|
+
].map(buildColumn)
|
|
285
|
+
|
|
286
|
+
async function grouped() {
|
|
287
|
+
const el: any = await fixture(html`
|
|
288
|
+
<ox-grid
|
|
289
|
+
.config=${{ ...ZERO_CONFIG, columns, rows: { ...ZERO_CONFIG.rows } }}
|
|
290
|
+
.data=${{ total: 1, records: [{ palletId: 'P-0001', width: '1200', height: '900' }] }}
|
|
291
|
+
></ox-grid>
|
|
292
|
+
`)
|
|
293
|
+
|
|
294
|
+
await el.updateComplete
|
|
295
|
+
|
|
296
|
+
const header = el.renderRoot.querySelector('ox-grid-header')
|
|
297
|
+
const body = el.renderRoot.querySelector('ox-grid-body')
|
|
298
|
+
|
|
299
|
+
await header.updateComplete
|
|
300
|
+
await body.updateComplete
|
|
301
|
+
|
|
302
|
+
return { el, header, body }
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
it('머리가 두 줄로 세어진다 — 본문은 3번째 줄부터', async () => {
|
|
306
|
+
const { el, header, body } = await grouped()
|
|
307
|
+
|
|
308
|
+
expect(header.renderRoot.querySelectorAll('[role=row]').length).to.equal(2)
|
|
309
|
+
|
|
310
|
+
/* 머리 두 줄 + 1건 */
|
|
311
|
+
expect(el.renderRoot.querySelector('[role=grid]').getAttribute('aria-rowcount')).to.equal('3')
|
|
312
|
+
|
|
313
|
+
const rows = Array.from(body.renderRoot.querySelectorAll('[role=row]')) as HTMLElement[]
|
|
314
|
+
expect(rows[0].getAttribute('aria-rowindex')).to.equal('3')
|
|
315
|
+
})
|
|
316
|
+
|
|
317
|
+
it('묶음 머리가 몇 열을 덮는지 말한다', async () => {
|
|
318
|
+
const { header } = await grouped()
|
|
319
|
+
|
|
320
|
+
const cells = Array.from(header.renderRoot.querySelectorAll('[role=columnheader]')) as HTMLElement[]
|
|
321
|
+
const first = cells[0]
|
|
322
|
+
const group = cells.find(cell => cell.getAttribute('aria-colspan'))
|
|
323
|
+
|
|
324
|
+
/* 묶이지 않은 열은 두 줄에 걸친다 */
|
|
325
|
+
expect(first.getAttribute('aria-rowspan')).to.equal('2')
|
|
326
|
+
expect(first.getAttribute('aria-colindex')).to.equal('1')
|
|
327
|
+
|
|
328
|
+
/* 치수 묶음은 2 · 3열을 덮는다 */
|
|
329
|
+
expect(group, '묶음 머리를 찾지 못했다').to.exist
|
|
330
|
+
expect(group!.getAttribute('aria-colindex')).to.equal('2')
|
|
331
|
+
expect(group!.getAttribute('aria-colspan')).to.equal('2')
|
|
332
|
+
})
|
|
333
|
+
|
|
334
|
+
it('두 줄짜리 머리의 배치가 그대로다 — 묶음이 아래 줄보다 위에 있다', async () => {
|
|
335
|
+
const { header } = await grouped()
|
|
336
|
+
|
|
337
|
+
const cells = Array.from(header.renderRoot.querySelectorAll('[role=columnheader]')) as HTMLElement[]
|
|
338
|
+
const group = cells.find(cell => cell.getAttribute('aria-colspan'))!
|
|
339
|
+
const leaf = cells.find(cell => !cell.getAttribute('aria-colspan') && cell !== cells[0])!
|
|
340
|
+
|
|
341
|
+
expect(leaf.offsetTop, '묶음 머리와 그 아래 열이 같은 높이에 있다').to.be.greaterThan(group.offsetTop)
|
|
342
|
+
expect(group.offsetWidth, '묶음 머리가 두 열을 덮지 않는다').to.be.greaterThan(leaf.offsetWidth)
|
|
343
|
+
})
|
|
344
|
+
})
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* 표 감싸개가 바깥 배치를 건드리지 않나.
|
|
348
|
+
*
|
|
349
|
+
* `role=grid` 안에는 줄만 들어갈 수 있어서, 설정 단추 자리와 페이지 넘김은 감싸개 **밖**으로
|
|
350
|
+
* 나왔다. 그러면서 두 가지가 이 구조에 매인다.
|
|
351
|
+
*
|
|
352
|
+
* ```
|
|
353
|
+
* 세로 배치 호스트는 flex column 이다. 감싸개가 상자를 만들면 머리와 몸이 그 안으로 들어가
|
|
354
|
+
* flex 항목이 하나가 되고, 몸의 flex: 1 이 듣지 않아 높이가 무너진다
|
|
355
|
+
* 형제 선택자 「머리에 올렸을 때 설정 단추를 보인다」가 인접 형제 선택자다. 설정 단추가 감싸개
|
|
356
|
+
* 바로 뒤에 있어야 그 규칙이 성립한다
|
|
357
|
+
* ```
|
|
358
|
+
*/
|
|
359
|
+
describe('표 감싸개는 배치에 끼어들지 않는다', () => {
|
|
360
|
+
const columns = [
|
|
361
|
+
{ type: 'string', name: 'palletId', header: '파렛트 번호' },
|
|
362
|
+
{ type: 'string', name: 'location', header: '보관 위치' }
|
|
363
|
+
].map(buildColumn)
|
|
364
|
+
|
|
365
|
+
it('설정 단추는 표 바로 뒤에 있다 — 표 안이 아니라', async () => {
|
|
366
|
+
const el: any = await fixture(html`
|
|
367
|
+
<ox-grid
|
|
368
|
+
.config=${{ ...ZERO_CONFIG, columns, rows: { ...ZERO_CONFIG.rows } }}
|
|
369
|
+
.data=${{ total: 1, records: [{ palletId: 'P-0001', location: 'A-01' }] }}
|
|
370
|
+
></ox-grid>
|
|
371
|
+
`)
|
|
372
|
+
|
|
373
|
+
await el.updateComplete
|
|
374
|
+
|
|
375
|
+
const grid = el.renderRoot.querySelector('[role=grid]') as HTMLElement
|
|
376
|
+
const setting = el.renderRoot.querySelector('div[setting]') as HTMLElement
|
|
377
|
+
|
|
378
|
+
expect(setting, '설정 단추 자리가 없다').to.exist
|
|
379
|
+
expect(grid.contains(setting), '설정 단추가 표 안에 들어갔다 — 표 읽기가 깨진다').to.be.false
|
|
380
|
+
expect(grid.nextElementSibling, '인접 형제 규칙이 성립하지 않는다').to.equal(setting)
|
|
381
|
+
})
|
|
382
|
+
|
|
383
|
+
it('머리와 몸이 그대로 호스트의 세로 배치를 쓴다', async () => {
|
|
384
|
+
const el: any = await fixture(html`
|
|
385
|
+
<div style="height: 300px; display: flex">
|
|
386
|
+
<ox-grid
|
|
387
|
+
style="flex: 1"
|
|
388
|
+
.config=${{ ...ZERO_CONFIG, columns, rows: { ...ZERO_CONFIG.rows } }}
|
|
389
|
+
.data=${{ total: 1, records: [{ palletId: 'P-0001', location: 'A-01' }] }}
|
|
390
|
+
></ox-grid>
|
|
391
|
+
</div>
|
|
392
|
+
`)
|
|
393
|
+
|
|
394
|
+
const grid = el.querySelector('ox-grid') as any
|
|
395
|
+
await grid.updateComplete
|
|
396
|
+
|
|
397
|
+
const wrapper = grid.renderRoot.querySelector('[role=grid]') as HTMLElement
|
|
398
|
+
const header = grid.renderRoot.querySelector('ox-grid-header') as HTMLElement
|
|
399
|
+
const body = grid.renderRoot.querySelector('ox-grid-body') as HTMLElement
|
|
400
|
+
|
|
401
|
+
expect(getComputedStyle(wrapper).display).to.equal('contents')
|
|
402
|
+
|
|
403
|
+
/* 몸이 남는 높이를 다 쓴다 — 감싸개가 상자를 만들면 이 값이 머리 높이만큼으로 줄어든다 */
|
|
404
|
+
expect(body.offsetHeight, '몸이 남는 높이를 쓰지 못한다').to.be.greaterThan(100)
|
|
405
|
+
expect(body.offsetTop, '몸이 머리 아래에 있지 않다').to.be.greaterThan(0)
|
|
406
|
+
expect(header.offsetTop).to.equal(0)
|
|
407
|
+
})
|
|
408
|
+
})
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { expect
|
|
2
|
-
import { html } from 'lit'
|
|
1
|
+
import { expect } from '@open-wc/testing'
|
|
3
2
|
|
|
4
3
|
import { DataGrist } from '../src/data-grist.js'
|
|
5
4
|
import { DataGrid } from '../src/data-grid/data-grid.js'
|
|
@@ -13,7 +12,7 @@ import { DataGrid } from '../src/data-grid/data-grid.js'
|
|
|
13
12
|
* 줄과 띠가 나란히 안 보여도 그 시험은 전부 초록이다. 실제로 그랬다.
|
|
14
13
|
*
|
|
15
14
|
* ```
|
|
16
|
-
* [
|
|
15
|
+
* [확인함] 2026-09-04 · operato-plant 인원 화면(어두운 모드)
|
|
17
16
|
* 줄 rgb(30 34 40) · 띠 rgb(26 30 35) → 대비 1.048 보이지 않는다
|
|
18
17
|
* 그때 고정 열 시험 열여섯 건은 전부 초록이었다
|
|
19
18
|
* ```
|
|
@@ -72,15 +71,32 @@ const 대비 = (a: string, b: string) => {
|
|
|
72
71
|
return (x + 0.05) / (y + 0.05)
|
|
73
72
|
}
|
|
74
73
|
|
|
75
|
-
/**
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
74
|
+
/**
|
|
75
|
+
* 그 팔레트에서 선언값이 실제로 무슨 색이 되는지 — 브라우저에게 계산시킨다.
|
|
76
|
+
*
|
|
77
|
+
* ── 기다리지 않는다 (2026-09-05) ──────────────────────────────────────────
|
|
78
|
+
* 전에는 fixture() 로 세우고 await 했다. 잴 것은 div 하나의 계산된 색뿐이라 렌더링을 기다릴
|
|
79
|
+
* 이유가 없는데, 그 await 가 mocha 의 2초 문턱에 걸려 **기계가 바쁠 때만 붉어졌다** —
|
|
80
|
+
* 빌드와 웹팩이 함께 돌던 동안 어두운 팔레트 두 건이 시간초과로 넘어갔고, 혼자 돌리면 초록이었다.
|
|
81
|
+
* 색 판정은 한 번도 실패한 적이 없다.
|
|
82
|
+
*
|
|
83
|
+
* 붙이고 재고 떼는 것으로 충분하다. 기다림이 없으니 부하와 무관하게 같은 답이 나온다.
|
|
84
|
+
*/
|
|
85
|
+
function 칠해보다(값: string, 팔레트: { 줄: string; 잉크: string; 사다리: string }) {
|
|
86
|
+
const probe = document.createElement('div')
|
|
82
87
|
|
|
83
|
-
|
|
88
|
+
probe.setAttribute(
|
|
89
|
+
'style',
|
|
90
|
+
`${팔레트.사다리} --grid-record-background-color:${팔레트.줄}; --grid-record-color:${팔레트.잉크}; background-color:${값};`
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
document.body.appendChild(probe)
|
|
94
|
+
|
|
95
|
+
try {
|
|
96
|
+
return getComputedStyle(probe).backgroundColor
|
|
97
|
+
} finally {
|
|
98
|
+
probe.remove()
|
|
99
|
+
}
|
|
84
100
|
}
|
|
85
101
|
|
|
86
102
|
/**
|
|
@@ -107,7 +123,7 @@ const 팔레트들 = {
|
|
|
107
123
|
* 얼마나 벌어져야 보이나.
|
|
108
124
|
*
|
|
109
125
|
* 지나는 줄 표시는 **훨씬 옅어야 한다** — 고른 줄과 같은 무게로 그리면 무엇이 골라졌는지 흐려진다.
|
|
110
|
-
* 그래서 큰 값을 요구하지 않는다. 다만 1.05 는 눈에 안 들어온다(위 [
|
|
126
|
+
* 그래서 큰 값을 요구하지 않는다. 다만 1.05 는 눈에 안 들어온다(위 [확인함]). 눈으로 확인한 값이
|
|
111
127
|
* 1.11 · 1.14 이므로 그 아래에 문턱을 둔다.
|
|
112
128
|
*/
|
|
113
129
|
const 최소분리 = 1.08
|
|
@@ -120,8 +136,8 @@ describe('마우스가 지나는 줄이 보인다', () => {
|
|
|
120
136
|
})
|
|
121
137
|
|
|
122
138
|
Object.entries(팔레트들).forEach(([이름, 팔레트]) => {
|
|
123
|
-
it(`${이름} 팔레트에서 줄과 띠가 갈린다`,
|
|
124
|
-
const 띠 =
|
|
139
|
+
it(`${이름} 팔레트에서 줄과 띠가 갈린다`, () => {
|
|
140
|
+
const 띠 = 칠해보다(값!, 팔레트)
|
|
125
141
|
const 벌어짐 = 대비(띠, 팔레트.줄)
|
|
126
142
|
|
|
127
143
|
expect(
|
|
@@ -130,8 +146,8 @@ describe('마우스가 지나는 줄이 보인다', () => {
|
|
|
130
146
|
).to.be.greaterThan(최소분리)
|
|
131
147
|
})
|
|
132
148
|
|
|
133
|
-
it(`${이름} 팔레트에서 띠가 줄을 덮지 않는다 — 옅어야 한다`,
|
|
134
|
-
const 띠 =
|
|
149
|
+
it(`${이름} 팔레트에서 띠가 줄을 덮지 않는다 — 옅어야 한다`, () => {
|
|
150
|
+
const 띠 = 칠해보다(값!, 팔레트)
|
|
135
151
|
|
|
136
152
|
expect(대비(띠, 팔레트.줄), '고른 줄과 같은 무게가 되면 무엇이 골라졌는지 흐려진다').to.be.lessThan(1.6)
|
|
137
153
|
})
|
package/translations/en.json
CHANGED
|
@@ -1,20 +1,30 @@
|
|
|
1
1
|
{
|
|
2
|
-
"button.save": "save",
|
|
3
2
|
"button.delete": "delete",
|
|
4
|
-
"
|
|
3
|
+
"button.save": "save",
|
|
5
4
|
"label.accumulator_avg": "avg",
|
|
6
5
|
"label.accumulator_count": "cnt",
|
|
7
6
|
"label.accumulator_max": "min",
|
|
8
7
|
"label.accumulator_min": "max",
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"text.
|
|
12
|
-
"text.
|
|
8
|
+
"label.accumulator_sum": "sum",
|
|
9
|
+
"label.filter": "filter",
|
|
10
|
+
"text.grid-cell-input": "{name} input",
|
|
11
|
+
"text.grid-cell-input-plain": "cell input",
|
|
12
|
+
"text.grid-clear-search": "clear the search or filters to see everything",
|
|
13
|
+
"text.grid-filter-from": "{name} filter, from",
|
|
14
|
+
"text.grid-filter-of": "{name} filter",
|
|
15
|
+
"text.grid-filter-to": "{name} filter, to",
|
|
16
|
+
"text.grid-no-records": "nothing to show",
|
|
17
|
+
"text.grid-nothing-found": "nothing found",
|
|
18
|
+
"text.grid-open-editor": "press to edit",
|
|
19
|
+
"text.grid-select-all-records": "select all rows",
|
|
20
|
+
"text.grid-select-record": "select row {row}",
|
|
21
|
+
"text.grid-total-records": "{total} in total",
|
|
22
|
+
"text.input-secret-hide": "hide",
|
|
13
23
|
"text.input-secret-placeholder": "enter secret information",
|
|
14
24
|
"text.input-secret-show": "show",
|
|
15
|
-
"text.input-secret-hide": "hide",
|
|
16
25
|
"text.input-secret-toggle": "show/hide",
|
|
17
|
-
"text.
|
|
18
|
-
"text.
|
|
19
|
-
"text.
|
|
26
|
+
"text.validation-reason.FORMAT": "invalid format",
|
|
27
|
+
"text.validation-reason.MANDATORY": "mandatory",
|
|
28
|
+
"text.validation-reason.RANGE": "out of range",
|
|
29
|
+
"text.validation-reason.UNIQUE": "duplicate value"
|
|
20
30
|
}
|
package/translations/ja.json
CHANGED
|
@@ -1,20 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"button.delete": "削除",
|
|
3
3
|
"button.save": "保存",
|
|
4
|
-
"label.accumulator_sum": "合計",
|
|
5
4
|
"label.accumulator_avg": "平均",
|
|
6
5
|
"label.accumulator_count": "カウント",
|
|
7
6
|
"label.accumulator_max": "最小",
|
|
8
7
|
"label.accumulator_min": "最大",
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"text.
|
|
12
|
-
"text.
|
|
8
|
+
"label.accumulator_sum": "合計",
|
|
9
|
+
"label.filter": "フィルター",
|
|
10
|
+
"text.grid-cell-input": "{name} 入力",
|
|
11
|
+
"text.grid-cell-input-plain": "セル入力",
|
|
12
|
+
"text.grid-clear-search": "検索語やフィルターを消すと全体が表示されます",
|
|
13
|
+
"text.grid-filter-from": "{name} フィルター 開始値",
|
|
14
|
+
"text.grid-filter-of": "{name} フィルター",
|
|
15
|
+
"text.grid-filter-to": "{name} フィルター 終了値",
|
|
16
|
+
"text.grid-no-records": "まだ何もありません",
|
|
17
|
+
"text.grid-nothing-found": "見つかりませんでした",
|
|
18
|
+
"text.grid-open-editor": "押して編集します",
|
|
19
|
+
"text.grid-select-all-records": "すべての行を選択",
|
|
20
|
+
"text.grid-select-record": "{row} 行目を選択",
|
|
21
|
+
"text.grid-total-records": "全 {total} 件",
|
|
22
|
+
"text.input-secret-hide": "非表示",
|
|
13
23
|
"text.input-secret-placeholder": "機密情報を入力",
|
|
14
24
|
"text.input-secret-show": "表示",
|
|
15
|
-
"text.input-secret-hide": "非表示",
|
|
16
25
|
"text.input-secret-toggle": "表示/非表示",
|
|
17
|
-
"text.
|
|
18
|
-
"text.
|
|
19
|
-
"text.
|
|
26
|
+
"text.validation-reason.FORMAT": "形式が正しくありません",
|
|
27
|
+
"text.validation-reason.MANDATORY": "必須",
|
|
28
|
+
"text.validation-reason.RANGE": "範囲外",
|
|
29
|
+
"text.validation-reason.UNIQUE": "重複"
|
|
20
30
|
}
|
package/translations/ko.json
CHANGED
|
@@ -1,21 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"button.delete": "삭제",
|
|
3
3
|
"button.save": "저장",
|
|
4
|
-
"label.accumulator_sum": "합계",
|
|
5
4
|
"label.accumulator_avg": "평균",
|
|
6
5
|
"label.accumulator_count": "계수",
|
|
7
6
|
"label.accumulator_max": "최소",
|
|
8
7
|
"label.accumulator_min": "최대",
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"text.
|
|
12
|
-
"text.
|
|
8
|
+
"label.accumulator_sum": "합계",
|
|
9
|
+
"label.filter": "필터",
|
|
10
|
+
"text.grid-cell-input": "{name} 입력",
|
|
11
|
+
"text.grid-cell-input-plain": "칸 입력",
|
|
12
|
+
"text.grid-clear-search": "검색어나 필터를 지우면 전체가 보입니다",
|
|
13
|
+
"text.grid-filter-from": "{name} 필터 시작값",
|
|
14
|
+
"text.grid-filter-of": "{name} 필터",
|
|
15
|
+
"text.grid-filter-to": "{name} 필터 끝값",
|
|
16
|
+
"text.grid-no-records": "아직 아무것도 없습니다",
|
|
17
|
+
"text.grid-nothing-found": "찾는 것이 없습니다",
|
|
18
|
+
"text.grid-open-editor": "눌러서 고칩니다",
|
|
19
|
+
"text.grid-select-all-records": "모든 행 선택",
|
|
20
|
+
"text.grid-select-record": "{row}번째 행 선택",
|
|
21
|
+
"text.grid-total-records": "모두 {total}건",
|
|
22
|
+
"text.input-secret-hide": "숨기기",
|
|
13
23
|
"text.input-secret-placeholder": "보안 정보 입력",
|
|
14
24
|
"text.input-secret-show": "보기",
|
|
15
|
-
"text.input-secret-hide": "숨기기",
|
|
16
25
|
"text.input-secret-toggle": "보기/숨기기",
|
|
17
|
-
"
|
|
18
|
-
"text.
|
|
19
|
-
"text.
|
|
20
|
-
"text.
|
|
26
|
+
"text.validation-reason.FORMAT": "잘못된 형식입니다.",
|
|
27
|
+
"text.validation-reason.MANDATORY": "필수 입력 항목입니다.",
|
|
28
|
+
"text.validation-reason.RANGE": "범위를 벗어났습니다.",
|
|
29
|
+
"text.validation-reason.UNIQUE": "중복된 값입니다."
|
|
21
30
|
}
|