@1771technologies/lytenyte-pro 1.0.1 → 1.0.3

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 (62) hide show
  1. package/README.md +1 -6
  2. package/dist/+types.d.ts +24 -4
  3. package/dist/cell-selection/cell-selection-driver.js +2 -1
  4. package/dist/cell-selection/cell-style-row.d.ts +2 -2
  5. package/dist/cell-selection/cell-style-row.js +1 -1
  6. package/dist/cell-selection/get-root-cell.js +3 -83
  7. package/dist/cell-selection/index.d.ts +0 -1
  8. package/dist/cell-selection/index.js +0 -1
  9. package/dist/cell-selection/split-cell-selection-rect.d.ts +8 -1
  10. package/dist/cell-selection/split-cell-selection-rect.js +13 -4
  11. package/dist/cell-selection/split-on-pivot.d.ts +3 -0
  12. package/dist/cell-selection/split-on-pivot.js +50 -0
  13. package/dist/cells/cell-editor.js +1 -1
  14. package/dist/cells/cell-spacer.d.ts +3 -0
  15. package/dist/cells/cell-spacer.js +37 -0
  16. package/dist/cells/cell.d.ts +1 -3
  17. package/dist/cells/cell.js +11 -9
  18. package/dist/column-manager/branch.js +1 -1
  19. package/dist/column-manager/leaf.js +1 -1
  20. package/dist/column-manager/move-handle.d.ts +0 -7
  21. package/dist/column-manager/move-handle.js +23 -6
  22. package/dist/filter-tree/leaf.js +3 -1
  23. package/dist/grid-box/+types.d.ts +2 -2
  24. package/dist/grid-box/item.js +3 -3
  25. package/dist/grid-box/use-aggregation-box-items.js +1 -2
  26. package/dist/grid-box/use-column-box-items.d.ts +2 -3
  27. package/dist/grid-box/use-column-box-items.js +3 -3
  28. package/dist/grid-box/use-row-group-box-items.d.ts +3 -3
  29. package/dist/grid-box/use-row-group-box-items.js +41 -5
  30. package/dist/grid.d.ts +1 -1
  31. package/dist/header/resize-handler.js +21 -15
  32. package/dist/license.js +1 -1
  33. package/dist/row-data-source-client/use-client-data-source-paginated.js +154 -164
  34. package/dist/row-data-source-client/use-client-data-source.js +144 -177
  35. package/dist/row-data-source-client/use-client-tree-data-source.js +119 -152
  36. package/dist/row-data-source-server/use-server-data-source.js +102 -120
  37. package/dist/rows/row/row.d.ts +1 -1
  38. package/dist/rows/row/row.js +11 -4
  39. package/dist/rows/rows-sections.js +1 -1
  40. package/dist/sort-manager/+types.d.ts +2 -0
  41. package/dist/sort-manager/hooks/use-sort-row-item.js +6 -6
  42. package/dist/sort-manager/utils/sort-item-to-sort-model.js +5 -0
  43. package/dist/sort-manager/utils/sort-model-to-sort-items.js +2 -1
  44. package/dist/state/+types.d.ts +8 -10
  45. package/dist/state/api/cell-root.d.ts +5 -0
  46. package/dist/state/api/cell-root.js +64 -0
  47. package/dist/state/api/edit-begin.js +5 -9
  48. package/dist/state/api/edit-is-cell-active.d.ts +1 -1
  49. package/dist/state/api/edit-is-cell-active.js +2 -7
  50. package/dist/state/api/focus-cell.js +2 -2
  51. package/dist/state/helpers/column-layout.d.ts +3 -3
  52. package/dist/state/helpers/column-layout.js +9 -15
  53. package/dist/state/helpers/get-full-width-callback.d.ts +1 -1
  54. package/dist/state/helpers/get-full-width-callback.js +2 -0
  55. package/dist/state/helpers/get-span-callback.d.ts +1 -1
  56. package/dist/state/helpers/get-span-callback.js +2 -0
  57. package/dist/state/helpers/row-layout/row-layout.d.ts +5 -4
  58. package/dist/state/helpers/row-layout/row-layout.js +112 -346
  59. package/dist/state/use-lytenyte.js +398 -334
  60. package/dist/viewport/viewport.js +3 -2
  61. package/main.css +27 -3
  62. package/package.json +7 -7
@@ -1,124 +1,171 @@
1
- import { isFullWidthMap } from "@1771technologies/lytenyte-shared";
2
- import { getFocusCriteria } from "./get-focus-criteria";
1
+ import { CONTAINS_DEAD_CELLS, FULL_WIDTH, } from "@1771technologies/lytenyte-shared";
3
2
  /**
4
3
  * This is quite a complex function so read each part carefully.
5
4
  */
6
- export function makeRowLayout({ layout: n, layoutMap, rds, columns, focus, }) {
5
+ export function makeRowLayout({ view: n, viewCache, layout, rds, columns }) {
7
6
  // Initializes the layout sections for the view.
8
7
  const top = [];
9
8
  const center = [];
10
9
  const bottom = [];
11
- // Compute the focus setup for the view. The cell that is currently focused must always be mounted.
12
- // However things get tricky since the cell may be scrolled out of view. Additionally it may be in any
13
- // quadrant of the grid. This function returns the specification of where exactly the focus cell is.
14
- const f = getFocusCriteria(n, focus);
10
+ handleViewLayout({
11
+ columns,
12
+ container: top,
13
+ layout,
14
+ rowStart: n.rowTopStart,
15
+ rowEnd: n.rowTopEnd,
16
+ rowForIndex: rds.rowForIndex,
17
+ rowPin: "top",
18
+ spanLayout: n,
19
+ viewCache,
20
+ });
21
+ handleViewLayout({
22
+ columns,
23
+ container: center,
24
+ layout,
25
+ rowStart: n.rowCenterStart,
26
+ rowEnd: n.rowCenterEnd,
27
+ rowForIndex: rds.rowForIndex,
28
+ rowPin: null,
29
+ spanLayout: n,
30
+ viewCache,
31
+ });
32
+ handleViewLayout({
33
+ columns,
34
+ container: bottom,
35
+ layout,
36
+ rowStart: n.rowBotStart,
37
+ rowEnd: n.rowBotEnd,
38
+ rowForIndex: rds.rowForIndex,
39
+ rowPin: "bottom",
40
+ spanLayout: n,
41
+ viewCache,
42
+ });
43
+ /**
44
+ * BOTTOM ROW LAYOUT END
45
+ */
46
+ return {
47
+ top: top.map((t) => partition(n, t)),
48
+ center: center.map((t) => partition(n, t)),
49
+ bottom: bottom.map((t) => partition(n, t)),
50
+ };
51
+ }
52
+ const partition = (n, row) => {
53
+ if (row.kind === "full-width")
54
+ return row;
55
+ let found = false;
56
+ const cells = [
57
+ ...row.cells.slice(0, n.colStartEnd),
58
+ ...row.cells.slice(n.colCenterStart, n.colCenterEnd).map((c) => {
59
+ if (!found && c.isDeadCol && !c.isDeadRow)
60
+ return { ...c, isDeadCol: false, isDeadRow: true };
61
+ found = true;
62
+ return c;
63
+ }),
64
+ ...row.cells.slice(n.colEndStart, n.colEndEnd),
65
+ ];
66
+ return {
67
+ ...row,
68
+ cells,
69
+ };
70
+ };
71
+ function handleViewLayout({ columns, spanLayout: n, rowStart, rowEnd, rowPin, layout, viewCache, container, rowForIndex, }) {
15
72
  /**
16
73
  * TOP ROW LAYOUT START
17
74
  */
18
- for (let r = n.rowTopStart; r < n.rowTopEnd; r++) {
19
- const row = layoutMap.get(r);
20
- if (!row) {
75
+ for (let r = rowStart; r < rowEnd; r++) {
76
+ const status = layout.special[r];
77
+ const computed = layout.computed[r];
78
+ if (!computed)
79
+ continue;
80
+ if (viewCache.has(r)) {
81
+ container.push(viewCache.get(r));
21
82
  continue;
22
83
  }
23
- const node = rds.rowForIndex(r);
24
- if (!node) {
25
- console.error(`Row data source did not return a row for a valid row position at index: ${r}`);
84
+ const node = rowForIndex(r);
85
+ if (!node)
26
86
  break;
27
- }
28
87
  const rowLastPinTop = n.rowTopEnd - 1 === r ? true : undefined;
29
- if (isFullWidthMap(row)) {
30
- top.push({
88
+ if (status === FULL_WIDTH) {
89
+ const row = {
31
90
  id: node.get()?.id ?? `${r}`,
32
91
  rowIndex: r,
33
92
  kind: "full-width",
34
- rowPin: "top",
93
+ rowPin,
35
94
  row: node,
36
95
  rowLastPinTop,
37
- });
96
+ };
97
+ viewCache.set(r, row);
98
+ container.push(row);
38
99
  continue;
39
100
  }
101
+ const cellSpec = layout.lookup.get(r);
40
102
  const cellLayout = [];
103
+ const hasDead = status === CONTAINS_DEAD_CELLS;
41
104
  for (let c = n.colStartStart; c < n.colStartEnd; c++) {
42
- const v = row.get(c);
43
- if (!v || v.length === 3)
44
- continue;
105
+ const ci = c * 4;
106
+ const isDeadRow = hasDead && cellSpec?.[ci] === -1;
107
+ const isDeadCol = hasDead && cellSpec?.[ci] === 0;
108
+ const colSpan = cellSpec?.[c * 4 + 1] || 1;
45
109
  cellLayout.push({
46
110
  id: columns[c].id,
47
111
  kind: "cell",
48
112
  colIndex: c,
49
113
  rowIndex: r,
50
- rowSpan: v[0],
51
- colSpan: v[1],
52
- rowPin: "top",
114
+ rowSpan: cellSpec?.[c * 4] || 1,
115
+ colSpan,
116
+ rowPin,
53
117
  colPin: "start",
54
- colLastStartPin: c + v[1] === n.colStartEnd ? true : undefined,
118
+ isDeadCol,
119
+ isDeadRow,
120
+ colLastStartPin: c + colSpan === n.colStartEnd ? true : undefined,
55
121
  rowLastPinTop,
56
122
  row: node,
57
123
  column: columns[c],
58
124
  });
59
125
  }
60
- for (let c = n.colCenterStart; c < n.colCenterEnd; c++) {
61
- const v = row.get(c);
62
- if (!v || v.length === 3)
63
- continue;
126
+ for (let c = n.colStartEnd; c < n.colCenterLast; c++) {
127
+ const ci = c * 4;
128
+ const isDeadRow = hasDead && cellSpec?.[ci] === -1;
129
+ const isDeadCol = hasDead && cellSpec?.[ci] === 0;
130
+ const colSpan = cellSpec?.[c * 4 + 1] || 1;
64
131
  cellLayout.push({
65
132
  id: columns[c].id,
66
133
  kind: "cell",
67
134
  colIndex: c,
68
135
  rowIndex: r,
69
- rowSpan: v[0],
70
- colSpan: v[1],
71
- rowPin: "top",
136
+ rowSpan: cellSpec?.[c * 4] || 1,
137
+ colSpan,
138
+ rowPin,
72
139
  colPin: null,
140
+ isDeadCol,
141
+ isDeadRow,
73
142
  rowLastPinTop,
74
143
  row: node,
75
144
  column: columns[c],
76
145
  });
77
146
  }
78
- // For the top section, only the center cells may be out of view. The focused cell may be before or after the
79
- // center cells (if they are in the center cells we will be rendering them anyway).
80
- if (f.isTop && (f.isColCenterBefore || f.isColCenterAfter)) {
81
- const v = row.get(f.colIndex);
82
- if (v && v.length !== 3) {
83
- const cell = {
84
- id: columns[f.colIndex].id,
85
- kind: "cell",
86
- colIndex: f.colIndex,
87
- rowIndex: f.rowIndex,
88
- rowSpan: v[0],
89
- colSpan: v[1],
90
- rowPin: "top",
91
- colPin: null,
92
- rowLastPinTop,
93
- row: node,
94
- column: columns[f.colIndex],
95
- };
96
- if (f.isColCenterBefore)
97
- cellLayout.unshift(cell);
98
- else
99
- cellLayout.push(cell);
100
- }
101
- }
102
147
  for (let c = n.colEndStart; c < n.colEndEnd; c++) {
103
- const v = row.get(c);
104
- if (!v || v.length === 3)
105
- continue;
148
+ const ci = c * 4;
149
+ const isDeadRow = hasDead && cellSpec?.[ci] === -1;
150
+ const isDeadCol = hasDead && cellSpec?.[ci] === 0;
106
151
  cellLayout.push({
107
152
  id: columns[c].id,
108
153
  kind: "cell",
109
154
  colIndex: c,
110
155
  rowIndex: r,
111
- rowSpan: v[0],
112
- colSpan: v[1],
156
+ rowSpan: cellSpec?.[c * 4] || 1,
157
+ colSpan: cellSpec?.[c * 4 + 1] || 1,
113
158
  rowPin: "top",
114
159
  colPin: "end",
160
+ isDeadCol,
161
+ isDeadRow,
115
162
  colFirstEndPin: c === n.colCenterLast ? true : undefined,
116
163
  rowLastPinTop,
117
164
  row: node,
118
165
  column: columns[c],
119
166
  });
120
167
  }
121
- top.push({
168
+ const row = {
122
169
  id: node.get()?.id ?? `${r}`,
123
170
  rowIndex: r,
124
171
  kind: "row",
@@ -126,289 +173,8 @@ export function makeRowLayout({ layout: n, layoutMap, rds, columns, focus, }) {
126
173
  rowPin: "top",
127
174
  row: node,
128
175
  rowLastPinTop,
129
- });
130
- }
131
- /**
132
- * TOP ROW LAYOUT END
133
- */
134
- /**
135
- * CENTER ROW LAYOUT START
136
- */
137
- for (let r = n.rowCenterStart; r < n.rowCenterEnd; r++) {
138
- const row = layoutMap.get(r);
139
- if (!row) {
140
- continue;
141
- }
142
- const node = rds.rowForIndex(r);
143
- if (!node) {
144
- console.error(`Row data source did not return a row for a valid row position at index: ${r}`);
145
- break;
146
- }
147
- if (isFullWidthMap(row)) {
148
- center.push({
149
- id: node.get()?.id ?? `${r}`,
150
- rowIndex: r,
151
- kind: "full-width",
152
- rowPin: null,
153
- row: node,
154
- });
155
- continue;
156
- }
157
- const cellLayout = [];
158
- for (let c = n.colStartStart; c < n.colStartEnd; c++) {
159
- const v = row.get(c);
160
- if (!v || v.length === 3)
161
- continue;
162
- cellLayout.push({
163
- id: columns[c].id,
164
- kind: "cell",
165
- colIndex: c,
166
- rowIndex: r,
167
- rowSpan: v[0],
168
- colSpan: v[1],
169
- rowPin: null,
170
- colPin: "start",
171
- colLastStartPin: c + v[1] === n.colStartEnd ? true : undefined,
172
- row: node,
173
- column: columns[c],
174
- });
175
- }
176
- for (let c = n.colCenterStart; c < n.colCenterEnd; c++) {
177
- const v = row.get(c);
178
- if (!v || v.length === 3)
179
- continue;
180
- cellLayout.push({
181
- id: columns[c].id,
182
- kind: "cell",
183
- colIndex: c,
184
- rowIndex: r,
185
- rowSpan: v[0],
186
- colSpan: v[1],
187
- rowPin: null,
188
- colPin: null,
189
- row: node,
190
- column: columns[c],
191
- });
192
- }
193
- if (!f.isBot &&
194
- !f.isTop &&
195
- !f.isRowCenterAfter &&
196
- !f.isRowCenterAfter &&
197
- (f.isColCenterAfter || f.isColCenterBefore)) {
198
- const v = row.get(f.colIndex);
199
- if (v && v.length !== 3) {
200
- const cell = {
201
- id: columns[f.colIndex].id,
202
- kind: "cell",
203
- colIndex: f.colIndex,
204
- rowIndex: f.rowIndex,
205
- rowSpan: v[0],
206
- colSpan: v[1],
207
- rowPin: null,
208
- colPin: null,
209
- row: node,
210
- column: columns[f.colIndex],
211
- };
212
- if (f.isColCenterAfter)
213
- cellLayout.push(cell);
214
- else
215
- cellLayout.unshift(cell);
216
- }
217
- }
218
- for (let c = n.colEndStart; c < n.colEndEnd; c++) {
219
- const v = row.get(c);
220
- if (!v || v.length === 3)
221
- continue;
222
- cellLayout.push({
223
- id: columns[c].id,
224
- kind: "cell",
225
- colIndex: c,
226
- rowIndex: r,
227
- rowSpan: v[0],
228
- colSpan: v[1],
229
- rowPin: null,
230
- colPin: "end",
231
- colFirstEndPin: c === n.colCenterLast ? true : undefined,
232
- row: node,
233
- column: columns[c],
234
- });
235
- }
236
- center.push({
237
- id: node.get()?.id ?? `${r}`,
238
- rowIndex: r,
239
- kind: "row",
240
- cells: cellLayout,
241
- rowPin: null,
242
- row: node,
243
- });
176
+ };
177
+ viewCache.set(r, row);
178
+ container.push(row);
244
179
  }
245
- if (f.isRowCenterBefore || f.isRowCenterAfter) {
246
- const row = layoutMap.get(f.rowIndex);
247
- const node = rds.rowForIndex(f.rowIndex);
248
- if (row && node) {
249
- if (isFullWidthMap(row)) {
250
- center.push({
251
- id: node.get()?.id ?? `${f.rowIndex}`,
252
- rowIndex: f.rowIndex,
253
- kind: "full-width",
254
- rowPin: null,
255
- row: node,
256
- rowIsFocusRow: true,
257
- });
258
- }
259
- else {
260
- const cellLayout = [];
261
- const v = row.get(f.colIndex);
262
- if (v && v.length !== 3) {
263
- cellLayout.push({
264
- id: columns[f.colIndex].id,
265
- kind: "cell",
266
- colIndex: f.colIndex,
267
- rowIndex: f.rowIndex,
268
- rowSpan: v[0],
269
- colSpan: v[1],
270
- rowPin: null,
271
- colPin: f.isStart ? "start" : f.isEnd ? "end" : null,
272
- rowIsFocusRow: true,
273
- row: node,
274
- column: columns[f.colIndex],
275
- });
276
- }
277
- const rowLayout = {
278
- id: node.get()?.id ?? `${f.rowIndex}`,
279
- rowIndex: f.rowIndex,
280
- kind: "row",
281
- cells: cellLayout,
282
- rowPin: null,
283
- row: node,
284
- rowIsFocusRow: true,
285
- };
286
- if (f.isRowCenterAfter)
287
- center.push(rowLayout);
288
- else
289
- center.unshift(rowLayout);
290
- }
291
- }
292
- }
293
- /**
294
- * CENTER ROW LAYOUT END
295
- */
296
- /**
297
- * BOTTOM ROW LAYOUT START
298
- */
299
- for (let r = n.rowBotStart; r < n.rowBotEnd; r++) {
300
- const row = layoutMap.get(r);
301
- if (!row) {
302
- continue;
303
- }
304
- const node = rds.rowForIndex(r);
305
- if (!node) {
306
- console.error(`Row data source did not return a row for a valid row position at index: ${r}`);
307
- break;
308
- }
309
- const rowFirstPinBottom = r === n.rowBotStart ? true : undefined;
310
- if (isFullWidthMap(row)) {
311
- bottom.push({
312
- id: node.get()?.id ?? `${r}`,
313
- rowIndex: r,
314
- kind: "full-width",
315
- rowPin: "bottom",
316
- row: node,
317
- rowFirstPinBottom,
318
- });
319
- continue;
320
- }
321
- const cellLayout = [];
322
- for (let c = n.colStartStart; c < n.colStartEnd; c++) {
323
- const v = row.get(c);
324
- if (!v || v.length === 3)
325
- continue;
326
- cellLayout.push({
327
- id: columns[c].id,
328
- kind: "cell",
329
- colIndex: c,
330
- rowIndex: r,
331
- rowSpan: v[0],
332
- colSpan: v[1],
333
- rowPin: "bottom",
334
- colPin: "start",
335
- colLastStartPin: c + v[1] === n.colStartEnd ? true : undefined,
336
- rowFirstPinBottom,
337
- row: node,
338
- column: columns[c],
339
- });
340
- }
341
- for (let c = n.colCenterStart; c < n.colCenterEnd; c++) {
342
- const v = row.get(c);
343
- if (!v || v.length === 3)
344
- continue;
345
- cellLayout.push({
346
- id: columns[c].id,
347
- kind: "cell",
348
- colIndex: c,
349
- rowIndex: r,
350
- rowSpan: v[0],
351
- colSpan: v[1],
352
- rowPin: "bottom",
353
- colPin: null,
354
- rowFirstPinBottom,
355
- row: node,
356
- column: columns[c],
357
- });
358
- }
359
- if (f.isBot && (f.isColCenterAfter || f.isColCenterBefore)) {
360
- const v = row.get(f.colIndex);
361
- if (v && v.length !== 3) {
362
- const cell = {
363
- id: columns[f.colIndex].id,
364
- kind: "cell",
365
- colIndex: f.colIndex,
366
- rowIndex: f.rowIndex,
367
- rowSpan: v[0],
368
- colSpan: v[1],
369
- rowPin: "bottom",
370
- colPin: null,
371
- row: node,
372
- column: columns[f.colIndex],
373
- };
374
- cellLayout.push(cell);
375
- }
376
- }
377
- for (let c = n.colEndStart; c < n.colEndEnd; c++) {
378
- const v = row.get(c);
379
- if (!v || v.length === 3)
380
- continue;
381
- cellLayout.push({
382
- id: columns[c].id,
383
- kind: "cell",
384
- colIndex: c,
385
- rowIndex: r,
386
- rowSpan: v[0],
387
- colSpan: v[1],
388
- rowPin: "bottom",
389
- colPin: "end",
390
- colFirstEndPin: c === n.colCenterLast ? true : undefined,
391
- rowFirstPinBottom,
392
- row: node,
393
- column: columns[c],
394
- });
395
- }
396
- bottom.push({
397
- id: node.get()?.id ?? `${r}`,
398
- rowIndex: r,
399
- kind: "row",
400
- cells: cellLayout,
401
- rowPin: "bottom",
402
- row: node,
403
- rowFirstPinBottom,
404
- });
405
- }
406
- /**
407
- * BOTTOM ROW LAYOUT END
408
- */
409
- return {
410
- top,
411
- center,
412
- bottom,
413
- };
414
180
  }