@ai-matrx/design-system 0.25.0 → 0.26.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 +76 -0
- package/dist/data-table/copy-helpers.d.cts +2 -1
- package/dist/data-table/copy-helpers.d.ts +2 -1
- package/dist/data-table/data-row-inspector.cjs.map +1 -1
- package/dist/data-table/data-row-inspector.js.map +1 -1
- package/dist/data-table/data-row-window.cjs.map +1 -1
- package/dist/data-table/data-row-window.js.map +1 -1
- package/dist/data-table/facets.cjs +118 -0
- package/dist/data-table/facets.cjs.map +1 -0
- package/dist/data-table/facets.d.cts +100 -0
- package/dist/data-table/facets.d.ts +100 -0
- package/dist/data-table/facets.js +98 -0
- package/dist/data-table/facets.js.map +1 -0
- package/dist/data-table/filter-engine.d.cts +2 -1
- package/dist/data-table/filter-engine.d.ts +2 -1
- package/dist/data-table/host.cjs.map +1 -1
- package/dist/data-table/host.d.cts +13 -3
- package/dist/data-table/host.d.ts +13 -3
- package/dist/data-table/host.js.map +1 -1
- package/dist/data-table/index.cjs +680 -145
- package/dist/data-table/index.cjs.map +1 -1
- package/dist/data-table/index.d.cts +4 -2
- package/dist/data-table/index.d.ts +4 -2
- package/dist/data-table/index.js +718 -182
- package/dist/data-table/index.js.map +1 -1
- package/dist/data-table/infer-filter.d.cts +2 -1
- package/dist/data-table/infer-filter.d.ts +2 -1
- package/dist/data-table/layered-filters.d.cts +2 -1
- package/dist/data-table/layered-filters.d.ts +2 -1
- package/dist/data-table/menu-targets.cjs +77 -0
- package/dist/data-table/menu-targets.cjs.map +1 -0
- package/dist/data-table/menu-targets.d.cts +108 -0
- package/dist/data-table/menu-targets.d.ts +108 -0
- package/dist/data-table/menu-targets.js +57 -0
- package/dist/data-table/menu-targets.js.map +1 -0
- package/dist/data-table/pagination.cjs.map +1 -1
- package/dist/data-table/pagination.js.map +1 -1
- package/dist/data-table/query-control.d.cts +2 -1
- package/dist/data-table/query-control.d.ts +2 -1
- package/dist/data-table/spreadsheet.cjs +61 -13
- package/dist/data-table/spreadsheet.cjs.map +1 -1
- package/dist/data-table/spreadsheet.d.cts +36 -1
- package/dist/data-table/spreadsheet.d.ts +36 -1
- package/dist/data-table/spreadsheet.js +61 -13
- 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 -1
- package/dist/data-table/types.d.ts +2 -1
- package/dist/data-table/url-state.d.cts +2 -1
- package/dist/data-table/url-state.d.ts +2 -1
- package/dist/data-table/uuid-cell.cjs.map +1 -1
- package/dist/data-table/uuid-cell.js.map +1 -1
- package/dist/data-table/xlsx.d.cts +2 -1
- package/dist/data-table/xlsx.d.ts +2 -1
- package/dist/{types-nlLCMiqd.d.ts → types-Cu5_eUG1.d.ts} +115 -3
- package/dist/{types-CmQrOz-T.d.cts → types-DrJXAAoD.d.cts} +115 -3
- package/package.json +21 -1
|
@@ -644,6 +644,26 @@ function useSpreadsheetGrid(options) {
|
|
|
644
644
|
for (let i = 0; i < columnIds.length; i += 1) map.set(columnIds[i], i);
|
|
645
645
|
return map;
|
|
646
646
|
}, [columnIds]);
|
|
647
|
+
const screenPatches = useCallback(
|
|
648
|
+
(patches) => {
|
|
649
|
+
const validate = optionsRef.current?.validateCell;
|
|
650
|
+
if (!validate) return { accepted: patches, refusals: [] };
|
|
651
|
+
const accepted = [];
|
|
652
|
+
const refusals = [];
|
|
653
|
+
for (const patch of patches) {
|
|
654
|
+
let reason;
|
|
655
|
+
try {
|
|
656
|
+
reason = validate({ rowId: patch.rowId, columnId: patch.columnId, value: patch.value });
|
|
657
|
+
} catch {
|
|
658
|
+
reason = void 0;
|
|
659
|
+
}
|
|
660
|
+
if (reason) refusals.push({ columnId: patch.columnId, reason });
|
|
661
|
+
else accepted.push(patch);
|
|
662
|
+
}
|
|
663
|
+
return { accepted, refusals };
|
|
664
|
+
},
|
|
665
|
+
[]
|
|
666
|
+
);
|
|
647
667
|
const applyPatches = useCallback(
|
|
648
668
|
async (patches, intent, label) => {
|
|
649
669
|
const current = optionsRef.current;
|
|
@@ -700,9 +720,10 @@ function useSpreadsheetGrid(options) {
|
|
|
700
720
|
...base,
|
|
701
721
|
range: { top: bounds.r0, left: bounds.c0, bottom: bounds.r1, right: bounds.c1 }
|
|
702
722
|
});
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
723
|
+
const screened = screenPatches(result.patches);
|
|
724
|
+
await applyPatches(screened.accepted, "fill-down", "Filled down");
|
|
725
|
+
announceSkips([...result.skipped, ...screened.refusals], result.summary);
|
|
726
|
+
}, [fillRequestBase, bounds, applyPatches, announceSkips, screenPatches]);
|
|
706
727
|
const doClear = useCallback(async () => {
|
|
707
728
|
const current = optionsRef.current;
|
|
708
729
|
if (!current || !bounds) return;
|
|
@@ -723,9 +744,13 @@ function useSpreadsheetGrid(options) {
|
|
|
723
744
|
patches.push({ rowId, columnId, value: null });
|
|
724
745
|
}
|
|
725
746
|
}
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
747
|
+
const screened = screenPatches(patches);
|
|
748
|
+
await applyPatches(screened.accepted, "clear", "Cleared");
|
|
749
|
+
announceSkips(
|
|
750
|
+
[...skipped, ...screened.refusals],
|
|
751
|
+
`Cleared ${screened.accepted.length} cells.`
|
|
752
|
+
);
|
|
753
|
+
}, [bounds, applyPatches, announceSkips, screenPatches]);
|
|
729
754
|
const doUndo = useCallback(async () => {
|
|
730
755
|
const taken = popUndo(stack);
|
|
731
756
|
if (!taken.entry) return;
|
|
@@ -810,6 +835,14 @@ function useSpreadsheetGrid(options) {
|
|
|
810
835
|
case "escape":
|
|
811
836
|
setRange(null);
|
|
812
837
|
return;
|
|
838
|
+
case "edit":
|
|
839
|
+
case "editSeeded": {
|
|
840
|
+
const focused = range?.focus;
|
|
841
|
+
if (!focused || !current.onEditRequest) return;
|
|
842
|
+
const seed = action.kind === "editSeeded" ? action.seed : null;
|
|
843
|
+
if (current.onEditRequest(focused, seed)) event.preventDefault();
|
|
844
|
+
return;
|
|
845
|
+
}
|
|
813
846
|
default:
|
|
814
847
|
return;
|
|
815
848
|
}
|
|
@@ -824,6 +857,13 @@ function useSpreadsheetGrid(options) {
|
|
|
824
857
|
);
|
|
825
858
|
return gridToTsv(grid);
|
|
826
859
|
}, [range, rowIds, columnIds]);
|
|
860
|
+
const selectionAddresses = useCallback(() => {
|
|
861
|
+
if (!range || !bounds) return { rowIds: [], columnIds: [] };
|
|
862
|
+
return {
|
|
863
|
+
rowIds: rowIds.slice(bounds.r0, bounds.r1 + 1),
|
|
864
|
+
columnIds: columnIds.slice(bounds.c0, bounds.c1 + 1)
|
|
865
|
+
};
|
|
866
|
+
}, [range, bounds, rowIds, columnIds]);
|
|
827
867
|
const onCopy = useCallback(
|
|
828
868
|
(event) => {
|
|
829
869
|
if (!optionsRef.current || !range || targetsAnEditor(event.target)) return;
|
|
@@ -879,11 +919,12 @@ function useSpreadsheetGrid(options) {
|
|
|
879
919
|
patches.push({ rowId, columnId, value: line[c] ?? null });
|
|
880
920
|
}
|
|
881
921
|
}
|
|
882
|
-
|
|
922
|
+
const screened = screenPatches(patches);
|
|
923
|
+
void applyPatches(screened.accepted, "paste", "Pasted");
|
|
883
924
|
const tail = outside > 0 ? ` ${outside} landed past the edge of the table and were ignored.` : "";
|
|
884
|
-
announceSkips(skipped, `Pasted ${
|
|
925
|
+
announceSkips([...skipped, ...screened.refusals], `Pasted ${screened.accepted.length} cells.${tail}`);
|
|
885
926
|
},
|
|
886
|
-
[range, rowIds, columnIds, applyPatches, announceSkips]
|
|
927
|
+
[range, rowIds, columnIds, applyPatches, announceSkips, screenPatches]
|
|
887
928
|
);
|
|
888
929
|
const cellProps = useCallback(
|
|
889
930
|
(rowId, columnId) => {
|
|
@@ -902,6 +943,10 @@ function useSpreadsheetGrid(options) {
|
|
|
902
943
|
onMouseDown: (event) => {
|
|
903
944
|
if (event.button !== 0) return;
|
|
904
945
|
event.preventDefault();
|
|
946
|
+
const origin = event.currentTarget;
|
|
947
|
+
if (typeof HTMLElement !== "undefined" && origin instanceof HTMLElement) {
|
|
948
|
+
origin.closest('[data-matrx-table-spreadsheet="true"]')?.focus({ preventScroll: true });
|
|
949
|
+
}
|
|
905
950
|
setRange(
|
|
906
951
|
(previous) => event.shiftKey && previous ? { anchor: previous.anchor, focus: address } : { anchor: address, focus: address }
|
|
907
952
|
);
|
|
@@ -963,12 +1008,13 @@ function useSpreadsheetGrid(options) {
|
|
|
963
1008
|
source: { top: source.r0, left: source.c0, bottom: source.r1, right: source.c1 },
|
|
964
1009
|
target
|
|
965
1010
|
});
|
|
966
|
-
|
|
967
|
-
|
|
1011
|
+
const screened = screenPatches(result.patches);
|
|
1012
|
+
void applyPatches(screened.accepted, "fill", "Filled");
|
|
1013
|
+
announceSkips([...result.skipped, ...screened.refusals], result.summary);
|
|
968
1014
|
};
|
|
969
1015
|
window.addEventListener("mouseup", commit);
|
|
970
1016
|
return () => window.removeEventListener("mouseup", commit);
|
|
971
|
-
}, [options, fillRequestBase, applyPatches, announceSkips]);
|
|
1017
|
+
}, [options, fillRequestBase, applyPatches, announceSkips, screenPatches]);
|
|
972
1018
|
return {
|
|
973
1019
|
range,
|
|
974
1020
|
bounds,
|
|
@@ -984,7 +1030,9 @@ function useSpreadsheetGrid(options) {
|
|
|
984
1030
|
isFillHandleCell,
|
|
985
1031
|
startFillDrag,
|
|
986
1032
|
canUndo: stack.past.length > 0,
|
|
987
|
-
canRedo: stack.future.length > 0
|
|
1033
|
+
canRedo: stack.future.length > 0,
|
|
1034
|
+
selectionTsv: selectionAsTsv,
|
|
1035
|
+
selectionAddresses
|
|
988
1036
|
};
|
|
989
1037
|
}
|
|
990
1038
|
export {
|