@zhenliang/sheet 0.1.92-beta.6 → 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.
|
@@ -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
|
};
|
|
@@ -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[][];
|