@dxos/lit-grid 0.8.4-staging.ac66bdf99f → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/lit-grid",
3
- "version": "0.8.4-staging.ac66bdf99f",
3
+ "version": "0.9.0",
4
4
  "description": "A grid Web Component using Lit",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -8,7 +8,7 @@
8
8
  "type": "git",
9
9
  "url": "https://github.com/dxos/dxos"
10
10
  },
11
- "license": "MIT",
11
+ "license": "FSL-1.1-Apache-2.0",
12
12
  "author": "DXOS.org",
13
13
  "sideEffects": [
14
14
  "*.css",
@@ -30,13 +30,6 @@
30
30
  },
31
31
  "main": "dist/src/index.js",
32
32
  "types": "dist/src/index.d.ts",
33
- "typesVersions": {
34
- "*": {
35
- "testing": [
36
- "dist/src/testing/index.d.ts"
37
- ]
38
- }
39
- },
40
33
  "files": [
41
34
  "src",
42
35
  "dist"
@@ -46,7 +39,10 @@
46
39
  "lit": "^3.3.1"
47
40
  },
48
41
  "devDependencies": {
49
- "@dxos/random": "0.8.4-staging.ac66bdf99f",
50
- "@dxos/test-utils": "0.8.4-staging.ac66bdf99f"
42
+ "@dxos/random": "0.9.0",
43
+ "@dxos/test-utils": "0.9.0"
44
+ },
45
+ "publishConfig": {
46
+ "access": "public"
51
47
  }
52
48
  }
@@ -25,6 +25,6 @@ dx-grid-axis-resize-handle {
25
25
  outline: none;
26
26
  }
27
27
  &:focus-visible {
28
- background: var(--color-accent-surface);
28
+ background: var(--color-accent-bg);
29
29
  }
30
30
  }
package/src/dx-grid.pcss CHANGED
@@ -19,8 +19,13 @@
19
19
  @layer dx-components {
20
20
  dx-grid {
21
21
  display: contents;
22
- --dx-grid-gap: 1px;
23
- --dx-plane-gap: 1px;
22
+ /*
23
+ * Cells touch edge-to-edge; lines come from each cell's border-right /
24
+ * border-bottom. Setting either gap to a non-zero value re-introduces the
25
+ * doubled-line artifact at plane seams.
26
+ */
27
+ --dx-grid-gap: 0;
28
+ --dx-plane-gap: 0;
24
29
  }
25
30
 
26
31
  .dx-grid {
@@ -56,7 +61,7 @@
56
61
  position: absolute;
57
62
  inset: 0;
58
63
  pointer-events: none;
59
- border: var(--dx-grid-focus-indicator-width) solid var(--color-grid-focus-indicator);
64
+ border: var(--dx-grid-focus-indicator-width) solid var(--color-focus-ring);
60
65
  }
61
66
  }
62
67
 
@@ -70,17 +75,26 @@
70
75
 
71
76
  .dx-grid {
72
77
  --grid-cell-surface: var(--color-grid-surface);
78
+ --grid-cell-fg: var(--color-grid-fg);
73
79
 
74
80
  [role='gridcell'],
75
81
  [role='columnheader'],
76
82
  [role='rowheader'] {
77
83
  background: var(--grid-cell-surface);
84
+ color: var(--grid-cell-fg);
78
85
  cursor: pointer;
79
86
  position: relative;
80
87
 
81
- /** TODO(burdon): It this performant? */
82
- border-right: 1px solid var(--color-grid-line);
83
- border-bottom: 1px solid var(--color-grid-line);
88
+ /*
89
+ * Paint grid lines via inset box-shadow rather than border so the cell's
90
+ * content-box equals its border-box. This lets `.dx-grid__cell__content`
91
+ * (with block-size/inline-size: 100%) fill the cell exactly — including
92
+ * the right/bottom edges. When focused, the cell-content's own border
93
+ * (focus ring) then aligns with the grid lines pixel-for-pixel.
94
+ */
95
+ box-shadow:
96
+ inset calc(-1 * var(--dx-grid-focus-indicator-width)) 0 0 var(--color-grid-line),
97
+ inset 0 calc(-1 * var(--dx-grid-focus-indicator-width)) 0 var(--color-grid-line);
84
98
 
85
99
  &[aria-readonly='true'] {
86
100
  cursor: default;
@@ -126,7 +140,8 @@
126
140
  [role='columnheader'],
127
141
  [role='rowheader'] {
128
142
  &[aria-selected] {
129
- --grid-cell-surface: var(--color-grid-selection-overlay);
143
+ --grid-cell-surface: var(--color-grid-selection-surface);
144
+ --grid-cell-fg: var(--color-grid-selection-fg);
130
145
 
131
146
  &:focus:not([aria-readonly='true']),
132
147
  &:focus-visible,
@@ -148,7 +163,7 @@
148
163
  }
149
164
 
150
165
  &:has(.dx-grid__row--cta__cell:hover) .dx-grid__row--cta__cell {
151
- background: var(--color-grid-hover-overlay);
166
+ background: var(--color-grid-highlight);
152
167
  }
153
168
  }
154
169
 
@@ -161,10 +176,15 @@
161
176
  &:focus,
162
177
  &:focus-within {
163
178
  & > .dx-grid__cell__content {
164
- min-block-size: 100%;
165
- block-size: min-content;
166
- max-block-size: min(12em, 50vh);
167
-
179
+ /*
180
+ * Inline (horizontal) unfurl: cell-content can grow horizontally
181
+ * to show wider content. Block-size stays clamped to the cell
182
+ * height so the focus ring aligns with the bottom grid line —
183
+ * `block-size: min-content` would let cell-content overshoot the
184
+ * cell when the content's natural height (line-height + padding +
185
+ * border) exceeds the cell track size by even a fraction of a
186
+ * pixel, pushing the focus ring's bottom edge below the grid line.
187
+ */
168
188
  min-inline-size: 100%;
169
189
  inline-size: min-content;
170
190
  max-inline-size: min(60ch, 90vw);
@@ -173,23 +193,20 @@
173
193
  scrollbar-width: thin;
174
194
  overscroll-behavior: contain;
175
195
 
176
- white-space: normal;
177
- hyphens: auto;
178
- overflow-wrap: break-word;
179
-
180
196
  z-index: 1;
181
197
 
182
198
  background: var(--grid-cell-surface);
199
+ color: var(--grid-cell-fg);
183
200
  }
184
201
 
185
202
  &:not([aria-readonly='true']) > .dx-grid__cell__content {
186
- border-color: var(--color-grid-focus-indicator);
203
+ border-color: var(--color-focus-ring);
187
204
  }
188
205
  }
189
206
  }
190
207
 
191
208
  &:focus-visible > .dx-grid__cell__content {
192
- border-color: var(--color-grid-focus-indicator);
209
+ border-color: var(--color-focus-ring);
193
210
  }
194
211
  }
195
212
  }
@@ -201,7 +218,7 @@
201
218
  overflow-wrap: break-word;
202
219
 
203
220
  background: var(--dx-grid-base, var(--color-base-surface));
204
- border: var(--dx-grid-focus-indicator-width) solid var(--color-grid-focus-indicator);
221
+ border: var(--dx-grid-focus-indicator-width) solid var(--color-focus-ring);
205
222
  border-radius: 2px;
206
223
 
207
224
  --dx-grid-cell-editor-max-block-size: min(12em, 50vh);
@@ -227,7 +244,7 @@
227
244
  [role='columnheader'],
228
245
  [role='rowheader'] {
229
246
  &[data-dx-active]:not([aria-readonly='true']) > .dx-grid__cell__content {
230
- border-color: var(--color-grid-focus-indicator);
247
+ border-color: var(--color-focus-ring);
231
248
  }
232
249
  }
233
250
  }
@@ -12,8 +12,9 @@ import { toPlaneCellIndex } from '../util';
12
12
 
13
13
  const gridPlaneCellSize = 31;
14
14
  const gap = 1;
15
- const nCols = 9;
16
- const nRows = 7;
15
+ // The spec viewport fits one extra column/row beyond the nominal grid plane size.
16
+ const nCols = 10;
17
+ const nRows = 8;
17
18
 
18
19
  test.describe('dx-grid', () => {
19
20
  let page: Page;
@@ -23,8 +24,8 @@ test.describe('dx-grid', () => {
23
24
  const setup = await setupPage(browser, {
24
25
  url: storybookUrl('dx-grid--spec', 9002),
25
26
  viewportSize: {
26
- width: (gridPlaneCellSize + gap) * (nCols + 1.5),
27
- height: (gridPlaneCellSize + gap) * (nRows + 1.5),
27
+ width: (gridPlaneCellSize + gap) * (nCols + 0.5),
28
+ height: (gridPlaneCellSize + gap) * (nRows + 0.5),
28
29
  }, // 336 x 272
29
30
  });
30
31
  page = setup.page;
@@ -46,8 +47,8 @@ test.describe('dx-grid', () => {
46
47
  // Now pan by wheel to the center point of the cell one right and one down from the origin cell of the grid plane.
47
48
  await grid.panByWheel(gridPlaneCellSize * 1.5 + gap, gridPlaneCellSize * 1.5 + gap);
48
49
 
49
- // Confirm that the grid plane is showing only the cells that would be visible.
50
- await grid.expectVirtualizationResult(nCols + 1, nRows + 1, 1, 1);
50
+ // Pan shifts the viewport by one cell; visible cell counts stay the same.
51
+ await grid.expectVirtualizationResult(nCols, nRows, 1, 1);
51
52
  });
52
53
 
53
54
  test('mouse access', async () => {
package/src/util.ts CHANGED
@@ -63,9 +63,11 @@ export const rowToA1Notation = (row: number): string => {
63
63
  };
64
64
 
65
65
  /**
66
- * The size in pixels of the gap between cells
66
+ * The size in pixels of the gap between cells.
67
+ * Must match `--dx-grid-gap` / `--dx-plane-gap` in `dx-grid.pcss`. Cells
68
+ * paint their own borders edge-to-edge, so this is 0.
67
69
  */
68
- export const gap = 1;
70
+ export const gap = 0;
69
71
 
70
72
  /**
71
73
  * ResizeObserver notices even subpixel changes, only respond to changes of at least 1px.