@zhenliang/sheet 0.1.4 → 0.1.7
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/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/events.js +2 -1
- package/dist/core/table/index.js +2 -2
- 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 +1 -0
- 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/dist/type/sheet.d.ts +1 -0
- package/package.json +1 -1
|
@@ -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<{
|
|
@@ -77,7 +77,8 @@ export var GroupEvent = function GroupEvent(props) {
|
|
|
77
77
|
name: "group-open-title",
|
|
78
78
|
handler: function handler(value) {
|
|
79
79
|
onGroupChange && onGroupChange(_objectSpread(_objectSpread({}, rowGroupConfig), {}, {
|
|
80
|
-
groupOpen: Array(rowGroupConfig.groupOpen.length).fill(value)
|
|
80
|
+
groupOpen: Array(rowGroupConfig === null || rowGroupConfig === void 0 ? void 0 : rowGroupConfig.groupOpen.length).fill(value),
|
|
81
|
+
defaultOpen: !groups.length ? value : undefined
|
|
81
82
|
}));
|
|
82
83
|
sheetInstance === null || sheetInstance === void 0 ? void 0 : sheetInstance.pushToHistory({
|
|
83
84
|
type: 'Custom',
|
package/dist/core/table/index.js
CHANGED
|
@@ -33,7 +33,7 @@ import { useRowSelection } from "./useRowSelection";
|
|
|
33
33
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
34
34
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
35
35
|
var Table = function Table(_ref) {
|
|
36
|
-
var _rowGroupConfig$group;
|
|
36
|
+
var _rowGroupConfig$group, _rowGroupConfig$group2;
|
|
37
37
|
var sheetRef = _ref.sheetInstance,
|
|
38
38
|
columns = _ref.columns,
|
|
39
39
|
dataSource = _ref.dataSource,
|
|
@@ -228,7 +228,7 @@ var Table = function Table(_ref) {
|
|
|
228
228
|
newChecked[currentRow] = !newChecked[currentRow];
|
|
229
229
|
setCheckedRow(newChecked);
|
|
230
230
|
}, [sheetInstance, checkedRow]);
|
|
231
|
-
var headGroupOpen = !(rowGroupConfig !== null && rowGroupConfig !== void 0 && (_rowGroupConfig$group = rowGroupConfig.groupOpen) !== null && _rowGroupConfig$group !== void 0 && _rowGroupConfig$group.some(function (value) {
|
|
231
|
+
var headGroupOpen = !(rowGroupConfig !== null && rowGroupConfig !== void 0 && (_rowGroupConfig$group = rowGroupConfig.groupOpen) !== null && _rowGroupConfig$group !== void 0 && _rowGroupConfig$group.length) ? !!(rowGroupConfig !== null && rowGroupConfig !== void 0 && rowGroupConfig.defaultOpen) : !(rowGroupConfig !== null && rowGroupConfig !== void 0 && (_rowGroupConfig$group2 = rowGroupConfig.groupOpen) !== null && _rowGroupConfig$group2 !== void 0 && _rowGroupConfig$group2.some(function (value) {
|
|
232
232
|
return !value;
|
|
233
233
|
}));
|
|
234
234
|
var headSelection = !!rowSelection;
|
|
@@ -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
|
};
|
package/dist/example/basic.js
CHANGED
package/dist/example/ellipsis.js
CHANGED
package/dist/example/fixed.js
CHANGED
package/dist/type/sheet.d.ts
CHANGED