@operato/data-grist 10.29.77 → 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.
Files changed (150) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/src/data-card/record-card.d.ts +4 -0
  3. package/dist/src/data-card/record-card.js +62 -20
  4. package/dist/src/data-card/record-card.js.map +1 -1
  5. package/dist/src/editors/ox-grist-editor-date.d.ts +2 -0
  6. package/dist/src/editors/ox-grist-editor-date.js +3 -8
  7. package/dist/src/editors/ox-grist-editor-date.js.map +1 -1
  8. package/dist/src/editors/ox-grist-editor-month.d.ts +2 -0
  9. package/dist/src/editors/ox-grist-editor-month.js +3 -1
  10. package/dist/src/editors/ox-grist-editor-month.js.map +1 -1
  11. package/dist/src/editors/ox-grist-editor-week.d.ts +2 -0
  12. package/dist/src/editors/ox-grist-editor-week.js +3 -1
  13. package/dist/src/editors/ox-grist-editor-week.js.map +1 -1
  14. package/dist/src/editors/ox-grist-editor.js +2 -1
  15. package/dist/src/editors/ox-grist-editor.js.map +1 -1
  16. package/dist/src/filters/filter-input.d.ts +1 -0
  17. package/dist/src/filters/filter-input.js +20 -0
  18. package/dist/src/filters/filter-input.js.map +1 -1
  19. package/dist/src/filters/filter-range-date.d.ts +7 -0
  20. package/dist/src/filters/filter-range-date.js +53 -0
  21. package/dist/src/filters/filter-range-date.js.map +1 -1
  22. package/dist/src/filters/filter-select-buttons.js +7 -0
  23. package/dist/src/filters/filter-select-buttons.js.map +1 -1
  24. package/dist/src/filters/filter-styles.js +8 -2
  25. package/dist/src/filters/filter-styles.js.map +1 -1
  26. package/dist/src/filters/filters-form.js +38 -14
  27. package/dist/src/filters/filters-form.js.map +1 -1
  28. package/dist/src/filters/pill-choice.d.ts +24 -0
  29. package/dist/src/filters/pill-choice.js +63 -0
  30. package/dist/src/filters/pill-choice.js.map +1 -0
  31. package/dist/test/accessible-name.test.js +324 -0
  32. package/dist/test/accessible-name.test.js.map +1 -0
  33. package/dist/test/accumulator-labels.test.d.ts +1 -0
  34. package/dist/test/accumulator-labels.test.js +32 -0
  35. package/dist/test/accumulator-labels.test.js.map +1 -0
  36. package/dist/test/address-intents.test.js +201 -0
  37. package/dist/test/address-intents.test.js.map +1 -0
  38. package/dist/test/card-selector.test.js +71 -0
  39. package/dist/test/card-selector.test.js.map +1 -0
  40. package/dist/test/card-thumb.test.d.ts +1 -0
  41. package/dist/test/card-thumb.test.js +44 -0
  42. package/dist/test/card-thumb.test.js.map +1 -0
  43. package/dist/test/card-totals-narrow.test.js +103 -0
  44. package/dist/test/card-totals-narrow.test.js.map +1 -0
  45. package/dist/test/cell-button-row-height.test.js +53 -0
  46. package/dist/test/cell-button-row-height.test.js.map +1 -0
  47. package/dist/test/column-resize.test.js +153 -0
  48. package/dist/test/column-resize.test.js.map +1 -0
  49. package/dist/test/control-heights.test.js +25 -0
  50. package/dist/test/control-heights.test.js.map +1 -0
  51. package/dist/test/count-handler.test.js +56 -0
  52. package/dist/test/count-handler.test.js.map +1 -0
  53. package/dist/test/create-paste-policy.test.js +159 -0
  54. package/dist/test/create-paste-policy.test.js.map +1 -0
  55. package/dist/test/data-integrity.test.js +145 -0
  56. package/dist/test/data-integrity.test.js.map +1 -0
  57. package/dist/test/date-fields.test.d.ts +2 -0
  58. package/dist/test/date-fields.test.js +138 -0
  59. package/dist/test/date-fields.test.js.map +1 -0
  60. package/dist/test/destructive-actions.test.js +147 -0
  61. package/dist/test/destructive-actions.test.js.map +1 -0
  62. package/dist/test/edit-lifecycle.test.js +270 -0
  63. package/dist/test/edit-lifecycle.test.js.map +1 -0
  64. package/dist/test/edit-rebase.test.js +185 -0
  65. package/dist/test/edit-rebase.test.js.map +1 -0
  66. package/dist/test/editor-commit.test.js +68 -0
  67. package/dist/test/editor-commit.test.js.map +1 -0
  68. package/dist/test/fetch-failure-state.test.js +129 -0
  69. package/dist/test/fetch-failure-state.test.js.map +1 -0
  70. package/dist/test/field-contains-content.test.js +101 -0
  71. package/dist/test/field-contains-content.test.js.map +1 -0
  72. package/dist/test/field-hint.test.js +54 -0
  73. package/dist/test/field-hint.test.js.map +1 -0
  74. package/dist/test/filter-labels.test.js +140 -0
  75. package/dist/test/filter-labels.test.js.map +1 -0
  76. package/dist/test/filter-ownership.test.js +83 -0
  77. package/dist/test/filter-ownership.test.js.map +1 -0
  78. package/dist/test/filter-select-buttons-count.test.js +36 -0
  79. package/dist/test/filter-select-buttons-count.test.js.map +1 -0
  80. package/dist/test/filter-typing.test.js +66 -0
  81. package/dist/test/filter-typing.test.js.map +1 -0
  82. package/dist/test/filters-phone-width.test.d.ts +1 -0
  83. package/dist/test/filters-phone-width.test.js +33 -0
  84. package/dist/test/filters-phone-width.test.js.map +1 -0
  85. package/dist/test/filters-phone-wrap.test.js +17 -0
  86. package/dist/test/filters-phone-wrap.test.js.map +1 -0
  87. package/dist/test/filters-pills.test.d.ts +2 -0
  88. package/dist/test/filters-pills.test.js +149 -0
  89. package/dist/test/filters-pills.test.js.map +1 -0
  90. package/dist/test/first-click-stays.test.js +77 -0
  91. package/dist/test/first-click-stays.test.js.map +1 -0
  92. package/dist/test/fixed-column-opaque.test.js +134 -0
  93. package/dist/test/fixed-column-opaque.test.js.map +1 -0
  94. package/dist/test/flexible-columns.test.js +134 -0
  95. package/dist/test/flexible-columns.test.js.map +1 -0
  96. package/dist/test/grid-single-scroller.test.js +107 -0
  97. package/dist/test/grid-single-scroller.test.js.map +1 -0
  98. package/dist/test/group-heading.test.js +208 -0
  99. package/dist/test/group-heading.test.js.map +1 -0
  100. package/dist/test/latest-fetch-wins.test.js +91 -0
  101. package/dist/test/latest-fetch-wins.test.js.map +1 -0
  102. package/dist/test/list-defaults.test.js +146 -0
  103. package/dist/test/list-defaults.test.js.map +1 -0
  104. package/dist/test/list-records.test.js +46 -0
  105. package/dist/test/list-records.test.js.map +1 -0
  106. package/dist/test/office-density.test.js +52 -0
  107. package/dist/test/office-density.test.js.map +1 -0
  108. package/dist/test/page-errors.d.ts +1 -0
  109. package/dist/test/page-errors.js +44 -0
  110. package/dist/test/page-errors.js.map +1 -0
  111. package/dist/test/paste-integrity.test.js +163 -0
  112. package/dist/test/paste-integrity.test.js.map +1 -0
  113. package/dist/test/record-card-height.test.js +15 -0
  114. package/dist/test/record-card-height.test.js.map +1 -0
  115. package/dist/test/record-view-popup-editor.test.js +71 -0
  116. package/dist/test/record-view-popup-editor.test.js.map +1 -0
  117. package/dist/test/renderer-date-calendar-day.test.js +48 -0
  118. package/dist/test/renderer-date-calendar-day.test.js.map +1 -0
  119. package/dist/test/request-generation.test.js +153 -0
  120. package/dist/test/request-generation.test.js.map +1 -0
  121. package/dist/test/resubmit.test.js +83 -0
  122. package/dist/test/resubmit.test.js.map +1 -0
  123. package/dist/test/row-hover-visible.test.js +139 -0
  124. package/dist/test/row-hover-visible.test.js.map +1 -0
  125. package/dist/test/search-term.test.js +108 -0
  126. package/dist/test/search-term.test.js.map +1 -0
  127. package/dist/test/searchable-select.test.js +65 -0
  128. package/dist/test/searchable-select.test.js.map +1 -0
  129. package/dist/test/select-empty-value.test.js +61 -0
  130. package/dist/test/select-empty-value.test.js.map +1 -0
  131. package/dist/test/shift-range-select.test.js +100 -0
  132. package/dist/test/shift-range-select.test.js.map +1 -0
  133. package/dist/test/sparkline-renderer.test.js +36 -0
  134. package/dist/test/sparkline-renderer.test.js.map +1 -0
  135. package/dist/test/wheel-one-scroller.test.js +275 -0
  136. package/dist/test/wheel-one-scroller.test.js.map +1 -0
  137. package/dist/tsconfig.tsbuildinfo +1 -1
  138. package/package.json +7 -7
  139. package/test/card-selector.test.ts +18 -4
  140. package/test/date-fields.test.ts +163 -0
  141. package/test/filter-select-buttons-count.test.ts +2 -1
  142. package/test/filters-phone-width.test.ts +35 -0
  143. package/test/filters-pills.test.ts +162 -0
  144. package/test/list-defaults.test.ts +2 -1
  145. package/translations/en.json +8 -1
  146. package/translations/es.json +8 -1
  147. package/translations/ja.json +8 -1
  148. package/translations/ko.json +8 -1
  149. package/translations/ms.json +8 -1
  150. package/translations/zh.json +8 -1
@@ -0,0 +1,134 @@
1
+ import { expect, fixture } from '@open-wc/testing';
2
+ import { html } from 'lit';
3
+ import '../src/data-grid/data-grid-body.js';
4
+ import { ZERO_CONFIG, ZERO_DATA } from '../src/configure/zero-config.js';
5
+ /**
6
+ * 고정 열의 바탕.
7
+ *
8
+ * ## 왜 시험이 필요한가
9
+ *
10
+ * 고정 칸은 `position: sticky` 로 스크롤되는 열 **위에** 떠 있다. 그래서 이 칸의 바탕이 투명해지면
11
+ * 아래로 지나가는 열이 그대로 비쳐, 한 줄에 글자 두 벌이 겹쳐 보인다
12
+ * (`P-CAM-I-0001` 위에 `CAM-INSP-01` 이 찍혔다).
13
+ *
14
+ * 바탕이 지워지는 것은 색을 잘못 고른 것이 아니라 **줄 상태 색을 `transparent` 로 둔 것**이었다.
15
+ * 그 값은 「칠하지 않는다」가 아니라 「칸의 바탕을 지운다」다. 지워진 자리에는 표 뒤에 있는 것이
16
+ * 비치고, 그것은 표가 정한 색이 아니다.
17
+ *
18
+ * ## 두 가지를 함께 잰다
19
+ *
20
+ * ```
21
+ * 불투명한가 투명해지면 스크롤되는 열이 비친다
22
+ * 같은 색인가 고정 열만 다르면 줄 하나가 두 색으로 갈린다
23
+ * ```
24
+ *
25
+ * 둘을 따로 두면 **한쪽만 지키는 고침이 통과한다.** 실제로 그랬다 — 뒤에 불투명한 층을 깔아 첫째를
26
+ * 지켰는데, 그 층이 상태 색을 덮어 둘째가 깨졌다(음수 z-index 자식은 자기 요소의 배경 **위에**
27
+ * 그려진다).
28
+ */
29
+ /** 상태마다 실제로 쓰는 색. 표(data-grist.ts)가 채우는 자리를 같이 채운다. */
30
+ const 색들 = `
31
+ --grid-record-background-color: #ffffff;
32
+ --grid-record-odd-background-color: #f4f5f7;
33
+ --grid-record-selected-background-color: #dbe7f3;
34
+ --grid-record-emphasized-background-color: #fdf3d7;
35
+ --grid-record-editing-background-color: #eef6ff;
36
+ --grid-record-disabled-background-color: #f0f1f3;
37
+ `;
38
+ async function 표를세운다(hover = 'rgb(247, 248, 250)') {
39
+ const el = (await fixture(html `
40
+ <ox-grid-body style="${색들} --grid-record-hover-background-color: ${hover};"></ox-grid-body>
41
+ `));
42
+ /*
43
+ * 칸은 column.record.renderer 로 내용을 그린다. 그것이 없으면 칸마다 예외가 나고, 예외가 나는
44
+ * 칸의 색을 재면 무엇을 잰 것인지 알 수 없다.
45
+ */
46
+ const 열 = (name, width) => ({
47
+ name,
48
+ type: 'string',
49
+ width,
50
+ record: { renderer: (value) => html `<span>${value !== null && value !== void 0 ? value : ''}</span>`, align: 'left' }
51
+ });
52
+ el.config = { ...ZERO_CONFIG, columns: [] };
53
+ el.columns = [열('name', 120), 열('description', 200), 열('tail', 200)];
54
+ el.data = { ...ZERO_DATA, records: [{ name: 'P-CAM-I-0001' }, { name: 'P-CAM-P-0001' }] };
55
+ /* 첫 열만 고정한다 — 왼쪽 오프셋이 있는 열이 곧 고정 열이다. */
56
+ el.fixedLefts = [0];
57
+ el.from = 0;
58
+ el.to = 2;
59
+ await el.updateComplete;
60
+ return el;
61
+ }
62
+ const 칸들 = (el) => Array.from(el.renderRoot.querySelectorAll('ox-grid-field'));
63
+ const 고정 = (el) => 칸들(el).filter(c => c.hasAttribute('fixed'));
64
+ const 스크롤 = (el) => 칸들(el).filter(c => !c.hasAttribute('fixed'));
65
+ /**
66
+ * **칸에 칠해진 색.**
67
+ *
68
+ * `background-color` 하나만 본다 — 요소의 배경은 그것이 맨 아래이고, 그 위에 무엇을 깔면
69
+ * (`::before` · inset 그림자) 상태 색을 **덮는다.** 그래서 그 둘을 합쳐 재면 「덮여서 안 보이는
70
+ * 색」을 「칠해진 색」으로 읽는다. 한 번 그렇게 재고 고쳤다고 말했다.
71
+ */
72
+ const 칠해진색 = (cell) => getComputedStyle(cell).backgroundColor;
73
+ const 알파 = (color) => {
74
+ const parts = (color.match(/[\d.]+/g) || []).map(Number);
75
+ return parts.length > 3 ? parts[3] : 1;
76
+ };
77
+ const 상태들 = ['hovered-row', 'selected-row', 'emphasized-row', 'editing', 'disabled'];
78
+ describe('고정 열의 바탕', () => {
79
+ describe('어떤 줄 상태에서도 불투명하다', () => {
80
+ it('아무 상태도 아닌 줄', async () => {
81
+ const el = await 표를세운다();
82
+ expect(고정(el).length, '고정 열이 안 그려지면 이 시험이 아무것도 재지 않는다').to.be.greaterThan(0);
83
+ expect(알파(칠해진색(고정(el)[0]))).to.equal(1);
84
+ });
85
+ 상태들.forEach(상태 => {
86
+ it(`${상태} 인 줄`, async () => {
87
+ const el = await 표를세운다();
88
+ 칸들(el).forEach(cell => cell.setAttribute(상태, ''));
89
+ await el.updateComplete;
90
+ expect(알파(칠해진색(고정(el)[0])), '이 상태가 바탕을 지우면 스크롤되는 열이 고정 열 아래에서 비쳐 보인다').to.equal(1);
91
+ });
92
+ });
93
+ it('홀수 줄', async () => {
94
+ const el = await 표를세운다();
95
+ 칸들(el).forEach(cell => cell.setAttribute('odd', ''));
96
+ await el.updateComplete;
97
+ expect(알파(칠해진색(고정(el)[0]))).to.equal(1);
98
+ });
99
+ });
100
+ describe('줄 하나는 한 색이다', () => {
101
+ 상태들.forEach(상태 => {
102
+ it(`${상태} — 고정 열과 스크롤되는 열이 같은 색`, async () => {
103
+ const el = await 표를세운다();
104
+ 칸들(el).forEach(cell => cell.setAttribute(상태, ''));
105
+ await el.updateComplete;
106
+ expect(칠해진색(고정(el)[0]), '고정 열만 다르면 줄 하나가 두 색으로 갈린다').to.equal(칠해진색(스크롤(el)[0]));
107
+ });
108
+ });
109
+ it('마우스가 지나는 줄은 표가 정한 색이다', async () => {
110
+ const el = await 표를세운다('rgb(247, 248, 250)');
111
+ 칸들(el).forEach(cell => cell.setAttribute('hovered-row', ''));
112
+ await el.updateComplete;
113
+ expect(칠해진색(고정(el)[0])).to.equal('rgb(247, 248, 250)');
114
+ });
115
+ });
116
+ ['::before', '::after'].forEach(층 => {
117
+ it(`고정 칸을 ${층} 로 덮지 않는다`, async () => {
118
+ const el = await 표를세운다();
119
+ 칸들(el).forEach(cell => cell.setAttribute('hovered-row', ''));
120
+ await el.updateComplete;
121
+ const cs = getComputedStyle(고정(el)[0], 층);
122
+ expect(알파(cs.backgroundColor), '이 층이 줄 상태의 색을 덮는다').to.equal(0);
123
+ expect(cs.backgroundImage, '이 층이 줄 상태의 색을 덮는다').to.equal('none');
124
+ });
125
+ });
126
+ /** 고침이 아니라 **왜 그 방식이 안 되는지**를 못박는다. 고치는 표가 이렇게 두고 있었다. */
127
+ it('색을 비우면 칸의 바탕이 지워진다 — 그래서 비우지 않는다', async () => {
128
+ const el = await 표를세운다('transparent');
129
+ 칸들(el).forEach(cell => cell.setAttribute('hovered-row', ''));
130
+ await el.updateComplete;
131
+ expect(칠해진색(스크롤(el)[0]), 'transparent 는 「칠하지 않는다」가 아니라 「지운다」다 — 표 뒤가 무엇이든 그것이 줄 색이 된다').to.equal('rgba(0, 0, 0, 0)');
132
+ });
133
+ });
134
+ //# sourceMappingURL=fixed-column-opaque.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixed-column-opaque.test.js","sourceRoot":"","sources":["../../test/fixed-column-opaque.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAE1B,OAAO,oCAAoC,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAA;AAExE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,uDAAuD;AACvD,MAAM,EAAE,GAAG;;;;;;;CAOV,CAAA;AAED,KAAK,UAAU,KAAK,CAAC,KAAK,GAAG,oBAAoB;IAC/C,MAAM,EAAE,GAAG,CAAC,MAAM,OAAO,CAAC,IAAI,CAAA;2BACL,EAAE,0CAA0C,KAAK;GACzE,CAAC,CAAQ,CAAA;IAEV;;;OAGG;IACH,MAAM,CAAC,G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,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;YAEzC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,eAAe,CAAC,EAAE,mBAAmB,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;YAC/D,MAAM,CAAC,EAAE,CAAC,eAAe,EAAE,mBAAmB,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;QAClE,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,0DAA0D;IAC1D,EAAE,CAAC,kCAAkC,EAAE,KAAK,IAAI,EAAE;QAChD,MAAM,EAAE,GAAG,MAAM,KAAK,CAAC,aAAa,CAAC,CAAA;QAErC,EAAE,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC,CAAA;QAC5D,MAAM,EAAE,CAAC,cAAc,CAAA;QAEvB,MAAM,CACJ,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAChB,6DAA6D,CAC9D,CAAC,EAAE,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAA;IAChC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import { expect, fixture } from '@open-wc/testing'\nimport { html } from 'lit'\n\nimport '../src/data-grid/data-grid-body.js'\nimport { ZERO_CONFIG, ZERO_DATA } from '../src/configure/zero-config.js'\n\n/**\n * 고정 열의 바탕.\n *\n * ## 왜 시험이 필요한가\n *\n * 고정 칸은 `position: sticky` 로 스크롤되는 열 **위에** 떠 있다. 그래서 이 칸의 바탕이 투명해지면\n * 아래로 지나가는 열이 그대로 비쳐, 한 줄에 글자 두 벌이 겹쳐 보인다\n * (`P-CAM-I-0001` 위에 `CAM-INSP-01` 이 찍혔다).\n *\n * 바탕이 지워지는 것은 색을 잘못 고른 것이 아니라 **줄 상태 색을 `transparent` 로 둔 것**이었다.\n * 그 값은 「칠하지 않는다」가 아니라 「칸의 바탕을 지운다」다. 지워진 자리에는 표 뒤에 있는 것이\n * 비치고, 그것은 표가 정한 색이 아니다.\n *\n * ## 두 가지를 함께 잰다\n *\n * ```\n * 불투명한가 투명해지면 스크롤되는 열이 비친다\n * 같은 색인가 고정 열만 다르면 줄 하나가 두 색으로 갈린다\n * ```\n *\n * 둘을 따로 두면 **한쪽만 지키는 고침이 통과한다.** 실제로 그랬다 — 뒤에 불투명한 층을 깔아 첫째를\n * 지켰는데, 그 층이 상태 색을 덮어 둘째가 깨졌다(음수 z-index 자식은 자기 요소의 배경 **위에**\n * 그려진다).\n */\n\n/** 상태마다 실제로 쓰는 색. 표(data-grist.ts)가 채우는 자리를 같이 채운다. */\nconst 색들 = `\n --grid-record-background-color: #ffffff;\n --grid-record-odd-background-color: #f4f5f7;\n --grid-record-selected-background-color: #dbe7f3;\n --grid-record-emphasized-background-color: #fdf3d7;\n --grid-record-editing-background-color: #eef6ff;\n --grid-record-disabled-background-color: #f0f1f3;\n`\n\nasync function 표를세운다(hover = 'rgb(247, 248, 250)') {\n const el = (await fixture(html`\n <ox-grid-body style=\"${색들} --grid-record-hover-background-color: ${hover};\"></ox-grid-body>\n `)) as any\n\n /*\n * 칸은 column.record.renderer 로 내용을 그린다. 그것이 없으면 칸마다 예외가 나고, 예외가 나는\n * 칸의 색을 재면 무엇을 잰 것인지 알 수 없다.\n */\n const 열 = (name: string, width: number) => ({\n name,\n type: 'string',\n width,\n record: { renderer: (value: unknown) => html`<span>${value ?? ''}</span>`, align: 'left' }\n })\n\n el.config = { ...ZERO_CONFIG, columns: [] }\n el.columns = [열('name', 120), 열('description', 200), 열('tail', 200)]\n el.data = { ...ZERO_DATA, records: [{ name: 'P-CAM-I-0001' }, { name: 'P-CAM-P-0001' }] }\n /* 첫 열만 고정한다 — 왼쪽 오프셋이 있는 열이 곧 고정 열이다. */\n el.fixedLefts = [0]\n el.from = 0\n el.to = 2\n\n await el.updateComplete\n\n return el\n}\n\nconst 칸들 = (el: any): HTMLElement[] => Array.from(el.renderRoot.querySelectorAll('ox-grid-field'))\nconst 고정 = (el: any) => 칸들(el).filter(c => c.hasAttribute('fixed'))\nconst 스크롤 = (el: any) => 칸들(el).filter(c => !c.hasAttribute('fixed'))\n\n/**\n * **칸에 칠해진 색.**\n *\n * `background-color` 하나만 본다 — 요소의 배경은 그것이 맨 아래이고, 그 위에 무엇을 깔면\n * (`::before` · inset 그림자) 상태 색을 **덮는다.** 그래서 그 둘을 합쳐 재면 「덮여서 안 보이는\n * 색」을 「칠해진 색」으로 읽는다. 한 번 그렇게 재고 고쳤다고 말했다.\n */\nconst 칠해진색 = (cell: Element) => getComputedStyle(cell).backgroundColor\nconst 알파 = (color: string) => {\n const parts = (color.match(/[\\d.]+/g) || []).map(Number)\n return parts.length > 3 ? parts[3] : 1\n}\n\nconst 상태들 = ['hovered-row', 'selected-row', 'emphasized-row', 'editing', 'disabled']\n\ndescribe('고정 열의 바탕', () => {\n describe('어떤 줄 상태에서도 불투명하다', () => {\n it('아무 상태도 아닌 줄', async () => {\n const el = await 표를세운다()\n\n expect(고정(el).length, '고정 열이 안 그려지면 이 시험이 아무것도 재지 않는다').to.be.greaterThan(0)\n expect(알파(칠해진색(고정(el)[0]))).to.equal(1)\n })\n\n 상태들.forEach(상태 => {\n it(`${상태} 인 줄`, async () => {\n const el = await 표를세운다()\n\n 칸들(el).forEach(cell => cell.setAttribute(상태, ''))\n await el.updateComplete\n\n expect(\n 알파(칠해진색(고정(el)[0])),\n '이 상태가 바탕을 지우면 스크롤되는 열이 고정 열 아래에서 비쳐 보인다'\n ).to.equal(1)\n })\n })\n\n it('홀수 줄', async () => {\n const el = await 표를세운다()\n\n 칸들(el).forEach(cell => cell.setAttribute('odd', ''))\n await el.updateComplete\n\n expect(알파(칠해진색(고정(el)[0]))).to.equal(1)\n })\n })\n\n describe('줄 하나는 한 색이다', () => {\n 상태들.forEach(상태 => {\n it(`${상태} — 고정 열과 스크롤되는 열이 같은 색`, async () => {\n const el = await 표를세운다()\n\n 칸들(el).forEach(cell => cell.setAttribute(상태, ''))\n await el.updateComplete\n\n expect(칠해진색(고정(el)[0]), '고정 열만 다르면 줄 하나가 두 색으로 갈린다').to.equal(\n 칠해진색(스크롤(el)[0])\n )\n })\n })\n\n it('마우스가 지나는 줄은 표가 정한 색이다', async () => {\n const el = await 표를세운다('rgb(247, 248, 250)')\n\n 칸들(el).forEach(cell => cell.setAttribute('hovered-row', ''))\n await el.updateComplete\n\n expect(칠해진색(고정(el)[0])).to.equal('rgb(247, 248, 250)')\n })\n })\n\n /**\n * **칸 위에 덮는 층을 두지 않는다.**\n *\n * 위의 시험들은 `background-color` 를 읽으므로 이것을 못 잡는다 — 그 위에 층을 깔아도 속성은\n * 그대로다. 실제로 그렇게 한 번 놓쳤다: `[fixed]::before` 로 불투명한 바탕을 깔고 「같은\n * 색이다」라고 쟀는데, 화면에서는 그 층이 상태 색을 덮어 고정 열에서만 띠가 사라졌다.\n *\n * 음수 z-index 자식은 자기 요소의 배경 **위에** 그려진다. 요소의 배경보다 아래에 층을 깔\n * 방법은 없다. 그러니 규칙은 하나다 — **덮지 않는다.**\n */\n ;['::before', '::after'].forEach(층 => {\n it(`고정 칸을 ${층} 로 덮지 않는다`, async () => {\n const el = await 표를세운다()\n\n 칸들(el).forEach(cell => cell.setAttribute('hovered-row', ''))\n await el.updateComplete\n\n const cs = getComputedStyle(고정(el)[0], 층)\n\n expect(알파(cs.backgroundColor), '이 층이 줄 상태의 색을 덮는다').to.equal(0)\n expect(cs.backgroundImage, '이 층이 줄 상태의 색을 덮는다').to.equal('none')\n })\n })\n\n /** 고침이 아니라 **왜 그 방식이 안 되는지**를 못박는다. 고치는 표가 이렇게 두고 있었다. */\n it('색을 비우면 칸의 바탕이 지워진다 — 그래서 비우지 않는다', async () => {\n const el = await 표를세운다('transparent')\n\n 칸들(el).forEach(cell => cell.setAttribute('hovered-row', ''))\n await el.updateComplete\n\n expect(\n 칠해진색(스크롤(el)[0]),\n 'transparent 는 「칠하지 않는다」가 아니라 「지운다」다 — 표 뒤가 무엇이든 그것이 줄 색이 된다'\n ).to.equal('rgba(0, 0, 0, 0)')\n })\n})\n"]}
@@ -0,0 +1,134 @@
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 { 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 very long account name that is far wider than any room the table has left for it';
8
+ async function grid(widths, width = 700, editable = false) {
9
+ var _a, _b;
10
+ const columns = [
11
+ { type: 'string', name: 'id', hidden: true },
12
+ { type: 'string', name: 'name', header: 'name', width: (_a = widths.name) !== null && _a !== void 0 ? _a : 150, record: { editable } },
13
+ { type: 'string', name: 'code', header: 'code', width: 100 },
14
+ { type: 'string', name: 'memo', header: 'memo', width: (_b = widths.memo) !== null && _b !== void 0 ? _b : 120 }
15
+ ];
16
+ const records = Array.from({ length: 5 }, (_, r) => ({ id: String(r), name: r % 2 ? LONG : 'short', code: 'C-' + r, memo: 'note ' + r }));
17
+ const el = (await fixture(html `
18
+ <ox-grist
19
+ style=${`width: ${width}px; height: 320px`}
20
+ mode="GRID"
21
+ .config=${{ columns, pagination: { infinite: true }, rows: { appendable: false, selectable: false } }}
22
+ .data=${{ records }}
23
+ ></ox-grist>
24
+ `));
25
+ await settle();
26
+ await el.updateComplete;
27
+ const ox = el.renderRoot.querySelector('#grist');
28
+ await ox.updateComplete;
29
+ const scroller = ox.renderRoot.querySelector('div[grid]');
30
+ const header = ox.renderRoot.querySelector('ox-grid-header');
31
+ const body = ox.renderRoot.querySelector('ox-grid-body');
32
+ await body.updateComplete;
33
+ await settle(50);
34
+ return { ox, scroller, header, body };
35
+ }
36
+ function heads(header) {
37
+ return Array.from(header.renderRoot.querySelectorAll('[role=columnheader]'));
38
+ }
39
+ function width(element) {
40
+ return Math.round(element.getBoundingClientRect().width);
41
+ }
42
+ /** The largest distance, in left or in width, between a header cell and a cell of its column, over every row. */
43
+ function misalignment(header, body) {
44
+ const hs = heads(header);
45
+ let worst = 0;
46
+ for (const row of Array.from(body.renderRoot.querySelectorAll('div[grid-row]'))) {
47
+ const cells = Array.from(row.querySelectorAll(':scope > ox-grid-field'));
48
+ hs.forEach((h, i) => {
49
+ const cell = cells[i];
50
+ if (!cell)
51
+ return;
52
+ const a = h.getBoundingClientRect();
53
+ const b = cell.getBoundingClientRect();
54
+ worst = Math.max(worst, Math.abs(a.left - b.left), Math.abs(a.width - b.width));
55
+ });
56
+ }
57
+ return Math.round(worst);
58
+ }
59
+ /** Whether the text of a column's cell is cut in any row. */
60
+ function cut(body, index) {
61
+ return Array.from(body.renderRoot.querySelectorAll('div[grid-row]')).some(row => {
62
+ const cell = row.querySelectorAll(':scope > ox-grid-field')[index];
63
+ return !!cell && [cell, ...Array.from(cell.renderRoot.querySelectorAll('*'))].some(e => e.scrollWidth > e.clientWidth + 1);
64
+ });
65
+ }
66
+ describe('a flexible column', () => {
67
+ /* Resizing the grid body inside a fixture trips Chrome's benign "ResizeObserver loop" error. */
68
+ const ignoreResizeLoop = (e) => {
69
+ if (String(e.message).includes('ResizeObserver loop')) {
70
+ e.stopImmediatePropagation();
71
+ e.preventDefault();
72
+ }
73
+ };
74
+ let previousOnError = null;
75
+ before(() => {
76
+ window.addEventListener('error', ignoreResizeLoop, true);
77
+ previousOnError = window.onerror;
78
+ window.onerror = (message, ...rest) => String(message).includes('ResizeObserver loop') ? true : previousOnError === null || previousOnError === void 0 ? void 0 : previousOnError.call(window, message, ...rest);
79
+ });
80
+ after(async () => {
81
+ window.removeEventListener('error', ignoreResizeLoop, true);
82
+ window.onerror = previousOnError;
83
+ await sendMouse({ type: 'move', position: [0, 0] });
84
+ });
85
+ it('with room, takes the room on the right and stays under its header', async () => {
86
+ const { scroller, header, body } = await grid({ name: 'minmax(150px, 1fr)' }, 1200);
87
+ const name = heads(header)[0];
88
+ expect(width(name), 'the column takes the room').to.be.greaterThan(500);
89
+ expect(scroller.scrollWidth, 'nothing overflows').to.be.at.most(scroller.clientWidth);
90
+ expect(misalignment(header, body)).to.equal(0);
91
+ });
92
+ it('without room, stays at its floor, cuts its text and stays under its header', async () => {
93
+ const { header, body } = await grid({ name: 'minmax(150px, 1fr)', memo: 600 }, 700);
94
+ expect(width(heads(header)[0])).to.equal(150);
95
+ expect(cut(body, 0), 'the long name is cut').to.equal(true);
96
+ expect(misalignment(header, body)).to.equal(0);
97
+ });
98
+ it('two flexible columns share the room one to two and stay under their headers', async () => {
99
+ const { header, body } = await grid({ name: 'minmax(100px, 1fr)', memo: 'minmax(100px, 2fr)' }, 900);
100
+ const [name, , memo] = heads(header);
101
+ /* fr shares the whole width of the tracks, not what is above their floors: 1fr and 2fr are x and 2x. */
102
+ const share = width(memo) / width(name);
103
+ expect(share).to.be.within(1.9, 2.1);
104
+ expect(misalignment(header, body)).to.equal(0);
105
+ });
106
+ it('leaves a table of fixed columns as it was', async () => {
107
+ const { body } = await grid({}, 700);
108
+ const cell = body.renderRoot.querySelector('ox-grid-field');
109
+ expect(getComputedStyle(cell).contain).to.equal('none');
110
+ });
111
+ it('prints with a valid template', async () => {
112
+ const { ox } = await grid({ name: 'minmax(150px, 1fr)' }, 700);
113
+ const print = ox.style.getPropertyValue('--grid-template-print-columns');
114
+ expect(CSS.supports('grid-template-columns', print), print).to.equal(true);
115
+ expect(print).to.contain('150fr');
116
+ });
117
+ it('dragging its edge gives it a width in px from where it stood', async () => {
118
+ const { header } = await grid({ name: 'minmax(150px, 1fr)' }, 1000, true);
119
+ const name = heads(header)[0];
120
+ const before = width(name);
121
+ const splitter = name.querySelector('span[splitter]');
122
+ expect(!!splitter, 'an editable column has a handle').to.equal(true);
123
+ const r = splitter.getBoundingClientRect();
124
+ const x = Math.round(r.left + r.width / 2);
125
+ const y = Math.round(r.top + r.height / 2);
126
+ await sendMouse({ type: 'move', position: [x, y] });
127
+ await sendMouse({ type: 'down' });
128
+ await sendMouse({ type: 'move', position: [x - 40, y] });
129
+ await sendMouse({ type: 'up' });
130
+ await settle(300);
131
+ expect(width(heads(header)[0])).to.be.within(before - 45, before - 35);
132
+ });
133
+ });
134
+ //# sourceMappingURL=flexible-columns.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flexible-columns.test.js","sourceRoot":"","sources":["../../test/flexible-columns.test.ts"],"names":[],"mappings":"AAAA,kIAAkI;AAClI,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAE1B,OAAO,sBAAsB,CAAA;AAuB7B,MAAM,MAAM,GAAG,CAAC,EAAE,GAAG,GAAG,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAA;AAE5E,MAAM,IAAI,GAAG,oFAAoF,CAAA;AAEjG,KAAK,UAAU,IAAI,CAAC,MAAkC,EAAE,KAAK,GAAG,GAAG,EAAE,QAAQ,GAAG,KAAK;;IACnF,MAAM,OAAO,GAAU;QACrB,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;QAC5C,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAA,MAAM,CAAC,IAAI,mCAAI,GAAG,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,EAAE;QACjG,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE;QAC5D,EAAE,I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,iCAAiC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAEpE,MAAM,CAAC,GAAG,QAAQ,CAAC,qBAAqB,EAAE,CAAA;QAC1C,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAA;QAC1C,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;QAC1C,MAAM,SAAS,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAA;QACnD,MAAM,SAAS,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAA;QACjC,MAAM,SAAS,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAA;QACxD,MAAM,SAAS,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;QAC/B,MAAM,MAAM,CAAC,GAAG,CAAC,CAAA;QAEjB,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,GAAG,EAAE,EAAE,MAAM,GAAG,EAAE,CAAC,CAAA;IACxE,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 { sendMouse } from '@web/test-runner-commands'\nimport { html } from 'lit'\n\nimport '../src/data-grist.js'\n\n/**\n * A column that takes the room left over: `width: 'minmax(150px, 1fr)'`.\n *\n * A string width goes into grid-template-columns as it is, so fr was always accepted — and broke the\n * table. The header and the body are two CSS grids with the same template. A flexible track is sized\n * from what its cells hold, and the two grids hold different things: the body grew the column to its\n * longest text while the header kept it at its floor. Measured on the balance screen: 182px apart with\n * one fr column whose text was longer than the room, 251px with two fr columns.\n *\n * ```\n * aligned every cell sits under its header, room or no room\n * room a flexible column takes the room on the right; the filler after the last column gets none\n * no room it stays at its floor and its text is cut (\"…\"), as a fixed column's is\n * ratio 1fr and 2fr share the room one to two\n * print the print template is a valid template (px became fr letter by letter: minmax(150fr, 1fr))\n * resize dragging a flexible column's edge gives it a width in px from where it stood\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 very long account name that is far wider than any room the table has left for it'\n\nasync function grid(widths: { name?: any; memo?: any }, width = 700, editable = false) {\n const columns: any[] = [\n { type: 'string', name: 'id', hidden: true },\n { type: 'string', name: 'name', header: 'name', width: widths.name ?? 150, record: { editable } },\n { type: 'string', name: 'code', header: 'code', width: 100 },\n { type: 'string', name: 'memo', header: 'memo', width: widths.memo ?? 120 }\n ]\n\n const records = Array.from({ length: 5 }, (_, r) => ({ id: String(r), name: r % 2 ? LONG : 'short', code: 'C-' + r, memo: 'note ' + r }))\n\n const el = (await fixture(html`\n <ox-grist\n style=${`width: ${width}px; height: 320px`}\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\n const ox = el.renderRoot.querySelector('#grist') as Root\n await ox.updateComplete\n const scroller = ox.renderRoot.querySelector('div[grid]') as HTMLElement\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, scroller, header, body }\n}\n\nfunction heads(header: Root) {\n return Array.from(header.renderRoot.querySelectorAll('[role=columnheader]')) as HTMLElement[]\n}\n\nfunction width(element: Element) {\n return Math.round(element.getBoundingClientRect().width)\n}\n\n/** The largest distance, in left or in width, between a header cell and a cell of its column, over every row. */\nfunction misalignment(header: Root, body: Root) {\n const hs = heads(header)\n let worst = 0\n for (const row of Array.from(body.renderRoot.querySelectorAll('div[grid-row]'))) {\n const cells = Array.from(row.querySelectorAll(':scope > ox-grid-field')) as HTMLElement[]\n hs.forEach((h, i) => {\n const cell = cells[i]\n if (!cell) return\n const a = h.getBoundingClientRect()\n const b = cell.getBoundingClientRect()\n worst = Math.max(worst, Math.abs(a.left - b.left), Math.abs(a.width - b.width))\n })\n }\n return Math.round(worst)\n}\n\n/** Whether the text of a column's cell is cut in any row. */\nfunction cut(body: Root, index: number) {\n return Array.from(body.renderRoot.querySelectorAll('div[grid-row]')).some(row => {\n const cell = row.querySelectorAll(':scope > ox-grid-field')[index] as Root | undefined\n return !!cell && [cell, ...Array.from(cell.renderRoot.querySelectorAll('*'))].some(e => e.scrollWidth > e.clientWidth + 1)\n })\n}\n\ndescribe('a flexible column', () => {\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 after(async () => {\n window.removeEventListener('error', ignoreResizeLoop, true)\n window.onerror = previousOnError\n await sendMouse({ type: 'move', position: [0, 0] })\n })\n\n it('with room, takes the room on the right and stays under its header', async () => {\n const { scroller, header, body } = await grid({ name: 'minmax(150px, 1fr)' }, 1200)\n\n const name = heads(header)[0]\n expect(width(name), 'the column takes the room').to.be.greaterThan(500)\n expect(scroller.scrollWidth, 'nothing overflows').to.be.at.most(scroller.clientWidth)\n expect(misalignment(header, body)).to.equal(0)\n })\n\n it('without room, stays at its floor, cuts its text and stays under its header', async () => {\n const { header, body } = await grid({ name: 'minmax(150px, 1fr)', memo: 600 }, 700)\n\n expect(width(heads(header)[0])).to.equal(150)\n expect(cut(body, 0), 'the long name is cut').to.equal(true)\n expect(misalignment(header, body)).to.equal(0)\n })\n\n it('two flexible columns share the room one to two and stay under their headers', async () => {\n const { header, body } = await grid({ name: 'minmax(100px, 1fr)', memo: 'minmax(100px, 2fr)' }, 900)\n\n const [name, , memo] = heads(header)\n /* fr shares the whole width of the tracks, not what is above their floors: 1fr and 2fr are x and 2x. */\n const share = width(memo) / width(name)\n expect(share).to.be.within(1.9, 2.1)\n expect(misalignment(header, body)).to.equal(0)\n })\n\n it('leaves a table of fixed columns as it was', async () => {\n const { body } = await grid({}, 700)\n\n const cell = body.renderRoot.querySelector('ox-grid-field') as HTMLElement\n expect(getComputedStyle(cell).contain).to.equal('none')\n })\n\n it('prints with a valid template', async () => {\n const { ox } = await grid({ name: 'minmax(150px, 1fr)' }, 700)\n\n const print = ox.style.getPropertyValue('--grid-template-print-columns')\n expect(CSS.supports('grid-template-columns', print), print).to.equal(true)\n expect(print).to.contain('150fr')\n })\n\n it('dragging its edge gives it a width in px from where it stood', async () => {\n const { header } = await grid({ name: 'minmax(150px, 1fr)' }, 1000, true)\n\n const name = heads(header)[0]\n const before = width(name)\n const splitter = name.querySelector('span[splitter]') as HTMLElement\n expect(!!splitter, 'an editable column has a handle').to.equal(true)\n\n const r = splitter.getBoundingClientRect()\n const x = Math.round(r.left + r.width / 2)\n const y = Math.round(r.top + r.height / 2)\n await sendMouse({ type: 'move', position: [x, y] })\n await sendMouse({ type: 'down' })\n await sendMouse({ type: 'move', position: [x - 40, y] })\n await sendMouse({ type: 'up' })\n await settle(300)\n\n expect(width(heads(header)[0])).to.be.within(before - 45, before - 35)\n })\n})\n"]}
@@ -0,0 +1,107 @@
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
+ const settle = (ms = 150) => new Promise(resolve => setTimeout(resolve, ms));
6
+ async function grid() {
7
+ const columns = [
8
+ { type: 'gutter', gutterName: 'sequence' },
9
+ { type: 'string', name: 'id', hidden: true },
10
+ { type: 'string', name: 'code', header: 'code', width: 120, fixed: true }
11
+ ];
12
+ for (let i = 0; i < 12; i++) {
13
+ columns.push({ type: 'string', name: 'c' + i, header: 'col ' + i, width: 110 });
14
+ }
15
+ const records = Array.from({ length: 60 }, (_, r) => {
16
+ const record = { id: String(r), code: 'C-' + r };
17
+ for (let i = 0; i < 12; i++)
18
+ record['c' + i] = `v${r}-${i}`;
19
+ return record;
20
+ });
21
+ const el = (await fixture(html `
22
+ <ox-grist
23
+ style="width: 600px; height: 320px"
24
+ mode="GRID"
25
+ .config=${{ columns, pagination: { pages: [100] } }}
26
+ .fetchHandler=${async () => ({ total: records.length, records })}
27
+ ></ox-grist>
28
+ `));
29
+ await el.fetch();
30
+ await settle();
31
+ await el.updateComplete;
32
+ const grist = el.renderRoot.querySelector('#grist');
33
+ const scroller = grist.renderRoot.querySelector('div[grid]');
34
+ const header = grist.renderRoot.querySelector('ox-grid-header');
35
+ const body = grist.renderRoot.querySelector('ox-grid-body');
36
+ await body.updateComplete;
37
+ return { grist, scroller, header, body };
38
+ }
39
+ /** The largest horizontal distance between a column's header cell and its cell in the first row. */
40
+ function misalignment(header, body) {
41
+ const heads = Array.from(header.renderRoot.querySelectorAll('[role=columnheader]'));
42
+ const row = body.renderRoot.querySelector('div[grid-row]');
43
+ const cells = Array.from(row.querySelectorAll('ox-grid-field'));
44
+ const n = Math.min(heads.length, cells.length);
45
+ let worst = 0;
46
+ for (let i = 0; i < n; i++) {
47
+ worst = Math.max(worst, Math.abs(heads[i].getBoundingClientRect().left - cells[i].getBoundingClientRect().left));
48
+ }
49
+ return { n, worst };
50
+ }
51
+ describe('grid header and body share one scroller', () => {
52
+ /* Resizing the grid body inside a fixture trips Chrome's benign "ResizeObserver loop" error. */
53
+ const ignoreResizeLoop = (e) => {
54
+ if (String(e.message).includes('ResizeObserver loop')) {
55
+ e.stopImmediatePropagation();
56
+ e.preventDefault();
57
+ }
58
+ };
59
+ let previousOnError = null;
60
+ before(() => {
61
+ window.addEventListener('error', ignoreResizeLoop, true);
62
+ previousOnError = window.onerror;
63
+ window.onerror = (message, ...rest) => String(message).includes('ResizeObserver loop') ? true : previousOnError === null || previousOnError === void 0 ? void 0 : previousOnError.call(window, message, ...rest);
64
+ });
65
+ after(() => {
66
+ window.removeEventListener('error', ignoreResizeLoop, true);
67
+ window.onerror = previousOnError;
68
+ });
69
+ it('neither the header nor the body scrolls on its own', async () => {
70
+ const { scroller, header, body } = await grid();
71
+ expect(scroller.scrollWidth, 'the grid must overflow, or this measures nothing').to.be.greaterThan(scroller.clientWidth);
72
+ expect(getComputedStyle(body).overflowX).to.equal('visible');
73
+ expect(getComputedStyle(header).overflowX).to.equal('visible');
74
+ expect(header.offsetWidth, 'header and body span the same width').to.equal(body.offsetWidth);
75
+ });
76
+ for (const where of ['start', 'middle', 'end']) {
77
+ it(`every column lines up with its header at the ${where}`, async () => {
78
+ const { scroller, header, body } = await grid();
79
+ const max = scroller.scrollWidth - scroller.clientWidth;
80
+ scroller.scrollLeft = where === 'start' ? 0 : where === 'middle' ? Math.round(max / 2) : max;
81
+ await settle(50);
82
+ const { n, worst } = misalignment(header, body);
83
+ expect(n, 'columns must be drawn, or this measures nothing').to.be.greaterThan(10);
84
+ expect(worst).to.equal(0);
85
+ });
86
+ }
87
+ it('the header stays on top when the rows scroll', async () => {
88
+ const { scroller, header } = await grid();
89
+ scroller.scrollTop = 600;
90
+ await settle(50);
91
+ expect(scroller.scrollTop, 'the rows must scroll, or this measures nothing').to.be.greaterThan(0);
92
+ expect(header.getBoundingClientRect().top).to.equal(scroller.getBoundingClientRect().top);
93
+ });
94
+ it('a focused row that was under the header is brought out below it', async () => {
95
+ const { grist, scroller, header, body } = await grid();
96
+ scroller.scrollTop = 600;
97
+ await settle(50);
98
+ grist.focused = { row: 2, column: 3 };
99
+ await grist.updateComplete;
100
+ await body.updateComplete;
101
+ await settle(50);
102
+ const focused = body.renderRoot.querySelector('ox-grid-field[focused]');
103
+ expect(!!focused, 'a cell must take the focus').to.equal(true);
104
+ expect(focused.getBoundingClientRect().top).to.be.at.least(header.getBoundingClientRect().bottom - 1);
105
+ });
106
+ });
107
+ //# sourceMappingURL=grid-single-scroller.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grid-single-scroller.test.js","sourceRoot":"","sources":["../../test/grid-single-scroller.test.ts"],"names":[],"mappings":"AAAA,kIAAkI;AAClI,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAE1B,OAAO,sBAAsB,CAAA;AAqB7B,MAAM,MAAM,GAAG,CAAC,EAAE,GAAG,GAAG,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAA;AAE5E,KAAK,UAAU,IAAI;IACjB,MAAM,OAAO,GAAU;QACrB,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE;QAC1C,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;QAC5C,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE;KAC1E,CAAA;IACD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;QAC5B,OAAO,CA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ence, 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'\n\n/**\n * Header and body move as one.\n *\n * The body used to be its own scroller, and the header a second scroller that copied the body's\n * scrollLeft from its scroll event (and the other way round). Three things went wrong:\n *\n * ```\n * gap the compositor moves the body at once; the header only moves after the main thread\n * handles the event, so on a busy screen it trails by several frames\n * shake the sync ran both ways, so a late header event put the body back one frame\n * the end when the two scroll widths differ, the header stops while the body goes on\n * ```\n *\n * Now the role=grid box is the only scroller. The header sticks to its top and the body does not\n * scroll. Nothing copies a position, so nothing can trail or pull back.\n */\n\ntype Root = HTMLElement & { renderRoot: ShadowRoot; updateComplete: Promise<unknown> }\n\nconst settle = (ms = 150) => new Promise(resolve => setTimeout(resolve, ms))\n\nasync function grid() {\n const columns: any[] = [\n { type: 'gutter', gutterName: 'sequence' },\n { type: 'string', name: 'id', hidden: true },\n { type: 'string', name: 'code', header: 'code', width: 120, fixed: true }\n ]\n for (let i = 0; i < 12; i++) {\n columns.push({ type: 'string', name: 'c' + i, header: 'col ' + i, width: 110 })\n }\n\n const records = Array.from({ length: 60 }, (_, r) => {\n const record: any = { id: String(r), code: 'C-' + r }\n for (let i = 0; i < 12; i++) record['c' + i] = `v${r}-${i}`\n return record\n })\n\n const el = (await fixture(html`\n <ox-grist\n style=\"width: 600px; height: 320px\"\n mode=\"GRID\"\n .config=${{ columns, pagination: { pages: [100] } }}\n .fetchHandler=${async () => ({ total: records.length, records })}\n ></ox-grist>\n `)) as Root & { fetch(): Promise<void> }\n\n await el.fetch()\n await settle()\n await el.updateComplete\n\n const grist = el.renderRoot.querySelector('#grist') as Root & { focused?: { row: number; column: number } }\n const scroller = grist.renderRoot.querySelector('div[grid]') as HTMLElement\n const header = grist.renderRoot.querySelector('ox-grid-header') as Root\n const body = grist.renderRoot.querySelector('ox-grid-body') as Root\n await body.updateComplete\n\n return { grist, scroller, header, body }\n}\n\n/** The largest horizontal distance between a column's header cell and its cell in the first row. */\nfunction misalignment(header: Root, body: Root) {\n const heads = Array.from(header.renderRoot.querySelectorAll('[role=columnheader]')) as HTMLElement[]\n const row = body.renderRoot.querySelector('div[grid-row]') as HTMLElement\n const cells = Array.from(row.querySelectorAll('ox-grid-field')) as HTMLElement[]\n const n = Math.min(heads.length, cells.length)\n\n let worst = 0\n for (let i = 0; i < n; i++) {\n worst = Math.max(worst, Math.abs(heads[i].getBoundingClientRect().left - cells[i].getBoundingClientRect().left))\n }\n return { n, worst }\n}\n\ndescribe('grid header and body share one scroller', () => {\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 after(() => {\n window.removeEventListener('error', ignoreResizeLoop, true)\n window.onerror = previousOnError\n })\n\n it('neither the header nor the body scrolls on its own', async () => {\n const { scroller, header, body } = await grid()\n\n expect(scroller.scrollWidth, 'the grid must overflow, or this measures nothing').to.be.greaterThan(\n scroller.clientWidth\n )\n expect(getComputedStyle(body).overflowX).to.equal('visible')\n expect(getComputedStyle(header).overflowX).to.equal('visible')\n expect(header.offsetWidth, 'header and body span the same width').to.equal(body.offsetWidth)\n })\n\n for (const where of ['start', 'middle', 'end'] as const) {\n it(`every column lines up with its header at the ${where}`, async () => {\n const { scroller, header, body } = await grid()\n\n const max = scroller.scrollWidth - scroller.clientWidth\n scroller.scrollLeft = where === 'start' ? 0 : where === 'middle' ? Math.round(max / 2) : max\n await settle(50)\n\n const { n, worst } = misalignment(header, body)\n expect(n, 'columns must be drawn, or this measures nothing').to.be.greaterThan(10)\n expect(worst).to.equal(0)\n })\n }\n\n it('the header stays on top when the rows scroll', async () => {\n const { scroller, header } = await grid()\n\n scroller.scrollTop = 600\n await settle(50)\n\n expect(scroller.scrollTop, 'the rows must scroll, or this measures nothing').to.be.greaterThan(0)\n expect(header.getBoundingClientRect().top).to.equal(scroller.getBoundingClientRect().top)\n })\n\n it('a focused row that was under the header is brought out below it', async () => {\n const { grist, scroller, header, body } = await grid()\n\n scroller.scrollTop = 600\n await settle(50)\n\n grist.focused = { row: 2, column: 3 }\n await grist.updateComplete\n await body.updateComplete\n await settle(50)\n\n const focused = body.renderRoot.querySelector('ox-grid-field[focused]') as HTMLElement\n expect(!!focused, 'a cell must take the focus').to.equal(true)\n expect(focused.getBoundingClientRect().top).to.be.at.least(header.getBoundingClientRect().bottom - 1)\n })\n})\n"]}