@azrico/reactgrid 1.2.33 → 1.2.35
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/.vscode/launch.json +15 -0
- package/CHANGELOG.md +86 -72
- package/config/config-overrides.js +12 -36
- package/config/tsconfig.base.json +0 -4
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -21
- package/dist/src/example.d.ts +4 -4
- package/dist/src/example.js +112 -155
- package/dist/src/func/func_child.d.ts +29 -29
- package/dist/src/func/func_child.js +70 -73
- package/dist/src/func/func_grid.d.ts +39 -39
- package/dist/src/func/func_grid.js +275 -261
- package/dist/src/index.d.ts +4 -4
- package/dist/src/index.js +10 -60
- package/dist/src/themes/grid.css +13 -0
- package/dist/src/views/DataGrid.d.ts +79 -79
- package/dist/src/views/DataGrid.js +195 -246
- package/dist/src/views/index.d.ts +3 -3
- package/dist/src/views/index.js +3 -23
- package/package.json +2 -2
- package/public/manifest.json +9 -9
- package/src/index.tsx +5 -5
- package/src/themes/grid.css +13 -0
- package/src/views/index.ts +4 -4
|
@@ -1,79 +1,79 @@
|
|
|
1
|
-
import '@inovua/reactdatagrid-enterprise/index.css';
|
|
2
|
-
import '@inovua/reactdatagrid-enterprise/theme/default-dark.css';
|
|
3
|
-
import '@inovua/reactdatagrid-enterprise/theme/amber-dark.css';
|
|
4
|
-
import '../themes/base_styles.css';
|
|
5
|
-
import '../themes/grid.css';
|
|
6
|
-
import { ConvertableToMenuItem } from '@azrico/controls';
|
|
7
|
-
import React from 'react';
|
|
8
|
-
import { TypeCellSelection, TypeColumn, TypeDataGridProps, TypeDataSource, TypeEditInfo, TypeFilterTypes, TypeFilterValue, TypeRowDetailsInfo, TypeRowProps, TypeRowSelection } from '@inovua/reactdatagrid-community/types';
|
|
9
|
-
import { TypeOnSelectionChangeArg } from '@inovua/reactdatagrid-community/types/TypeDataGridProps';
|
|
10
|
-
export type ColumnDefinition = TypeColumn;
|
|
11
|
-
export type CellDefinition = any;
|
|
12
|
-
export type RowDefinition = any;
|
|
13
|
-
export type RowProps = TypeRowProps;
|
|
14
|
-
export type RowSelectionValue = TypeRowSelection;
|
|
15
|
-
export type CellSelectionValue = TypeCellSelection;
|
|
16
|
-
export type DataRowDefinition = any;
|
|
17
|
-
export type FilterTypes = TypeFilterTypes;
|
|
18
|
-
export type FilterValues = TypeFilterValue;
|
|
19
|
-
export type DataSourceDefinition = TypeDataSource;
|
|
20
|
-
export type OnSelectionChangeFunc = (config: TypeOnSelectionChangeArg) => void;
|
|
21
|
-
export type OnCellSelectionChangeFunc = (s: {
|
|
22
|
-
[key: string]: boolean;
|
|
23
|
-
}) => void;
|
|
24
|
-
export type RowDetailsFunc = (rowDetailsInfo: TypeRowDetailsInfo) => React.ReactNode;
|
|
25
|
-
type loose_column_names = {
|
|
26
|
-
key: string;
|
|
27
|
-
field: string;
|
|
28
|
-
columnName: string;
|
|
29
|
-
name: string;
|
|
30
|
-
};
|
|
31
|
-
type loose_column_fields = loose_column_names & {
|
|
32
|
-
title: string;
|
|
33
|
-
type: string;
|
|
34
|
-
items: any[];
|
|
35
|
-
};
|
|
36
|
-
export type LooseColumnDefinition = Partial<loose_column_fields & ColumnDefinition>;
|
|
37
|
-
type customColumnData = {
|
|
38
|
-
name: string;
|
|
39
|
-
render: (cell: any, formatterParams: any, onRendered: any) => React.ReactNode | undefined | null;
|
|
40
|
-
};
|
|
41
|
-
export type AzGridOptions = Partial<TypeDataGridProps>;
|
|
42
|
-
export type AzGridProps = {
|
|
43
|
-
dataSource?: any[] | ((args: any) => any[] | Promise<any[] | any>);
|
|
44
|
-
details_dataSource?: any[] | ((args: any) => any[] | Promise<any[] | any>);
|
|
45
|
-
details_columns?: LooseColumnDefinition[];
|
|
46
|
-
details_filter?: FilterValues;
|
|
47
|
-
licenseKey?: string;
|
|
48
|
-
gridRef?: any;
|
|
49
|
-
gridOptions?: AzGridOptions;
|
|
50
|
-
columns?: LooseColumnDefinition[];
|
|
51
|
-
columnExtensions?: Partial<LooseColumnDefinition>;
|
|
52
|
-
editableColumns?: string[];
|
|
53
|
-
leftColumns?: string[];
|
|
54
|
-
rightColumns?: string[];
|
|
55
|
-
customColumns?: customColumnData[];
|
|
56
|
-
contextMenuItems?: ConvertableToMenuItem;
|
|
57
|
-
highlightedRow?: any;
|
|
58
|
-
RowDetail?: RowDetailsFunc;
|
|
59
|
-
selected?: RowSelectionValue;
|
|
60
|
-
cellSelection?: CellSelectionValue;
|
|
61
|
-
onEditComplete?: (editInfo: TypeEditInfo) => void;
|
|
62
|
-
onSelectionChange?: OnSelectionChangeFunc;
|
|
63
|
-
onCellSelectionChange?: OnCellSelectionChangeFunc;
|
|
64
|
-
onRowClick?: (rowIndex: number, row: any) => void;
|
|
65
|
-
onRowDoubleClick?: (rowIndex: number, row: any) => void;
|
|
66
|
-
onLimitChange?: (v: number) => void;
|
|
67
|
-
onSkipChange?: (v: number) => void;
|
|
68
|
-
skip?: number;
|
|
69
|
-
limit?: number;
|
|
70
|
-
editable?: boolean | ((editValue: any, cellProps: any) => boolean);
|
|
71
|
-
loading?: boolean;
|
|
72
|
-
dark?: boolean;
|
|
73
|
-
delayedSize?: boolean;
|
|
74
|
-
allowChildRows?: boolean;
|
|
75
|
-
looseCacheCheck?: boolean;
|
|
76
|
-
className?: string;
|
|
77
|
-
};
|
|
78
|
-
export declare function AzGrid(props: AzGridProps): JSX.Element;
|
|
79
|
-
export default AzGrid;
|
|
1
|
+
import '@inovua/reactdatagrid-enterprise/index.css';
|
|
2
|
+
import '@inovua/reactdatagrid-enterprise/theme/default-dark.css';
|
|
3
|
+
import '@inovua/reactdatagrid-enterprise/theme/amber-dark.css';
|
|
4
|
+
import '../themes/base_styles.css';
|
|
5
|
+
import '../themes/grid.css';
|
|
6
|
+
import { ConvertableToMenuItem } from '@azrico/controls';
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { TypeCellSelection, TypeColumn, TypeDataGridProps, TypeDataSource, TypeEditInfo, TypeFilterTypes, TypeFilterValue, TypeRowDetailsInfo, TypeRowProps, TypeRowSelection } from '@inovua/reactdatagrid-community/types';
|
|
9
|
+
import { TypeOnSelectionChangeArg } from '@inovua/reactdatagrid-community/types/TypeDataGridProps';
|
|
10
|
+
export type ColumnDefinition = TypeColumn;
|
|
11
|
+
export type CellDefinition = any;
|
|
12
|
+
export type RowDefinition = any;
|
|
13
|
+
export type RowProps = TypeRowProps;
|
|
14
|
+
export type RowSelectionValue = TypeRowSelection;
|
|
15
|
+
export type CellSelectionValue = TypeCellSelection;
|
|
16
|
+
export type DataRowDefinition = any;
|
|
17
|
+
export type FilterTypes = TypeFilterTypes;
|
|
18
|
+
export type FilterValues = TypeFilterValue;
|
|
19
|
+
export type DataSourceDefinition = TypeDataSource;
|
|
20
|
+
export type OnSelectionChangeFunc = (config: TypeOnSelectionChangeArg) => void;
|
|
21
|
+
export type OnCellSelectionChangeFunc = (s: {
|
|
22
|
+
[key: string]: boolean;
|
|
23
|
+
}) => void;
|
|
24
|
+
export type RowDetailsFunc = (rowDetailsInfo: TypeRowDetailsInfo) => React.ReactNode;
|
|
25
|
+
type loose_column_names = {
|
|
26
|
+
key: string;
|
|
27
|
+
field: string;
|
|
28
|
+
columnName: string;
|
|
29
|
+
name: string;
|
|
30
|
+
};
|
|
31
|
+
type loose_column_fields = loose_column_names & {
|
|
32
|
+
title: string;
|
|
33
|
+
type: string;
|
|
34
|
+
items: any[];
|
|
35
|
+
};
|
|
36
|
+
export type LooseColumnDefinition = Partial<loose_column_fields & ColumnDefinition>;
|
|
37
|
+
type customColumnData = {
|
|
38
|
+
name: string;
|
|
39
|
+
render: (cell: any, formatterParams: any, onRendered: any) => React.ReactNode | undefined | null;
|
|
40
|
+
};
|
|
41
|
+
export type AzGridOptions = Partial<TypeDataGridProps>;
|
|
42
|
+
export type AzGridProps = {
|
|
43
|
+
dataSource?: any[] | ((args: any) => any[] | Promise<any[] | any>);
|
|
44
|
+
details_dataSource?: any[] | ((args: any) => any[] | Promise<any[] | any>);
|
|
45
|
+
details_columns?: LooseColumnDefinition[];
|
|
46
|
+
details_filter?: FilterValues;
|
|
47
|
+
licenseKey?: string;
|
|
48
|
+
gridRef?: any;
|
|
49
|
+
gridOptions?: AzGridOptions;
|
|
50
|
+
columns?: LooseColumnDefinition[];
|
|
51
|
+
columnExtensions?: Partial<LooseColumnDefinition>;
|
|
52
|
+
editableColumns?: string[];
|
|
53
|
+
leftColumns?: string[];
|
|
54
|
+
rightColumns?: string[];
|
|
55
|
+
customColumns?: customColumnData[];
|
|
56
|
+
contextMenuItems?: ConvertableToMenuItem;
|
|
57
|
+
highlightedRow?: any;
|
|
58
|
+
RowDetail?: RowDetailsFunc;
|
|
59
|
+
selected?: RowSelectionValue;
|
|
60
|
+
cellSelection?: CellSelectionValue;
|
|
61
|
+
onEditComplete?: (editInfo: TypeEditInfo) => void;
|
|
62
|
+
onSelectionChange?: OnSelectionChangeFunc;
|
|
63
|
+
onCellSelectionChange?: OnCellSelectionChangeFunc;
|
|
64
|
+
onRowClick?: (rowIndex: number, row: any) => void;
|
|
65
|
+
onRowDoubleClick?: (rowIndex: number, row: any) => void;
|
|
66
|
+
onLimitChange?: (v: number) => void;
|
|
67
|
+
onSkipChange?: (v: number) => void;
|
|
68
|
+
skip?: number;
|
|
69
|
+
limit?: number;
|
|
70
|
+
editable?: boolean | ((editValue: any, cellProps: any) => boolean);
|
|
71
|
+
loading?: boolean;
|
|
72
|
+
dark?: boolean;
|
|
73
|
+
delayedSize?: boolean;
|
|
74
|
+
allowChildRows?: boolean;
|
|
75
|
+
looseCacheCheck?: boolean;
|
|
76
|
+
className?: string;
|
|
77
|
+
};
|
|
78
|
+
export declare function AzGrid(props: AzGridProps): React.JSX.Element;
|
|
79
|
+
export default AzGrid;
|
|
@@ -1,273 +1,222 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var _func_grid = require("../func/func_grid");
|
|
14
|
-
var _controls = require("@azrico/controls");
|
|
15
|
-
var _react = _interopRequireDefault(require("react"));
|
|
16
|
-
var _func_child = require("../func/func_child");
|
|
17
|
-
var _reactdatagridEnterprise = _interopRequireDefault(require("@inovua/reactdatagrid-enterprise"));
|
|
18
|
-
var _clsx = _interopRequireDefault(require("clsx"));
|
|
19
|
-
var _reactUseSize = require("react-use-size");
|
|
20
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1
|
+
import '@inovua/reactdatagrid-enterprise/index.css';
|
|
2
|
+
import '@inovua/reactdatagrid-enterprise/theme/default-dark.css';
|
|
3
|
+
import '@inovua/reactdatagrid-enterprise/theme/amber-dark.css';
|
|
4
|
+
import '../themes/base_styles.css';
|
|
5
|
+
import '../themes/grid.css';
|
|
6
|
+
import { ApplyColumnData, ApplyDataSource, get_default_key, get_row_id, } from '../func/func_grid';
|
|
7
|
+
import { ContextMenu } from '@azrico/controls';
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import { func_selection } from '../func/func_child';
|
|
10
|
+
import ReactDataGrid from '@inovua/reactdatagrid-enterprise';
|
|
11
|
+
import clsx from 'clsx';
|
|
12
|
+
import { useComponentSize } from 'react-use-size';
|
|
21
13
|
/* -------------------------------------------------------------------------- */
|
|
22
14
|
const defaultOptions = {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
15
|
+
//filterTypes: defaultfilterTypes,
|
|
16
|
+
remoteFilter: false,
|
|
17
|
+
remoteSort: false,
|
|
18
|
+
editStartEvent: 'click',
|
|
19
|
+
rowReorderColumn: false,
|
|
20
|
+
resizable: true,
|
|
21
|
+
columnUserSelect: true,
|
|
22
|
+
rowIndexColumn: true,
|
|
23
|
+
rowHeight: 35,
|
|
32
24
|
};
|
|
33
25
|
const forcedOptions = {
|
|
34
|
-
|
|
35
|
-
|
|
26
|
+
idProperty: '__table_id',
|
|
27
|
+
nodesProperty: '__children',
|
|
36
28
|
};
|
|
37
29
|
const dynamic_option_names = ['selected', 'cellSelection', 'loading', 'limit', 'skip'];
|
|
38
30
|
/* -------------------------------------------------------------------------- */
|
|
39
|
-
function AzGrid(props) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
columns: cached_columns,
|
|
104
|
-
dataSource: dataSource,
|
|
105
|
-
highlightedRow: props.highlightedRow
|
|
106
|
-
});
|
|
31
|
+
export function AzGrid(props) {
|
|
32
|
+
const gridRefBackup = React.useRef(null);
|
|
33
|
+
const gridRef = props.gridRef || gridRefBackup;
|
|
34
|
+
/* -------------------------------------------------------------------------- */
|
|
35
|
+
/* Columns */
|
|
36
|
+
/* -------------------------------------------------------------------------- */
|
|
37
|
+
const cached_columns = React.useMemo(() => {
|
|
38
|
+
return ApplyColumnData(props);
|
|
39
|
+
}, [
|
|
40
|
+
props.columns,
|
|
41
|
+
props.leftColumns,
|
|
42
|
+
props.rightColumns,
|
|
43
|
+
props.editableColumns,
|
|
44
|
+
props.columnExtensions,
|
|
45
|
+
props.customColumns,
|
|
46
|
+
]);
|
|
47
|
+
/* -------------------------------------------------------------------------- */
|
|
48
|
+
/* Row changes */
|
|
49
|
+
/* -------------------------------------------------------------------------- */
|
|
50
|
+
const cached_data = React.useRef();
|
|
51
|
+
const last_cache_info = React.useRef();
|
|
52
|
+
const dataSource = React.useCallback(async (dt) => {
|
|
53
|
+
return await ApplyDataSource(props.dataSource, {
|
|
54
|
+
skip: dt.skip,
|
|
55
|
+
limit: dt.limit,
|
|
56
|
+
cached_data: cached_data,
|
|
57
|
+
last_cache_info: last_cache_info,
|
|
58
|
+
});
|
|
59
|
+
}, [props.dataSource]);
|
|
60
|
+
const base_gridOptions = React.useMemo(() => {
|
|
61
|
+
const firstcolumn = cached_columns[0];
|
|
62
|
+
const licenseKey = props.licenseKey || get_default_key();
|
|
63
|
+
const events = {
|
|
64
|
+
onSkipChange: props.onSkipChange,
|
|
65
|
+
onLimitChange: props.onLimitChange,
|
|
66
|
+
onEditComplete: props.onEditComplete,
|
|
67
|
+
};
|
|
68
|
+
const extra_ops = {
|
|
69
|
+
onSelectionChange: props.onSelectionChange,
|
|
70
|
+
onCellSelectionChange: props.onCellSelectionChange,
|
|
71
|
+
licenseKey: licenseKey,
|
|
72
|
+
editable: props.editable,
|
|
73
|
+
treeColumn: props.allowChildRows ? firstcolumn.name : undefined,
|
|
74
|
+
renderRowDetails: props.RowDetail,
|
|
75
|
+
theme: props.dark ? 'amber-dark' : 'default-light',
|
|
76
|
+
};
|
|
77
|
+
return { ...defaultOptions, ...events, ...extra_ops };
|
|
78
|
+
}, [
|
|
79
|
+
cached_columns,
|
|
80
|
+
props.allowChildRows,
|
|
81
|
+
props.editable,
|
|
82
|
+
props.RowDetail,
|
|
83
|
+
props.onEditComplete,
|
|
84
|
+
]);
|
|
85
|
+
const static_gridOptions = React.useMemo(() => {
|
|
86
|
+
return { ...base_gridOptions, ...props.gridOptions, ...forcedOptions };
|
|
87
|
+
}, [props.gridOptions, base_gridOptions, forcedOptions]);
|
|
88
|
+
const dynamic_gridOptions = React.useMemo(() => {
|
|
89
|
+
const res = {};
|
|
90
|
+
dynamic_option_names.map((r) => {
|
|
91
|
+
res[r] = props[r];
|
|
92
|
+
});
|
|
93
|
+
return res;
|
|
94
|
+
}, dynamic_option_names.map((r) => props[r]));
|
|
95
|
+
return (React.createElement(DataGridEventsWrapper, { ...props, gridRef: gridRef, static_gridOptions: static_gridOptions, dynamic_gridOptions: dynamic_gridOptions, columns: cached_columns, dataSource: dataSource, highlightedRow: props.highlightedRow }));
|
|
107
96
|
}
|
|
108
97
|
/* -------------------------------------------------------------------------- */
|
|
109
|
-
/**
|
|
110
|
-
* Wrapper for menu events
|
|
111
|
-
* @param props
|
|
112
|
-
* @returns
|
|
98
|
+
/**
|
|
99
|
+
* Wrapper for menu events
|
|
100
|
+
* @param props
|
|
101
|
+
* @returns
|
|
113
102
|
*/
|
|
114
103
|
function DataGridEventsWrapper(props) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
104
|
+
/* -------------------------------------------------------------------------- */
|
|
105
|
+
const click_data = React.useRef(null);
|
|
106
|
+
const [menuAnchorEl, set_menuAnchorEl] = React.useState(null);
|
|
107
|
+
const [menuRow, set_menuRow] = React.useState(null);
|
|
108
|
+
/* --------------------------------- events --------------------------------- */
|
|
109
|
+
const onRowContextMenu = React.useCallback((rowProps, event) => {
|
|
110
|
+
if (!rowProps || !rowProps.data || func_selection.has_selection())
|
|
111
|
+
return;
|
|
112
|
+
const anEl = func_selection.getVirtualElement(event.clientX, event.clientY);
|
|
113
|
+
update_menuRow(rowProps.data);
|
|
114
|
+
update_menuAnchorEl(anEl);
|
|
115
|
+
event.preventDefault();
|
|
116
|
+
}, []);
|
|
117
|
+
const onRowClick = React.useCallback((rowProps, event) => {
|
|
118
|
+
const nowDate = Date.now();
|
|
119
|
+
const lastclick = click_data.current[get_row_id(rowProps)];
|
|
120
|
+
if (lastclick) {
|
|
121
|
+
const diffTime = Math.abs(nowDate - lastclick);
|
|
122
|
+
if (diffTime < 400) {
|
|
123
|
+
click_data.current[get_row_id(rowProps)] = null;
|
|
124
|
+
return (props.onRowDoubleClick &&
|
|
125
|
+
props.onRowDoubleClick(rowProps.rowIndex, rowProps.data));
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
click_data.current[get_row_id(rowProps)] = nowDate;
|
|
129
|
+
return props.onRowClick && props.onRowClick(rowProps.rowIndex, rowProps.data);
|
|
130
|
+
}, [props.onRowClick, props.onRowDoubleClick]);
|
|
131
|
+
React.useEffect(() => {
|
|
132
|
+
click_data.current = {};
|
|
133
|
+
}, [props.dataSource]);
|
|
134
|
+
/* ------------------------------- ContextMenu ------------------------------ */
|
|
135
|
+
const update_menuAnchorEl = React.useCallback((el) => {
|
|
136
|
+
if (el) {
|
|
137
|
+
set_menuAnchorEl(el);
|
|
138
|
+
}
|
|
139
|
+
else
|
|
140
|
+
set_menuAnchorEl(null);
|
|
141
|
+
}, []);
|
|
142
|
+
const update_menuRow = React.useCallback((r) => {
|
|
143
|
+
if (r) {
|
|
144
|
+
set_menuRow(r);
|
|
145
|
+
}
|
|
146
|
+
else
|
|
147
|
+
set_menuRow(null);
|
|
148
|
+
}, []);
|
|
149
|
+
/**
|
|
150
|
+
* Merge click events into grid options
|
|
151
|
+
*/
|
|
152
|
+
const static_gridOptions = React.useMemo(() => {
|
|
153
|
+
const events = {
|
|
154
|
+
onRowClick: onRowClick,
|
|
155
|
+
onRowContextMenu: onRowContextMenu,
|
|
156
|
+
};
|
|
157
|
+
return { ...props.static_gridOptions, ...events };
|
|
158
|
+
}, [props.static_gridOptions, onRowClick]);
|
|
159
|
+
const contextMenu = React.useMemo(() => {
|
|
160
|
+
return (React.createElement(ContextMenu, { menuAnchorEl: menuAnchorEl, set_menuAnchorEl: update_menuAnchorEl, menuRow: menuRow, menu_items: props.contextMenuItems }));
|
|
161
|
+
}, [menuAnchorEl, menuRow, props.contextMenuItems]);
|
|
162
|
+
if (props.details_dataSource) {
|
|
163
|
+
return (React.createElement(DataGridDetailsWrapper, { ...props, static_gridOptions: static_gridOptions }, contextMenu));
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
return (React.createElement(DataGridSizeWrapper, { ...props, static_gridOptions: static_gridOptions }, contextMenu));
|
|
136
167
|
}
|
|
137
|
-
click_data.current[(0, _func_grid.get_row_id)(rowProps)] = nowDate;
|
|
138
|
-
return props.onRowClick && props.onRowClick(rowProps.rowIndex, rowProps.data);
|
|
139
|
-
}, [props.onRowClick, props.onRowDoubleClick]);
|
|
140
|
-
_react.default.useEffect(() => {
|
|
141
|
-
click_data.current = {};
|
|
142
|
-
}, [props.dataSource]);
|
|
143
|
-
/* ------------------------------- ContextMenu ------------------------------ */
|
|
144
|
-
const update_menuAnchorEl = _react.default.useCallback(el => {
|
|
145
|
-
if (el) {
|
|
146
|
-
set_menuAnchorEl(el);
|
|
147
|
-
} else set_menuAnchorEl(null);
|
|
148
|
-
}, []);
|
|
149
|
-
const update_menuRow = _react.default.useCallback(r => {
|
|
150
|
-
if (r) {
|
|
151
|
-
set_menuRow(r);
|
|
152
|
-
} else set_menuRow(null);
|
|
153
|
-
}, []);
|
|
154
|
-
/**
|
|
155
|
-
* Merge click events into grid options
|
|
156
|
-
*/
|
|
157
|
-
const static_gridOptions = _react.default.useMemo(() => {
|
|
158
|
-
const events = {
|
|
159
|
-
onRowClick: onRowClick,
|
|
160
|
-
onRowContextMenu: onRowContextMenu
|
|
161
|
-
};
|
|
162
|
-
return {
|
|
163
|
-
...props.static_gridOptions,
|
|
164
|
-
...events
|
|
165
|
-
};
|
|
166
|
-
}, [props.static_gridOptions, onRowClick]);
|
|
167
|
-
const contextMenu = _react.default.useMemo(() => {
|
|
168
|
-
return _react.default.createElement(_controls.ContextMenu, {
|
|
169
|
-
menuAnchorEl: menuAnchorEl,
|
|
170
|
-
set_menuAnchorEl: update_menuAnchorEl,
|
|
171
|
-
menuRow: menuRow,
|
|
172
|
-
menu_items: props.contextMenuItems
|
|
173
|
-
});
|
|
174
|
-
}, [menuAnchorEl, menuRow, props.contextMenuItems]);
|
|
175
|
-
if (props.details_dataSource) {
|
|
176
|
-
return _react.default.createElement(DataGridDetailsWrapper, {
|
|
177
|
-
...props,
|
|
178
|
-
static_gridOptions: static_gridOptions
|
|
179
|
-
}, contextMenu);
|
|
180
|
-
} else {
|
|
181
|
-
return _react.default.createElement(DataGridSizeWrapper, {
|
|
182
|
-
...props,
|
|
183
|
-
static_gridOptions: static_gridOptions
|
|
184
|
-
}, contextMenu);
|
|
185
|
-
}
|
|
186
168
|
}
|
|
187
169
|
function DataGridDetailsWrapper(props) {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
const static_gridOptions = _react.default.useMemo(() => {
|
|
215
|
-
const finalresult = props.static_gridOptions || {};
|
|
216
|
-
finalresult['renderDetailsGrid'] = renderDetailsGrid;
|
|
217
|
-
return finalresult;
|
|
218
|
-
}, [props.static_gridOptions]);
|
|
219
|
-
return _react.default.createElement(DataGridSizeWrapper, {
|
|
220
|
-
...props,
|
|
221
|
-
static_gridOptions: static_gridOptions
|
|
222
|
-
});
|
|
170
|
+
const cached_details_columns = React.useMemo(() => {
|
|
171
|
+
return ApplyColumnData(props.details_columns);
|
|
172
|
+
}, [props.details_columns]);
|
|
173
|
+
const cached_data = React.useRef();
|
|
174
|
+
const last_cache_info = React.useRef();
|
|
175
|
+
const dataSource = React.useCallback(async (dt) => {
|
|
176
|
+
const res = await ApplyDataSource(props.details_dataSource, {
|
|
177
|
+
skip: dt.skip,
|
|
178
|
+
limit: dt.limit,
|
|
179
|
+
cached_data: cached_data,
|
|
180
|
+
last_cache_info: last_cache_info,
|
|
181
|
+
});
|
|
182
|
+
return res;
|
|
183
|
+
}, [props.dataSource]);
|
|
184
|
+
const renderDetailsGrid = ({ data }) => {
|
|
185
|
+
return (React.createElement(ReactDataGrid, { defaultFilterValue: props.details_filter, dataSource: dataSource, columns: cached_details_columns }));
|
|
186
|
+
};
|
|
187
|
+
/**
|
|
188
|
+
* Merge details into grid
|
|
189
|
+
*/
|
|
190
|
+
const static_gridOptions = React.useMemo(() => {
|
|
191
|
+
const finalresult = props.static_gridOptions || {};
|
|
192
|
+
finalresult['renderDetailsGrid'] = renderDetailsGrid;
|
|
193
|
+
return finalresult;
|
|
194
|
+
}, [props.static_gridOptions]);
|
|
195
|
+
return React.createElement(DataGridSizeWrapper, { ...props, static_gridOptions: static_gridOptions });
|
|
223
196
|
}
|
|
224
197
|
function DataGridSizeWrapper(props) {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
...props
|
|
232
|
-
});
|
|
233
|
-
}
|
|
198
|
+
if (props.delayedSize) {
|
|
199
|
+
return React.createElement(DataGridDelayedSizeWrapper, { ...props });
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
return React.createElement(DataGridCore, { ...props });
|
|
203
|
+
}
|
|
234
204
|
}
|
|
235
205
|
/* -------------------------------------------------------------------------- */
|
|
236
206
|
function DataGridDelayedSizeWrapper(props) {
|
|
237
|
-
|
|
238
|
-
ref,
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
} = (0, _reactUseSize.useComponentSize)();
|
|
242
|
-
return _react.default.createElement("div", {
|
|
243
|
-
ref: ref,
|
|
244
|
-
className: 'azgrid-filler'
|
|
245
|
-
}, _react.default.createElement("div", {
|
|
246
|
-
className: 'azgrid-delayedresize',
|
|
247
|
-
style: {
|
|
248
|
-
height: height,
|
|
249
|
-
width: width
|
|
250
|
-
}
|
|
251
|
-
}, _react.default.createElement(DataGridCore, {
|
|
252
|
-
...props
|
|
253
|
-
})));
|
|
207
|
+
const { ref, height, width } = useComponentSize();
|
|
208
|
+
return (React.createElement("div", { ref: ref, className: 'azgrid-filler' },
|
|
209
|
+
React.createElement("div", { className: 'azgrid-delayedresize', style: { height: height, width: width } },
|
|
210
|
+
React.createElement(DataGridCore, { ...props }))));
|
|
254
211
|
}
|
|
255
212
|
function DataGridCore(props) {
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
...props.static_gridOptions,
|
|
260
|
-
...props.dynamic_gridOptions,
|
|
261
|
-
handle: ref => props.gridRef.current = ref ? ref.current : null,
|
|
262
|
-
className: 'azgrid-filler',
|
|
263
|
-
columns: props.columns,
|
|
264
|
-
dataSource: props.dataSource
|
|
265
|
-
}), props.children);
|
|
213
|
+
return (React.createElement("div", { className: clsx(props.className, 'azgrid-filler') },
|
|
214
|
+
React.createElement(ReactDataGrid, { ...props.static_gridOptions, ...props.dynamic_gridOptions, handle: (ref) => (props.gridRef.current = ref ? ref.current : null), className: 'azgrid-filler', columns: props.columns, dataSource: props.dataSource }),
|
|
215
|
+
props.children));
|
|
266
216
|
}
|
|
267
217
|
/* -------------------------------------------------------------------------- */
|
|
268
218
|
/* -------------------------------------------------------------------------- */
|
|
269
219
|
/* -------------------------------------------------------------------------- */
|
|
270
220
|
/* -------------------------------------------------------------------------- */
|
|
271
221
|
/* -------------------------------------------------------------------------- */
|
|
272
|
-
|
|
273
|
-
exports.default = _default;
|
|
222
|
+
export default AzGrid;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './DataGrid';
|
|
2
|
-
import AzGrid from './DataGrid';
|
|
3
|
-
export default AzGrid;
|
|
1
|
+
export * from './DataGrid';
|
|
2
|
+
import AzGrid from './DataGrid';
|
|
3
|
+
export default AzGrid;
|