@azrico/reactgrid 1.3.40 → 1.3.41
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/index.d.ts +3 -0
- package/dist/index.js +20 -0
- package/dist/src/example.d.ts +4 -0
- package/dist/src/example.js +173 -0
- package/dist/src/func/func_child.d.ts +29 -0
- package/dist/src/func/func_child.js +85 -0
- package/dist/src/func/func_grid.d.ts +48 -0
- package/dist/src/func/func_grid.js +318 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.js +63 -0
- package/dist/src/themes/base_styles.css +52 -0
- package/dist/src/themes/grid.css +65 -0
- package/dist/src/views/DataGrid.d.ts +80 -0
- package/dist/src/views/DataGrid.js +377 -0
- package/dist/src/views/index.d.ts +3 -0
- package/dist/src/views/index.js +22 -0
- package/package.json +1 -1
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
get_row_id: true,
|
|
8
|
+
set_row_id: true,
|
|
9
|
+
get_col_name: true,
|
|
10
|
+
get_col_header: true
|
|
11
|
+
};
|
|
12
|
+
exports.default = void 0;
|
|
13
|
+
Object.defineProperty(exports, "get_col_header", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () {
|
|
16
|
+
return _func_grid.get_col_header;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "get_col_name", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () {
|
|
22
|
+
return _func_grid.get_col_name;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
Object.defineProperty(exports, "get_row_id", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () {
|
|
28
|
+
return _func_grid.get_row_id;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
Object.defineProperty(exports, "set_row_id", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: function () {
|
|
34
|
+
return _func_grid.set_row_id;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
var _DataGrid = _interopRequireWildcard(require("./views/DataGrid"));
|
|
38
|
+
Object.keys(_DataGrid).forEach(function (key) {
|
|
39
|
+
if (key === "default" || key === "__esModule") return;
|
|
40
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
41
|
+
if (key in exports && exports[key] === _DataGrid[key]) return;
|
|
42
|
+
Object.defineProperty(exports, key, {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function () {
|
|
45
|
+
return _DataGrid[key];
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
var _func_grid = require("./func/func_grid");
|
|
50
|
+
var _example = _interopRequireDefault(require("./example"));
|
|
51
|
+
var _react = _interopRequireDefault(require("react"));
|
|
52
|
+
var _client = _interopRequireDefault(require("react-dom/client"));
|
|
53
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
54
|
+
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); }
|
|
55
|
+
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; }
|
|
56
|
+
/* -------------------------------------------------------------------------- */
|
|
57
|
+
//
|
|
58
|
+
var _default = exports.default = _DataGrid.default;
|
|
59
|
+
const testroot = document.getElementById('testroot');
|
|
60
|
+
if (testroot) {
|
|
61
|
+
const root = _client.default.createRoot(document.getElementById('testroot'));
|
|
62
|
+
root.render(_react.default.createElement(_example.default, null));
|
|
63
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
.azgrid-container {
|
|
2
|
+
height: 100%;
|
|
3
|
+
width: 100%;
|
|
4
|
+
}
|
|
5
|
+
.azgrid-borderbox {
|
|
6
|
+
box-sizing: border-box;
|
|
7
|
+
}
|
|
8
|
+
.azgrid-filler {
|
|
9
|
+
height: 100%;
|
|
10
|
+
width: 100%;
|
|
11
|
+
}
|
|
12
|
+
.azgrid-nooverflow {
|
|
13
|
+
overflow: hidden;
|
|
14
|
+
}
|
|
15
|
+
.azgrid-flexed {
|
|
16
|
+
flex: 1;
|
|
17
|
+
}
|
|
18
|
+
.azgrid-flexlayout {
|
|
19
|
+
display: flex;
|
|
20
|
+
flex-direction: column;
|
|
21
|
+
}
|
|
22
|
+
.azgrid-testborder {
|
|
23
|
+
border: 3px solid red;
|
|
24
|
+
}
|
|
25
|
+
.azgrid-pad50px {
|
|
26
|
+
padding: 50px;
|
|
27
|
+
}
|
|
28
|
+
.azgrid-nopad {
|
|
29
|
+
padding: 0;
|
|
30
|
+
}
|
|
31
|
+
.azgrid-nomargin {
|
|
32
|
+
margin: 0;
|
|
33
|
+
}
|
|
34
|
+
.azgrid-delayedresize {
|
|
35
|
+
transition-property: width, height;
|
|
36
|
+
transition-delay: 200ms;
|
|
37
|
+
transition-duration: 0ms;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.azgrid-searcharea {
|
|
41
|
+
margin: 5px;
|
|
42
|
+
font-size: large;
|
|
43
|
+
}
|
|
44
|
+
.azgrid-searcharea label {
|
|
45
|
+
gap: 5px;
|
|
46
|
+
display: flex;
|
|
47
|
+
align-items: center;
|
|
48
|
+
}
|
|
49
|
+
.azgrid-searcharea label input {
|
|
50
|
+
padding: 5px;
|
|
51
|
+
font-size: large;
|
|
52
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
.InovuaReactDataGrid {
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
z-index: 1000;
|
|
5
|
+
font-family: 'Nunito Sans', 'Iran Sans', sans-serif;
|
|
6
|
+
}
|
|
7
|
+
.InovuaReactDataGrid--theme-amber-dark {
|
|
8
|
+
--grid-bg: #313943;
|
|
9
|
+
--grid-fg:#c5cae9;
|
|
10
|
+
--grid-fg-hover:#ececec;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.InovuaReactDataGrid--theme-default-light {
|
|
14
|
+
--grid-bg: #fff;
|
|
15
|
+
--grid-fg:#1e1e1e;
|
|
16
|
+
--grid-fg-hover:#000000;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.InovuaReactDataGrid__row{
|
|
20
|
+
color:var(--grid-fg);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
/* --------------------------- selected row color --------------------------- */
|
|
27
|
+
.InovuaReactDataGrid
|
|
28
|
+
.InovuaReactDataGrid__row--active
|
|
29
|
+
.InovuaReactDataGrid__cell:not(.InovuaReactDataGrid__cell--no-background),
|
|
30
|
+
.InovuaReactDataGrid
|
|
31
|
+
.InovuaReactDataGrid__row--active.InovuaReactDataGrid__row--even
|
|
32
|
+
.InovuaReactDataGrid__cell:not(.InovuaReactDataGrid__cell--no-background),
|
|
33
|
+
.InovuaReactDataGrid
|
|
34
|
+
.InovuaReactDataGrid__row--active.InovuaReactDataGrid__row--odd
|
|
35
|
+
.InovuaReactDataGrid__cell:not(.InovuaReactDataGrid__cell--no-background) {
|
|
36
|
+
color: var(--grid-fg-hover);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.inovua-react-toolkit-text-input {
|
|
40
|
+
font-family: inherit;
|
|
41
|
+
}
|
|
42
|
+
.inovua-react-toolkit-text-input input {
|
|
43
|
+
font-family: inherit;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
.InovuaReactDataGrid__cell .InovuaReactDataGrid__cell__content {
|
|
49
|
+
height: 100%;
|
|
50
|
+
display: flex;
|
|
51
|
+
align-items: center;
|
|
52
|
+
}
|
|
53
|
+
.InovuaReactDataGrid__column-header__content {
|
|
54
|
+
text-overflow: clip;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.InovuaReactDataGrid__row.deleted:after {
|
|
58
|
+
position: absolute;
|
|
59
|
+
content: '';
|
|
60
|
+
left: 5px;
|
|
61
|
+
top: 50%;
|
|
62
|
+
right: 5px;
|
|
63
|
+
border-top: 1.5px solid;
|
|
64
|
+
border-color: gray;
|
|
65
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
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, TypeComputedProps } 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
|
+
export type CustomColumnDefinition = {
|
|
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?: React.MutableRefObject<TypeComputedProps>;
|
|
49
|
+
gridOptions?: AzGridOptions;
|
|
50
|
+
columns?: LooseColumnDefinition[];
|
|
51
|
+
columnExtensions?: Partial<LooseColumnDefinition>;
|
|
52
|
+
editableColumns?: string[];
|
|
53
|
+
leftColumns?: string[];
|
|
54
|
+
rightColumns?: string[];
|
|
55
|
+
customColumns?: CustomColumnDefinition[];
|
|
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
|
+
advancedFilterFields?: string[];
|
|
72
|
+
loading?: boolean;
|
|
73
|
+
dark?: boolean;
|
|
74
|
+
delayedSize?: boolean;
|
|
75
|
+
allowChildRows?: boolean;
|
|
76
|
+
looseCacheCheck?: boolean;
|
|
77
|
+
className?: string;
|
|
78
|
+
};
|
|
79
|
+
export declare function AzGrid(props: AzGridProps): React.JSX.Element;
|
|
80
|
+
export default AzGrid;
|
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.AzGrid = AzGrid;
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
require("@inovua/reactdatagrid-enterprise/index.css");
|
|
9
|
+
require("@inovua/reactdatagrid-enterprise/theme/default-dark.css");
|
|
10
|
+
require("@inovua/reactdatagrid-enterprise/theme/amber-dark.css");
|
|
11
|
+
require("../themes/base_styles.css");
|
|
12
|
+
require("../themes/grid.css");
|
|
13
|
+
var _func_grid = require("../func/func_grid");
|
|
14
|
+
var _controls = require("@azrico/controls");
|
|
15
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
16
|
+
var _func_child = require("../func/func_child");
|
|
17
|
+
var _object = require("@azrico/object");
|
|
18
|
+
var _reactdatagridEnterprise = _interopRequireDefault(require("@inovua/reactdatagrid-enterprise"));
|
|
19
|
+
var _clsx = _interopRequireDefault(require("clsx"));
|
|
20
|
+
var _reactUseSize = require("react-use-size");
|
|
21
|
+
var _lodash = _interopRequireDefault(require("lodash.debounce"));
|
|
22
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
+
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); }
|
|
24
|
+
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; }
|
|
25
|
+
/* -------------------------------------------------------------------------- */
|
|
26
|
+
const defaultOptions = {
|
|
27
|
+
//filterTypes: defaultfilterTypes,
|
|
28
|
+
remoteFilter: false,
|
|
29
|
+
remoteSort: false,
|
|
30
|
+
editStartEvent: 'click',
|
|
31
|
+
rowReorderColumn: false,
|
|
32
|
+
resizable: true,
|
|
33
|
+
columnUserSelect: true,
|
|
34
|
+
rowIndexColumn: true,
|
|
35
|
+
rowHeight: 35
|
|
36
|
+
};
|
|
37
|
+
const forcedOptions = {
|
|
38
|
+
idProperty: '__table_id',
|
|
39
|
+
nodesProperty: '__children'
|
|
40
|
+
};
|
|
41
|
+
const dynamic_option_names = ['selected', 'cellSelection', 'loading', 'limit', 'skip'];
|
|
42
|
+
/* -------------------------------------------------------------------------- */
|
|
43
|
+
function AzGrid(props) {
|
|
44
|
+
const gridRefBackup = _react.default.useRef(null);
|
|
45
|
+
const gridRef = props.gridRef || gridRefBackup;
|
|
46
|
+
/* -------------------------------------------------------------------------- */
|
|
47
|
+
/* Columns */
|
|
48
|
+
/* -------------------------------------------------------------------------- */
|
|
49
|
+
const cached_columns = _react.default.useMemo(() => {
|
|
50
|
+
return (0, _func_grid.ApplyColumnData)(props);
|
|
51
|
+
}, [props.columns, props.leftColumns, props.rightColumns, props.editableColumns, props.columnExtensions, props.customColumns]);
|
|
52
|
+
/* -------------------------------------------------------------------------- */
|
|
53
|
+
/* Row changes */
|
|
54
|
+
/* -------------------------------------------------------------------------- */
|
|
55
|
+
const cached_data = _react.default.useRef();
|
|
56
|
+
const last_cache_info = _react.default.useRef();
|
|
57
|
+
const dataSource = _react.default.useCallback(async dt => {
|
|
58
|
+
return await (0, _func_grid.ApplyDataSource)(props.dataSource, {
|
|
59
|
+
skip: dt === null || dt === void 0 ? void 0 : dt.skip,
|
|
60
|
+
limit: dt === null || dt === void 0 ? void 0 : dt.limit,
|
|
61
|
+
cached_data: cached_data,
|
|
62
|
+
last_cache_info: last_cache_info
|
|
63
|
+
});
|
|
64
|
+
}, [props.dataSource]);
|
|
65
|
+
const base_gridOptions = _react.default.useMemo(() => {
|
|
66
|
+
const firstcolumn = cached_columns[0];
|
|
67
|
+
const licenseKey = props.licenseKey || (0, _func_grid.get_default_key)();
|
|
68
|
+
const events = {
|
|
69
|
+
onSkipChange: props.onSkipChange,
|
|
70
|
+
onLimitChange: props.onLimitChange,
|
|
71
|
+
onEditComplete: props.onEditComplete
|
|
72
|
+
};
|
|
73
|
+
const extra_ops = {
|
|
74
|
+
onSelectionChange: props.onSelectionChange,
|
|
75
|
+
onCellSelectionChange: props.onCellSelectionChange,
|
|
76
|
+
licenseKey: licenseKey,
|
|
77
|
+
editable: props.editable,
|
|
78
|
+
treeColumn: props.allowChildRows ? firstcolumn.name : undefined,
|
|
79
|
+
renderRowDetails: props.RowDetail,
|
|
80
|
+
theme: props.dark ? 'amber-dark' : 'default-light'
|
|
81
|
+
};
|
|
82
|
+
return {
|
|
83
|
+
...defaultOptions,
|
|
84
|
+
...events,
|
|
85
|
+
...extra_ops
|
|
86
|
+
};
|
|
87
|
+
}, [cached_columns, props.allowChildRows, props.editable, props.RowDetail, props.onEditComplete]);
|
|
88
|
+
const static_gridOptions = _react.default.useMemo(() => {
|
|
89
|
+
const finalres = {
|
|
90
|
+
...base_gridOptions,
|
|
91
|
+
...props.gridOptions,
|
|
92
|
+
...forcedOptions
|
|
93
|
+
};
|
|
94
|
+
//append filter types instead of replacing it
|
|
95
|
+
if (finalres.filterTypes) finalres.filterTypes = Object.assign({}, _reactdatagridEnterprise.default.defaultProps.filterTypes, finalres.filterTypes);
|
|
96
|
+
return finalres;
|
|
97
|
+
}, [props.gridOptions, base_gridOptions, forcedOptions]);
|
|
98
|
+
const dynamic_gridOptions = _react.default.useMemo(() => {
|
|
99
|
+
const res = {};
|
|
100
|
+
dynamic_option_names.map(r => {
|
|
101
|
+
res[r] = props[r];
|
|
102
|
+
});
|
|
103
|
+
return res;
|
|
104
|
+
}, dynamic_option_names.map(r => props[r]));
|
|
105
|
+
return _react.default.createElement(DataGridEventsWrapper, {
|
|
106
|
+
...props,
|
|
107
|
+
gridRef: gridRef,
|
|
108
|
+
static_gridOptions: static_gridOptions,
|
|
109
|
+
dynamic_gridOptions: dynamic_gridOptions,
|
|
110
|
+
columns: cached_columns,
|
|
111
|
+
dataSource: dataSource,
|
|
112
|
+
highlightedRow: props.highlightedRow
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
/* -------------------------------------------------------------------------- */
|
|
116
|
+
/**
|
|
117
|
+
* Wrapper for menu events
|
|
118
|
+
* @param props
|
|
119
|
+
* @returns
|
|
120
|
+
*/
|
|
121
|
+
function DataGridEventsWrapper(props) {
|
|
122
|
+
/* -------------------------------------------------------------------------- */
|
|
123
|
+
const click_data = _react.default.useRef(null);
|
|
124
|
+
const [menuAnchorEl, set_menuAnchorEl] = _react.default.useState(null);
|
|
125
|
+
const [menuRow, set_menuRow] = _react.default.useState(null);
|
|
126
|
+
/* -------------------------------------------------------------------------- */
|
|
127
|
+
/* refresh functions */
|
|
128
|
+
/* -------------------------------------------------------------------------- */
|
|
129
|
+
const refreshColumn = _react.default.useCallback(col => {
|
|
130
|
+
const dt = props.gridRef.current.ungroupedData;
|
|
131
|
+
for (let index = 0; index < dt.length; index++) {
|
|
132
|
+
props.gridRef.current.setItemPropertyAt(index, col, dt[index][col]);
|
|
133
|
+
}
|
|
134
|
+
}, [props.gridRef.current]);
|
|
135
|
+
const refresh = _react.default.useCallback(() => {
|
|
136
|
+
const dt = props.gridRef.current.ungroupedData;
|
|
137
|
+
for (let index = 0; index < dt.length; index++) {
|
|
138
|
+
props.gridRef.current.setItemAt(index, {}, {
|
|
139
|
+
replace: false
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
}, [props.gridRef.current]);
|
|
143
|
+
_react.default.useEffect(() => {
|
|
144
|
+
if (!props.gridRef.current) return;
|
|
145
|
+
props.gridRef.current['refresh'] = refresh;
|
|
146
|
+
props.gridRef.current['refreshColumn'] = refreshColumn;
|
|
147
|
+
}, [props.gridRef.current, props.dataSource, refresh, refreshColumn]);
|
|
148
|
+
/* -------------------------------------------------------------------------- */
|
|
149
|
+
/* events */
|
|
150
|
+
/* -------------------------------------------------------------------------- */
|
|
151
|
+
const onRowClick = _react.default.useCallback((rowProps, event) => {
|
|
152
|
+
const nowDate = Date.now();
|
|
153
|
+
const lastclick = click_data.current[(0, _func_grid.get_row_id)(rowProps)];
|
|
154
|
+
if (lastclick) {
|
|
155
|
+
const diffTime = Math.abs(nowDate - lastclick);
|
|
156
|
+
if (diffTime < 400) {
|
|
157
|
+
click_data.current[(0, _func_grid.get_row_id)(rowProps)] = null;
|
|
158
|
+
return props.onRowDoubleClick && props.onRowDoubleClick(rowProps.rowIndex, rowProps.data);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
click_data.current[(0, _func_grid.get_row_id)(rowProps)] = nowDate;
|
|
162
|
+
return props.onRowClick && props.onRowClick(rowProps.rowIndex, rowProps.data);
|
|
163
|
+
}, [props.onRowClick, props.onRowDoubleClick]);
|
|
164
|
+
_react.default.useEffect(() => {
|
|
165
|
+
click_data.current = {};
|
|
166
|
+
}, [props.dataSource]);
|
|
167
|
+
/* ------------------------------- ContextMenu ------------------------------ */
|
|
168
|
+
const onRowContextMenu = _react.default.useCallback((rowProps, event) => {
|
|
169
|
+
if (!rowProps || !rowProps.data || _func_child.func_selection.has_selection()) {
|
|
170
|
+
update_menuRow(null, null);
|
|
171
|
+
return true;
|
|
172
|
+
}
|
|
173
|
+
event.preventDefault();
|
|
174
|
+
const realRow = (0, _func_grid.find_realData)(rowProps.dataSourceArray, event.target, rowProps.data);
|
|
175
|
+
const anEl = _func_child.func_selection.getVirtualElement(event.clientX, event.clientY);
|
|
176
|
+
update_menuRow(realRow, anEl);
|
|
177
|
+
return false;
|
|
178
|
+
}, []);
|
|
179
|
+
const update_menuRow = _react.default.useCallback((r = null, el = null) => {
|
|
180
|
+
set_menuRow(r || null);
|
|
181
|
+
set_menuAnchorEl(el || null);
|
|
182
|
+
}, []);
|
|
183
|
+
/* -------------------------------------------------------------------------- */
|
|
184
|
+
const onRenderRow = (0, _react.useCallback)(rowProps => {
|
|
185
|
+
// save the original handlers to be called later
|
|
186
|
+
rowProps['data-row-id'] = (0, _func_grid.get_row_id)(rowProps.data);
|
|
187
|
+
}, []);
|
|
188
|
+
/* -------------------------------------------------------------------------- */
|
|
189
|
+
/**
|
|
190
|
+
* Merge click events into grid options
|
|
191
|
+
*/
|
|
192
|
+
const static_gridOptions = _react.default.useMemo(() => {
|
|
193
|
+
const events = {
|
|
194
|
+
onRowClick: onRowClick,
|
|
195
|
+
onRowContextMenu: onRowContextMenu
|
|
196
|
+
};
|
|
197
|
+
const renderProps = {
|
|
198
|
+
onRenderRow: onRenderRow
|
|
199
|
+
};
|
|
200
|
+
return {
|
|
201
|
+
...props.static_gridOptions,
|
|
202
|
+
...events,
|
|
203
|
+
...renderProps
|
|
204
|
+
};
|
|
205
|
+
}, [props.static_gridOptions]);
|
|
206
|
+
/* -------------------------------------------------------------------------- */
|
|
207
|
+
return _react.default.createElement(_react.default.Fragment, null, _react.default.createElement(_controls.ContextMenu, {
|
|
208
|
+
menuAnchorEl: menuAnchorEl,
|
|
209
|
+
menuRow: menuRow,
|
|
210
|
+
close: update_menuRow,
|
|
211
|
+
dontAutoClose: false,
|
|
212
|
+
menu_items: props.contextMenuItems
|
|
213
|
+
}), props.details_dataSource ? _react.default.createElement(DataGridDetailsWrapper, {
|
|
214
|
+
...props,
|
|
215
|
+
static_gridOptions: static_gridOptions
|
|
216
|
+
}) : _react.default.createElement(DataGridSizeWrapper, {
|
|
217
|
+
...props,
|
|
218
|
+
static_gridOptions: static_gridOptions
|
|
219
|
+
}));
|
|
220
|
+
}
|
|
221
|
+
function DataGridDetailsWrapper(props) {
|
|
222
|
+
const cached_details_columns = _react.default.useMemo(() => {
|
|
223
|
+
return (0, _func_grid.ApplyColumnData)(props.details_columns);
|
|
224
|
+
}, [props.details_columns]);
|
|
225
|
+
const cached_data = _react.default.useRef();
|
|
226
|
+
const last_cache_info = _react.default.useRef();
|
|
227
|
+
const details_dataSource = _react.default.useCallback(async dt => {
|
|
228
|
+
const res = await (0, _func_grid.ApplyDataSource)(props.details_dataSource, {
|
|
229
|
+
skip: dt.skip,
|
|
230
|
+
limit: dt.limit,
|
|
231
|
+
cached_data: cached_data,
|
|
232
|
+
last_cache_info: last_cache_info
|
|
233
|
+
});
|
|
234
|
+
return res;
|
|
235
|
+
}, [props.details_dataSource]);
|
|
236
|
+
const renderDetailsGrid = ({
|
|
237
|
+
data
|
|
238
|
+
}) => {
|
|
239
|
+
return _react.default.createElement(_reactdatagridEnterprise.default, {
|
|
240
|
+
defaultFilterValue: props.details_filter,
|
|
241
|
+
dataSource: details_dataSource,
|
|
242
|
+
columns: cached_details_columns
|
|
243
|
+
});
|
|
244
|
+
};
|
|
245
|
+
/**
|
|
246
|
+
* Merge details into grid
|
|
247
|
+
*/
|
|
248
|
+
const static_gridOptions = _react.default.useMemo(() => {
|
|
249
|
+
const finalresult = props.static_gridOptions || {};
|
|
250
|
+
finalresult['renderDetailsGrid'] = renderDetailsGrid;
|
|
251
|
+
return finalresult;
|
|
252
|
+
}, [props.static_gridOptions]);
|
|
253
|
+
return _react.default.createElement(DataGridSizeWrapper, {
|
|
254
|
+
...props,
|
|
255
|
+
static_gridOptions: static_gridOptions
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
function DataGridSizeWrapper(props) {
|
|
259
|
+
if (props.delayedSize) {
|
|
260
|
+
return _react.default.createElement(DataGridDelayedSizeWrapper, {
|
|
261
|
+
...props
|
|
262
|
+
});
|
|
263
|
+
} else {
|
|
264
|
+
return _react.default.createElement(DataGridNormalSizeWrapper, {
|
|
265
|
+
...props
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
/* -------------------------------------------------------------------------- */
|
|
270
|
+
function DataGridNormalSizeWrapper(props) {
|
|
271
|
+
return props.advancedFilterFields ? _react.default.createElement(DataGridSearchWrapper, {
|
|
272
|
+
...props
|
|
273
|
+
}) : _react.default.createElement(DataGridCore, {
|
|
274
|
+
...props
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
function DataGridDelayedSizeWrapper(props) {
|
|
278
|
+
const {
|
|
279
|
+
ref,
|
|
280
|
+
height,
|
|
281
|
+
width
|
|
282
|
+
} = (0, _reactUseSize.useComponentSize)();
|
|
283
|
+
return _react.default.createElement("div", {
|
|
284
|
+
ref: ref,
|
|
285
|
+
className: 'azgrid-filler azgrid-nooverflow '
|
|
286
|
+
}, _react.default.createElement("div", {
|
|
287
|
+
className: 'azgrid-delayedresize azgrid-flexlayout',
|
|
288
|
+
style: {
|
|
289
|
+
height: height,
|
|
290
|
+
width: width
|
|
291
|
+
}
|
|
292
|
+
}, props.advancedFilterFields ? _react.default.createElement(DataGridSearchWrapper, {
|
|
293
|
+
...props
|
|
294
|
+
}) : _react.default.createElement(DataGridCore, {
|
|
295
|
+
...props
|
|
296
|
+
})));
|
|
297
|
+
}
|
|
298
|
+
function DataGridSearchWrapper(props) {
|
|
299
|
+
const [search, set_search] = _react.default.useState('');
|
|
300
|
+
const [filteredData, set_filteredData] = _react.default.useState([]);
|
|
301
|
+
const currentSearch = _react.default.useRef('');
|
|
302
|
+
const currentDS = _react.default.useRef([]);
|
|
303
|
+
const try_search = _react.default.useCallback((0, _lodash.default)(() => {
|
|
304
|
+
if (!Array.isArray(currentDS.current)) {
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
let newData = [];
|
|
308
|
+
if (currentSearch.current) {
|
|
309
|
+
const visibleColumns = props.gridRef.current.visibleColumns;
|
|
310
|
+
const columns_to_search = (0, _object.array_intersection)(props.advancedFilterFields || [], visibleColumns.map(r => r.id));
|
|
311
|
+
const lowerSearchText = currentSearch.current.toLowerCase().trim();
|
|
312
|
+
if (!lowerSearchText || columns_to_search.length === 0) newData = currentDS.current;else {
|
|
313
|
+
newData = currentDS.current.filter(p => {
|
|
314
|
+
for (let index = 0; index < columns_to_search.length; index++) {
|
|
315
|
+
const col = columns_to_search[index];
|
|
316
|
+
const v = (p[col] + '').toLowerCase(); //value of column
|
|
317
|
+
if (v && v.indexOf(lowerSearchText) != -1) {
|
|
318
|
+
//if one column is matching then the row is a match
|
|
319
|
+
return true;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
return false;
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
} else newData = currentDS.current;
|
|
326
|
+
set_filteredData(newData);
|
|
327
|
+
}, 1000), []);
|
|
328
|
+
_react.default.useEffect(() => {
|
|
329
|
+
(0, _object.fn_eval)(props.dataSource).then(r => {
|
|
330
|
+
currentDS.current = typeof r === 'object' ? r.data || r : r;
|
|
331
|
+
searchIfNeeded();
|
|
332
|
+
});
|
|
333
|
+
}, [props.dataSource]);
|
|
334
|
+
_react.default.useEffect(() => {
|
|
335
|
+
currentSearch.current = search;
|
|
336
|
+
searchIfNeeded();
|
|
337
|
+
}, [search]);
|
|
338
|
+
function searchIfNeeded() {
|
|
339
|
+
if (!search) {
|
|
340
|
+
set_filteredData(props.dataSource);
|
|
341
|
+
} else try_search();
|
|
342
|
+
}
|
|
343
|
+
return _react.default.createElement("div", {
|
|
344
|
+
className: 'azgrid-flexed azgrid-flexlayout azgrid-nooverflow'
|
|
345
|
+
}, _react.default.createElement("form", {
|
|
346
|
+
className: 'azgrid-searcharea'
|
|
347
|
+
}, _react.default.createElement("label", null, "Search", _react.default.createElement("input", {
|
|
348
|
+
type: "text",
|
|
349
|
+
name: "name",
|
|
350
|
+
value: search,
|
|
351
|
+
onChange: e => set_search(e.target.value)
|
|
352
|
+
}))), _react.default.createElement(DataGridCore, {
|
|
353
|
+
...props,
|
|
354
|
+
dataSource: filteredData
|
|
355
|
+
}));
|
|
356
|
+
}
|
|
357
|
+
function DataGridCore(props) {
|
|
358
|
+
return _react.default.createElement("div", {
|
|
359
|
+
className: (0, _clsx.default)(props.className, 'azgrid-flexed', 'azgrid-flexlayout')
|
|
360
|
+
}, _react.default.createElement(_reactdatagridEnterprise.default, {
|
|
361
|
+
...props.static_gridOptions,
|
|
362
|
+
...props.dynamic_gridOptions,
|
|
363
|
+
rowIndexColumn: true,
|
|
364
|
+
handle: ref => {
|
|
365
|
+
if (ref) props.gridRef.current = ref.current;
|
|
366
|
+
},
|
|
367
|
+
className: 'azgrid-flexed',
|
|
368
|
+
columns: props.columns,
|
|
369
|
+
dataSource: props.dataSource
|
|
370
|
+
}), props.children);
|
|
371
|
+
}
|
|
372
|
+
/* -------------------------------------------------------------------------- */
|
|
373
|
+
/* -------------------------------------------------------------------------- */
|
|
374
|
+
/* -------------------------------------------------------------------------- */
|
|
375
|
+
/* -------------------------------------------------------------------------- */
|
|
376
|
+
/* -------------------------------------------------------------------------- */
|
|
377
|
+
var _default = exports.default = AzGrid;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exportNames = {};
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _DataGrid = _interopRequireWildcard(require("./DataGrid"));
|
|
9
|
+
Object.keys(_DataGrid).forEach(function (key) {
|
|
10
|
+
if (key === "default" || key === "__esModule") return;
|
|
11
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
12
|
+
if (key in exports && exports[key] === _DataGrid[key]) return;
|
|
13
|
+
Object.defineProperty(exports, key, {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () {
|
|
16
|
+
return _DataGrid[key];
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
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); }
|
|
21
|
+
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; }
|
|
22
|
+
var _default = exports.default = _DataGrid.default;
|