@dxos/lit-grid 0.8.4-main.e098934 → 0.8.4-main.ead640a

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-main.e098934",
3
+ "version": "0.8.4-main.ead640a",
4
4
  "description": "A grid Web Component using Lit",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -36,10 +36,10 @@
36
36
  ],
37
37
  "dependencies": {
38
38
  "@atlaskit/pragmatic-drag-and-drop": "^1.4.0",
39
- "lit": "^3.2.0"
39
+ "lit": "^3.3.1"
40
40
  },
41
41
  "devDependencies": {
42
- "@dxos/random": "0.8.4-main.e098934",
43
- "@dxos/test-utils": "0.8.4-main.e098934"
42
+ "@dxos/random": "0.8.4-main.ead640a",
43
+ "@dxos/test-utils": "0.8.4-main.ead640a"
44
44
  }
45
45
  }
package/src/dx-grid.pcss CHANGED
@@ -4,10 +4,10 @@
4
4
  @layer dx-tokens {
5
5
  :root {
6
6
  --dx-grid-cell-padding-block: 0.2rem;
7
- --dx-grid-cell-content-padding-block: calc(var(--dx-grid-cell-padding-block) - 1px);
7
+ --dx-grid-cell-content-padding-block: calc(var(--dx-grid-cell-padding-block) - var(--dx-gridFocusIndicatorWidth));
8
8
  --dx-grid-cell-editor-padding-block: var(--dx-grid-cell-content-padding-block);
9
9
  --dx-grid-cell-padding-inline: 0.25rem;
10
- --dx-grid-cell-content-padding-inline: calc(var(--dx-grid-cell-padding-inline) - 1px);
10
+ --dx-grid-cell-content-padding-inline: calc(var(--dx-grid-cell-padding-inline) - var(--dx-gridFocusIndicatorWidth));
11
11
  --dx-grid-cell-editor-padding-inline: var(--dx-grid-cell-content-padding-inline);
12
12
  }
13
13
  }
@@ -54,7 +54,7 @@
54
54
  position: absolute;
55
55
  inset: 0;
56
56
  pointer-events: none;
57
- border: 1px solid var(--dx-accentSurface);
57
+ border: var(--dx-gridFocusIndicatorWidth) solid var(--dx-gridFocusIndicatorColor);
58
58
  }
59
59
  }
60
60
 
@@ -98,7 +98,7 @@
98
98
  white-space: nowrap;
99
99
  block-size: 100%;
100
100
  position: relative;
101
- border: 1px solid transparent;
101
+ border: var(--dx-gridFocusIndicatorWidth) solid transparent;
102
102
  border-radius: 2px;
103
103
 
104
104
  &:has(.dx-tag), &:has(dx-tag-picker-item) {
@@ -175,13 +175,13 @@
175
175
  }
176
176
 
177
177
  &:not([aria-readonly='true']) > .dx-grid__cell__content {
178
- border-color: var(--dx-accentSurface);
178
+ border-color: var(--dx-gridFocusIndicatorColor);
179
179
  }
180
180
  }
181
181
  }
182
182
 
183
183
  &:focus-visible > .dx-grid__cell__content {
184
- border-color: var(--dx-accentSurface);
184
+ border-color: var(--dx-gridFocusIndicatorColor);
185
185
  }
186
186
  }
187
187
  }
@@ -193,7 +193,7 @@
193
193
  overflow-wrap: break-word;
194
194
 
195
195
  background: var(--dx-grid-base, var(--dx-baseSurface));
196
- border: 1px solid var(--dx-accentSurface);
196
+ border: var(--dx-gridFocusIndicatorWidth) solid var(--dx-gridFocusIndicatorColor);
197
197
  border-radius: 2px;
198
198
 
199
199
  --dx-grid-cell-editor-max-block-size: min(12em, 50vh);
@@ -218,7 +218,7 @@
218
218
  [role='columnheader'],
219
219
  [role='rowheader'] {
220
220
  &[data-dx-active]:not([aria-readonly='true']) > .dx-grid__cell__content {
221
- border-color: var(--dx-accentSurface);
221
+ border-color: var(--dx-gridFocusIndicatorColor);
222
222
  }
223
223
  }
224
224
  }
package/src/dx-grid.ts CHANGED
@@ -23,11 +23,13 @@ import {
23
23
  type DxGridCells,
24
24
  DxGridCellsSelect,
25
25
  type DxGridFixedPlane,
26
+ type DxGridFocusIndicatorVariant,
26
27
  type DxGridFrozenAxes,
27
28
  type DxGridFrozenColsPlane,
28
29
  type DxGridFrozenPlane,
29
30
  type DxGridFrozenRowsPlane,
30
31
  type DxGridMode,
32
+ type DxGridOverscroll,
31
33
  type DxGridPlane,
32
34
  type DxGridPlaneCellIndex,
33
35
  type DxGridPlaneCells,
@@ -64,12 +66,12 @@ import {
64
66
  export class DxGrid extends LitElement {
65
67
  constructor() {
66
68
  super();
67
- // Wheel, top-level and element-level
69
+ // Wheel, top-level and element-level.
68
70
  document.defaultView?.addEventListener('wheel', this.handleTopLevelWheel, { passive: false });
69
71
  this.addEventListener('wheel', this.handleWheel);
70
- // Custom event(s)
72
+ // Custom event(s).
71
73
  this.addEventListener('dx-axis-resize-internal', this.handleAxisResizeInternal as EventListener);
72
- // Standard events
74
+ // Standard events.
73
75
  this.addEventListener('pointerdown', this.handlePointerDown);
74
76
  this.addEventListener('pointermove', this.handlePointerMove);
75
77
  this.addEventListener('pointerup', this.handlePointerUp);
@@ -114,11 +116,14 @@ export class DxGrid extends LitElement {
114
116
  frozen: DxGridFrozenAxes = {};
115
117
 
116
118
  @property({ type: String })
117
- overscroll: 'inline' | 'block' | 'trap' | undefined = undefined;
119
+ overscroll: DxGridOverscroll = undefined;
118
120
 
119
121
  @property({ type: String })
120
122
  activeRefs = '';
121
123
 
124
+ @property({ type: String })
125
+ focusIndicatorVariant: DxGridFocusIndicatorVariant = 'sheet';
126
+
122
127
  /**
123
128
  * When this function is defined, it is used first to try to get a value for a cell,
124
129
  * and otherwise will fall back to `cells`.
@@ -194,6 +199,7 @@ export class DxGrid extends LitElement {
194
199
  //
195
200
  // `template` is the rendered value of `grid-{axis}-template`.
196
201
  //
202
+
197
203
  @state()
198
204
  private templateGridColumns = '0';
199
205
 
@@ -317,7 +323,7 @@ export class DxGrid extends LitElement {
317
323
  this.dispatchSelectionChange();
318
324
  }
319
325
  if (this.mode === 'edit-select') {
320
- // Prevent focus moving when editing while selection is possible
326
+ // Prevent focus moving when editing while selection is possible.
321
327
  event.preventDefault();
322
328
  } else if (this.focusActive && isSameCell(this.focusedCell, cellCoords)) {
323
329
  this.dispatchEditRequest();
@@ -425,15 +431,13 @@ export class DxGrid extends LitElement {
425
431
  }
426
432
 
427
433
  private moveFocusIntoPlane(plane: DxGridPlane): void {
428
- if (this.focusedCell.plane !== plane) {
429
- const colPlane = resolveColPlane(plane);
430
- const rowPlane = resolveRowPlane(plane);
431
- this.focusedCell = {
432
- plane,
433
- col: colPlane === 'grid' ? this.visColMin : 0,
434
- row: rowPlane === 'grid' ? this.visRowMin : 0,
435
- };
436
- }
434
+ const colPlane = resolveColPlane(plane);
435
+ const rowPlane = resolveRowPlane(plane);
436
+ this.focusedCell = {
437
+ plane,
438
+ col: colPlane === 'grid' ? this.visColMin : 0,
439
+ row: rowPlane === 'grid' ? this.visRowMin : 0,
440
+ };
437
441
  this.focusedCellElement()?.focus({ preventScroll: true });
438
442
  }
439
443
 
@@ -590,7 +594,7 @@ export class DxGrid extends LitElement {
590
594
  }
591
595
 
592
596
  //
593
- // Resize & reposition handlers, observer, ref
597
+ // Resize & reposition handlers, observer, ref.
594
598
  //
595
599
 
596
600
  @state()
@@ -690,7 +694,7 @@ export class DxGrid extends LitElement {
690
694
  };
691
695
 
692
696
  private updateVisInline(): void {
693
- // todo: avoid starting from zero
697
+ // todo: avoid starting from zero.
694
698
  let axisCursor = 0;
695
699
  let pxCursor = this.colSize(axisCursor, 'grid');
696
700
 
@@ -748,7 +752,7 @@ export class DxGrid extends LitElement {
748
752
  }
749
753
 
750
754
  private updateVisBlock(): void {
751
- // todo: avoid starting from zero
755
+ // todo: avoid starting from zero.
752
756
  let axisCursor = 0;
753
757
  let pxCursor = this.rowSize(axisCursor, 'grid');
754
758
 
@@ -1024,7 +1028,7 @@ export class DxGrid extends LitElement {
1024
1028
  }
1025
1029
 
1026
1030
  /**
1027
- * Updates `pos` so that a cell in focus is fully within the viewport
1031
+ * Updates `pos` so that a cell in focus is fully within the viewport.
1028
1032
  */
1029
1033
  snapPosToFocusedCell(): void {
1030
1034
  const outOfVis = this.focusedCellOutOfVis();
@@ -1152,7 +1156,7 @@ export class DxGrid extends LitElement {
1152
1156
  }
1153
1157
 
1154
1158
  //
1155
- // Render and other lifecycle methods
1159
+ // Render and other lifecycle methods.
1156
1160
  //
1157
1161
 
1158
1162
  // TODO(thure): This is for rendering presentational objects superimposed onto the canonical grid (e.g. DnD drop line for #8108).
@@ -1507,6 +1511,7 @@ export class DxGrid extends LitElement {
1507
1511
  })}
1508
1512
  data-grid=${this.gridId}
1509
1513
  data-grid-mode=${this.mode}
1514
+ data-grid-focus-indicator-variant=${this.focusIndicatorVariant}
1510
1515
  ?data-grid-select=${selection.visible}
1511
1516
  ${ref(this.gridRef)}
1512
1517
  >
package/src/types.ts CHANGED
@@ -128,6 +128,10 @@ export type DxGridSelectionProps = {
128
128
  visible?: boolean;
129
129
  };
130
130
 
131
+ export type DxGridFocusIndicatorVariant = 'sheet' | 'stack';
132
+
133
+ export type DxGridOverscroll = 'inline' | 'block' | 'trap' | undefined;
134
+
131
135
  export class DxAxisResize extends Event {
132
136
  public readonly axis: DxGridAxis;
133
137
  public readonly plane: 'grid' | DxGridFrozenPlane;