es-grid-template 0.1.1 → 0.1.2-1
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/es/grid-component/ColumnsChoose.js +25 -8
- package/es/grid-component/Command.js +6 -5
- package/es/grid-component/ContextMenu.d.ts +2 -2
- package/es/grid-component/ContextMenu.js +1 -0
- package/es/grid-component/EditableCell.js +265 -248
- package/es/grid-component/GridStyle.js +1 -1
- package/es/grid-component/InternalTable.js +24 -16
- package/es/grid-component/TableGrid.js +2 -1
- package/es/grid-component/async-select/index.d.ts +9 -0
- package/es/grid-component/async-select/index.js +35 -0
- package/es/grid-component/hooks/constant.d.ts +10 -0
- package/es/grid-component/hooks/constant.js +11 -1
- package/es/grid-component/hooks/useColumns/index.js +7 -4
- package/es/grid-component/hooks/utils.d.ts +2 -0
- package/es/grid-component/hooks/utils.js +11 -0
- package/es/grid-component/index.d.ts +3 -2
- package/es/grid-component/styles.scss +89 -30
- package/es/grid-component/table/Grid.js +7 -6
- package/es/grid-component/table/GridEdit.d.ts +1 -1
- package/es/grid-component/table/GridEdit.js +19 -15
- package/es/grid-component/type.d.ts +6 -3
- package/es/grid-component/useContext.d.ts +2 -1
- package/es/index.d.ts +1 -1
- package/lib/grid-component/ColumnsChoose.js +25 -8
- package/lib/grid-component/Command.js +7 -5
- package/lib/grid-component/ContextMenu.d.ts +2 -2
- package/lib/grid-component/ContextMenu.js +2 -0
- package/lib/grid-component/EditableCell.js +262 -245
- package/lib/grid-component/GridStyle.js +1 -1
- package/lib/grid-component/InternalTable.js +24 -16
- package/lib/grid-component/TableGrid.js +2 -1
- package/lib/grid-component/async-select/index.d.ts +9 -0
- package/lib/grid-component/async-select/index.js +44 -0
- package/lib/grid-component/hooks/constant.d.ts +10 -0
- package/lib/grid-component/hooks/constant.js +12 -2
- package/lib/grid-component/hooks/useColumns/index.js +7 -4
- package/lib/grid-component/hooks/utils.d.ts +2 -0
- package/lib/grid-component/hooks/utils.js +16 -3
- package/lib/grid-component/index.d.ts +3 -2
- package/lib/grid-component/styles.scss +89 -30
- package/lib/grid-component/table/Grid.js +7 -6
- package/lib/grid-component/table/GridEdit.d.ts +1 -1
- package/lib/grid-component/table/GridEdit.js +19 -15
- package/lib/grid-component/type.d.ts +6 -3
- package/lib/grid-component/useContext.d.ts +2 -1
- package/lib/index.d.ts +1 -1
- package/package.json +102 -113
|
@@ -9,4 +9,4 @@ var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
|
9
9
|
const GridStyle = exports.GridStyle = _styledComponents.default.div.withConfig({
|
|
10
10
|
displayName: "GridStyle",
|
|
11
11
|
componentId: "es-grid-template__sc-sueu2e-0"
|
|
12
|
-
})([".ui-rc-pagination{border-bottom:1px solid #e0e0e0;border-top:1px solid #e0e0e0;margin:0;padding:.75rem 1rem;.ui-rc-pagination-total-text{order:2;margin-left:auto;}&::before{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:", ";bottom:0;left:0;z-index:-1;}&::after{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:", ";bottom:0;visibility:visible;right:0;z-index:-1;}}"], props => props.heightTable ? typeof props.heightTable === 'string' ? props.heightTable : `${props.heightTable}px` : undefined, props => props.heightTable ? `${props.heightTable}px` : undefined);
|
|
12
|
+
})([".ui-rc-pagination{border-bottom:1px solid #e0e0e0;border-top:1px solid #e0e0e0;margin:0;padding:.75rem 1rem;.ui-rc-pagination-total-text{order:2;margin-left:auto;}&::before{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:", ";bottom:0;left:0;z-index:-1;}&::after{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:", ";bottom:0;visibility:visible;right:0;z-index:-1;}}.react-resizable{position:relative;background-clip:padding-box;}.react-resizable-handle{position:absolute;right:0px;bottom:0;z-index:1;width:5px;height:100%;cursor:col-resize;&.none{cursor:auto;display:none;}}"], props => props.heightTable ? typeof props.heightTable === 'string' ? props.heightTable : `${props.heightTable}px` : undefined, props => props.heightTable ? `${props.heightTable}px` : undefined);
|
|
@@ -65,6 +65,7 @@ const InternalTable = props => {
|
|
|
65
65
|
onFilterClick,
|
|
66
66
|
editAble,
|
|
67
67
|
rowKey,
|
|
68
|
+
onDataChange,
|
|
68
69
|
...rest
|
|
69
70
|
} = props;
|
|
70
71
|
const locale = lang && lang === 'en' ? _en_US.default : _vi_VN.default;
|
|
@@ -95,11 +96,9 @@ const InternalTable = props => {
|
|
|
95
96
|
if (typeof rowKey === 'function') {
|
|
96
97
|
return rowKey;
|
|
97
98
|
}
|
|
98
|
-
|
|
99
99
|
// @ts-ignore
|
|
100
100
|
return record => record?.[rowKey];
|
|
101
101
|
}, [rowKey]);
|
|
102
|
-
console.log('getRowKey', getRowKey);
|
|
103
102
|
const handleSearch = (selectedKeys, confirm) => {
|
|
104
103
|
confirm();
|
|
105
104
|
};
|
|
@@ -240,32 +239,37 @@ const InternalTable = props => {
|
|
|
240
239
|
return cols.map((col, index) => {
|
|
241
240
|
const currentPath = [...parentPath, index];
|
|
242
241
|
// @ts-ignore
|
|
243
|
-
if (!col?.dataIndex && !col.key) {
|
|
242
|
+
if (!col?.dataIndex && !col.key && !col.field) {
|
|
244
243
|
return col;
|
|
245
244
|
}
|
|
245
|
+
const transformedColumn = {
|
|
246
|
+
...col,
|
|
247
|
+
dataIndex: col.field ?? col.dataIndex,
|
|
248
|
+
title: t ? t(col.headerText ?? col.title) : col.headerText ?? col.title,
|
|
249
|
+
ellipsis: col.ellipsis !== false,
|
|
250
|
+
align: col.textAlign ?? col.align,
|
|
251
|
+
fixed: col.frozen ? col.frozen.toLowerCase() : col.fixed
|
|
252
|
+
};
|
|
246
253
|
if (col.children) {
|
|
247
254
|
return {
|
|
248
|
-
...
|
|
249
|
-
title: col.headerText ?? col.title,
|
|
250
|
-
ellipsis: col.ellipsis !== false,
|
|
255
|
+
...transformedColumn,
|
|
251
256
|
children: transformColumns(col.children, currentPath)
|
|
252
257
|
};
|
|
253
258
|
}
|
|
254
259
|
if (col.dataIndex === 'index' || col.field === 'index' || col.dataIndex === '#' || col.dataIndex === '#') {
|
|
255
260
|
return {
|
|
256
|
-
...
|
|
257
|
-
title: col.headerText ?? col.title,
|
|
258
|
-
ellipsis: col.ellipsis !== false
|
|
261
|
+
...transformedColumn
|
|
259
262
|
};
|
|
260
263
|
}
|
|
261
264
|
return {
|
|
262
265
|
...getColumnSearchProps(col),
|
|
263
|
-
...
|
|
264
|
-
dataIndex: col.field ?? col.dataIndex,
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
266
|
+
...transformedColumn,
|
|
267
|
+
// dataIndex: col.field ?? col.dataIndex,
|
|
268
|
+
// key: col.field ?? col.dataIndex ?? col.key,
|
|
269
|
+
// title: col.headerText ?? col.title,
|
|
270
|
+
// ellipsis: col.ellipsis !== false,
|
|
271
|
+
// align: col.textAlign ?? col.align,
|
|
272
|
+
// fixed: col.frozen ? col.frozen.toLowerCase() : col.fixed,
|
|
269
273
|
onFilter: (value, record) => {
|
|
270
274
|
// @ts-ignore
|
|
271
275
|
return record[col.field ?? col.dataIndex];
|
|
@@ -284,7 +288,11 @@ const InternalTable = props => {
|
|
|
284
288
|
// console.log('mergedColumns', mergedColumns)
|
|
285
289
|
|
|
286
290
|
const triggerChangeColumns = () => {};
|
|
287
|
-
const triggerChangeData =
|
|
291
|
+
const triggerChangeData = newData => {
|
|
292
|
+
setIsManualUpdate(true);
|
|
293
|
+
setData(newData);
|
|
294
|
+
onDataChange?.(newData);
|
|
295
|
+
};
|
|
288
296
|
const TableComponent = editAble ? _GridEdit.default : _Grid.default;
|
|
289
297
|
return /*#__PURE__*/_react.default.createElement(TableComponent, (0, _extends2.default)({}, rest, {
|
|
290
298
|
tableRef: tableRef,
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { BaseOptionType, DefaultOptionType } from "rc-select/lib/Select";
|
|
3
|
+
import type { SelectProps } from "rc-master-ui/es/select";
|
|
4
|
+
export interface DebounceSelectProps<OptionType extends BaseOptionType = DefaultOptionType> extends SelectProps {
|
|
5
|
+
loadOptions?: (search: string, callback: (newOptions: OptionType[]) => void) => void;
|
|
6
|
+
debounceTimeout?: number;
|
|
7
|
+
defaultOptions?: OptionType[];
|
|
8
|
+
}
|
|
9
|
+
export declare function AsyncSelect<OptionType extends BaseOptionType>({ loadOptions, debounceTimeout, defaultOptions, ...props }: DebounceSelectProps<OptionType>): React.JSX.Element;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.AsyncSelect = AsyncSelect;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _debounce = _interopRequireDefault(require("lodash/debounce"));
|
|
11
|
+
var _rcMasterUi = require("rc-master-ui");
|
|
12
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
13
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
14
|
+
function AsyncSelect({
|
|
15
|
+
loadOptions,
|
|
16
|
+
debounceTimeout = 500,
|
|
17
|
+
defaultOptions,
|
|
18
|
+
...props
|
|
19
|
+
}) {
|
|
20
|
+
const [options, setOptions] = (0, _react.useState)(defaultOptions ?? []);
|
|
21
|
+
const debounceFetcher = (0, _react.useMemo)(() => {
|
|
22
|
+
const fetchOptions = value => {
|
|
23
|
+
if (value.trim().length === 0) {
|
|
24
|
+
setOptions(defaultOptions ?? []);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (loadOptions) {
|
|
28
|
+
loadOptions(value, newOptions => {
|
|
29
|
+
setOptions(newOptions);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
return (0, _debounce.default)(fetchOptions, debounceTimeout);
|
|
34
|
+
}, [loadOptions, debounceTimeout]);
|
|
35
|
+
(0, _react.useEffect)(() => {
|
|
36
|
+
setOptions(defaultOptions ?? []);
|
|
37
|
+
}, [defaultOptions]);
|
|
38
|
+
return /*#__PURE__*/_react.default.createElement(_rcMasterUi.Select, (0, _extends2.default)({}, props, {
|
|
39
|
+
filterOption: loadOptions ? false : props?.filterOption,
|
|
40
|
+
onSearch: debounceFetcher,
|
|
41
|
+
onSelect: () => setOptions(defaultOptions ?? []),
|
|
42
|
+
options: options
|
|
43
|
+
}));
|
|
44
|
+
}
|
|
@@ -60,3 +60,13 @@ declare const SortOrder: {
|
|
|
60
60
|
descend: string;
|
|
61
61
|
};
|
|
62
62
|
export default SortOrder;
|
|
63
|
+
export declare const valueToBoolean: {
|
|
64
|
+
true: boolean;
|
|
65
|
+
false: boolean;
|
|
66
|
+
1: boolean;
|
|
67
|
+
0: boolean;
|
|
68
|
+
};
|
|
69
|
+
export declare const booleanToValue: {
|
|
70
|
+
true: number;
|
|
71
|
+
false: number;
|
|
72
|
+
};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.translateOption = exports.transferFontSize = exports.stringOperator = exports.paperSize = exports.optionsSize = exports.optionsPaperOrientation = exports.optionFontSize = exports.optionFont = exports.numberOperator = exports.defaultWidth = exports.defaultTimeFormat = exports.defaultRowHeight = exports.defaultPageSizes = exports.defaultDateTimeFormat = exports.defaultDateFormat = exports.default = exports.dateTimeOperator = exports.dateOperator = exports.booleanOperator = exports.alignToFlex = void 0;
|
|
6
|
+
exports.valueToBoolean = exports.translateOption = exports.transferFontSize = exports.stringOperator = exports.paperSize = exports.optionsSize = exports.optionsPaperOrientation = exports.optionFontSize = exports.optionFont = exports.numberOperator = exports.defaultWidth = exports.defaultTimeFormat = exports.defaultRowHeight = exports.defaultPageSizes = exports.defaultDateTimeFormat = exports.defaultDateFormat = exports.default = exports.dateTimeOperator = exports.dateOperator = exports.booleanToValue = exports.booleanOperator = exports.alignToFlex = void 0;
|
|
7
7
|
const defaultWidth = exports.defaultWidth = 100;
|
|
8
8
|
const defaultRowHeight = exports.defaultRowHeight = 35;
|
|
9
9
|
const numberOperator = exports.numberOperator = [{
|
|
@@ -233,4 +233,14 @@ const SortOrder = {
|
|
|
233
233
|
*/
|
|
234
234
|
descend: 'Descending'
|
|
235
235
|
};
|
|
236
|
-
var _default = exports.default = SortOrder;
|
|
236
|
+
var _default = exports.default = SortOrder;
|
|
237
|
+
const valueToBoolean = exports.valueToBoolean = {
|
|
238
|
+
true: true,
|
|
239
|
+
false: false,
|
|
240
|
+
1: true,
|
|
241
|
+
0: false
|
|
242
|
+
};
|
|
243
|
+
const booleanToValue = exports.booleanToValue = {
|
|
244
|
+
true: 1,
|
|
245
|
+
false: 0
|
|
246
|
+
};
|
|
@@ -17,6 +17,7 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
|
|
|
17
17
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
18
18
|
// import * as React from 'react'
|
|
19
19
|
|
|
20
|
+
// import {ColorPicker} from "antd";
|
|
20
21
|
const {
|
|
21
22
|
RangePicker
|
|
22
23
|
} = _rcMasterUi.DatePicker;
|
|
@@ -72,13 +73,15 @@ const getValueCell = (column, value, format) => {
|
|
|
72
73
|
case 'boolean':
|
|
73
74
|
return value ? 'true' : 'false';
|
|
74
75
|
case 'color':
|
|
75
|
-
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null,
|
|
76
|
+
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
76
77
|
className: 'w-100 h-100',
|
|
77
78
|
style: {
|
|
78
|
-
backgroundColor: value,
|
|
79
|
-
border: '1px solid #f0f0f0'
|
|
79
|
+
backgroundColor: (0, _utils.isColor)(value) ? value : '#fff',
|
|
80
|
+
border: '1px solid #f0f0f0',
|
|
81
|
+
height: '100%',
|
|
82
|
+
minHeight: 20
|
|
80
83
|
}
|
|
81
|
-
})
|
|
84
|
+
}));
|
|
82
85
|
case 'checkbox':
|
|
83
86
|
return /*#__PURE__*/_react.default.createElement(_rcMasterUi.Input, {
|
|
84
87
|
checked: !!content,
|
|
@@ -33,3 +33,5 @@ export declare const totalFixedWidth: <T>(columns: ColumnsType<T>, type: 'left'
|
|
|
33
33
|
export declare const isObjEmpty: (obj: any) => boolean;
|
|
34
34
|
export declare const getColumnsVisible: <T>(columns: ColumnsType<T>, index: number) => import("../type").ColumnType<T>[];
|
|
35
35
|
export declare const updateData: <Record_1 = AnyObject>(initData: Record_1[], rows: Record_1[], key: keyof Record_1) => Record_1[];
|
|
36
|
+
export declare const parseBooleanToValue: (value: boolean, type: 'boolean' | 'number') => number | boolean;
|
|
37
|
+
export declare const genPresets: (presets?: import("@ant-design/colors").PalettesProps) => import("antd/es/color-picker/interface").PresetsItem[];
|
|
@@ -4,12 +4,13 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.getEditType = exports.getDatepickerFormat = exports.getDateString = exports.getColumnsVisible = exports.getAllVisibleKeys = exports.customWeekStartEndFormat = exports.convertLabelToTitle = exports.convertDayjsToDate = exports.convertDateToDayjs = exports.convertArrayWithIndent = exports.checkThousandSeparator = exports.checkFieldKey = exports.checkDecimalSeparator = void 0;
|
|
7
|
+
exports.getEditType = exports.getDatepickerFormat = exports.getDateString = exports.getColumnsVisible = exports.getAllVisibleKeys = exports.genPresets = exports.customWeekStartEndFormat = exports.convertLabelToTitle = exports.convertDayjsToDate = exports.convertDateToDayjs = exports.convertArrayWithIndent = exports.checkThousandSeparator = exports.checkFieldKey = exports.checkDecimalSeparator = void 0;
|
|
8
8
|
exports.getHiddenParentKeys = getHiddenParentKeys;
|
|
9
|
-
exports.updateData = exports.updateColumns = exports.updateArrayByKey = exports.totalFixedWidth = exports.sumDataByField = exports.newGuid = exports.isObjEmpty = exports.isNullOrUndefined = exports.isNameColor = exports.isEmpty = exports.isDisable = exports.isColor = exports.getVisibleColumnKeys = exports.getTypeFilter = exports.getTemplate = void 0;
|
|
9
|
+
exports.updateData = exports.updateColumns = exports.updateArrayByKey = exports.totalFixedWidth = exports.sumDataByField = exports.parseBooleanToValue = exports.newGuid = exports.isObjEmpty = exports.isNullOrUndefined = exports.isNameColor = exports.isEmpty = exports.isDisable = exports.isColor = exports.getVisibleColumnKeys = exports.getTypeFilter = exports.getTemplate = void 0;
|
|
10
10
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
11
11
|
var _moment = _interopRequireDefault(require("moment/moment"));
|
|
12
12
|
var _uuid = require("uuid");
|
|
13
|
+
var _colors = require("@ant-design/colors");
|
|
13
14
|
const newGuid = () => {
|
|
14
15
|
for (let i = 0; i < 20; i++) {
|
|
15
16
|
// @ts-ignore
|
|
@@ -354,4 +355,16 @@ const updateData = (initData, rows, key) => {
|
|
|
354
355
|
const newRows = rows.filter(row => !initData.some(item => item[key] === row[key]));
|
|
355
356
|
return [...updatedData, ...newRows];
|
|
356
357
|
};
|
|
357
|
-
exports.updateData = updateData;
|
|
358
|
+
exports.updateData = updateData;
|
|
359
|
+
const parseBooleanToValue = (value, type) => {
|
|
360
|
+
return type === 'boolean' ? value : Number(value);
|
|
361
|
+
};
|
|
362
|
+
exports.parseBooleanToValue = parseBooleanToValue;
|
|
363
|
+
const genPresets = (presets = _colors.presetPalettes) => {
|
|
364
|
+
return Object.entries(presets).map(([label, colors]) => ({
|
|
365
|
+
label,
|
|
366
|
+
colors,
|
|
367
|
+
key: label
|
|
368
|
+
}));
|
|
369
|
+
};
|
|
370
|
+
exports.genPresets = genPresets;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import InternalTable from './InternalTable';
|
|
2
|
-
import type { ColumnsTable, TableProps, ColumnTable } from './type';
|
|
3
|
-
|
|
2
|
+
import type { ColumnsTable, TableProps, ColumnTable, CommandItem, ContextMenuItem } from './type';
|
|
3
|
+
import type { ToolbarItem } from "rc-master-ui/es/toolbar";
|
|
4
|
+
export type { ColumnsTable, TableProps, ColumnTable, ToolbarItem, CommandItem, ContextMenuItem };
|
|
4
5
|
export default InternalTable;
|
|
@@ -25,27 +25,6 @@ $rowSelectedHoverBg: 'ui-rc' !default;
|
|
|
25
25
|
min-width: 200px;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
.react-resizable {
|
|
29
|
-
position: relative;
|
|
30
|
-
background-clip: padding-box;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.react-resizable-handle {
|
|
34
|
-
position: absolute;
|
|
35
|
-
//right: 10px;
|
|
36
|
-
right: 0px;
|
|
37
|
-
bottom: 0;
|
|
38
|
-
z-index: 1;
|
|
39
|
-
width: 5px;
|
|
40
|
-
height: 100%;
|
|
41
|
-
cursor: col-resize;
|
|
42
|
-
//transform: translateY(-50%);
|
|
43
|
-
&.none {
|
|
44
|
-
cursor: auto;
|
|
45
|
-
display: none;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
28
|
// -------------- Table -------------
|
|
50
29
|
|
|
51
30
|
.#{$prefix}-table-wrapper {
|
|
@@ -302,10 +281,55 @@ $rowSelectedHoverBg: 'ui-rc' !default;
|
|
|
302
281
|
}
|
|
303
282
|
}
|
|
304
283
|
|
|
284
|
+
.ui-rc-checkbox-wrapper {
|
|
285
|
+
.ui-rc-checkbox {
|
|
286
|
+
background-color: red;
|
|
287
|
+
}
|
|
288
|
+
.ui-rc-checkbox-input {
|
|
289
|
+
&:focus-visible {
|
|
290
|
+
outline: none;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
305
295
|
|
|
306
296
|
.ant-input, .ant-picker{
|
|
307
297
|
border-radius: 0;
|
|
308
298
|
}
|
|
299
|
+
|
|
300
|
+
// color picker
|
|
301
|
+
|
|
302
|
+
.ant-color-picker-trigger{
|
|
303
|
+
height: 100%;
|
|
304
|
+
border-radius: 0;
|
|
305
|
+
.ant-color-picker-color-block {
|
|
306
|
+
height: 100%;
|
|
307
|
+
width: 100%;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
// ------------ select ---------------
|
|
314
|
+
|
|
315
|
+
.ui-rc-table-select-single .ui-rc-table-select-selector,
|
|
316
|
+
.ui-rc-select-single .ui-rc-select-selector {
|
|
317
|
+
|
|
318
|
+
border-radius: 0;
|
|
319
|
+
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
.ui-rc-table-select-single:not(.ui-rc-table-select-customize-input) {
|
|
323
|
+
.ui-rc-table-select-selector {
|
|
324
|
+
.ui-rc-table-select-selection-search-input {
|
|
325
|
+
height: auto;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
// ------------ select ---------------
|
|
331
|
+
|
|
332
|
+
|
|
309
333
|
}
|
|
310
334
|
&.cell-editable {
|
|
311
335
|
padding: 0;
|
|
@@ -321,6 +345,9 @@ $rowSelectedHoverBg: 'ui-rc' !default;
|
|
|
321
345
|
.ui-rc_content {
|
|
322
346
|
padding: 5px 8px;
|
|
323
347
|
}
|
|
348
|
+
.ui-rc_content:has(.ant-color-picker-trigger) {
|
|
349
|
+
padding: 1px 8px;
|
|
350
|
+
}
|
|
324
351
|
}
|
|
325
352
|
}
|
|
326
353
|
|
|
@@ -345,6 +372,15 @@ $rowSelectedHoverBg: 'ui-rc' !default;
|
|
|
345
372
|
}
|
|
346
373
|
}
|
|
347
374
|
}
|
|
375
|
+
//.ui-rc-checkbox-input {
|
|
376
|
+
// &:focus-visible {
|
|
377
|
+
// outline: none;
|
|
378
|
+
// }
|
|
379
|
+
//}
|
|
380
|
+
|
|
381
|
+
.ui-rc-checkbox .ui-rc-checkbox-input:focus-visible+.ui-rc-checkbox-inner {
|
|
382
|
+
outline: none;
|
|
383
|
+
}
|
|
348
384
|
|
|
349
385
|
.#{$prefix}-checkbox {
|
|
350
386
|
&.#{$prefix}-checkbox-checked {
|
|
@@ -486,6 +522,8 @@ $rowSelectedHoverBg: 'ui-rc' !default;
|
|
|
486
522
|
}
|
|
487
523
|
}
|
|
488
524
|
|
|
525
|
+
|
|
526
|
+
|
|
489
527
|
//.#{$prefix}-table-wrapper .#{$prefix}-table.#{$prefix}-table-bordered >.#{$prefix}-table-container >.#{$prefix}-table-content >table >tbody>tr>td >.#{$prefix}-table-expanded-row-fixed {
|
|
490
528
|
// border-inline-end: 1px solid $tableBorderColor;
|
|
491
529
|
//}
|
|
@@ -530,16 +568,37 @@ $rowSelectedHoverBg: 'ui-rc' !default;
|
|
|
530
568
|
}
|
|
531
569
|
|
|
532
570
|
|
|
533
|
-
.ui-rc-table-wrapper
|
|
534
|
-
.ui-rc-table
|
|
535
|
-
.ui-rc-table-
|
|
536
|
-
.ui-rc-table-
|
|
537
|
-
.ui-rc-table-
|
|
538
|
-
.ui-rc-table-
|
|
539
|
-
.ui-rc-table-
|
|
540
|
-
.ui-rc-table-
|
|
541
|
-
|
|
571
|
+
.ui-rc-table-wrapper {
|
|
572
|
+
.ui-rc-table.ui-rc-table-small {
|
|
573
|
+
.ui-rc-table-title,
|
|
574
|
+
.ui-rc-table-footer,
|
|
575
|
+
.ui-rc-table-cell,
|
|
576
|
+
.ui-rc-table-thead > tr > th,
|
|
577
|
+
.ui-rc-table-tbody > tr > th,
|
|
578
|
+
.ui-rc-table-tbody > tr > td,
|
|
579
|
+
tfoot > tr > th,
|
|
580
|
+
tfoot > tr > td {
|
|
581
|
+
padding: 5px 8px;
|
|
582
|
+
}
|
|
583
|
+
}
|
|
542
584
|
}
|
|
585
|
+
.ui-rc-table-wrapper {
|
|
586
|
+
.ui-rc-table.ui-rc-table-small {
|
|
587
|
+
.ui-rc-table-cell {
|
|
588
|
+
&:has(.ant-color-picker-trigger) {
|
|
589
|
+
padding: 1px 8px;
|
|
590
|
+
}
|
|
591
|
+
.ant-color-picker-trigger{
|
|
592
|
+
width: 100%;
|
|
593
|
+
min-height: 20px;
|
|
594
|
+
.ant-color-picker-clear {
|
|
595
|
+
height: 20px;
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
|
|
543
602
|
|
|
544
603
|
|
|
545
604
|
//ui-rc-table-ping-right
|
|
@@ -9,8 +9,8 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _GridStyle = require("../GridStyle");
|
|
11
11
|
var _TableGrid = _interopRequireDefault(require("../TableGrid"));
|
|
12
|
-
var _EditableCell = _interopRequireDefault(require("../EditableCell"));
|
|
13
12
|
var _Command = _interopRequireDefault(require("../Command"));
|
|
13
|
+
var _useColumns = require("../hooks/useColumns");
|
|
14
14
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
15
15
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
16
16
|
const Grid = props => {
|
|
@@ -21,6 +21,7 @@ const Grid = props => {
|
|
|
21
21
|
className,
|
|
22
22
|
components,
|
|
23
23
|
style,
|
|
24
|
+
format,
|
|
24
25
|
...rest
|
|
25
26
|
} = props;
|
|
26
27
|
const transformColumns = _react.default.useCallback(cols => {
|
|
@@ -67,7 +68,10 @@ const Grid = props => {
|
|
|
67
68
|
}) : null))
|
|
68
69
|
};
|
|
69
70
|
}
|
|
70
|
-
return
|
|
71
|
+
return {
|
|
72
|
+
...transformedColumn,
|
|
73
|
+
render: (value, record, rowIndex) => (0, _useColumns.renderContent)(column, value, record, rowIndex, format)
|
|
74
|
+
};
|
|
71
75
|
});
|
|
72
76
|
}, []);
|
|
73
77
|
const mergedColumns = (0, _react.useMemo)(() => transformColumns(columns ?? []), [transformColumns, columns]);
|
|
@@ -79,10 +83,7 @@ const Grid = props => {
|
|
|
79
83
|
}, /*#__PURE__*/_react.default.createElement(_TableGrid.default, (0, _extends2.default)({}, rest, {
|
|
80
84
|
tableRef: tableRef,
|
|
81
85
|
components: {
|
|
82
|
-
...components
|
|
83
|
-
body: {
|
|
84
|
-
cell: _EditableCell.default
|
|
85
|
-
}
|
|
86
|
+
...components
|
|
86
87
|
},
|
|
87
88
|
columns: mergedColumns,
|
|
88
89
|
style: {
|
|
@@ -6,7 +6,7 @@ import type { GetRowKey } from "../type";
|
|
|
6
6
|
type Props<RecordType> = TableEditProps<RecordType> & {
|
|
7
7
|
tableRef: any;
|
|
8
8
|
triggerChangeColumns?: () => void;
|
|
9
|
-
triggerChangeData?: () => void;
|
|
9
|
+
triggerChangeData?: (newData: RecordType[], type: string) => void;
|
|
10
10
|
getRowKey: GetRowKey<RecordType>;
|
|
11
11
|
};
|
|
12
12
|
declare const GridEdit: <RecordType extends object>(props: Props<RecordType>) => React.JSX.Element;
|
|
@@ -39,7 +39,8 @@ const GridEdit = props => {
|
|
|
39
39
|
selectionSettings,
|
|
40
40
|
height,
|
|
41
41
|
format,
|
|
42
|
-
onDataChange,
|
|
42
|
+
// onDataChange,
|
|
43
|
+
triggerChangeData,
|
|
43
44
|
onCellPaste,
|
|
44
45
|
onCellChange,
|
|
45
46
|
style,
|
|
@@ -357,6 +358,7 @@ const GridEdit = props => {
|
|
|
357
358
|
...item,
|
|
358
359
|
...row
|
|
359
360
|
});
|
|
361
|
+
triggerChangeData?.(newData, 'onChange');
|
|
360
362
|
|
|
361
363
|
// trigger DataChange
|
|
362
364
|
// setData(newData);
|
|
@@ -378,14 +380,16 @@ const GridEdit = props => {
|
|
|
378
380
|
type,
|
|
379
381
|
newState,
|
|
380
382
|
prevState,
|
|
381
|
-
option
|
|
383
|
+
option,
|
|
384
|
+
field
|
|
382
385
|
} = args;
|
|
383
386
|
|
|
384
387
|
// console.log('newState', newState)
|
|
385
388
|
//
|
|
386
389
|
// console.log('getValues()', getValues())
|
|
387
390
|
|
|
388
|
-
const newRecord = getValues()
|
|
391
|
+
// const newRecord = getValues()
|
|
392
|
+
|
|
389
393
|
if (type === 'enter') {
|
|
390
394
|
console.log('aaaaaa enter');
|
|
391
395
|
}
|
|
@@ -399,20 +403,14 @@ const GridEdit = props => {
|
|
|
399
403
|
const callbackRecord = callbackData;
|
|
400
404
|
Object.entries(callbackRecord).forEach(([name, value]) => {
|
|
401
405
|
setValue(name, value);
|
|
402
|
-
|
|
403
|
-
// if (listObjectDate.includes(name) && value) {
|
|
404
|
-
// setValue(name, new Date(value))
|
|
405
|
-
// } else {
|
|
406
|
-
// setValue(name, value)
|
|
407
|
-
// }
|
|
408
406
|
});
|
|
409
|
-
onSubmit(
|
|
407
|
+
onSubmit(callbackRecord);
|
|
410
408
|
};
|
|
411
409
|
if (onCellChange) {
|
|
412
410
|
if (onCellChange.length > 1) {
|
|
413
411
|
console.log('onCellChange Callback');
|
|
414
412
|
onCellChange({
|
|
415
|
-
field
|
|
413
|
+
field,
|
|
416
414
|
indexCol: 1,
|
|
417
415
|
type: 'onChange',
|
|
418
416
|
value: newState,
|
|
@@ -424,11 +422,9 @@ const GridEdit = props => {
|
|
|
424
422
|
sumValue: []
|
|
425
423
|
}, handleChangeCallback);
|
|
426
424
|
} else {
|
|
427
|
-
// const aaaa = updateData(dataSource, newRecord, rowKey as any)
|
|
428
|
-
|
|
429
425
|
console.log('onCellChange');
|
|
430
426
|
onCellChange({
|
|
431
|
-
field
|
|
427
|
+
field,
|
|
432
428
|
indexCol: 1,
|
|
433
429
|
type: 'onChange',
|
|
434
430
|
option,
|
|
@@ -702,6 +698,14 @@ const GridEdit = props => {
|
|
|
702
698
|
handleEdit(record, col, col.editType, event);
|
|
703
699
|
}
|
|
704
700
|
},
|
|
701
|
+
// onMouseDown: (event) => {
|
|
702
|
+
// handleMouseDown(rowIndex, colIndex, event)
|
|
703
|
+
// },
|
|
704
|
+
//
|
|
705
|
+
// onMouseEnter: () => {
|
|
706
|
+
// handleMouseEnter(rowIndex, colIndex)
|
|
707
|
+
// },
|
|
708
|
+
|
|
705
709
|
onClick: () => {
|
|
706
710
|
if (record[rowKey] !== editingKey && editingKey !== '') {
|
|
707
711
|
setEditingKey('');
|
|
@@ -736,7 +740,7 @@ const GridEdit = props => {
|
|
|
736
740
|
onMouseEnter: () => handleMouseEnter(rowIndex, colIndex)
|
|
737
741
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
738
742
|
className: 'ui-rc_content'
|
|
739
|
-
}, (0, _useColumns.renderContent)(col, value, record, rowIndex)));
|
|
743
|
+
}, (0, _useColumns.renderContent)(col, value, record, rowIndex, format)));
|
|
740
744
|
}
|
|
741
745
|
};
|
|
742
746
|
});
|
|
@@ -6,11 +6,13 @@ import type { FilterOperator, TableRowSelection } from "rc-master-ui/es/table/in
|
|
|
6
6
|
import type { ToolbarItem } from "rc-master-ui/es/toolbar";
|
|
7
7
|
import type { ItemType } from "rc-master-ui/es/menu/interface";
|
|
8
8
|
import type { FieldNames, FilterFunc } from "rc-select/es/Select";
|
|
9
|
+
import type { ColorPickerProps } from "antd";
|
|
9
10
|
export type IColumnType = "number" | "time" | "date" | "week" | "month" | "file" | "quarter" | "year" | "datetime" | "string" | "boolean" | "checkbox" | "color" | null | undefined;
|
|
10
11
|
export type AnyObject = Record<PropertyKey, any>;
|
|
11
12
|
export type SelectMode = 'checkbox' | 'radio' | undefined;
|
|
12
13
|
export type ITextAlign = 'center' | 'left' | 'right';
|
|
13
14
|
export type Frozen = 'left' | 'right' | 'Left' | 'Right';
|
|
15
|
+
export type ContextMenuItem = ItemType & {};
|
|
14
16
|
export type ITemplateColumn = {
|
|
15
17
|
value: any;
|
|
16
18
|
column: any;
|
|
@@ -124,7 +126,7 @@ export interface TableProps<RecordType> extends Omit<RcTableProps<RecordType>, '
|
|
|
124
126
|
format?: IFormat;
|
|
125
127
|
t?: any;
|
|
126
128
|
lang?: string;
|
|
127
|
-
contextMenuItems?:
|
|
129
|
+
contextMenuItems?: ContextMenuItem[];
|
|
128
130
|
contextMenuHidden?: string[] | ((args?: Omit<ContextInfo<RecordType>, 'item' | 'event'>) => string[]);
|
|
129
131
|
contextMenuOpen?: (args: Omit<ContextInfo<RecordType>, 'item'>) => void;
|
|
130
132
|
contextMenuClick?: (args: ContextInfo<RecordType>) => void;
|
|
@@ -153,7 +155,7 @@ export interface TableProps<RecordType> extends Omit<RcTableProps<RecordType>, '
|
|
|
153
155
|
selected: RecordType | RecordType[];
|
|
154
156
|
}) => void;
|
|
155
157
|
dataSourceFilter?: SourceFilter[];
|
|
156
|
-
onFilterClick?: (column:
|
|
158
|
+
onFilterClick?: (column: ColumnTable<RecordType>, callback: (key: string, data: any) => void) => void;
|
|
157
159
|
loading?: boolean;
|
|
158
160
|
allowResizing?: boolean;
|
|
159
161
|
onDataChange?: (data: RecordType[]) => void;
|
|
@@ -184,7 +186,7 @@ export type CellChangeArgs<T> = {
|
|
|
184
186
|
rowsData: T[];
|
|
185
187
|
indexRow: number;
|
|
186
188
|
rowId?: string;
|
|
187
|
-
field: string;
|
|
189
|
+
field: string | undefined;
|
|
188
190
|
indexCol: any;
|
|
189
191
|
sumValue?: any[];
|
|
190
192
|
};
|
|
@@ -238,3 +240,4 @@ export type IFormat = {
|
|
|
238
240
|
yearFormat?: string;
|
|
239
241
|
};
|
|
240
242
|
export type GetRowKey<RecordType> = (record: RecordType, index?: number) => Key;
|
|
243
|
+
export type Presets = Required<ColorPickerProps>['presets'][number];
|
|
@@ -16,12 +16,13 @@ export interface IContext<RecordType> {
|
|
|
16
16
|
handleSubmit?: any;
|
|
17
17
|
onSubmit?: SubmitHandler<any>;
|
|
18
18
|
getValues?: any;
|
|
19
|
-
handleCellChange?: (
|
|
19
|
+
handleCellChange?: (args: ContextCellChange<RecordType>) => void;
|
|
20
20
|
getRowKey?: GetRowKey<RecordType>;
|
|
21
21
|
}
|
|
22
22
|
export type ContextCellChange<RecordType = AnyObject> = {
|
|
23
23
|
key: string | keyof RecordType | GetRowKey<RecordType>;
|
|
24
24
|
record: any;
|
|
25
|
+
field: string | undefined;
|
|
25
26
|
option: any;
|
|
26
27
|
newState?: any;
|
|
27
28
|
prevState?: any;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { default as GridComponent } from './grid-component';
|
|
2
|
-
export type { ColumnsTable, TableProps, ColumnTable } from './grid-component';
|
|
2
|
+
export type { ColumnsTable, TableProps, ColumnTable, CommandItem, ToolbarItem, ContextMenuItem } from './grid-component';
|