@zhenliang/sheet 0.1.23 → 0.1.25

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 (61) hide show
  1. package/changes.md +45 -0
  2. package/dist/core/editor/cascaderEditor/index.js +0 -1
  3. package/dist/core/editor/cascaderEditor/index.less +9 -5
  4. package/dist/core/editor/dateEditor/index.js +10 -4
  5. package/dist/core/editor/dateEditor/index.less +8 -1
  6. package/dist/core/editor/numberEditor/index.d.ts +1 -1
  7. package/dist/core/editor/numberEditor/index.js +5 -5
  8. package/dist/core/editor/numberEditor/index.less +2 -2
  9. package/dist/core/editor/selectEditor/index.js +4 -4
  10. package/dist/core/editor/selectEditor/index.less +8 -3
  11. package/dist/core/reducers/index.d.ts +2 -2
  12. package/dist/core/reducers/keyboardReducer.js +3 -3
  13. package/dist/core/reducers/mouseReducer.js +5 -5
  14. package/dist/core/reducers/sideEffectReducer.d.ts +1 -1
  15. package/dist/core/reducers/sideEffectReducer.js +10 -10
  16. package/dist/core/reducers/stateReducer.js +10 -10
  17. package/dist/core/sheet/Cell.js +2 -2
  18. package/dist/core/sheet/DataEditor.js +1 -1
  19. package/dist/core/sheet/DefaultCell.d.ts +1 -0
  20. package/dist/core/sheet/DefaultCell.js +3 -3
  21. package/dist/core/sheet/DefaultRowMapper.js +4 -1
  22. package/dist/core/sheet/index.js +31 -23
  23. package/dist/core/sheet/index.less +6 -3
  24. package/dist/core/sheet/useContextMenu.d.ts +1 -1
  25. package/dist/core/sheet/useContextMenu.js +6 -6
  26. package/dist/core/sheet/useKeyBoardEvent.js +1 -1
  27. package/dist/core/sheet/useMouseEvent.js +6 -6
  28. package/dist/core/sheet/useSelectVisible.js +3 -3
  29. package/dist/core/sheet/useVirtualList.js +3 -3
  30. package/dist/core/shell/draggableShell/index.d.ts +1 -0
  31. package/dist/core/shell/draggableShell/index.js +6 -6
  32. package/dist/core/shell/tableShell.d.ts +1 -0
  33. package/dist/core/shell/tableShell.js +4 -4
  34. package/dist/core/table/events.js +5 -5
  35. package/dist/core/table/index.js +7 -7
  36. package/dist/core/table/useGroupConfig.js +1 -1
  37. package/dist/core/table/useRowSelection.js +1 -1
  38. package/dist/core/util.d.ts +0 -1
  39. package/dist/core/util.js +19 -52
  40. package/dist/core/viewer/cascaderViewer/index.js +6 -1
  41. package/dist/core/viewer/editViewer/index.js +2 -1
  42. package/dist/core/viewer/groupViewer/index.js +5 -1
  43. package/dist/example/antComponent.js +7 -8
  44. package/dist/example/basic.js +4 -4
  45. package/dist/example/group.js +3 -3
  46. package/dist/example/selection.js +4 -4
  47. package/dist/example/sheet.js +21 -17
  48. package/dist/example/valuationAnalyze.d.ts +1 -0
  49. package/dist/example/valuationAnalyze.js +1 -1
  50. package/dist/hooks/useEventBus.js +1 -1
  51. package/dist/hooks/useKeyboard.d.ts +2 -2
  52. package/dist/hooks/useMiddlewareReducer.d.ts +5 -5
  53. package/dist/hooks/useMiddlewareReducer.js +2 -2
  54. package/dist/hooks/useMouse.d.ts +1 -1
  55. package/dist/hooks/useMouse.js +6 -6
  56. package/dist/hooks/useSetState.js +4 -4
  57. package/dist/standardUtils/index.d.ts +1 -1
  58. package/dist/standardUtils/index.js +1 -1
  59. package/dist/type/sheet.d.ts +28 -27
  60. package/dist/type/sheetTable.d.ts +10 -9
  61. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
4
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
5
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
6
  function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
@@ -8,7 +8,7 @@ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArra
8
8
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
9
9
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
10
10
  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; }
11
- function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
11
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
12
12
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
13
  import { useCallback, useState } from 'react';
14
14
  var useSetState = function useSetState() {
@@ -1,4 +1,4 @@
1
- declare type ValueParams = string | number | null | undefined;
1
+ type ValueParams = string | number | null | undefined;
2
2
  export declare const formatPrecision: (value: ValueParams, precision?: number) => string;
3
3
  /**
4
4
  * 千位分隔符
@@ -2,7 +2,7 @@ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArra
2
2
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
3
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
4
  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; }
5
- function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
5
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
6
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
7
  export var formatPrecision = function formatPrecision(value) {
8
8
  var precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
@@ -8,7 +8,7 @@ export declare enum CellAlign {
8
8
  right = "right",
9
9
  unset = "unset"
10
10
  }
11
- export declare type Cell = {
11
+ export type Cell = {
12
12
  id: string;
13
13
  key?: string;
14
14
  readonly?: boolean;
@@ -26,49 +26,49 @@ export declare type Cell = {
26
26
  fixed?: Omit<CellAlign, 'center'>;
27
27
  value?: string | number | null;
28
28
  };
29
- export declare type CellViewerProps = {
29
+ export type CellViewerProps = {
30
30
  value: unknown;
31
31
  record?: Record<string, unknown>;
32
32
  row?: number;
33
33
  col?: number;
34
34
  cell?: Cell;
35
35
  };
36
- export declare type CellEditorProps = {
36
+ export type CellEditorProps = {
37
37
  value: unknown;
38
38
  cell?: Cell;
39
39
  onChange: (value: unknown) => void;
40
40
  onConfirm: (value: unknown) => void;
41
41
  } & CellViewerProps;
42
- export declare type CellEditor = React.FC<CellEditorProps> & {
42
+ export type CellEditor = React.FC<CellEditorProps> & {
43
43
  checker?: (value: unknown, record?: Record<string, unknown>) => boolean;
44
44
  formatter?: (value: unknown, record?: Record<string, unknown>) => unknown;
45
45
  parser?: (value: unknown, record?: Record<string, unknown>) => unknown;
46
46
  };
47
- export declare type CellViewer = React.FC<CellViewerProps>;
48
- export declare type CellPosition = {
47
+ export type CellViewer = React.FC<CellViewerProps>;
48
+ export type CellPosition = {
49
49
  row: number;
50
50
  col: number;
51
51
  };
52
- export declare type CellData = {
52
+ export type CellData = {
53
53
  id: string;
54
54
  cell: Cell;
55
55
  row: number;
56
56
  col: number;
57
57
  value?: string;
58
58
  };
59
- export declare type CellNavigable = (cell?: Cell, row?: number, col?: number) => boolean;
60
- export declare type CellChangeHandler = (cells: CellData[], additions?: CellData[]) => void;
61
- export declare type RowGroup = {
59
+ export type CellNavigable = (cell?: Cell, row?: number, col?: number) => boolean;
60
+ export type CellChangeHandler = (cells: CellData[], additions?: CellData[]) => void;
61
+ export type RowGroup = {
62
62
  groupName: string;
63
63
  groupStart: number;
64
64
  groupEnd: number;
65
65
  };
66
- export declare type RowGroupConfig = {
66
+ export type RowGroupConfig = {
67
67
  defaultOpen?: boolean;
68
68
  groups: RowGroup[];
69
69
  groupOpen: boolean[];
70
70
  };
71
- export declare type MenuRenderProps = {
71
+ export type MenuRenderProps = {
72
72
  position?: {
73
73
  top: number;
74
74
  left: number;
@@ -76,7 +76,7 @@ export declare type MenuRenderProps = {
76
76
  cell?: CellPosition;
77
77
  onContextMenu?: (event: any) => void;
78
78
  };
79
- export declare type SheetInstance = {
79
+ export type SheetInstance = {
80
80
  zoomTo: (row?: number) => void;
81
81
  pushToHistory: (value: OperateHistory) => void;
82
82
  selectRow: (row?: number) => void;
@@ -86,10 +86,11 @@ export declare type SheetInstance = {
86
86
  }) => void;
87
87
  popHistory: () => OperateHistory;
88
88
  };
89
- export declare type SheetProps = {
89
+ export type SheetProps = {
90
90
  sheetInstance?: React.MutableRefObject<SheetInstance | null>;
91
91
  sheetRenderer?: any;
92
92
  rowRenderer?: any;
93
+ emptyRenderer?: any;
93
94
  className?: string;
94
95
  data: Cell[][];
95
96
  freePaste?: boolean;
@@ -108,11 +109,11 @@ export declare type SheetProps = {
108
109
  rowClassName?: string | ((record: Record<string, unknown>, index: number) => string);
109
110
  children?: any[];
110
111
  };
111
- export declare type WidthConfig = {
112
+ export type WidthConfig = {
112
113
  onChange?: (value: Record<number | string, number>) => void;
113
114
  widths?: Record<number | string, number>;
114
115
  };
115
- export declare type SheetShell = Pick<SheetTableType.TableProps, 'columns'> & {
116
+ export type SheetShell = Pick<SheetTableType.TableProps, 'columns'> & {
116
117
  className?: string;
117
118
  showGroup?: boolean;
118
119
  showSelect?: boolean;
@@ -127,24 +128,24 @@ export declare type SheetShell = Pick<SheetTableType.TableProps, 'columns'> & {
127
128
  };
128
129
  };
129
130
  };
130
- export declare type SheetRow = {
131
+ export type SheetRow = {
131
132
  row: number;
132
133
  cells: Cell[];
133
134
  selected: boolean;
134
135
  children: React.ElementType;
135
136
  };
136
- export declare type windowAssertion = {
137
+ export type windowAssertion = {
137
138
  clipboardData?: {
138
139
  getData?: (type: string) => string;
139
140
  setData?: (type: string, data: string) => string;
140
141
  };
141
142
  };
142
- export declare type refAssertion = {
143
+ export type refAssertion = {
143
144
  contains?: (target: EventTarget | null) => boolean;
144
145
  focus?: () => boolean;
145
146
  } & HTMLSpanElement;
146
- export declare type AttributesRenderer = (cell: Cell, row: number, col: number) => Record<string, string>;
147
- export declare type CellProps = {
147
+ export type AttributesRenderer = (cell: Cell, row: number, col: number) => Record<string, string>;
148
+ export type CellProps = {
148
149
  row: number;
149
150
  col: number;
150
151
  cell: Cell;
@@ -153,7 +154,7 @@ export declare type CellProps = {
153
154
  valueViewer?: React.ElementType;
154
155
  attributesRenderer?: AttributesRenderer;
155
156
  };
156
- export declare type UpdateStateType = {
157
+ export type UpdateStateType = {
157
158
  eventBus: EventEmitter;
158
159
  start: CellPosition;
159
160
  end: CellPosition;
@@ -184,16 +185,16 @@ export declare type UpdateStateType = {
184
185
  };
185
186
  cellChangeHandler: (cells: CellData[], additions?: CellData[]) => void;
186
187
  };
187
- export declare type UpdateFocus = (start: CellPosition, end: CellPosition) => void;
188
- export declare type Options<T = any> = {
188
+ export type UpdateFocus = (start: CellPosition, end: CellPosition) => void;
189
+ export type Options<T = any> = {
189
190
  value: string | number;
190
191
  label: string;
191
192
  } & T;
192
- export declare type OptionsType = Options<{
193
+ export type OptionsType = Options<{
193
194
  disabled?: boolean;
194
195
  children?: OptionsType[];
195
196
  }>;
196
- export declare type OperateHistory = {
197
+ export type OperateHistory = {
197
198
  changes: Partial<CellData>[];
198
199
  type: OperateType;
199
200
  rowInfo?: {
@@ -202,4 +203,4 @@ export declare type OperateHistory = {
202
203
  };
203
204
  extraInfo?: Record<string, unknown>;
204
205
  };
205
- export declare type OperateType = 'Edit' | 'Paste' | 'Delete' | 'DeleteRow' | 'NewRow' | 'Custom';
206
+ export type OperateType = 'Edit' | 'Paste' | 'Delete' | 'DeleteRow' | 'NewRow' | 'Custom';
@@ -1,12 +1,12 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { SheetType } from '.';
3
- export declare type refAssertion = {
3
+ export type refAssertion = {
4
4
  contains?: (target: EventTarget | null) => boolean;
5
5
  focus?: () => boolean;
6
6
  } & HTMLTableSectionElement;
7
- export declare type CellFixed = SheetType.CellAlign;
8
- export declare type RecordRowMap<T> = (value: unknown, record: Record<string, unknown>, index: number, colIndex?: number) => T;
9
- export declare type ColumnProps = {
7
+ export type CellFixed = SheetType.CellAlign;
8
+ export type RecordRowMap<T> = (value: unknown, record: Record<string, unknown>, index: number, colIndex?: number) => T;
9
+ export type ColumnProps = {
10
10
  /**
11
11
  * @description 对齐
12
12
  * @default "left"
@@ -37,24 +37,24 @@ export declare type ColumnProps = {
37
37
  render?: SheetType.CellViewer;
38
38
  editor?: SheetType.CellEditor;
39
39
  };
40
- export declare type TableChange = {
40
+ export type TableChange = {
41
41
  col?: number;
42
42
  row: number;
43
43
  id: string;
44
44
  key: string;
45
45
  value: unknown;
46
46
  };
47
- export declare type TableRowSelection = {
47
+ export type TableRowSelection = {
48
48
  rowSelected?: string[];
49
49
  onChange?: (selectedRowKeys: string[], selectedRows: Record<string, unknown>[]) => void;
50
50
  };
51
- export declare type TableGroupConfig = {
51
+ export type TableGroupConfig = {
52
52
  defaultOpen?: boolean;
53
53
  rowGroup?: SheetType.RowGroupConfig;
54
54
  onChange?: (value: SheetType.RowGroupConfig) => void;
55
55
  };
56
- export declare type EventHandler = (value: any) => void;
57
- export declare type TableProps = {
56
+ export type EventHandler = (value: any) => void;
57
+ export type TableProps = {
58
58
  /**
59
59
  * @description 表格类名
60
60
  * @default "undefined"
@@ -68,6 +68,7 @@ export declare type TableProps = {
68
68
  columns: ColumnProps[];
69
69
  virtualized?: boolean;
70
70
  dataSource: Record<string, unknown>[];
71
+ emptyRenderer?: any;
71
72
  rowClassName?: string | ((record: Record<string, unknown>, index: number) => string);
72
73
  rowKey?: string | ((record: Record<string, unknown>, index: number) => string);
73
74
  scroll?: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhenliang/sheet",
3
- "version": "0.1.23",
3
+ "version": "0.1.25",
4
4
  "description": "A react library developed with dumi",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",