@operato/data-grist 10.29.51 → 10.29.52

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@operato/data-grist",
3
- "version": "10.29.51",
3
+ "version": "10.29.52",
4
4
  "description": "User interface for grid (desktop) and list (mobile)",
5
5
  "author": "heartyoh",
6
6
  "type": "module",
@@ -78,10 +78,10 @@
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.49",
81
+ "@operato/input": "^10.29.52",
82
82
  "@operato/list-state": "^10.29.49",
83
- "@operato/p13n": "^10.29.50",
84
- "@operato/popup": "^10.29.49",
83
+ "@operato/p13n": "^10.29.52",
84
+ "@operato/popup": "^10.29.52",
85
85
  "@operato/pull-to-refresh": "^10.29.23",
86
86
  "@operato/styles": "^10.29.30",
87
87
  "@operato/time-calculator": "^10.29.1",
@@ -124,5 +124,5 @@
124
124
  "prettier --write"
125
125
  ]
126
126
  },
127
- "gitHead": "dc2cbe82ecb8fc65d0723f3b380edc4396dac87e"
127
+ "gitHead": "2e34202735031117c1f096297dee7e48d3595144"
128
128
  }
@@ -0,0 +1,76 @@
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
+
5
+ import '../src/editors/ox-grist-editor-select.js'
6
+ import { buildColumn } from '../src/configure/column-builder.js'
7
+ import { OxGristEditor } from '../src/editors/ox-grist-editor.js'
8
+
9
+ /*
10
+ * A select column with `record.searchable` edits through the popup list with a search box on top, as select2 does
11
+ * (2026-10-25, the user: 「셀렉트는 전부 select2 처럼 상단에 검색이 가능한 select였으면」). Without it the cell keeps the
12
+ * browser's own <select>, so grids that did not ask do not change.
13
+ */
14
+
15
+ const GRADES = [
16
+ { display: 'one', value: 1 },
17
+ { display: 'two', value: 2 }
18
+ ]
19
+
20
+ const mount = async (record: any, searchable = true) => {
21
+ const editor = (await fixture(
22
+ html`${Object.assign(document.createElement('ox-grist-editor-select'), {
23
+ column: buildColumn({ type: 'select', name: 'grade', record: { editable: true, searchable, options: GRADES } }),
24
+ record,
25
+ row: 0
26
+ })}`
27
+ )) as OxGristEditor
28
+ await editor.updateComplete
29
+ const changes: any[] = []
30
+ editor.addEventListener('field-change', event => changes.push((event as CustomEvent).detail))
31
+ return { editor, changes }
32
+ }
33
+
34
+ /* What the list does when it closes: its value is the picked option's value attribute, and ox-select tells a change. */
35
+ const close = (editor: OxGristEditor, value: string) => {
36
+ const select = editor.renderRoot.querySelector('ox-select') as any
37
+ select.value = value
38
+ select.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: value }))
39
+ }
40
+
41
+ describe('a searchable select cell', () => {
42
+ it('draws the popup list with a search box, not a native select', async () => {
43
+ const { editor } = await mount({ grade: 1 })
44
+ expect(editor.renderRoot.querySelector('select') === null).to.equal(true)
45
+ const list = editor.renderRoot.querySelector('ox-select ox-popup-list')
46
+ expect(!!list && list.hasAttribute('with-search')).to.equal(true)
47
+ expect(list!.querySelectorAll('[option]').length).to.equal(2)
48
+ })
49
+
50
+ it('keeps the native select when the column does not ask', async () => {
51
+ const { editor } = await mount({ grade: 1 }, false)
52
+ expect(editor.renderRoot.querySelector('select') !== null).to.equal(true)
53
+ expect(editor.renderRoot.querySelector('ox-select') === null).to.equal(true)
54
+ })
55
+
56
+ it('commits a pick at once, as the option value and not its text', async () => {
57
+ const { editor, changes } = await mount({ grade: 1 })
58
+ close(editor, '2')
59
+ expect(changes.length).to.equal(1)
60
+ expect(changes[0].after).to.equal(2)
61
+ })
62
+
63
+ it('a list closed on the value it had commits nothing', async () => {
64
+ const { editor, changes } = await mount({ grade: 1 })
65
+ close(editor, '1')
66
+ editor.flush()
67
+ editor._onfocusout()
68
+ expect(changes.length).to.equal(0)
69
+ })
70
+
71
+ it('an untouched cell commits nothing on flush', async () => {
72
+ const { editor, changes } = await mount({ grade: 1 })
73
+ editor.flush()
74
+ expect(changes.length).to.equal(0)
75
+ })
76
+ })