@zhenliang/sheet 0.1.81 → 0.1.82

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.
@@ -76,7 +76,9 @@ export var mouseReducer = {
76
76
  row = _ref2.row,
77
77
  col = _ref2.col;
78
78
  var data = state.data;
79
- if (state.mouseDown === false || isFreezedCell(row, col, data)) return state;
79
+ if (state.mouseDown === false || isFreezedCell(row, col, data)) {
80
+ return state;
81
+ }
80
82
  if (state.isIndex && state.start && state.end && (data === null || data === void 0 ? void 0 : data[row][col].dataIndex) === 'index') {
81
83
  var _state$end;
82
84
  return _objectSpread(_objectSpread({}, state), {}, {
@@ -106,7 +108,9 @@ export var mouseReducer = {
106
108
  row = _ref3.row,
107
109
  col = _ref3.col;
108
110
  var data = state.data;
109
- if (state.mouseDown === false || isFreezedCell(row, col, data)) return state;
111
+ if (state.mouseDown === false || isFreezedCell(row, col, data)) {
112
+ return state;
113
+ }
110
114
  if (state.isIndex && state.end) {
111
115
  var _state$end2;
112
116
  return _objectSpread(_objectSpread({}, state), {}, {
@@ -192,12 +196,12 @@ export var mouseReducer = {
192
196
  });
193
197
  },
194
198
  mouseLeaveInterval: function mouseLeaveInterval(state, payload) {
195
- var _data$, _end$col;
199
+ var _data$, _end$col, _data$2, _end$col2;
196
200
  var _ref5 = payload,
197
201
  end = _ref5.end;
198
202
  var data = state.data;
199
- // fixed 列不选中
200
- if (data !== null && data !== void 0 && (_data$ = data[0]) !== null && _data$ !== void 0 && (_data$ = _data$[(_end$col = end.col) !== null && _end$col !== void 0 ? _end$col : 0]) !== null && _data$ !== void 0 && _data$.fixed) {
203
+ //fixed 列不选中
204
+ if (data !== null && data !== void 0 && (_data$ = data[0]) !== null && _data$ !== void 0 && (_data$ = _data$[(_end$col = end.col) !== null && _end$col !== void 0 ? _end$col : 0]) !== null && _data$ !== void 0 && _data$.fixed && !(data !== null && data !== void 0 && (_data$2 = data[0]) !== null && _data$2 !== void 0 && (_data$2 = _data$2[(_end$col2 = end.col) !== null && _end$col2 !== void 0 ? _end$col2 : 0]) !== null && _data$2 !== void 0 && _data$2.fixedAllowSelect)) {
201
205
  return state;
202
206
  }
203
207
  return _objectSpread(_objectSpread({}, state), {}, {
@@ -1,6 +1,6 @@
1
1
  import { useMouse } from "../..";
2
2
  import { useCallback, useEffect, useRef } from 'react';
3
- import { extractDataRowAndCol, findParentTd, isSiblingControl } from "../util";
3
+ import { extractDataRowAndCol, findParentTd, isFreezedCell, isSiblingControl } from "../util";
4
4
  var rowCount = 10; //每秒10行
5
5
  var colCount = 5; //每秒5列
6
6
 
@@ -131,7 +131,10 @@ export var useMouseEvent = function useMouseEvent(dispatch, elementRef) {
131
131
  e.preventDefault();
132
132
  if (!((_elementRef$current5 = elementRef.current) !== null && _elementRef$current5 !== void 0 && _elementRef$current5.contains(e.target))) return;
133
133
  var currentCell = findParentTd(e.target);
134
- if (!currentCell || currentCell.classList.contains('fixed')) return;
134
+ // if (!currentCell || currentCell.classList.contains('fixed')) return;
135
+ if (!currentCell) {
136
+ return;
137
+ }
135
138
  (_elementRef$current6 = elementRef.current) === null || _elementRef$current6 === void 0 || _elementRef$current6.style.setProperty('scroll-behavior', 'smooth');
136
139
  var currentPos = extractDataRowAndCol(currentCell);
137
140
  dispatch({
@@ -141,8 +144,13 @@ export var useMouseEvent = function useMouseEvent(dispatch, elementRef) {
141
144
  dispatch(function (d, getState) {
142
145
  var _elementRef$current7;
143
146
  var _getState = getState(),
144
- mouseDown = _getState.mouseDown;
145
- if (!mouseDown || !elementRef.current) return;
147
+ mouseDown = _getState.mouseDown,
148
+ data = _getState.data;
149
+ var row = currentPos.row,
150
+ col = currentPos.col;
151
+ if (!mouseDown || !elementRef.current || isFreezedCell(row, col, data)) {
152
+ return;
153
+ }
146
154
  var cellBounding = currentCell.getBoundingClientRect();
147
155
  var parentBounding = (_elementRef$current7 = elementRef.current) === null || _elementRef$current7 === void 0 ? void 0 : _elementRef$current7.getBoundingClientRect();
148
156
  var left = cellBounding.left,
@@ -193,7 +201,8 @@ export var useMouseEvent = function useMouseEvent(dispatch, elementRef) {
193
201
 
194
202
  resetInterval();
195
203
  var currentCell = findParentTd(e.target);
196
- if (!currentCell || currentCell.classList.contains('fixed')) {
204
+ // if (!currentCell || currentCell.classList.contains('fixed')) {
205
+ if (!currentCell) {
197
206
  dispatch({
198
207
  type: 'changes',
199
208
  payload: {
@@ -146,7 +146,9 @@ export var DraggableShell = function DraggableShell(_ref) {
146
146
  className: classNames('cell', 'cell-title', 'read-only', item.fixed && 'fixed', item.fixed && "fixed-".concat(item.fixed), (_item$titleConfig3 = item.titleConfig) === null || _item$titleConfig3 === void 0 ? void 0 : _item$titleConfig3.className, isLastFixedLeft && isScrolledOver ? "last-fixed-left" : '', isFirstFixedRight && !isScrolledToEnd ? "first-fixed-right" : ''),
147
147
  colSpan: (_item$titleConfig4 = item.titleConfig) === null || _item$titleConfig4 === void 0 ? void 0 : _item$titleConfig4.colSpan,
148
148
  onClick: function onClick(e) {
149
- if (item.fixed) return;
149
+ if (item.fixed && !item.fixedAllowSelect) {
150
+ return;
151
+ }
150
152
  var target = e.target;
151
153
  if (e.nativeEvent.offsetX <= target.offsetWidth - 8) {
152
154
  var _item$titleConfig5;
@@ -167,6 +167,7 @@ export var formatGroupData = function formatGroupData(param) {
167
167
  dataIndex: colInfo.dataIndex,
168
168
  key: colInfo.key,
169
169
  allowClear: colInfo.allowClear,
170
+ fixedAllowSelect: colInfo.fixedAllowSelect,
170
171
  col: col
171
172
  });
172
173
  });
@@ -85,6 +85,7 @@ export var formatSelectionData = function formatSelectionData(param) {
85
85
  col: col,
86
86
  dataIndex: colInfo.dataIndex,
87
87
  allowClear: colInfo.allowClear,
88
+ fixedAllowSelect: colInfo.fixedAllowSelect,
88
89
  key: colInfo.key
89
90
  });
90
91
  });
package/dist/core/util.js CHANGED
@@ -459,7 +459,7 @@ export var calcMenuPosition = function calcMenuPosition(_ref5) {
459
459
  };
460
460
  export var isFreezedCell = function isFreezedCell(row, col, data) {
461
461
  var _data$row$col$classNa;
462
- var isFreezed = (data === null || data === void 0 ? void 0 : data[row][col].fixed) || (data === null || data === void 0 || (_data$row$col$classNa = data[row][col].className) === null || _data$row$col$classNa === void 0 ? void 0 : _data$row$col$classNa.includes('sheet-control'));
462
+ var isFreezed = (data === null || data === void 0 ? void 0 : data[row][col].fixed) && !(data !== null && data !== void 0 && data[row][col].fixedAllowSelect) || (data === null || data === void 0 || (_data$row$col$classNa = data[row][col].className) === null || _data$row$col$classNa === void 0 ? void 0 : _data$row$col$classNa.includes('sheet-control'));
463
463
  return !!isFreezed;
464
464
  };
465
465
  export var stripRowIndex = function stripRowIndex(data) {
@@ -507,7 +507,7 @@ export var isSearchElement = function isSearchElement(tableRootNode, target) {
507
507
  var _tableRootNode$nextSi2;
508
508
  return (_tableRootNode$nextSi2 = tableRootNode.nextSibling) === null || _tableRootNode$nextSi2 === void 0 || (_tableRootNode$nextSi2 = _tableRootNode$nextSi2.nextSibling) === null || _tableRootNode$nextSi2 === void 0 ? void 0 : _tableRootNode$nextSi2.contains(target);
509
509
  };
510
- var punctuationMap = new Map([["", ","], ["", ":"], ["", ";"]]);
510
+ var punctuationMap = new Map([['', ','], ['', ':'], ['', ';']]);
511
511
  export var noramlizeSearch = function noramlizeSearch(target) {
512
512
  if (!target) {
513
513
  return target;
@@ -515,7 +515,7 @@ export var noramlizeSearch = function noramlizeSearch(target) {
515
515
  var lower = target.toLowerCase();
516
516
  // 逗号分号
517
517
  punctuationMap.forEach(function (value, key) {
518
- lower = lower.replace(new RegExp(key, "g"), value);
518
+ lower = lower.replace(new RegExp(key, 'g'), value);
519
519
  });
520
520
  return lower;
521
521
  };
@@ -528,10 +528,10 @@ export var searchInclude = function searchInclude(search, compare) {
528
528
  };
529
529
  export var getTextWidth = function getTextWidth(text) {
530
530
  // 创建隐藏的临时元素
531
- var tempElement = document.createElement("span");
532
- tempElement.style.visibility = "hidden";
533
- tempElement.style.whiteSpace = "pre"; // 保持空格和换行的格式
534
- tempElement.style.display = "inline-block";
531
+ var tempElement = document.createElement('span');
532
+ tempElement.style.visibility = 'hidden';
533
+ tempElement.style.whiteSpace = 'pre'; // 保持空格和换行的格式
534
+ tempElement.style.display = 'inline-block';
535
535
  tempElement.textContent = text;
536
536
  document.body.appendChild(tempElement);
537
537
  var width = tempElement.offsetWidth;
@@ -107,7 +107,8 @@ var columns = [{
107
107
  readonly: function readonly(value, record, row) {
108
108
  return row === 1;
109
109
  },
110
- fixed: 'left'
110
+ fixed: 'left',
111
+ fixedAllowSelect: true
111
112
  }, {
112
113
  title: 'date',
113
114
  width: 150,
@@ -30,6 +30,7 @@ export type Cell = {
30
30
  fixed?: Omit<CellAlign, 'center'>;
31
31
  value?: string | number | null;
32
32
  allowClear?: boolean;
33
+ fixedAllowSelect?: boolean;
33
34
  };
34
35
  export type FixedInfo = {
35
36
  isFirstFixedRight: boolean;
@@ -39,6 +39,7 @@ export type ColumnProps = {
39
39
  render?: SheetType.CellViewer;
40
40
  editor?: SheetType.CellEditor;
41
41
  searchKey?: (value: unknown, record: Record<string, unknown>) => string;
42
+ fixedAllowSelect?: boolean | RecordRowMap<boolean>;
42
43
  };
43
44
  export type TableChange = {
44
45
  col?: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhenliang/sheet",
3
- "version": "0.1.81",
3
+ "version": "0.1.82",
4
4
  "description": "A react library developed with dumi",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",