@azrico/reactgrid 1.0.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/.babelrc +13 -0
- package/README.md +3 -0
- package/config/config-overrides.js +68 -0
- package/config/file-mock.js +5 -0
- package/config/jest.config.base.js +22 -0
- package/config/jest.setup.js +32 -0
- package/config/style-mock.js +5 -0
- package/config/tsconfig.base.json +31 -0
- package/package.json +61 -0
- package/public/index.html +19 -0
- package/public/manifest.json +9 -0
- package/src/example.tsx +63 -0
- package/src/index.tsx +11 -0
- package/src/views/DataGrid.tsx +337 -0
- package/src/views/func/helpers.ts +65 -0
- package/src/views/index.ts +4 -0
- package/src/views/theme/styles.css +26 -0
- package/tsconfig.json +74 -0
- package/yarn-error.log +9253 -0
package/.babelrc
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
const path = require("path");
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const {
|
|
5
|
+
override,
|
|
6
|
+
babelInclude,
|
|
7
|
+
addWebpackAlias,
|
|
8
|
+
useBabelRc,
|
|
9
|
+
addWebpackModuleRule,
|
|
10
|
+
// addDecoratorsLegacy,
|
|
11
|
+
} = require("customize-cra");
|
|
12
|
+
// const rewireReactHotLoader = require("react-app-rewire-hot-loader");
|
|
13
|
+
|
|
14
|
+
module.exports = (config, env) => {
|
|
15
|
+
/* -------------------------------------------------------------------------- */
|
|
16
|
+
let rootdir = path.resolve("..");
|
|
17
|
+
if (!path.dirname(rootdir).startsWith("amadeus")) {
|
|
18
|
+
rootdir = path.resolve("../..");
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const folders = ["packages", "packages_extra"];
|
|
22
|
+
const result_paths = [];
|
|
23
|
+
|
|
24
|
+
for (let index = 0; index < folders.length; index++) {
|
|
25
|
+
const current_folder = folders[index];
|
|
26
|
+
|
|
27
|
+
const packageFolders = fs.readdirSync(
|
|
28
|
+
path.resolve(`${rootdir}/${current_folder}`),
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
const packageFiles = packageFolders.map((fld) =>
|
|
32
|
+
fs.realpathSync(
|
|
33
|
+
path.resolve(`${rootdir}/${current_folder}/${fld}/src`),
|
|
34
|
+
),
|
|
35
|
+
);
|
|
36
|
+
result_paths.push(...packageFiles);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
config = Object.assign(
|
|
40
|
+
// rewireReactHotLoader(config),
|
|
41
|
+
override(
|
|
42
|
+
// addWebpackAlias({
|
|
43
|
+
// "react-dom": "@hot-loader/react-dom",
|
|
44
|
+
// }),
|
|
45
|
+
|
|
46
|
+
addWebpackModuleRule({
|
|
47
|
+
test: /\.html$/i,
|
|
48
|
+
loader: "html-loader",
|
|
49
|
+
}),
|
|
50
|
+
addWebpackModuleRule({
|
|
51
|
+
test: /\.css$/i,
|
|
52
|
+
loader: "raw-loader",
|
|
53
|
+
}),
|
|
54
|
+
addWebpackAlias({
|
|
55
|
+
stream: "stream-browserify",
|
|
56
|
+
path: "path-browserify",
|
|
57
|
+
"react-native": "react-native-web",
|
|
58
|
+
cldr: "cldrjs/dist/cldr",
|
|
59
|
+
cldr$: "cldrjs",
|
|
60
|
+
}),
|
|
61
|
+
useBabelRc(),
|
|
62
|
+
babelInclude([path.resolve("src"), ...result_paths]),
|
|
63
|
+
// addDecoratorsLegacy(),
|
|
64
|
+
)(config, env),
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
return config;
|
|
68
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
rootDir: ".",
|
|
3
|
+
preset: "react-native",
|
|
4
|
+
moduleNameMapper: {
|
|
5
|
+
"\\.(css|less|scss|sass)$": "identity-obj-proxy",
|
|
6
|
+
"^@/(.*)$": "<rootDir>/$1",
|
|
7
|
+
},
|
|
8
|
+
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
|
|
9
|
+
testMatch: ["./**/__tests__/**/*.(js|ts|tsx)"],
|
|
10
|
+
testPathIgnorePatterns: ["\\.snap$", "<rootDir>/node_modules/"],
|
|
11
|
+
transformIgnorePatterns: ["node_modules/?!(static-container)"],
|
|
12
|
+
cacheDirectory: ".jest/cache",
|
|
13
|
+
globals: {
|
|
14
|
+
"ts-jest": {
|
|
15
|
+
isolatedModules: true,
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
clearMocks: true,
|
|
19
|
+
//collectCoverageFrom: ["src/**/*.{ts,tsx}", "!**/node_modules/**"],
|
|
20
|
+
testEnvironment: "jsdom",
|
|
21
|
+
setupFilesAfterEnv: ["../../config/jest.setup.js"],
|
|
22
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import mockAsyncStorage from "@react-native-async-storage/async-storage/jest/async-storage-mock";
|
|
2
|
+
|
|
3
|
+
jest.mock("@react-native-async-storage/async-storage", () => mockAsyncStorage);
|
|
4
|
+
|
|
5
|
+
jest.mock("react", () => {
|
|
6
|
+
const React = jest.requireActual("react");
|
|
7
|
+
|
|
8
|
+
const Suspense = ({children}) => <div>{children}</div>;
|
|
9
|
+
Suspense.displayName = "Suspense";
|
|
10
|
+
|
|
11
|
+
const lazy = React.lazy(() =>
|
|
12
|
+
Promise.resolve().then(() => ({
|
|
13
|
+
default() {
|
|
14
|
+
return null;
|
|
15
|
+
},
|
|
16
|
+
})),
|
|
17
|
+
);
|
|
18
|
+
lazy.displayName = "lazy";
|
|
19
|
+
|
|
20
|
+
return {
|
|
21
|
+
...React,
|
|
22
|
+
//lazy,
|
|
23
|
+
//Suspense,
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const Enzyme = require("enzyme");
|
|
28
|
+
const EnzymeAdapter = require("@wojtekmaj/enzyme-adapter-react-17");
|
|
29
|
+
|
|
30
|
+
Enzyme.configure({
|
|
31
|
+
adapter: new EnzymeAdapter(),
|
|
32
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"allowSyntheticDefaultImports": true,
|
|
4
|
+
"esModuleInterop": true,
|
|
5
|
+
"lib": ["ES2021", "dom"],
|
|
6
|
+
"moduleResolution": "node",
|
|
7
|
+
"strict": true,
|
|
8
|
+
"resolveJsonModule": true,
|
|
9
|
+
"isolatedModules": false,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"noImplicitAny": false,
|
|
12
|
+
"allowJs": true,
|
|
13
|
+
"sourceMap": true,
|
|
14
|
+
"module": "esnext",
|
|
15
|
+
"jsx": "react",
|
|
16
|
+
"target": "es6",
|
|
17
|
+
|
|
18
|
+
"baseUrl": ".",
|
|
19
|
+
"paths": {
|
|
20
|
+
//"globalize": ["node_modules/globalize/dist/globalize"],
|
|
21
|
+
//"globalize/*": ["node_modules/globalize/dist/globalize/*"],
|
|
22
|
+
//"cldr": ["node_modules/cldrjs/dist/cldr"],
|
|
23
|
+
//"cldr/*": ["node_modules/cldrjs/dist/cldr/*"],
|
|
24
|
+
|
|
25
|
+
"@amadeusproject/*": ["packages/*"],
|
|
26
|
+
"@amadeusproject_extra/*": ["packages_extra/*"],
|
|
27
|
+
"@amadeusproject_main/*": ["packages_main/*"]
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"exclude": ["**/node_modules", "**/dist"]
|
|
31
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@azrico/reactgrid",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"main": "src/test",
|
|
5
|
+
"description": "React Datagrid",
|
|
6
|
+
"author": "Azrideus <MehrdadTavangar@gmail.com>",
|
|
7
|
+
"homepage": ".",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"start": "react-scripts start",
|
|
10
|
+
"build": "tsc && babel dist --out-dir dist",
|
|
11
|
+
"test": "rem",
|
|
12
|
+
"eject": "react-scripts eject",
|
|
13
|
+
"deploy": "gh-pages -d build"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@azrico/controls": "1.3.0",
|
|
17
|
+
"@emotion/react": "^11.9.3",
|
|
18
|
+
"@emotion/styled": "^11.9.3",
|
|
19
|
+
"@inovua/reactdatagrid-enterprise": "^5.6.1",
|
|
20
|
+
"clsx": "^1.2.1",
|
|
21
|
+
"react": "^18.2.0",
|
|
22
|
+
"react-resize-detector": "^7.1.2"
|
|
23
|
+
},
|
|
24
|
+
"config-overrides-path": "../../config/config-overrides.js",
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@babel/cli": "^7.13.14",
|
|
27
|
+
"@babel/core": "^7.13.15",
|
|
28
|
+
"@babel/eslint-parser": "^7.12.17",
|
|
29
|
+
"@babel/node": "^7.13.13",
|
|
30
|
+
"@babel/plugin-proposal-class-properties": "^7.12.13",
|
|
31
|
+
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.14.5",
|
|
32
|
+
"@babel/preset-env": "^7.13.15",
|
|
33
|
+
"@babel/preset-typescript": "^7.14.5",
|
|
34
|
+
"@mui/material": "*",
|
|
35
|
+
"@types/react": "^18.0.25",
|
|
36
|
+
"@types/react-dom": "^18.0.8",
|
|
37
|
+
"react-dom": "^18.2.0",
|
|
38
|
+
"react-scripts": "^5.0.1",
|
|
39
|
+
"typescript": "^4.8.4"
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"@azrico/controls": "*",
|
|
43
|
+
"@emotion/react": "*",
|
|
44
|
+
"@emotion/styled": "*",
|
|
45
|
+
"clsx": "*",
|
|
46
|
+
"react": "*",
|
|
47
|
+
"react-resize-detector": "*"
|
|
48
|
+
},
|
|
49
|
+
"browserslist": {
|
|
50
|
+
"production": [
|
|
51
|
+
">0.2%",
|
|
52
|
+
"not dead",
|
|
53
|
+
"not op_mini all"
|
|
54
|
+
],
|
|
55
|
+
"development": [
|
|
56
|
+
"last 1 chrome version",
|
|
57
|
+
"last 1 firefox version",
|
|
58
|
+
"last 1 safari version"
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en" class="azgrid-filler azgrid-borderbox azgrid-nopad azgrid-nomargin">
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="utf-8">
|
|
6
|
+
<meta name="viewport" content="width=device-width, user-scalable=no">
|
|
7
|
+
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
|
|
8
|
+
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
|
|
9
|
+
<title>Azriel's React Grid</title>
|
|
10
|
+
</head>
|
|
11
|
+
|
|
12
|
+
<body class="azgrid-nomargin azgrid-filler azgrid-borderbox">
|
|
13
|
+
<noscript>
|
|
14
|
+
You need to enable JavaScript to run this app.
|
|
15
|
+
</noscript>
|
|
16
|
+
<div id="root" class="azgrid-filler azgrid-testborder azgrid-borderbox azgrid-nopad azgrid-nomargin"></div>
|
|
17
|
+
</body>
|
|
18
|
+
|
|
19
|
+
</html>
|
package/src/example.tsx
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
export * from './views/DataGrid';
|
|
2
|
+
|
|
3
|
+
import AzGrid from './views/DataGrid';
|
|
4
|
+
import { LooseColumnDefinition } from './views/DataGrid';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import ReactDOM from 'react-dom';
|
|
7
|
+
|
|
8
|
+
const columns: LooseColumnDefinition[] = [
|
|
9
|
+
{ name: 'username', title: 'Username', editor: 'input' },
|
|
10
|
+
{ name: 'job', title: 'Job' },
|
|
11
|
+
{ name: 'age', title: 'Age', editor: 'input' },
|
|
12
|
+
{ title: 'Example', field: 'example', editor: 'input' },
|
|
13
|
+
];
|
|
14
|
+
const leftColumns = ['username', 'row'];
|
|
15
|
+
const customColumns = [
|
|
16
|
+
{
|
|
17
|
+
name: 'job',
|
|
18
|
+
render: () => {
|
|
19
|
+
return <div>test</div>;
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
const contextMenuItems = ['test'];
|
|
25
|
+
function getData() {
|
|
26
|
+
const fd: any[] = [];
|
|
27
|
+
for (let index = 0; index < 5; index++) {
|
|
28
|
+
fd.push({ __table_id: String(index), username: 'user-' + index, age: 20 });
|
|
29
|
+
if (index % 5 == 0) {
|
|
30
|
+
fd.push({ __table_id: 's' + index, __parent__table_id: String(index), username: 'sub-user-' + index, age: 20 });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return fd;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function ExampleGrid() {
|
|
37
|
+
const renderContactsGrid = ({ data }) => {
|
|
38
|
+
return (
|
|
39
|
+
<div>
|
|
40
|
+
<div>{'Test'}</div>
|
|
41
|
+
</div>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
44
|
+
const [selected, setSelected] = React.useState(null);
|
|
45
|
+
const onSelectionChange = React.useCallback(({ selected }) => {
|
|
46
|
+
setSelected(selected);
|
|
47
|
+
}, []);
|
|
48
|
+
return (
|
|
49
|
+
<AzGrid
|
|
50
|
+
dark
|
|
51
|
+
allowChildRows
|
|
52
|
+
onSelectionChange={onSelectionChange}
|
|
53
|
+
selected={selected}
|
|
54
|
+
contextMenuItems={contextMenuItems}
|
|
55
|
+
customColumns={customColumns}
|
|
56
|
+
columns={columns}
|
|
57
|
+
rows={getData()}
|
|
58
|
+
leftColumns={leftColumns}
|
|
59
|
+
gridOptions={{ rowIndexColumn: true, checkboxColumn: true }}
|
|
60
|
+
/>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
export default ExampleGrid;
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './views/DataGrid';
|
|
2
|
+
|
|
3
|
+
import AzGrid from './views/DataGrid';
|
|
4
|
+
import ExampleGrid from './example';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import ReactDOM from 'react-dom/client';
|
|
7
|
+
|
|
8
|
+
export default AzGrid;
|
|
9
|
+
|
|
10
|
+
const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement);
|
|
11
|
+
root.render(<ExampleGrid />);
|