@zhenliang/sheet 0.1.83 → 0.1.84-beta-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.
@@ -176,10 +176,28 @@ export var stateReducer = _objectSpread({
176
176
  },
177
177
  select: function select(state, payload) {
178
178
  var oldStart = state.start,
179
- oldEnd = state.end;
179
+ oldEnd = state.end,
180
+ data = state.data;
180
181
  var _ref3 = payload,
181
182
  start = _ref3.start,
182
183
  end = _ref3.end;
184
+ if (data) {
185
+ var _stripRowIndex = stripRowIndex(data),
186
+ startIndex = _stripRowIndex.startIndex,
187
+ endIndex = _stripRowIndex.endIndex;
188
+ return _objectSpread(_objectSpread({}, state), {}, {
189
+ start: _objectSpread(_objectSpread({}, start), {}, {
190
+ col: Math.max(startIndex, start.col)
191
+ }),
192
+ end: _objectSpread(_objectSpread({}, end), {}, {
193
+ col: Math.min(endIndex, end.col)
194
+ }),
195
+ lastSelected: {
196
+ start: oldStart,
197
+ end: oldEnd
198
+ }
199
+ });
200
+ }
183
201
  return _objectSpread(_objectSpread({}, state), {}, {
184
202
  start: start,
185
203
  end: end,
@@ -192,9 +210,9 @@ export var stateReducer = _objectSpread({
192
210
  selectOneRow: function selectOneRow(state, payload) {
193
211
  var _state$data4 = state.data,
194
212
  data = _state$data4 === void 0 ? [] : _state$data4;
195
- var _stripRowIndex = stripRowIndex(data),
196
- startIndex = _stripRowIndex.startIndex,
197
- endIndex = _stripRowIndex.endIndex;
213
+ var _stripRowIndex2 = stripRowIndex(data),
214
+ startIndex = _stripRowIndex2.startIndex,
215
+ endIndex = _stripRowIndex2.endIndex;
198
216
  if (startIndex >= 0 && endIndex >= 0) {
199
217
  return _objectSpread(_objectSpread({}, state), {}, {
200
218
  start: {
@@ -1,4 +1,5 @@
1
1
  import type { SheetType } from "../type";
2
+ import { Cell } from '../type/sheet';
2
3
  export declare function findParentTd(el: HTMLElement): HTMLElement | null;
3
4
  export declare function extractDataRowAndCol(el: HTMLElement): {
4
5
  row: number;
package/dist/core/util.js CHANGED
@@ -97,7 +97,11 @@ export function stringToClipboardData(str, count) {
97
97
  });
98
98
  }
99
99
  export var defaultParsePaste = function defaultParsePaste(str) {
100
- return str.trimEnd().split(/\r\n|\n|\r/).map(function (row) {
100
+ var cleanStr = str;
101
+ if (str.endsWith('\r\n')) {
102
+ cleanStr = str.slice(0, -2);
103
+ }
104
+ return cleanStr.split(/\r\n|\n|\r/).map(function (row) {
101
105
  return row.split('\t');
102
106
  });
103
107
  };
@@ -19,17 +19,32 @@ import 'antd/dist/antd.css';
19
19
  import React, { useCallback, useState } from 'react';
20
20
  import { jsx as _jsx } from "react/jsx-runtime";
21
21
  var columns = [{
22
- title: 'Name',
23
- dataIndex: 'name',
22
+ title: '#',
23
+ dataIndex: 'index',
24
24
  render: function render(_ref) {
25
25
  var value = _ref.value;
26
26
  return /*#__PURE__*/_jsx("a", {
27
27
  children: value
28
28
  });
29
29
  }
30
+ }, {
31
+ title: 'Name',
32
+ dataIndex: 'name',
33
+ render: function render(_ref2) {
34
+ var value = _ref2.value;
35
+ return /*#__PURE__*/_jsx("a", {
36
+ children: value
37
+ });
38
+ }
30
39
  }, {
31
40
  title: 'Age',
32
41
  dataIndex: 'age'
42
+ }, {
43
+ title: 'Age1',
44
+ dataIndex: 'age1'
45
+ }, {
46
+ title: 'Age2',
47
+ dataIndex: 'age2'
33
48
  }, {
34
49
  title: 'Address',
35
50
  dataIndex: 'address'
@@ -62,10 +77,10 @@ var App = function App() {
62
77
  setData = _useState2[1];
63
78
  var onChange = useCallback(function (changes) {
64
79
  var newData = _toConsumableArray(dataSource);
65
- changes.forEach(function (_ref2) {
66
- var row = _ref2.row,
67
- key = _ref2.key,
68
- value = _ref2.value;
80
+ changes.forEach(function (_ref3) {
81
+ var row = _ref3.row,
82
+ key = _ref3.key,
83
+ value = _ref3.value;
69
84
  newData[row] = _objectSpread(_objectSpread({}, newData[row]), {}, _defineProperty({}, key, key === 'tags' ? value.split(',') : value));
70
85
  });
71
86
  setData(newData);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhenliang/sheet",
3
- "version": "0.1.83",
3
+ "version": "0.1.84-beta-2",
4
4
  "description": "A react library developed with dumi",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",