@ai-matrx/design-system 0.28.0 → 0.30.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/CHANGELOG.md +56 -0
- package/dist/data-table/copy-helpers.d.cts +1 -1
- package/dist/data-table/copy-helpers.d.ts +1 -1
- package/dist/data-table/filter-engine.d.cts +1 -1
- package/dist/data-table/filter-engine.d.ts +1 -1
- package/dist/data-table/host.d.cts +1 -1
- package/dist/data-table/host.d.ts +1 -1
- package/dist/data-table/index.cjs +39 -7
- package/dist/data-table/index.cjs.map +1 -1
- package/dist/data-table/index.d.cts +3 -3
- package/dist/data-table/index.d.ts +3 -3
- package/dist/data-table/index.js +39 -7
- package/dist/data-table/index.js.map +1 -1
- package/dist/data-table/infer-filter.d.cts +1 -1
- package/dist/data-table/infer-filter.d.ts +1 -1
- package/dist/data-table/layered-filters.d.cts +1 -1
- package/dist/data-table/layered-filters.d.ts +1 -1
- package/dist/data-table/query-control.d.cts +1 -1
- package/dist/data-table/query-control.d.ts +1 -1
- package/dist/data-table/spreadsheet.cjs +37 -6
- package/dist/data-table/spreadsheet.cjs.map +1 -1
- package/dist/data-table/spreadsheet.d.cts +35 -1
- package/dist/data-table/spreadsheet.d.ts +35 -1
- package/dist/data-table/spreadsheet.js +37 -6
- package/dist/data-table/spreadsheet.js.map +1 -1
- package/dist/data-table/types.cjs.map +1 -1
- package/dist/data-table/types.d.cts +2 -2
- package/dist/data-table/types.d.ts +2 -2
- package/dist/data-table/url-state.d.cts +1 -1
- package/dist/data-table/url-state.d.ts +1 -1
- package/dist/data-table/xlsx.d.cts +1 -1
- package/dist/data-table/xlsx.d.ts +1 -1
- package/dist/index.cjs +8 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +8 -4
- package/dist/index.js.map +1 -1
- package/dist/{types-D9JBR6ZU.d.ts → types-CFmCZXVn.d.ts} +24 -1
- package/dist/{types-jQddSUnj.d.cts → types-CYkwg9jR.d.cts} +24 -1
- package/package.json +1 -1
|
@@ -33,6 +33,35 @@ import { CellPatch } from './fill.js';
|
|
|
33
33
|
|
|
34
34
|
/** What a set of cell patches was for, so a consumer can label its own toast. */
|
|
35
35
|
type SpreadsheetIntent = "paste" | "fill" | "fill-down" | "undo" | "redo" | "clear";
|
|
36
|
+
/** One cell a paste did not write, with the sentence that says why. */
|
|
37
|
+
interface PasteRefusal {
|
|
38
|
+
/** Null when the cell belongs to no row on the grid. */
|
|
39
|
+
rowId: string | null;
|
|
40
|
+
columnId: string;
|
|
41
|
+
reason: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* What a paste WOULD do, handed over before any of it happens.
|
|
45
|
+
*
|
|
46
|
+
* Addresses are (rowId, columnId) like everywhere else in the grid, never
|
|
47
|
+
* indices — a row filtered out between the copy and the paste is not a row.
|
|
48
|
+
*/
|
|
49
|
+
interface SpreadsheetPastePlan {
|
|
50
|
+
/** The cells that would be written, already screened by `validateCell`. */
|
|
51
|
+
accepted: CellPatch[];
|
|
52
|
+
/** Cells `validateCell` or `writableColumnIds` turned away, each with its sentence. */
|
|
53
|
+
refusals: PasteRefusal[];
|
|
54
|
+
/**
|
|
55
|
+
* Rows of the pasted block that fell past the last row of the grid, in the
|
|
56
|
+
* grid's current column order (so a hidden or reordered column is honoured).
|
|
57
|
+
* Each entry maps a columnId to the raw clipboard text for that cell.
|
|
58
|
+
*/
|
|
59
|
+
overflow: Array<Record<string, string>>;
|
|
60
|
+
/** Cells that fell past the RIGHT edge — there is no column to hold them. */
|
|
61
|
+
pastRightEdge: number;
|
|
62
|
+
/** Write `accepted` through `onPatch`, exactly as an unconfirmed paste would. */
|
|
63
|
+
apply: () => Promise<void>;
|
|
64
|
+
}
|
|
36
65
|
interface SpreadsheetGridOptions {
|
|
37
66
|
/** Row ids currently rendered, in visual order. */
|
|
38
67
|
rowIds: readonly string[];
|
|
@@ -54,6 +83,11 @@ interface SpreadsheetGridOptions {
|
|
|
54
83
|
paste?: boolean | undefined;
|
|
55
84
|
/** Says what just happened, and why something did not. */
|
|
56
85
|
notify?: ((message: string) => void) | undefined;
|
|
86
|
+
/**
|
|
87
|
+
* Hand the whole paste over instead of applying it. See
|
|
88
|
+
* `MatrxDataTableSpreadsheetConfig.onPastePlan` for why this exists.
|
|
89
|
+
*/
|
|
90
|
+
onPastePlan?: ((plan: SpreadsheetPastePlan) => void) | undefined;
|
|
57
91
|
/**
|
|
58
92
|
* OPEN THE EDITOR on the focused cell. Return true when the editor actually
|
|
59
93
|
* opened, so the keystroke is consumed; return false and the key is left to
|
|
@@ -150,4 +184,4 @@ interface SpreadsheetClipboardEvent {
|
|
|
150
184
|
declare const NOTHING: CellPatch[];
|
|
151
185
|
declare function useSpreadsheetGrid(options: SpreadsheetGridOptions | null): SpreadsheetGrid;
|
|
152
186
|
|
|
153
|
-
export { NOTHING as NO_PATCHES, type SpreadsheetCellProps, type SpreadsheetClipboardEvent, type SpreadsheetGrid, type SpreadsheetGridOptions, type SpreadsheetIntent, type SpreadsheetKeyEvent, useSpreadsheetGrid };
|
|
187
|
+
export { NOTHING as NO_PATCHES, type PasteRefusal, type SpreadsheetCellProps, type SpreadsheetClipboardEvent, type SpreadsheetGrid, type SpreadsheetGridOptions, type SpreadsheetIntent, type SpreadsheetKeyEvent, type SpreadsheetPastePlan, useSpreadsheetGrid };
|
|
@@ -657,7 +657,7 @@ function useSpreadsheetGrid(options) {
|
|
|
657
657
|
} catch {
|
|
658
658
|
reason = void 0;
|
|
659
659
|
}
|
|
660
|
-
if (reason) refusals.push({ columnId: patch.columnId, reason });
|
|
660
|
+
if (reason) refusals.push({ rowId: patch.rowId, columnId: patch.columnId, reason });
|
|
661
661
|
else accepted.push(patch);
|
|
662
662
|
}
|
|
663
663
|
return { accepted, refusals };
|
|
@@ -736,6 +736,7 @@ function useSpreadsheetGrid(options) {
|
|
|
736
736
|
if (rowId === void 0 || columnId === void 0) continue;
|
|
737
737
|
if (!current.isColumnWritable(columnId)) {
|
|
738
738
|
skipped.push({
|
|
739
|
+
rowId,
|
|
739
740
|
columnId,
|
|
740
741
|
reason: current.columnRefusal?.(columnId) ?? `${columnId} cannot be cleared.`
|
|
741
742
|
});
|
|
@@ -899,18 +900,33 @@ function useSpreadsheetGrid(options) {
|
|
|
899
900
|
if (startRow === -1 || startCol === -1) return;
|
|
900
901
|
const patches = [];
|
|
901
902
|
const skipped = [];
|
|
902
|
-
let
|
|
903
|
+
let pastRightEdge = 0;
|
|
904
|
+
const overflow = [];
|
|
903
905
|
for (let r = 0; r < block.length; r += 1) {
|
|
904
906
|
const line = block[r] ?? [];
|
|
907
|
+
const rowId = rowIds[startRow + r];
|
|
908
|
+
if (rowId === void 0) {
|
|
909
|
+
const beyond = {};
|
|
910
|
+
for (let c = 0; c < line.length; c += 1) {
|
|
911
|
+
const columnId = columnIds[startCol + c];
|
|
912
|
+
if (columnId === void 0) {
|
|
913
|
+
pastRightEdge += 1;
|
|
914
|
+
continue;
|
|
915
|
+
}
|
|
916
|
+
beyond[columnId] = line[c] ?? "";
|
|
917
|
+
}
|
|
918
|
+
overflow.push(beyond);
|
|
919
|
+
continue;
|
|
920
|
+
}
|
|
905
921
|
for (let c = 0; c < line.length; c += 1) {
|
|
906
|
-
const rowId = rowIds[startRow + r];
|
|
907
922
|
const columnId = columnIds[startCol + c];
|
|
908
|
-
if (
|
|
909
|
-
|
|
923
|
+
if (columnId === void 0) {
|
|
924
|
+
pastRightEdge += 1;
|
|
910
925
|
continue;
|
|
911
926
|
}
|
|
912
927
|
if (!current.isColumnWritable(columnId)) {
|
|
913
928
|
skipped.push({
|
|
929
|
+
rowId,
|
|
914
930
|
columnId,
|
|
915
931
|
reason: current.columnRefusal?.(columnId) ?? `${columnId} cannot take a pasted value.`
|
|
916
932
|
});
|
|
@@ -920,9 +936,24 @@ function useSpreadsheetGrid(options) {
|
|
|
920
936
|
}
|
|
921
937
|
}
|
|
922
938
|
const screened = screenPatches(patches);
|
|
939
|
+
const refusals = [...skipped, ...screened.refusals];
|
|
940
|
+
if (current.onPastePlan) {
|
|
941
|
+
const accepted = screened.accepted;
|
|
942
|
+
current.onPastePlan({
|
|
943
|
+
accepted,
|
|
944
|
+
refusals,
|
|
945
|
+
overflow,
|
|
946
|
+
pastRightEdge,
|
|
947
|
+
apply: async () => {
|
|
948
|
+
await applyPatches(accepted, "paste", "Pasted");
|
|
949
|
+
}
|
|
950
|
+
});
|
|
951
|
+
return;
|
|
952
|
+
}
|
|
923
953
|
void applyPatches(screened.accepted, "paste", "Pasted");
|
|
954
|
+
const outside = pastRightEdge + overflow.reduce((n, row) => n + Object.keys(row).length, 0);
|
|
924
955
|
const tail = outside > 0 ? ` ${outside} landed past the edge of the table and were ignored.` : "";
|
|
925
|
-
announceSkips(
|
|
956
|
+
announceSkips(refusals, `Pasted ${screened.accepted.length} cells.${tail}`);
|
|
926
957
|
},
|
|
927
958
|
[range, rowIds, columnIds, applyPatches, announceSkips, screenPatches]
|
|
928
959
|
);
|