@zhenliang/sheet 0.1.92-beta.5 → 0.1.92-beta.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/numberEditor/index.js +1 -1
- package/dist/core/editor/selectEditor/index.d.ts +1 -1
- package/dist/core/editor/selectEditor/index.js +18 -14
- package/dist/core/reducers/sideEffectReducer.js +2 -2
- package/dist/core/sheet/Cell.js +1 -1
- package/dist/core/table/useRowSelection.d.ts +1 -1
- package/dist/type/sheet.d.ts +1 -1
- package/package.json +1 -1
|
@@ -123,7 +123,7 @@ export var getNumberEditor = function getNumberEditor(extraProps, getExtraProps)
|
|
|
123
123
|
return result;
|
|
124
124
|
};
|
|
125
125
|
// 粘贴上去的时候触发
|
|
126
|
-
NumberEditor.parser = function (value, currentValue) {
|
|
126
|
+
NumberEditor.parser = function (value, record, currentValue) {
|
|
127
127
|
var _String2;
|
|
128
128
|
var result = (_String2 = String(value)) === null || _String2 === void 0 ? void 0 : _String2.replace(/,/g, '');
|
|
129
129
|
result = formulaString(result, currentValue);
|
|
@@ -2,5 +2,5 @@ import type { SheetType } from "../../../type";
|
|
|
2
2
|
import { SelectProps } from 'antd';
|
|
3
3
|
import 'antd/es/select/style/index.css';
|
|
4
4
|
import './index.less';
|
|
5
|
-
export declare const getSelectEditor: (options: SheetType.Options[], valueKey?: string, extra?: React.ReactNode, selectProps?: Partial<SelectProps>, getCustomOptions?: ((
|
|
5
|
+
export declare const getSelectEditor: (options: SheetType.Options[], valueKey?: string, extra?: React.ReactNode, selectProps?: Partial<SelectProps>, getCustomOptions?: ((record: any) => SheetType.Options[]) | undefined) => SheetType.CellEditor;
|
|
6
6
|
export default getSelectEditor;
|
|
@@ -26,6 +26,7 @@ export var getSelectEditor = function getSelectEditor(options) {
|
|
|
26
26
|
var selectProps = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
27
27
|
var getCustomOptions = arguments.length > 4 ? arguments[4] : undefined;
|
|
28
28
|
var SelectEditor = function SelectEditor(props) {
|
|
29
|
+
var _props$record;
|
|
29
30
|
var _useState = useState(true),
|
|
30
31
|
_useState2 = _slicedToArray(_useState, 2),
|
|
31
32
|
isOpen = _useState2[0],
|
|
@@ -50,7 +51,7 @@ export var getSelectEditor = function getSelectEditor(options) {
|
|
|
50
51
|
children: [menu, extra]
|
|
51
52
|
});
|
|
52
53
|
};
|
|
53
|
-
var customOptions = getCustomOptions ? getCustomOptions(props) : options;
|
|
54
|
+
var customOptions = getCustomOptions ? getCustomOptions((_props$record = props === null || props === void 0 ? void 0 : props.record) !== null && _props$record !== void 0 ? _props$record : {}) : options;
|
|
54
55
|
return /*#__PURE__*/_jsx(Select, _objectSpread({
|
|
55
56
|
autoFocus: true,
|
|
56
57
|
className: "select-editor",
|
|
@@ -67,29 +68,32 @@ export var getSelectEditor = function getSelectEditor(options) {
|
|
|
67
68
|
allowClear: true
|
|
68
69
|
}, selectProps));
|
|
69
70
|
};
|
|
70
|
-
SelectEditor.checker = function (value) {
|
|
71
|
+
SelectEditor.checker = function (value, record) {
|
|
71
72
|
if (isNil(value) && selectProps.allowClear !== false) return true;
|
|
72
|
-
|
|
73
|
+
var customOptions = getCustomOptions ? getCustomOptions(record !== null && record !== void 0 ? record : {}) : options;
|
|
74
|
+
return customOptions.some(function (item) {
|
|
73
75
|
return item.value == value;
|
|
74
|
-
}) ||
|
|
76
|
+
}) || customOptions.some(function (item) {
|
|
75
77
|
return item.label === value;
|
|
76
78
|
});
|
|
77
79
|
};
|
|
78
|
-
SelectEditor.parser = function (value) {
|
|
79
|
-
var
|
|
80
|
-
|
|
80
|
+
SelectEditor.parser = function (value, record) {
|
|
81
|
+
var _customOptions$find, _customOptions$find2;
|
|
82
|
+
var customOptions = getCustomOptions ? getCustomOptions(record !== null && record !== void 0 ? record : {}) : options;
|
|
83
|
+
return ((_customOptions$find = customOptions.find(function (item) {
|
|
81
84
|
return item.value == value;
|
|
82
|
-
})) === null ||
|
|
85
|
+
})) === null || _customOptions$find === void 0 ? void 0 : _customOptions$find[valueKey]) || ((_customOptions$find2 = customOptions.find(function (item) {
|
|
83
86
|
return item.label === value;
|
|
84
|
-
})) === null ||
|
|
87
|
+
})) === null || _customOptions$find2 === void 0 ? void 0 : _customOptions$find2[valueKey]);
|
|
85
88
|
};
|
|
86
|
-
SelectEditor.formatter = function (value) {
|
|
87
|
-
var
|
|
88
|
-
|
|
89
|
+
SelectEditor.formatter = function (value, record) {
|
|
90
|
+
var _customOptions$find3, _customOptions$find4;
|
|
91
|
+
var customOptions = getCustomOptions ? getCustomOptions(record !== null && record !== void 0 ? record : {}) : options;
|
|
92
|
+
return ((_customOptions$find3 = customOptions.find(function (item) {
|
|
89
93
|
return item.value == value;
|
|
90
|
-
})) === null ||
|
|
94
|
+
})) === null || _customOptions$find3 === void 0 ? void 0 : _customOptions$find3.label) || ((_customOptions$find4 = customOptions.find(function (item) {
|
|
91
95
|
return item.label === value;
|
|
92
|
-
})) === null ||
|
|
96
|
+
})) === null || _customOptions$find4 === void 0 ? void 0 : _customOptions$find4.label);
|
|
93
97
|
};
|
|
94
98
|
return SelectEditor;
|
|
95
99
|
};
|
|
@@ -263,7 +263,7 @@ export var sideEffectReducer = {
|
|
|
263
263
|
row: row,
|
|
264
264
|
col: col,
|
|
265
265
|
id: (_data$row$col2 = data[row][col]) === null || _data$row$col2 === void 0 ? void 0 : _data$row$col2.id,
|
|
266
|
-
value: editor !== null && editor !== void 0 && editor.parser ? editor === null || editor === void 0 || (_editor$parser = editor.parser) === null || _editor$parser === void 0 ? void 0 : _editor$parser.call(editor, value, data[row][col].value) : value
|
|
266
|
+
value: editor !== null && editor !== void 0 && editor.parser ? editor === null || editor === void 0 || (_editor$parser = editor.parser) === null || _editor$parser === void 0 ? void 0 : _editor$parser.call(editor, value, data[row][col].record, data[row][col].value) : value
|
|
267
267
|
};
|
|
268
268
|
});
|
|
269
269
|
lastRow = extChanges === null || extChanges === void 0 || (_extChanges$ = extChanges[0]) === null || _extChanges$ === void 0 ? void 0 : _extChanges$.row;
|
|
@@ -290,7 +290,7 @@ export var sideEffectReducer = {
|
|
|
290
290
|
return {
|
|
291
291
|
row: row,
|
|
292
292
|
col: col,
|
|
293
|
-
value: editor !== null && editor !== void 0 && editor.parser ? editor === null || editor === void 0 || (_editor$parser2 = editor.parser) === null || _editor$parser2 === void 0 ? void 0 : _editor$parser2.call(editor, value, data[row][col].value) : value,
|
|
293
|
+
value: editor !== null && editor !== void 0 && editor.parser ? editor === null || editor === void 0 || (_editor$parser2 = editor.parser) === null || _editor$parser2 === void 0 ? void 0 : _editor$parser2.call(editor, value, data[row][col].record, data[row][col].value) : value,
|
|
294
294
|
id: -lastIndex
|
|
295
295
|
};
|
|
296
296
|
});
|
package/dist/core/sheet/Cell.js
CHANGED
|
@@ -60,7 +60,7 @@ var Cell = function Cell(props) {
|
|
|
60
60
|
} else if (eventInfo.value && eventInfo.editing) {
|
|
61
61
|
var _cell$dataEditor, _cell$dataEditor2, _cell$dataEditor2$par;
|
|
62
62
|
// 单元格直接键盘编辑,设置为输入值
|
|
63
|
-
setValue((_cell$dataEditor = cell.dataEditor) !== null && _cell$dataEditor !== void 0 && _cell$dataEditor.parser ? cell === null || cell === void 0 || (_cell$dataEditor2 = cell.dataEditor) === null || _cell$dataEditor2 === void 0 || (_cell$dataEditor2$par = _cell$dataEditor2.parser) === null || _cell$dataEditor2$par === void 0 ? void 0 : _cell$dataEditor2$par.call(_cell$dataEditor2, eventInfo.value, valueRef.current) : eventInfo.value);
|
|
63
|
+
setValue((_cell$dataEditor = cell.dataEditor) !== null && _cell$dataEditor !== void 0 && _cell$dataEditor.parser ? cell === null || cell === void 0 || (_cell$dataEditor2 = cell.dataEditor) === null || _cell$dataEditor2 === void 0 || (_cell$dataEditor2$par = _cell$dataEditor2.parser) === null || _cell$dataEditor2$par === void 0 ? void 0 : _cell$dataEditor2$par.call(_cell$dataEditor2, eventInfo.value, cell.record, valueRef.current) : eventInfo.value);
|
|
64
64
|
}
|
|
65
65
|
setEventState(eventInfo);
|
|
66
66
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SheetTableType } from "../..";
|
|
2
2
|
export declare const useRowSelection: (dataSource: Record<string, unknown>[], rowSelection?: SheetTableType.TableRowSelection, hasChildren?: boolean) => [boolean[], (value: boolean[]) => void];
|
|
3
|
-
export declare const formatSelectionData: (param: Pick<SheetTableType.TableProps, "columns" | "
|
|
3
|
+
export declare const formatSelectionData: (param: Pick<SheetTableType.TableProps, "columns" | "showRemark" | "rowSelection" | "dataSource" | "rowKey"> & {
|
|
4
4
|
checked: boolean[];
|
|
5
5
|
}) => any[][];
|
package/dist/type/sheet.d.ts
CHANGED
|
@@ -56,7 +56,7 @@ export type CellEditorProps = {
|
|
|
56
56
|
export type CellEditor = React.FC<CellEditorProps> & {
|
|
57
57
|
checker?: (value: unknown, record?: Record<string, unknown>, currentValue?: unknown) => boolean;
|
|
58
58
|
formatter?: (value: unknown, record?: Record<string, unknown>) => unknown;
|
|
59
|
-
parser?: (value: unknown, currentValue?: unknown) => unknown;
|
|
59
|
+
parser?: (value: unknown, record?: Record<string, unknown>, currentValue?: unknown) => unknown;
|
|
60
60
|
formula?: (value: unknown, record?: Record<string, unknown>, currentValue?: unknown) => unknown;
|
|
61
61
|
};
|
|
62
62
|
export type CellViewer = React.FC<CellViewerProps>;
|