@zhenliang/sheet 0.1.72-beta.7 → 0.1.74

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 (68) hide show
  1. package/dist/core/editor/dateEditor/index.js +6 -6
  2. package/dist/core/editor/numberEditor/index.d.ts +1 -1
  3. package/dist/core/editor/numberEditor/index.js +7 -7
  4. package/dist/core/editor/selectEditor/index.js +6 -6
  5. package/dist/core/reducers/index.d.ts +2 -2
  6. package/dist/core/reducers/keyboardReducer.js +8 -7
  7. package/dist/core/reducers/mouseReducer.js +10 -9
  8. package/dist/core/reducers/sideEffectReducer.d.ts +1 -1
  9. package/dist/core/reducers/sideEffectReducer.js +17 -17
  10. package/dist/core/reducers/stateReducer.js +10 -10
  11. package/dist/core/sheet/Cell.js +2 -2
  12. package/dist/core/sheet/DataEditor.js +1 -1
  13. package/dist/core/sheet/DefaultCell.d.ts +3 -3
  14. package/dist/core/sheet/DefaultCell.js +5 -5
  15. package/dist/core/sheet/DefaultRowMapper.js +5 -5
  16. package/dist/core/sheet/Remark.d.ts +9 -0
  17. package/dist/core/sheet/Remark.js +32 -0
  18. package/dist/core/sheet/index.js +67 -19
  19. package/dist/core/sheet/index.less +36 -0
  20. package/dist/core/sheet/searchInput.js +1 -1
  21. package/dist/core/sheet/useContextMenu.d.ts +1 -1
  22. package/dist/core/sheet/useContextMenu.js +11 -11
  23. package/dist/core/sheet/useKeyBoardEvent.js +1 -1
  24. package/dist/core/sheet/useMouseEvent.js +11 -12
  25. package/dist/core/sheet/useRemarkContainer.d.ts +14 -0
  26. package/dist/core/sheet/useRemarkContainer.js +144 -0
  27. package/dist/core/sheet/useSearchInput.js +8 -8
  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 -1
  31. package/dist/core/shell/draggableShell/index.js +15 -10
  32. package/dist/core/shell/tableShell.d.ts +2 -2
  33. package/dist/core/shell/tableShell.js +11 -155
  34. package/dist/core/table/addButton.d.ts +0 -1
  35. package/dist/core/table/addButton.js +2 -3
  36. package/dist/core/table/events.js +7 -7
  37. package/dist/core/table/index.d.ts +1 -0
  38. package/dist/core/table/index.js +167 -17
  39. package/dist/core/table/index.less +19 -0
  40. package/dist/core/table/remarkEvent.d.ts +5 -0
  41. package/dist/core/table/remarkEvent.js +9 -0
  42. package/dist/core/table/useGroupConfig.d.ts +1 -1
  43. package/dist/core/table/useGroupConfig.js +16 -14
  44. package/dist/core/table/useRowSelection.d.ts +3 -25
  45. package/dist/core/table/useRowSelection.js +7 -4
  46. package/dist/core/util.js +14 -14
  47. package/dist/core/viewer/editViewer/index.js +1 -2
  48. package/dist/core/viewer/groupViewer/index.js +4 -8
  49. package/dist/example/antComponent.js +9 -9
  50. package/dist/example/basic.js +6 -6
  51. package/dist/example/group.js +1 -2
  52. package/dist/example/selection.js +6 -6
  53. package/dist/example/sheet.js +16 -21
  54. package/dist/example/valuationAnalyze.d.ts +1 -0
  55. package/dist/example/valuationAnalyze.js +356 -14
  56. package/dist/hooks/useEventBus.js +1 -1
  57. package/dist/hooks/useKeyboard.d.ts +2 -2
  58. package/dist/hooks/useMiddlewareReducer.d.ts +5 -5
  59. package/dist/hooks/useMiddlewareReducer.js +2 -2
  60. package/dist/hooks/useMouse.d.ts +1 -1
  61. package/dist/hooks/useMouse.js +6 -6
  62. package/dist/hooks/useSetState.js +6 -6
  63. package/dist/standardUtils/index.d.ts +1 -1
  64. package/dist/standardUtils/index.js +1 -1
  65. package/dist/type/sheet.d.ts +40 -32
  66. package/dist/type/sheetTable.d.ts +24 -11
  67. package/package.json +8 -3
  68. package/changes.md +0 -45
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import type { EventEmitter } from 'events';
3
- import { CSSProperties } from 'react';
3
+ import { CSSProperties, ReactNode } from 'react';
4
4
  import { SheetTableType, SheetType } from '.';
5
5
  export declare enum CellAlign {
6
6
  left = "left",
@@ -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
  row?: number;
14
14
  col?: number;
@@ -31,37 +31,37 @@ export declare type Cell = {
31
31
  value?: string | number | null;
32
32
  allowClear?: boolean;
33
33
  };
34
- export declare type FixedInfo = {
34
+ export type FixedInfo = {
35
35
  isFirstFixedRight: boolean;
36
36
  isLastFixedLeft: boolean;
37
37
  fixPosition: number;
38
38
  isScrolledOver?: boolean;
39
39
  isScrolledToEnd?: boolean;
40
40
  };
41
- export declare type CellViewerProps = {
41
+ export type CellViewerProps = {
42
42
  value: unknown;
43
43
  record?: Record<string, unknown>;
44
44
  row?: number;
45
45
  col?: number;
46
46
  cell?: Cell;
47
47
  };
48
- export declare type CellEditorProps = {
48
+ export type CellEditorProps = {
49
49
  value: unknown;
50
50
  cell?: Cell;
51
51
  onChange: (value: unknown) => void;
52
52
  onConfirm: (value: unknown) => void;
53
53
  } & CellViewerProps;
54
- export declare type CellEditor = React.FC<CellEditorProps> & {
54
+ export type CellEditor = React.FC<CellEditorProps> & {
55
55
  checker?: (value: unknown, record?: Record<string, unknown>) => boolean;
56
56
  formatter?: (value: unknown, record?: Record<string, unknown>) => unknown;
57
57
  parser?: (value: unknown, record?: Record<string, unknown>) => unknown;
58
58
  };
59
- export declare type CellViewer = React.FC<CellViewerProps>;
60
- export declare type CellPosition = {
59
+ export type CellViewer = React.FC<CellViewerProps>;
60
+ export type CellPosition = {
61
61
  row: number;
62
62
  col: number;
63
63
  };
64
- export declare type CellData = {
64
+ export type CellData = {
65
65
  id: string;
66
66
  cell: Cell;
67
67
  row: number;
@@ -69,31 +69,33 @@ export declare type CellData = {
69
69
  key?: string;
70
70
  value?: string;
71
71
  };
72
- export declare type CellNavigable = (cell?: Cell, row?: number, col?: number) => boolean;
73
- export declare type CellChangeHandler = (cells: CellData[], additions?: CellData[]) => void;
74
- export declare type RowGroup = {
72
+ export type CellNavigable = (cell?: Cell, row?: number, col?: number) => boolean;
73
+ export type CellChangeHandler = (cells: CellData[], additions?: CellData[]) => void;
74
+ export type RowGroup = {
75
75
  groupName: string;
76
76
  groupStart: number;
77
77
  groupEnd: number;
78
78
  };
79
- export declare type RowGroupConfig = {
79
+ export type RowGroupConfig = {
80
80
  defaultOpen?: boolean;
81
81
  groups: RowGroup[];
82
82
  groupOpen: boolean[];
83
83
  };
84
- export declare type GroupMap = Map<number, SheetType.RowGroup & {
84
+ export type GroupMap = Map<number, SheetType.RowGroup & {
85
85
  isStart: boolean;
86
86
  isOpen: boolean;
87
87
  }>;
88
- export declare type MenuRenderProps = {
88
+ export type MenuRenderProps = {
89
89
  position?: {
90
90
  top: number;
91
91
  left: number;
92
92
  };
93
93
  cell?: CellPosition;
94
94
  onContextMenu?: (event: any) => void;
95
+ children?: ReactNode | ReactNode[];
96
+ target?: any;
95
97
  };
96
- export declare type SheetInstance = {
98
+ export type SheetInstance = {
97
99
  zoomTo: (row?: number) => void;
98
100
  goTo: (row: number, col: number) => void;
99
101
  pushToHistory: (value: OperateHistory) => void;
@@ -104,8 +106,9 @@ export declare type SheetInstance = {
104
106
  }) => void;
105
107
  popHistory: () => OperateHistory;
106
108
  dropHistory: () => OperateHistory[];
109
+ call: (caller: (...args: any) => void, ...args: any) => void;
107
110
  };
108
- export declare type SheetProps = {
111
+ export type SheetProps = {
109
112
  sheetInstance?: React.MutableRefObject<SheetInstance | null>;
110
113
  sheetRenderer?: any;
111
114
  rowRenderer?: any;
@@ -118,7 +121,9 @@ export declare type SheetProps = {
118
121
  backEditStyle?: Partial<CSSProperties>;
119
122
  searchStyle?: Partial<CSSProperties>;
120
123
  sticky?: boolean;
124
+ freeze?: boolean;
121
125
  groupConfig?: RowGroupConfig;
126
+ remarkElement?: ReactNode;
122
127
  onCellsChanged?: CellChangeHandler;
123
128
  menuRenderer?: React.FC<MenuRenderProps>;
124
129
  onContextMenu?: (event: any) => void;
@@ -132,20 +137,22 @@ export declare type SheetProps = {
132
137
  boldScroll?: boolean;
133
138
  hideColBar?: boolean;
134
139
  showQuickLocationBtn?: boolean;
140
+ showRemark?: boolean;
135
141
  ControlContainer?: React.FC;
136
142
  };
137
- export declare type WidthConfigContext = {
143
+ export type WidthConfigContext = {
138
144
  onChange?: (value: Record<number | string, number>) => void;
139
145
  widths?: Record<number | string, number>;
140
146
  };
141
- export declare type GroupConfigContext = {
147
+ export type GroupConfigContext = {
142
148
  onChange?: (value: RowGroupConfig) => void;
143
149
  config?: RowGroupConfig & {
144
150
  configMap: GroupMap;
145
151
  };
146
152
  };
147
- export declare type SheetShell = Pick<SheetTableType.TableProps, 'columns'> & {
153
+ export type SheetShell = Pick<SheetTableType.TableProps, 'columns'> & {
148
154
  className?: string;
155
+ dragable?: boolean;
149
156
  showGroup?: boolean;
150
157
  showSelect?: boolean;
151
158
  controlWidth?: number;
@@ -159,24 +166,24 @@ export declare type SheetShell = Pick<SheetTableType.TableProps, 'columns'> & {
159
166
  };
160
167
  };
161
168
  };
162
- export declare type SheetRow = {
169
+ export type SheetRow = {
163
170
  row: number;
164
171
  cells: Cell[];
165
172
  selected: boolean;
166
173
  children: React.ElementType;
167
174
  };
168
- export declare type windowAssertion = {
175
+ export type windowAssertion = {
169
176
  clipboardData?: {
170
177
  getData?: (type: string) => string;
171
178
  setData?: (type: string, data: string) => string;
172
179
  };
173
180
  };
174
- export declare type refAssertion = {
181
+ export type refAssertion = {
175
182
  contains?: (target: EventTarget | null) => boolean;
176
183
  focus?: () => boolean;
177
184
  } & HTMLSpanElement;
178
- export declare type AttributesRenderer = (cell: Cell, row: number, col: number) => Record<string, string>;
179
- export declare type CellProps = {
185
+ export type AttributesRenderer = (cell: Cell, row: number, col: number) => Record<string, string>;
186
+ export type CellProps = {
180
187
  row: number;
181
188
  col: number;
182
189
  cell: Cell;
@@ -186,7 +193,7 @@ export declare type CellProps = {
186
193
  attributesRenderer?: AttributesRenderer;
187
194
  cellFixedInfo: SheetType.FixedInfo;
188
195
  };
189
- export declare type SearchState = {
196
+ export type SearchState = {
190
197
  showSearch: boolean;
191
198
  searchText: string;
192
199
  searchTotal: number;
@@ -194,7 +201,7 @@ export declare type SearchState = {
194
201
  searchResultList?: CellPosition[];
195
202
  searchCalledCount: number;
196
203
  };
197
- export declare type UpdateStateType = {
204
+ export type UpdateStateType = {
198
205
  eventBus: EventEmitter;
199
206
  start: CellPosition;
200
207
  end: CellPosition;
@@ -210,6 +217,7 @@ export declare type UpdateStateType = {
210
217
  data: Cell[][];
211
218
  mouseDown: boolean;
212
219
  isIndex: boolean;
220
+ freeze: boolean;
213
221
  lastSelected?: {
214
222
  start?: CellPosition;
215
223
  end?: CellPosition;
@@ -228,16 +236,16 @@ export declare type UpdateStateType = {
228
236
  cellChangeHandler: (cells: CellData[], additions?: CellData[]) => void;
229
237
  fixedInfo: SheetType.FixedInfo[];
230
238
  } & SearchState;
231
- export declare type UpdateFocus = (start: CellPosition, end: CellPosition) => void;
232
- export declare type Options<T = any> = {
239
+ export type UpdateFocus = (start: CellPosition, end: CellPosition) => void;
240
+ export type Options<T = any> = {
233
241
  value: string | number;
234
242
  label: string;
235
243
  } & T;
236
- export declare type OptionsType = Options<{
244
+ export type OptionsType = Options<{
237
245
  disabled?: boolean;
238
246
  children?: OptionsType[];
239
247
  }>;
240
- export declare type OperateHistory = {
248
+ export type OperateHistory = {
241
249
  changes: Partial<CellData>[];
242
250
  type: OperateType;
243
251
  rowInfo?: {
@@ -246,4 +254,4 @@ export declare type OperateHistory = {
246
254
  };
247
255
  extraInfo?: Record<string, unknown>;
248
256
  };
249
- export declare type OperateType = 'Edit' | 'Paste' | 'Delete' | 'DeleteRow' | 'NewRow' | 'Custom';
257
+ export type OperateType = 'Edit' | 'Paste' | 'Delete' | 'DeleteRow' | 'NewRow' | 'Custom';
@@ -1,12 +1,12 @@
1
1
  import { CSSProperties, 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"
@@ -23,7 +23,7 @@ export declare type ColumnProps = {
23
23
  */
24
24
  width?: string | number;
25
25
  dataIndex?: string;
26
- title: string | ReactNode | ReactNode[] | React.FC;
26
+ title: string | ReactNode;
27
27
  titleConfig?: {
28
28
  colSpan?: number;
29
29
  className?: string;
@@ -39,24 +39,33 @@ export declare type ColumnProps = {
39
39
  editor?: SheetType.CellEditor;
40
40
  searchKey?: (value: unknown, record: Record<string, unknown>) => string;
41
41
  };
42
- export declare type TableChange = {
42
+ export type TableChange = {
43
43
  col?: number;
44
44
  row: number;
45
45
  id: string;
46
46
  key: string;
47
47
  value: unknown;
48
48
  };
49
- export declare type TableRowSelection = {
49
+ export type TableRowSelection = {
50
50
  rowSelected?: string[];
51
51
  onChange?: (selectedRowKeys: string[], selectedRows: Record<string, unknown>[]) => void;
52
52
  };
53
- export declare type TableGroupConfig = {
53
+ export type TableGroupConfig = {
54
54
  defaultOpen?: boolean;
55
55
  rowGroup?: SheetType.RowGroupConfig;
56
56
  onChange?: (value: SheetType.RowGroupConfig) => void;
57
57
  };
58
- export declare type EventHandler = (value: any) => void;
59
- export declare type TableProps = {
58
+ export type EventHandler = (value: any) => void;
59
+ export type RemarkProps = {
60
+ cell: SheetType.CellPosition;
61
+ columnKey: string;
62
+ id?: string | number;
63
+ close: () => void;
64
+ };
65
+ export type TableInstance = {
66
+ goToByTable?: (id: number, columnKey: string) => void;
67
+ } & SheetType.SheetInstance;
68
+ export type TableProps = {
60
69
  /**
61
70
  * @description 表格类名
62
71
  * @default "undefined"
@@ -66,7 +75,7 @@ export declare type TableProps = {
66
75
  * @description sheet的一些定义方法可执行
67
76
  * @default "object"
68
77
  */
69
- sheetInstance?: React.MutableRefObject<SheetType.SheetInstance | null>;
78
+ sheetInstance?: React.MutableRefObject<SheetType.SheetInstance & TableInstance | null>;
70
79
  columns: ColumnProps[];
71
80
  virtualized?: boolean;
72
81
  dataSource: Record<string, unknown>[];
@@ -80,7 +89,11 @@ export declare type TableProps = {
80
89
  sticky?: boolean;
81
90
  draggable?: boolean;
82
91
  freePaste?: boolean;
92
+ freeze?: boolean;
83
93
  showBackEdit?: boolean;
94
+ showRemark?: boolean;
95
+ remarkRender?: React.FC<RemarkProps>;
96
+ handleAddRemark?: (value: RemarkProps) => void;
84
97
  backEditStyle?: Partial<CSSProperties>;
85
98
  searchStyle?: Partial<CSSProperties>;
86
99
  rowSelection?: TableRowSelection;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhenliang/sheet",
3
- "version": "0.1.72-beta.7",
3
+ "version": "0.1.74",
4
4
  "description": "A react library developed with dumi",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",
@@ -43,12 +43,17 @@
43
43
  "prettier --parser=typescript --write"
44
44
  ]
45
45
  },
46
+ "resolutions": {
47
+ "@types/react": "17.0.40"
48
+ },
46
49
  "dependencies": {
47
50
  "@ant-design/icons": "^4.6.2",
48
51
  "antd": "^4.24.0",
49
52
  "events": "^3.3.0",
50
53
  "lodash": "^4.17.21",
51
54
  "moment": "^2.29.4",
55
+ "react": "17.x",
56
+ "react-dom": "17.x",
52
57
  "redux-logger": "^3.0.6",
53
58
  "redux-thunk": "^2.4.2"
54
59
  },
@@ -56,8 +61,8 @@
56
61
  "@commitlint/cli": "^17.1.2",
57
62
  "@commitlint/config-conventional": "^17.1.0",
58
63
  "@types/lodash": "^4.14.195",
59
- "@types/react": "^17.0.0",
60
- "@types/react-dom": "^17.0.0",
64
+ "@types/react": "17.0.40",
65
+ "@types/react-dom": "17.0.13",
61
66
  "@umijs/lint": "^4.0.0",
62
67
  "dumi": "^2.2.0",
63
68
  "eslint": "^8.23.0",
package/changes.md DELETED
@@ -1,45 +0,0 @@
1
- ### 为什么要重写
2
-
3
- #### 存在问题
4
-
5
- 1、表格选择逻辑与虚拟列表的冲突
6
- 2、表格的刷新机制: setRefresh(在多人开发的时候不便维护)
7
- 3、回调地狱
8
- 4、无法从 jll-portal 中剥离,有些地方与业务字段耦合
9
-
10
- #### 后果
11
-
12
- 1、新增功能难度大
13
- 2、修改容易出 bug
14
- 3、不利于业务代码优化和重构
15
-
16
- ### 重写后的表格
17
-
18
- #### 优点
19
-
20
- 1、维护性
21
- 2、扩展性
22
- 3、新的功能
23
-
24
- #### 新的 API
25
-
26
- 1、TableProps
27
-
28
- | 表头 | 表头 | 表头 |
29
- | -------------------------------------------- | ----------------------- | ---- |
30
- | className | container 类名 | 无 | |
31
- | | sheetInstance | sheet 对外暴露的一些 API | 选中行,参与回滚等 | |
32
-
33
- | columns | 表格列 | 无 ,必填 |
34
- | dataSource | 数据源 | 无,必填 |
35
- | virtualized |虚拟列表 | false |
36
- | draggable | 列宽可调整 | false |
37
- | rowClassName | 行类名 | 无 |
38
- | rowKey | 唯一标识字段 | key , id |
39
- | scroll | 同 antd table | {y:Math.min(400,row \* 40)} |
40
- | rowSelection | 选中行的配置 | 尚未完全实现 |
41
- | groupConfig | 表格分组 | 表格内部自动支持,对外配置尚未完全实现 |
42
- | onChange | 表格 cell change handler | 无 |
43
- | eventHandler | 自定义事件 handler | Record<string,(value:unknown)=>void> |
44
-
45
- 2、 ColumnProps