@zhenliang/sheet 0.1.6 → 0.1.8
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.
- package/dist/core/editor/cascaderEditor/index.less +4 -0
- package/dist/core/editor/numberEditor/index.js +3 -0
- package/dist/core/editor/selectEditor/index.js +16 -3
- package/dist/core/editor/selectEditor/index.less +3 -1
- package/dist/core/reducers/sideEffectReducer.js +1 -1
- package/dist/core/shell/draggableShell/index.d.ts +1 -0
- package/dist/core/shell/draggableShell/index.js +1 -1
- package/dist/core/shell/tableShell.d.ts +1 -0
- package/dist/core/table/index.js +0 -1
- package/dist/core/table/useGroupConfig.js +0 -3
- package/dist/core/util.d.ts +1 -1
- package/dist/core/util.js +6 -4
- package/dist/core/viewer/selectorViewer/index.js +7 -3
- package/dist/example/antComponent.js +7 -4
- package/dist/example/basic.js +1 -0
- package/dist/example/ellipsis.js +1 -0
- package/dist/example/fixed.js +1 -0
- package/dist/example/selection.js +1 -0
- package/dist/hooks/useEventBus.d.ts +1 -0
- package/package.json +1 -1
|
@@ -92,6 +92,9 @@ export var getNumberEditor = function getNumberEditor(extraProps) {
|
|
|
92
92
|
};
|
|
93
93
|
NumberEditor.checker = function (value) {
|
|
94
94
|
var _String2;
|
|
95
|
+
if (!value) {
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
95
98
|
// parse number with thousands separator
|
|
96
99
|
var result = parseFloat((_String2 = String(value)) === null || _String2 === void 0 ? void 0 : _String2.replace(/,/g, ''));
|
|
97
100
|
if (isNaN(result) || isNaN(value)) {
|
|
@@ -4,10 +4,17 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
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); }
|
|
7
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
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
|
+
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
|
+
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; } }
|
|
12
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
13
|
/* eslint-disable eqeqeq */
|
|
8
14
|
|
|
9
15
|
import { Select } from 'antd';
|
|
10
16
|
import 'antd/es/select/style/index.css';
|
|
17
|
+
import { useState } from 'react';
|
|
11
18
|
import { isNil } from 'lodash';
|
|
12
19
|
import "./index.less";
|
|
13
20
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
@@ -18,6 +25,10 @@ export var getSelectEditor = function getSelectEditor(options) {
|
|
|
18
25
|
var extra = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : /*#__PURE__*/_jsx(_Fragment, {});
|
|
19
26
|
var selectProps = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
20
27
|
var SelectEditor = function SelectEditor(props) {
|
|
28
|
+
var _useState = useState(true),
|
|
29
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
30
|
+
isOpen = _useState2[0],
|
|
31
|
+
setIsOpen = _useState2[1];
|
|
21
32
|
var value = props.value,
|
|
22
33
|
onConfirm = props.onConfirm;
|
|
23
34
|
var handleChange = function handleChange(opt) {
|
|
@@ -31,16 +42,18 @@ export var getSelectEditor = function getSelectEditor(options) {
|
|
|
31
42
|
}
|
|
32
43
|
};
|
|
33
44
|
var dropdown = function dropdown(menu) {
|
|
34
|
-
return /*#__PURE__*/_jsxs(
|
|
45
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
46
|
+
onClick: function onClick() {
|
|
47
|
+
setIsOpen(false);
|
|
48
|
+
},
|
|
35
49
|
children: [menu, extra]
|
|
36
50
|
});
|
|
37
51
|
};
|
|
38
52
|
return /*#__PURE__*/_jsx(Select, _objectSpread(_objectSpread({}, selectProps), {}, {
|
|
39
53
|
autoFocus: true,
|
|
40
54
|
className: "select-editor",
|
|
41
|
-
defaultOpen: true,
|
|
42
55
|
allowClear: true,
|
|
43
|
-
open:
|
|
56
|
+
open: isOpen,
|
|
44
57
|
onMouseDown: function onMouseDown(e) {
|
|
45
58
|
e.stopPropagation();
|
|
46
59
|
},
|
|
@@ -166,7 +166,7 @@ export var sideEffectReducer = {
|
|
|
166
166
|
value: ''
|
|
167
167
|
});
|
|
168
168
|
var text = copyData.value.trimStart();
|
|
169
|
-
stringToClipboardData(text);
|
|
169
|
+
stringToClipboardData(text, cellIndex.length);
|
|
170
170
|
},
|
|
171
171
|
paste: function paste(dispatch, getState) {
|
|
172
172
|
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
@@ -88,7 +88,7 @@ export var DraggableShell = function DraggableShell(_ref) {
|
|
|
88
88
|
},
|
|
89
89
|
onMouseMove: function onMouseMove(e) {
|
|
90
90
|
var target = e.target;
|
|
91
|
-
if (e.nativeEvent.offsetX > target.offsetWidth -
|
|
91
|
+
if (e.nativeEvent.offsetX > target.offsetWidth - 8) {
|
|
92
92
|
target.style.cursor = 'col-resize';
|
|
93
93
|
} else {
|
|
94
94
|
target.style.cursor = 'default';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import type { SheetType } from "../../type";
|
|
2
3
|
import './draggableShell/index.less';
|
|
3
4
|
export declare const TableShell: ({ columns, className, showGroup, showSelect, controlProps, controlWidth, }: SheetType.SheetShell) => import("react").FC<{
|
package/dist/core/table/index.js
CHANGED
|
@@ -232,7 +232,6 @@ var Table = function Table(_ref) {
|
|
|
232
232
|
return !value;
|
|
233
233
|
}));
|
|
234
234
|
var headSelection = !!rowSelection;
|
|
235
|
-
console.log('shell-render', rowGroupConfig === null || rowGroupConfig === void 0 ? void 0 : rowGroupConfig.defaultOpen, headGroupOpen);
|
|
236
235
|
var WrappedTableShell = useMemo(function () {
|
|
237
236
|
console.log('shell-render', '损耗性能大');
|
|
238
237
|
if (draggable) {
|
|
@@ -26,7 +26,6 @@ export var useGroupConfig = function useGroupConfig(dataSource, tableGroupConfig
|
|
|
26
26
|
}, [dataSource]);
|
|
27
27
|
useEffect(function () {
|
|
28
28
|
if (!hasChildren) return;
|
|
29
|
-
console.log('groupConfigEffect', dataSource.length);
|
|
30
29
|
var rowConfig = dataSourceToRowConfig(dataSource, tableGroupConfig === null || tableGroupConfig === void 0 ? void 0 : tableGroupConfig.defaultOpen);
|
|
31
30
|
if (groupConfigRef.current) {
|
|
32
31
|
groupConfigRef.current.groups.forEach(function (_ref, index) {
|
|
@@ -39,10 +38,8 @@ export var useGroupConfig = function useGroupConfig(dataSource, tableGroupConfig
|
|
|
39
38
|
});
|
|
40
39
|
}
|
|
41
40
|
setGroupConfig(rowConfig);
|
|
42
|
-
console.log('groupConfigEffect', rowConfig.groups, rowConfig.groupOpen);
|
|
43
41
|
groupConfigRef.current = rowConfig;
|
|
44
42
|
}, [dataSource.length, childrenLength, hasChildren]);
|
|
45
|
-
console.log('groupConfigEffect', dataSource.length, childrenLength);
|
|
46
43
|
var handleGroupChange = useCallback(function (value) {
|
|
47
44
|
setGroupConfig(value);
|
|
48
45
|
groupConfigRef.current = value;
|
package/dist/core/util.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export declare function flatRowColIndex(start?: SheetType.CellPosition, end?: Sh
|
|
|
14
14
|
export declare function flatRowCol(start?: SheetType.CellPosition, end?: SheetType.CellPosition): string[];
|
|
15
15
|
export declare function isInputKey(keyCode: number): boolean;
|
|
16
16
|
export declare function classNames(...args: (string | null | undefined)[]): string;
|
|
17
|
-
export declare function stringToClipboardData(str: string): void;
|
|
17
|
+
export declare function stringToClipboardData(str: string, count: number): void;
|
|
18
18
|
export declare const defaultParsePaste: (str: string) => string[][];
|
|
19
19
|
export declare function clipboardDataToString(): Promise<string[][]>;
|
|
20
20
|
export declare function formatDataToCell({ start, editing, end, data, pasteData, groupConfig, freePaste, }: Partial<SheetType.UpdateStateType> & {
|
package/dist/core/util.js
CHANGED
|
@@ -14,6 +14,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
14
14
|
/* eslint-disable no-param-reassign */
|
|
15
15
|
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
16
16
|
|
|
17
|
+
import { message } from 'antd';
|
|
17
18
|
import { cloneDeep, get, isNil, range } from 'lodash';
|
|
18
19
|
export function findParentTd(el) {
|
|
19
20
|
if (!el) return null;
|
|
@@ -85,12 +86,14 @@ export function classNames() {
|
|
|
85
86
|
}
|
|
86
87
|
return args.filter(Boolean).join(' ');
|
|
87
88
|
}
|
|
88
|
-
export function stringToClipboardData(str) {
|
|
89
|
+
export function stringToClipboardData(str, count) {
|
|
89
90
|
// navigator.clipboard.writeText(str);
|
|
90
91
|
navigator.clipboard.writeText(str).then(function () {
|
|
91
|
-
console.log('复制成功');
|
|
92
|
+
// console.log('复制成功');
|
|
93
|
+
message.success("\u5DF2\u590D\u5236".concat(count, "\u4E2A\u5355\u5143\u683C"));
|
|
92
94
|
}, function () {
|
|
93
|
-
console.error('复制失败');
|
|
95
|
+
// console.error('复制失败');
|
|
96
|
+
message.info("\u590D\u5236\u5931\u8D25");
|
|
94
97
|
});
|
|
95
98
|
}
|
|
96
99
|
export var defaultParsePaste = function defaultParsePaste(str) {
|
|
@@ -255,7 +258,6 @@ export var optionsTransferToValue = function optionsTransferToValue(options, val
|
|
|
255
258
|
}
|
|
256
259
|
} else if (get(options[i], key) === val) {
|
|
257
260
|
values.push(value);
|
|
258
|
-
console.log('cascader', get(options[i], key), val, value);
|
|
259
261
|
break;
|
|
260
262
|
} else {
|
|
261
263
|
values = [];
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
2
|
/* eslint-disable eqeqeq */
|
|
2
3
|
// == string 和 number 类型忽略
|
|
3
4
|
|
|
4
5
|
export var getSelectorViewer = function getSelectorViewer(options) {
|
|
5
6
|
var TypeViewer = function TypeViewer(props) {
|
|
6
7
|
var _options$find;
|
|
7
|
-
return (
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
return /*#__PURE__*/_jsx("span", {
|
|
9
|
+
className: "value-viewer",
|
|
10
|
+
children: ((_options$find = options.find(function (item) {
|
|
11
|
+
return item.label === props.value || "".concat(item.value) === "".concat(props.value);
|
|
12
|
+
})) === null || _options$find === void 0 ? void 0 : _options$find.label) || null
|
|
13
|
+
});
|
|
10
14
|
};
|
|
11
15
|
return TypeViewer;
|
|
12
16
|
};
|
|
@@ -19,6 +19,7 @@ import { cloneDeep, random } from 'lodash';
|
|
|
19
19
|
import React, { useCallback, useMemo, useRef, useState } from 'react';
|
|
20
20
|
import { getCascaderEditor, getDateEditor, getNumberEditor, getSelectEditor } from "../core/editor";
|
|
21
21
|
import Table from "../core/table";
|
|
22
|
+
import { getSelectorViewer } from "../core/viewer";
|
|
22
23
|
import { BtnViewer } from "../core/viewer/btnViewer";
|
|
23
24
|
import { getCascaderViewer } from "../core/viewer/cascaderViewer";
|
|
24
25
|
import { EditViewer } from "../core/viewer/editViewer";
|
|
@@ -48,13 +49,14 @@ var SelectorOptions = [{
|
|
|
48
49
|
}];
|
|
49
50
|
var getTypeViewer = function getTypeViewer(options) {
|
|
50
51
|
var TypeViewer = function TypeViewer(props) {
|
|
51
|
-
|
|
52
|
+
var _options$find;
|
|
53
|
+
console.log('getTypeViewer', options);
|
|
54
|
+
return (_options$find = options.find(function (item) {
|
|
52
55
|
return item.label === props.value || item.value == props.value;
|
|
53
|
-
}).label;
|
|
56
|
+
})) === null || _options$find === void 0 ? void 0 : _options$find.label;
|
|
54
57
|
};
|
|
55
58
|
return TypeViewer;
|
|
56
59
|
};
|
|
57
|
-
var TypeSelector = getSelectEditor(SelectorOptions, 'label');
|
|
58
60
|
var cascaderOptions = [{
|
|
59
61
|
value: 'zhejiang',
|
|
60
62
|
label: 'Zhejiang',
|
|
@@ -118,7 +120,7 @@ var columns = [{
|
|
|
118
120
|
title: 'select',
|
|
119
121
|
width: 200,
|
|
120
122
|
dataIndex: 'select',
|
|
121
|
-
render:
|
|
123
|
+
render: getSelectorViewer(SelectorOptions),
|
|
122
124
|
editor: getSelectEditor(SelectorOptions, 'label')
|
|
123
125
|
}, {
|
|
124
126
|
title: 'Column 2',
|
|
@@ -257,6 +259,7 @@ var App = function App() {
|
|
|
257
259
|
}, [options]);
|
|
258
260
|
return /*#__PURE__*/_jsx(Table, {
|
|
259
261
|
freePaste: true,
|
|
262
|
+
draggable: true,
|
|
260
263
|
sheetInstance: sheetInstance,
|
|
261
264
|
columns: antColumns,
|
|
262
265
|
dataSource: state,
|
package/dist/example/basic.js
CHANGED
package/dist/example/ellipsis.js
CHANGED
package/dist/example/fixed.js
CHANGED