@zhenliang/sheet 0.1.63 → 0.1.65-beta

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.
@@ -232,6 +232,10 @@ export var sideEffectReducer = {
232
232
  col = _ref5.col,
233
233
  value = _ref5.value;
234
234
  var editor = data[row][col].dataEditor;
235
+ var notEditable = data[row][col].readonly || !data[row][col].editable;
236
+ if (notEditable) {
237
+ return false;
238
+ }
235
239
  if (editor && editor.checker) {
236
240
  return editor.checker(value, data[row][col].record);
237
241
  }
@@ -89,28 +89,20 @@ span.harvest-sheet-container:focus {
89
89
  z-index: 3;
90
90
  }
91
91
 
92
- &::before {
93
- position: absolute;
94
- top: -1px;
95
- left: 0;
96
- width: 100%;
97
- border-color: var(--cell-border-color);
98
- border-top: 1px solid var(--cell-border-color);
99
- content: '';
100
- }
101
92
 
102
93
  &.fixed-left::after {
103
94
  position: absolute;
95
+ z-index: 3;
104
96
  top: 0;
105
97
  bottom: -1px;
106
- right: -1px;
98
+ right: 0;
107
99
  width: 30px;
108
- border-left: 1px solid var(--cell-border-color);
100
+ // border-left: 1px solid var(--cell-border-color);
109
101
  content: '';
110
102
  pointer-events: none;
111
103
  transform: translate(100%);
112
104
  transition: box-shadow 0.3s;
113
- box-shadow: var(--cell-fixed-box-shadow-left);
105
+ // box-shadow: var(--cell-fixed-box-shadow-left);
114
106
  }
115
107
 
116
108
  &.fixed-right {
@@ -57,7 +57,10 @@ export var useContextMenu = function useContextMenu(dispatch, elementRef) {
57
57
  top: top,
58
58
  left: left
59
59
  },
60
- cellPosition: currentPos
60
+ cellPosition: {
61
+ row: currentPos.row,
62
+ col: currentPos.col - 1
63
+ }
61
64
  });
62
65
  };
63
66
  useEffect(function () {
@@ -40,8 +40,11 @@ export var DraggableShell = function DraggableShell(_ref) {
40
40
  var setWidth = contextSetWidth || _setWidth;
41
41
  var widths = contextWidths || _widths;
42
42
  var hasControl = showGroup || showSelect;
43
+ var offset = 1 + (hasControl ? 1 : 0);
43
44
  var thItems = useMemo(function () {
44
- var ths = [];
45
+ var ths = [/*#__PURE__*/_jsx("th", {
46
+ className: "cell cell-title read-only sheet-control sheet-row-cursor"
47
+ }, -2)];
45
48
  if (hasControl) {
46
49
  var _controlProps$group, _controlProps$check, _controlProps$check2, _controlProps$check3;
47
50
  ths.push( /*#__PURE__*/_jsxs("th", {
@@ -77,7 +80,7 @@ export var DraggableShell = function DraggableShell(_ref) {
77
80
  if (e.nativeEvent.offsetX <= target.offsetWidth - 8) {
78
81
  var _item$titleConfig4;
79
82
  eventBus.emit('col-select', {
80
- col: hasControl ? index + 1 : index,
83
+ col: index + offset,
81
84
  colSpan: (_item$titleConfig4 = item.titleConfig) === null || _item$titleConfig4 === void 0 ? void 0 : _item$titleConfig4.colSpan
82
85
  });
83
86
  }
@@ -123,9 +126,15 @@ export var DraggableShell = function DraggableShell(_ref) {
123
126
  }, (_item$dataIndex = item.dataIndex) !== null && _item$dataIndex !== void 0 ? _item$dataIndex : index));
124
127
  });
125
128
  return ths;
126
- }, [columns]);
129
+ }, [columns, offset]);
127
130
  var colItems = useMemo(function () {
128
- var cols = [];
131
+ var cols = [/*#__PURE__*/_jsx("col", {
132
+ className: classNames('sheet-control sheet-row-cursor'),
133
+ style: {
134
+ width: 0,
135
+ border: 'none'
136
+ }
137
+ }, "sheet-row-cursor")];
129
138
  if (hasControl) {
130
139
  cols.push( /*#__PURE__*/_jsx("col", {
131
140
  className: classNames('sheet-control'),
@@ -170,7 +179,7 @@ export var DraggableShell = function DraggableShell(_ref) {
170
179
  var newWidth = Math.max(Number(((_downRef$current$oldW2 = downRef.current.oldWidth) !== null && _downRef$current$oldW2 !== void 0 ? _downRef$current$oldW2 : 0) + (e.x - ((_downRef$current$oldX2 = downRef.current.oldX) !== null && _downRef$current$oldX2 !== void 0 ? _downRef$current$oldX2 : 0))), 50);
171
180
  var cellList = [].slice.call((_headRef$current = headRef.current) === null || _headRef$current === void 0 ? void 0 : _headRef$current.cells);
172
181
  var changeIndex = cellList.indexOf(downRef.current);
173
- var actualIndex = hasControl ? changeIndex - 1 : changeIndex;
182
+ var actualIndex = changeIndex - offset;
174
183
  var isDoubleSpan = (((_columns$actualIndex = columns[actualIndex]) === null || _columns$actualIndex === void 0 || (_columns$actualIndex = _columns$actualIndex.titleConfig) === null || _columns$actualIndex === void 0 ? void 0 : _columns$actualIndex.colSpan) || 0) > 1;
175
184
  var nextColumn = columns[actualIndex + 1] || {};
176
185
  var nextWidth = +String(nextColumn === null || nextColumn === void 0 ? void 0 : nextColumn.width).replace('px', '');
@@ -188,7 +197,7 @@ export var DraggableShell = function DraggableShell(_ref) {
188
197
  document.removeEventListener('mouseup', handleMouseUp);
189
198
  document.removeEventListener('mousemove', handleMouseMove);
190
199
  };
191
- }, [hasControl]);
200
+ }, [hasControl, offset]);
192
201
  return /*#__PURE__*/_jsxs(_Fragment, {
193
202
  children: [/*#__PURE__*/_jsxs("table", {
194
203
  className: classNames('header', 'harvest-sheet', className),
@@ -21,10 +21,10 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
21
21
  import { SheetEvent } from "../sheet/Event";
22
22
  import { DraggableShell } from "../shell/draggableShell";
23
23
  import { TableShell } from "../shell/tableShell";
24
+ import { AddButton } from "./addButton";
24
25
  import { GroupEvent, SelectionEvent } from "./events";
25
26
  import { formatGroupData, useGroupConfig } from "./useGroupConfig";
26
27
  import { formatSelectionData, useRowSelection } from "./useRowSelection";
27
- import { AddButton } from "./addButton";
28
28
  import { jsx as _jsx } from "react/jsx-runtime";
29
29
  import { jsxs as _jsxs } from "react/jsx-runtime";
30
30
  var Table = function Table(_ref) {
@@ -57,6 +57,7 @@ var Table = function Table(_ref) {
57
57
  var configWithChildren = !!groupConfig && !!dataSource.length;
58
58
  var hasChildren = dataHasChildren || configWithChildren;
59
59
  var hasControl = hasChildren || !!rowSelection;
60
+ var offset = hasControl ? 2 : 1;
60
61
  var _useRowSelection = useRowSelection(dataSource, rowSelection, hasChildren),
61
62
  _useRowSelection2 = _slicedToArray(_useRowSelection, 2),
62
63
  checkedRow = _useRowSelection2[0],
@@ -98,7 +99,7 @@ var Table = function Table(_ref) {
98
99
  col: item.col,
99
100
  row: item.row,
100
101
  id: item.id,
101
- key: columns[hasControl ? item.col - 1 : item.col].dataIndex,
102
+ key: columns[item.col - offset].dataIndex,
102
103
  value: item.value
103
104
  };
104
105
  }), extChange === null || extChange === void 0 ? void 0 : extChange.map(function (item) {
@@ -106,7 +107,7 @@ var Table = function Table(_ref) {
106
107
  col: item.col,
107
108
  row: item.row,
108
109
  id: item.id,
109
- key: columns[hasControl ? item.col - 1 : item.col].dataIndex,
110
+ key: columns[item.col - offset].dataIndex,
110
111
  value: item.value
111
112
  };
112
113
  }));
@@ -123,6 +123,18 @@ export var formatGroupData = function formatGroupData(param) {
123
123
  rowId = itemRow[rowKey];
124
124
  }
125
125
  }
126
+ dataRow.push({
127
+ id: rowId,
128
+ row: currentIndex,
129
+ col: -2,
130
+ editable: false,
131
+ readonly: true,
132
+ fixed: 'left',
133
+ valueViewer: function valueViewer() {
134
+ return null;
135
+ },
136
+ className: 'sheet-control sheet-row-cursor'
137
+ });
126
138
  dataRow.push({
127
139
  id: rowId,
128
140
  row: currentIndex,
@@ -130,7 +142,7 @@ export var formatGroupData = function formatGroupData(param) {
130
142
  editable: !((columns === null || columns === void 0 ? void 0 : columns[0].editable) instanceof Function) ? columns === null || columns === void 0 || (_columns$ = columns[0]) === null || _columns$ === void 0 ? void 0 : _columns$.editable : columns === null || columns === void 0 || (_columns$2 = columns[0]) === null || _columns$2 === void 0 ? void 0 : _columns$2.editable('', itemRow, currentIndex),
131
143
  readonly: !((columns === null || columns === void 0 ? void 0 : columns[0].readonly) instanceof Function) ? columns === null || columns === void 0 || (_columns$3 = columns[0]) === null || _columns$3 === void 0 ? void 0 : _columns$3.readonly : columns === null || columns === void 0 || (_columns$4 = columns[0]) === null || _columns$4 === void 0 ? void 0 : _columns$4.readonly('', itemRow, currentIndex),
132
144
  align: 'center',
133
- fixed: 'unset',
145
+ // fixed: 'unset',
134
146
  valueViewer: GroupViewer,
135
147
  className: 'sheet-control'
136
148
  });
@@ -2,7 +2,18 @@ import { SheetTableType, SheetType } from "../..";
2
2
  export declare const useRowSelection: (dataSource: Record<string, unknown>[], rowSelection?: SheetTableType.TableRowSelection, hasChildren?: boolean) => [boolean[], (value: boolean[]) => void];
3
3
  export declare const formatSelectionData: (param: Pick<SheetTableType.TableProps, "columns" | "dataSource" | "rowKey" | "rowSelection"> & {
4
4
  checked: boolean[];
5
- }) => {
5
+ }) => ({
6
+ id: string;
7
+ row: number;
8
+ col: number;
9
+ editable: boolean;
10
+ readonly: boolean;
11
+ fixed: string;
12
+ valueViewer: () => null;
13
+ className: string;
14
+ align?: undefined;
15
+ value?: undefined;
16
+ } | {
6
17
  id: string;
7
18
  row: number;
8
19
  col: number;
@@ -11,4 +22,6 @@ export declare const formatSelectionData: (param: Pick<SheetTableType.TableProps
11
22
  value: string;
12
23
  valueViewer: SheetType.CellViewer;
13
24
  className: string;
14
- }[][];
25
+ editable?: undefined;
26
+ fixed?: undefined;
27
+ })[][];
@@ -39,6 +39,18 @@ export var formatSelectionData = function formatSelectionData(param) {
39
39
  }
40
40
  }
41
41
  var rows = [];
42
+ rows.push({
43
+ id: rowId,
44
+ row: row,
45
+ col: -2,
46
+ editable: false,
47
+ readonly: true,
48
+ fixed: 'left',
49
+ valueViewer: function valueViewer() {
50
+ return null;
51
+ },
52
+ className: 'sheet-control sheet-row-cursor'
53
+ });
42
54
  if (rowSelection) {
43
55
  rows.push({
44
56
  id: rowId,
package/dist/core/util.js CHANGED
@@ -463,10 +463,10 @@ export var stripRowIndex = function stripRowIndex(data) {
463
463
  endIndex: 0
464
464
  };
465
465
  var rowData = data[0];
466
- var startIndex = 0,
466
+ var startIndex = 1,
467
467
  endIndex = rowData.length - 1;
468
- if (rowData[0].fixed && !rowData[0].editable) {
469
- startIndex = 1;
468
+ if (!rowData[1].editable) {
469
+ startIndex = 2;
470
470
  }
471
471
  if (rowData[rowData.length - 1].fixed && !rowData[rowData.length - 1].editable) {
472
472
  endIndex = rowData.length - 2;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhenliang/sheet",
3
- "version": "0.1.63",
3
+ "version": "0.1.65-beta",
4
4
  "description": "A react library developed with dumi",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",