@jsb188/mday-web 1.1.10 → 1.1.12

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 (38) hide show
  1. package/package.json +36 -24
  2. package/src/libs/route-metadata.server.ts +67 -0
  3. package/src/modules/Grids.filters.ts +36 -0
  4. package/src/modules/Grids.tsx +610 -0
  5. package/src/modules/RouteShell.tsx +76 -0
  6. package/src/schemas/organization.ts +128 -0
  7. package/src/utils/email.ts +117 -0
  8. package/src/utils/list-web.ts +17 -0
  9. package/src/utils/log-web.helpers.ts +99 -0
  10. package/src/utils/log-web.icons.ts +184 -0
  11. package/src/utils/log-web.ts +74 -364
  12. package/src/utils/operation-pages.ts +154 -0
  13. package/src/utils/org-web.ts +35 -8
  14. package/src/utils/route-helpers.ts +837 -596
  15. package/src/utils/workflow-web.ts +72 -0
  16. package/tests/log-web.test.ts +134 -0
  17. package/tests/route-helpers.test.ts +17 -0
  18. package/tsconfig.json +11 -11
  19. package/src/modules/DataTable-ContextMenu.tsx +0 -169
  20. package/src/modules/DataTable-InboundContact.tsx +0 -523
  21. package/src/modules/DataTable.tsx +0 -5060
  22. package/src/modules/Sheet-ContextMenu.tsx +0 -161
  23. package/src/modules/Sheet.tsx +0 -28
  24. package/src/modules/cell-save-beacon.ts +0 -67
  25. package/src/modules/dataTable-interaction-state.ts +0 -276
  26. package/src/modules/dataTable-shortcuts.ts +0 -192
  27. package/src/modules/dataTable-viewport.ts +0 -89
  28. package/src/modules/grid-cell-render.ts +0 -72
  29. package/src/modules/grid-context-menu.ts +0 -112
  30. package/src/modules/grid-keyboard.ts +0 -267
  31. package/src/modules/grid-render-store.ts +0 -103
  32. package/src/modules/grid-runtime.ts +0 -178
  33. package/src/modules/grid-selection.ts +0 -336
  34. package/src/modules/grid-viewport.ts +0 -57
  35. package/src/modules/use-dataTable-states.ts +0 -529
  36. package/src/modules/use-debounced-cell-save-batch.ts +0 -160
  37. package/tests/DataTable.test.tsx +0 -4466
  38. package/tests/dataTable-interaction-state.test.ts +0 -127
@@ -1,336 +0,0 @@
1
- import {
2
- getSheetCellKey,
3
- SHEET_ROW_NUMBER_WIDTH,
4
- type SheetColumnMetric,
5
- type SheetUISelectedCellKeyMap,
6
- type SheetUISelectedCellState,
7
- } from '@jsb188/react-web/ui/SheetUI';
8
- import type { GridArrowDirection } from './grid-keyboard.ts';
9
-
10
- export type GridSelectionBoxPosition = {
11
- height: number;
12
- left: number;
13
- top: number;
14
- width: number;
15
- };
16
-
17
- export type GridSelectionBoxRowMetric = {
18
- height: number;
19
- rowKey: string;
20
- top: number;
21
- };
22
-
23
- export type GridCellRangeSelection = {
24
- activeCell: SheetUISelectedCellState;
25
- anchorCell: SheetUISelectedCellState;
26
- rangeEndCell: SheetUISelectedCellState;
27
- selectedCellKeyMap: SheetUISelectedCellKeyMap;
28
- };
29
-
30
- /*
31
- * Build a selected-cell key map from already-ordered coordinate cells.
32
- */
33
-
34
- export function getGridSelectedCellKeyMapFromCells(cells: SheetUISelectedCellState[]) {
35
- const selectedCellKeyMap: SheetUISelectedCellKeyMap = {};
36
-
37
- cells.forEach((cell) => {
38
- selectedCellKeyMap[getSheetCellKey(cell.rowId, cell.cellKey)] = true;
39
- });
40
-
41
- return selectedCellKeyMap;
42
- }
43
-
44
- /*
45
- * Build a rectangular selected-cell key map from ordered row and column metrics.
46
- */
47
-
48
- export function getGridSelectedCellKeyMapForRange(params: {
49
- activeCell: SheetUISelectedCellState;
50
- anchorCell: SheetUISelectedCellState;
51
- columnMetrics: SheetColumnMetric[];
52
- rowIds: string[];
53
- }) {
54
- const activeColumnIndex = params.columnMetrics.findIndex((metric) => metric.column.key === params.activeCell.cellKey);
55
- const anchorColumnIndex = params.columnMetrics.findIndex((metric) => metric.column.key === params.anchorCell.cellKey);
56
- const activeRowIndex = params.rowIds.indexOf(params.activeCell.rowId);
57
- const anchorRowIndex = params.rowIds.indexOf(params.anchorCell.rowId);
58
-
59
- if (activeColumnIndex < 0 || anchorColumnIndex < 0 || activeRowIndex < 0 || anchorRowIndex < 0) {
60
- return getGridSelectedCellKeyMapFromCells([params.activeCell]);
61
- }
62
-
63
- const columnStart = Math.min(activeColumnIndex, anchorColumnIndex);
64
- const columnEnd = Math.max(activeColumnIndex, anchorColumnIndex);
65
- const rowStart = Math.min(activeRowIndex, anchorRowIndex);
66
- const rowEnd = Math.max(activeRowIndex, anchorRowIndex);
67
- const selectedCellKeyMap: SheetUISelectedCellKeyMap = {};
68
-
69
- for (let rowIndex = rowStart; rowIndex <= rowEnd; rowIndex += 1) {
70
- const rowId = params.rowIds[rowIndex];
71
- if (!rowId) {
72
- continue;
73
- }
74
-
75
- for (let columnIndex = columnStart; columnIndex <= columnEnd; columnIndex += 1) {
76
- const column = params.columnMetrics[columnIndex]?.column;
77
- if (column) {
78
- selectedCellKeyMap[getSheetCellKey(rowId, column.key)] = true;
79
- }
80
- }
81
- }
82
-
83
- return selectedCellKeyMap;
84
- }
85
-
86
- /*
87
- * Build the full rectangular selection state for a generic grid.
88
- */
89
-
90
- export function getGridRangeSelection(params: {
91
- activeCell: SheetUISelectedCellState;
92
- anchorCell: SheetUISelectedCellState;
93
- columnMetrics: SheetColumnMetric[];
94
- rowIds: string[];
95
- selectedActiveCell?: SheetUISelectedCellState;
96
- }): GridCellRangeSelection {
97
- return {
98
- activeCell: params.selectedActiveCell || params.anchorCell,
99
- anchorCell: params.anchorCell,
100
- rangeEndCell: params.activeCell,
101
- selectedCellKeyMap: getGridSelectedCellKeyMapForRange({
102
- activeCell: params.activeCell,
103
- anchorCell: params.anchorCell,
104
- columnMetrics: params.columnMetrics,
105
- rowIds: params.rowIds,
106
- }),
107
- };
108
- }
109
-
110
- /*
111
- * Return the next selected grid cell after one arrow-key movement.
112
- */
113
-
114
- export function getGridArrowNavigationSelection(params: {
115
- columnMetrics: SheetColumnMetric[];
116
- direction: GridArrowDirection;
117
- rowIds: string[];
118
- selectedCellState?: SheetUISelectedCellState | null;
119
- }) {
120
- const { columnMetrics, direction, rowIds, selectedCellState } = params;
121
-
122
- if (!columnMetrics.length || !rowIds.length) {
123
- return null;
124
- }
125
-
126
- const currentColumnIndex = selectedCellState ? columnMetrics.findIndex((metric) => metric.column.key === selectedCellState.cellKey) : -1;
127
- const currentRowIndex = selectedCellState ? rowIds.indexOf(selectedCellState.rowId) : -1;
128
-
129
- if (currentColumnIndex < 0 || currentRowIndex < 0) {
130
- return {
131
- cellKey: columnMetrics[0].column.key,
132
- rowId: rowIds[0],
133
- };
134
- }
135
-
136
- let nextColumnIndex = currentColumnIndex;
137
- let nextRowIndex = currentRowIndex;
138
-
139
- switch (direction) {
140
- case 'left':
141
- nextColumnIndex = Math.max(0, currentColumnIndex - 1);
142
- break;
143
- case 'right':
144
- nextColumnIndex = Math.min(columnMetrics.length - 1, currentColumnIndex + 1);
145
- break;
146
- case 'up':
147
- nextRowIndex = Math.max(0, currentRowIndex - 1);
148
- break;
149
- case 'down':
150
- nextRowIndex = Math.min(rowIds.length - 1, currentRowIndex + 1);
151
- break;
152
- default:
153
- }
154
-
155
- const nextColumn = columnMetrics[nextColumnIndex];
156
- const nextRowId = rowIds[nextRowIndex];
157
-
158
- if (!nextColumn || !nextRowId) {
159
- return null;
160
- }
161
-
162
- return {
163
- cellKey: nextColumn.column.key,
164
- rowId: nextRowId,
165
- };
166
- }
167
-
168
- /*
169
- * Return the stable anchor corner for an existing rectangular grid selection.
170
- */
171
-
172
- export function getGridSelectionAnchorCell(params: {
173
- activeCell?: SheetUISelectedCellState | null;
174
- columnMetrics: SheetColumnMetric[];
175
- rowIds: string[];
176
- selectedCellKeyMap?: SheetUISelectedCellKeyMap | null;
177
- }) {
178
- const { activeCell, columnMetrics, rowIds, selectedCellKeyMap } = params;
179
-
180
- if (!activeCell || !selectedCellKeyMap || Object.keys(selectedCellKeyMap).length <= 1) {
181
- return activeCell || null;
182
- }
183
-
184
- let minColumnIndex = Infinity;
185
- let maxColumnIndex = -Infinity;
186
- let minRowIndex = Infinity;
187
- let maxRowIndex = -Infinity;
188
-
189
- rowIds.forEach((rowId, rowIndex) => {
190
- columnMetrics.forEach((metric, columnIndex) => {
191
- if (!selectedCellKeyMap[getSheetCellKey(rowId, metric.column.key)]) {
192
- return;
193
- }
194
-
195
- minColumnIndex = Math.min(minColumnIndex, columnIndex);
196
- maxColumnIndex = Math.max(maxColumnIndex, columnIndex);
197
- minRowIndex = Math.min(minRowIndex, rowIndex);
198
- maxRowIndex = Math.max(maxRowIndex, rowIndex);
199
- });
200
- });
201
-
202
- const activeColumnIndex = columnMetrics.findIndex((metric) => metric.column.key === activeCell.cellKey);
203
- const activeRowIndex = rowIds.indexOf(activeCell.rowId);
204
-
205
- if (
206
- activeColumnIndex < 0 ||
207
- activeRowIndex < 0 ||
208
- !Number.isFinite(minColumnIndex) ||
209
- !Number.isFinite(maxColumnIndex) ||
210
- !Number.isFinite(minRowIndex) ||
211
- !Number.isFinite(maxRowIndex)
212
- ) {
213
- return activeCell;
214
- }
215
-
216
- const anchorColumnIndex = activeColumnIndex <= minColumnIndex ? maxColumnIndex : minColumnIndex;
217
- const anchorRowIndex = activeRowIndex <= minRowIndex ? maxRowIndex : minRowIndex;
218
- const anchorColumn = columnMetrics[anchorColumnIndex];
219
- const anchorRowId = rowIds[anchorRowIndex];
220
-
221
- if (!anchorColumn || !anchorRowId) {
222
- return activeCell;
223
- }
224
-
225
- return {
226
- cellKey: anchorColumn.column.key,
227
- rowId: anchorRowId,
228
- };
229
- }
230
-
231
- /*
232
- * Return one rectangle that surrounds an active multi-cell grid selection.
233
- */
234
-
235
- export function getGridSelectionBoxPosition(params: {
236
- columnMetrics: SheetColumnMetric[];
237
- getColumnDisplayLeft?: (metric: SheetColumnMetric) => number;
238
- rowMetrics: GridSelectionBoxRowMetric[];
239
- selectedCellKeyMap?: SheetUISelectedCellKeyMap | null;
240
- stickyHeaderHeight: number;
241
- }): GridSelectionBoxPosition | null {
242
- const selectedCellKeyMap = params.selectedCellKeyMap;
243
-
244
- if (!selectedCellKeyMap || Object.keys(selectedCellKeyMap).length <= 1) {
245
- return null;
246
- }
247
-
248
- let selectedCount = 0;
249
- let minColumnLeft = Infinity;
250
- let maxColumnRight = -Infinity;
251
- let minRowTop = Infinity;
252
- let maxRowBottom = -Infinity;
253
-
254
- params.rowMetrics.forEach((rowMetric) => {
255
- params.columnMetrics.forEach((columnMetric) => {
256
- if (!selectedCellKeyMap[getSheetCellKey(rowMetric.rowKey, columnMetric.column.key)]) {
257
- return;
258
- }
259
-
260
- const columnLeft = params.getColumnDisplayLeft?.(columnMetric) ?? columnMetric.left;
261
-
262
- selectedCount += 1;
263
- minColumnLeft = Math.min(minColumnLeft, columnLeft);
264
- maxColumnRight = Math.max(maxColumnRight, columnLeft + columnMetric.width);
265
- minRowTop = Math.min(minRowTop, rowMetric.top);
266
- maxRowBottom = Math.max(maxRowBottom, rowMetric.top + rowMetric.height);
267
- });
268
- });
269
-
270
- if (selectedCount <= 1 || !Number.isFinite(minColumnLeft) || !Number.isFinite(maxColumnRight) || !Number.isFinite(minRowTop) || !Number.isFinite(maxRowBottom)) {
271
- return null;
272
- }
273
-
274
- return {
275
- height: maxRowBottom - minRowTop + 1,
276
- left: SHEET_ROW_NUMBER_WIDTH + minColumnLeft - 1,
277
- top: params.stickyHeaderHeight + minRowTop - 1,
278
- width: maxColumnRight - minColumnLeft + 1,
279
- };
280
- }
281
-
282
- /*
283
- * Return selected cells in row-major order from a generic grid.
284
- */
285
-
286
- export function getOrderedGridSelectedCells(params: {
287
- columnMetrics: SheetColumnMetric[];
288
- rowIds: string[];
289
- selectedCellKeyMap: SheetUISelectedCellKeyMap;
290
- }) {
291
- const selectedCells: SheetUISelectedCellState[] = [];
292
-
293
- params.rowIds.forEach((rowId) => {
294
- params.columnMetrics.forEach((metric) => {
295
- if (params.selectedCellKeyMap[getSheetCellKey(rowId, metric.column.key)]) {
296
- selectedCells.push({
297
- cellKey: metric.column.key,
298
- rowId,
299
- });
300
- }
301
- });
302
- });
303
-
304
- return selectedCells;
305
- }
306
-
307
- /*
308
- * Return the next active cell within the current selected cells.
309
- */
310
-
311
- export function getNextActiveGridSelectedCell(params: {
312
- activeCell?: SheetUISelectedCellState | null;
313
- columnMetrics: SheetColumnMetric[];
314
- direction: 'forward' | 'backward';
315
- rowIds: string[];
316
- selectedCellKeyMap: SheetUISelectedCellKeyMap;
317
- }) {
318
- const selectedCells = getOrderedGridSelectedCells({
319
- columnMetrics: params.columnMetrics,
320
- rowIds: params.rowIds,
321
- selectedCellKeyMap: params.selectedCellKeyMap,
322
- });
323
-
324
- if (!selectedCells.length) {
325
- return null;
326
- }
327
-
328
- const activeIndex = params.activeCell
329
- ? selectedCells.findIndex((cell) => cell.rowId === params.activeCell?.rowId && cell.cellKey === params.activeCell?.cellKey)
330
- : -1;
331
- const currentIndex = activeIndex >= 0 ? activeIndex : 0;
332
- const offset = params.direction === 'backward' ? -1 : 1;
333
- const nextIndex = (currentIndex + offset + selectedCells.length) % selectedCells.length;
334
-
335
- return selectedCells[nextIndex] || null;
336
- }
@@ -1,57 +0,0 @@
1
- import {
2
- getSheetColumnIndexAtOffset,
3
- getSheetRowIndexAtOffset,
4
- SHEET_ROW_NUMBER_WIDTH,
5
- type SheetColumnMetric,
6
- type SheetRowMetric,
7
- type SheetUISelectedCellState,
8
- } from '@jsb188/react-web/ui/SheetUI';
9
-
10
- /*
11
- * Return cells that are visible in the current grid viewport.
12
- */
13
-
14
- export function getGridViewportVisibleCells(params: {
15
- columnMetrics: SheetColumnMetric[];
16
- columnOffsets: number[];
17
- frozenColumnCount: number;
18
- rowMetrics: SheetRowMetric[];
19
- rowOffsets: number[];
20
- scrollLeft: number;
21
- scrollTop: number;
22
- stickyHeaderHeight: number;
23
- viewportHeight: number;
24
- viewportWidth: number;
25
- }) {
26
- const visibleBodyHeight = Math.max(0, params.viewportHeight - params.stickyHeaderHeight);
27
- const visibleBodyTop = Math.max(0, params.scrollTop - params.stickyHeaderHeight);
28
- const visibleBodyBottom = Math.max(visibleBodyTop, visibleBodyTop + visibleBodyHeight - 1);
29
- const visibleRowStart = getSheetRowIndexAtOffset(params.rowOffsets, visibleBodyTop);
30
- const visibleRowEnd = getSheetRowIndexAtOffset(params.rowOffsets, visibleBodyBottom) + 1;
31
- const bodyScrollLeft = Math.max(0, params.scrollLeft - SHEET_ROW_NUMBER_WIDTH);
32
- const bodyScrollRight = Math.max(bodyScrollLeft, bodyScrollLeft + params.viewportWidth - 1);
33
- const visibleColumnStart = getSheetColumnIndexAtOffset(params.columnOffsets, bodyScrollLeft);
34
- const visibleColumnEnd = getSheetColumnIndexAtOffset(params.columnOffsets, bodyScrollRight) + 1;
35
- const visibleColumnIndexes = new Set<number>();
36
-
37
- for (let columnIndex = 0; columnIndex < params.frozenColumnCount && columnIndex < params.columnMetrics.length; columnIndex += 1) {
38
- visibleColumnIndexes.add(columnIndex);
39
- }
40
-
41
- for (let columnIndex = visibleColumnStart; columnIndex < visibleColumnEnd; columnIndex += 1) {
42
- visibleColumnIndexes.add(columnIndex);
43
- }
44
-
45
- const visibleRows = params.rowMetrics.slice(visibleRowStart, visibleRowEnd);
46
- const visibleColumns = Array.from(visibleColumnIndexes)
47
- .sort((a, b) => a - b)
48
- .map((columnIndex) => params.columnMetrics[columnIndex])
49
- .filter(Boolean);
50
-
51
- return visibleRows.flatMap((rowMetric): SheetUISelectedCellState[] => {
52
- return visibleColumns.map((columnMetric) => ({
53
- cellKey: columnMetric.column.key,
54
- rowId: rowMetric.rowKey,
55
- }));
56
- });
57
- }