@operato/data-grist 10.29.78 → 10.29.79
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 +17 -0
- package/dist/src/editors/ox-grist-editor-date.d.ts +2 -0
- package/dist/src/editors/ox-grist-editor-date.js +3 -8
- package/dist/src/editors/ox-grist-editor-date.js.map +1 -1
- package/dist/src/editors/ox-grist-editor-month.d.ts +2 -0
- package/dist/src/editors/ox-grist-editor-month.js +3 -1
- package/dist/src/editors/ox-grist-editor-month.js.map +1 -1
- package/dist/src/editors/ox-grist-editor-week.d.ts +2 -0
- package/dist/src/editors/ox-grist-editor-week.js +3 -1
- package/dist/src/editors/ox-grist-editor-week.js.map +1 -1
- package/dist/src/editors/ox-grist-editor.js +2 -1
- package/dist/src/editors/ox-grist-editor.js.map +1 -1
- package/dist/src/filters/filter-input.d.ts +1 -0
- package/dist/src/filters/filter-input.js +20 -0
- package/dist/src/filters/filter-input.js.map +1 -1
- package/dist/src/filters/filter-range-date.d.ts +7 -0
- package/dist/src/filters/filter-range-date.js +53 -0
- package/dist/src/filters/filter-range-date.js.map +1 -1
- package/dist/src/filters/filter-select-buttons.js +7 -0
- package/dist/src/filters/filter-select-buttons.js.map +1 -1
- package/dist/src/filters/filter-styles.js +8 -2
- package/dist/src/filters/filter-styles.js.map +1 -1
- package/dist/src/filters/filters-form.js +38 -14
- package/dist/src/filters/filters-form.js.map +1 -1
- package/dist/src/filters/pill-choice.d.ts +24 -0
- package/dist/src/filters/pill-choice.js +63 -0
- package/dist/src/filters/pill-choice.js.map +1 -0
- package/dist/test/date-fields.test.d.ts +2 -0
- package/dist/test/date-fields.test.js +138 -0
- package/dist/test/date-fields.test.js.map +1 -0
- package/dist/test/filter-select-buttons-count.test.js +2 -1
- package/dist/test/filter-select-buttons-count.test.js.map +1 -1
- package/dist/test/filters-phone-width.test.d.ts +1 -0
- package/dist/test/filters-phone-width.test.js +33 -0
- package/dist/test/filters-phone-width.test.js.map +1 -0
- package/dist/test/filters-pills.test.d.ts +2 -0
- package/dist/test/filters-pills.test.js +149 -0
- package/dist/test/filters-pills.test.js.map +1 -0
- package/dist/test/list-defaults.test.js +2 -1
- package/dist/test/list-defaults.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/test/date-fields.test.ts +163 -0
- package/test/filter-select-buttons-count.test.ts +2 -1
- package/test/filters-phone-width.test.ts +35 -0
- package/test/filters-pills.test.ts +162 -0
- package/test/list-defaults.test.ts +2 -1
- package/translations/en.json +8 -1
- package/translations/es.json +8 -1
- package/translations/ja.json +8 -1
- package/translations/ko.json +8 -1
- package/translations/ms.json +8 -1
- package/translations/zh.json +8 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@operato/data-grist",
|
|
3
|
-
"version": "10.29.
|
|
3
|
+
"version": "10.29.79",
|
|
4
4
|
"description": "User interface for grid (desktop) and list (mobile)",
|
|
5
5
|
"author": "heartyoh",
|
|
6
6
|
"type": "module",
|
|
@@ -82,13 +82,13 @@
|
|
|
82
82
|
"@material/web": "^2.0.0",
|
|
83
83
|
"@operato/headroom": "^10.29.1",
|
|
84
84
|
"@operato/i18n": "^10.29.27",
|
|
85
|
-
"@operato/input": "^10.29.
|
|
86
|
-
"@operato/layout": "^10.29.
|
|
85
|
+
"@operato/input": "^10.29.79",
|
|
86
|
+
"@operato/layout": "^10.29.79",
|
|
87
87
|
"@operato/list-state": "^10.29.76",
|
|
88
|
-
"@operato/p13n": "^10.29.
|
|
89
|
-
"@operato/popup": "^10.29.
|
|
88
|
+
"@operato/p13n": "^10.29.79",
|
|
89
|
+
"@operato/popup": "^10.29.79",
|
|
90
90
|
"@operato/pull-to-refresh": "^10.29.23",
|
|
91
|
-
"@operato/styles": "^10.29.
|
|
91
|
+
"@operato/styles": "^10.29.79",
|
|
92
92
|
"@operato/time-calculator": "^10.29.1",
|
|
93
93
|
"@operato/utils": "^10.29.76",
|
|
94
94
|
"i18next": "^24.2.1",
|
|
@@ -129,5 +129,5 @@
|
|
|
129
129
|
"prettier --write"
|
|
130
130
|
]
|
|
131
131
|
},
|
|
132
|
-
"gitHead": "
|
|
132
|
+
"gitHead": "f86fbc40c2d343d7996573fe49f82829c1ac1ea4"
|
|
133
133
|
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { expect, fixture } from '@open-wc/testing'
|
|
2
|
+
import { sendKeys } from '@web/test-runner-commands'
|
|
3
|
+
import { html, render } from 'lit'
|
|
4
|
+
|
|
5
|
+
import { i18next } from '@operato/i18n'
|
|
6
|
+
import { OxInputDate } from '@operato/input/ox-input-date.js'
|
|
7
|
+
|
|
8
|
+
import '../src/editors/ox-grist-editor-date.js'
|
|
9
|
+
import '../src/editors/ox-grist-editor-week.js'
|
|
10
|
+
import { OxFiltersForm } from '../src/filters/filters-form.js'
|
|
11
|
+
import { FilterInput } from '../src/filters/filter-input.js'
|
|
12
|
+
import { FilterRangeDate } from '../src/filters/filter-range-date.js'
|
|
13
|
+
|
|
14
|
+
/*
|
|
15
|
+
* Days, weeks and months in a grid - its filters and its editors - are the one field for them, ox-input-date: typed
|
|
16
|
+
* at a desk, the phone's own picker on touch. Tests stand at a desk.
|
|
17
|
+
*/
|
|
18
|
+
const inner = (field: Element) => (field as OxInputDate).renderRoot.querySelector('input') as HTMLInputElement
|
|
19
|
+
|
|
20
|
+
describe('date fields in a grid', () => {
|
|
21
|
+
const touchQuery = OxInputDate.touchQuery
|
|
22
|
+
let previousLanguage: string
|
|
23
|
+
before(async () => {
|
|
24
|
+
OxInputDate.touchQuery = 'not all'
|
|
25
|
+
previousLanguage = i18next.language
|
|
26
|
+
await i18next.changeLanguage('ko')
|
|
27
|
+
})
|
|
28
|
+
after(async () => {
|
|
29
|
+
OxInputDate.touchQuery = touchQuery
|
|
30
|
+
/* The language is kept in the browser's storage; the next test file must not start in Korean. */
|
|
31
|
+
await i18next.changeLanguage(previousLanguage)
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
describe('filters', () => {
|
|
35
|
+
const column = (type: string, operator = 'between') =>
|
|
36
|
+
({ name: 'day', type, header: 'day', record: {}, filter: { operator } }) as any
|
|
37
|
+
|
|
38
|
+
it('bounds a range of days, weeks or months by two of the one field; a time keeps the browser\'s', async () => {
|
|
39
|
+
for (const type of ['date', 'week', 'month']) {
|
|
40
|
+
const form = await fixture<HTMLFormElement>(html`<form><label>${FilterRangeDate(column(type), [], {} as any)}</label></form>`)
|
|
41
|
+
const fields = form.querySelectorAll('ox-input-date')
|
|
42
|
+
expect(fields.length, type).to.equal(2)
|
|
43
|
+
expect((fields[0] as OxInputDate).type).to.equal(type)
|
|
44
|
+
expect(form.querySelector('input'), type).to.equal(null)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const time = await fixture<HTMLFormElement>(html`<form><label>${FilterRangeDate(column('datetime'), [], {} as any)}</label></form>`)
|
|
48
|
+
expect(time.querySelectorAll('input[type="datetime-local"]').length).to.equal(2)
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
it('shows a default bound given as a time as its day, and a week as it is', async () => {
|
|
52
|
+
const from = new Date(2026, 10, 2).getTime()
|
|
53
|
+
const days = await fixture<HTMLFormElement>(html`<form><label>${FilterRangeDate(column('date'), [from, '2026-11-10'], {} as any)}</label></form>`)
|
|
54
|
+
const [first, last] = Array.from(days.querySelectorAll('ox-input-date')) as OxInputDate[]
|
|
55
|
+
expect(first.value).to.equal('2026-11-02')
|
|
56
|
+
expect(last.value).to.equal('2026-11-10')
|
|
57
|
+
|
|
58
|
+
const weeks = await fixture<HTMLFormElement>(html`<form><label>${FilterRangeDate(column('week'), ['2026-W40', from], {} as any)}</label></form>`)
|
|
59
|
+
expect((Array.from(weeks.querySelectorAll('ox-input-date')) as OxInputDate[]).map(field => field.value)).to.deep.equal(['2026-W40', '2026-W45'])
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
it('gives the form both bounds, from first, and narrows the column when one is typed', async () => {
|
|
63
|
+
const form = await fixture<HTMLFormElement>(html`<form><label>${FilterRangeDate(column('date'), ['2026-11-01', '2026-11-30'], {} as any)}</label></form>`)
|
|
64
|
+
expect(new FormData(form).getAll('day')).to.deep.equal(['2026-11-01', '2026-11-30'])
|
|
65
|
+
|
|
66
|
+
let asked: any
|
|
67
|
+
form.addEventListener('filter-change', e => (asked = (e as CustomEvent).detail))
|
|
68
|
+
const to = form.querySelector('ox-input-date[to]') as OxInputDate
|
|
69
|
+
inner(to).focus()
|
|
70
|
+
inner(to).select()
|
|
71
|
+
await sendKeys({ type: '1115' })
|
|
72
|
+
await sendKeys({ press: 'Enter' })
|
|
73
|
+
expect(asked).to.deep.equal({ name: 'day', operator: 'between', value: ['2026-11-01', '2026-11-15'] })
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
it('names its two empty bounds 시작일 and 종료일, not a format pattern', async () => {
|
|
77
|
+
const form = await fixture<HTMLFormElement>(html`<form><label>${FilterRangeDate(column('date'), [], {} as any)}</label></form>`)
|
|
78
|
+
const fields = Array.from(form.querySelectorAll('ox-input-date')) as OxInputDate[]
|
|
79
|
+
await Promise.all(fields.map(field => field.updateComplete))
|
|
80
|
+
expect(fields.map(field => inner(field).placeholder)).to.deep.equal(['시작일', '종료일'])
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
it('narrows by one month typed into a single month filter', async () => {
|
|
84
|
+
const form = await fixture<HTMLFormElement>(html`<form>${FilterInput(column('month', 'eq'), '', {} as any)}</form>`)
|
|
85
|
+
let asked: any
|
|
86
|
+
form.addEventListener('filter-change', e => (asked = (e as CustomEvent).detail))
|
|
87
|
+
const field = form.querySelector('ox-input-date') as OxInputDate
|
|
88
|
+
inner(field).focus()
|
|
89
|
+
await sendKeys({ type: '3월' })
|
|
90
|
+
await sendKeys({ press: 'Enter' })
|
|
91
|
+
expect(asked.value).to.match(/^\d{4}-03$/)
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
/* The phone rule of 398caeefe holds for the field: a range on a 375px screen ends inside its room. */
|
|
95
|
+
it('keeps a range of the field inside a phone\'s width', async () => {
|
|
96
|
+
const room = await fixture<HTMLDivElement>(html`<div style="display:flex;width:351px"></div>`)
|
|
97
|
+
const host = document.createElement('div')
|
|
98
|
+
host.className = 'host'
|
|
99
|
+
room.appendChild(host)
|
|
100
|
+
const root = host.attachShadow({ mode: 'open' })
|
|
101
|
+
const style = document.createElement('style')
|
|
102
|
+
style.textContent = (Array.isArray(OxFiltersForm.styles) ? OxFiltersForm.styles : [OxFiltersForm.styles])
|
|
103
|
+
.map(s => String((s as any).cssText ?? s))
|
|
104
|
+
.join('\n')
|
|
105
|
+
root.appendChild(style)
|
|
106
|
+
const form = document.createElement('form')
|
|
107
|
+
root.appendChild(form)
|
|
108
|
+
render(
|
|
109
|
+
html`<label filter-title between><span>조회 기간 조회 기간 조회 기간</span>${FilterRangeDate(column('date'), ['2026-11-01', '2026-11-30'], {} as any)}</label>`,
|
|
110
|
+
form
|
|
111
|
+
)
|
|
112
|
+
await (form.querySelector('ox-input-date[to]') as OxInputDate).updateComplete
|
|
113
|
+
const right = Math.round(form.querySelector('ox-input-date[to]')!.getBoundingClientRect().right)
|
|
114
|
+
expect(right, 'the last date runs past the room').to.be.at.most(Math.round(room.getBoundingClientRect().right))
|
|
115
|
+
})
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
describe('editors', () => {
|
|
119
|
+
const open = async (tag: string, value: string) => {
|
|
120
|
+
const editor = await fixture<any>(
|
|
121
|
+
tag === 'week'
|
|
122
|
+
? html`<ox-grist-editor-week .column=${{ name: 'w', type: 'week', record: {} }} .record=${{ w: value }}></ox-grist-editor-week>`
|
|
123
|
+
: html`<ox-grist-editor-date .column=${{ name: 'd', type: 'date', record: {} }} .record=${{ d: value }}></ox-grist-editor-date>`
|
|
124
|
+
)
|
|
125
|
+
await editor.updateComplete
|
|
126
|
+
await new Promise(r => requestAnimationFrame(r))
|
|
127
|
+
return editor
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
it('edits a day cell in the field and commits what is typed when it is left', async () => {
|
|
131
|
+
const editor = await open('date', '2026-01-01')
|
|
132
|
+
const field = editor.editor as OxInputDate
|
|
133
|
+
expect(field.tagName).to.equal('OX-INPUT-DATE')
|
|
134
|
+
await field.updateComplete
|
|
135
|
+
expect(inner(field).value).to.equal('2026-01-01')
|
|
136
|
+
|
|
137
|
+
let commit: any
|
|
138
|
+
editor.addEventListener('field-change', (e: CustomEvent) => (commit = e.detail))
|
|
139
|
+
inner(field).focus()
|
|
140
|
+
inner(field).select()
|
|
141
|
+
await sendKeys({ type: '1110' })
|
|
142
|
+
inner(field).blur()
|
|
143
|
+
expect(commit?.after).to.equal('2026-11-10')
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
it('commits the week a key moved to, and nothing when nothing was entered', async () => {
|
|
147
|
+
const editor = await open('week', '2026-W45')
|
|
148
|
+
const field = editor.editor as OxInputDate
|
|
149
|
+
let commit: any
|
|
150
|
+
editor.addEventListener('field-change', (e: CustomEvent) => (commit = e.detail))
|
|
151
|
+
|
|
152
|
+
inner(field).focus()
|
|
153
|
+
inner(field).blur()
|
|
154
|
+
expect(commit, 'an editor left untouched commits nothing').to.equal(undefined)
|
|
155
|
+
|
|
156
|
+
inner(field).focus()
|
|
157
|
+
await sendKeys({ press: 'ArrowUp' })
|
|
158
|
+
await field.updateComplete
|
|
159
|
+
editor.flush()
|
|
160
|
+
expect(commit?.after).to.equal('2026-W46')
|
|
161
|
+
})
|
|
162
|
+
})
|
|
163
|
+
})
|
|
@@ -30,7 +30,8 @@ describe('select-buttons filter', () => {
|
|
|
30
30
|
[4, 'not yet released'],
|
|
31
31
|
[0, undefined]
|
|
32
32
|
])
|
|
33
|
-
|
|
33
|
+
/* The first chip is 「전체」 (several choices may be none) and has no count of its own. */
|
|
34
|
+
const chips = [...buttons.renderRoot.querySelectorAll('md-filter-chip:not([data-all])')] as HTMLElement[]
|
|
34
35
|
expect(chips.map(chip => chip.querySelector('.count')?.textContent)).to.deep.equal(['4', '0'])
|
|
35
36
|
host.remove()
|
|
36
37
|
})
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { expect } from '@open-wc/testing'
|
|
2
|
+
|
|
3
|
+
import { OxFiltersForm } from '../src/filters/filters-form.js'
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
* A filter wider than the line - a date range on a phone: its label and two dates - ran past the screen's edge, the
|
|
7
|
+
* form taking its content's width (2026-11-10, 감사 기록 at 375px). The form is no wider than the room it is given, and
|
|
8
|
+
* a filter's inputs shrink into it.
|
|
9
|
+
*/
|
|
10
|
+
const text = (styles: unknown) =>
|
|
11
|
+
(Array.isArray(styles) ? styles : [styles]).map(s => String((s as { cssText?: string }).cssText ?? s)).join('\n')
|
|
12
|
+
|
|
13
|
+
describe('a date range filter on a phone', () => {
|
|
14
|
+
it('ends inside the room the form is given', async () => {
|
|
15
|
+
const frame = document.createElement('iframe')
|
|
16
|
+
frame.style.cssText = 'width:375px;height:300px;border:0'
|
|
17
|
+
document.body.appendChild(frame)
|
|
18
|
+
const doc = frame.contentDocument!
|
|
19
|
+
const css = text(OxFiltersForm.styles).replace(/:host/g, '.host')
|
|
20
|
+
doc.open()
|
|
21
|
+
doc.write(`<style>body{margin:0}</style><style>${css}</style>
|
|
22
|
+
<div id="room" style="display:flex;width:351px"><div class="host"><form><label filter-title between><span>조회 기간</span>
|
|
23
|
+
<input from type="date" /> ~ <input id="to" to type="date" />
|
|
24
|
+
</label></form></div></div>`)
|
|
25
|
+
doc.close()
|
|
26
|
+
await new Promise(resolve => setTimeout(resolve, 0))
|
|
27
|
+
try {
|
|
28
|
+
const right = (selector: string) => Math.round(doc.querySelector(selector)!.getBoundingClientRect().right)
|
|
29
|
+
expect(right('form'), 'the form is wider than its room').to.be.at.most(351)
|
|
30
|
+
expect(right('#to'), 'the last date runs past the room').to.be.at.most(351)
|
|
31
|
+
} finally {
|
|
32
|
+
frame.remove()
|
|
33
|
+
}
|
|
34
|
+
})
|
|
35
|
+
})
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/* Elements are compared by presence, not by value: a failing element comparison makes chai render the DOM and hang the runner. */
|
|
2
|
+
import { expect, fixture } from '@open-wc/testing'
|
|
3
|
+
import { html } from 'lit'
|
|
4
|
+
import { i18next } from '@operato/i18n'
|
|
5
|
+
|
|
6
|
+
import '../src/data-grist.js'
|
|
7
|
+
import '../src/filters/filters-form.js'
|
|
8
|
+
import { fitsAsPills, hasAllChip, wordWidth } from '../src/filters/pill-choice.js'
|
|
9
|
+
|
|
10
|
+
/*
|
|
11
|
+
* A filter of two or three fixed choices with short words is chips - one press, where a select takes two - with a first
|
|
12
|
+
* 「전체」 chip when nothing may be chosen. More choices, read choices or long words stay a searchable select
|
|
13
|
+
* (2026-11-10: the inquiry list's 보기·종류·상태 were three selects).
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
const kinds = [
|
|
17
|
+
{ display: '', value: '' },
|
|
18
|
+
{ display: '질문', value: 'QUESTION' },
|
|
19
|
+
{ display: '버그 신고', value: 'BUG' },
|
|
20
|
+
{ display: '기능 제안', value: 'PROPOSAL' }
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
const columns = [
|
|
24
|
+
{ type: 'string', name: 'kind', header: '종류', filter: { type: 'select', operator: 'eq', options: kinds } },
|
|
25
|
+
{
|
|
26
|
+
type: 'string',
|
|
27
|
+
name: 'status',
|
|
28
|
+
header: '상태',
|
|
29
|
+
filter: { type: 'select', operator: 'eq', options: ['', 'RECEIVED', 'IN_PROGRESS', 'ANSWERED', 'CLOSED'] }
|
|
30
|
+
},
|
|
31
|
+
{ type: 'string', name: 'owner', header: '담당', filter: { type: 'select', operator: 'eq', options: async () => [{ display: 'A', value: 'a' }, { display: 'B', value: 'b' }] } },
|
|
32
|
+
{
|
|
33
|
+
type: 'string',
|
|
34
|
+
name: 'long',
|
|
35
|
+
header: '긴 글',
|
|
36
|
+
filter: { type: 'select', operator: 'eq', options: ['', { display: '아주 긴 이름의 선택지', value: 'L' }, { display: '짧음', value: 'S' }] }
|
|
37
|
+
},
|
|
38
|
+
{ type: 'select', name: 'direction', header: '방향', record: { options: ['', 'SALE', 'PURCHASE'] }, filter: 'in' },
|
|
39
|
+
{
|
|
40
|
+
type: 'string',
|
|
41
|
+
name: 'view',
|
|
42
|
+
header: '보기',
|
|
43
|
+
filter: { type: 'select', operator: 'eq', value: 'mine', options: [{ display: '내 것', value: 'mine' }, { display: '처리할 것', value: 'turn' }] }
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
const settle = (ms = 150) => new Promise(resolve => setTimeout(resolve, ms))
|
|
48
|
+
|
|
49
|
+
describe('filters as pills', () => {
|
|
50
|
+
const ignoreResizeLoop = (e: ErrorEvent) => {
|
|
51
|
+
if (String(e.message).includes('ResizeObserver loop')) {
|
|
52
|
+
e.stopImmediatePropagation()
|
|
53
|
+
e.preventDefault()
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
let previousOnError: OnErrorEventHandler = null
|
|
57
|
+
let previousLanguage: string
|
|
58
|
+
before(async () => {
|
|
59
|
+
/* The 「전체」 chip's own words count toward the line: the test stands in Korean. */
|
|
60
|
+
previousLanguage = i18next.language
|
|
61
|
+
await i18next.changeLanguage('ko')
|
|
62
|
+
window.addEventListener('error', ignoreResizeLoop, true)
|
|
63
|
+
previousOnError = window.onerror
|
|
64
|
+
window.onerror = (message, ...rest) => (String(message).includes('ResizeObserver loop') ? true : previousOnError?.call(window, message, ...rest))
|
|
65
|
+
})
|
|
66
|
+
after(async () => {
|
|
67
|
+
window.removeEventListener('error', ignoreResizeLoop, true)
|
|
68
|
+
window.onerror = previousOnError
|
|
69
|
+
/* The language is kept in the browser's storage; the next test file must not start in Korean. */
|
|
70
|
+
await i18next.changeLanguage(previousLanguage)
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
async function form() {
|
|
74
|
+
const asked: any[] = []
|
|
75
|
+
const grist = (await fixture(html`
|
|
76
|
+
<ox-grist
|
|
77
|
+
style="height: 300px"
|
|
78
|
+
mode="GRID"
|
|
79
|
+
.config=${{ columns, pagination: { pages: [20] } }}
|
|
80
|
+
.fetchHandler=${async ({ filters }: any) => (asked.push(filters), { page: 1, limit: 20, total: 0, records: [] })}
|
|
81
|
+
>
|
|
82
|
+
<div slot="headroom"><ox-filters-form without-search></ox-filters-form></div>
|
|
83
|
+
</ox-grist>
|
|
84
|
+
`)) as any
|
|
85
|
+
await settle()
|
|
86
|
+
const filters = grist.querySelector('ox-filters-form') as any
|
|
87
|
+
await filters.updateComplete
|
|
88
|
+
const root = filters.renderRoot as ShadowRoot
|
|
89
|
+
const chooser = (name: string) => root.querySelector(`[name="${name}"]`) as any
|
|
90
|
+
return { grist, chooser, asked }
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const chipWords = async (buttons: any) => {
|
|
94
|
+
await buttons.updateComplete
|
|
95
|
+
return [...buttons.renderRoot.querySelectorAll('md-filter-chip')].map((chip: any) => chip.label || chip.textContent.trim())
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
it('draws two or three short fixed choices as chips, 「전체」 first', async () => {
|
|
99
|
+
const { chooser } = await form()
|
|
100
|
+
expect(chooser('kind')?.tagName).to.equal('OX-INPUT-SELECT-BUTTONS')
|
|
101
|
+
expect(await chipWords(chooser('kind'))).to.deep.equal(['전체', '질문', '버그 신고', '기능 제안'])
|
|
102
|
+
expect(chooser('direction')?.tagName).to.equal('OX-INPUT-SELECT-BUTTONS')
|
|
103
|
+
expect(chooser('direction').multiple).to.equal(true)
|
|
104
|
+
expect(await chipWords(chooser('direction'))).to.deep.equal(['전체', 'SALE', 'PURCHASE'])
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
it('keeps a select for more choices, read choices and long words', async () => {
|
|
108
|
+
const { chooser } = await form()
|
|
109
|
+
expect(chooser('status')?.tagName).to.equal('OX-SELECT')
|
|
110
|
+
expect(chooser('owner')?.tagName).to.equal('OX-SELECT')
|
|
111
|
+
expect(chooser('long')?.tagName).to.equal('OX-SELECT')
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
it('a single choice that opens with a value and has no empty line has no 「전체」 and stays chosen', async () => {
|
|
115
|
+
const { chooser } = await form()
|
|
116
|
+
const view = chooser('view')
|
|
117
|
+
expect(view?.tagName).to.equal('OX-INPUT-SELECT-BUTTONS')
|
|
118
|
+
expect(await chipWords(view)).to.deep.equal(['내 것', '처리할 것'])
|
|
119
|
+
expect(view.required).to.equal(true)
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
it('a chip pressed reads the list with it, and 「전체」 reads it without', async () => {
|
|
123
|
+
const { chooser, asked } = await form()
|
|
124
|
+
const kind = chooser('kind')
|
|
125
|
+
const chips = () => [...kind.renderRoot.querySelectorAll('md-filter-chip')] as any[]
|
|
126
|
+
|
|
127
|
+
chips()[2].click()
|
|
128
|
+
await settle()
|
|
129
|
+
expect(asked[asked.length - 1].find((one: any) => one.name === 'kind')?.value).to.equal('BUG')
|
|
130
|
+
|
|
131
|
+
chips()[0].click()
|
|
132
|
+
await settle()
|
|
133
|
+
expect(!!asked[asked.length - 1].find((one: any) => one.name === 'kind')).to.equal(false)
|
|
134
|
+
})
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
describe('pill choice rules', () => {
|
|
138
|
+
it('counts a wide character as 2', () => {
|
|
139
|
+
expect(wordWidth('버그 신고')).to.equal(9)
|
|
140
|
+
expect(wordWidth('Bug reports')).to.equal(11)
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
it('fits up to three short choices, two chips at least with 「전체」 counted', () => {
|
|
144
|
+
const eq = { type: 'select', operator: 'eq' as const }
|
|
145
|
+
const one = { type: 'select', operator: 'in' as const }
|
|
146
|
+
expect(fitsAsPills(eq, ['', 'A', 'B'], '전체')).to.equal(true)
|
|
147
|
+
expect(fitsAsPills(eq, ['', 'A'], '전체')).to.equal(true)
|
|
148
|
+
expect(fitsAsPills(one, ['A'], '전체')).to.equal(false)
|
|
149
|
+
expect(fitsAsPills(eq, ['A', 'B', 'C', 'D'], '전체')).to.equal(false)
|
|
150
|
+
expect(fitsAsPills(eq, ['일이삼사오육칠', 'B'], '전체')).to.equal(false)
|
|
151
|
+
expect(fitsAsPills(eq, ['일이삼사오육', '일이삼사오육', '일이삼'], '전체')).to.equal(false)
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
it('has 「전체」 unless a single choice must always have one, or there is one chip', () => {
|
|
155
|
+
expect(hasAllChip({ type: 'select', operator: 'in' }, ['A', 'B'])).to.equal(true)
|
|
156
|
+
expect(hasAllChip({ type: 'select', operator: 'eq' }, ['', 'A', 'B'])).to.equal(true)
|
|
157
|
+
expect(hasAllChip({ type: 'select', operator: 'eq' }, ['A', 'B'])).to.equal(true)
|
|
158
|
+
expect(hasAllChip({ type: 'select', operator: 'eq', value: 'A' } as any, ['A', 'B'])).to.equal(false)
|
|
159
|
+
expect(hasAllChip({ type: 'select', operator: 'eq' }, ['', 'MINE'])).to.equal(true)
|
|
160
|
+
expect(hasAllChip({ type: 'select', operator: 'in' }, ['CANCELLED'])).to.equal(false)
|
|
161
|
+
})
|
|
162
|
+
})
|
|
@@ -147,7 +147,8 @@ describe('list defaults and the shape of list operators', () => {
|
|
|
147
147
|
await until(() => reads.length > 0, 'first read')
|
|
148
148
|
const form = grist.querySelector('ox-filters-form') as any
|
|
149
149
|
await form.updateComplete
|
|
150
|
-
|
|
150
|
+
/* Two choices are chips now (pill-choice); the chooser is read by its name, whatever draws it. */
|
|
151
|
+
return (form.renderRoot as ShadowRoot).querySelector('[name="state"]') as any
|
|
151
152
|
}
|
|
152
153
|
expect((await shown('?defaults=select'))?.value).to.equal('GOING')
|
|
153
154
|
expect((await shown('?filters=[]'))?.value ?? '').to.equal('')
|
package/translations/en.json
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"label.collapse-all": "collapse all",
|
|
12
12
|
"label.expand-all": "expand all",
|
|
13
13
|
"label.filter": "filter",
|
|
14
|
+
"label.all": "All",
|
|
14
15
|
"text.grid-cell-input": "{name} input",
|
|
15
16
|
"text.grid-cell-input-plain": "cell input",
|
|
16
17
|
"text.grid-filter-from": "{name} filter, from",
|
|
@@ -29,5 +30,11 @@
|
|
|
29
30
|
"text.validation-reason.RANGE": "out of range",
|
|
30
31
|
"text.validation-reason.UNIQUE": "duplicate value",
|
|
31
32
|
"button.remove-new-row": "Remove row",
|
|
32
|
-
"text.paste-rows-dropped": "Applied {applied} of {rows} pasted rows. This table does not allow new rows, so {dropped} rows were not applied."
|
|
33
|
+
"text.paste-rows-dropped": "Applied {applied} of {rows} pasted rows. This table does not allow new rows, so {dropped} rows were not applied.",
|
|
34
|
+
"text.grid-range-from-date": "start date",
|
|
35
|
+
"text.grid-range-to-date": "end date",
|
|
36
|
+
"text.grid-range-from-week": "start week",
|
|
37
|
+
"text.grid-range-to-week": "end week",
|
|
38
|
+
"text.grid-range-from-month": "start month",
|
|
39
|
+
"text.grid-range-to-month": "end month"
|
|
33
40
|
}
|
package/translations/es.json
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"label.collapse-all": "contraer todo",
|
|
12
12
|
"label.expand-all": "expandir todo",
|
|
13
13
|
"label.filter": "filtro",
|
|
14
|
+
"label.all": "Todo",
|
|
14
15
|
"text.grid-cell-input": "entrada de {name}",
|
|
15
16
|
"text.grid-cell-input-plain": "entrada de celda",
|
|
16
17
|
"text.grid-filter-from": "filtro de {name}, desde",
|
|
@@ -29,5 +30,11 @@
|
|
|
29
30
|
"text.validation-reason.RANGE": "fuera de rango",
|
|
30
31
|
"text.validation-reason.UNIQUE": "valor duplicado",
|
|
31
32
|
"button.remove-new-row": "Quitar fila",
|
|
32
|
-
"text.paste-rows-dropped": "De {rows} filas pegadas se aplicaron {applied}. Esta tabla no admite filas nuevas, por lo que {dropped} no se aplicaron."
|
|
33
|
+
"text.paste-rows-dropped": "De {rows} filas pegadas se aplicaron {applied}. Esta tabla no admite filas nuevas, por lo que {dropped} no se aplicaron.",
|
|
34
|
+
"text.grid-range-from-date": "fecha inicial",
|
|
35
|
+
"text.grid-range-to-date": "fecha final",
|
|
36
|
+
"text.grid-range-from-week": "semana inicial",
|
|
37
|
+
"text.grid-range-to-week": "semana final",
|
|
38
|
+
"text.grid-range-from-month": "mes inicial",
|
|
39
|
+
"text.grid-range-to-month": "mes final"
|
|
33
40
|
}
|
package/translations/ja.json
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"label.collapse-all": "すべて折りたたむ",
|
|
12
12
|
"label.expand-all": "すべて展開",
|
|
13
13
|
"label.filter": "フィルター",
|
|
14
|
+
"label.all": "すべて",
|
|
14
15
|
"text.grid-cell-input": "{name} 入力",
|
|
15
16
|
"text.grid-cell-input-plain": "セル入力",
|
|
16
17
|
"text.grid-filter-from": "{name} フィルター 開始値",
|
|
@@ -29,5 +30,11 @@
|
|
|
29
30
|
"text.validation-reason.RANGE": "範囲外",
|
|
30
31
|
"text.validation-reason.UNIQUE": "重複",
|
|
31
32
|
"button.remove-new-row": "行を削除",
|
|
32
|
-
"text.paste-rows-dropped": "貼り付けた {rows} 行のうち {applied} 行のみ反映しました。この表には行を追加できないため、{dropped} 行は反映していません。"
|
|
33
|
+
"text.paste-rows-dropped": "貼り付けた {rows} 行のうち {applied} 行のみ反映しました。この表には行を追加できないため、{dropped} 行は反映していません。",
|
|
34
|
+
"text.grid-range-from-date": "開始日",
|
|
35
|
+
"text.grid-range-to-date": "終了日",
|
|
36
|
+
"text.grid-range-from-week": "開始週",
|
|
37
|
+
"text.grid-range-to-week": "終了週",
|
|
38
|
+
"text.grid-range-from-month": "開始月",
|
|
39
|
+
"text.grid-range-to-month": "終了月"
|
|
33
40
|
}
|
package/translations/ko.json
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"label.collapse-all": "모두 접기",
|
|
12
12
|
"label.expand-all": "모두 펼치기",
|
|
13
13
|
"label.filter": "필터",
|
|
14
|
+
"label.all": "전체",
|
|
14
15
|
"text.grid-cell-input": "{name} 입력",
|
|
15
16
|
"text.grid-cell-input-plain": "칸 입력",
|
|
16
17
|
"text.grid-filter-from": "{name} 필터 시작값",
|
|
@@ -29,5 +30,11 @@
|
|
|
29
30
|
"text.validation-reason.RANGE": "범위를 벗어났습니다.",
|
|
30
31
|
"text.validation-reason.UNIQUE": "중복된 값입니다.",
|
|
31
32
|
"button.remove-new-row": "행 제거",
|
|
32
|
-
"text.paste-rows-dropped": "붙여 넣은 {rows}행 중 {applied}행만 반영했습니다. 이 표에는 행을 추가할 수 없어 {dropped}행은 반영하지 않았습니다."
|
|
33
|
+
"text.paste-rows-dropped": "붙여 넣은 {rows}행 중 {applied}행만 반영했습니다. 이 표에는 행을 추가할 수 없어 {dropped}행은 반영하지 않았습니다.",
|
|
34
|
+
"text.grid-range-from-date": "시작일",
|
|
35
|
+
"text.grid-range-to-date": "종료일",
|
|
36
|
+
"text.grid-range-from-week": "시작 주",
|
|
37
|
+
"text.grid-range-to-week": "종료 주",
|
|
38
|
+
"text.grid-range-from-month": "시작 월",
|
|
39
|
+
"text.grid-range-to-month": "종료 월"
|
|
33
40
|
}
|
package/translations/ms.json
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"label.collapse-all": "runtuhkan semua",
|
|
12
12
|
"label.expand-all": "kembangkan semua",
|
|
13
13
|
"label.filter": "penapis",
|
|
14
|
+
"label.all": "Semua",
|
|
14
15
|
"text.grid-cell-input": "input {name}",
|
|
15
16
|
"text.grid-cell-input-plain": "input sel",
|
|
16
17
|
"text.grid-filter-from": "penapis {name}, dari",
|
|
@@ -29,5 +30,11 @@
|
|
|
29
30
|
"text.validation-reason.RANGE": "diluar jangka",
|
|
30
31
|
"text.validation-reason.UNIQUE": "nilai duplikat",
|
|
31
32
|
"button.remove-new-row": "Buang baris",
|
|
32
|
-
"text.paste-rows-dropped": "Daripada {rows} baris yang ditampal, {applied} digunakan. Jadual ini tidak boleh menerima baris baharu, jadi {dropped} tidak digunakan."
|
|
33
|
+
"text.paste-rows-dropped": "Daripada {rows} baris yang ditampal, {applied} digunakan. Jadual ini tidak boleh menerima baris baharu, jadi {dropped} tidak digunakan.",
|
|
34
|
+
"text.grid-range-from-date": "tarikh mula",
|
|
35
|
+
"text.grid-range-to-date": "tarikh tamat",
|
|
36
|
+
"text.grid-range-from-week": "minggu mula",
|
|
37
|
+
"text.grid-range-to-week": "minggu tamat",
|
|
38
|
+
"text.grid-range-from-month": "bulan mula",
|
|
39
|
+
"text.grid-range-to-month": "bulan tamat"
|
|
33
40
|
}
|
package/translations/zh.json
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"label.collapse-all": "全部折叠",
|
|
12
12
|
"label.expand-all": "全部展开",
|
|
13
13
|
"label.filter": "筛选",
|
|
14
|
+
"label.all": "全部",
|
|
14
15
|
"text.grid-cell-input": "{name} 输入",
|
|
15
16
|
"text.grid-cell-input-plain": "单元格输入",
|
|
16
17
|
"text.grid-filter-from": "{name} 筛选起始值",
|
|
@@ -29,5 +30,11 @@
|
|
|
29
30
|
"text.validation-reason.RANGE": "超出范围",
|
|
30
31
|
"text.validation-reason.UNIQUE": "重复值",
|
|
31
32
|
"button.remove-new-row": "移除行",
|
|
32
|
-
"text.paste-rows-dropped": "粘贴的 {rows} 行中仅应用了 {applied} 行。此表不能添加新行,因此有 {dropped} 行未应用。"
|
|
33
|
+
"text.paste-rows-dropped": "粘贴的 {rows} 行中仅应用了 {applied} 行。此表不能添加新行,因此有 {dropped} 行未应用。",
|
|
34
|
+
"text.grid-range-from-date": "开始日期",
|
|
35
|
+
"text.grid-range-to-date": "结束日期",
|
|
36
|
+
"text.grid-range-from-week": "开始周",
|
|
37
|
+
"text.grid-range-to-week": "结束周",
|
|
38
|
+
"text.grid-range-from-month": "开始月份",
|
|
39
|
+
"text.grid-range-to-month": "结束月份"
|
|
33
40
|
}
|