@dxos/lit-grid 0.8.4-main.a4bbb77 → 0.8.4-main.abd8ff62ef

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,12 +1,19 @@
1
1
  {
2
2
  "name": "@dxos/lit-grid",
3
- "version": "0.8.4-main.a4bbb77",
3
+ "version": "0.8.4-main.abd8ff62ef",
4
4
  "description": "A grid Web Component using Lit",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/dxos/dxos"
10
+ },
7
11
  "license": "MIT",
8
12
  "author": "DXOS.org",
9
- "sideEffects": true,
13
+ "sideEffects": [
14
+ "*.css",
15
+ "*.pcss"
16
+ ],
10
17
  "type": "module",
11
18
  "exports": {
12
19
  ".": {
@@ -23,23 +30,16 @@
23
30
  },
24
31
  "main": "dist/src/index.js",
25
32
  "types": "dist/src/index.d.ts",
26
- "typesVersions": {
27
- "*": {
28
- "testing": [
29
- "dist/src/testing/index.d.ts"
30
- ]
31
- }
32
- },
33
33
  "files": [
34
34
  "src",
35
35
  "dist"
36
36
  ],
37
37
  "dependencies": {
38
- "@atlaskit/pragmatic-drag-and-drop": "^1.4.0",
38
+ "@atlaskit/pragmatic-drag-and-drop": "1.7.7",
39
39
  "lit": "^3.3.1"
40
40
  },
41
41
  "devDependencies": {
42
- "@dxos/random": "0.8.4-main.a4bbb77",
43
- "@dxos/test-utils": "0.8.4-main.a4bbb77"
42
+ "@dxos/random": "0.8.4-main.abd8ff62ef",
43
+ "@dxos/test-utils": "0.8.4-main.abd8ff62ef"
44
44
  }
45
45
  }
@@ -7,24 +7,24 @@ dx-grid-axis-resize-handle {
7
7
  background: transparent;
8
8
  z-index: 2;
9
9
  &:hover {
10
- background: var(--dx-grid-resizeHandleHover, var(--dx-hoverSurface));
10
+ background: var(--color-hover-surface);
11
11
  }
12
12
  &[data-dx-grid-axis='col'] {
13
13
  inset-block: 0;
14
14
  inset-inline-end: 0;
15
- inline-size: .5rem;
15
+ inline-size: 0.5rem;
16
16
  cursor: col-resize;
17
17
  }
18
18
  &[data-dx-grid-axis='row'] {
19
19
  inset-inline: 0;
20
20
  inset-block-end: 0;
21
- block-size: .5rem;
21
+ block-size: 0.5rem;
22
22
  cursor: row-resize;
23
23
  }
24
24
  &:focus {
25
25
  outline: none;
26
26
  }
27
27
  &:focus-visible {
28
- background: var(--dx-grid-resizeHandleFocus, var(--dx-accentSurface));
28
+ background: var(--color-accent-surface);
29
29
  }
30
30
  }
@@ -1,8 +1,10 @@
1
+ @reference "../../ui-theme/src/main.css";
2
+
1
3
  dx-grid-multiselect-cell {
2
4
  display: contents;
3
5
  }
4
6
 
5
- .dx-grid__cell__multiselect{
7
+ .dx-grid__cell__multiselect {
6
8
  display: flex;
7
9
  flex-flow: row nowrap;
8
10
  gap: 2px;
@@ -14,19 +16,19 @@ dx-grid-multiselect-cell {
14
16
  white-space: nowrap;
15
17
  text-overflow: ellipsis;
16
18
  &.dx-grid__cell__multiselect__value {
17
- @apply bs-full border border-separator text-xs font-semibold pli-2 plb-0.5 rounded cursor-default text-neutral-800 dark:text-neutral-150
19
+ @apply h-full border border-separator text-xs font-semibold px-2 py-0.5 rounded cursor-default text-neutral-800 dark:text-neutral-200;
18
20
  }
19
21
  &.dx-grid__cell__multiselect__placeholder {
20
22
  @apply text-description;
21
23
  }
22
24
  }
23
- & > .dx-grid__cell__multiselect__separator{
25
+ & > .dx-grid__cell__multiselect__separator {
24
26
  flex: 1 0 0;
25
27
  }
26
28
  & > svg {
27
29
  flex: 0 0 auto;
28
- margin-block: .25em;
30
+ margin-block: 0.25em;
29
31
  inline-size: 1em;
30
32
  block-size: 1em;
31
33
  }
32
- }
34
+ }
@@ -3,15 +3,13 @@
3
3
  //
4
4
 
5
5
  import '@dxos-theme';
6
-
7
6
  import './dx-grid.ts';
8
7
  import './dx-grid.pcss';
9
-
10
8
  import './dx-grid-multiselect-cell.ts';
11
9
 
12
10
  import { html, nothing } from 'lit';
13
11
 
14
- import { faker } from '@dxos/random';
12
+ import { random } from '@dxos/random';
15
13
 
16
14
  import { defaultRowSize } from './defs.js';
17
15
  import { type DxGridFrozenPlane, type DxGridPlaneCells, type DxGridProps } from './types';
@@ -39,7 +37,7 @@ const initialLabels = {
39
37
  '0,0': { value: '', resizeHandle: 'col' },
40
38
  },
41
39
  frozenColsStart: [...Array(64)].reduce((acc, _, i) => {
42
- acc[`0,${i}`] = { value: rowToA1Notation(i), className: 'text-end pie-1', resizeHandle: 'row' };
40
+ acc[`0,${i}`] = { value: rowToA1Notation(i), className: 'text-end pe-1', resizeHandle: 'row' };
43
41
  return acc;
44
42
  }, {}),
45
43
  frozenRowsStart: [...Array(12)].reduce((acc, _, i) => {
@@ -53,7 +51,7 @@ Basic.args = {
53
51
  grid: {
54
52
  '1,1': {
55
53
  // end: '8,1',
56
- value: faker.lorem.paragraphs(5),
54
+ value: random.lorem.paragraphs(5),
57
55
  },
58
56
  '2,2': {
59
57
  value: '',
package/src/dx-grid.pcss CHANGED
@@ -4,10 +4,14 @@
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) - var(--dx-gridFocusIndicatorWidth));
7
+ --dx-grid-cell-content-padding-block: calc(
8
+ var(--dx-grid-cell-padding-block) - var(--dx-grid-focus-indicator-width)
9
+ );
8
10
  --dx-grid-cell-editor-padding-block: var(--dx-grid-cell-content-padding-block);
9
11
  --dx-grid-cell-padding-inline: 0.25rem;
10
- --dx-grid-cell-content-padding-inline: calc(var(--dx-grid-cell-padding-inline) - var(--dx-gridFocusIndicatorWidth));
12
+ --dx-grid-cell-content-padding-inline: calc(
13
+ var(--dx-grid-cell-padding-inline) - var(--dx-grid-focus-indicator-width)
14
+ );
11
15
  --dx-grid-cell-editor-padding-inline: var(--dx-grid-cell-content-padding-inline);
12
16
  }
13
17
  }
@@ -33,8 +37,6 @@
33
37
 
34
38
  touch-action: none;
35
39
  user-select: none;
36
-
37
- background: var(--dx-grid-lines, var(--dx-gridLine));
38
40
  }
39
41
 
40
42
  .dx-grid__plane--frozen-row,
@@ -54,7 +56,7 @@
54
56
  position: absolute;
55
57
  inset: 0;
56
58
  pointer-events: none;
57
- border: var(--dx-gridFocusIndicatorWidth) solid var(--dx-gridFocusIndicatorColor);
59
+ border: var(--dx-grid-focus-indicator-width) solid var(--color-grid-focus-indicator);
58
60
  }
59
61
  }
60
62
 
@@ -67,15 +69,18 @@
67
69
  }
68
70
 
69
71
  .dx-grid {
70
- --dx-grid-cell-surface: var(--dx-grid-base, var(--dx-baseSurface));
72
+ --grid-cell-surface: var(--color-grid-surface);
71
73
 
72
74
  [role='gridcell'],
73
75
  [role='columnheader'],
74
76
  [role='rowheader'] {
75
- background: var(--dx-grid-cell-surface);
77
+ background: var(--grid-cell-surface);
76
78
  cursor: pointer;
77
79
  position: relative;
78
80
 
81
+ border-right: 1px solid var(--color-grid-line);
82
+ border-bottom: 1px solid var(--color-grid-line);
83
+
79
84
  &[aria-readonly='true'] {
80
85
  cursor: default;
81
86
  }
@@ -98,10 +103,11 @@
98
103
  white-space: nowrap;
99
104
  block-size: 100%;
100
105
  position: relative;
101
- border: var(--dx-gridFocusIndicatorWidth) solid transparent;
106
+ border: var(--dx-grid-focus-indicator-width) solid transparent;
102
107
  border-radius: 2px;
103
108
 
104
- &:has(.dx-tag), &:has(dx-tag-picker-item) {
109
+ &:has(.dx-tag),
110
+ &:has(dx-tag-picker-item) {
105
111
  text-overflow: clip;
106
112
  line-height: 0;
107
113
  --dx-grid-cell-content-padding-inline: 1px;
@@ -110,7 +116,7 @@
110
116
  }
111
117
 
112
118
  &.dx-grid__cell--commented {
113
- background: var(--dx-grid-commented, var(--dx-gridCommented));
119
+ background: var(--color-grid-comment);
114
120
  }
115
121
  }
116
122
 
@@ -119,10 +125,11 @@
119
125
  [role='columnheader'],
120
126
  [role='rowheader'] {
121
127
  &[aria-selected] {
122
- --dx-grid-cell-surface: var(--dx-gridSelectionOverlay);
128
+ --grid-cell-surface: var(--color-grid-selection-overlay);
123
129
 
124
130
  &:focus:not([aria-readonly='true']),
125
- &:focus-visible, &:focus-within {
131
+ &:focus-visible,
132
+ &:focus-within {
126
133
  & > .dx-grid__cell__content {
127
134
  background: transparent;
128
135
  }
@@ -140,7 +147,7 @@
140
147
  }
141
148
 
142
149
  &:has(.dx-grid__row--cta__cell:hover) .dx-grid__row--cta__cell {
143
- background: var(--dx-hoverOverlay);
150
+ background: var(--color-grid-hover-overlay);
144
151
  }
145
152
  }
146
153
 
@@ -149,7 +156,7 @@
149
156
  [role='gridcell'],
150
157
  [role='columnheader'],
151
158
  [role='rowheader'] {
152
- &:not([data-focus-unfurl="false"]):not(.dx-grid__cell--no-focus-unfurl) {
159
+ &:not([data-focus-unfurl='false']):not(.dx-grid__cell--no-focus-unfurl) {
153
160
  &:focus,
154
161
  &:focus-within {
155
162
  & > .dx-grid__cell__content {
@@ -171,17 +178,17 @@
171
178
 
172
179
  z-index: 1;
173
180
 
174
- background: var(--dx-grid-cell-surface);
181
+ background: var(--grid-cell-surface);
175
182
  }
176
183
 
177
184
  &:not([aria-readonly='true']) > .dx-grid__cell__content {
178
- border-color: var(--dx-gridFocusIndicatorColor);
185
+ border-color: var(--color-grid-focus-indicator);
179
186
  }
180
187
  }
181
188
  }
182
189
 
183
190
  &:focus-visible > .dx-grid__cell__content {
184
- border-color: var(--dx-gridFocusIndicatorColor);
191
+ border-color: var(--color-grid-focus-indicator);
185
192
  }
186
193
  }
187
194
  }
@@ -192,8 +199,8 @@
192
199
  hyphens: auto;
193
200
  overflow-wrap: break-word;
194
201
 
195
- background: var(--dx-grid-base, var(--dx-baseSurface));
196
- border: var(--dx-gridFocusIndicatorWidth) solid var(--dx-gridFocusIndicatorColor);
202
+ background: var(--dx-grid-base, var(--color-base-surface));
203
+ border: var(--dx-grid-focus-indicator-width) solid var(--color-grid-focus-indicator);
197
204
  border-radius: 2px;
198
205
 
199
206
  --dx-grid-cell-editor-max-block-size: min(12em, 50vh);
@@ -204,7 +211,8 @@
204
211
  inline-size: min-content;
205
212
  max-inline-size: var(--dx-grid-cell-editor-max-inline-size);
206
213
 
207
- &:has(.dx-tag), &:has(dx-tag-picker-item) {
214
+ &:has(.dx-tag),
215
+ &:has(dx-tag-picker-item) {
208
216
  text-overflow: clip;
209
217
  line-height: 0;
210
218
  --dx-grid-cell-editor-padding-inline: 1px;
@@ -218,7 +226,7 @@
218
226
  [role='columnheader'],
219
227
  [role='rowheader'] {
220
228
  &[data-dx-active]:not([aria-readonly='true']) > .dx-grid__cell__content {
221
- border-color: var(--dx-gridFocusIndicatorColor);
229
+ border-color: var(--color-grid-focus-indicator);
222
230
  }
223
231
  }
224
232
  }
@@ -246,7 +254,7 @@
246
254
  inline-size: 0;
247
255
  block-size: 0;
248
256
  border-inline-start: 0.5em solid transparent;
249
- border-block-start: 0.5em solid var(--dx-warningText);
257
+ border-block-start: 0.5em solid var(--color-warning-text);
250
258
  z-index: 1;
251
259
  }
252
260
  }
package/src/dx-grid.ts CHANGED
@@ -2,6 +2,8 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
+ import './dx-grid-axis-resize-handle';
6
+
5
7
  import { LitElement, html, nothing } from 'lit';
6
8
  import { customElement, property, state } from 'lit/decorators.js';
7
9
  import { type Ref, createRef, ref } from 'lit/directives/ref.js';
@@ -9,7 +11,6 @@ import { styleMap } from 'lit/directives/style-map.js';
9
11
  import { html as staticHtml, unsafeStatic } from 'lit/static-html.js';
10
12
 
11
13
  import { defaultColSize, defaultRowSize, focusUnfurlDefault } from './defs';
12
- import './dx-grid-axis-resize-handle';
13
14
  import {
14
15
  DxAxisResize,
15
16
  type DxAxisResizeInternal,
@@ -66,12 +67,12 @@ import {
66
67
  export class DxGrid extends LitElement {
67
68
  constructor() {
68
69
  super();
69
- // Wheel, top-level and element-level
70
+ // Wheel, top-level and element-level.
70
71
  document.defaultView?.addEventListener('wheel', this.handleTopLevelWheel, { passive: false });
71
72
  this.addEventListener('wheel', this.handleWheel);
72
- // Custom event(s)
73
+ // Custom event(s).
73
74
  this.addEventListener('dx-axis-resize-internal', this.handleAxisResizeInternal as EventListener);
74
- // Standard events
75
+ // Standard events.
75
76
  this.addEventListener('pointerdown', this.handlePointerDown);
76
77
  this.addEventListener('pointermove', this.handlePointerMove);
77
78
  this.addEventListener('pointerup', this.handlePointerUp);
@@ -199,6 +200,7 @@ export class DxGrid extends LitElement {
199
200
  //
200
201
  // `template` is the rendered value of `grid-{axis}-template`.
201
202
  //
203
+
202
204
  @state()
203
205
  private templateGridColumns = '0';
204
206
 
@@ -322,7 +324,7 @@ export class DxGrid extends LitElement {
322
324
  this.dispatchSelectionChange();
323
325
  }
324
326
  if (this.mode === 'edit-select') {
325
- // Prevent focus moving when editing while selection is possible
327
+ // Prevent focus moving when editing while selection is possible.
326
328
  event.preventDefault();
327
329
  } else if (this.focusActive && isSameCell(this.focusedCell, cellCoords)) {
328
330
  this.dispatchEditRequest();
@@ -593,7 +595,7 @@ export class DxGrid extends LitElement {
593
595
  }
594
596
 
595
597
  //
596
- // Resize & reposition handlers, observer, ref
598
+ // Resize & reposition handlers, observer, ref.
597
599
  //
598
600
 
599
601
  @state()
@@ -693,7 +695,7 @@ export class DxGrid extends LitElement {
693
695
  };
694
696
 
695
697
  private updateVisInline(): void {
696
- // todo: avoid starting from zero
698
+ // todo: avoid starting from zero.
697
699
  let axisCursor = 0;
698
700
  let pxCursor = this.colSize(axisCursor, 'grid');
699
701
 
@@ -751,7 +753,7 @@ export class DxGrid extends LitElement {
751
753
  }
752
754
 
753
755
  private updateVisBlock(): void {
754
- // todo: avoid starting from zero
756
+ // todo: avoid starting from zero.
755
757
  let axisCursor = 0;
756
758
  let pxCursor = this.rowSize(axisCursor, 'grid');
757
759
 
@@ -1027,7 +1029,7 @@ export class DxGrid extends LitElement {
1027
1029
  }
1028
1030
 
1029
1031
  /**
1030
- * Updates `pos` so that a cell in focus is fully within the viewport
1032
+ * Updates `pos` so that a cell in focus is fully within the viewport.
1031
1033
  */
1032
1034
  snapPosToFocusedCell(): void {
1033
1035
  const outOfVis = this.focusedCellOutOfVis();
@@ -1155,7 +1157,7 @@ export class DxGrid extends LitElement {
1155
1157
  }
1156
1158
 
1157
1159
  //
1158
- // Render and other lifecycle methods
1160
+ // Render and other lifecycle methods.
1159
1161
  //
1160
1162
 
1161
1163
  // TODO(thure): This is for rendering presentational objects superimposed onto the canonical grid (e.g. DnD drop line for #8108).
@@ -1446,6 +1448,7 @@ export class DxGrid extends LitElement {
1446
1448
  data-dx-grid-action="cell"
1447
1449
  aria-colindex=${col}
1448
1450
  aria-rowindex=${row}
1451
+ data-testid=${`${plane}.${col}.${row}`}
1449
1452
  style="grid-column:${visCol + 1};grid-row:${visRow + 1}"
1450
1453
  >
1451
1454
  <div role="none" class="dx-grid__cell__content">${cell?.value}${accessory}</div>
@@ -1474,9 +1477,7 @@ export class DxGrid extends LitElement {
1474
1477
  .split(' ')
1475
1478
  .filter((value) => value)
1476
1479
  .map(
1477
- // TODO(burdon): Consistent camelCase?
1478
- (activeRef) =>
1479
- `[data-refs~="${activeRef}"] { background: var(--dx-grid-commented-active, var(--dx-gridCommentedActive)) !important; }`,
1480
+ (activeRef) => `[data-refs~="${activeRef}"] { background: var(--color-grid-comment-active) !important; }`,
1480
1481
  )
1481
1482
  .join('\n')}
1482
1483
  </style>
@@ -10,7 +10,7 @@ export default defineConfig({
10
10
  ...e2ePreset(import.meta.dirname),
11
11
  // TODO(wittjosiah): Avoid hard-coding ports.
12
12
  webServer: {
13
- command: 'moon run lit-storybook:serve-e2e -- --port=9002',
13
+ command: 'pnpm storybook dev --ci --quiet --port=9002 --config-dir=.storybook',
14
14
  port: 9002,
15
15
  reuseExistingServer: false,
16
16
  },