@zhenliang/sheet 0.0.1 → 0.0.2

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 (67) hide show
  1. package/dist/core/config.d.ts +13 -0
  2. package/dist/core/editor/cascaderEditor/index.d.ts +5 -0
  3. package/dist/core/editor/cascaderEditor/index.js +35 -55
  4. package/dist/core/editor/dateEditor/index.d.ts +4 -0
  5. package/dist/core/editor/index.d.ts +4 -0
  6. package/dist/core/editor/index.js +4 -0
  7. package/dist/core/editor/numberEditor/index.d.ts +4 -0
  8. package/dist/core/editor/selectEditor/index.d.ts +5 -0
  9. package/dist/core/editor/selectEditor/index.js +2 -2
  10. package/dist/core/reducers/index.d.ts +9 -0
  11. package/dist/core/reducers/keyboardReducer.d.ts +2 -0
  12. package/dist/core/reducers/mouseReducer.d.ts +2 -0
  13. package/dist/core/reducers/sideEffectReducer.d.ts +4 -0
  14. package/dist/core/reducers/stateReducer.d.ts +2 -0
  15. package/dist/core/sheet/Cell.d.ts +4 -0
  16. package/dist/core/sheet/Cell.js +4 -6
  17. package/dist/core/sheet/DataEditor.d.ts +3 -0
  18. package/dist/core/sheet/DefaultCell.d.ts +11 -0
  19. package/dist/core/sheet/DefaultRow.d.ts +11 -0
  20. package/dist/core/sheet/DefaultRowMapper.d.ts +8 -0
  21. package/dist/core/sheet/DefaultShell.d.ts +8 -0
  22. package/dist/core/sheet/Event.d.ts +5 -0
  23. package/dist/core/sheet/ValueViewer.d.ts +3 -0
  24. package/dist/core/sheet/index.d.ts +5 -0
  25. package/dist/core/sheet/useCellEvent.d.ts +3 -0
  26. package/dist/core/sheet/useContextMenu.d.ts +21 -0
  27. package/dist/core/sheet/useKeyBoardEvent.d.ts +3 -0
  28. package/dist/core/sheet/useMouseEvent.d.ts +3 -0
  29. package/dist/core/sheet/useVirtualList.d.ts +7 -0
  30. package/dist/core/shell/draggableShell/index.d.ts +6 -0
  31. package/dist/core/shell/tableShell.d.ts +6 -0
  32. package/dist/core/table/index.d.ts +4 -0
  33. package/dist/core/table/index.js +1 -1
  34. package/dist/core/table/useGroupConfig.d.ts +2 -0
  35. package/dist/core/table/useRowSelection.d.ts +1 -0
  36. package/dist/core/table/util.d.ts +8 -0
  37. package/dist/core/util.d.ts +55 -0
  38. package/dist/core/util.js +1 -0
  39. package/dist/core/viewer/checkViewer/index.d.ts +2 -0
  40. package/dist/core/viewer/groupViewer/index.d.ts +2 -0
  41. package/dist/example/basic.d.ts +4 -0
  42. package/dist/example/ellipsis.d.ts +3 -0
  43. package/dist/example/fixed.d.ts +3 -0
  44. package/dist/example/group.d.ts +3 -0
  45. package/dist/example/selection.d.ts +4 -0
  46. package/dist/example/sheet.d.ts +4 -0
  47. package/dist/hooks/index.d.ts +7 -0
  48. package/dist/hooks/useEventBus.d.ts +4 -0
  49. package/dist/hooks/useKeyboard.d.ts +18 -0
  50. package/dist/hooks/useMiddlewareReducer.d.ts +12 -0
  51. package/dist/hooks/useMouse.d.ts +11 -0
  52. package/dist/hooks/useSetState.d.ts +2 -0
  53. package/dist/hooks/useSheetEvent.d.ts +5 -0
  54. package/dist/index.d.ts +4 -0
  55. package/dist/index.js +2 -1
  56. package/dist/standardUtils/index.d.ts +9 -0
  57. package/dist/type/index.d.ts +2 -0
  58. package/dist/type/index.js +4 -0
  59. package/dist/type/sheet.d.ts +188 -0
  60. package/dist/type/sheet.js +1 -0
  61. package/dist/type/sheetTable.d.ts +53 -0
  62. package/dist/type/sheetTable.js +1 -0
  63. package/package.json +4 -4
  64. package/dist/core/shell/resizeShell.js +0 -57
  65. package/dist/example/draggable.js +0 -0
  66. package/dist/typings/sheet.d.ts +0 -209
  67. package/dist/typings/table.js +0 -0
@@ -0,0 +1,13 @@
1
+ export declare const TAB_KEY = 9;
2
+ export declare const ENTER_KEY = 13;
3
+ export declare const ESCAPE_KEY = 27;
4
+ export declare const LEFT_KEY = 37;
5
+ export declare const UP_KEY = 38;
6
+ export declare const RIGHT_KEY = 39;
7
+ export declare const DOWN_KEY = 40;
8
+ export declare const DELETE_KEY = 46;
9
+ export declare const BACKSPACE_KEY = 8;
10
+ export declare const Z_KEY = 90;
11
+ export declare const C_KEY = 67;
12
+ export declare const V_KEY = 86;
13
+ export declare const X_KEY = 88;
@@ -0,0 +1,5 @@
1
+ import type { SheetType } from "../../../type";
2
+ import 'antd/es/cascader/style/index.css';
3
+ import './index.less';
4
+ declare const getCascaderEditor: (options: SheetType.OptionsType[]) => void;
5
+ export default getCascaderEditor;
@@ -4,60 +4,40 @@ import { useMemo } from 'react';
4
4
  import { optionsTransferToValue } from "../../util";
5
5
  import "./index.less";
6
6
  import { jsx as _jsx } from "react/jsx-runtime";
7
- var options = [{
8
- value: 'zhejiang',
9
- label: 'Zhejiang',
10
- children: [{
11
- value: 'hangzhou',
12
- label: 'Hangzhou',
13
- children: [{
14
- value: 'West Lake',
15
- label: 'West Lake'
16
- }]
17
- }]
18
- }, {
19
- value: 'jiangsu',
20
- label: 'Jiangsu',
21
- children: [{
22
- value: 'nanjing',
23
- label: 'Nanjing',
24
- children: [{
25
- value: 'Zhong Hua Men',
26
- label: 'Zhong Hua Men'
27
- }]
28
- }]
29
- }];
30
- export var CascaderEditor = function CascaderEditor(props) {
31
- var value = props.value,
32
- onConfirm = props.onConfirm;
33
- var val = useMemo(function () {
34
- return optionsTransferToValue(options, value);
35
- }, [value, options]);
36
- var handleChange = function handleChange(opt) {
37
- console.log(opt);
38
- onConfirm(opt ? opt[opt.length - 1] : null);
7
+ var getCascaderEditor = function getCascaderEditor(options) {
8
+ var CascaderEditor = function CascaderEditor(props) {
9
+ var value = props.value,
10
+ onConfirm = props.onConfirm;
11
+ var val = useMemo(function () {
12
+ return optionsTransferToValue(options, value);
13
+ }, [value, options]);
14
+ var handleChange = function handleChange(opt) {
15
+ console.log(opt);
16
+ onConfirm(opt ? opt[opt.length - 1] : null);
17
+ };
18
+ return /*#__PURE__*/_jsx(Cascader, {
19
+ autoFocus: true,
20
+ open: true,
21
+ className: 'cascader-editor',
22
+ onMouseDown: function onMouseDown(event) {
23
+ event.stopPropagation();
24
+ },
25
+ value: val
26
+ // allowClear={false}
27
+ ,
28
+ displayRender: function displayRender(label) {
29
+ return label[label.length - 1];
30
+ },
31
+ onChange: handleChange
32
+ // onBlur={handleBlur}
33
+ // onKeyDown={handleKeyDown}
34
+ ,
35
+ options: options
36
+ });
37
+ };
38
+ CascaderEditor.checker = function (value) {
39
+ var res = optionsTransferToValue(options, value);
40
+ return res && res.length > 0;
39
41
  };
40
- return /*#__PURE__*/_jsx(Cascader, {
41
- autoFocus: true,
42
- open: true,
43
- className: 'cascader-editor',
44
- onMouseDown: function onMouseDown(event) {
45
- event.stopPropagation();
46
- },
47
- value: val
48
- // allowClear={false}
49
- ,
50
- displayRender: function displayRender(label) {
51
- return label[label.length - 1];
52
- },
53
- onChange: handleChange
54
- // onBlur={handleBlur}
55
- // onKeyDown={handleKeyDown}
56
- ,
57
- options: options
58
- });
59
42
  };
60
- CascaderEditor.checker = function (value) {
61
- var res = optionsTransferToValue(options, value);
62
- return res && res.length > 0;
63
- };
43
+ export default getCascaderEditor;
@@ -0,0 +1,4 @@
1
+ import 'antd/es/date-picker/style/index.css';
2
+ import type { SheetType } from "../../../type";
3
+ import './index.less';
4
+ export declare const DateEditor: SheetType.CellEditor;
@@ -0,0 +1,4 @@
1
+ export { default as getCascaderEditor } from './cascaderEditor';
2
+ export { DateEditor } from './dateEditor';
3
+ export { NumberEditor } from './numberEditor';
4
+ export { default as getSelectEditor } from './selectEditor';
@@ -0,0 +1,4 @@
1
+ export { default as getCascaderEditor } from "./cascaderEditor";
2
+ export { DateEditor } from "./dateEditor";
3
+ export { NumberEditor } from "./numberEditor";
4
+ export { default as getSelectEditor } from "./selectEditor";
@@ -0,0 +1,4 @@
1
+ import type { SheetType } from "../../../type";
2
+ import 'antd/es/input-number/style/index.css';
3
+ import './index.less';
4
+ export declare const NumberEditor: SheetType.CellEditor;
@@ -0,0 +1,5 @@
1
+ import type { SheetType } from "../../../type";
2
+ import 'antd/es/select/style/index.css';
3
+ import './index.less';
4
+ export declare const getSelectEditor: (options: any) => SheetType.CellEditor;
5
+ export default getSelectEditor;
@@ -2,7 +2,7 @@ import { Select } from 'antd';
2
2
  import 'antd/es/select/style/index.css';
3
3
  import "./index.less";
4
4
  import { jsx as _jsx } from "react/jsx-runtime";
5
- export var GetSelectEditor = function GetSelectEditor(options) {
5
+ export var getSelectEditor = function getSelectEditor(options) {
6
6
  var SelectEditor = function SelectEditor(props) {
7
7
  var value = props.value,
8
8
  onConfirm = props.onConfirm;
@@ -41,4 +41,4 @@ export var GetSelectEditor = function GetSelectEditor(options) {
41
41
  };
42
42
  return SelectEditor;
43
43
  };
44
- export default GetSelectEditor;
44
+ export default getSelectEditor;
@@ -0,0 +1,9 @@
1
+ import type { SheetType } from "../../type";
2
+ export declare type SheetAction = 'change' | 'changes' | 'rowMove' | 'colMove' | 'editFinish' | 'pushHistory' | 'selectRow' | 'clearSelect' | 'clearSelectIfNotSingleRow' | 'clearEdit' | 'mouseDown' | 'mouseOver' | 'mouseUp' | 'loseFocus' | 'doubleClick' | 'mouseLeaveInterval' | 'move' | 'escape' | 'reverse' | 'delete' | 'enter' | 'otherInput' | 'none';
3
+ export declare type reducerAction = (type: Partial<SheetType.UpdateStateType>, payload?: unknown) => Partial<SheetType.UpdateStateType>;
4
+ declare const sheetReducer: (state: Partial<SheetType.UpdateStateType>, action: {
5
+ type: SheetAction;
6
+ payload?: unknown;
7
+ }) => Partial<SheetType.UpdateStateType>;
8
+ export default sheetReducer;
9
+ export { sideEffectReducer } from './sideEffectReducer';
@@ -0,0 +1,2 @@
1
+ import { reducerAction } from '.';
2
+ export declare const keyboardReducer: Record<string, reducerAction>;
@@ -0,0 +1,2 @@
1
+ import { reducerAction } from '.';
2
+ export declare const mouseReducer: Record<string, reducerAction>;
@@ -0,0 +1,4 @@
1
+ import type { SheetType } from "../../type";
2
+ import { FunctionAction, NormalAction } from '../../hooks';
3
+ export declare type asyncActionType = (dispatch: (action: NormalAction | FunctionAction) => void, getState: () => SheetType.UpdateStateType) => void;
4
+ export declare const sideEffectReducer: Record<string, asyncActionType>;
@@ -0,0 +1,2 @@
1
+ import { reducerAction } from '.';
2
+ export declare const stateReducer: Record<string, reducerAction>;
@@ -0,0 +1,4 @@
1
+ import type { SheetType } from "../../type";
2
+ import React from 'react';
3
+ declare const _default: React.MemoExoticComponent<(props: SheetType.CellProps) => import("react/jsx-runtime").JSX.Element>;
4
+ export default _default;
@@ -13,10 +13,8 @@ import DefaultCell from "./DefaultCell";
13
13
  import ValueViewer from "./ValueViewer";
14
14
  import { jsx as _jsx } from "react/jsx-runtime";
15
15
  function initialData(_ref) {
16
- var cell = _ref.cell,
17
- row = _ref.row,
18
- col = _ref.col;
19
- return renderValue(cell, row, col);
16
+ var cell = _ref.cell;
17
+ return renderValue(cell);
20
18
  }
21
19
  function widthStyle(cell) {
22
20
  var width = typeof (cell === null || cell === void 0 ? void 0 : cell.width) === 'number' ? "".concat(cell.width, "px") : cell.width;
@@ -57,7 +55,7 @@ var Cell = function Cell(props) {
57
55
  setValue = _useState2[1];
58
56
  var valueRef = useRef(value);
59
57
  useEffect(function () {
60
- var newValue = renderValue(cell, row, col);
58
+ var newValue = renderValue(cell);
61
59
  setValue(newValue);
62
60
  valueRef.current = newValue;
63
61
  }, [cell, row, col]);
@@ -127,7 +125,7 @@ var Cell = function Cell(props) {
127
125
  };
128
126
  var renderViewer = function renderViewer(cel, r, col, valViewer) {
129
127
  var Viewer = cell.valueViewer || valViewer || ValueViewer;
130
- var val = renderValue(cell, row, col);
128
+ var val = renderValue(cell);
131
129
  return /*#__PURE__*/_jsx(Viewer, {
132
130
  record: cell.record,
133
131
  cell: cell,
@@ -0,0 +1,3 @@
1
+ import type { SheetType } from "../../type";
2
+ declare const DataEditor: SheetType.CellEditor;
3
+ export default DataEditor;
@@ -0,0 +1,11 @@
1
+ import type { SheetType } from "../../type";
2
+ declare const DefaultCell: (props: {
3
+ cell: SheetType.Cell;
4
+ row: number;
5
+ col: number;
6
+ attributesRenderer?: SheetType.AttributesRenderer | undefined;
7
+ className: string;
8
+ style: Record<string, string>;
9
+ children: React.ReactElement;
10
+ }) => import("react/jsx-runtime").JSX.Element;
11
+ export default DefaultCell;
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ import type { SheetType } from "../../type";
3
+ declare const DefaultRow: React.FC<{
4
+ children: React.ReactElement;
5
+ row: number;
6
+ groupConfig?: {
7
+ groups: SheetType.RowGroup[];
8
+ groupOpen: boolean[];
9
+ };
10
+ }>;
11
+ export default DefaultRow;
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ import type { SheetType } from "../../type";
3
+ interface DefaultRowMapperProps {
4
+ rowData: SheetType.Cell[];
5
+ row: number;
6
+ }
7
+ export declare const DefaultRowMapper: React.FC<DefaultRowMapperProps>;
8
+ export {};
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ interface IShell {
3
+ children: React.ReactElement;
4
+ data?: unknown;
5
+ className?: string;
6
+ }
7
+ declare const DefaultShell: React.FC<IShell>;
8
+ export default DefaultShell;
@@ -0,0 +1,5 @@
1
+ import { FC } from 'react';
2
+ export declare const SheetEvent: FC<{
3
+ handler: (value: unknown) => void;
4
+ name: string;
5
+ }>;
@@ -0,0 +1,3 @@
1
+ import type { SheetType } from "../../type";
2
+ declare const ValueViewer: SheetType.CellViewer;
3
+ export default ValueViewer;
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ import type { SheetType } from "../../type";
3
+ import './index.less';
4
+ declare const Sheet: React.FC<SheetType.SheetProps>;
5
+ export default Sheet;
@@ -0,0 +1,3 @@
1
+ import { Dispatch } from "../../hooks/useMiddlewareReducer";
2
+ import type { SheetType } from "../../type";
3
+ export declare const useCellEvent: (dispatch: Dispatch, listenerVar?: Partial<SheetType.UpdateStateType>) => void;
@@ -0,0 +1,21 @@
1
+ import { Dispatch } from "../../hooks";
2
+ import type { SheetType } from "../../type";
3
+ export declare type MenuEvent = {
4
+ showMenu: boolean;
5
+ position: {
6
+ top: number;
7
+ left: number;
8
+ };
9
+ cellPosition: SheetType.CellPosition;
10
+ };
11
+ export declare const useContextMenu: (dispatch: Dispatch, elementRef: React.RefObject<SheetType.refAssertion>, enableContextMenu: boolean | undefined, contextMenuRef: React.RefObject<HTMLDivElement>) => {
12
+ showMenu: boolean;
13
+ position: {
14
+ top: number;
15
+ left: number;
16
+ };
17
+ cellPosition: {
18
+ row: number;
19
+ col: number;
20
+ };
21
+ };
@@ -0,0 +1,3 @@
1
+ import { Dispatch } from "../../hooks/useMiddlewareReducer";
2
+ import type { SheetType } from "../../type";
3
+ export declare const useKeyBoardEvent: (dispatch: Dispatch, elementRef: React.RefObject<SheetType.refAssertion>) => void;
@@ -0,0 +1,3 @@
1
+ import { Dispatch } from "../../hooks/useMiddlewareReducer";
2
+ import type { SheetType } from "../../type";
3
+ export declare const useMouseEvent: (dispatch: Dispatch, elementRef: React.RefObject<SheetType.refAssertion>) => void;
@@ -0,0 +1,7 @@
1
+ import type { SheetType } from "../../type";
2
+ export declare const useVirtualList: (elementRef: React.RefObject<SheetType.refAssertion>, data?: SheetType.Cell[][], virtualized?: boolean) => {
3
+ virtualStart: number;
4
+ virtualEnd: number;
5
+ paddingTop: number;
6
+ paddingBottom: number;
7
+ };
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ import type { SheetType } from "../../../type";
3
+ import './index.less';
4
+ export declare const DraggableShell: ({ columns, className, showGroup, showSelect, controlProps, controlWidth, }: SheetType.SheetShell) => import("react").FC<{
5
+ children: React.ReactElement;
6
+ }>;
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ import type { SheetType } from "../../type";
3
+ import './draggableShell/index.less';
4
+ export declare const TableShell: ({ columns, className, showGroup, showSelect, controlProps, controlWidth, }: SheetType.SheetShell) => import("react").FC<{
5
+ children: React.ReactElement;
6
+ }>;
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import type { SheetTableType } from "../../type";
3
+ declare const Table: React.FC<SheetTableType.TableProps>;
4
+ export default Table;
@@ -17,8 +17,8 @@ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefine
17
17
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
18
18
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
19
19
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
20
+ import { Sheet } from "../..";
20
21
  import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
21
- import Sheet from "../sheet";
22
22
  import { SheetEvent } from "../sheet/Event";
23
23
  import { DraggableShell } from "../shell/draggableShell";
24
24
  import { TableShell } from "../shell/tableShell";
@@ -0,0 +1,2 @@
1
+ import type { SheetTableType, SheetType } from "../../type";
2
+ export declare const useGroupConfig: (dataSource: Record<string, unknown>[], tableGroupConfig?: SheetTableType.TableGroupConfig, hasChildren?: boolean) => [SheetType.RowGroupConfig, (value: SheetType.RowGroupConfig) => void];
@@ -0,0 +1 @@
1
+ export declare const useRowSelection: (dataSource: Record<string, unknown>[], rowSelection?: any, hasChildren?: boolean) => [boolean[], (value: boolean[]) => void];
@@ -0,0 +1,8 @@
1
+ export declare const dataSourceToRowConfig: (dataSource: Record<string, unknown>[], defaultOpen?: boolean) => {
2
+ groups: {
3
+ groupStart: number;
4
+ groupEnd: number;
5
+ groupName: string;
6
+ }[];
7
+ groupOpen: boolean[];
8
+ };
@@ -0,0 +1,55 @@
1
+ import type { SheetType } from "../type";
2
+ export declare function findParentTd(el: HTMLElement): HTMLElement | null;
3
+ export declare function extractDataRowAndCol(el: HTMLElement): {
4
+ row: number;
5
+ col: number;
6
+ };
7
+ export declare function getRowColConfig(start?: SheetType.CellPosition, end?: SheetType.CellPosition): {
8
+ startRow: number;
9
+ endRow: number;
10
+ startCol: number;
11
+ endCol: number;
12
+ };
13
+ export declare function flatRowColIndex(start?: SheetType.CellPosition, end?: SheetType.CellPosition): SheetType.CellPosition[];
14
+ export declare function flatRowCol(start?: SheetType.CellPosition, end?: SheetType.CellPosition): string[];
15
+ export declare function isInputKey(keyCode: number): boolean;
16
+ export declare function classNames(...args: (string | null | undefined)[]): string;
17
+ export declare function stringToClipboardData(str: string): void;
18
+ export declare const defaultParsePaste: (str: string) => string[][];
19
+ export declare function clipboardDataToString(): Promise<string[][]>;
20
+ export declare function formatDataToCell({ start, editing, end, data, pasteData, groupConfig, freePaste, }: Partial<SheetType.UpdateStateType> & {
21
+ pasteData: string[][];
22
+ freePaste: boolean;
23
+ }): {
24
+ changes: SheetType.CellData[];
25
+ extChanges?: undefined;
26
+ } | {
27
+ changes: SheetType.CellData[];
28
+ extChanges: SheetType.CellData[] | undefined;
29
+ } | undefined;
30
+ export declare const defaultValueRenderer: (cell: SheetType.Cell) => string | number | null | undefined;
31
+ export declare function renderValue(cell: SheetType.Cell): string | number;
32
+ export declare const optionsTransferToValue: (options: SheetType.OptionsType[], val: string) => string[];
33
+ export declare const groupConfigToGroupMap: (rowGroupConfig?: SheetType.RowGroupConfig) => Map<number, SheetType.RowGroup & {
34
+ isStart: boolean;
35
+ isOpen: boolean;
36
+ }>;
37
+ export declare const changeGroupConfig: (rowGroupConfig: SheetType.RowGroupConfig, changeInfo: {
38
+ add?: number | undefined;
39
+ remove?: number | undefined;
40
+ }) => SheetType.RowGroupConfig;
41
+ export declare const rowToActualRow: (row: number, groupConfig?: SheetType.RowGroupConfig) => number;
42
+ export declare const getRowHeight: (container: HTMLSpanElement) => number;
43
+ export declare const getNextVisibleRow: (row: number, maxRow: number, groupMap?: Map<number, SheetType.RowGroup & {
44
+ isStart: boolean;
45
+ isOpen: boolean;
46
+ }>) => number | null;
47
+ export declare const calcMenuPosition: ({ tableElement, menuElement, x, y, }: {
48
+ tableElement: SheetType.refAssertion | null;
49
+ menuElement?: Element | null | undefined;
50
+ x: number;
51
+ y: number;
52
+ }) => {
53
+ top: number;
54
+ left: number;
55
+ };
package/dist/core/util.js CHANGED
@@ -12,6 +12,7 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToAr
12
12
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
13
13
  /* eslint-disable no-param-reassign */
14
14
  /* eslint-disable @typescript-eslint/no-use-before-define */
15
+
15
16
  import { cloneDeep, isNil, range } from 'lodash';
16
17
  export function findParentTd(el) {
17
18
  if (!el) return null;
@@ -0,0 +1,2 @@
1
+ import type { SheetType } from "../../../type";
2
+ export declare const CheckViewer: SheetType.CellViewer;
@@ -0,0 +1,2 @@
1
+ import type { SheetType } from "../../../type";
2
+ export declare const GroupViewer: SheetType.CellViewer;
@@ -0,0 +1,4 @@
1
+ import 'antd/dist/antd.css';
2
+ import React from 'react';
3
+ declare const App: React.FC;
4
+ export default App;
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const App: React.FC;
3
+ export default App;
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const App: React.FC;
3
+ export default App;
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ declare const App: React.FC;
3
+ export default App;
@@ -0,0 +1,4 @@
1
+ import 'antd/dist/antd.css';
2
+ import React from 'react';
3
+ declare const App: React.FC;
4
+ export default App;
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import './index.less';
3
+ declare const BasicSheet: React.FC;
4
+ export default BasicSheet;
@@ -0,0 +1,7 @@
1
+ export { useEventBus } from './useEventBus';
2
+ export { useKeyBoard } from './useKeyboard';
3
+ export { useMiddlewareReducer } from './useMiddlewareReducer';
4
+ export type { Dispatch, FunctionAction, NormalAction, } from './useMiddlewareReducer';
5
+ export { useMouse } from './useMouse';
6
+ export { useSetState } from './useSetState';
7
+ export { SheetEventContext, useSheetEvent } from './useSheetEvent';
@@ -0,0 +1,4 @@
1
+ /// <reference types="node" />
2
+ import EventEmitter from 'events';
3
+ declare const useEventBus: () => EventEmitter;
4
+ export { useEventBus };
@@ -0,0 +1,18 @@
1
+ declare type KeyOrClipBoardEvent = (event: KeyboardEvent | ClipboardEvent, value?: any) => void;
2
+ declare type KeyboardHandler = {
3
+ move: KeyOrClipBoardEvent;
4
+ escape: KeyOrClipBoardEvent;
5
+ delete: KeyOrClipBoardEvent;
6
+ enter: KeyOrClipBoardEvent;
7
+ otherInput: KeyOrClipBoardEvent;
8
+ copy: KeyOrClipBoardEvent;
9
+ paste: KeyOrClipBoardEvent;
10
+ reverse: KeyOrClipBoardEvent;
11
+ cut: KeyOrClipBoardEvent;
12
+ };
13
+ export declare function move(keyCode: number, isShiftKey: boolean): {
14
+ row: number;
15
+ col: number;
16
+ } | undefined;
17
+ export declare const useKeyBoard: (handler: KeyboardHandler, listenElement: HTMLSpanElement | null) => void;
18
+ export {};
@@ -0,0 +1,12 @@
1
+ export declare type NormalAction = {
2
+ type: string;
3
+ payload?: any;
4
+ };
5
+ export declare type FunctionAction = (dispatch: any, getState?: () => any) => any;
6
+ export declare type Dispatch = (action: any) => any;
7
+ export declare type MiddlewareAPI<A> = {
8
+ getState: () => A;
9
+ dispatch: Dispatch;
10
+ };
11
+ export declare type Middleware<A> = (api: MiddlewareAPI<A>) => (next: Dispatch) => Dispatch;
12
+ export declare const useMiddlewareReducer: <A, B>(reducer: (state: A, action: B) => A, initialState: A, middleware?: Middleware<A>[]) => [A, Dispatch];
@@ -0,0 +1,11 @@
1
+ declare type MouseHandler = {
2
+ mouseUp: (value: MouseEvent) => void;
3
+ mouseDown: (value: MouseEvent) => void;
4
+ mouseOver: (value: MouseEvent) => void;
5
+ mouseLeave: (value: MouseEvent) => void;
6
+ mouseEnter: (value: MouseEvent) => void;
7
+ doubleClick: (value: MouseEvent) => void;
8
+ loseFocus: (value: MouseEvent) => void;
9
+ };
10
+ export declare const useMouse: (handler: MouseHandler, listenElement: HTMLSpanElement | null) => void;
11
+ export {};
@@ -0,0 +1,2 @@
1
+ declare const useSetState: <T extends object>(initialState?: T) => [T, (patch: Partial<T> | ((prevState: T) => Partial<T>)) => void];
2
+ export { useSetState };
@@ -0,0 +1,5 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="react" />
3
+ import Events from 'events';
4
+ export declare const SheetEventContext: import("react").Context<Events | undefined>;
5
+ export declare function useSheetEvent(): Events;
@@ -0,0 +1,4 @@
1
+ export * from './core/editor';
2
+ export { default as Sheet } from './core/sheet';
3
+ export { default as Table } from './core/table';
4
+ export { useSheetEvent } from './hooks/useSheetEvent';
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ export * from "./core/editor";
1
2
  export { default as Sheet } from "./core/sheet";
2
3
  export { default as Table } from "./core/table";
3
- // export { default as Excel } from './historyComponent/ExcelTable';
4
+ export { useSheetEvent } from "./hooks/useSheetEvent";
@@ -0,0 +1,9 @@
1
+ declare type ValueParams = string | number | null | undefined;
2
+ export declare const formatPrecision: (value: ValueParams, precision?: number) => string;
3
+ /**
4
+ * 千位分隔符
5
+ * @param value 需要千分符格式化的数据
6
+ * @returns 含千分符的字符串
7
+ */
8
+ export declare const thousandsSeparator: (value: string | number) => string;
9
+ export {};
@@ -0,0 +1,2 @@
1
+ export * as SheetType from './sheet';
2
+ export * as SheetTableType from './sheetTable';
@@ -0,0 +1,4 @@
1
+ import * as _SheetType from "./sheet";
2
+ export { _SheetType as SheetType };
3
+ import * as _SheetTableType from "./sheetTable";
4
+ export { _SheetTableType as SheetTableType };
@@ -0,0 +1,188 @@
1
+ /// <reference types="react" />
2
+ /// <reference types="node" />
3
+ import type { EventEmitter } from 'events';
4
+ import { SheetTableType } from '.';
5
+ export declare type Cell = {
6
+ id: string;
7
+ key?: string;
8
+ readonly?: boolean;
9
+ component?: CellViewer;
10
+ editable?: boolean;
11
+ colSpan?: number;
12
+ rowSpan?: number;
13
+ width?: number;
14
+ record?: Record<string, unknown>;
15
+ disableEvents?: boolean;
16
+ dataEditor?: CellEditor;
17
+ valueViewer?: CellViewer;
18
+ className?: string;
19
+ align?: 'left' | 'center' | 'right';
20
+ fixed?: 'left' | 'right';
21
+ value?: string | number | null;
22
+ };
23
+ export declare type CellEditorProps = {
24
+ value: unknown;
25
+ cell?: Cell;
26
+ onChange: (value: unknown) => void;
27
+ onConfirm: (value: unknown) => void;
28
+ };
29
+ export declare type CellViewerProps = {
30
+ value: unknown;
31
+ record?: Record<string, unknown>;
32
+ row: number;
33
+ col: number;
34
+ cell?: Cell;
35
+ };
36
+ export declare type CellEditor = React.FC<CellEditorProps> & {
37
+ checker?: (value: unknown) => boolean;
38
+ formatter?: (value: unknown) => unknown;
39
+ };
40
+ export declare type CellViewer = React.FC<CellViewerProps>;
41
+ export declare type CellPosition = {
42
+ row: number;
43
+ col: number;
44
+ };
45
+ export declare type CellData = {
46
+ id: string;
47
+ cell: Cell;
48
+ row: number;
49
+ col: number;
50
+ value?: string;
51
+ };
52
+ export declare type CellNavigable = (cell?: Cell, row?: number, col?: number) => boolean;
53
+ export declare type CellChangeHandler = (cells: CellData[], additions?: CellData[]) => void;
54
+ export declare type RowGroup = {
55
+ groupName: string;
56
+ groupStart: number;
57
+ groupEnd: number;
58
+ };
59
+ export declare type RowGroupConfig = {
60
+ groups: RowGroup[];
61
+ groupOpen: boolean[];
62
+ };
63
+ export declare type MenuRenderProps = {
64
+ position?: {
65
+ top: number;
66
+ left: number;
67
+ };
68
+ cell?: CellPosition;
69
+ onContextMenu?: (event: any) => void;
70
+ };
71
+ export declare type SheetInstance = {
72
+ zoomTo: (row?: number) => void;
73
+ pushToHistory: (value: OperateHistory) => void;
74
+ selectRow: (row?: number) => void;
75
+ popHistory: () => OperateHistory;
76
+ };
77
+ export declare type SheetProps = {
78
+ sheetInstance?: React.MutableRefObject<SheetInstance | null>;
79
+ sheetRenderer?: any;
80
+ rowRenderer?: any;
81
+ className?: string;
82
+ data: Cell[][];
83
+ freePaste?: boolean;
84
+ virtualized?: boolean;
85
+ groupConfig?: RowGroupConfig;
86
+ onCellsChanged?: CellChangeHandler;
87
+ menuRenderer?: React.FC<MenuRenderProps>;
88
+ onContextMenu?: (event: any) => void;
89
+ scroll?: {
90
+ x?: number | string;
91
+ y?: number | string;
92
+ };
93
+ rowClassName?: string | ((record: Record<string, unknown>, index: number) => string);
94
+ children?: any[];
95
+ };
96
+ export declare type SheetShell = Pick<SheetTableType.TableProps, 'columns'> & {
97
+ className?: string;
98
+ showGroup?: boolean;
99
+ showSelect?: boolean;
100
+ controlWidth?: number;
101
+ controlProps?: {
102
+ check?: {
103
+ checked: boolean;
104
+ indeterminate?: boolean;
105
+ };
106
+ group?: {
107
+ open: boolean;
108
+ };
109
+ };
110
+ };
111
+ export declare type SheetRow = {
112
+ row: number;
113
+ cells: Cell[];
114
+ selected: boolean;
115
+ children: React.ElementType;
116
+ };
117
+ export declare type windowAssertion = {
118
+ clipboardData?: {
119
+ getData?: (type: string) => string;
120
+ setData?: (type: string, data: string) => string;
121
+ };
122
+ };
123
+ export declare type refAssertion = {
124
+ contains?: (target: EventTarget | null) => boolean;
125
+ focus?: () => boolean;
126
+ } & HTMLSpanElement;
127
+ export declare type AttributesRenderer = (cell: Cell, row: number, col: number) => Record<string, string>;
128
+ export declare type CellProps = {
129
+ row: number;
130
+ col: number;
131
+ cell: Cell;
132
+ cellRenderer?: React.ElementType;
133
+ dataEditor?: React.ElementType;
134
+ valueViewer?: React.ElementType;
135
+ attributesRenderer?: AttributesRenderer;
136
+ };
137
+ export declare type UpdateStateType = {
138
+ eventBus: EventEmitter;
139
+ start: CellPosition;
140
+ end: CellPosition;
141
+ selecting: boolean;
142
+ forceEdit: boolean;
143
+ clear: CellPosition;
144
+ editing: CellPosition & {
145
+ value?: string;
146
+ };
147
+ history: OperateHistory[];
148
+ freePaste?: boolean;
149
+ data: Cell[][];
150
+ mouseDown: boolean;
151
+ lastSelected?: {
152
+ start?: CellPosition;
153
+ end?: CellPosition;
154
+ };
155
+ groupConfig?: {
156
+ groups: RowGroup[];
157
+ groupOpen: boolean[];
158
+ };
159
+ lastFocus: {
160
+ id: string;
161
+ col: number;
162
+ }[];
163
+ lastEditing: CellPosition & {
164
+ confirm?: boolean;
165
+ };
166
+ cellChangeHandler: (cells: CellData[], additions?: CellData[]) => void;
167
+ };
168
+ export declare type UpdateFocus = (start: CellPosition, end: CellPosition) => void;
169
+ export declare type Options<T> = {
170
+ value: string;
171
+ label: string;
172
+ } & T;
173
+ export declare type OptionsType = Options<{
174
+ disabled?: boolean;
175
+ children?: Options<{
176
+ children?: Options<Record<string, unknown>>;
177
+ }>;
178
+ }>;
179
+ export declare type OperateHistory = {
180
+ changes: Partial<CellData>[];
181
+ type: OperateType;
182
+ rowInfo?: {
183
+ newRow?: number;
184
+ deleteRow?: number;
185
+ };
186
+ extraInfo?: Record<string, unknown>;
187
+ };
188
+ export declare type OperateType = 'Edit' | 'Paste' | 'Delete' | 'DeleteRow' | 'NewRow' | 'Custom';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,53 @@
1
+ import { SheetType } from '.';
2
+ export declare type refAssertion = {
3
+ contains?: (target: EventTarget | null) => boolean;
4
+ focus?: () => boolean;
5
+ } & HTMLTableSectionElement;
6
+ export declare type CellAlign = 'left' | 'right' | 'center';
7
+ export declare type CellFixed = 'left' | 'right';
8
+ export declare type ColumnProps = {
9
+ align?: CellAlign;
10
+ fixed?: CellFixed;
11
+ width?: string | number;
12
+ dataIndex?: string;
13
+ title: string;
14
+ key?: string;
15
+ editable?: boolean;
16
+ readonly?: boolean | ((value: unknown, record: Record<string, unknown>, index: number) => boolean);
17
+ render?: SheetType.CellViewer;
18
+ editor?: SheetType.CellEditor;
19
+ };
20
+ export declare type TableChange = {
21
+ row: number;
22
+ id: string;
23
+ key: string;
24
+ value: unknown;
25
+ };
26
+ export declare type TableRowSelection = {
27
+ onChange: (selectedRowKeys: string[], selectedRows: Record<string, unknown>[]) => void;
28
+ };
29
+ export declare type TableGroupConfig = {
30
+ defaultOpen: boolean;
31
+ };
32
+ export declare type TableProps = {
33
+ columns: ColumnProps[];
34
+ virtualized?: boolean;
35
+ dataSource: Record<string, unknown>[];
36
+ rowClassName?: string | ((record: Record<string, unknown>, index: number) => string);
37
+ rowKey?: string | ((record: Record<string, unknown>, index: number) => string);
38
+ scroll?: {
39
+ x?: number | string;
40
+ y?: number | string;
41
+ };
42
+ sticky?: boolean;
43
+ draggable?: boolean;
44
+ rowSelection?: {
45
+ rowSelected: string[];
46
+ onChange: (selectedRowKeys: string[], selectedRows: Record<string, unknown>[]) => void;
47
+ };
48
+ groupConfig?: {
49
+ rowGroup: TableGroupConfig;
50
+ onChange: (value: TableGroupConfig) => void;
51
+ };
52
+ onChange: (changes: TableChange[]) => void;
53
+ };
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhenliang/sheet",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "A react library developed with dumi",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",
@@ -45,6 +45,7 @@
45
45
  },
46
46
  "dependencies": {
47
47
  "@ant-design/icons": "^4.6.2",
48
+ "antd": "^4.24.0",
48
49
  "events": "^3.3.0",
49
50
  "lodash": "^4.17.21",
50
51
  "moment": "^2.29.4",
@@ -71,9 +72,8 @@
71
72
  "stylelint": "^14.9.1"
72
73
  },
73
74
  "peerDependencies": {
74
- "antd": "^4.24.0",
75
- "react": ">=16.9.0",
76
- "react-dom": ">=16.9.0"
75
+ "react": "17.x",
76
+ "react-dom": "17.x"
77
77
  },
78
78
  "publishConfig": {
79
79
  "access": "public"
@@ -1,57 +0,0 @@
1
- import { useMemo } from 'react';
2
- import { classNames } from "./util";
3
- import { jsx as _jsx } from "react/jsx-runtime";
4
- import { jsxs as _jsxs } from "react/jsx-runtime";
5
- import { Fragment as _Fragment } from "react/jsx-runtime";
6
- export var WrapperShell = function WrapperShell(_ref) {
7
- var columns = _ref.columns,
8
- className = _ref.className;
9
- var TableShell = function TableShell(_ref2) {
10
- var children = _ref2.children;
11
- var _useMemo = useMemo(function () {
12
- var thItems = columns.map(function (item) {
13
- var _item$width;
14
- return /*#__PURE__*/_jsx("th", {
15
- className: "cell read-only",
16
- style: {
17
- width: (_item$width = item.width) !== null && _item$width !== void 0 ? _item$width : 'unset'
18
- },
19
- children: item.title
20
- }, item.dataIndex);
21
- });
22
- var colItems = columns.map(function (item) {
23
- var _item$width2;
24
- return /*#__PURE__*/_jsx("col", {
25
- className: "cell",
26
- style: {
27
- width: (_item$width2 = item.width) !== null && _item$width2 !== void 0 ? _item$width2 : 'unset'
28
- }
29
- }, item.dataIndex);
30
- });
31
- return {
32
- thItems: thItems,
33
- colItems: colItems
34
- };
35
- }, [columns]),
36
- thItems = _useMemo.thItems,
37
- colItems = _useMemo.colItems;
38
- return /*#__PURE__*/_jsxs(_Fragment, {
39
- children: [/*#__PURE__*/_jsx("table", {
40
- className: classNames('header', 'harvest-sheet', className),
41
- children: /*#__PURE__*/_jsx("thead", {
42
- children: /*#__PURE__*/_jsx("tr", {
43
- children: thItems
44
- })
45
- })
46
- }, "header"), /*#__PURE__*/_jsxs("table", {
47
- className: classNames('body', 'harvest-sheet'),
48
- children: [/*#__PURE__*/_jsx("colgroup", {
49
- children: colItems
50
- }), /*#__PURE__*/_jsx("tbody", {
51
- children: children
52
- }, "tbody")]
53
- }, "body")]
54
- });
55
- };
56
- return TableShell;
57
- };
File without changes
@@ -1,209 +0,0 @@
1
- declare namespace Sheet {
2
- type Cell = {
3
- id: string;
4
- key?: string;
5
- readonly?: boolean;
6
- component?: CellViewer;
7
- editable?: boolean;
8
- colSpan?: number;
9
- rowSpan?: number;
10
- width?: number;
11
- record?: Record<string, unknown>;
12
- disableEvents?: boolean;
13
- dataEditor?: CellEditor;
14
- valueViewer?: CellViewer;
15
- className?: string;
16
- align?: 'left' | 'center' | 'right';
17
- fixed?: 'left' | 'right';
18
- value?: string | number | null;
19
- };
20
-
21
- type CellEditorProps = {
22
- value: unknown;
23
- cell?: Cell;
24
- onChange: (value) => void;
25
- onConfirm: (value) => void;
26
- };
27
-
28
- type CellViewerProps = {
29
- value: unknown;
30
- record?: Record<string, unknown>;
31
- row: number;
32
- col: number;
33
- cell?: Cell;
34
- };
35
-
36
- type CellEditor = React.FC<CellEditorProps> & {
37
- checker?: (value: unknown) => boolean;
38
- formatter?: (value: unknown) => unknown;
39
- };
40
- type CellViewer = React.FC<CellViewerProps>;
41
-
42
- type CellPosition = {
43
- row: number;
44
- col: number;
45
- };
46
-
47
- type CellData = {
48
- id: string;
49
- cell: Cell;
50
- row: number;
51
- col: number;
52
- value?: string;
53
- };
54
-
55
- type CellNavigable = (cell?: Cell, row?: number, col?: number) => boolean;
56
- type CellChangeHandler = (cells: CellData[], additions?: CellData[]) => void;
57
-
58
- type RowGroup = {
59
- groupName: string;
60
- groupStart: number;
61
- groupEnd: number;
62
- };
63
- type RowGroupConfig = {
64
- groups: RowGroup[];
65
- groupOpen: boolean[];
66
- };
67
- type MenuRenderProps = {
68
- position?: { top: number; left: number };
69
- cell?: Sheet.CellPosition;
70
- onContextMenu?: (event: any) => void;
71
- };
72
-
73
- type SheetInstance = {
74
- zoomTo: (row?: number) => void;
75
- pushToHistory: (value: OperateHistory) => void;
76
- selectRow: (row?: number) => void;
77
- popHistory: () => OperateHistory;
78
- };
79
-
80
- type SheetProps = {
81
- sheetInstance?: React.MutableRefObject<Sheet.SheetInstance | null>;
82
- sheetRenderer?: any;
83
- rowRenderer?: any;
84
- className?: string;
85
- data: Cell[][];
86
- freePaste?: boolean;
87
- virtualized?: boolean;
88
-
89
- groupConfig?: RowGroupConfig;
90
-
91
- onCellsChanged?: CellChangeHandler;
92
- menuRenderer?: React.FC<MenuRenderProps>;
93
- onContextMenu?: (event: any) => void;
94
-
95
- scroll?: { x?: number | string; y?: number | string };
96
- rowClassName?:
97
- | string
98
- | ((record: Record<string, unknown>, index: number) => string);
99
- children?: (React.Element | null)[];
100
- };
101
-
102
- type SheetShell = Pick<SheetTable.TableProps, 'columns'> & {
103
- className?: string;
104
- showGroup?: boolean;
105
- showSelect?: boolean;
106
- controlWidth?: number;
107
- controlProps?: {
108
- check?: {
109
- checked: boolean;
110
- indeterminate?: boolean;
111
- };
112
- group?: {
113
- open: boolean;
114
- };
115
- };
116
- };
117
-
118
- type SheetRow = {
119
- row: number;
120
- cells: Cell[];
121
- selected: boolean;
122
- children: React.ElementType;
123
- };
124
-
125
- // todo
126
- type windowAssertion = {
127
- clipboardData?: {
128
- getData?: (type: string) => string;
129
- setData?: (type: string, data: string) => string;
130
- };
131
- };
132
-
133
- type refAssertion = {
134
- contains?: (target: EventTarget | null) => boolean;
135
- focus?: () => boolean;
136
- } & HTMLSpanElement;
137
-
138
- type AttributesRenderer = (
139
- cell: Sheet.Cell,
140
- row: number,
141
- col: number,
142
- ) => Record<string, string>;
143
-
144
- type CellProps = {
145
- row: number;
146
- col: number;
147
- cell: Cell;
148
- cellRenderer?: React.ElementType;
149
- dataEditor?: React.ElementType;
150
- valueViewer?: React.ElementType;
151
- attributesRenderer?: AttributesRenderer;
152
- };
153
-
154
- type UpdateStateType = {
155
- eventBus: EventEmitter;
156
- start: Sheet.CellPosition;
157
- end: Sheet.CellPosition;
158
- selecting: boolean;
159
- forceEdit: boolean;
160
- clear: CellPosition;
161
- editing: CellPosition & { value?: string };
162
- history: OperateHistory[];
163
- freePaste?: boolean;
164
- data: Cell[][];
165
- mouseDown: boolean;
166
- lastSelected?: { start?: Sheet.CellPosition; end?: Sheet.CellPosition };
167
- groupConfig?: {
168
- groups: RowGroup[];
169
- groupOpen: boolean[];
170
- };
171
- lastFocus: { id: string; col: number }[];
172
- lastEditing: CellPosition & { confirm?: boolean };
173
- cellChangeHandler: (cells: CellData[], additions?: CellData[]) => void;
174
- };
175
- type UpdateFocus = (start: CellPosition, end: CellPosition) => void;
176
-
177
- type Options<T> = {
178
- value: string;
179
- label: string;
180
- } & T;
181
-
182
- type OptionsType = Options<{
183
- disabled?: boolean;
184
- children?: Common.Option<{
185
- children?: Common.Options<Record<string, unknown>>;
186
- }>;
187
- }>;
188
-
189
- type OperateHistory = {
190
- changes: Partial<CellData>[];
191
- type: OperateType;
192
-
193
- rowInfo?: {
194
- newRow?: number;
195
- deleteRow?: number;
196
- };
197
- extraInfo?: Record<string, unknown>;
198
- };
199
-
200
- type OperateType =
201
- // 前三个Type 直接调用 onCellChange
202
- | 'Edit'
203
- | 'Paste'
204
- | 'Delete'
205
- // 后三个单独Event 处理
206
- | 'DeleteRow'
207
- | 'NewRow'
208
- | 'Custom';
209
- }
File without changes