@operato/data-grist 10.29.76 → 10.29.78
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/data-card/record-card.d.ts +4 -0
- package/dist/src/data-card/record-card.js +62 -20
- package/dist/src/data-card/record-card.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/accumulator-labels.test.d.ts +1 -0
- package/dist/test/accumulator-labels.test.js +32 -0
- package/dist/test/accumulator-labels.test.js.map +1 -0
- package/dist/test/address-intents.test.d.ts +1 -0
- package/dist/test/address-intents.test.js +201 -0
- package/dist/test/address-intents.test.js.map +1 -0
- package/dist/test/card-selector.test.d.ts +1 -0
- package/dist/test/card-selector.test.js +71 -0
- package/dist/test/card-selector.test.js.map +1 -0
- package/dist/test/card-thumb.test.d.ts +1 -0
- package/dist/test/card-thumb.test.js +44 -0
- package/dist/test/card-thumb.test.js.map +1 -0
- package/dist/test/card-totals-narrow.test.d.ts +1 -0
- package/dist/test/card-totals-narrow.test.js +103 -0
- package/dist/test/card-totals-narrow.test.js.map +1 -0
- package/dist/test/cell-button-row-height.test.d.ts +1 -0
- package/dist/test/cell-button-row-height.test.js +53 -0
- package/dist/test/cell-button-row-height.test.js.map +1 -0
- package/dist/test/column-resize.test.d.ts +1 -0
- package/dist/test/column-resize.test.js +153 -0
- package/dist/test/column-resize.test.js.map +1 -0
- package/dist/test/control-heights.test.d.ts +1 -0
- package/dist/test/control-heights.test.js +25 -0
- package/dist/test/control-heights.test.js.map +1 -0
- package/dist/test/count-handler.test.d.ts +1 -0
- package/dist/test/count-handler.test.js +56 -0
- package/dist/test/count-handler.test.js.map +1 -0
- package/dist/test/create-paste-policy.test.d.ts +1 -0
- package/dist/test/create-paste-policy.test.js +159 -0
- package/dist/test/create-paste-policy.test.js.map +1 -0
- package/dist/test/data-integrity.test.d.ts +1 -0
- package/dist/test/data-integrity.test.js +145 -0
- package/dist/test/data-integrity.test.js.map +1 -0
- package/dist/test/destructive-actions.test.d.ts +11 -0
- package/dist/test/destructive-actions.test.js +147 -0
- package/dist/test/destructive-actions.test.js.map +1 -0
- package/dist/test/edit-lifecycle.test.d.ts +2 -0
- package/dist/test/edit-lifecycle.test.js +270 -0
- package/dist/test/edit-lifecycle.test.js.map +1 -0
- package/dist/test/edit-rebase.test.d.ts +1 -0
- package/dist/test/edit-rebase.test.js +185 -0
- package/dist/test/edit-rebase.test.js.map +1 -0
- package/dist/test/editor-commit.test.d.ts +2 -0
- package/dist/test/editor-commit.test.js +68 -0
- package/dist/test/editor-commit.test.js.map +1 -0
- package/dist/test/fetch-failure-state.test.d.ts +1 -0
- package/dist/test/fetch-failure-state.test.js +129 -0
- package/dist/test/fetch-failure-state.test.js.map +1 -0
- package/dist/test/field-contains-content.test.d.ts +1 -0
- package/dist/test/field-contains-content.test.js +101 -0
- package/dist/test/field-contains-content.test.js.map +1 -0
- 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/filter-labels.test.d.ts +2 -0
- package/dist/test/filter-labels.test.js +140 -0
- package/dist/test/filter-labels.test.js.map +1 -0
- package/dist/test/filter-ownership.test.d.ts +1 -0
- package/dist/test/filter-ownership.test.js +83 -0
- package/dist/test/filter-ownership.test.js.map +1 -0
- package/dist/test/filter-select-buttons-count.test.d.ts +1 -0
- package/dist/test/filter-select-buttons-count.test.js +35 -0
- package/dist/test/filter-select-buttons-count.test.js.map +1 -0
- package/dist/test/filter-typing.test.d.ts +2 -0
- package/dist/test/filter-typing.test.js +66 -0
- package/dist/test/filter-typing.test.js.map +1 -0
- package/dist/test/filters-phone-wrap.test.d.ts +1 -0
- package/dist/test/filters-phone-wrap.test.js +17 -0
- package/dist/test/filters-phone-wrap.test.js.map +1 -0
- package/dist/test/first-click-stays.test.d.ts +1 -0
- package/dist/test/first-click-stays.test.js +77 -0
- package/dist/test/first-click-stays.test.js.map +1 -0
- package/dist/test/fixed-column-opaque.test.d.ts +1 -0
- package/dist/test/fixed-column-opaque.test.js +134 -0
- package/dist/test/fixed-column-opaque.test.js.map +1 -0
- package/dist/test/flexible-columns.test.d.ts +1 -0
- package/dist/test/flexible-columns.test.js +134 -0
- package/dist/test/flexible-columns.test.js.map +1 -0
- package/dist/test/grid-single-scroller.test.d.ts +1 -0
- package/dist/test/grid-single-scroller.test.js +107 -0
- package/dist/test/grid-single-scroller.test.js.map +1 -0
- package/dist/test/group-heading.test.d.ts +1 -0
- package/dist/test/group-heading.test.js +208 -0
- package/dist/test/group-heading.test.js.map +1 -0
- package/dist/test/latest-fetch-wins.test.d.ts +1 -0
- package/dist/test/latest-fetch-wins.test.js +91 -0
- package/dist/test/latest-fetch-wins.test.js.map +1 -0
- package/dist/test/list-defaults.test.d.ts +2 -0
- package/dist/test/list-defaults.test.js +145 -0
- package/dist/test/list-defaults.test.js.map +1 -0
- package/dist/test/list-records.test.d.ts +1 -0
- package/dist/test/list-records.test.js +46 -0
- package/dist/test/list-records.test.js.map +1 -0
- package/dist/test/office-density.test.d.ts +1 -0
- package/dist/test/office-density.test.js +52 -0
- package/dist/test/office-density.test.js.map +1 -0
- package/dist/test/page-errors.d.ts +1 -0
- package/dist/test/page-errors.js +44 -0
- package/dist/test/page-errors.js.map +1 -0
- package/dist/test/paste-integrity.test.d.ts +1 -0
- package/dist/test/paste-integrity.test.js +163 -0
- package/dist/test/paste-integrity.test.js.map +1 -0
- package/dist/test/record-card-height.test.d.ts +1 -0
- package/dist/test/record-card-height.test.js +15 -0
- package/dist/test/record-card-height.test.js.map +1 -0
- package/dist/test/record-view-popup-editor.test.d.ts +1 -0
- package/dist/test/record-view-popup-editor.test.js +71 -0
- package/dist/test/record-view-popup-editor.test.js.map +1 -0
- package/dist/test/renderer-date-calendar-day.test.d.ts +1 -0
- package/dist/test/renderer-date-calendar-day.test.js +48 -0
- package/dist/test/renderer-date-calendar-day.test.js.map +1 -0
- package/dist/test/request-generation.test.d.ts +1 -0
- package/dist/test/request-generation.test.js +153 -0
- package/dist/test/request-generation.test.js.map +1 -0
- package/dist/test/resubmit.test.d.ts +1 -0
- package/dist/test/resubmit.test.js +83 -0
- package/dist/test/resubmit.test.js.map +1 -0
- package/dist/test/row-hover-visible.test.d.ts +1 -0
- package/dist/test/row-hover-visible.test.js +139 -0
- package/dist/test/row-hover-visible.test.js.map +1 -0
- package/dist/test/search-term.test.d.ts +1 -0
- package/dist/test/search-term.test.js +108 -0
- package/dist/test/search-term.test.js.map +1 -0
- package/dist/test/searchable-select.test.d.ts +1 -0
- package/dist/test/searchable-select.test.js +65 -0
- package/dist/test/searchable-select.test.js.map +1 -0
- package/dist/test/select-empty-value.test.d.ts +1 -0
- package/dist/test/select-empty-value.test.js +61 -0
- package/dist/test/select-empty-value.test.js.map +1 -0
- package/dist/test/shift-range-select.test.d.ts +1 -0
- package/dist/test/shift-range-select.test.js +100 -0
- package/dist/test/shift-range-select.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/test/wheel-one-scroller.test.d.ts +2 -0
- package/dist/test/wheel-one-scroller.test.js +275 -0
- package/dist/test/wheel-one-scroller.test.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -6
- package/test/card-selector.test.ts +18 -4
|
@@ -0,0 +1,103 @@
|
|
|
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 '../src/data-grist.js';
|
|
5
|
+
import { failOnPageErrors } from './page-errors.js';
|
|
6
|
+
/*
|
|
7
|
+
* A report read on a phone (2026-11-06). The grid's totals row is drawn as a totals card after the cards, and a
|
|
8
|
+
* grist with a narrow mode draws it while its own width is under narrowWidth - a table on a wide screen, cards on a
|
|
9
|
+
* phone, from one config.
|
|
10
|
+
*/
|
|
11
|
+
const records = [
|
|
12
|
+
{ id: '1', name: 'one', shares: 15250, since: '2020-01-01' },
|
|
13
|
+
{ id: '2', name: 'two', shares: 5600, since: '2026-03-17' }
|
|
14
|
+
];
|
|
15
|
+
const config = (accumulator) => ({
|
|
16
|
+
columns: [
|
|
17
|
+
{ type: 'string', name: 'name', header: 'Name' },
|
|
18
|
+
{ type: 'integer', name: 'shares', header: 'Shares', accumulator: 'sum' }
|
|
19
|
+
],
|
|
20
|
+
rows: { appendable: false, editable: false, selectable: false, accumulator },
|
|
21
|
+
list: { fields: ['name'], details: ['shares'] }
|
|
22
|
+
});
|
|
23
|
+
const idle = async (el) => {
|
|
24
|
+
while (!((await el.updateComplete) && (await el.grist.updateComplete)))
|
|
25
|
+
;
|
|
26
|
+
};
|
|
27
|
+
const frame = (width) => new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)));
|
|
28
|
+
describe('a card list and its totals', () => {
|
|
29
|
+
failOnPageErrors();
|
|
30
|
+
it('draws the totals card after the cards, each total naming its column', async () => {
|
|
31
|
+
const el = await fixture(html `<ox-grist style="width:340px;height:400px" mode="CARD" .config=${config(true)} .data=${{ records }}></ox-grist>`);
|
|
32
|
+
await idle(el);
|
|
33
|
+
const totals = el.grist.renderRoot.querySelector('[totals]');
|
|
34
|
+
expect(totals, 'no totals card').to.exist;
|
|
35
|
+
const shares = totals.querySelector('[total="shares"]');
|
|
36
|
+
expect(shares.querySelector('label').textContent).to.equal('Shares');
|
|
37
|
+
expect(shares.textContent).to.contain('20850');
|
|
38
|
+
expect(totals.querySelector('[total="name"]'), 'a column with no accumulator is totalled').to.equal(null);
|
|
39
|
+
const cards = el.grist.renderRoot.querySelectorAll('ox-record-card');
|
|
40
|
+
expect(totals.getBoundingClientRect().top, 'the totals stand above a card').to.be.at.least(cards[cards.length - 1].getBoundingClientRect().bottom);
|
|
41
|
+
});
|
|
42
|
+
it('draws no totals card when the rows do not accumulate', async () => {
|
|
43
|
+
const el = await fixture(html `<ox-grist style="width:340px;height:400px" mode="CARD" .config=${config(false)} .data=${{ records }}></ox-grist>`);
|
|
44
|
+
await idle(el);
|
|
45
|
+
expect(el.grist.renderRoot.querySelector('[totals]')).to.equal(null);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
describe('a grist with a narrow mode', () => {
|
|
49
|
+
failOnPageErrors();
|
|
50
|
+
it('draws its mode when wide and its narrow mode when narrow, by its own width', async () => {
|
|
51
|
+
const el = await fixture(html `<ox-grist style="display:flex;width:900px;height:400px" mode="GRID" narrow-mode="CARD" .config=${config(true)} .data=${{ records }}></ox-grist>`);
|
|
52
|
+
await frame(0);
|
|
53
|
+
await idle(el);
|
|
54
|
+
expect(el.shownMode).to.equal('GRID');
|
|
55
|
+
expect(el.renderRoot.querySelector('ox-grid'), 'not a grid while wide').to.exist;
|
|
56
|
+
el.style.width = '340px';
|
|
57
|
+
await frame(0);
|
|
58
|
+
await idle(el);
|
|
59
|
+
expect(el.shownMode).to.equal('CARD');
|
|
60
|
+
expect(el.renderRoot.querySelector('ox-card'), 'not cards while narrow').to.exist;
|
|
61
|
+
expect(el.mode, 'the requested mode was overwritten').to.equal('GRID');
|
|
62
|
+
el.style.width = '900px';
|
|
63
|
+
await frame(0);
|
|
64
|
+
await idle(el);
|
|
65
|
+
expect(el.renderRoot.querySelector('ox-grid'), 'not a grid again once wide').to.exist;
|
|
66
|
+
});
|
|
67
|
+
it('keeps its mode at every width when no narrow mode is set', async () => {
|
|
68
|
+
const el = await fixture(html `<ox-grist style="display:flex;width:340px;height:400px" mode="GRID" .config=${config(true)} .data=${{ records }}></ox-grist>`);
|
|
69
|
+
await frame(0);
|
|
70
|
+
await idle(el);
|
|
71
|
+
expect(el.renderRoot.querySelector('ox-grid')).to.exist;
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
describe('a card detail with a label', () => {
|
|
75
|
+
failOnPageErrors();
|
|
76
|
+
it('keeps the label whole when details stand in a row', async () => {
|
|
77
|
+
const labelled = {
|
|
78
|
+
...config(false),
|
|
79
|
+
columns: [
|
|
80
|
+
{ type: 'string', name: 'name', header: 'Name' },
|
|
81
|
+
{ type: 'string', name: 'since', header: 'Since', label: { renderer: () => '취득일' } }
|
|
82
|
+
],
|
|
83
|
+
list: { fields: ['name'], details: ['since'] }
|
|
84
|
+
};
|
|
85
|
+
const el = await fixture(html `<ox-grist style="width:340px;height:400px;font-size:13px;--data-card-detail-direction:row;--data-card-item-etc-label-font:400 11.5px sans-serif" mode="CARD" .config=${labelled} .data=${{ records }}></ox-grist>`);
|
|
86
|
+
await idle(el);
|
|
87
|
+
const card = el.grist.renderRoot.querySelector('ox-record-card');
|
|
88
|
+
const field = card.renderRoot.querySelector('[detail] ox-card-field');
|
|
89
|
+
const label = field.renderRoot.querySelector('label');
|
|
90
|
+
expect(label.scrollWidth, 'the label is cut').to.be.at.most(label.clientWidth);
|
|
91
|
+
const range = document.createRange();
|
|
92
|
+
range.setStartAfter(label);
|
|
93
|
+
range.setEnd(field.renderRoot, field.renderRoot.childNodes.length);
|
|
94
|
+
const words = document.createRange();
|
|
95
|
+
words.selectNodeContents(label);
|
|
96
|
+
expect(range.getBoundingClientRect().left - words.getBoundingClientRect().right, 'the label touches its value').to.be.at.least(4);
|
|
97
|
+
const value = Array.from(field.renderRoot.children).find(child => child !== label && child.tagName !== 'STYLE');
|
|
98
|
+
const text = document.createRange();
|
|
99
|
+
text.selectNodeContents(value);
|
|
100
|
+
expect(value.getBoundingClientRect().width, 'the value is cut').to.be.at.least(text.getBoundingClientRect().width - 0.01);
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
//# sourceMappingURL=card-totals-narrow.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"card-totals-narrow.test.js","sourceRoot":"","sources":["../../test/card-totals-narrow.test.ts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,CAAC,qBAAqB,EAAE,CAAC,KAAK,EAAE,6BAA6B,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QACjI,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,KAAK,KAAK,IAAI,KAAK,CAAC,OAAO,KAAK,OAAO,CAAgB,CAAA;QAC9H,MAAM,IAAI,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAA;QACnC,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAA;QAC9B,MAAM,CAAC,KAAK,CAAC,qBAAqB,EAAE,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,qBAAqB,EAAE,CAAC,KAAK,GAAG,IAAI,CAAC,CAAA;IAC3H,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["/* Elements are compared by presence, not by value: a failing element comparison makes chai render the DOM and hang the runner. */\nimport { expect, fixture } from '@open-wc/testing'\nimport { html } from 'lit'\n\nimport '../src/data-grist.js'\nimport { DataGrist } from '../src/data-grist.js'\nimport { failOnPageErrors } from './page-errors.js'\n\n/*\n * A report read on a phone (2026-11-06). The grid's totals row is drawn as a totals card after the cards, and a\n * grist with a narrow mode draws it while its own width is under narrowWidth - a table on a wide screen, cards on a\n * phone, from one config.\n */\n\nconst records = [\n { id: '1', name: 'one', shares: 15250, since: '2020-01-01' },\n { id: '2', name: 'two', shares: 5600, since: '2026-03-17' }\n]\nconst config = (accumulator: boolean) => ({\n columns: [\n { type: 'string', name: 'name', header: 'Name' },\n { type: 'integer', name: 'shares', header: 'Shares', accumulator: 'sum' }\n ],\n rows: { appendable: false, editable: false, selectable: false, accumulator },\n list: { fields: ['name'], details: ['shares'] }\n})\n\nconst idle = async (el: DataGrist) => {\n while (!((await el.updateComplete) && (await el.grist.updateComplete)));\n}\n\nconst frame = (width: number) => new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)))\n\ndescribe('a card list and its totals', () => {\n failOnPageErrors()\n\n it('draws the totals card after the cards, each total naming its column', async () => {\n const el = await fixture<DataGrist>(\n html`<ox-grist style=\"width:340px;height:400px\" mode=\"CARD\" .config=${config(true)} .data=${{ records }}></ox-grist>`\n )\n await idle(el)\n const totals = el.grist.renderRoot.querySelector('[totals]') as HTMLElement\n expect(totals, 'no totals card').to.exist\n const shares = totals.querySelector('[total=\"shares\"]') as HTMLElement\n expect(shares.querySelector('label')!.textContent).to.equal('Shares')\n expect(shares.textContent).to.contain('20850')\n expect(totals.querySelector('[total=\"name\"]'), 'a column with no accumulator is totalled').to.equal(null)\n\n const cards = el.grist.renderRoot.querySelectorAll('ox-record-card')\n expect(totals.getBoundingClientRect().top, 'the totals stand above a card').to.be.at.least(cards[cards.length - 1].getBoundingClientRect().bottom)\n })\n\n it('draws no totals card when the rows do not accumulate', async () => {\n const el = await fixture<DataGrist>(\n html`<ox-grist style=\"width:340px;height:400px\" mode=\"CARD\" .config=${config(false)} .data=${{ records }}></ox-grist>`\n )\n await idle(el)\n expect(el.grist.renderRoot.querySelector('[totals]')).to.equal(null)\n })\n})\n\ndescribe('a grist with a narrow mode', () => {\n failOnPageErrors()\n\n it('draws its mode when wide and its narrow mode when narrow, by its own width', async () => {\n const el = await fixture<DataGrist>(\n html`<ox-grist style=\"display:flex;width:900px;height:400px\" mode=\"GRID\" narrow-mode=\"CARD\" .config=${config(true)} .data=${{ records }}></ox-grist>`\n )\n await frame(0)\n await idle(el)\n expect(el.shownMode).to.equal('GRID')\n expect(el.renderRoot.querySelector('ox-grid'), 'not a grid while wide').to.exist\n\n el.style.width = '340px'\n await frame(0)\n await idle(el)\n expect(el.shownMode).to.equal('CARD')\n expect(el.renderRoot.querySelector('ox-card'), 'not cards while narrow').to.exist\n expect(el.mode, 'the requested mode was overwritten').to.equal('GRID')\n\n el.style.width = '900px'\n await frame(0)\n await idle(el)\n expect(el.renderRoot.querySelector('ox-grid'), 'not a grid again once wide').to.exist\n })\n\n it('keeps its mode at every width when no narrow mode is set', async () => {\n const el = await fixture<DataGrist>(\n html`<ox-grist style=\"display:flex;width:340px;height:400px\" mode=\"GRID\" .config=${config(true)} .data=${{ records }}></ox-grist>`\n )\n await frame(0)\n await idle(el)\n expect(el.renderRoot.querySelector('ox-grid')).to.exist\n })\n})\n\ndescribe('a card detail with a label', () => {\n failOnPageErrors()\n\n it('keeps the label whole when details stand in a row', async () => {\n const labelled = {\n ...config(false),\n columns: [\n { type: 'string', name: 'name', header: 'Name' },\n { type: 'string', name: 'since', header: 'Since', label: { renderer: () => '취득일' } }\n ],\n list: { fields: ['name'], details: ['since'] }\n }\n const el = await fixture<DataGrist>(\n html`<ox-grist style=\"width:340px;height:400px;font-size:13px;--data-card-detail-direction:row;--data-card-item-etc-label-font:400 11.5px sans-serif\" mode=\"CARD\" .config=${labelled} .data=${{ records }}></ox-grist>`\n )\n await idle(el)\n const card = el.grist.renderRoot.querySelector('ox-record-card') as any\n const field = card.renderRoot.querySelector('[detail] ox-card-field') as HTMLElement & { renderRoot: ShadowRoot }\n const label = field.renderRoot.querySelector('label') as HTMLElement\n expect(label.scrollWidth, 'the label is cut').to.be.at.most(label.clientWidth)\n const range = document.createRange()\n range.setStartAfter(label)\n range.setEnd(field.renderRoot, field.renderRoot.childNodes.length)\n const words = document.createRange()\n words.selectNodeContents(label)\n expect(range.getBoundingClientRect().left - words.getBoundingClientRect().right, 'the label touches its value').to.be.at.least(4)\n const value = Array.from(field.renderRoot.children).find(child => child !== label && child.tagName !== 'STYLE') as HTMLElement\n const text = document.createRange()\n text.selectNodeContents(value)\n expect(value.getBoundingClientRect().width, 'the value is cut').to.be.at.least(text.getBoundingClientRect().width - 0.01)\n })\n})\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '../src/data-grist.js';
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { expect, fixture } from '@open-wc/testing';
|
|
2
|
+
import { html } from 'lit';
|
|
3
|
+
import '../src/data-grist.js';
|
|
4
|
+
import { failOnPageErrors } from './page-errors.js';
|
|
5
|
+
/*
|
|
6
|
+
* A button a renderer returns in a grid cell never raises the row. The fields take the page's button look
|
|
7
|
+
* (ButtonStyles, 2026-11-06), and with it the page's 32px action height: the scenario list's 「발행」 button
|
|
8
|
+
* (a plain <button> styled inline) made every row taller than a text row (2026-11-09).
|
|
9
|
+
*/
|
|
10
|
+
const records = [
|
|
11
|
+
{ id: '1', what: 'teams-meetings' },
|
|
12
|
+
{ id: '2', what: 'm365' }
|
|
13
|
+
];
|
|
14
|
+
const idle = async (el) => {
|
|
15
|
+
while (!((await el.updateComplete) && (await el.grist.updateComplete)))
|
|
16
|
+
;
|
|
17
|
+
};
|
|
18
|
+
const rowHeight = async (act) => {
|
|
19
|
+
const config = {
|
|
20
|
+
columns: [
|
|
21
|
+
{ type: 'string', name: 'what', header: 'What' },
|
|
22
|
+
...(act ? [{ type: 'string', name: 'act', header: '', width: 100, record: { editable: false, align: 'center', renderer: act } }] : [])
|
|
23
|
+
],
|
|
24
|
+
rows: { appendable: false, editable: false, selectable: false }
|
|
25
|
+
};
|
|
26
|
+
const el = await fixture(html `<ox-grist style="display:flex;width:700px;height:400px" mode="GRID" .config=${config} .data=${{ records }}></ox-grist>`);
|
|
27
|
+
await idle(el);
|
|
28
|
+
const root = el.grist.renderRoot.querySelector('ox-grid-body').renderRoot;
|
|
29
|
+
const cell = Array.from(root.querySelectorAll('ox-grid-field')).find((one) => { var _a; return ((_a = one.column) === null || _a === void 0 ? void 0 : _a.name) === 'what'; });
|
|
30
|
+
return cell.getBoundingClientRect().height;
|
|
31
|
+
};
|
|
32
|
+
describe('a button a renderer returns in a grid cell', () => {
|
|
33
|
+
failOnPageErrors();
|
|
34
|
+
const buttons = {
|
|
35
|
+
/* the scenario list's release button, as it is written there */
|
|
36
|
+
'a plain button styled inline': () => html `<button
|
|
37
|
+
style="cursor:pointer;display:inline-flex;align-items:center;gap:3px;font:inherit;font-size:11px;border:none;border-radius:999px;padding:2px 11px;"
|
|
38
|
+
>
|
|
39
|
+
<md-icon style="font-size:15px;">publish</md-icon>Release
|
|
40
|
+
</button>`,
|
|
41
|
+
'a plain button': () => html `<button>Open</button>`,
|
|
42
|
+
'a quiet small button': () => html `<button quiet small>Open</button>`,
|
|
43
|
+
'an icon-only button': () => html `<button icon-only><md-icon>open_in_new</md-icon></button>`
|
|
44
|
+
};
|
|
45
|
+
for (const [name, renderer] of Object.entries(buttons)) {
|
|
46
|
+
it(`keeps the row as high as a text row (${name})`, async () => {
|
|
47
|
+
const text = await rowHeight();
|
|
48
|
+
const withButton = await rowHeight(renderer);
|
|
49
|
+
expect(withButton, `a text row is ${text}px`).to.equal(text);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
//# sourceMappingURL=cell-button-row-height.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cell-button-row-height.test.js","sourceRoot":"","sources":["../../test/cell-button-row-height.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAE1B,OAAO,sBAAsB,CAAA;AAE7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAEnD;;;;GAIG;AAEH,MAAM,OAAO,GAAG;IACd,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,gBAAgB,EAAE;IACnC,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE;CAC1B,CAAA;AAED,MAAM,IAAI,GAAG,KAAK,EAAE,EAAa,EAAE,EAAE;IACnC,OAAO,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,cAA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C,CAAA;AAED,QAAQ,CAAC,4CAA4C,EAAE,GAAG,EAAE;IAC1D,gBAAgB,EAAE,CAAA;IAElB,MAAM,OAAO,GAAkC;QAC7C,gEAAgE;QAChE,8BAA8B,EAAE,GAAG,EAAE,CACnC,IAAI,CAAA;;;;gBAIM;QACZ,gBAAgB,EAAE,GAAG,EAAE,CAAC,IAAI,CAAA,uBAAuB;QACnD,sBAAsB,EAAE,GAAG,EAAE,CAAC,IAAI,CAAA,mCAAmC;QACrE,qBAAqB,EAAE,GAAG,EAAE,CAAC,IAAI,CAAA,2DAA2D;KAC7F,CAAA;IAED,KAAK,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACvD,EAAE,CAAC,wCAAwC,IAAI,GAAG,EAAE,KAAK,IAAI,EAAE;YAC7D,MAAM,IAAI,GAAG,MAAM,SAAS,EAAE,CAAA;YAC9B,MAAM,UAAU,GAAG,MAAM,SAAS,CAAC,QAAQ,CAAC,CAAA;YAC5C,MAAM,CAAC,UAAU,EAAE,iBAAiB,IAAI,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAC9D,CAAC,CAAC,CAAA;IACJ,CAAC;AACH,CAAC,CAAC,CAAA","sourcesContent":["import { expect, fixture } from '@open-wc/testing'\nimport { html } from 'lit'\n\nimport '../src/data-grist.js'\nimport { DataGrist } from '../src/data-grist.js'\nimport { failOnPageErrors } from './page-errors.js'\n\n/*\n * A button a renderer returns in a grid cell never raises the row. The fields take the page's button look\n * (ButtonStyles, 2026-11-06), and with it the page's 32px action height: the scenario list's 「발행」 button\n * (a plain <button> styled inline) made every row taller than a text row (2026-11-09).\n */\n\nconst records = [\n { id: '1', what: 'teams-meetings' },\n { id: '2', what: 'm365' }\n]\n\nconst idle = async (el: DataGrist) => {\n while (!((await el.updateComplete) && (await el.grist.updateComplete)));\n}\n\nconst rowHeight = async (act?: (value: any) => unknown) => {\n const config = {\n columns: [\n { type: 'string', name: 'what', header: 'What' },\n ...(act ? [{ type: 'string', name: 'act', header: '', width: 100, record: { editable: false, align: 'center', renderer: act } }] : [])\n ],\n rows: { appendable: false, editable: false, selectable: false }\n }\n const el = await fixture<DataGrist>(\n html`<ox-grist style=\"display:flex;width:700px;height:400px\" mode=\"GRID\" .config=${config} .data=${{ records }}></ox-grist>`\n )\n await idle(el)\n const root = (el.grist.renderRoot.querySelector('ox-grid-body') as any).renderRoot as ShadowRoot\n const cell = Array.from(root.querySelectorAll('ox-grid-field')).find((one: any) => one.column?.name === 'what') as HTMLElement\n return cell.getBoundingClientRect().height\n}\n\ndescribe('a button a renderer returns in a grid cell', () => {\n failOnPageErrors()\n\n const buttons: Record<string, () => unknown> = {\n /* the scenario list's release button, as it is written there */\n 'a plain button styled inline': () =>\n html`<button\n style=\"cursor:pointer;display:inline-flex;align-items:center;gap:3px;font:inherit;font-size:11px;border:none;border-radius:999px;padding:2px 11px;\"\n >\n <md-icon style=\"font-size:15px;\">publish</md-icon>Release\n </button>`,\n 'a plain button': () => html`<button>Open</button>`,\n 'a quiet small button': () => html`<button quiet small>Open</button>`,\n 'an icon-only button': () => html`<button icon-only><md-icon>open_in_new</md-icon></button>`\n }\n\n for (const [name, renderer] of Object.entries(buttons)) {\n it(`keeps the row as high as a text row (${name})`, async () => {\n const text = await rowHeight()\n const withButton = await rowHeight(renderer)\n expect(withButton, `a text row is ${text}px`).to.equal(text)\n })\n }\n})\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '../src/data-grist.js';
|
|
@@ -0,0 +1,153 @@
|
|
|
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 { executeServerCommand, sendMouse } from '@web/test-runner-commands';
|
|
4
|
+
import { html } from 'lit';
|
|
5
|
+
import '../src/data-grist.js';
|
|
6
|
+
const settle = (ms = 150) => new Promise(resolve => setTimeout(resolve, ms));
|
|
7
|
+
const LONG = 'A long counterparty name that does not fit its column';
|
|
8
|
+
async function grid({ editable = false, nameWidth = 120 } = {}) {
|
|
9
|
+
const columns = [
|
|
10
|
+
{ type: 'string', name: 'id', hidden: true },
|
|
11
|
+
{ type: 'string', name: 'name', header: 'name', width: nameWidth, record: { editable } },
|
|
12
|
+
{ type: 'string', name: 'code', header: 'code', width: 100, record: { editable } },
|
|
13
|
+
/* Text and a mark side by side, as the cash list's counterparty and its 「미등록」: long text pushes the mark out. */
|
|
14
|
+
{
|
|
15
|
+
type: 'string',
|
|
16
|
+
name: 'memo',
|
|
17
|
+
header: 'memo',
|
|
18
|
+
width: 120,
|
|
19
|
+
record: {
|
|
20
|
+
editable,
|
|
21
|
+
renderer: (value) => html `${value} <span style="font-size: 11px; font-weight: 600">unregistered</span>`
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
];
|
|
25
|
+
const records = Array.from({ length: 5 }, (_, r) => ({ id: String(r), name: r === 3 ? LONG : 'short', code: 'C-' + r, memo: r === 2 ? LONG : 'note' }));
|
|
26
|
+
const el = (await fixture(html `
|
|
27
|
+
<ox-grist
|
|
28
|
+
style="width: 900px; height: 300px"
|
|
29
|
+
mode="GRID"
|
|
30
|
+
.config=${{ columns, pagination: { infinite: true }, rows: { appendable: false, selectable: false } }}
|
|
31
|
+
.data=${{ records }}
|
|
32
|
+
></ox-grist>
|
|
33
|
+
`));
|
|
34
|
+
await settle();
|
|
35
|
+
await el.updateComplete;
|
|
36
|
+
const ox = el.renderRoot.querySelector('#grist');
|
|
37
|
+
await ox.updateComplete;
|
|
38
|
+
const header = ox.renderRoot.querySelector('ox-grid-header');
|
|
39
|
+
const body = ox.renderRoot.querySelector('ox-grid-body');
|
|
40
|
+
await body.updateComplete;
|
|
41
|
+
await settle(50);
|
|
42
|
+
return { ox, header, body };
|
|
43
|
+
}
|
|
44
|
+
const heads = (header) => Array.from(header.renderRoot.querySelectorAll('[role=columnheader]'));
|
|
45
|
+
const width = (element) => Math.round(element.getBoundingClientRect().width);
|
|
46
|
+
const handle = (head) => head.querySelector('span[splitter]');
|
|
47
|
+
function centre(element) {
|
|
48
|
+
const r = element.getBoundingClientRect();
|
|
49
|
+
return [Math.round(r.left + r.width / 2), Math.round(r.top + r.height / 2)];
|
|
50
|
+
}
|
|
51
|
+
/** Whether the text of any cell of the column under this header is cut - the cell itself, or text it ends with "…". */
|
|
52
|
+
function cut(head, body) {
|
|
53
|
+
const left = head.getBoundingClientRect().left;
|
|
54
|
+
return Array.from(body.renderRoot.querySelectorAll('ox-grid-field'))
|
|
55
|
+
.filter(cell => Math.abs(cell.getBoundingClientRect().left - left) < 1)
|
|
56
|
+
.some(cell => [cell, ...Array.from(cell.renderRoot.querySelectorAll('*'))]
|
|
57
|
+
.filter(e => e === cell || getComputedStyle(e).textOverflow === 'ellipsis')
|
|
58
|
+
.some(e => e.scrollWidth > e.clientWidth + 1));
|
|
59
|
+
}
|
|
60
|
+
async function drag(from, by) {
|
|
61
|
+
await sendMouse({ type: 'move', position: from });
|
|
62
|
+
await sendMouse({ type: 'down' });
|
|
63
|
+
await sendMouse({ type: 'move', position: [from[0] + by, from[1]] });
|
|
64
|
+
await sendMouse({ type: 'up' });
|
|
65
|
+
await settle(300);
|
|
66
|
+
}
|
|
67
|
+
async function doubleClick([x, y]) {
|
|
68
|
+
await executeServerCommand('send-double-click', { x, y });
|
|
69
|
+
await settle(300);
|
|
70
|
+
}
|
|
71
|
+
describe('a column edge', () => {
|
|
72
|
+
/* Resizing the grid body inside a fixture trips Chrome's benign "ResizeObserver loop" error. */
|
|
73
|
+
const ignoreResizeLoop = (e) => {
|
|
74
|
+
if (String(e.message).includes('ResizeObserver loop')) {
|
|
75
|
+
e.stopImmediatePropagation();
|
|
76
|
+
e.preventDefault();
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
let previousOnError = null;
|
|
80
|
+
before(() => {
|
|
81
|
+
window.addEventListener('error', ignoreResizeLoop, true);
|
|
82
|
+
previousOnError = window.onerror;
|
|
83
|
+
window.onerror = (message, ...rest) => String(message).includes('ResizeObserver loop') ? true : previousOnError === null || previousOnError === void 0 ? void 0 : previousOnError.call(window, message, ...rest);
|
|
84
|
+
});
|
|
85
|
+
afterEach(async () => {
|
|
86
|
+
await sendMouse({ type: 'move', position: [0, 0] });
|
|
87
|
+
});
|
|
88
|
+
after(() => {
|
|
89
|
+
window.removeEventListener('error', ignoreResizeLoop, true);
|
|
90
|
+
window.onerror = previousOnError;
|
|
91
|
+
});
|
|
92
|
+
describe('on a read-only grid', () => {
|
|
93
|
+
it('has a handle that draws no line and leaves the header as it was', async () => {
|
|
94
|
+
const { header } = await grid();
|
|
95
|
+
const name = heads(header)[0];
|
|
96
|
+
const splitter = handle(name);
|
|
97
|
+
expect(!!splitter, 'the handle is there').to.equal(true);
|
|
98
|
+
expect(getComputedStyle(splitter).borderRightColor, 'no line').to.equal('rgba(0, 0, 0, 0)');
|
|
99
|
+
expect(parseFloat(getComputedStyle(name).paddingRight), 'the right padding stays').to.be.greaterThan(0);
|
|
100
|
+
expect(width(splitter), 'the handle is narrow').to.be.at.most(8);
|
|
101
|
+
});
|
|
102
|
+
it('draws its line while the pointer is on it', async () => {
|
|
103
|
+
const { header } = await grid();
|
|
104
|
+
const splitter = handle(heads(header)[0]);
|
|
105
|
+
await sendMouse({ type: 'move', position: centre(splitter) });
|
|
106
|
+
await settle(100);
|
|
107
|
+
expect(getComputedStyle(splitter).borderRightColor).not.to.equal('rgba(0, 0, 0, 0)');
|
|
108
|
+
});
|
|
109
|
+
it('can be dragged to widen the column', async () => {
|
|
110
|
+
const { header } = await grid();
|
|
111
|
+
const name = heads(header)[0];
|
|
112
|
+
const before = width(name);
|
|
113
|
+
await drag(centre(handle(name)), 40);
|
|
114
|
+
expect(width(heads(header)[0])).to.be.within(before + 35, before + 45);
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
for (const editable of [false, true]) {
|
|
118
|
+
describe(`on ${editable ? 'an editable' : 'a read-only'} grid, a double-click`, () => {
|
|
119
|
+
it('widens the column until no cell in it is cut', async () => {
|
|
120
|
+
const { header, body } = await grid({ editable });
|
|
121
|
+
const name = heads(header)[0];
|
|
122
|
+
expect(cut(name, body), 'the long name is cut to begin with').to.equal(true);
|
|
123
|
+
const before = width(name);
|
|
124
|
+
await doubleClick(centre(handle(name)));
|
|
125
|
+
const after = heads(header)[0];
|
|
126
|
+
expect(width(after)).to.be.greaterThan(before);
|
|
127
|
+
expect(cut(after, body)).to.equal(false);
|
|
128
|
+
});
|
|
129
|
+
it('leaves a column whose cells all fit as it is', async () => {
|
|
130
|
+
const { header } = await grid({ editable });
|
|
131
|
+
const code = heads(header)[1];
|
|
132
|
+
const before = width(code);
|
|
133
|
+
await doubleClick(centre(handle(code)));
|
|
134
|
+
expect(width(heads(header)[1])).to.equal(before);
|
|
135
|
+
});
|
|
136
|
+
it('widens a column of text and a mark until the mark is back', async () => {
|
|
137
|
+
const { header, body } = await grid({ editable });
|
|
138
|
+
const memo = heads(header)[2];
|
|
139
|
+
expect(cut(memo, body), 'the long text pushes the mark out to begin with').to.equal(true);
|
|
140
|
+
await doubleClick(centre(handle(memo)));
|
|
141
|
+
expect(cut(heads(header)[2], body)).to.equal(false);
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
it('does nothing on a click that does not drag (an fr column stays flexible)', async () => {
|
|
146
|
+
const { ox, header } = await grid({ editable: true, nameWidth: 'minmax(120px, 1fr)' });
|
|
147
|
+
const before = ox.style.getPropertyValue('--grid-template-columns');
|
|
148
|
+
await sendMouse({ type: 'click', position: centre(handle(heads(header)[0])) });
|
|
149
|
+
await settle(300);
|
|
150
|
+
expect(ox.style.getPropertyValue('--grid-template-columns')).to.equal(before);
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
//# sourceMappingURL=column-resize.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"column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oB,EAAE,CAAC,CAAA;QAEtF,MAAM,MAAM,GAAG,EAAE,CAAC,KAAK,CAAC,gBAAgB,CAAC,yBAAyB,CAAC,CAAA;QACnE,MAAM,SAAS,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAE,CAAC,EAAE,CAAC,CAAA;QAC/E,MAAM,MAAM,CAAC,GAAG,CAAC,CAAA;QAEjB,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,gBAAgB,CAAC,yBAAyB,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;IAC/E,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["/* Elements are compared by presence, not by value: a failing element comparison makes chai render the DOM and hang the runner. */\nimport { expect, fixture } from '@open-wc/testing'\nimport { executeServerCommand, sendMouse } from '@web/test-runner-commands'\nimport { html } from 'lit'\n\nimport '../src/data-grist.js'\n\n/**\n * A column's edge can be dragged and double-clicked on every grid.\n *\n * The handle on a column's edge also draws the grid's vertical line, and a grid with nothing to edit\n * hides its lines (--grid-header-splitter-display: none) - which took the handle with them. A read\n * list then had no way to widen a column whose text was cut, though reading is what it is for.\n *\n * ```\n * read-only the handle stays and draws no line until the pointer is on it or drags it; the header\n * keeps the look it had without one (its right padding, its name not pushed)\n * drag dragging the edge sets the width, on a read-only grid as on an editable one\n * fit double-clicking the edge widens the column until no cell in it is cut, header included\n * click a click that does not drag changes nothing (an fr column stays flexible)\n * ```\n */\n\ntype Root = HTMLElement & { renderRoot: ShadowRoot; updateComplete: Promise<unknown> }\n\nconst settle = (ms = 150) => new Promise(resolve => setTimeout(resolve, ms))\n\nconst LONG = 'A long counterparty name that does not fit its column'\n\nasync function grid({ editable = false, nameWidth = 120 as number | string } = {}) {\n const columns: any[] = [\n { type: 'string', name: 'id', hidden: true },\n { type: 'string', name: 'name', header: 'name', width: nameWidth, record: { editable } },\n { type: 'string', name: 'code', header: 'code', width: 100, record: { editable } },\n /* Text and a mark side by side, as the cash list's counterparty and its 「미등록」: long text pushes the mark out. */\n {\n type: 'string',\n name: 'memo',\n header: 'memo',\n width: 120,\n record: {\n editable,\n renderer: (value: string) => html`${value} <span style=\"font-size: 11px; font-weight: 600\">unregistered</span>`\n }\n }\n ]\n const records = Array.from({ length: 5 }, (_, r) => ({ id: String(r), name: r === 3 ? LONG : 'short', code: 'C-' + r, memo: r === 2 ? LONG : 'note' }))\n\n const el = (await fixture(html`\n <ox-grist\n style=\"width: 900px; height: 300px\"\n mode=\"GRID\"\n .config=${{ columns, pagination: { infinite: true }, rows: { appendable: false, selectable: false } }}\n .data=${{ records }}\n ></ox-grist>\n `)) as Root\n\n await settle()\n await el.updateComplete\n const ox = el.renderRoot.querySelector('#grist') as Root\n await ox.updateComplete\n const header = ox.renderRoot.querySelector('ox-grid-header') as Root\n const body = ox.renderRoot.querySelector('ox-grid-body') as Root\n await body.updateComplete\n await settle(50)\n\n return { ox, header, body }\n}\n\nconst heads = (header: Root) => Array.from(header.renderRoot.querySelectorAll('[role=columnheader]')) as HTMLElement[]\nconst width = (element: Element) => Math.round(element.getBoundingClientRect().width)\nconst handle = (head: HTMLElement) => head.querySelector('span[splitter]') as HTMLElement | null\n\nfunction centre(element: Element): [number, number] {\n const r = element.getBoundingClientRect()\n return [Math.round(r.left + r.width / 2), Math.round(r.top + r.height / 2)]\n}\n\n/** Whether the text of any cell of the column under this header is cut - the cell itself, or text it ends with \"…\". */\nfunction cut(head: HTMLElement, body: Root) {\n const left = head.getBoundingClientRect().left\n return (Array.from(body.renderRoot.querySelectorAll('ox-grid-field')) as Root[])\n .filter(cell => Math.abs(cell.getBoundingClientRect().left - left) < 1)\n .some(cell =>\n [cell, ...Array.from(cell.renderRoot.querySelectorAll('*'))]\n .filter(e => e === cell || getComputedStyle(e).textOverflow === 'ellipsis')\n .some(e => e.scrollWidth > e.clientWidth + 1)\n )\n}\n\nasync function drag(from: [number, number], by: number) {\n await sendMouse({ type: 'move', position: from })\n await sendMouse({ type: 'down' })\n await sendMouse({ type: 'move', position: [from[0] + by, from[1]] })\n await sendMouse({ type: 'up' })\n await settle(300)\n}\n\nasync function doubleClick([x, y]: [number, number]) {\n await executeServerCommand('send-double-click', { x, y })\n await settle(300)\n}\n\ndescribe('a column edge', () => {\n /* Resizing the grid body inside a fixture trips Chrome's benign \"ResizeObserver loop\" error. */\n const ignoreResizeLoop = (e: ErrorEvent) => {\n if (String(e.message).includes('ResizeObserver loop')) {\n e.stopImmediatePropagation()\n e.preventDefault()\n }\n }\n let previousOnError: OnErrorEventHandler = null\n before(() => {\n window.addEventListener('error', ignoreResizeLoop, true)\n previousOnError = window.onerror\n window.onerror = (message, ...rest) =>\n String(message).includes('ResizeObserver loop') ? true : previousOnError?.call(window, message, ...rest)\n })\n afterEach(async () => {\n await sendMouse({ type: 'move', position: [0, 0] })\n })\n after(() => {\n window.removeEventListener('error', ignoreResizeLoop, true)\n window.onerror = previousOnError\n })\n\n describe('on a read-only grid', () => {\n it('has a handle that draws no line and leaves the header as it was', async () => {\n const { header } = await grid()\n\n const name = heads(header)[0]\n const splitter = handle(name)\n expect(!!splitter, 'the handle is there').to.equal(true)\n expect(getComputedStyle(splitter!).borderRightColor, 'no line').to.equal('rgba(0, 0, 0, 0)')\n expect(parseFloat(getComputedStyle(name).paddingRight), 'the right padding stays').to.be.greaterThan(0)\n expect(width(splitter!), 'the handle is narrow').to.be.at.most(8)\n })\n\n it('draws its line while the pointer is on it', async () => {\n const { header } = await grid()\n\n const splitter = handle(heads(header)[0])!\n await sendMouse({ type: 'move', position: centre(splitter) })\n await settle(100)\n\n expect(getComputedStyle(splitter).borderRightColor).not.to.equal('rgba(0, 0, 0, 0)')\n })\n\n it('can be dragged to widen the column', async () => {\n const { header } = await grid()\n\n const name = heads(header)[0]\n const before = width(name)\n await drag(centre(handle(name)!), 40)\n\n expect(width(heads(header)[0])).to.be.within(before + 35, before + 45)\n })\n })\n\n for (const editable of [false, true]) {\n describe(`on ${editable ? 'an editable' : 'a read-only'} grid, a double-click`, () => {\n it('widens the column until no cell in it is cut', async () => {\n const { header, body } = await grid({ editable })\n\n const name = heads(header)[0]\n expect(cut(name, body), 'the long name is cut to begin with').to.equal(true)\n const before = width(name)\n await doubleClick(centre(handle(name)!))\n\n const after = heads(header)[0]\n expect(width(after)).to.be.greaterThan(before)\n expect(cut(after, body)).to.equal(false)\n })\n\n it('leaves a column whose cells all fit as it is', async () => {\n const { header } = await grid({ editable })\n\n const code = heads(header)[1]\n const before = width(code)\n await doubleClick(centre(handle(code)!))\n\n expect(width(heads(header)[1])).to.equal(before)\n })\n\n it('widens a column of text and a mark until the mark is back', async () => {\n const { header, body } = await grid({ editable })\n\n const memo = heads(header)[2]\n expect(cut(memo, body), 'the long text pushes the mark out to begin with').to.equal(true)\n await doubleClick(centre(handle(memo)!))\n\n expect(cut(heads(header)[2], body)).to.equal(false)\n })\n })\n }\n\n it('does nothing on a click that does not drag (an fr column stays flexible)', async () => {\n const { ox, header } = await grid({ editable: true, nameWidth: 'minmax(120px, 1fr)' })\n\n const before = ox.style.getPropertyValue('--grid-template-columns')\n await sendMouse({ type: 'click', position: centre(handle(heads(header)[0])!) })\n await settle(300)\n\n expect(ox.style.getPropertyValue('--grid-template-columns')).to.equal(before)\n })\n})\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { expect } from '@open-wc/testing';
|
|
2
|
+
import { DataGridField } from '../src/data-grid/data-grid-field.js';
|
|
3
|
+
import { FilterStyles } from '../src/filters/filter-styles.js';
|
|
4
|
+
/**
|
|
5
|
+
* A button inside a grid cell is --cell-action-height (26px by default, ADR-0060 decision 6), for its
|
|
6
|
+
* width as well: a second token for the width could say a different number. It still takes no more
|
|
7
|
+
* than a line of text in the row, so one cell with a button does not make every row taller.
|
|
8
|
+
*/
|
|
9
|
+
const text = (styles) => (Array.isArray(styles) ? styles : [styles]).map(s => { var _a; return String((_a = s.cssText) !== null && _a !== void 0 ? _a : s); }).join('\n');
|
|
10
|
+
describe('cell action height', () => {
|
|
11
|
+
it('the icon button in a cell reads the cell token for height and width', () => {
|
|
12
|
+
const css = text(DataGridField.styles);
|
|
13
|
+
const rule = css.slice(css.indexOf(':host > button.icon {'));
|
|
14
|
+
expect(rule).to.match(/^:host > button\.icon \{[^}]*width: var\(--cell-action-height, 26px\);/);
|
|
15
|
+
expect(rule).to.match(/^:host > button\.icon \{[^}]*height: var\(--cell-action-height, 26px\);/);
|
|
16
|
+
expect(rule).to.contain('margin-top: calc((20px - var(--cell-action-height, 26px)) / 2)');
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
describe('filter bar input height', () => {
|
|
20
|
+
it('a grid filter bar: the suite small height in the operato products, natural height elsewhere', () => {
|
|
21
|
+
const css = text(FilterStyles);
|
|
22
|
+
expect(css).to.match(/box-sizing: border-box;\s*height: var\(--suite-form-element-height-small, auto\);/);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=control-heights.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control-heights.test.js","sourceRoot":"","sources":["../../test/control-heights.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAEzC,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAA;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAE9D;;;;GAIG;AAEH,MAAM,IAAI,GAAG,CAAC,MAAe,EAAE,EAAE,CAC/B,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,WAAC,OAAA,MAAM,CAAC,MAAC,CAA0B,CAAC,OAAO,mCAAI,CAAC,CAAC,CAAA,EAAA,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAEnH,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAClC,EAAE,CAAC,qEAAqE,EAAE,GAAG,EAAE;QAC7E,MAAM,GAAG,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAA;QACtC,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAC,CAAA;QAE5D,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,wEAAwE,CAAC,CAAA;QAC/F,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,yEAAyE,CAAC,CAAA;QAChG,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,gEAAgE,CAAC,CAAA;IAC3F,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA;AAEF,QAAQ,CAAC,yBAAyB,EAAE,GAAG,EAAE;IACvC,EAAE,CAAC,6FAA6F,EAAE,GAAG,EAAE;QACrG,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,CAAC,CAAA;QAC9B,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,mFAAmF,CAAC,CAAA;IAC3G,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import { expect } from '@open-wc/testing'\n\nimport { DataGridField } from '../src/data-grid/data-grid-field.js'\nimport { FilterStyles } from '../src/filters/filter-styles.js'\n\n/**\n * A button inside a grid cell is --cell-action-height (26px by default, ADR-0060 decision 6), for its\n * width as well: a second token for the width could say a different number. It still takes no more\n * than a line of text in the row, so one cell with a button does not make every row taller.\n */\n\nconst text = (styles: unknown) =>\n (Array.isArray(styles) ? styles : [styles]).map(s => String((s as { cssText?: string }).cssText ?? s)).join('\\n')\n\ndescribe('cell action height', () => {\n it('the icon button in a cell reads the cell token for height and width', () => {\n const css = text(DataGridField.styles)\n const rule = css.slice(css.indexOf(':host > button.icon {'))\n\n expect(rule).to.match(/^:host > button\\.icon \\{[^}]*width: var\\(--cell-action-height, 26px\\);/)\n expect(rule).to.match(/^:host > button\\.icon \\{[^}]*height: var\\(--cell-action-height, 26px\\);/)\n expect(rule).to.contain('margin-top: calc((20px - var(--cell-action-height, 26px)) / 2)')\n })\n})\n\ndescribe('filter bar input height', () => {\n it('a grid filter bar: the suite small height in the operato products, natural height elsewhere', () => {\n const css = text(FilterStyles)\n expect(css).to.match(/box-sizing: border-box;\\s*height: var\\(--suite-form-element-height-small, auto\\);/)\n })\n})\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { expect, fixture } from '@open-wc/testing';
|
|
2
|
+
import { html, render } from 'lit';
|
|
3
|
+
import { DataProvider } from '../src/data-provider.js';
|
|
4
|
+
import { FilterSelectButtons } from '../src/filters/filter-select-buttons.js';
|
|
5
|
+
/**
|
|
6
|
+
* The counts beside a list's filter choices (ADR-0190): read with the conditions of each fetch that replaces the rows,
|
|
7
|
+
* under its signal - only the counts of the current read land, and a chip shows them when its option has none.
|
|
8
|
+
*/
|
|
9
|
+
function deferred() {
|
|
10
|
+
let resolve;
|
|
11
|
+
const promise = new Promise(yes => (resolve = yes));
|
|
12
|
+
return { promise, resolve };
|
|
13
|
+
}
|
|
14
|
+
function setup() {
|
|
15
|
+
const counted = [];
|
|
16
|
+
const consumer = Object.assign(new EventTarget(), {
|
|
17
|
+
shownMode: 'GRID',
|
|
18
|
+
data: { records: [] },
|
|
19
|
+
_data: { records: [] },
|
|
20
|
+
checkDirties() { },
|
|
21
|
+
showSpinner() { },
|
|
22
|
+
hideSpinner() { },
|
|
23
|
+
fetchHandler: async () => ({ total: 0, records: [] }),
|
|
24
|
+
countHandler(options) {
|
|
25
|
+
const answer = deferred();
|
|
26
|
+
counted.push({ options, answer });
|
|
27
|
+
return answer.promise;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
return { provider: new DataProvider(consumer), consumer, counted };
|
|
31
|
+
}
|
|
32
|
+
describe('countHandler', () => {
|
|
33
|
+
it("is read with the fetch's conditions and signal; a count of a read replaced never lands", async () => {
|
|
34
|
+
var _a;
|
|
35
|
+
const { provider, consumer, counted } = setup();
|
|
36
|
+
provider.filters = [{ name: 'state', operator: 'in', value: ['draft'] }];
|
|
37
|
+
void provider.fetch();
|
|
38
|
+
void provider.fetch();
|
|
39
|
+
expect(counted.length).to.equal(2);
|
|
40
|
+
expect(counted[0].options.filters).to.deep.equal([{ name: 'state', operator: 'in', value: ['draft'] }]);
|
|
41
|
+
expect((_a = counted[0].options.signal) === null || _a === void 0 ? void 0 : _a.aborted).to.equal(true);
|
|
42
|
+
counted[1].answer.resolve({ state: { draft: 2 } });
|
|
43
|
+
await Promise.resolve();
|
|
44
|
+
counted[0].answer.resolve({ state: { draft: 99 } });
|
|
45
|
+
await Promise.resolve();
|
|
46
|
+
expect(consumer.counts).to.deep.equal({ state: { draft: 2 } });
|
|
47
|
+
});
|
|
48
|
+
it('a chip shows the grid count for its column and value, unless the option gives its own', async () => {
|
|
49
|
+
const column = { name: 'state', filter: { operator: 'in', options: [{ display: 'Draft', value: 'draft' }, { display: 'Released', value: 'released', count: 7 }] }, record: {} };
|
|
50
|
+
const host = await fixture(html `<div></div>`);
|
|
51
|
+
render(FilterSelectButtons(column, [], { counts: { state: { draft: 3, released: 1 } } }), host);
|
|
52
|
+
const buttons = host.querySelector('ox-input-select-buttons');
|
|
53
|
+
expect(buttons.options.map((one) => one.count)).to.deep.equal([3, 7]);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
//# sourceMappingURL=count-handler.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"count-handler.test.js","sourceRoot":"","sources":["../../test/count-handler.test.ts"],"names":[],"mappings":"AAAA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CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,CAAA;IAChE,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,uFAAuF,EAAE,KAAK,IAAI,EAAE;QACrG,MAAM,MAAM,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAS,CAAA;QACtL,MAAM,IAAI,GAAG,MAAM,OAAO,CAAc,IAAI,CAAA,aAAa,CAAC,CAAA;QAC1D,MAAM,CAAC,mBAAmB,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,EAAE,EAAS,CAAC,EAAE,IAAI,CAAC,CAAA;QACtG,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAQ,CAAA;QACpE,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAQ,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;IAC5E,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import { expect, fixture } from '@open-wc/testing'\nimport { html, render } from 'lit'\n\nimport { DataProvider } from '../src/data-provider.js'\nimport type { DataConsumer } from '../src/data-consumer.js'\nimport { FilterSelectButtons } from '../src/filters/filter-select-buttons.js'\nimport type { FetchOption, FetchResult } from '../src/types.js'\n\n/**\n * The counts beside a list's filter choices (ADR-0190): read with the conditions of each fetch that replaces the rows,\n * under its signal - only the counts of the current read land, and a chip shows them when its option has none.\n */\nfunction deferred<T>() {\n let resolve!: (value: T) => void\n const promise = new Promise<T>(yes => (resolve = yes))\n return { promise, resolve }\n}\n\nfunction setup() {\n const counted: { options: FetchOption; answer: ReturnType<typeof deferred<Record<string, Record<string, number>>>> }[] = []\n const consumer = Object.assign(new EventTarget(), {\n shownMode: 'GRID' as const,\n data: { records: [] },\n _data: { records: [] },\n checkDirties() {},\n showSpinner() {},\n hideSpinner() {},\n fetchHandler: async (): Promise<FetchResult> => ({ total: 0, records: [] }),\n countHandler(options: FetchOption) {\n const answer = deferred<Record<string, Record<string, number>>>()\n counted.push({ options, answer })\n return answer.promise\n }\n }) as unknown as DataConsumer\n return { provider: new DataProvider(consumer), consumer, counted }\n}\n\ndescribe('countHandler', () => {\n it(\"is read with the fetch's conditions and signal; a count of a read replaced never lands\", async () => {\n const { provider, consumer, counted } = setup()\n provider.filters = [{ name: 'state', operator: 'in', value: ['draft'] }] as any\n void provider.fetch()\n void provider.fetch()\n expect(counted.length).to.equal(2)\n expect(counted[0].options.filters).to.deep.equal([{ name: 'state', operator: 'in', value: ['draft'] }])\n expect(counted[0].options.signal?.aborted).to.equal(true)\n counted[1].answer.resolve({ state: { draft: 2 } })\n await Promise.resolve()\n counted[0].answer.resolve({ state: { draft: 99 } })\n await Promise.resolve()\n expect(consumer.counts).to.deep.equal({ state: { draft: 2 } })\n })\n\n it('a chip shows the grid count for its column and value, unless the option gives its own', async () => {\n const column = { name: 'state', filter: { operator: 'in', options: [{ display: 'Draft', value: 'draft' }, { display: 'Released', value: 'released', count: 7 }] }, record: {} } as any\n const host = await fixture<HTMLElement>(html`<div></div>`)\n render(FilterSelectButtons(column, [], { counts: { state: { draft: 3, released: 1 } } } as any), host)\n const buttons = host.querySelector('ox-input-select-buttons') as any\n expect(buttons.options.map((one: any) => one.count)).to.deep.equal([3, 7])\n })\n})\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '../src/data-grist.js';
|