@azrico/reactgrid 1.0.7 → 1.0.9
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.
|
File without changes
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import '@inovua/reactdatagrid-enterprise/index.css';
|
|
2
2
|
import '@inovua/reactdatagrid-enterprise/theme/default-dark.css';
|
|
3
|
+
import '../themes/styles.css';
|
|
3
4
|
import React from 'react';
|
|
4
5
|
import { TypeColumn, TypeDataGridProps, TypeDataSource, TypeRowDetailsInfo, TypeRowProps, TypeRowSelection } from '@inovua/reactdatagrid-community/types';
|
|
5
6
|
import { TypeOnSelectionChangeArg } from '@inovua/reactdatagrid-community/types/TypeDataGridProps';
|
|
@@ -7,6 +7,7 @@ exports.AzGrid = AzGrid;
|
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
require("@inovua/reactdatagrid-enterprise/index.css");
|
|
9
9
|
require("@inovua/reactdatagrid-enterprise/theme/default-dark.css");
|
|
10
|
+
require("../themes/styles.css");
|
|
10
11
|
var _react = _interopRequireDefault(require("react"));
|
|
11
12
|
var _helpers = require("./func/helpers");
|
|
12
13
|
var _controls = require("@azrico/controls");
|
|
@@ -51,7 +52,7 @@ function AzGrid(props) {
|
|
|
51
52
|
};
|
|
52
53
|
if (typeof r === 'object') {
|
|
53
54
|
let final_cl = {
|
|
54
|
-
name: r
|
|
55
|
+
name: get_col_name(r),
|
|
55
56
|
header: r.header || r.title || r.name || '-',
|
|
56
57
|
width: r.width || undefined
|
|
57
58
|
};
|
|
@@ -72,7 +73,7 @@ function AzGrid(props) {
|
|
|
72
73
|
/* ---------------------------- apply extensions ---------------------------- */
|
|
73
74
|
if (mcolExts && Array.isArray(mcolExts)) for (let index = 0; index < mcolExts.length; index++) {
|
|
74
75
|
const ext = mcolExts[index];
|
|
75
|
-
const ext_cl = ext
|
|
76
|
+
const ext_cl = get_col_name(ext);
|
|
76
77
|
const mcol = final_columns.find(s => s.name === ext_cl);
|
|
77
78
|
if (!mcol) continue;
|
|
78
79
|
// if (ext.width) mcol.width = ext.width;
|
|
@@ -81,7 +82,7 @@ function AzGrid(props) {
|
|
|
81
82
|
/* ------------------------------- frozen cols ------------------------------ */
|
|
82
83
|
if (Array.isArray(leftColumns)) {
|
|
83
84
|
for (let index = 0; index < leftColumns.length; index++) {
|
|
84
|
-
const r = leftColumns[index];
|
|
85
|
+
const r = get_col_name(leftColumns[index]);
|
|
85
86
|
const mcol = final_columns.find(s => s.name === r);
|
|
86
87
|
if (mcol) {
|
|
87
88
|
mcol.locked = 'start';
|
|
@@ -90,7 +91,7 @@ function AzGrid(props) {
|
|
|
90
91
|
}
|
|
91
92
|
if (Array.isArray(rightColumns)) {
|
|
92
93
|
for (let index = 0; index < rightColumns.length; index++) {
|
|
93
|
-
const r = rightColumns[index];
|
|
94
|
+
const r = get_col_name(rightColumns[index]);
|
|
94
95
|
const mcol = final_columns.find(s => s.name === r);
|
|
95
96
|
if (mcol) {
|
|
96
97
|
mcol.locked = 'end';
|
|
@@ -100,7 +101,7 @@ function AzGrid(props) {
|
|
|
100
101
|
/* -------------------------------- ediatable ------------------------------- */
|
|
101
102
|
if (Array.isArray(editableColumns)) {
|
|
102
103
|
for (let index = 0; index < editableColumns.length; index++) {
|
|
103
|
-
const r = editableColumns[index];
|
|
104
|
+
const r = get_col_name(editableColumns[index]);
|
|
104
105
|
const mcol = final_columns.find(s => s.name === r);
|
|
105
106
|
if (mcol) {
|
|
106
107
|
// mcol.editor = editorWrapper;
|
|
@@ -113,7 +114,8 @@ function AzGrid(props) {
|
|
|
113
114
|
if (Array.isArray(customColumns)) {
|
|
114
115
|
for (let index = 0; index < customColumns.length; index++) {
|
|
115
116
|
const r = customColumns[index];
|
|
116
|
-
const
|
|
117
|
+
const rn = get_col_name(r);
|
|
118
|
+
const mcol = final_columns.find(s => s.name === rn);
|
|
117
119
|
if (mcol) {
|
|
118
120
|
//@ts-ignore
|
|
119
121
|
mcol.render = r.render;
|
|
@@ -170,7 +172,6 @@ function DataGrid(props) {
|
|
|
170
172
|
const gridRef = _react.default.useRef(null);
|
|
171
173
|
const [menuAnchorEl, set_menuAnchorEl] = _react.default.useState(null);
|
|
172
174
|
const [menuRow, set_menuRow] = _react.default.useState(null);
|
|
173
|
-
const gridID = _react.default.useMemo(() => 'table-' + Date.now().valueOf(), []);
|
|
174
175
|
/* -------------------------------------------------------------------------- */
|
|
175
176
|
/* Create the grid */
|
|
176
177
|
/* -------------------------------------------------------------------------- */
|
|
@@ -249,6 +250,12 @@ function DataGrid(props) {
|
|
|
249
250
|
}));
|
|
250
251
|
}
|
|
251
252
|
/* -------------------------------------------------------------------------- */
|
|
253
|
+
function get_col_name(obj) {
|
|
254
|
+
if (!obj) return 'default';
|
|
255
|
+
if (typeof obj == 'string') return obj;
|
|
256
|
+
if (typeof obj != 'object') return 'default';
|
|
257
|
+
return obj.name || obj.field || obj.key || obj.columnName || 'default';
|
|
258
|
+
}
|
|
252
259
|
function get_default_key() {
|
|
253
260
|
return 'ExpiryDate=2999-01-01,Z=1040577552';
|
|
254
261
|
}
|
package/package.json
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azrico/reactgrid",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"description": "React Datagrid",
|
|
6
6
|
"author": "Azrideus <MehrdadTavangar@gmail.com>",
|
|
7
7
|
"homepage": ".",
|
|
8
8
|
"scripts": {
|
|
9
9
|
"start": "react-scripts start",
|
|
10
|
-
"build": "tsc && babel dist --out-dir dist",
|
|
10
|
+
"build": "tsc && yarn cp_themes && babel dist --out-dir dist",
|
|
11
11
|
"test": "rem",
|
|
12
|
-
"
|
|
13
|
-
"deploy": "gh-pages -d build"
|
|
12
|
+
"cp_themes": "copyfiles ./src/themes/* ./dist/"
|
|
14
13
|
},
|
|
15
14
|
"config-overrides-path": "../../config/config-overrides.js",
|
|
16
15
|
"devDependencies": {
|
package/public/index.html
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<meta name="viewport" content="width=device-width, user-scalable=no">
|
|
7
7
|
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
|
|
8
8
|
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
|
|
9
|
-
|
|
9
|
+
|
|
10
10
|
<title>Azriel's React Grid</title>
|
|
11
11
|
</head>
|
|
12
12
|
|
|
@@ -0,0 +1,26 @@
|
|
|
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-testborder {
|
|
16
|
+
border: 3px solid red;
|
|
17
|
+
}
|
|
18
|
+
.azgrid-pad50px {
|
|
19
|
+
padding: 50px;
|
|
20
|
+
}
|
|
21
|
+
.azgrid-nopad {
|
|
22
|
+
padding: 0;
|
|
23
|
+
}
|
|
24
|
+
.azgrid-nomargin {
|
|
25
|
+
margin: 0;
|
|
26
|
+
}
|
package/src/views/DataGrid.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import '@inovua/reactdatagrid-enterprise/index.css';
|
|
2
2
|
import '@inovua/reactdatagrid-enterprise/theme/default-dark.css';
|
|
3
|
+
import '../themes/styles.css';
|
|
3
4
|
|
|
4
5
|
import React, { useCallback, useState } from 'react';
|
|
5
6
|
import {
|
|
@@ -123,7 +124,7 @@ export function AzGrid(props: AzGridProps) {
|
|
|
123
124
|
if (typeof r === 'string') return { field: r, header: r };
|
|
124
125
|
if (typeof r === 'object') {
|
|
125
126
|
let final_cl: MakeWriteable<ColumnDefinition> = {
|
|
126
|
-
name: r
|
|
127
|
+
name: get_col_name(r),
|
|
127
128
|
header: r.header || r.title || r.name || '-',
|
|
128
129
|
width: r.width || undefined,
|
|
129
130
|
};
|
|
@@ -147,7 +148,7 @@ export function AzGrid(props: AzGridProps) {
|
|
|
147
148
|
if (mcolExts && Array.isArray(mcolExts))
|
|
148
149
|
for (let index = 0; index < mcolExts.length; index++) {
|
|
149
150
|
const ext = mcolExts[index];
|
|
150
|
-
const ext_cl = ext
|
|
151
|
+
const ext_cl = get_col_name(ext);
|
|
151
152
|
const mcol = final_columns.find((s) => s.name === ext_cl);
|
|
152
153
|
if (!mcol) continue;
|
|
153
154
|
// if (ext.width) mcol.width = ext.width;
|
|
@@ -157,7 +158,7 @@ export function AzGrid(props: AzGridProps) {
|
|
|
157
158
|
/* ------------------------------- frozen cols ------------------------------ */
|
|
158
159
|
if (Array.isArray(leftColumns)) {
|
|
159
160
|
for (let index = 0; index < leftColumns.length; index++) {
|
|
160
|
-
const r = leftColumns[index];
|
|
161
|
+
const r = get_col_name(leftColumns[index]);
|
|
161
162
|
const mcol = final_columns.find((s) => s.name === r);
|
|
162
163
|
if (mcol) {
|
|
163
164
|
mcol.locked = 'start';
|
|
@@ -166,7 +167,7 @@ export function AzGrid(props: AzGridProps) {
|
|
|
166
167
|
}
|
|
167
168
|
if (Array.isArray(rightColumns)) {
|
|
168
169
|
for (let index = 0; index < rightColumns.length; index++) {
|
|
169
|
-
const r = rightColumns[index];
|
|
170
|
+
const r = get_col_name(rightColumns[index]);
|
|
170
171
|
const mcol = final_columns.find((s) => s.name === r);
|
|
171
172
|
if (mcol) {
|
|
172
173
|
mcol.locked = 'end';
|
|
@@ -176,7 +177,7 @@ export function AzGrid(props: AzGridProps) {
|
|
|
176
177
|
/* -------------------------------- ediatable ------------------------------- */
|
|
177
178
|
if (Array.isArray(editableColumns)) {
|
|
178
179
|
for (let index = 0; index < editableColumns.length; index++) {
|
|
179
|
-
const r = editableColumns[index];
|
|
180
|
+
const r = get_col_name(editableColumns[index]);
|
|
180
181
|
const mcol = final_columns.find((s) => s.name === r);
|
|
181
182
|
if (mcol) {
|
|
182
183
|
// mcol.editor = editorWrapper;
|
|
@@ -189,7 +190,8 @@ export function AzGrid(props: AzGridProps) {
|
|
|
189
190
|
if (Array.isArray(customColumns)) {
|
|
190
191
|
for (let index = 0; index < customColumns.length; index++) {
|
|
191
192
|
const r = customColumns[index];
|
|
192
|
-
const
|
|
193
|
+
const rn = get_col_name(r);
|
|
194
|
+
const mcol = final_columns.find((s) => s.name === rn);
|
|
193
195
|
if (mcol) {
|
|
194
196
|
//@ts-ignore
|
|
195
197
|
mcol.render = r.render;
|
|
@@ -242,8 +244,6 @@ function DataGrid(props: DataGridProps) {
|
|
|
242
244
|
const [menuAnchorEl, set_menuAnchorEl] = React.useState<any>(null);
|
|
243
245
|
const [menuRow, set_menuRow] = React.useState<any>(null);
|
|
244
246
|
|
|
245
|
-
const gridID = React.useMemo(() => 'table-' + Date.now().valueOf(), []);
|
|
246
|
-
|
|
247
247
|
/* -------------------------------------------------------------------------- */
|
|
248
248
|
/* Create the grid */
|
|
249
249
|
/* -------------------------------------------------------------------------- */
|
|
@@ -316,6 +316,13 @@ function DataGrid(props: DataGridProps) {
|
|
|
316
316
|
);
|
|
317
317
|
}
|
|
318
318
|
/* -------------------------------------------------------------------------- */
|
|
319
|
+
|
|
320
|
+
function get_col_name(obj: any): string {
|
|
321
|
+
if (!obj) return 'default';
|
|
322
|
+
if (typeof obj == 'string') return obj;
|
|
323
|
+
if (typeof obj != 'object') return 'default';
|
|
324
|
+
return obj.name || obj.field || obj.key || obj.columnName || 'default';
|
|
325
|
+
}
|
|
319
326
|
function get_default_key() {
|
|
320
327
|
return 'ExpiryDate=2999-01-01,Z=1040577552';
|
|
321
328
|
}
|