xontable 0.1.1
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/LICENSE +21 -0
- package/README.md +29 -0
- package/dist/XOnTable.d.ts +4 -0
- package/dist/XOnTable.d.ts.map +1 -0
- package/dist/XOnTable.js +182 -0
- package/dist/components/ColumnFilterMenu.d.ts +13 -0
- package/dist/components/ColumnFilterMenu.d.ts.map +1 -0
- package/dist/components/ColumnFilterMenu.js +7 -0
- package/dist/components/SelectMenu.d.ts +15 -0
- package/dist/components/SelectMenu.d.ts.map +1 -0
- package/dist/components/SelectMenu.js +38 -0
- package/dist/components/XOnTableGrid.d.ts +62 -0
- package/dist/components/XOnTableGrid.d.ts.map +1 -0
- package/dist/components/XOnTableGrid.js +42 -0
- package/dist/components/XOnTableHeader.d.ts +34 -0
- package/dist/components/XOnTableHeader.d.ts.map +1 -0
- package/dist/components/XOnTableHeader.js +7 -0
- package/dist/components/index.d.ts +5 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +4 -0
- package/dist/hooks/index.d.ts +14 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +13 -0
- package/dist/hooks/useAutoRows.d.ts +9 -0
- package/dist/hooks/useAutoRows.d.ts.map +1 -0
- package/dist/hooks/useAutoRows.js +41 -0
- package/dist/hooks/useClipboardCatcher.d.ts +15 -0
- package/dist/hooks/useClipboardCatcher.d.ts.map +1 -0
- package/dist/hooks/useClipboardCatcher.js +29 -0
- package/dist/hooks/useColumnFilters.d.ts +17 -0
- package/dist/hooks/useColumnFilters.d.ts.map +1 -0
- package/dist/hooks/useColumnFilters.js +95 -0
- package/dist/hooks/useColumnGroups.d.ts +27 -0
- package/dist/hooks/useColumnGroups.d.ts.map +1 -0
- package/dist/hooks/useColumnGroups.js +89 -0
- package/dist/hooks/useColumnResize.d.ts +12 -0
- package/dist/hooks/useColumnResize.d.ts.map +1 -0
- package/dist/hooks/useColumnResize.js +27 -0
- package/dist/hooks/useEditorOverlay.d.ts +24 -0
- package/dist/hooks/useEditorOverlay.d.ts.map +1 -0
- package/dist/hooks/useEditorOverlay.js +74 -0
- package/dist/hooks/useFillHandle.d.ts +16 -0
- package/dist/hooks/useFillHandle.d.ts.map +1 -0
- package/dist/hooks/useFillHandle.js +52 -0
- package/dist/hooks/useGridKeydown.d.ts +18 -0
- package/dist/hooks/useGridKeydown.d.ts.map +1 -0
- package/dist/hooks/useGridKeydown.js +109 -0
- package/dist/hooks/useOutsideClick.d.ts +7 -0
- package/dist/hooks/useOutsideClick.d.ts.map +1 -0
- package/dist/hooks/useOutsideClick.js +26 -0
- package/dist/hooks/useRangeSelection.d.ts +23 -0
- package/dist/hooks/useRangeSelection.d.ts.map +1 -0
- package/dist/hooks/useRangeSelection.js +48 -0
- package/dist/hooks/useSelectOptions.d.ts +13 -0
- package/dist/hooks/useSelectOptions.d.ts.map +1 -0
- package/dist/hooks/useSelectOptions.js +35 -0
- package/dist/hooks/useTableModel.d.ts +31 -0
- package/dist/hooks/useTableModel.d.ts.map +1 -0
- package/dist/hooks/useTableModel.js +135 -0
- package/dist/hooks/useValidation.d.ts +9 -0
- package/dist/hooks/useValidation.d.ts.map +1 -0
- package/dist/hooks/useValidation.js +42 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -0
- package/dist/types.d.ts +37 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/dist/utils/cellKey.d.ts +2 -0
- package/dist/utils/cellKey.d.ts.map +1 -0
- package/dist/utils/cellKey.js +3 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/tsv.d.ts +3 -0
- package/dist/utils/tsv.d.ts.map +1 -0
- package/dist/utils/tsv.js +9 -0
- package/package.json +36 -0
- package/src/styles/xontable.base.css +71 -0
- package/src/styles/xontable.css +3 -0
- package/src/styles/xontable.filter.css +65 -0
- package/src/styles/xontable.theme.css +42 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { CellPos } from "../types";
|
|
2
|
+
type Selection = {
|
|
3
|
+
start: CellPos;
|
|
4
|
+
end: CellPos;
|
|
5
|
+
};
|
|
6
|
+
type RangeSelectionApi = {
|
|
7
|
+
selection: Selection | null;
|
|
8
|
+
isSelecting: boolean;
|
|
9
|
+
startSelection: (pos: CellPos) => void;
|
|
10
|
+
updateSelection: (pos: CellPos) => void;
|
|
11
|
+
stopSelection: () => void;
|
|
12
|
+
clearSelection: () => void;
|
|
13
|
+
isSelected: (r: number, c: number) => boolean;
|
|
14
|
+
getBounds: () => {
|
|
15
|
+
r1: number;
|
|
16
|
+
r2: number;
|
|
17
|
+
c1: number;
|
|
18
|
+
c2: number;
|
|
19
|
+
} | null;
|
|
20
|
+
};
|
|
21
|
+
export declare function useRangeSelection(): RangeSelectionApi;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=useRangeSelection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRangeSelection.d.ts","sourceRoot":"","sources":["../../src/hooks/useRangeSelection.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAExC,KAAK,SAAS,GAAG;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,GAAG,EAAE,OAAO,CAAA;CAAE,CAAC;AAElD,KAAK,iBAAiB,GAAG;IACvB,SAAS,EAAE,SAAS,GAAG,IAAI,CAAC;IAC5B,WAAW,EAAE,OAAO,CAAC;IACrB,cAAc,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,eAAe,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAC;IACxC,aAAa,EAAE,MAAM,IAAI,CAAC;IAC1B,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,UAAU,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC;IAC9C,SAAS,EAAE,MAAM;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;CAC5E,CAAC;AAEF,wBAAgB,iBAAiB,IAAI,iBAAiB,CAoDrD"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { useCallback, useEffect, useState } from "react";
|
|
2
|
+
export function useRangeSelection() {
|
|
3
|
+
const [selection, setSelection] = useState(null);
|
|
4
|
+
const [isSelecting, setIsSelecting] = useState(false);
|
|
5
|
+
const startSelection = useCallback((pos) => {
|
|
6
|
+
setSelection({ start: pos, end: pos });
|
|
7
|
+
setIsSelecting(true);
|
|
8
|
+
}, []);
|
|
9
|
+
const updateSelection = useCallback((pos) => {
|
|
10
|
+
setSelection((prev) => (prev ? { ...prev, end: pos } : null));
|
|
11
|
+
}, []);
|
|
12
|
+
const stopSelection = useCallback(() => setIsSelecting(false), []);
|
|
13
|
+
const clearSelection = useCallback(() => setSelection(null), []);
|
|
14
|
+
const getBounds = useCallback(() => {
|
|
15
|
+
if (!selection)
|
|
16
|
+
return null;
|
|
17
|
+
const r1 = Math.min(selection.start.r, selection.end.r);
|
|
18
|
+
const r2 = Math.max(selection.start.r, selection.end.r);
|
|
19
|
+
const c1 = Math.min(selection.start.c, selection.end.c);
|
|
20
|
+
const c2 = Math.max(selection.start.c, selection.end.c);
|
|
21
|
+
return { r1, r2, c1, c2 };
|
|
22
|
+
}, [selection]);
|
|
23
|
+
const isSelected = useCallback((r, c) => {
|
|
24
|
+
if (!selection)
|
|
25
|
+
return false;
|
|
26
|
+
const b = getBounds();
|
|
27
|
+
if (!b)
|
|
28
|
+
return false;
|
|
29
|
+
return r >= b.r1 && r <= b.r2 && c >= b.c1 && c <= b.c2;
|
|
30
|
+
}, [getBounds, selection]);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if (!isSelecting)
|
|
33
|
+
return;
|
|
34
|
+
const onUp = () => setIsSelecting(false);
|
|
35
|
+
window.addEventListener("mouseup", onUp);
|
|
36
|
+
return () => window.removeEventListener("mouseup", onUp);
|
|
37
|
+
}, [isSelecting]);
|
|
38
|
+
return {
|
|
39
|
+
selection,
|
|
40
|
+
isSelecting,
|
|
41
|
+
startSelection,
|
|
42
|
+
updateSelection,
|
|
43
|
+
stopSelection,
|
|
44
|
+
clearSelection,
|
|
45
|
+
isSelected,
|
|
46
|
+
getBounds,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ColumnDef } from "../types";
|
|
2
|
+
type Option = {
|
|
3
|
+
value: string;
|
|
4
|
+
label: string;
|
|
5
|
+
};
|
|
6
|
+
type SelectOptionsResult<Row extends Record<string, any>> = {
|
|
7
|
+
getOptions: (row: Row, col: ColumnDef<Row>) => Option[];
|
|
8
|
+
ensureOptions: (row: Row, col: ColumnDef<Row>) => void;
|
|
9
|
+
isLoading: (row: Row, col: ColumnDef<Row>) => boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare function useSelectOptions<Row extends Record<string, any>>(columns: ColumnDef<Row>[]): SelectOptionsResult<Row>;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=useSelectOptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSelectOptions.d.ts","sourceRoot":"","sources":["../../src/hooks/useSelectOptions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,KAAK,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAE/C,KAAK,mBAAmB,CAAC,GAAG,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI;IAC1D,UAAU,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,SAAS,CAAC,GAAG,CAAC,KAAK,MAAM,EAAE,CAAC;IACxD,aAAa,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,SAAS,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC;IACvD,SAAS,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,SAAS,CAAC,GAAG,CAAC,KAAK,OAAO,CAAC;CACvD,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,GAAG,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC9D,OAAO,EAAE,SAAS,CAAC,GAAG,CAAC,EAAE,GACxB,mBAAmB,CAAC,GAAG,CAAC,CA4C1B"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { useCallback, useRef, useState } from "react";
|
|
2
|
+
export function useSelectOptions(columns) {
|
|
3
|
+
const cacheRef = useRef({});
|
|
4
|
+
const loadingRef = useRef({});
|
|
5
|
+
const [, bump] = useState(0);
|
|
6
|
+
const keyFor = useCallback((row, col) => {
|
|
7
|
+
const dep = col.dependsOn ? String(row[col.dependsOn] ?? "") : "";
|
|
8
|
+
const rid = String(row.id ?? row._id ?? "");
|
|
9
|
+
return `${rid}|${col.key}|${dep}`;
|
|
10
|
+
}, []);
|
|
11
|
+
const getOptions = useCallback((row, col) => {
|
|
12
|
+
if (col.options)
|
|
13
|
+
return col.options;
|
|
14
|
+
const key = keyFor(row, col);
|
|
15
|
+
return cacheRef.current[key] ?? [];
|
|
16
|
+
}, [keyFor]);
|
|
17
|
+
const isLoading = useCallback((row, col) => {
|
|
18
|
+
const key = keyFor(row, col);
|
|
19
|
+
return Boolean(loadingRef.current[key]);
|
|
20
|
+
}, [keyFor]);
|
|
21
|
+
const ensureOptions = useCallback((row, col) => {
|
|
22
|
+
if (col.options || !col.getOptions)
|
|
23
|
+
return;
|
|
24
|
+
const key = keyFor(row, col);
|
|
25
|
+
if (cacheRef.current[key] || loadingRef.current[key])
|
|
26
|
+
return;
|
|
27
|
+
loadingRef.current[key] = true;
|
|
28
|
+
col.getOptions(row).then((opts) => {
|
|
29
|
+
cacheRef.current[key] = opts ?? [];
|
|
30
|
+
loadingRef.current[key] = false;
|
|
31
|
+
bump((v) => v + 1);
|
|
32
|
+
});
|
|
33
|
+
}, [keyFor]);
|
|
34
|
+
return { getOptions, ensureOptions, isLoading };
|
|
35
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { CellPos, XOnTableMeta, ColumnDef } from "../types";
|
|
2
|
+
type CellUpdate = {
|
|
3
|
+
r: number;
|
|
4
|
+
c: number;
|
|
5
|
+
value: any;
|
|
6
|
+
};
|
|
7
|
+
type TableModelOptions<Row extends Record<string, any>> = {
|
|
8
|
+
columns: ColumnDef<Row>[];
|
|
9
|
+
rows: Row[];
|
|
10
|
+
rowFilter?: (row: Row, r: number) => boolean;
|
|
11
|
+
onChange?: (rows: Row[], meta: XOnTableMeta) => void;
|
|
12
|
+
createRow?: () => Row;
|
|
13
|
+
};
|
|
14
|
+
export declare function useTableModel<Row extends Record<string, any>>(options: TableModelOptions<Row>): {
|
|
15
|
+
data: Row[];
|
|
16
|
+
rawData: Row[];
|
|
17
|
+
active: CellPos;
|
|
18
|
+
setActive: import("react").Dispatch<import("react").SetStateAction<CellPos>>;
|
|
19
|
+
getValue: (r: number, c: number) => string;
|
|
20
|
+
updateCells: (updates: CellUpdate[], meta: XOnTableMeta) => void;
|
|
21
|
+
moveActive: (dr: number, dc: number) => void;
|
|
22
|
+
rowCount: number;
|
|
23
|
+
colCount: number;
|
|
24
|
+
hasError: (r: number, c: number) => boolean;
|
|
25
|
+
getError: (r: number, c: number) => string | null;
|
|
26
|
+
setCellErrorView: (r: number, c: number, msg: string | null) => void;
|
|
27
|
+
undo: () => void;
|
|
28
|
+
redo: () => void;
|
|
29
|
+
};
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=useTableModel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTableModel.d.ts","sourceRoot":"","sources":["../../src/hooks/useTableModel.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAGjE,KAAK,UAAU,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,GAAG,CAAA;CAAE,CAAC;AAEvD,KAAK,iBAAiB,CAAC,GAAG,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI;IACxD,OAAO,EAAE,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC;IAC1B,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC;IAC7C,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,YAAY,KAAK,IAAI,CAAC;IACrD,SAAS,CAAC,EAAE,MAAM,GAAG,CAAC;CACvB,CAAC;AAIF,wBAAgB,aAAa,CAAC,GAAG,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAC;;;;;kBAsB3D,MAAM,KAAK,MAAM;2BAgBR,UAAU,EAAE,QAAQ,YAAY;qBAoBtC,MAAM,MAAM,MAAM;;;kBAmBjB,MAAM,KAAK,MAAM;kBAIjB,MAAM,KAAK,MAAM;0BApDb,MAAM,KAAK,MAAM,OAAO,MAAM,GAAG,IAAI;;;EAwE/E"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
2
|
+
import { useValidation } from "./useValidation";
|
|
3
|
+
const clamp = (n, min, max) => Math.max(min, Math.min(max, n));
|
|
4
|
+
export function useTableModel(options) {
|
|
5
|
+
const { columns, rows, rowFilter, onChange } = options;
|
|
6
|
+
const createRow = options.createRow;
|
|
7
|
+
const colCount = columns.length;
|
|
8
|
+
const [data, setData] = useState(rows);
|
|
9
|
+
const dataRef = useRef(rows);
|
|
10
|
+
const historyRef = useRef({ past: [], future: [] });
|
|
11
|
+
const lastCellRef = useRef({ r: 0, c: 0 });
|
|
12
|
+
useEffect(() => { setData(rows); dataRef.current = rows; historyRef.current = { past: [], future: [] }; }, [rows]);
|
|
13
|
+
const [active, setActive] = useState({ r: 0, c: 0 });
|
|
14
|
+
const view = useMemo(() => {
|
|
15
|
+
const map = [];
|
|
16
|
+
const list = [];
|
|
17
|
+
dataRef.current.forEach((row, i) => { if (!rowFilter || rowFilter(row, i)) {
|
|
18
|
+
map.push(i);
|
|
19
|
+
list.push(row);
|
|
20
|
+
} });
|
|
21
|
+
return { map, list };
|
|
22
|
+
}, [rowFilter, data]);
|
|
23
|
+
const rowCount = view.list.length;
|
|
24
|
+
const getRow = useCallback((r) => {
|
|
25
|
+
const real = view.map[r];
|
|
26
|
+
return real == null ? undefined : dataRef.current[real];
|
|
27
|
+
}, [view.map]);
|
|
28
|
+
const getValue = useCallback((r, c) => {
|
|
29
|
+
const col = columns[c];
|
|
30
|
+
const real = view.map[r];
|
|
31
|
+
const row = real == null ? undefined : dataRef.current[real];
|
|
32
|
+
const v = row && col ? row[col.key] : "";
|
|
33
|
+
return v == null ? "" : String(v);
|
|
34
|
+
}, [columns, view.map]);
|
|
35
|
+
const { validateCell, setCellError, hasError, getError } = useValidation(columns, getRow, getValue);
|
|
36
|
+
const setCellErrorView = useCallback((r, c, msg) => {
|
|
37
|
+
const real = view.map[r];
|
|
38
|
+
if (real == null)
|
|
39
|
+
return;
|
|
40
|
+
setCellError(real, c, msg);
|
|
41
|
+
}, [setCellError, view.map]);
|
|
42
|
+
const commitRows = useCallback((next, meta, recordHistory, prev) => {
|
|
43
|
+
if (recordHistory) {
|
|
44
|
+
const h = historyRef.current;
|
|
45
|
+
h.past.push(prev);
|
|
46
|
+
h.future = [];
|
|
47
|
+
if (h.past.length > 50)
|
|
48
|
+
h.past.shift();
|
|
49
|
+
}
|
|
50
|
+
dataRef.current = next;
|
|
51
|
+
setData(next);
|
|
52
|
+
onChange?.(next, meta);
|
|
53
|
+
}, [onChange]);
|
|
54
|
+
const updateCells = useCallback((updates, meta) => {
|
|
55
|
+
if (updates.length === 0)
|
|
56
|
+
return;
|
|
57
|
+
const prev = dataRef.current;
|
|
58
|
+
const next = prev.map((r) => ({ ...r }));
|
|
59
|
+
let changed = false;
|
|
60
|
+
const map = [...view.map];
|
|
61
|
+
for (const u of updates) {
|
|
62
|
+
const col = columns[u.c];
|
|
63
|
+
let real = map[u.r];
|
|
64
|
+
if (real == null && createRow) {
|
|
65
|
+
real = next.length;
|
|
66
|
+
next.push(createRow());
|
|
67
|
+
map[u.r] = real;
|
|
68
|
+
}
|
|
69
|
+
const row = real == null ? undefined : next[real];
|
|
70
|
+
if (!col || !row || col.editable === false)
|
|
71
|
+
continue;
|
|
72
|
+
const nextRow = { ...row };
|
|
73
|
+
nextRow[col.key] = u.value;
|
|
74
|
+
next[real] = nextRow;
|
|
75
|
+
const err = validateCell(u.r, u.c, u.value, nextRow);
|
|
76
|
+
if (real != null)
|
|
77
|
+
setCellError(real, u.c, err);
|
|
78
|
+
changed = true;
|
|
79
|
+
lastCellRef.current = { r: u.r, c: u.c };
|
|
80
|
+
}
|
|
81
|
+
if (changed)
|
|
82
|
+
commitRows(next, meta, true, prev);
|
|
83
|
+
}, [columns, commitRows, createRow, setCellError, validateCell, view.map]);
|
|
84
|
+
const moveActive = useCallback((dr, dc) => {
|
|
85
|
+
setActive((prev) => {
|
|
86
|
+
if (rowCount === 0 || colCount === 0)
|
|
87
|
+
return prev;
|
|
88
|
+
return { r: clamp(prev.r + dr, 0, rowCount - 1), c: clamp(prev.c + dc, 0, colCount - 1) };
|
|
89
|
+
});
|
|
90
|
+
}, [colCount, rowCount]);
|
|
91
|
+
const undo = useCallback(() => {
|
|
92
|
+
const h = historyRef.current;
|
|
93
|
+
if (h.past.length === 0)
|
|
94
|
+
return;
|
|
95
|
+
const prev = h.past.pop();
|
|
96
|
+
h.future.push(dataRef.current);
|
|
97
|
+
dataRef.current = prev;
|
|
98
|
+
setData(prev);
|
|
99
|
+
onChange?.(prev, { type: "undo", cell: lastCellRef.current });
|
|
100
|
+
}, [onChange]);
|
|
101
|
+
const redo = useCallback(() => {
|
|
102
|
+
const h = historyRef.current;
|
|
103
|
+
if (h.future.length === 0)
|
|
104
|
+
return;
|
|
105
|
+
const next = h.future.pop();
|
|
106
|
+
h.past.push(dataRef.current);
|
|
107
|
+
dataRef.current = next;
|
|
108
|
+
setData(next);
|
|
109
|
+
onChange?.(next, { type: "redo", cell: lastCellRef.current });
|
|
110
|
+
}, [onChange]);
|
|
111
|
+
const hasErrorView = useCallback((r, c) => {
|
|
112
|
+
const real = view.map[r];
|
|
113
|
+
return real == null ? false : hasError(real, c);
|
|
114
|
+
}, [hasError, view.map]);
|
|
115
|
+
const getErrorView = useCallback((r, c) => {
|
|
116
|
+
const real = view.map[r];
|
|
117
|
+
return real == null ? null : getError(real, c);
|
|
118
|
+
}, [getError, view.map]);
|
|
119
|
+
return {
|
|
120
|
+
data: view.list,
|
|
121
|
+
rawData: dataRef.current,
|
|
122
|
+
active,
|
|
123
|
+
setActive,
|
|
124
|
+
getValue,
|
|
125
|
+
updateCells,
|
|
126
|
+
moveActive,
|
|
127
|
+
rowCount,
|
|
128
|
+
colCount,
|
|
129
|
+
hasError: hasErrorView,
|
|
130
|
+
getError: getErrorView,
|
|
131
|
+
setCellErrorView,
|
|
132
|
+
undo,
|
|
133
|
+
redo,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ColumnDef } from "../types";
|
|
2
|
+
export declare function useValidation<Row extends Record<string, any>>(columns: ColumnDef<Row>[], getRow: (r: number) => Row | undefined, getValue: (r: number, c: number) => string): {
|
|
3
|
+
errors: Record<string, string>;
|
|
4
|
+
validateCell: (r: number, c: number, nextValue?: string, rowOverride?: Row) => string | null;
|
|
5
|
+
setCellError: (r: number, c: number, msg: string | null) => void;
|
|
6
|
+
hasError: (r: number, c: number) => boolean;
|
|
7
|
+
getError: (r: number, c: number) => string;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=useValidation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useValidation.d.ts","sourceRoot":"","sources":["../../src/hooks/useValidation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,wBAAgB,aAAa,CAAC,GAAG,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC3D,OAAO,EAAE,SAAS,CAAC,GAAG,CAAC,EAAE,EACzB,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,GAAG,GAAG,SAAS,EACtC,QAAQ,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,MAAM;;sBAMnC,MAAM,KACN,MAAM,cACG,MAAM,gBACJ,GAAG;sBA0Bf,MAAM,KAAK,MAAM,OAAO,MAAM,GAAG,IAAI;kBAarC,MAAM,KAAK,MAAM;kBAOjB,MAAM,KAAK,MAAM;EAUxB"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { useCallback, useMemo, useState } from "react";
|
|
2
|
+
import { cellKey } from "../utils";
|
|
3
|
+
export function useValidation(columns, getRow, getValue) {
|
|
4
|
+
const [errors, setErrors] = useState({});
|
|
5
|
+
const validateCell = useCallback((r, c, nextValue, rowOverride) => {
|
|
6
|
+
const col = columns[c];
|
|
7
|
+
if (!col)
|
|
8
|
+
return null;
|
|
9
|
+
const raw = nextValue ?? getValue(r, c);
|
|
10
|
+
const value = raw == null ? "" : String(raw);
|
|
11
|
+
const rowObj = rowOverride ?? getRow(r);
|
|
12
|
+
// default simple validators by type (optional)
|
|
13
|
+
if (col.type === "number" && value.trim() !== "" && Number.isNaN(Number(value))) {
|
|
14
|
+
return "Must be a number";
|
|
15
|
+
}
|
|
16
|
+
if (col.type === "checkbox") {
|
|
17
|
+
const v = typeof nextValue === "boolean" ? String(nextValue) : value.trim().toLowerCase();
|
|
18
|
+
if (v !== "true" && v !== "false")
|
|
19
|
+
return "Must be true or false";
|
|
20
|
+
}
|
|
21
|
+
if (col.validator)
|
|
22
|
+
return col.validator(value, rowObj);
|
|
23
|
+
return null;
|
|
24
|
+
}, [columns, getRow, getValue]);
|
|
25
|
+
const setCellError = useCallback((r, c, msg) => {
|
|
26
|
+
const k = cellKey(r, c);
|
|
27
|
+
setErrors((prev) => {
|
|
28
|
+
const next = { ...prev };
|
|
29
|
+
if (!msg)
|
|
30
|
+
delete next[k];
|
|
31
|
+
else
|
|
32
|
+
next[k] = msg;
|
|
33
|
+
return next;
|
|
34
|
+
});
|
|
35
|
+
}, []);
|
|
36
|
+
const hasError = useCallback((r, c) => {
|
|
37
|
+
return Boolean(errors[cellKey(r, c)]);
|
|
38
|
+
}, [errors]);
|
|
39
|
+
const getError = useCallback((r, c) => errors[cellKey(r, c)] ?? null, [errors]);
|
|
40
|
+
const api = useMemo(() => ({ errors, validateCell, setCellError, hasError, getError }), [errors, validateCell, setCellError, hasError, getError]);
|
|
41
|
+
return api;
|
|
42
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,YAAY,EACV,aAAa,EACb,YAAY,EACZ,SAAS,EACT,UAAU,EACV,OAAO,GACR,MAAM,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { XOnTable } from "./XOnTable";
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export type CellPos = {
|
|
2
|
+
r: number;
|
|
3
|
+
c: number;
|
|
4
|
+
};
|
|
5
|
+
export type ColumnType = "text" | "number" | "date" | "select" | "checkbox";
|
|
6
|
+
export type ColumnDef<Row extends Record<string, any> = any> = {
|
|
7
|
+
key: string;
|
|
8
|
+
label: string;
|
|
9
|
+
width?: number;
|
|
10
|
+
group?: string;
|
|
11
|
+
groupCollapsible?: boolean;
|
|
12
|
+
type?: ColumnType;
|
|
13
|
+
options?: Array<{
|
|
14
|
+
value: string;
|
|
15
|
+
label: string;
|
|
16
|
+
}>;
|
|
17
|
+
getOptions?: (row: Row) => Promise<Array<{
|
|
18
|
+
value: string;
|
|
19
|
+
label: string;
|
|
20
|
+
}>>;
|
|
21
|
+
dependsOn?: string;
|
|
22
|
+
editable?: boolean;
|
|
23
|
+
validator?: (value: string, row: Row) => string | null;
|
|
24
|
+
};
|
|
25
|
+
export type XOnTableMeta = {
|
|
26
|
+
type: "edit" | "paste" | "fill" | "undo" | "redo";
|
|
27
|
+
cell: CellPos;
|
|
28
|
+
};
|
|
29
|
+
export type XOnTableProps<Row extends Record<string, any> = any> = {
|
|
30
|
+
columns: ColumnDef<Row>[];
|
|
31
|
+
rows: Row[];
|
|
32
|
+
rowIdKey?: keyof Row;
|
|
33
|
+
readOnly?: boolean;
|
|
34
|
+
theme?: "light" | "dark";
|
|
35
|
+
onChange?: (rows: Row[], meta: XOnTableMeta) => void;
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE/C,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,GAAG,UAAU,CAAC;AAE5E,MAAM,MAAM,SAAS,CAAC,GAAG,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,IAAI;IAC7D,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,OAAO,CAAC,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAClD,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,OAAO,CAAC,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAC;IAC5E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,KAAK,MAAM,GAAG,IAAI,CAAC;CACxD,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IAClD,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,aAAa,CAAC,GAAG,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,IAAI;IACjE,OAAO,EAAE,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC;IAC1B,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,GAAG,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,YAAY,KAAK,IAAI,CAAC;CACtD,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cellKey.d.ts","sourceRoot":"","sources":["../../src/utils/cellKey.ts"],"names":[],"mappings":"AAAA,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,UAE3C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tsv.d.ts","sourceRoot":"","sources":["../../src/utils/tsv.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,CAIjD;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,GAAG,MAAM,CAE/C"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function parseTSV(text) {
|
|
2
|
+
const lines = text.replace(/\r\n/g, "\n").replace(/\r/g, "\n").split("\n");
|
|
3
|
+
if (lines.length && lines[lines.length - 1] === "")
|
|
4
|
+
lines.pop();
|
|
5
|
+
return lines.map((line) => line.split("\t"));
|
|
6
|
+
}
|
|
7
|
+
export function toTSV(block) {
|
|
8
|
+
return block.map((row) => row.join("\t")).join("\n");
|
|
9
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "xontable",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"private": false,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./styles": "./src/styles/xontable.css"
|
|
15
|
+
},
|
|
16
|
+
"sideEffects": [
|
|
17
|
+
"./src/styles/xontable.css"
|
|
18
|
+
],
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"src/styles"
|
|
22
|
+
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "tsc -p tsconfig.json",
|
|
25
|
+
"clean": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\"",
|
|
26
|
+
"prepublishOnly": "npm run clean && npm run build"
|
|
27
|
+
},
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"react": "^19.0.0",
|
|
30
|
+
"react-dom": "^19.0.0",
|
|
31
|
+
"lucide-react": "^0.468.0"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"typescript": "^5.9.3"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
.xontable-wrap { display: block; width: 100%; height: 100%; border: 1px solid #e3e5ea; border-radius: 8px; overflow: hidden; background: #fff; --xontable-range: #1a73e8; --xontable-copy: #1a1a1a; }
|
|
2
|
+
.xontable-surface { outline: none; width: 100%; height: 100%; overflow: auto; scrollbar-width: thin; scrollbar-color: #b9c1cd transparent; }
|
|
3
|
+
.xontable-surface::-webkit-scrollbar { width: 8px; height: 8px; }
|
|
4
|
+
.xontable-surface::-webkit-scrollbar-thumb { background: #b9c1cd; border-radius: 999px; }
|
|
5
|
+
.xontable-surface::-webkit-scrollbar-track { background: transparent; }
|
|
6
|
+
.xontable { border: 0; display: inline-block; min-width: 100%; font-family: "Segoe UI", Tahoma, sans-serif; font-size: 13px; user-select: none; background: transparent; }
|
|
7
|
+
.xontable-row { display: flex; }
|
|
8
|
+
.xontable-cell { position: relative; height: 24px; border-right: 1px solid #e6e8ee; border-bottom: 1px solid #e6e8ee; display: flex; align-items: center; padding: 2px 6px 2px 8px; background: #fff; box-sizing: border-box; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
|
|
9
|
+
.xontable-cell.is-select { padding-right: 22px; }
|
|
10
|
+
.xontable-select-trigger { position: absolute; right: 4px; top: 50%; width: 16px; height: 16px; border: 0; background: transparent; display: flex; align-items: center; justify-content: center; padding: 0; cursor: pointer; transform: translateY(-50%); }
|
|
11
|
+
.xontable-select-trigger::after { content: ""; width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent; border-top: 5px solid #6b7280; transform: translateY(1px); opacity: 0.85; }
|
|
12
|
+
.xontable-cell.is-checkbox { justify-content: center; padding: 0; }
|
|
13
|
+
.xontable-checkbox { width: 14px; height: 14px; accent-color: #1a73e8; }
|
|
14
|
+
.xontable-measure { position: fixed; left: -9999px; top: -9999px; height: auto; font-family: "Segoe UI", Tahoma, sans-serif; font-size: 13px; overflow: visible; text-overflow: clip; white-space: nowrap; pointer-events: none; visibility: hidden; }
|
|
15
|
+
.xontable-head-cell { font-weight: 600; background: #f6f7f9; position: relative; gap: 6px; overflow: visible; }
|
|
16
|
+
.xontable-head-label { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; }
|
|
17
|
+
.xontable-rownum-cell { justify-content: center; color: #6b7280; background: #f7f7f9; font-weight: 600; }
|
|
18
|
+
.xontable-group-row { background: #f6f6f6; }
|
|
19
|
+
.xontable-group-cell { justify-content: space-between; gap: 6px; font-weight: 600; color: #333; background: #f6f6f6; }
|
|
20
|
+
.xontable-group-label { overflow: hidden; text-overflow: ellipsis; }
|
|
21
|
+
.xontable-group-toggle { width: 20px; height: 20px; min-width: 20px; min-height: 20px; border: 0; background: transparent; display: flex; align-items: center; justify-content: center; padding: 0; box-sizing: border-box; cursor: pointer; }
|
|
22
|
+
.xontable-group-toggle svg, .xontable-filter-btn svg { display: block; }
|
|
23
|
+
.xontable-col-resizer { position: absolute; top: 0; right: -3px; width: 6px; height: 100%; cursor: col-resize; }
|
|
24
|
+
.xontable-col-resizer::after { content: ""; position: absolute; left: 2px; top: 0; width: 2px; height: 100%; background: rgba(0, 0, 0, 0.08); }
|
|
25
|
+
.xontable-cell.is-active { outline: 2px solid #0b65d4; outline-offset: -2px; }
|
|
26
|
+
.xontable-cell.is-range { background: #eef9ee; --rs-top: 0px; --rs-right: 0px; --rs-bottom: 0px; --rs-left: 0px; box-shadow: inset 0 var(--rs-top) 0 0 var(--xontable-range), inset calc(var(--rs-right) * -1) 0 0 0 var(--xontable-range), inset 0 calc(var(--rs-bottom) * -1) 0 0 var(--xontable-range), inset var(--rs-left) 0 0 0 var(--xontable-range); }
|
|
27
|
+
.xontable-cell.is-range-top { --rs-top: 1px; }
|
|
28
|
+
.xontable-cell.is-range-right { --rs-right: 1px; }
|
|
29
|
+
.xontable-cell.is-range-bottom { --rs-bottom: 1px; }
|
|
30
|
+
.xontable-cell.is-range-left { --rs-left: 1px; }
|
|
31
|
+
.xontable-cell.is-copied-range { --ct: 0px; --cr: 0px; --cb: 0px; --cl: 0px; background-image: repeating-linear-gradient(90deg, var(--xontable-copy) 0 4px, transparent 4px 6px), repeating-linear-gradient(180deg, var(--xontable-copy) 0 4px, transparent 4px 6px), repeating-linear-gradient(90deg, var(--xontable-copy) 0 4px, transparent 4px 6px), repeating-linear-gradient(180deg, var(--xontable-copy) 0 4px, transparent 4px 6px); background-size: var(--ct) 2px, 2px var(--cr), var(--cb) 2px, 2px var(--cl); background-position: left top, right top, left bottom, left top; background-repeat: repeat-x, repeat-y, repeat-x, repeat-y; animation: xontable-march 0.8s linear infinite; opacity: 1; }
|
|
32
|
+
.xontable-cell.is-copied-top { --ct: 100%; }
|
|
33
|
+
.xontable-cell.is-copied-right { --cr: 100%; }
|
|
34
|
+
.xontable-cell.is-copied-bottom { --cb: 100%; }
|
|
35
|
+
.xontable-cell.is-copied-left { --cl: 100%; }
|
|
36
|
+
.xontable-cell.is-copied-top { border-top-color: transparent; }
|
|
37
|
+
.xontable-cell.is-copied-right { border-right-color: transparent; }
|
|
38
|
+
.xontable-cell.is-copied-bottom { border-bottom-color: transparent; }
|
|
39
|
+
.xontable-cell.is-copied-left { border-left-color: transparent; }
|
|
40
|
+
|
|
41
|
+
@keyframes xontable-march {
|
|
42
|
+
0% { background-position: 0 0, 100% 0, 0 100%, 0 0; }
|
|
43
|
+
100% { background-position: 6px 0, 100% 6px, 6px 100%, 0 6px; }
|
|
44
|
+
}
|
|
45
|
+
.xontable-head-cell.is-active-col-head,
|
|
46
|
+
.xontable-rownum-cell.is-active-rownum { background: #cfe3ff; }
|
|
47
|
+
.xontable-cell.is-invalid { background: #ffe5e5; border: 1px solid #d92d2d; box-shadow: inset 0 0 0 1px #d92d2d; }
|
|
48
|
+
.xontable-cell.is-invalid:hover { background: #ffd6d6; }
|
|
49
|
+
.xontable-cell.is-fill-preview { background: #e8f0fe; }
|
|
50
|
+
.xontable-fill-handle { position: absolute; width: 14px; height: 14px; right: -7px; bottom: -7px; background: #0b65d4; border: 1px solid #fff; border-radius: 4px; cursor: crosshair; }
|
|
51
|
+
.xontable-editor { box-sizing: border-box; border: 2px solid #1a73e8; padding: 2px 6px 2px 8px; font: inherit; background: #fff; outline: none; line-height: 1.2; }
|
|
52
|
+
.xontable-clip { position: fixed; left: -9999px; top: -9999px; width: 1px; height: 1px; opacity: 0; }
|
|
53
|
+
.xontable-select-menu { background: #fff; border: 1px solid #e1e4ea; box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12); border-radius: 4px; padding: 4px 0; z-index: 30; max-height: 220px; overflow: auto; }
|
|
54
|
+
.xontable-select-item { width: 100%; text-align: left; padding: 6px 10px; border: 0; background: transparent; cursor: pointer; font-size: 12px; }
|
|
55
|
+
.xontable-select-item:hover, .xontable-select-item.is-active { background: #e9f1ff; }
|
|
56
|
+
|
|
57
|
+
.xontable-wrap.is-readonly { background: #fff; border-color: #e4e7ec; }
|
|
58
|
+
.xontable-wrap.is-readonly .xontable { color: #222; }
|
|
59
|
+
.xontable-wrap.is-readonly .xontable-cell { border-right-color: transparent; border-left-color: transparent; border-bottom-color: #e6e8ee; background: #fff; }
|
|
60
|
+
.xontable-wrap.is-readonly .xontable-head-cell,
|
|
61
|
+
.xontable-wrap.is-readonly .xontable-rownum-cell,
|
|
62
|
+
.xontable-wrap.is-readonly .xontable-group-cell { background: #f4f6fb; color: #1f2a37; font-weight: 600; }
|
|
63
|
+
.xontable-wrap.is-readonly .xontable-head-label { letter-spacing: 0.1px; }
|
|
64
|
+
.xontable-wrap.is-readonly .xontable-rownum-cell { color: #556070; }
|
|
65
|
+
.xontable-wrap.is-readonly .xontable-row.is-zebra .xontable-cell { background: #f8f9fc; }
|
|
66
|
+
.xontable-wrap.is-readonly .xontable-row.is-zebra .xontable-rownum-cell { background: #f1f4f9; }
|
|
67
|
+
.xontable-wrap.is-readonly .xontable-cell.is-active { outline-color: #8bb6ff; }
|
|
68
|
+
.xontable-wrap.is-readonly .xontable-fill-handle { display: none; }
|
|
69
|
+
.xontable-wrap.is-readonly .xontable-select-trigger { display: none; }
|
|
70
|
+
.xontable-wrap.is-readonly .xontable-checkbox { accent-color: #49b86e; }
|
|
71
|
+
.xontable-wrap.is-readonly .xontable-cell.is-invalid { background: #ffecec; border-color: #e07a7a; box-shadow: inset 0 0 0 1px #e07a7a; }
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
.xontable-filter-btn {
|
|
2
|
+
width: 18px;
|
|
3
|
+
height: 18px;
|
|
4
|
+
border: 0;
|
|
5
|
+
background: transparent;
|
|
6
|
+
cursor: pointer;
|
|
7
|
+
display: inline-flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
justify-content: center;
|
|
10
|
+
padding: 0;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.xontable-filter-menu {
|
|
14
|
+
position: absolute;
|
|
15
|
+
top: 100%;
|
|
16
|
+
right: 0;
|
|
17
|
+
margin-top: 4px;
|
|
18
|
+
width: 190px;
|
|
19
|
+
background: #fff;
|
|
20
|
+
border: 1px solid #e6e6e6;
|
|
21
|
+
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
|
|
22
|
+
z-index: 20;
|
|
23
|
+
padding: 8px;
|
|
24
|
+
border-radius: 8px;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.xontable-filter-search {
|
|
28
|
+
width: 100%;
|
|
29
|
+
padding: 6px 8px;
|
|
30
|
+
border: 1px solid #e0e0e0;
|
|
31
|
+
border-radius: 6px;
|
|
32
|
+
font-size: 12px;
|
|
33
|
+
box-sizing: border-box;
|
|
34
|
+
margin-bottom: 6px;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.xontable-filter-actions {
|
|
38
|
+
display: flex;
|
|
39
|
+
gap: 6px;
|
|
40
|
+
margin-bottom: 6px;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.xontable-filter-toggle {
|
|
44
|
+
display: flex;
|
|
45
|
+
align-items: center;
|
|
46
|
+
gap: 6px;
|
|
47
|
+
font-size: 12px;
|
|
48
|
+
cursor: pointer;
|
|
49
|
+
user-select: none;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.xontable-filter-list {
|
|
53
|
+
max-height: 160px;
|
|
54
|
+
overflow: auto;
|
|
55
|
+
display: flex;
|
|
56
|
+
flex-direction: column;
|
|
57
|
+
gap: 4px;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.xontable-filter-item {
|
|
61
|
+
display: flex;
|
|
62
|
+
align-items: center;
|
|
63
|
+
gap: 6px;
|
|
64
|
+
font-size: 12px;
|
|
65
|
+
}
|